arrthorizer 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 99020b8a7d6734b6d583dde7782bf0d5b4a795e1
4
+ data.tar.gz: 0d287e10df0682a16ab56f937c566971abf11a14
5
+ SHA512:
6
+ metadata.gz: a83bddadd007007cdd31313d26330c3f97fd663e1ea42fe460e39f9dba86820cfab2dc9138a6093cbeb165559f6aba1c6bf4ed193c4a00b854f2bcf5f61ed5d6
7
+ data.tar.gz: eb0daf7155fc4acb728ae2cfce174fbd84b88e4f34c53d17f15cd3d636e25110852864cc803ec32c3f1542a8a1fd5451d4bb62fbcf52c1292d895df3dde6029d
data/arrthorizer.gemspec CHANGED
@@ -20,5 +20,5 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency 'rails', '>= 3.2.18'
21
21
  gem.add_development_dependency 'combustion', '~> 0.5.1'
22
22
  gem.add_development_dependency 'sqlite3'
23
- gem.add_development_dependency 'rspec-rails'
23
+ gem.add_development_dependency 'rspec-rails', '>= 3'
24
24
  end
@@ -28,8 +28,10 @@ module Arrthorizer
28
28
  def arrthorizer_check_role(role, context)
29
29
  begin
30
30
  role.applies_to_user?(arrthorizer_scope, context)
31
- rescue StandardError
32
- ::Rails.logger.warn("Error occurred while evaluating #{role} for #{current_user}.")
31
+ rescue StandardError => error
32
+ ::Rails.logger.warn("A(n) #{error.class.name} occurred while evaluating #{role} for #{current_user}.")
33
+ ::Rails.logger.debug(error.message)
34
+ ::Rails.logger.debug(error.backtrace.join("\n"))
33
35
  return false
34
36
  end
35
37
  end
@@ -7,9 +7,9 @@ module Arrthorizer
7
7
  end
8
8
 
9
9
  role_spec = {
10
- type: :role,
11
- example_group: { file_path: %r(spec/roles) }
12
- }
10
+ type: :role,
11
+ file_path: %r(spec/roles)
12
+ }
13
13
 
14
14
  ::RSpec.configure do |config|
15
15
  config.include Arrthorizer::RSpec::Matchers::Roles, role_spec
@@ -1,3 +1,3 @@
1
1
  module Arrthorizer
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
data/spec/context_spec.rb CHANGED
@@ -20,7 +20,7 @@ describe Arrthorizer do
20
20
 
21
21
  context "when an object responding to #to_hash is provided" do
22
22
  before :each do
23
- arg.stub(:to_hash).and_return({ key => value })
23
+ allow(arg).to receive(:to_hash).and_return({ key => value })
24
24
  end
25
25
 
26
26
  it "returns an Arrthorizer::Context" do
@@ -4,12 +4,12 @@ describe SomeController do
4
4
  let(:action) { Arrthorizer::Rails::ControllerAction.fetch("some#some_action") }
5
5
  let(:other_action) { Arrthorizer::Rails::ControllerAction.fetch("some#other_action") }
6
6
 
7
- describe :some_action, type: :controller do
7
+ describe 'some_action', type: :controller do
8
8
  let!(:privilege) { action.privilege }
9
9
  let!(:current_user) { double("user") }
10
10
 
11
11
  before do
12
- controller.stub(:current_user) { current_user }
12
+ allow(controller).to receive(:current_user) { current_user }
13
13
  end
14
14
 
15
15
  describe "group roles" do
@@ -124,7 +124,7 @@ describe SomeController do
124
124
  private
125
125
  def configure_context_role(&block)
126
126
  UnnamespacedContextRole.instance.tap do |role|
127
- role.stub(:applies_to_user?, &block)
127
+ allow(role).to receive(:applies_to_user?, &block)
128
128
  end
129
129
  end
130
130
 
@@ -141,6 +141,6 @@ describe SomeController do
141
141
  end
142
142
 
143
143
  def stub_membership_with(user, group, &block)
144
- Arrthorizer.membership_service.stub(:is_member_of?).with(user, group, &block)
144
+ allow(Arrthorizer.membership_service).to receive(:is_member_of?).with(user, group, &block)
145
145
  end
146
146
  end
@@ -16,7 +16,7 @@ describe Arrthorizer::Privilege do
16
16
  let(:arg) { role }
17
17
 
18
18
  it "returns true" do
19
- expect(privilege.accessible_to?(arg)).to be_true
19
+ expect(privilege.accessible_to?(arg)).to be true
20
20
  end
21
21
  end
22
22
 
@@ -24,7 +24,7 @@ describe Arrthorizer::Privilege do
24
24
  let(:arg) { role.name }
25
25
 
26
26
  it "returns true" do
27
- expect(privilege.accessible_to?(arg)).to be_true
27
+ expect(privilege.accessible_to?(arg)).to be true
28
28
  end
29
29
  end
30
30
  end
@@ -16,7 +16,7 @@ describe Arrthorizer::Privilege do
16
16
 
