diff options
| -rw-r--r-- | app/controllers/concerns/feature_checker.rb | 5 | ||||
| -rw-r--r-- | spec/controllers/concerns/feature_checker_spec.rb | 6 |
2 files changed, 6 insertions, 5 deletions
diff --git a/app/controllers/concerns/feature_checker.rb b/app/controllers/concerns/feature_checker.rb index c23e672cf..9ca5ed0a7 100644 --- a/app/controllers/concerns/feature_checker.rb +++ b/app/controllers/concerns/feature_checker.rb @@ -33,8 +33,9 @@ module FeatureChecker end def check_feature!(*features) - authorized = has_feature? *features - raise NotAuthorizedError, "Feature not autorized" unless authorized + unless has_feature?(*features) + raise NotAuthorizedError, "Feature not autorized" + end end class NotAuthorizedError < StandardError; end diff --git a/spec/controllers/concerns/feature_checker_spec.rb b/spec/controllers/concerns/feature_checker_spec.rb index 0ffee0dfd..50b21954f 100644 --- a/spec/controllers/concerns/feature_checker_spec.rb +++ b/spec/controllers/concerns/feature_checker_spec.rb @@ -6,8 +6,8 @@ RSpec.describe "FeatureChecker", type: :controller do include FeatureChecker requires_feature :test, only: :protected - def protected; render :text => "protected"; end - def not_protected; render :text => "not protected"; end + def protected; render text: "protected"; end + def not_protected; render text: "not protected"; end def current_organisation @organisation ||= Organisation.new @@ -21,7 +21,7 @@ RSpec.describe "FeatureChecker", type: :controller do end end - it "refuse access when organisation has not the feature" do + it "refuse access when organisation does not have the feature" do expect{ get(:protected) }.to raise_error(FeatureChecker::NotAuthorizedError) end |
