rspec-authorization 0.0.2 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/Appraisals +7 -0
- data/Gemfile +9 -5
- data/HISTORY.md +20 -1
- data/README.md +28 -3
- data/gemfiles/rails_4.1.9.gemfile +28 -0
- data/gemfiles/rails_4.1.9.gemfile.lock +234 -0
- data/gemfiles/rails_4.2.0.gemfile +28 -0
- data/gemfiles/rails_4.2.0.gemfile.lock +260 -0
- data/lib/rspec/authorization/adapters.rb +3 -0
- data/lib/rspec/authorization/adapters/privilege.rb +14 -0
- data/lib/rspec/authorization/adapters/request.rb +4 -1
- data/lib/rspec/authorization/adapters/resource.rb +58 -0
- data/lib/rspec/authorization/adapters/restful_helper_method.rb +137 -0
- data/lib/rspec/authorization/matchers/have_permission_for.rb +93 -70
- data/lib/rspec/authorization/version.rb +1 -1
- data/rspec-authorization.gemspec +2 -1
- data/spec/controllers/articles_controller_spec.rb +3 -11
- data/spec/lib/rspec/authorization/adapters/resource_spec.rb +102 -0
- data/spec/lib/rspec/authorization/adapters/restful_helper_method_spec.rb +151 -0
- data/spec/lib/rspec/authorization/matchers/have_permission_for_spec.rb +81 -0
- data/spec/rails_helper.rb +1 -0
- data/tools/rails_test_app/template.rb +9 -5
- metadata +36 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c0e42d91eed5377d30cc6625bd461db6a68b9a3
|
4
|
+
data.tar.gz: c783bc1d2eff3831d65b23b00e48948fff90193a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b9883688d603bd9aa202c9be14a71d077b79d9e7293e28b1002676edc8ae7d8967fbe9698e57151f06ebc7421f7a239fa149eb945630a894588ea609c6486c7
|
7
|
+
data.tar.gz: 1c0a17be3ad7dd55aef48c39f51b0ef5ac14739b2ad925d18324ccf0bbcdfa30ec64df03e8a74df6aff1617dd89d62545b66e8d9c7e0fe3069f80c44b54356ea
|
data/.travis.yml
CHANGED
data/Appraisals
ADDED
data/Gemfile
CHANGED
@@ -1,19 +1,23 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
-
ruby '2.1.4'
|
3
|
-
|
4
2
|
gemspec
|
5
3
|
|
6
4
|
group :development, :test do
|
5
|
+
gem "codeclimate-test-reporter", require: nil
|
7
6
|
gem 'declarative_authorization', github: 'stffn/declarative_authorization'
|
7
|
+
gem 'devise'
|
8
8
|
gem 'guard-rspec'
|
9
|
+
gem 'jquery-rails'
|
10
|
+
|
9
11
|
gem 'pry'
|
12
|
+
gem 'pry-byebug'
|
10
13
|
gem 'terminal-notifier-guard' if `uname` =~ /Darwin/
|
11
|
-
gem "codeclimate-test-reporter", require: nil
|
12
|
-
|
13
|
-
gem 'jquery-rails'
|
14
14
|
gem 'turbolinks'
|
15
15
|
end
|
16
16
|
|
17
|
+
group :test do
|
18
|
+
gem 'shoulda-matchers', require: false
|
19
|
+
end
|
20
|
+
|
17
21
|
group :docs do
|
18
22
|
gem "inch"
|
19
23
|
gem "rdoc"
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
[v0.0.6 / 2015-03-19] (https://github.com/hendrauzia/rspec-authorization/tree/v0.0.6)
|
2
|
+
=====================
|
3
|
+
|
4
|
+
* Fix travis build matrix
|
5
|
+
* Add appraisal to test on multiple dependencies
|
6
|
+
* Stub all before and after callback except filter_access_filter
|
7
|
+
* Refactor resource initialization to use privilege class.
|
8
|
+
* Refactor restful helper method actions and negated actions out of resource
|
9
|
+
* Refactor permitted or forbidden into 2 separate permitted and forbidden methods
|
10
|
+
* Refactor run all requests and permitted or forbidden to resource
|
11
|
+
* Refactor actions, results and their negated counterparts to resource
|
12
|
+
* Refactor actions and negated actions from have_permission_to to resource
|
13
|
+
* Refactor restful helper method to resource class
|
14
|
+
* Refactor multiple request running to a resource class
|
15
|
+
* Refactor have permission for matcher
|
16
|
+
* Refactor restful helper method initialization
|
17
|
+
* Add focused restful helper method
|
18
|
+
* Refactor restful helper method generation from method missing to a class
|
19
|
+
* Refactor RESTful matcher method helper to use ruby's #method_missing
|
20
|
+
* Add license and history information in README
|
1
21
|
|
2
22
|
[v0.0.2 / 2014-11-11] (https://github.com/hendrauzia/rspec-authorization/tree/v0.0.2)
|
3
23
|
=====================
|
@@ -29,4 +49,3 @@
|
|
29
49
|
* Add rspec-rails for specs
|
30
50
|
* Add rspec-authorization gem scaffold using bundler
|
31
51
|
* Initial commit
|
32
|
-
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[![GitHub](http://img.shields.io/badge/github-hendrauzia/rspec--authorization-blue.svg)](http://github.com/hendrauzia/rspec-authorization)
|
4
4
|
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://rubydoc.org/github/hendrauzia/rspec-authorization)
|
5
|
+
[![License](http://img.shields.io/badge/license-MIT-blue.svg)](#license)
|
5
6
|
|
6
7
|
[![Gem Version](https://badge.fury.io/rb/rspec-authorization.svg)](http://badge.fury.io/rb/rspec-authorization)
|
7
8
|
[![Build Status](https://travis-ci.org/hendrauzia/rspec-authorization.svg)](https://travis-ci.org/hendrauzia/rspec-authorization)
|
@@ -19,7 +20,13 @@ declarative_authorization's rules inside controller using RSpec matcher.
|
|
19
20
|
Add this line to your application's Gemfile:
|
20
21
|
|
21
22
|
|
22
|
-
gem 'rspec-authorization', group: :test
|
23
|
+
gem 'rspec-authorization', group: :test, require: false
|
24
|
+
|
25
|
+
|
26
|
+
Add this to `spec_helper.rb`:
|
27
|
+
|
28
|
+
|
29
|
+
require 'rspec/authorization'
|
23
30
|
|
24
31
|
|
25
32
|
And then execute:
|
@@ -37,7 +44,7 @@ dependencies, following are requirements for this gem:
|
|
37
44
|
|
38
45
|
- declarative_authorization 1.0.0.pre
|
39
46
|
- rails 4.x
|
40
|
-
- rspec-rails 3.x
|
47
|
+
- rspec-rails 3.1.x
|
41
48
|
|
42
49
|
## Usage
|
43
50
|
|
@@ -55,7 +62,7 @@ In your controller spec:
|
|
55
62
|
it { is_expected.not_to have_permission_for(:writer).to(:destroy) }
|
56
63
|
end
|
57
64
|
|
58
|
-
You can also use convenience
|
65
|
+
You can also use convenience restful helper methods:
|
59
66
|
|
60
67
|
describe ArticlesController do
|
61
68
|
it { is_expected.to have_permission_for(:user).to_read }
|
@@ -71,6 +78,24 @@ You can also use convenience RESTful methods matcher:
|
|
71
78
|
it { is_expected.to have_permission_for(:editor).to_manage }
|
72
79
|
end
|
73
80
|
|
81
|
+
Or you can also use the focused restful helper method as follows:
|
82
|
+
|
83
|
+
describe ArticlesController do
|
84
|
+
it { is_expected.to have_permision_for(:user).only_to_read }
|
85
|
+
it { is_expected.to have_permision_for(:writer).except_to_delete }
|
86
|
+
end
|
87
|
+
|
88
|
+
## History
|
89
|
+
|
90
|
+
See {file:HISTORY.md} for history of changes.
|
91
|
+
|
92
|
+
## License
|
93
|
+
|
94
|
+
rspec-authorization © 2014 by Hendra Uzia. rspec-authorization is
|
95
|
+
licensed under the MIT license except for some files which come from the
|
96
|
+
RDoc/Ruby distributions. Please see the {file:LICENSE.txt} documents
|
97
|
+
for more information.
|
98
|
+
|
74
99
|
## Contributing
|
75
100
|
|
76
101
|
1. Fork it ( https://github.com/hendrauzia/rspec-authorization/fork )
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "4.1.9"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "codeclimate-test-reporter", :require => nil
|
9
|
+
gem "declarative_authorization", :github => "stffn/declarative_authorization"
|
10
|
+
gem "devise"
|
11
|
+
gem "guard-rspec"
|
12
|
+
gem "jquery-rails"
|
13
|
+
gem "pry"
|
14
|
+
gem "pry-byebug"
|
15
|
+
gem "turbolinks"
|
16
|
+
end
|
17
|
+
|
18
|
+
group :test do
|
19
|
+
gem "shoulda-matchers", :require => false
|
20
|
+
end
|
21
|
+
|
22
|
+
group :docs do
|
23
|
+
gem "inch"
|
24
|
+
gem "rdoc"
|
25
|
+
gem "yard"
|
26
|
+
end
|
27
|
+
|
28
|
+
gemspec :path => "../"
|
@@ -0,0 +1,234 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/stffn/declarative_authorization.git
|
3
|
+
revision: 45e91af20eba71b2828c5c84066bcce3ef032e8a
|
4
|
+
specs:
|
5
|
+
declarative_authorization (1.0.0.pre)
|
6
|
+
|
7
|
+
PATH
|
8
|
+
remote: ../
|
9
|
+
specs:
|
10
|
+
rspec-authorization (0.0.6)
|
11
|
+
declarative_authorization
|
12
|
+
rspec-rails (~> 3.0, < 3.2)
|
13
|
+
|
14
|
+
GEM
|
15
|
+
remote: https://rubygems.org/
|
16
|
+
specs:
|
17
|
+
actionmailer (4.1.9)
|
18
|
+
actionpack (= 4.1.9)
|
19
|
+
actionview (= 4.1.9)
|
20
|
+
mail (~> 2.5, >= 2.5.4)
|
21
|
+
actionpack (4.1.9)
|
22
|
+
actionview (= 4.1.9)
|
23
|
+
activesupport (= 4.1.9)
|
24
|
+
rack (~> 1.5.2)
|
25
|
+
rack-test (~> 0.6.2)
|
26
|
+
actionview (4.1.9)
|
27
|
+
activesupport (= 4.1.9)
|
28
|
+
builder (~> 3.1)
|
29
|
+
erubis (~> 2.7.0)
|
30
|
+
activemodel (4.1.9)
|
31
|
+
activesupport (= 4.1.9)
|
32
|
+
builder (~> 3.1)
|
33
|
+
activerecord (4.1.9)
|
34
|
+
activemodel (= 4.1.9)
|
35
|
+
activesupport (= 4.1.9)
|
36
|
+
arel (~> 5.0.0)
|
37
|
+
activesupport (4.1.9)
|
38
|
+
i18n (~> 0.6, >= 0.6.9)
|
39
|
+
json (~> 1.7, >= 1.7.7)
|
40
|
+
minitest (~> 5.1)
|
41
|
+
thread_safe (~> 0.1)
|
42
|
+
tzinfo (~> 1.1)
|
43
|
+
appraisal (1.0.3)
|
44
|
+
bundler
|
45
|
+
rake
|
46
|
+
thor (>= 0.14.0)
|
47
|
+
arel (5.0.1.20140414130214)
|
48
|
+
bcrypt (3.1.10)
|
49
|
+
builder (3.2.2)
|
50
|
+
byebug (4.0.3)
|
51
|
+
columnize (= 0.9.0)
|
52
|
+
celluloid (0.16.0)
|
53
|
+
timers (~> 4.0.0)
|
54
|
+
codeclimate-test-reporter (0.4.7)
|
55
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
56
|
+
coderay (1.1.0)
|
57
|
+
coffee-rails (4.1.0)
|
58
|
+
coffee-script (>= 2.2.0)
|
59
|
+
railties (>= 4.0.0, < 5.0)
|
60
|
+
coffee-script (2.3.0)
|
61
|
+
coffee-script-source
|
62
|
+
execjs
|
63
|
+
coffee-script-source (1.9.1)
|
64
|
+
columnize (0.9.0)
|
65
|
+
devise (3.4.1)
|
66
|
+
bcrypt (~> 3.0)
|
67
|
+
orm_adapter (~> 0.1)
|
68
|
+
railties (>= 3.2.6, < 5)
|
69
|
+
responders
|
70
|
+
thread_safe (~> 0.1)
|
71
|
+
warden (~> 1.2.3)
|
72
|
+
diff-lcs (1.2.5)
|
73
|
+
docile (1.1.5)
|
74
|
+
erubis (2.7.0)
|
75
|
+
execjs (2.4.0)
|
76
|
+
ffi (1.9.8)
|
77
|
+
formatador (0.2.5)
|
78
|
+
guard (2.12.5)
|
79
|
+
formatador (>= 0.2.4)
|
80
|
+
listen (~> 2.7)
|
81
|
+
lumberjack (~> 1.0)
|
82
|
+
nenv (~> 0.1)
|
83
|
+
notiffany (~> 0.0)
|
84
|
+
pry (>= 0.9.12)
|
85
|
+
shellany (~> 0.0)
|
86
|
+
thor (>= 0.18.1)
|
87
|
+
guard-compat (1.2.1)
|
88
|
+
guard-rspec (4.5.0)
|
89
|
+
guard (~> 2.1)
|
90
|
+
guard-compat (~> 1.1)
|
91
|
+
rspec (>= 2.99.0, < 4.0)
|
92
|
+
hike (1.2.3)
|
93
|
+
hitimes (1.2.2)
|
94
|
+
i18n (0.7.0)
|
95
|
+
inch (0.5.10)
|
96
|
+
pry
|
97
|
+
sparkr (>= 0.2.0)
|
98
|
+
term-ansicolor
|
99
|
+
yard (~> 0.8.7.5)
|
100
|
+
jquery-rails (3.1.2)
|
101
|
+
railties (>= 3.0, < 5.0)
|
102
|
+
thor (>= 0.14, < 2.0)
|
103
|
+
json (1.8.2)
|
104
|
+
listen (2.9.0)
|
105
|
+
celluloid (>= 0.15.2)
|
106
|
+
rb-fsevent (>= 0.9.3)
|
107
|
+
rb-inotify (>= 0.9)
|
108
|
+
lumberjack (1.0.9)
|
109
|
+
mail (2.6.3)
|
110
|
+
mime-types (>= 1.16, < 3)
|
111
|
+
method_source (0.8.2)
|
112
|
+
mime-types (2.4.3)
|
113
|
+
minitest (5.5.1)
|
114
|
+
multi_json (1.11.0)
|
115
|
+
nenv (0.2.0)
|
116
|
+
notiffany (0.0.6)
|
117
|
+
nenv (~> 0.1)
|
118
|
+
shellany (~> 0.0)
|
119
|
+
orm_adapter (0.5.0)
|
120
|
+
pry (0.10.1)
|
121
|
+
coderay (~> 1.1.0)
|
122
|
+
method_source (~> 0.8.1)
|
123
|
+
slop (~> 3.4)
|
124
|
+
pry-byebug (3.1.0)
|
125
|
+
byebug (~> 4.0)
|
126
|
+
pry (~> 0.10)
|
127
|
+
rack (1.5.2)
|
128
|
+
rack-test (0.6.3)
|
129
|
+
rack (>= 1.0)
|
130
|
+
rails (4.1.9)
|
131
|
+
actionmailer (= 4.1.9)
|
132
|
+
actionpack (= 4.1.9)
|
133
|
+
actionview (= 4.1.9)
|
134
|
+
activemodel (= 4.1.9)
|
135
|
+
activerecord (= 4.1.9)
|
136
|
+
activesupport (= 4.1.9)
|
137
|
+
bundler (>= 1.3.0, < 2.0)
|
138
|
+
railties (= 4.1.9)
|
139
|
+
sprockets-rails (~> 2.0)
|
140
|
+
railties (4.1.9)
|
141
|
+
actionpack (= 4.1.9)
|
142
|
+
activesupport (= 4.1.9)
|
143
|
+
rake (>= 0.8.7)
|
144
|
+
thor (>= 0.18.1, < 2.0)
|
145
|
+
rake (10.4.2)
|
146
|
+
rb-fsevent (0.9.4)
|
147
|
+
rb-inotify (0.9.5)
|
148
|
+
ffi (>= 0.5.0)
|
149
|
+
rdoc (4.2.0)
|
150
|
+
json (~> 1.4)
|
151
|
+
responders (1.1.2)
|
152
|
+
railties (>= 3.2, < 4.2)
|
153
|
+
rspec (3.1.0)
|
154
|
+
rspec-core (~> 3.1.0)
|
155
|
+
rspec-expectations (~> 3.1.0)
|
156
|
+
rspec-mocks (~> 3.1.0)
|
157
|
+
rspec-core (3.1.7)
|
158
|
+
rspec-support (~> 3.1.0)
|
159
|
+
rspec-expectations (3.1.2)
|
160
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
161
|
+
rspec-support (~> 3.1.0)
|
162
|
+
rspec-its (1.2.0)
|
163
|
+
rspec-core (>= 3.0.0)
|
164
|
+
rspec-expectations (>= 3.0.0)
|
165
|
+
rspec-mocks (3.1.3)
|
166
|
+
rspec-support (~> 3.1.0)
|
167
|
+
rspec-rails (3.1.0)
|
168
|
+
actionpack (>= 3.0)
|
169
|
+
activesupport (>= 3.0)
|
170
|
+
railties (>= 3.0)
|
171
|
+
rspec-core (~> 3.1.0)
|
172
|
+
rspec-expectations (~> 3.1.0)
|
173
|
+
rspec-mocks (~> 3.1.0)
|
174
|
+
rspec-support (~> 3.1.0)
|
175
|
+
rspec-support (3.1.2)
|
176
|
+
shellany (0.0.1)
|
177
|
+
shoulda-matchers (2.8.0)
|
178
|
+
activesupport (>= 3.0.0)
|
179
|
+
simplecov (0.9.2)
|
180
|
+
docile (~> 1.1.0)
|
181
|
+
multi_json (~> 1.0)
|
182
|
+
simplecov-html (~> 0.9.0)
|
183
|
+
simplecov-html (0.9.0)
|
184
|
+
slop (3.6.0)
|
185
|
+
sparkr (0.4.1)
|
186
|
+
sprockets (2.12.3)
|
187
|
+
hike (~> 1.2)
|
188
|
+
multi_json (~> 1.0)
|
189
|
+
rack (~> 1.0)
|
190
|
+
tilt (~> 1.1, != 1.3.0)
|
191
|
+
sprockets-rails (2.2.4)
|
192
|
+
actionpack (>= 3.0)
|
193
|
+
activesupport (>= 3.0)
|
194
|
+
sprockets (>= 2.8, < 4.0)
|
195
|
+
sqlite3 (1.3.10)
|
196
|
+
term-ansicolor (1.3.0)
|
197
|
+
tins (~> 1.0)
|
198
|
+
thor (0.19.1)
|
199
|
+
thread_safe (0.3.5)
|
200
|
+
tilt (1.4.1)
|
201
|
+
timers (4.0.1)
|
202
|
+
hitimes
|
203
|
+
tins (1.3.5)
|
204
|
+
turbolinks (2.5.3)
|
205
|
+
coffee-rails
|
206
|
+
tzinfo (1.2.2)
|
207
|
+
thread_safe (~> 0.1)
|
208
|
+
warden (1.2.3)
|
209
|
+
rack (>= 1.0)
|
210
|
+
yard (0.8.7.6)
|
211
|
+
|
212
|
+
PLATFORMS
|
213
|
+
ruby
|
214
|
+
|
215
|
+
DEPENDENCIES
|
216
|
+
appraisal
|
217
|
+
bundler (~> 1.7)
|
218
|
+
codeclimate-test-reporter
|
219
|
+
declarative_authorization!
|
220
|
+
devise
|
221
|
+
guard-rspec
|
222
|
+
inch
|
223
|
+
jquery-rails
|
224
|
+
pry
|
225
|
+
pry-byebug
|
226
|
+
rails (= 4.1.9)
|
227
|
+
rake (~> 10.0)
|
228
|
+
rdoc
|
229
|
+
rspec-authorization!
|
230
|
+
rspec-its
|
231
|
+
shoulda-matchers
|
232
|
+
sqlite3
|
233
|
+
turbolinks
|
234
|
+
yard
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "4.2.0"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "codeclimate-test-reporter", :require => nil
|
9
|
+
gem "declarative_authorization", :github => "stffn/declarative_authorization"
|
10
|
+
gem "devise"
|
11
|
+
gem "guard-rspec"
|
12
|
+
gem "jquery-rails"
|
13
|
+
gem "pry"
|
14
|
+
gem "pry-byebug"
|
15
|
+
gem "turbolinks"
|
16
|
+
end
|
17
|
+
|
18
|
+
group :test do
|
19
|
+
gem "shoulda-matchers", :require => false
|
20
|
+
end
|
21
|
+
|
22
|
+
group :docs do
|
23
|
+
gem "inch"
|
24
|
+
gem "rdoc"
|
25
|
+
gem "yard"
|
26
|
+
end
|
27
|
+
|
28
|
+
gemspec :path => "../"
|