Skip to content

Commit b409771

Browse files
committed
Tests and comments around rbac and ActsAsArScope
Turns out for AAAS case, we currently only need to define all Rbac has already used all, so all methods go directly to the aar_scope (which an an active record scope) So all of these other methods are moot. Well, for this implementation. We do want it to be complete in case the code changes and someone decides to do something like call eager_load before calling all
1 parent f00bd8a commit b409771

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

spec/lib/rbac/filterer_spec.rb

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2659,9 +2659,30 @@ def get_rbac_results_for_and_expect_objects(klass, expected_objects)
26592659
expect(described_class.filtered(Vm.where(:location => "good"))).to match_array(matched_vms)
26602660
end
26612661

2662-
it "support aaarm object" do
2663-
expect(VimPerformanceTrend).to receive(:find).with(:all, {:include => {:a => {}}}).and_return([:good])
2664-
expect(described_class.filtered(VimPerformanceTrend, :include_for_find => {:a => {}}).to_a).to match_array([:good])
2662+
it "support ActsAsArModel object" do
2663+
expect(PglogicalSubscription).to receive(:find).with(:all, {:include => {:a => {}}}).and_return([:good])
2664+
expect(described_class.filtered(PglogicalSubscription, :include_for_find => {:a => {}}).to_a).to match_array([:good])
2665+
end
2666+
2667+
it "supports ActsAsArScope object all target" do
2668+
all_vms
2669+
2670+
klass = ManageIQ::Providers::InfraManager::VmOrTemplate
2671+
expect(klass).to receive(:all).and_call_original
2672+
expect(described_class.filtered(klass, :include_for_find => {:host => {}})).to match_array(all_vms)
2673+
end
2674+
2675+
it "supports ActsAsArScope object scoping" do
2676+
all_vms
2677+
filter = MiqExpression.new("=" => {"field" => "Vm-location", "value" => "good"})
2678+
expect(described_class.filtered(ManageIQ::Providers::InfraManager::VmOrTemplate, :filter => filter)).to match_array(matched_vms)
2679+
end
2680+
2681+
it "understands ActsAsArScope includes (invalid)" do
2682+
klass = ManageIQ::Providers::InfraManager::VmOrTemplate
2683+
expect {
2684+
expect(described_class.filtered(klass, :include_for_find => {:missing_association => {}}).to_a).to eq(VmOrTemplate.new)
2685+
}.to raise_error(ActiveRecord::ConfigurationError)
26652686
end
26662687

26672688
# it returns objects too

0 commit comments

Comments
 (0)