Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…default value of :error
  • Loading branch information...
commit 1ab895bc454cecd7477cc27cc9e9e705dce2b360 1 parent addba6a
@henning-koch henning-koch authored
Showing with 10 additions and 3 deletions.
  1. +2 −2 lib/aegis/permissions.rb
  2. +8 −1 spec/aegis/permissions_spec.rb
View
4 lib/aegis/permissions.rb
@@ -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)
View
9 spec/aegis/permissions_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.