test/context_access_test.rb in surrounded-0.7.1 vs test/context_access_test.rb in surrounded-0.7.2
- old
+ new
@@ -12,10 +12,24 @@
end
disallow :if_ready do
user.name != 'Amy'
end
+
+ trigger :check_disallow_behavior do
+ # used for disallow check
+ end
+
+ disallow :check_disallow_behavior do
+ user.special
+ end
+
+ role :user do
+ def special
+ 'special user method'
+ end
+ end
end
describe Surrounded::Context, 'access control' do
let(:user){ User.new("Jim") }
let(:other_user){ User.new("Guille") }
@@ -34,7 +48,11 @@
it 'raises errors when trigger method not allowed' do
error = assert_raises(::Surrounded::Context::AccessError){
context.if_ready
}
assert_match(/access to FilteredContext#if_ready is not allowed/i, error.message)
+ end
+
+ it 'applies roles in disallow blocks' do
+ assert_equal 'special user method', context.disallow_check_disallow_behavior?
end
end
\ No newline at end of file