arrthorizer 0.1.0.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. data/.gitignore +21 -0
  2. data/.travis.yml +6 -0
  3. data/Gemfile +10 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +32 -0
  6. data/Rakefile +8 -0
  7. data/arrthorizer.gemspec +24 -0
  8. data/config.ru +7 -0
  9. data/lib/arrthorizer/arrthorizer_exception.rb +11 -0
  10. data/lib/arrthorizer/context.rb +65 -0
  11. data/lib/arrthorizer/context_builder.rb +11 -0
  12. data/lib/arrthorizer/context_role.rb +31 -0
  13. data/lib/arrthorizer/permission.rb +14 -0
  14. data/lib/arrthorizer/privilege.rb +44 -0
  15. data/lib/arrthorizer/rails/configuration.rb +67 -0
  16. data/lib/arrthorizer/rails/controller_action.rb +45 -0
  17. data/lib/arrthorizer/rails/controller_concern.rb +70 -0
  18. data/lib/arrthorizer/rails/controller_configuration.rb +36 -0
  19. data/lib/arrthorizer/rails/controller_context_builder.rb +39 -0
  20. data/lib/arrthorizer/rails.rb +24 -0
  21. data/lib/arrthorizer/registry.rb +30 -0
  22. data/lib/arrthorizer/role.rb +31 -0
  23. data/lib/arrthorizer/roles.rb +19 -0
  24. data/lib/arrthorizer/version.rb +3 -0
  25. data/lib/arrthorizer.rb +28 -0
  26. data/lib/generators/arrthorizer/install/USAGE +9 -0
  27. data/lib/generators/arrthorizer/install/install_generator.rb +62 -0
  28. data/lib/generators/arrthorizer/install/templates/config.yml +49 -0
  29. data/spec/arrthorizer_exception/inner_spec.rb +21 -0
  30. data/spec/context/equals_spec.rb +44 -0
  31. data/spec/context/merge_spec.rb +37 -0
  32. data/spec/context_builder/build_spec.rb +12 -0
  33. data/spec/context_role/to_key_spec.rb +21 -0
  34. data/spec/context_spec.rb +49 -0
  35. data/spec/controllers/some_controller_spec.rb +79 -0
  36. data/spec/integration/registry/missing_handler_spec.rb +25 -0
  37. data/spec/integration/role_spec.rb +17 -0
  38. data/spec/internal/app/assets/images/rails.png +0 -0
  39. data/spec/internal/app/assets/javascripts/application.js +15 -0
  40. data/spec/internal/app/assets/javascripts/test.js.coffee +3 -0
  41. data/spec/internal/app/assets/stylesheets/application.css +13 -0
  42. data/spec/internal/app/assets/stylesheets/test.css.scss +3 -0
  43. data/spec/internal/app/controllers/application_controller.rb +3 -0
  44. data/spec/internal/app/controllers/some_controller.rb +17 -0
  45. data/spec/internal/app/helpers/application_helper.rb +2 -0
  46. data/spec/internal/app/helpers/test_helper.rb +2 -0
  47. data/spec/internal/app/mailers/.gitkeep +0 -0
  48. data/spec/internal/app/models/.gitkeep +0 -0
  49. data/spec/internal/app/roles/namespaced/context_role.rb +9 -0
  50. data/spec/internal/app/roles/unnamespaced_context_role.rb +6 -0
  51. data/spec/internal/app/views/layouts/application.html.erb +11 -0
  52. data/spec/internal/app/views/some/some_action.html.erb +2 -0
  53. data/spec/internal/config/application.rb +65 -0
  54. data/spec/internal/config/arrthorizer.yml +9 -0
  55. data/spec/internal/config/boot.rb +6 -0
  56. data/spec/internal/config/database.yml +25 -0
  57. data/spec/internal/config/environment.rb +5 -0
  58. data/spec/internal/config/routes.rb +3 -0
  59. data/spec/internal/db/schema.rb +3 -0
  60. data/spec/internal/log/.gitignore +1 -0
  61. data/spec/internal/public/favicon.ico +0 -0
  62. data/spec/permission/grant_spec.rb +14 -0
  63. data/spec/privilege/accessible_to_spec.rb +32 -0
  64. data/spec/privilege/get_spec.rb +35 -0
  65. data/spec/privilege/initialize_spec.rb +15 -0
  66. data/spec/privilege/make_accessible_to_spec.rb +22 -0
  67. data/spec/rails/.gitkeep +0 -0
  68. data/spec/rails/controller_action/initialize_spec.rb +42 -0
  69. data/spec/rails/controller_action/key_for_spec.rb +17 -0
  70. data/spec/rails/controller_action/to_key_spec.rb +14 -0
  71. data/spec/rails/controller_concern/arrthorizer_context_spec.rb +22 -0
  72. data/spec/rails/controller_concern/authorize_spec.rb +113 -0
  73. data/spec/rails/controller_concern/integration_spec.rb +75 -0
  74. data/spec/rails/controller_concern/to_prepare_context_spec.rb +38 -0
  75. data/spec/rails/controller_configuration/initialize_spec.rb +19 -0
  76. data/spec/role/get_spec.rb +29 -0
  77. data/spec/role/shared_examples/finding_the_right_role.rb +6 -0
  78. data/spec/spec_helper.rb +21 -0
  79. data/spec/support/reset.rb +26 -0
  80. metadata +244 -0
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ TestCbac::Application.initialize!
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ get "some/some_action"
3
+ end
@@ -0,0 +1,3 @@
1
+ ActiveRecord::Schema.define do
2
+ #
3
+ end
@@ -0,0 +1 @@
1
+ *.log
File without changes
@@ -0,0 +1,14 @@
1
+ require "spec_helper"
2
+
3
+ describe Arrthorizer::Permission do
4
+ describe :grant do
5
+ let(:privilege) { Arrthorizer::Privilege.new(name: "privilege") }
6
+ let(:role) { UnnamespacedContextRole }
7
+
8
+ it "adds the role to the privilege set" do
9
+ Arrthorizer::Permission.grant(privilege, to: role)
10
+
11
+ expect(privilege).to be_accessible_to(role)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,32 @@
1
+ require "spec_helper"
2
+
3
+ describe Arrthorizer::Privilege do
4
+ subject(:privilege) { Arrthorizer::Privilege.new(name: "some privilege") }
5
+
6
+ let(:role) { Namespaced::ContextRole }
7
+ let(:other_role) { UnnamespacedContextRole }
8
+
9
+ describe :accessible_to? do
10
+ context "when a Role was configured to have access to this privilege" do
11
+ before :each do
12
+ privilege.make_accessible_to(role)
13
+ end
14
+
15
+ context "and that Role is provided" do
16
+ let(:arg) { role }
17
+
18
+ it "returns true" do
19
+ expect(privilege.accessible_to?(arg)).to be_true
20
+ end
21
+ end
22
+
23
+ context "and the name of that Role is provided" do
24
+ let(:arg) { role.name }
25
+
26
+ it "returns true" do
27
+ expect(privilege.accessible_to?(arg)).to be_true
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ describe Arrthorizer::Privilege do
4
+ describe :get do
5
+ context "when the privilege set does not exist" do
6
+ it "raises a Privilege::NotFound error" do
7
+ expect {
8
+ Arrthorizer::Privilege.get("computer_says_no")
9
+ }.to raise_error(Arrthorizer::Registry::NotFound)
10
+ end
11
+ end
12
+
13
+ context "when the privilege set with the given name exists" do
14
+ let(:name) { "computer_says_hi" }
15
+
16
+ before do
17
+ @privilege = Arrthorizer::Privilege.new(name: name)
18
+ end
19
+
20
+ it "returns that privilege set" do
21
+ Arrthorizer::Privilege.get(name).should be @privilege
22
+ end
23
+ end
24
+
25
+ context "when the parameter is already a privilege set" do
26
+ before do
27
+ @privilege = Arrthorizer::Privilege.new(name: "irrelevant")
28
+ end
29
+
30
+ specify "that privilege set is returned" do
31
+ Arrthorizer::Privilege.get(@privilege).should be @privilege
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,15 @@
1
+ require "spec_helper"
2
+
3
+ describe Arrthorizer::Privilege do
4
+ describe :initialize do
5
+ let(:role) { UnnamespacedContextRole }
6
+ let(:roles) { [ role ] }
7
+ let(:name) { "some name" }
8
+
9
+ subject(:privilege) { Arrthorizer::Privilege.new(name: name, roles: roles) }
10
+
11
+ it "makes itself accessible to each provided role" do
12
+ expect(privilege).to be_accessible_to(role)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe Arrthorizer::Privilege do
4
+ describe :make_accessible_to do
5
+ let(:privilege) { Arrthorizer::Privilege.new(name: "privilege") }
6
+ let(:role) { UnnamespacedContextRole }
7
+
8
+ it "makes the privilege accessible to the role" do
9
+ expect {
10
+ privilege.make_accessible_to(role)
11
+ }.to change { privilege.accessible_to?(role) }.to(true)
12
+ end
13
+
14
+ it "does not make it accessible to a different role" do
15
+ unrelated_role = Namespaced::ContextRole
16
+
17
+ expect {
18
+ privilege.make_accessible_to(role)
19
+ }.not_to change { privilege.accessible_to?(unrelated_role) }.to(true)
20
+ end
21
+ end
22
+ end
File without changes
@@ -0,0 +1,42 @@
1
+ require "spec_helper"
2
+
3
+ describe Arrthorizer::Rails::ControllerAction do
4
+ let(:controller_name) { 'some_controller' }
5
+ let(:action_name) { 'some_action' }
6
+
7
+ let(:definition) { { controller: controller_name, action: action_name } }
8
+
9
+ describe :initialize do
10
+ context "when all parameters are properly specified" do
11
+ it "does not raise an error" do
12
+ expect {
13
+ Arrthorizer::Rails::ControllerAction.new(definition)
14
+ }.not_to raise_error
15
+ end
16
+ end
17
+
18
+ context "when the controller is not properly specified" do
19
+ before :each do
20
+ definition.delete(:controller)
21
+ end
22
+
23
+ it "raises an Arrthorizer::Rails::ControllerAction::ControllerNotDefined" do
24
+ expect {
25
+ Arrthorizer::Rails::ControllerAction.new(definition)
26
+ }.to raise_error(Arrthorizer::Rails::ControllerAction::ControllerNotDefined)
27
+ end
28
+ end
29
+
30
+ context "when the action is not properly specified" do
31
+ before :each do
32
+ definition.delete(:action)
33
+ end
34
+
35
+ it "does raises an Arrthorizer::Rails::ControllerAction::ActionNotDefined" do
36
+ expect {
37
+ Arrthorizer::Rails::ControllerAction.new(definition)
38
+ }.to raise_error(Arrthorizer::Rails::ControllerAction::ActionNotDefined)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ describe Arrthorizer::Rails::ControllerAction do
4
+ describe :key_for do
5
+ context "when the controller lives in a separate namespace" do
6
+ let(:controller_path) { 'namespace/controller_name' }
7
+ let(:controller_path_regex) { %r(#{controller_path}) }
8
+ let(:controller) { double('some_controller', controller_path: controller_path, action_name: 'some_action') }
9
+
10
+ specify "that namespace is made part of the key" do
11
+ key = Arrthorizer::Rails::ControllerAction.key_for(controller)
12
+
13
+ expect(key).to match(%r(#{controller_path}))
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ require "spec_helper"
2
+
3
+ describe Arrthorizer::Rails::ControllerAction do
4
+ describe :to_key do
5
+ let(:controller) { "forum/topics" }
6
+ let(:action) { "create" }
7
+
8
+ subject(:controller_action) { Arrthorizer::Rails::ControllerAction.new(controller: controller, action: action) }
9
+
10
+ it "joins controller and action into a 'hash shorthand'" do
11
+ expect(controller_action.to_key).to eql("#{controller}##{action}")
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe Arrthorizer::Rails::ControllerConcern do
4
+ let(:controller_class) { Class.new(SomeController) }
5
+ let(:controller) { controller_class.new }
6
+
7
+ before :each do
8
+ controller_class.to_prepare_context do |c|
9
+ c.defaults do
10
+ params
11
+ end
12
+ end
13
+
14
+ controller.stub(:request).and_return(ActionDispatch::TestRequest.new)
15
+ end
16
+
17
+ describe :arrthorizer_context do
18
+ it "returns an Arrthorizer::Context" do
19
+ controller.send(:arrthorizer_context).should be_a Arrthorizer::Context
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,113 @@
1
+ require 'spec_helper'
2
+
3
+ describe Arrthorizer::Rails::ControllerConcern do
4
+ let(:controller_class) { Class.new(SomeController) }
5
+ let(:controller) { controller_class.new }
6
+ let(:controller_action){ Arrthorizer::Rails::ControllerAction.new(controller: controller_path, action: action_name)}
7
+
8
+ let(:action_name){ "some_action" }
9
+ let(:controller_path){ "some" }
10
+ let(:current_user){ double("user") }
11
+ let(:context){ double("context") }
12
+
13
+ before do
14
+ controller.stub(:action_name).and_return(action_name)
15
+ controller.stub(:current_user).and_return(current_user)
16
+ controller.stub(:arrthorizer_context).and_return(context)
17
+ controller.stub(:controller_path).and_return(controller_path)
18
+ end
19
+
20
+ describe :authorize do
21
+ context "when no privilege has been defined for the action" do
22
+ it "is forbidden" do
23
+ expect(controller).to receive(:forbidden)
24
+
25
+ controller.send(:authorize)
26
+ end
27
+ end
28
+
29
+ context "when a privilege has been defined for the action" do
30
+ let(:privilege){ Arrthorizer::Privilege.new(name: "test privilege") }
31
+ let(:permitted_roles){ Arrthorizer::Registry.new }
32
+
33
+ before do
34
+ controller_action.stub(:privilege).and_return(privilege)
35
+ privilege.stub(:permitted_roles).and_return(permitted_roles)
36
+ end
37
+
38
+ context "but the privilege has no permitted roles" do
39
+ it "is forbidden" do
40
+ expect(controller).to receive(:forbidden)
41
+
42
+ controller.send(:authorize)
43
+ end
44
+ end
45
+
46
+ context "and the privilege has a permitted role" do
47
+ let(:role){ Arrthorizer::Role.new }
48
+
49
+ before do
50
+ role.stub(:name).and_return('some_role')
51
+ permitted_roles.add(role)
52
+ end
53
+
54
+ context "and the role applies to the user" do
55
+ before do
56
+ role.stub(:applies_to_user?).with(current_user, context).and_return(true)
57
+ end
58
+
59
+ it "is not forbidden" do
60
+ expect(controller).not_to receive(:forbidden)
61
+
62
+ controller.send(:authorize)
63
+ end
64
+ end
65
+
66
+ context "and the role does not apply to the user" do
67
+ before do
68
+ role.stub(:applies_to_user?).with(current_user, context).and_return(false)
69
+ end
70
+
71
+ it "is forbidden" do
72
+ expect(controller).to receive(:forbidden)
73
+
74
+ controller.send(:authorize)
75
+ end
76
+
77
+ context "when the privilege has another permitted role" do
78
+ let(:another_role){ Arrthorizer::Role.new }
79
+
80
+ before do
81
+ another_role.stub(:name).and_return('another_role')
82
+ permitted_roles.add(another_role)
83
+ end
84
+
85
+ context "and the role applies to the user" do
86
+ before do
87
+ another_role.stub(:applies_to_user?).with(current_user, context).and_return(true)
88
+ end
89
+
90
+ it "is not forbidden" do
91
+ expect(controller).not_to receive(:forbidden)
92
+
93
+ controller.send(:authorize)
94
+ end
95
+ end
96
+
97
+ context "and the role does not apply to the user" do
98
+ before do
99
+ another_role.stub(:applies_to_user?).with(current_user, context).and_return(false)
100
+ end
101
+
102
+ it "is forbidden" do
103
+ expect(controller).to receive(:forbidden)
104
+
105
+ controller.send(:authorize)
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,75 @@
1
+ require "spec_helper"
2
+
3
+ require 'arrthorizer/rails'
4
+
5
+ describe Arrthorizer::Rails do
6
+ describe "controller integration" do
7
+ let(:controller_class) { Class.new(ApplicationController) do def index; end end}
8
+
9
+ describe "each controller class" do
10
+ it "responds to :prepare_context" do
11
+ controller_class.should respond_to :to_prepare_context
12
+ end
13
+
14
+ it "responds to :arrthorizer_configuration" do
15
+ controller_class.should respond_to :arrthorizer_configuration
16
+ end
17
+ end
18
+
19
+ describe "each controller" do
20
+ let(:controller) { controller_class.new }
21
+
22
+ it "responds to :arrthorizer_context" do
23
+ controller.should respond_to :arrthorizer_context
24
+ end
25
+
26
+ context "when it has a proper configuration for context building" do
27
+ let(:injected_params) { { some_param: 1 } }
28
+ let(:current_action) { 'some_action' }
29
+
30
+ before :each do
31
+ controller.stub(:params).and_return injected_params
32
+
33
+ controller.stub(:action_name).and_return(current_action)
34
+ end
35
+
36
+ context "and there is no specific configuration for the current action" do
37
+ before :each do
38
+ controller_class.to_prepare_context do |c|
39
+ c.defaults do
40
+ params # this is an example config which can be easily tested
41
+ end
42
+ end
43
+ end
44
+
45
+ it "uses the 'default' config to build an Arrthorizer context" do
46
+ controller.send(:arrthorizer_context).should == Arrthorizer::Context(injected_params)
47
+ end
48
+ end
49
+
50
+ context "and there is a specific configuration for the current action" do
51
+ let(:action_specific_config) { { some_extra_key: 'some_value' }}
52
+
53
+ before :each do
54
+ controller_class.to_prepare_context do |c|
55
+ c.defaults do
56
+ params
57
+ end
58
+
59
+ c.for_action(current_action) do
60
+ arrthorizer_defaults.merge(some_extra_key: 'some_value')
61
+ end
62
+ end
63
+ end
64
+
65
+ it "uses the more specific configuration for the current action" do
66
+ context_hash = injected_params.merge(action_specific_config)
67
+ expected_context = Arrthorizer::Context(context_hash)
68
+
69
+ controller.send(:arrthorizer_context).should == expected_context
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,38 @@
1
+ require "spec_helper"
2
+
3
+ describe Arrthorizer::Rails::ControllerConcern do
4
+ describe :to_prepare_context do
5
+ let(:controller_class) { Class.new(ApplicationController) }
6
+ let(:expected_controller_configuration_type) { Arrthorizer::Rails::ControllerConfiguration }
7
+
8
+ it "adds a ControllerConfiguration to the class" do
9
+ expected_controller_configuration = an_instance_of(expected_controller_configuration_type)
10
+
11
+ expect {
12
+ controller_class.to_prepare_context do end
13
+ }.to change { controller_class.arrthorizer_configuration }.to(expected_controller_configuration)
14
+ end
15
+
16
+ context "when we are dealing with a subclassed controller" do
17
+ let(:controller_subclass) { Class.new(controller_class) }
18
+
19
+ before :each do
20
+ controller_class.to_prepare_context do end
21
+ end
22
+
23
+ it "does not alter the context config for the superclass" do
24
+ expect {
25
+ controller_subclass.to_prepare_context do end
26
+ }.not_to change { controller_class.arrthorizer_configuration }
27
+ end
28
+ end
29
+
30
+ context "when no configuration block is provided" do
31
+ specify "an Arrthorizer::Rails::ControllerConfiguration::Error is raised" do
32
+ expect {
33
+ controller_class.to_prepare_context
34
+ }.to raise_error(Arrthorizer::Rails::ControllerConfiguration::Error)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ describe Arrthorizer::Rails::ControllerConfiguration do
4
+ describe :initialize do
5
+ it "yields the new instance to the builder block" do
6
+ expect { |block|
7
+ Arrthorizer::Rails::ControllerConfiguration.new(&block)
8
+ }.to yield_with_args(an_instance_of(Arrthorizer::Rails::ControllerConfiguration))
9
+ end
10
+
11
+ context "when no builder block is provided" do
12
+ specify "an Arrthorizer::Rails::ControllerConfiguration::Error is raised" do
13
+ expect {
14
+ Arrthorizer::Rails::ControllerConfiguration.new
15
+ }.to raise_error(Arrthorizer::Rails::ControllerConfiguration::Error)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ require_relative 'shared_examples/finding_the_right_role.rb'
4
+
5
+ describe Arrthorizer::Role do
6
+ describe :get do
7
+ describe "fetching ContextRoles" do
8
+ let(:expected_role) { Namespaced::ContextRole.instance } # provided by the internal Rails app
9
+
10
+ context "when a ContextRole class is provided" do
11
+ it_behaves_like "finding the right Role" do
12
+ let(:arg) { expected_role.class }
13
+ end
14
+ end
15
+
16
+ context "when a String representing a ContextRole instance is provided" do
17
+ it_behaves_like "finding the right Role" do
18
+ let(:arg) { expected_role.to_key }
19
+ end
20
+ end
21
+
22
+ context "when a ContextRole instance is provided" do
23
+ it_behaves_like "finding the right Role" do
24
+ let(:arg) { expected_role }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,6 @@
1
+ shared_examples_for "finding the right Role" do
2
+ it "finds the right Role" do
3
+ expect(Arrthorizer::Role.get(arg)).to be expected_role
4
+ end
5
+ end
6
+
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'combustion'
5
+
6
+ Combustion.initialize! :active_record, :action_controller,
7
+ :action_view
8
+
9
+ require 'rspec/rails'
10
+
11
+ Dir.glob('./spec/support/**/*.rb') do |file|
12
+ require file
13
+ end
14
+
15
+ Dir.glob('./spec/fixtures/**/*.rb') do |file|
16
+ require file
17
+ end
18
+
19
+ RSpec.configure do |config|
20
+ config.use_transactional_fixtures = true
21
+ end
@@ -0,0 +1,26 @@
1
+ module Arrthorizer
2
+ module Rails
3
+ module Resetter
4
+ extend self
5
+
6
+ def reset!
7
+ Arrthorizer::Rails::ControllerAction.send(:registry).reset!
8
+
9
+ Arrthorizer::Rails::Configuration.load
10
+ end
11
+ end
12
+ end
13
+
14
+ class Registry
15
+ def reset!
16
+ self.storage = Hash.new
17
+ end
18
+ end
19
+ end
20
+
21
+ RSpec.configure do |config|
22
+ config.before :each do
23
+ Arrthorizer::Rails::Resetter.reset!
24
+ end
25
+ end
26
+