diff options
| author | Alban Peignier | 2017-12-20 21:06:41 +0100 |
|---|---|---|
| committer | Alban Peignier | 2017-12-20 21:06:41 +0100 |
| commit | 3305dca57e2e0a46b583f183040a82819ffd6efb (patch) | |
| tree | 358a79ad601104753b9cbf276a8881d463bedf1f | |
| parent | 736d9e51c59d5bcf3966fc059fbe1dd5e2e47c69 (diff) | |
| download | chouette-core-3305dca57e2e0a46b583f183040a82819ffd6efb.tar.bz2 | |
Improve styles in FeatureCheck code. Refs #5339
| -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 |
