Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11564 from h-kataria/vm_compliance_history_link_fix
Vm compliance history link fix (cherry picked from commit 3a73026) https://bugzilla.redhat.com/show_bug.cgi?id=1382847
- Loading branch information
Showing
2 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
describe ComplianceSummaryHelper do | ||
before do | ||
server = FactoryGirl.build(:miq_server, :id => 0) | ||
@record = FactoryGirl.build(:vm_vmware, :miq_server => server) | ||
@compliance1 = FactoryGirl.build(:compliance) | ||
@compliance2 = FactoryGirl.build(:compliance) | ||
allow_any_instance_of(described_class).to receive(:role_allows?).and_return(true) | ||
end | ||
|
||
context "when @explorer is set" do | ||
before do | ||
allow(controller).to receive(:controller_name).and_return("vm_infra") | ||
allow(controller.class).to receive(:model).and_return(VmOrTemplate) | ||
@explorer = true | ||
end | ||
|
||
it "#textual_compliance_status" do | ||
@record.compliances = [@compliance1] | ||
date = @compliance1.timestamp | ||
expect(helper.textual_compliance_status).to eq(:label => "Status", | ||
:image => "check", | ||
:value => "Compliant as of #{time_ago_in_words(date.in_time_zone(Time.zone)).titleize} Ago", | ||
:title => "Show Details of Compliance Check on #{format_timezone(date)}", | ||
:explorer => true, | ||
:link => "/vm_infra/show?count=1&display=compliance_history") | ||
end | ||
|
||
it "#textual_compliance_history" do | ||
@record.compliances = [@compliance1, @compliance2] | ||
expect(helper.textual_compliance_history).to eq(:label => "History", | ||
:image => "compliance", | ||
:value => "Available", | ||
:explorer => true, | ||
:title => "Show Compliance History of this VM or Template (Last 10 Checks)", | ||
:link => "/vm_infra/show?display=compliance_history") | ||
end | ||
end | ||
|
||
context "for classic screens when @explorer is not set" do | ||
before do | ||
allow(controller).to receive(:controller_name).and_return("host") | ||
allow(controller.class).to receive(:model).and_return(Host) | ||
end | ||
|
||
it "#textual_compliance_status" do | ||
@record.compliances = [@compliance1] | ||
date = @compliance1.timestamp | ||
expect(helper.textual_compliance_status).to eq(:label => "Status", | ||
:image => "check", | ||
:value => "Compliant as of #{time_ago_in_words(date.in_time_zone(Time.zone)).titleize} Ago", | ||
:title => "Show Details of Compliance Check on #{format_timezone(date)}", | ||
:link => "/host/show?count=1&display=compliance_history") | ||
end | ||
|
||
it "#textual_compliance_history" do | ||
@record.compliances = [@compliance1, @compliance2] | ||
expect(helper.textual_compliance_history).to eq(:label => "History", | ||
:image => "compliance", | ||
:value => "Available", | ||
:title => "Show Compliance History of this Host / Node (Last 10 Checks)", | ||
:link => "/host/show?display=compliance_history") | ||
end | ||
end | ||
end |