test/test_canhaz.rb in rails-canhaz-0.3.0 vs test/test_canhaz.rb in rails-canhaz-0.4.0

- old
+ new

@@ -37,15 +37,15 @@ subject = SubjectModel.new object = ObjectModel.new assert_raise CanHaz::Exceptions::NotACanHazObject do - subject.can(:whatever, foo) + subject.can!(:whatever, foo) end assert_nothing_raised RuntimeError do - subject.can(:whatever, object) + subject.can!(:whatever, object) end assert_raise CanHaz::Exceptions::NotACanHazObject do subject.can?(:whatever, foo) end @@ -67,15 +67,15 @@ assert subject.can?(:bar, object) == false assert object.accessible_by?(subject, :foo) == false assert object.accessible_by?(subject, :bar) == false - assert subject.can(:foo, object) - assert subject.can(:bar, object) + assert subject.can!(:foo, object) + assert subject.can!(:bar, object) - assert subject.can(:foo, object) == false - assert subject.can(:bar, object) == false + assert subject.can!(:foo, object) == false + assert subject.can!(:bar, object) == false assert subject.can?(:foo, object) assert subject.can?(:bar, object) assert object.accessible_by?(subject, :foo) @@ -97,19 +97,19 @@ object = ObjectModel.new object.save assert subject.can?(:foo, object) == false - assert subject.cannot(:foo, object) == false + assert subject.cannot!(:foo, object) == false - subject.can(:foo, object) - subject.can(:bar, object) + subject.can!(:foo, object) + subject.can!(:bar, object) assert subject.can?(:foo, object) assert subject.can?(:bar, object) - assert subject.cannot(:foo, object) == true + assert subject.cannot!(:foo, object) == true assert subject.can?(:foo, object) == false assert subject.can?(:bar, object) == true end @@ -123,21 +123,21 @@ s1.save s2.save s3.save - s1.can(:foo, object) - s2.can(:bar, object) - s3.can(:foo, object) + s1.can!(:foo, object) + s2.can!(:bar, object) + s3.can!(:foo, object) foo = object.subjects_with_permission(SubjectModel, :foo) assert foo.include?(s1) == true assert foo.include?(s2) == false assert foo.include?(s3) == true - s3.cannot(:foo, object) + s3.cannot!(:foo, object) foo = object.subjects_with_permission(SubjectModel, :foo) assert foo.include?(s1) == true assert foo.include?(s2) == false @@ -163,16 +163,16 @@ object1.save object2 = ObjectModel.new object2.save - subject.can(:foo, object1) - subject.can(:bar, object1) - subject.can(:foo, object2) - subject.can(:bar, object2) + subject.can!(:foo, object1) + subject.can!(:bar, object1) + subject.can!(:foo, object2) + subject.can!(:bar, object2) - subject2.can(:foo, object1) + subject2.can!(:foo, object1) subject.can_do_nothing subject.reload @@ -195,16 +195,16 @@ s1.save s2.save o1.save o2.save - s1.can(:foo, o1) - s1.can(:foo, o2) - s1.can(:bar, o2) + s1.can!(:foo, o1) + s1.can!(:foo, o2) + s1.can!(:bar, o2) - s2.can(:bar, o1) - s2.can(:foo, o2) + s2.can!(:bar, o1) + s2.can!(:foo, o2) result = CanHazPermission.can?([s1, s2], :foo, [o1, o2]) assert result[s1.id] == [o1, o2] assert result[s2.id] == [o2] @@ -223,12 +223,12 @@ s.save o.save id = s.id - s.can(:foo, o) - s.can(:bar, o) + s.can!(:foo, o) + s.can!(:bar, o) s.destroy assert CanHazPermission.find_by_csubject_id(id).nil? @@ -238,11 +238,11 @@ s.save o.save id = o.id - s.can(:foo, o) - s.can(:bar, o) + s.can!(:foo, o) + s.can!(:bar, o) o.destroy assert CanHazPermission.find_by_cobject_id(id).nil? end