spec/spec_helpers/examples/model.rb in protector-0.7.6 vs spec/spec_helpers/examples/model.rb in protector-0.7.7

- old
+ new

@@ -19,9 +19,26 @@ meta.access[:read].should == fields meta.access[:create].should == fields meta.access[:update].should == fields end + it "respects inheritance" do + dummy.instance_eval do + protect do + can :read, :test + end + end + + attempt = Class.new(dummy) do + protect do + can :create, :test + end + end + + dummy.protector_meta.evaluate(nil, nil).access.should == {read: {"test"=>nil}} + attempt.protector_meta.evaluate(nil, nil).access.should == {read: {"test"=>nil}, create: {"test"=>nil}} + end + it "drops meta on restrict" do d = Dummy.first d.restrict!('!').protector_meta d.instance_variable_get('@protector_meta').should_not == nil \ No newline at end of file