17
17
  expect {
18
18
  privilege.make_accessible_to(role)
19
- }.not_to change { privilege.accessible_to?(unrelated_role) }.to(true)
19
+ }.not_to change { privilege.accessible_to?(unrelated_role) }
20
20
  end
21
21
  end
22
22
  end
@@ -5,7 +5,7 @@ describe Arrthorizer::Rails::ControllerAction do
5
5
  let(:controller) { double('controller') }
6
6
 
7
7
  before :each do
8
- Arrthorizer::Rails::ControllerAction.stub(:key_for).with(controller).and_return("controller#action")
8
+ allow(Arrthorizer::Rails::ControllerAction).to receive(:key_for).with(controller).and_return("controller#action")
9
9
  end
10
10
 
11
11
  context "when there is no configuration for the current action" do
@@ -11,7 +11,7 @@ describe Arrthorizer::Rails::ControllerConcern do
11
11
  end
12
12
  end
13
13
 
14
- controller.stub(:request).and_return(ActionDispatch::TestRequest.new)
14
+ allow(controller).to receive(:request).and_return(ActionDispatch::TestRequest.new)
15
15
  end
16
16
 
17
17
  describe :arrthorizer_context do
@@ -11,10 +11,10 @@ describe Arrthorizer::Rails::ControllerConcern do
11
11
  let(:context){ double("context") }
12
12
 
13
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)
14
+ allow(controller).to receive(:action_name).and_return(action_name)
15
+ allow(controller).to receive(:current_user).and_return(current_user)
16
+ allow(controller).to receive(:arrthorizer_context).and_return(context)
17
+ allow(controller).to receive(:controller_path).and_return(controller_path)
18
18
  end
19
19
 
20
20
  describe :authorize do
@@ -31,8 +31,8 @@ describe Arrthorizer::Rails::ControllerConcern do
31
31
  let(:permitted_roles){ Arrthorizer::Registry.new }
32
32
 
33
33
  before do
34
- controller_action.stub(:privilege).and_return(privilege)
35
- privilege.stub(:permitted_roles).and_return(permitted_roles)
34
+ allow(controller_action).to receive(:privilege).and_return(privilege)
35
+ allow(privilege).to receive(:permitted_roles).and_return(permitted_roles)
36
36
  end
37
37
 
38
38
  context "but the privilege has no permitted roles" do
@@ -47,7 +47,7 @@ describe Arrthorizer::Rails::ControllerConcern do
47
47
  let(:role){ Arrthorizer::Role.new }
48
48
 
49
49
  before do
50
- role.stub(:name).and_return('some_role')
50
+ allow(role).to receive(:name).and_return('some_role')
51
51
  permitted_roles.add(role)
52
52
  end
53
53
 
@@ -55,9 +55,9 @@ describe Arrthorizer::Rails::ControllerConcern do
55
55
  let(:error) { Class.new(StandardError).new }
56
56
 
57
57
  before :each do
58
- controller.stub(:arrthorizer_context).and_raise(error)
58
+ allow(controller).to receive(:arrthorizer_context).and_raise(error)
59
59
  # for testing purposes. We're testing a filter here, so no request exists, causing #status= to fail
60
- controller.stub(:forbidden)
60
+ allow(controller).to receive(:forbidden)
61
61
  end
62
62
 
63
63
  specify "that error not suppressed" do
@@ -69,7 +69,7 @@ describe Arrthorizer::Rails::ControllerConcern do
69
69
 
70
70
  context "and the role applies to the user" do
71
71
  before do
72
- role.stub(:applies_to_user?).with(current_user, context).and_return(true)
72
+ allow(role).to receive(:applies_to_user?).with(current_user, context).and_return(true)
73
73
  end
74
74
 
75
75
  it "is not forbidden" do
@@ -81,7 +81,7 @@ describe Arrthorizer::Rails::ControllerConcern do
81
81
 
82
82
  context "and the role does not apply to the user" do
83
83
  before do
84
- role.stub(:applies_to_user?).with(current_user, context).and_return(false)
84
+ allow(role).to receive(:applies_to_user?).with(current_user, context).and_return(false)
85
85
  end
86
86
 
87
87
  it "is forbidden" do
@@ -94,13 +94,13 @@ describe Arrthorizer::Rails::ControllerConcern do
94
94
  let(:another_role){ Arrthorizer::Role.new }
95
95
 
96
96
  before do
97
- another_role.stub(:name).and_return('another_role')
97
+ allow(another_role).to receive(:name).and_return('another_role')
98
98
  permitted_roles.add(another_role)
99
99
  end
100
100
 
101
101
  context "and the role applies to the user" do
102
102
  before do
103
- another_role.stub(:applies_to_user?).with(current_user, context).and_return(true)
103
+ allow(another_role).to receive(:applies_to_user?).with(current_user, context).and_return(true)
104
104
  end
105
105
 
106
106
  it "is not forbidden" do
@@ -112,7 +112,7 @@ describe Arrthorizer::Rails::ControllerConcern do
112
112
 
113
113
  context "and the role does not apply to the user" do
114
114
  before do
