spec/spec_helpers/examples/model.rb in protector-0.3.3 vs spec/spec_helpers/examples/model.rb in protector-0.4.0
- old
+ new
@@ -33,13 +33,23 @@
describe "visibility" do
it "marks blocked" do
Dummy.first.restrict!('-').visible?.should == false
end
- it "marks allowed" do
- Dummy.first.restrict!('+').visible?.should == true
+ context "adequate", paranoid: false do
+ it "marks allowed" do
+ Dummy.first.restrict!('!').visible?.should == true
+ Dummy.first.restrict!('+').visible?.should == true
+ end
end
+
+ context "paranoid", paranoid: true do
+ it "marks allowed" do
+ Dummy.first.restrict!('!').visible?.should == false
+ Dummy.first.restrict!('+').visible?.should == true
+ end
+ end
end
#
# Reading
#
@@ -341,24 +351,42 @@
#
# Associations
#
describe "association" do
context "(has_many)" do
- it "loads" do
- Dummy.first.restrict!('!').fluffies.length.should == 2
- Dummy.first.restrict!('+').fluffies.length.should == 1
- Dummy.first.restrict!('-').fluffies.empty?.should == true
+ context "adequate", paranoid: false do
+ it "loads" do
+ Dummy.first.restrict!('!').fluffies.length.should == 2
+ Dummy.first.restrict!('+').fluffies.length.should == 1
+ Dummy.first.restrict!('-').fluffies.empty?.should == true
+ end
end
+ context "paranoid", paranoid: true do
+ it "loads" do
+ Dummy.first.restrict!('!').fluffies.empty?.should == true
+ Dummy.first.restrict!('+').fluffies.length.should == 1
+ Dummy.first.restrict!('-').fluffies.empty?.should == true
+ end
+ end
end
context "(belongs_to)" do
- it "passes subject" do
- Fluffy.first.restrict!('!').dummy.protector_subject.should == '!'
+ context "adequate", paranoid: false do
+ it "passes subject" do
+ Fluffy.first.restrict!('!').dummy.protector_subject.should == '!'
+ end
+
+ it "loads" do
+ Fluffy.first.restrict!('!').dummy.should be_a_kind_of(Dummy)
+ Fluffy.first.restrict!('-').dummy.should == nil
+ end
end
- it "loads" do
- Fluffy.first.restrict!('!').dummy.should be_a_kind_of(Dummy)
- Fluffy.first.restrict!('-').dummy.should == nil
+ context "paranoid", paranoid: true do
+ it "loads" do
+ Fluffy.first.restrict!('!').dummy.should == nil
+ Fluffy.first.restrict!('-').dummy.should == nil
+ end
end
end
end
end
\ No newline at end of file