Skip to content

Commit 5d9bb09

Browse files
authored
Merge pull request #9153 from kbrock/supports_unsupports
stub_supports uses specific class
2 parents a791d15 + ed68bfc commit 5d9bb09

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

spec/controllers/application_controller/ci_processing_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,22 +644,22 @@
644644
before { controller.instance_variable_set(:@reconfigitems, [vm]) }
645645

646646
context "when vm supports reconfiguring disks" do
647-
before { stub_supports(Vm, :reconfigure_disks) }
647+
before { stub_supports(vm.class, :reconfigure_disks) }
648648
it "enables reconfigure disks" do
649649
expect(controller.send(:item_supports?, :reconfigure_disks)).to be_truthy
650650
end
651651
end
652652

653653
context "when vm does not supports reconfiguring disks" do
654-
before { stub_supports_not(Vm, :reconfigure_disks) }
654+
before { stub_supports_not(vm.class, :reconfigure_disks) }
655655
it "disables reconfigure disks" do
656656
expect(controller.send(:item_supports?, :reconfigure_disks)).to be_falsey
657657
end
658658
end
659659
end
660660

661661
context "when multiple vms selected" do
662-
before { stub_supports(Vm, :reconfigure_disks) }
662+
before { stub_supports(vm.class, :reconfigure_disks) }
663663
let(:vm1) { FactoryBot.create(:vm_redhat) }
664664

665665
it "disables reconfigure disks" do

spec/controllers/cloud_object_store_object_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
end
9898

9999
it "delete shows expected flash" do
100-
stub_supports(CloudObjectStoreObject, :delete)
100+
stub_supports(object.class, :delete)
101101

102102
post :button, :params => {
103103
:pressed => "cloud_object_store_object_delete", :format => :js, :id => object.id

spec/controllers/storage_controller_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@
9191
host = FactoryBot.create(:host)
9292
command = button.split('_', 2)[1]
9393

94-
stub_supports_all_others(Host)
95-
stub_supports(Host, command)
94+
stub_supports_all_others(host.class)
95+
stub_supports(host.class, command)
9696

9797
controller.params = {:pressed => button, :miq_grid_checks => host.id.to_s}
9898
controller.instance_variable_set(:@lastaction, "show_list")

spec/controllers/vm_infra_controller_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,8 @@
332332
end
333333

334334
it 'can set retirement date' do
335-
# allow the other supports (from other buttons) to still work:
336-
allow_any_instance_of(Vm).to receive(:supports?).and_call_original
337-
stub_supports(Vm, :retire)
335+
stub_supports_all_others(vm_vmware.class)
336+
stub_supports(vm_vmware.class, :retire)
338337
get :show, :params => {:id => vm_vmware.id}
339338
expect(response).to redirect_to(:action => 'explorer')
340339

spec/helpers/application_helper/buttons/vm_retire_now_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
context "when record is retireable" do
44
before do
55
@record = FactoryBot.create(:vm_vmware)
6-
stub_supports(Vm, :retire)
6+
stub_supports(@record.class, :retire)
77
end
88

99
it_behaves_like "will not be skipped for this record"
@@ -12,7 +12,7 @@
1212
context "when record is not retiretable" do
1313
before do
1414
@record = FactoryBot.create(:vm_vmware)
15-
stub_supports_not(Vm, :retire)
15+
stub_supports_not(@record.class, :retire)
1616
end
1717

1818
it_behaves_like "will be skipped for this record"

spec/helpers/application_helper/buttons/vm_retire_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
context "when record is retireable" do
44
before do
55
@record = FactoryBot.create(:vm_vmware)
6-
stub_supports(Vm, :retire)
6+
stub_supports(@record.class, :retire)
77
end
88

99
it_behaves_like "will not be skipped for this record"
@@ -12,7 +12,7 @@
1212
context "when record is not retiretable" do
1313
before do
1414
@record = FactoryBot.create(:vm_vmware)
15-
stub_supports_not(Vm, :retire)
15+
stub_supports_not(@record.class, :retire)
1616
end
1717

1818
it_behaves_like "will be skipped for this record"

spec/helpers/application_helper/buttons/volume_detach_spec.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
describe ApplicationHelper::Button::VolumeDetach do
2+
let(:record) { CloudVolume.new }
23
let(:button) do
34
described_class.new(
4-
setup_view_context_with_sandbox({}), {}, {"record" => CloudVolume.new}, {}
5+
setup_view_context_with_sandbox({}), {}, {"record" => record}, {}
56
)
67
end
78

89
describe '#disabled?' do
910
it "when the detach action is supported, then the button is enabled" do
10-
stub_supports(CloudVolume, :detach)
11+
stub_supports(record.class, :detach)
1112
expect(button.disabled?).to be false
1213
end
1314

1415
it "when the detach action is not supported, then the button is disabled" do
15-
stub_supports_not(CloudVolume, :detach, "unavailable")
16+
stub_supports_not(record.class, :detach, "unavailable")
1617
expect(button.disabled?).to be true
1718
end
1819
end
1920

2021
describe '#calculate_properties' do
2122
it "when the detach action is not supported, then the button has the error in the title" do
22-
stub_supports_not(CloudVolume, :detach, "unavailable")
23+
stub_supports_not(record.class, :detach, "unavailable")
2324
button.calculate_properties
2425
expect(button[:title]).to eq("unavailable")
2526
end
2627

2728
it "when the detach action is not supported, the button has no error in the title" do
28-
stub_supports(CloudVolume, :detach)
29+
stub_supports(record.class, :detach)
2930
button.calculate_properties
3031
expect(button[:title]).to be nil
3132
end

0 commit comments

Comments
 (0)