spec/lib/protector/dsl_spec.rb in protector-0.6.4 vs spec/lib/protector/dsl_spec.rb in protector-0.7.0
- old
+ new
@@ -83,21 +83,21 @@
l = lambda {|x| x > 4 }
before :each do
@meta = Protector::DSL::Meta.new(nil, nil){%w(field1 field2 field3 field4 field5)}
@meta << lambda {
- can :view
+ can :read
}
@meta << lambda {|user|
scope { 'relation' } if user
}
@meta << lambda {|user|
user.should == 'user' if user
- cannot :view, %w(field5), :field4
+ cannot :read, %w(field5), :field4
}
@meta << lambda {|user, entry|
user.should == 'user' if user
entry.should == 'entry' if user
@@ -142,11 +142,11 @@
"field2" => nil,
"field3" => 1,
"field4" => 0..5,
"field5" => l
},
- view: {
+ read: {
"field1" => nil,
"field2" => nil,
"field3" => nil
}
}
@@ -176,9 +176,27 @@
end
it "gets first uncreatable field" do
data = @meta.evaluate('user', 'entry')
data.first_uncreatable_field('field1' => 1, 'field6' => 2).should == 'field1'
+ end
+ end
+
+ context "deprecated methods" do
+ before :each do
+ @meta = Protector::DSL::Meta.new(nil, nil){%w(field1 field2 field3)}
+
+ @meta << lambda {
+ can :view
+ cannot :view, :field2
+ }
+ end
+
+ it "evaluates" do
+ data = ActiveSupport::Deprecation.silence { @meta.evaluate('user', 'entry') }
+ data.can?(:read).should == true
+ data.can?(:read, :field1).should == true
+ data.can?(:read, :field2).should == false
end
end
context "custom methods" do
before :each do
\ No newline at end of file