115
- another_role.stub(:applies_to_user?).with(current_user, context).and_return(false)
115
+ allow(another_role).to receive(:applies_to_user?).with(current_user, context).and_return(false)
116
116
  end
117
117
 
118
118
  it "is forbidden" do
@@ -126,12 +126,12 @@ describe Arrthorizer::Rails::ControllerConcern do
126
126
 
127
127
  context "but evaluating the role raises any kind of StandardError" do
128
128
  before do
129
- role.stub(:applies_to_user?).with(current_user, context).and_raise("Some exception")
129
+ allow(role).to receive(:applies_to_user?).with(current_user, context).and_raise("Some exception")
130
130
  end
131
131
 
132
132
  specify "a warning is logged" do
133
133
  # for testing purposes. We're testing a filter here, so no request exists, causing #status= to fail
134
- controller.stub(:forbidden)
134
+ allow(controller).to receive(:forbidden)
135
135
 
136
136
  expect(::Rails.logger).to receive(:warn).with(an_instance_of(String))
137
137
 
@@ -142,7 +142,7 @@ describe Arrthorizer::Rails::ControllerConcern do
142
142
  let(:another_role){ Arrthorizer::Group.new("some other role") }
143
143
 
144
144
  before :each do
145
- another_role.stub(:applies_to_user?).and_return(true)
145
+ allow(another_role).to receive(:applies_to_user?).and_return(true)
146
146
  permitted_roles.add(another_role)
147
147
  end
148
148
 
@@ -30,9 +30,9 @@ describe Arrthorizer::Rails do
30
30
  let(:current_action) { 'some_action' }
31
31
 
32
32
  before :each do
33
- controller.stub(:params).and_return injected_params
33
+ allow(controller).to receive(:params).and_return injected_params
34
34
 
35
- controller.stub(:action_name).and_return(current_action)
35
+ allow(controller).to receive(:action_name).and_return(current_action)
36
36
  end
37
37
 
38
38
  context "and there is no specific configuration for the current action" do
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arrthorizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
5
- prerelease:
4
+ version: 0.3.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - René van den Berg
@@ -10,72 +9,64 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2014-07-04 00:00:00.000000000 Z
12
+ date: 2015-02-03 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rails
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - ">="
21
19
  - !ruby/object:Gem::Version
22
20
  version: 3.2.18
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - ">="
29
26
  - !ruby/object:Gem::Version
30
27
  version: 3.2.18
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: combustion
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ~>
32
+ - - "~>"
37
33
  - !ruby/object:Gem::Version
38
34
  version: 0.5.1
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ~>
39
+ - - "~>"
45
40
  - !ruby/object:Gem::Version
46
41
  version: 0.5.1
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: sqlite3
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - ">="
53
47
  - !ruby/object:Gem::Version
54
48
  version: '0'
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ! '>='
53
+ - - ">="
61
54
  - !ruby/object:Gem::Version
62
55
  version: '0'
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: rspec-rails
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ! '>='
60
+ - - ">="
69
61
  - !ruby/object:Gem::Version
70
- version: '0'
62
+ version: '3'
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ! '>='
67
+ - - ">="
77
68
  - !ruby/object:Gem::Version
78
- version: '0'
69
+ version: '3'
79
70
  description: Contextual authorization for your Rails (3+) application
80
71
  email:
81
72
  - rene.vandenberg@ogd.nl
@@ -84,8 +75,8 @@ executables: []
84
75
  extensions: []
85
76
  extra_rdoc_files: []
86
77
  files:
87
- - .gitignore
88
- - .travis.yml
78
+ - ".gitignore"
79
+ - ".travis.yml"
89
80
  - LICENSE.txt
90
81
  - README.md
91
82
  - Rakefile
@@ -188,33 +179,26 @@ files:
188
179
  - spec/support/reset.rb
189
180
  homepage: https://github.com/BUS-ogd/arrthorizer
190
181
  licenses: []
182
+ metadata: {}
191
183
  post_install_message:
192
184
  rdoc_options: []
193
185
  require_paths:
194
186
  - lib
195
187
  required_ruby_version: !ruby/object:Gem::Requirement
196
- none: false
197
188
  requirements:
198
- - - ! '>='
189
+ - - ">="
199
190
  - !ruby/object:Gem::Version
200
191
  version: '0'
201
- segments:
202
- - 0
203
- hash: 4363344395387857595
204
192
  required_rubygems_version: !ruby/object:Gem::Requirement
205
- none: false
206
193
  requirements:
207
- - - ! '>='
194
+ - - ">="
208
195
  - !ruby/object:Gem::Version
209
196
  version: '0'
210
- segments:
211
- - 0
212
- hash: 4363344395387857595
213
197
  requirements: []
214
198
  rubyforge_project:
215
- rubygems_version: 1.8.24
199
+ rubygems_version: 2.4.3
216
200
  signing_key:
217
- specification_version: 3
201
+ specification_version: 4
218
202
  summary: Contextual authorization for your Rails (3+) application
219
203
  test_files:
220
204
  - spec/arrthorizer_exception/inner_spec.rb