Sha256: c3f61e36d801d47f00b59d3229345c667003b13ae11405127db2acbfec31e77f
Contents?: true
Size: 1.16 KB
Versions: 13
Compression:
Stored size: 1.16 KB
Contents
require "spec_helper" require "shamu/active_record" describe Shamu::Security::ActiveRecordPolicy do use_active_record let( :policy ) { Shamu::Security::ActiveRecordPolicy.new } describe "#refine_relation" do before( :each ) do ActiveRecordSpec::Favorite.create! name: "Example" end it "returns empty relation if there are no refinements" do relation = policy.refine_relation( :read, ActiveRecordSpec::Favorite.all ) expect( relation ).to be_empty end it "applies matching refinements" do refinement = double( Shamu::Security::PolicyRefinement ) allow( policy ).to receive( :refinements ).and_return [ refinement ] expect( refinement ).to receive( :match? ).and_return true expect( refinement ).to receive( :apply ).and_return ActiveRecordSpec::Favorite.all relation = policy.refine_relation( :read, ActiveRecordSpec::Favorite.all ) expect( relation ).not_to be_empty end end describe "#refine" do it "adds a new refinement" do expect do policy.send( :refine, :read, ActiveRecordSpec::Favorite ) end.to change { policy.send( :refinements ).length } end end end
Version data entries
13 entries across 13 versions & 1 rubygems