Permalink
Browse files

fix a bug where you cannot explicitely set missing_user_means to the …

…default value of :error
  • Loading branch information...
1 parent addba6a commit 1ab895bc454cecd7477cc27cc9e9e705dce2b360 @triskweline triskweline committed Nov 2, 2010
Showing with 10 additions and 3 deletions.
  1. +2 −2 lib/aegis/permissions.rb
  2. +8 −1 spec/aegis/permissions_spec.rb
View
@@ -12,9 +12,9 @@ def missing_action_means(strategy)
@missing_action_strategy = strategy
end
- def missing_user_means(&strategy)
+ def missing_user_means(strategy_symbol = nil, &strategy_block)
prepare
- @missing_user_strategy = strategy
+ @missing_user_strategy = strategy_symbol || strategy_block
end
def alias_action(aliases)
@@ -579,7 +579,14 @@
describe 'behavior when checking permissions without a user' do
- it "should raise an error if the user is nil" do
+ it "should raise an error if no missing user strategy is defined" do
+ expect { @permissions.may?(nil, :some_action) }.to raise_error(Aegis::MissingUser)
+ end
+
+ it 'should raise an error if the missing user strategy is :error' do
+ @permissions.class_eval do
+ missing_user_means :error
+ end
expect { @permissions.may?(nil, :some_action) }.to raise_error(Aegis::MissingUser)
end

0 comments on commit 1ab895b

Please sign in to comment.