abilities 0.1.2 → 4.0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +31 -44
  4. data/Rakefile +1 -14
  5. data/lib/abilities.rb +9 -18
  6. data/lib/abilities/definitions.rb +38 -29
  7. data/lib/abilities/extensions/action_controller/base.rb +28 -0
  8. data/lib/abilities/proxy.rb +6 -7
  9. data/lib/abilities/railtie.rb +4 -3
  10. data/lib/abilities/version.rb +1 -1
  11. data/lib/generators/abilities/install/install_generator.rb +15 -0
  12. data/lib/generators/abilities/{templates/abilities.rb → install/templates/configuration.rb} +0 -0
  13. data/test/dummy/Rakefile +0 -1
  14. data/test/dummy/app/assets/javascripts/application.js +2 -2
  15. data/test/dummy/app/assets/stylesheets/application.css +1 -1
  16. data/test/dummy/app/controllers/products_controller.rb +10 -0
  17. data/test/dummy/app/models/product.rb +2 -0
  18. data/test/dummy/app/models/user.rb +0 -1
  19. data/test/dummy/app/views/layouts/application.html.erb +9 -11
  20. data/test/dummy/app/views/products/show.html.erb +6 -0
  21. data/test/dummy/bin/bundle +1 -0
  22. data/test/dummy/bin/rails +2 -1
  23. data/test/dummy/bin/rake +1 -0
  24. data/test/dummy/bin/setup +30 -0
  25. data/test/dummy/config.ru +1 -1
  26. data/test/dummy/config/abilities.rb +6 -7
  27. data/test/dummy/config/application.rb +3 -0
  28. data/test/dummy/config/database.yml +4 -22
  29. data/test/dummy/config/database.yml.travis +3 -0
  30. data/test/dummy/config/environments/development.rb +6 -2
  31. data/test/dummy/config/environments/production.rb +16 -24
  32. data/test/dummy/config/environments/test.rb +7 -12
  33. data/test/dummy/config/initializers/assets.rb +11 -0
  34. data/test/dummy/config/initializers/mime_types.rb +1 -1
  35. data/test/dummy/config/routes.rb +1 -54
  36. data/test/dummy/config/secrets.yml +3 -3
  37. data/test/dummy/db/migrate/20140629203344_create_users.rb +1 -3
  38. data/test/dummy/db/migrate/20140629203412_create_products.rb +7 -0
  39. data/test/dummy/db/schema.rb +9 -9
  40. data/test/dummy/log/development.log +78 -0
  41. data/test/dummy/log/test.log +1465 -246
  42. data/test/dummy/public/404.html +57 -63
  43. data/test/dummy/public/422.html +57 -63
  44. data/test/dummy/public/500.html +56 -62
  45. data/test/dummy/tmp/cache/assets/sprockets/v3.0/2b/2bzOr5XdBQAg_ZBDeXY157jGXLRL6qjEoFZBTPyLFwM.cache +0 -0
  46. data/test/dummy/tmp/cache/assets/sprockets/v3.0/48/48oV_bpl6OaHjWm9j-I1uNUp5m7SbkTgYjW6NaNnTfU.cache +0 -0
  47. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
  48. data/test/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +2 -0
  49. data/test/dummy/tmp/cache/assets/sprockets/v3.0/SG/SGNGr7AZfBE1q7ev2-YM1G-o0XAZ0pKqbsS3NvHtRcA.cache +1 -0
  50. data/test/dummy/tmp/cache/assets/sprockets/v3.0/fG/fG_uaNK13wisQiji91xNsGecGxX9QhMCF2eSX_aR0G0.cache +1 -0
  51. data/test/dummy/tmp/cache/assets/sprockets/v3.0/gb/gbunrAFVOHPwl2npUgKv_C3f_qiJnZDd9zG5-h3jrpo.cache +1 -0
  52. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +2 -0
  53. data/test/dummy/tmp/cache/assets/sprockets/v3.0/j0/j06P5zp022n2VUoAPi5fqCp_UbS7OaCD8XtVtEbHy58.cache +0 -0
  54. data/test/dummy/tmp/cache/assets/sprockets/v3.0/mv/mvqN6PphkrOOC8zbUEhpC_9E_4ybdO25MRy_gG6dq3Y.cache +1 -0
  55. data/test/dummy/tmp/cache/assets/sprockets/v3.0/nm/nmcUZlKAIwyJ_35Nm9P8pukLeRX5aApP6NFj5MpNPgc.cache +1 -0
  56. data/test/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
  57. data/test/dummy/tmp/cache/assets/sprockets/v3.0/sB/sB6xWxBmgzVC0Co9__ANYrE58lr4WPwiwFa9mswooWM.cache +0 -0
  58. data/test/dummy/tmp/cache/assets/sprockets/v3.0/va/vaNrIny9hchHD9eIJxAicyYLC7qeV4PTh4Nh40_Y6Vg.cache +1 -0
  59. data/test/dummy/tmp/cache/assets/sprockets/v3.0/x6/x6W7JXRDHOmqATQMRSTLu17o8EcA-ietA1qm_PMPjbo.cache +0 -0
  60. data/test/dummy/tmp/cache/assets/sprockets/v3.0/xd/xdBKQyhEAlDIstGvXw945PWJoEWi23rKuY7elOcWqHc.cache +1 -0
  61. data/test/generator_test.rb +4 -4
  62. data/test/policy_test.rb +62 -0
  63. data/test/test_helper.rb +5 -16
  64. data/test/view_test.rb +6 -17
  65. metadata +63 -32
  66. data/lib/abilities/action_controller/base.rb +0 -20
  67. data/lib/abilities/action_view/base.rb +0 -14
  68. data/lib/abilities/concern.rb +0 -12
  69. data/lib/abilities/configuration.rb +0 -13
  70. data/lib/generators/abilities/install_generator.rb +0 -13
  71. data/test/changes_test.rb +0 -12
  72. data/test/checking_test.rb +0 -64
  73. data/test/controller_test.rb +0 -38
  74. data/test/dummy/README.rdoc +0 -28
  75. data/test/dummy/app/models/post.rb +0 -3
  76. data/test/dummy/config/initializers/abilities.rb +0 -7
  77. data/test/dummy/config/initializers/secret_token.rb +0 -1
  78. data/test/dummy/db/migrate/20140629203412_create_posts.rb +0 -10
@@ -1,24 +1,13 @@
1
1
  # Configure Rails Environment
2
2
  ENV['RAILS_ENV'] = 'test'
3
3
 
4
- require File.expand_path('../dummy/config/environment.rb', __FILE__)
4
+ require File.expand_path('../../test/dummy/config/environment.rb', __FILE__)
5
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path('../../test/dummy/db/migrate', __FILE__)]
5
6
  require 'rails/test_help'
6
7
 
7
- Rails.backtrace_cleaner.remove_silencers!
8
+ # Filter out Minitest backtrace while allowing backtrace from other libraries
9
+ # to be shown.
10
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
8
11
 
9
12
  # Load support files
10
13
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
-
12
- # Load fixtures from the engine
13
- if ActiveSupport::TestCase.method_defined?(:fixture_path=)
14
- ActiveSupport::TestCase.fixture_path = File.expand_path('../fixtures', __FILE__)
15
- end
16
-
17
- # Load database
18
- config = YAML::load(File.read(File.expand_path('../dummy/config/database.yml', __FILE__)))
19
- config['test']['adapter'] = 'jdbcsqlite3' if RUBY_PLATFORM == 'java'
20
- ActiveRecord::Base.establish_connection(config['test'])
21
- load(File.expand_path('../dummy/db/schema.rb', __FILE__))
22
-
23
- # Include helpers
24
- ActionView::TestCase.send :include, Abilities::ActionView::Base
@@ -1,23 +1,12 @@
1
1
  require 'test_helper'
2
2
 
3
- class ViewTest < ActionView::TestCase
3
+ class ViewTest < ActionDispatch::IntegrationTest
4
4
 
5
- test 'can helper' do
6
- assert can?(:create, post)
7
- end
8
-
9
- test 'cannot helper' do
10
- assert cannot?(:read, post)
11
- end
12
-
13
- private
14
-
15
- def post
16
- @post ||= Post.new
17
- end
18
-
19
- def current_user
20
- @user ||= User.new
5
+ test 'helpers' do
6
+ get product_path
7
+ assert_response :success
8
+ assert_select 'a', 'Touch'
9
+ assert_select 'a', 'Destroy'
21
10
  end
22
11
 
23
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abilities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 4.0.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmontossi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-29 00:00:00.000000000 Z
11
+ date: 2016-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.0
19
+ version: 4.2.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: 4.3.0
@@ -26,27 +26,27 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 4.0.0
29
+ version: 4.2.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 4.3.0
33
33
  - !ruby/object:Gem::Dependency
34
- name: sqlite3
34
+ name: pg
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '1.3'
39
+ version: '0.18'
40
40
  type: :development
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '1.3'
47
- description: Minimalistic authorization inspired in cancan for rails.
46
+ version: '0.18'
47
+ description: Authorization dsl to manage permissions in rails.
48
48
  email:
49
- - mmontossi@buyin.io
49
+ - mmontossi@gmail.com
50
50
  executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
@@ -55,62 +55,76 @@ files:
55
55
  - README.md
56
56
  - Rakefile
57
57
  - lib/abilities.rb
58
- - lib/abilities/action_controller/base.rb
59
- - lib/abilities/action_view/base.rb
60
- - lib/abilities/concern.rb
61
- - lib/abilities/configuration.rb
62
58
  - lib/abilities/definitions.rb
63
59
  - lib/abilities/exceptions.rb
60
+ - lib/abilities/extensions/action_controller/base.rb
64
61
  - lib/abilities/proxy.rb
65
62
  - lib/abilities/railtie.rb
66
63
  - lib/abilities/version.rb
67
- - lib/generators/abilities/install_generator.rb
68
- - lib/generators/abilities/templates/abilities.rb
69
- - test/changes_test.rb
70
- - test/checking_test.rb
71
- - test/controller_test.rb
72
- - test/dummy/README.rdoc
64
+ - lib/generators/abilities/install/install_generator.rb
65
+ - lib/generators/abilities/install/templates/configuration.rb
73
66
  - test/dummy/Rakefile
74
67
  - test/dummy/app/assets/javascripts/application.js
75
68
  - test/dummy/app/assets/stylesheets/application.css
76
69
  - test/dummy/app/controllers/application_controller.rb
70
+ - test/dummy/app/controllers/products_controller.rb
77
71
  - test/dummy/app/helpers/application_helper.rb
78
- - test/dummy/app/models/post.rb
72
+ - test/dummy/app/models/product.rb
79
73
  - test/dummy/app/models/user.rb
80
74
  - test/dummy/app/views/layouts/application.html.erb
75
+ - test/dummy/app/views/products/show.html.erb
81
76
  - test/dummy/bin/bundle
82
77
  - test/dummy/bin/rails
83
78
  - test/dummy/bin/rake
79
+ - test/dummy/bin/setup
84
80
  - test/dummy/config.ru
85
81
  - test/dummy/config/abilities.rb
86
82
  - test/dummy/config/application.rb
87
83
  - test/dummy/config/boot.rb
88
84
  - test/dummy/config/database.yml
85
+ - test/dummy/config/database.yml.travis
89
86
  - test/dummy/config/environment.rb
90
87
  - test/dummy/config/environments/development.rb
91
88
  - test/dummy/config/environments/production.rb
92
89
  - test/dummy/config/environments/test.rb
93
- - test/dummy/config/initializers/abilities.rb
90
+ - test/dummy/config/initializers/assets.rb
94
91
  - test/dummy/config/initializers/backtrace_silencers.rb
95
92
  - test/dummy/config/initializers/cookies_serializer.rb
96
93
  - test/dummy/config/initializers/filter_parameter_logging.rb
97
94
  - test/dummy/config/initializers/inflections.rb
98
95
  - test/dummy/config/initializers/mime_types.rb
99
- - test/dummy/config/initializers/secret_token.rb
100
96
  - test/dummy/config/initializers/session_store.rb
101
97
  - test/dummy/config/initializers/wrap_parameters.rb
102
98
  - test/dummy/config/locales/en.yml
103
99
  - test/dummy/config/routes.rb
104
100
  - test/dummy/config/secrets.yml
105
101
  - test/dummy/db/migrate/20140629203344_create_users.rb
106
- - test/dummy/db/migrate/20140629203412_create_posts.rb
102
+ - test/dummy/db/migrate/20140629203412_create_products.rb
107
103
  - test/dummy/db/schema.rb
104
+ - test/dummy/log/development.log
108
105
  - test/dummy/log/test.log
109
106
  - test/dummy/public/404.html
110
107
  - test/dummy/public/422.html
111
108
  - test/dummy/public/500.html
112
109
  - test/dummy/public/favicon.ico
110
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/2b/2bzOr5XdBQAg_ZBDeXY157jGXLRL6qjEoFZBTPyLFwM.cache
111
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/48/48oV_bpl6OaHjWm9j-I1uNUp5m7SbkTgYjW6NaNnTfU.cache
112
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache
113
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache
114
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/SG/SGNGr7AZfBE1q7ev2-YM1G-o0XAZ0pKqbsS3NvHtRcA.cache
115
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/fG/fG_uaNK13wisQiji91xNsGecGxX9QhMCF2eSX_aR0G0.cache
116
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/gb/gbunrAFVOHPwl2npUgKv_C3f_qiJnZDd9zG5-h3jrpo.cache
117
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache
118
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/j0/j06P5zp022n2VUoAPi5fqCp_UbS7OaCD8XtVtEbHy58.cache
119
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/mv/mvqN6PphkrOOC8zbUEhpC_9E_4ybdO25MRy_gG6dq3Y.cache
120
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/nm/nmcUZlKAIwyJ_35Nm9P8pukLeRX5aApP6NFj5MpNPgc.cache
121
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache
122
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/sB/sB6xWxBmgzVC0Co9__ANYrE58lr4WPwiwFa9mswooWM.cache
123
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/va/vaNrIny9hchHD9eIJxAicyYLC7qeV4PTh4Nh40_Y6Vg.cache
124
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/x6/x6W7JXRDHOmqATQMRSTLu17o8EcA-ietA1qm_PMPjbo.cache
125
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/xd/xdBKQyhEAlDIstGvXw945PWJoEWi23rKuY7elOcWqHc.cache
113
126
  - test/generator_test.rb
127
+ - test/policy_test.rb
114
128
  - test/test_helper.rb
115
129
  - test/view_test.rb
116
130
  homepage: https://github.com/mmontossi/abilities
@@ -125,7 +139,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
139
  requirements:
126
140
  - - ">="
127
141
  - !ruby/object:Gem::Version
128
- version: 2.0.0
142
+ version: 2.1.0
129
143
  required_rubygems_version: !ruby/object:Gem::Requirement
130
144
  requirements:
131
145
  - - ">="
@@ -138,34 +152,34 @@ signing_key:
138
152
  specification_version: 4
139
153
  summary: Abilities for rails.
140
154
  test_files:
141
- - test/changes_test.rb
142
- - test/checking_test.rb
143
- - test/controller_test.rb
144
155
  - test/dummy/app/assets/javascripts/application.js
145
156
  - test/dummy/app/assets/stylesheets/application.css
146
157
  - test/dummy/app/controllers/application_controller.rb
158
+ - test/dummy/app/controllers/products_controller.rb
147
159
  - test/dummy/app/helpers/application_helper.rb
148
- - test/dummy/app/models/post.rb
160
+ - test/dummy/app/models/product.rb
149
161
  - test/dummy/app/models/user.rb
150
162
  - test/dummy/app/views/layouts/application.html.erb
163
+ - test/dummy/app/views/products/show.html.erb
151
164
  - test/dummy/bin/bundle
152
165
  - test/dummy/bin/rails
153
166
  - test/dummy/bin/rake
167
+ - test/dummy/bin/setup
154
168
  - test/dummy/config/abilities.rb
155
169
  - test/dummy/config/application.rb
156
170
  - test/dummy/config/boot.rb
157
171
  - test/dummy/config/database.yml
172
+ - test/dummy/config/database.yml.travis
158
173
  - test/dummy/config/environment.rb
159
174
  - test/dummy/config/environments/development.rb
160
175
  - test/dummy/config/environments/production.rb
161
176
  - test/dummy/config/environments/test.rb
162
- - test/dummy/config/initializers/abilities.rb
177
+ - test/dummy/config/initializers/assets.rb
163
178
  - test/dummy/config/initializers/backtrace_silencers.rb
164
179
  - test/dummy/config/initializers/cookies_serializer.rb
165
180
  - test/dummy/config/initializers/filter_parameter_logging.rb
166
181
  - test/dummy/config/initializers/inflections.rb
167
182
  - test/dummy/config/initializers/mime_types.rb
168
- - test/dummy/config/initializers/secret_token.rb
169
183
  - test/dummy/config/initializers/session_store.rb
170
184
  - test/dummy/config/initializers/wrap_parameters.rb
171
185
  - test/dummy/config/locales/en.yml
@@ -173,15 +187,32 @@ test_files:
173
187
  - test/dummy/config/secrets.yml
174
188
  - test/dummy/config.ru
175
189
  - test/dummy/db/migrate/20140629203344_create_users.rb
176
- - test/dummy/db/migrate/20140629203412_create_posts.rb
190
+ - test/dummy/db/migrate/20140629203412_create_products.rb
177
191
  - test/dummy/db/schema.rb
192
+ - test/dummy/log/development.log
178
193
  - test/dummy/log/test.log
179
194
  - test/dummy/public/404.html
180
195
  - test/dummy/public/422.html
181
196
  - test/dummy/public/500.html
182
197
  - test/dummy/public/favicon.ico
183
198
  - test/dummy/Rakefile
184
- - test/dummy/README.rdoc
199
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/2b/2bzOr5XdBQAg_ZBDeXY157jGXLRL6qjEoFZBTPyLFwM.cache
200
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/48/48oV_bpl6OaHjWm9j-I1uNUp5m7SbkTgYjW6NaNnTfU.cache
201
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache
202
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/fG/fG_uaNK13wisQiji91xNsGecGxX9QhMCF2eSX_aR0G0.cache
203
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/gb/gbunrAFVOHPwl2npUgKv_C3f_qiJnZDd9zG5-h3jrpo.cache
204
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache
205
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/j0/j06P5zp022n2VUoAPi5fqCp_UbS7OaCD8XtVtEbHy58.cache
206
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/mv/mvqN6PphkrOOC8zbUEhpC_9E_4ybdO25MRy_gG6dq3Y.cache
207
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/nm/nmcUZlKAIwyJ_35Nm9P8pukLeRX5aApP6NFj5MpNPgc.cache
208
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache
209
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache
210
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/sB/sB6xWxBmgzVC0Co9__ANYrE58lr4WPwiwFa9mswooWM.cache
211
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/SG/SGNGr7AZfBE1q7ev2-YM1G-o0XAZ0pKqbsS3NvHtRcA.cache
212
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/va/vaNrIny9hchHD9eIJxAicyYLC7qeV4PTh4Nh40_Y6Vg.cache
213
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/x6/x6W7JXRDHOmqATQMRSTLu17o8EcA-ietA1qm_PMPjbo.cache
214
+ - test/dummy/tmp/cache/assets/sprockets/v3.0/xd/xdBKQyhEAlDIstGvXw945PWJoEWi23rKuY7elOcWqHc.cache
185
215
  - test/generator_test.rb
216
+ - test/policy_test.rb
186
217
  - test/test_helper.rb
187
218
  - test/view_test.rb
@@ -1,20 +0,0 @@
1
- module Abilities
2
- module ActionController
3
- module Base
4
- extend ActiveSupport::Concern
5
-
6
- protected
7
-
8
- %w(can? cannot?).each do |name|
9
- define_method name do |action, subject|
10
- Abilities.send name, instance_exec(&Abilities.configuration.fetcher), action, subject
11
- end
12
- end
13
-
14
- def authorize!(action, subject)
15
- raise Abilities::AccessDenied unless can? action, subject
16
- end
17
-
18
- end
19
- end
20
- end
@@ -1,14 +0,0 @@
1
- module Abilities
2
- module ActionView
3
- module Base
4
- extend ActiveSupport::Concern
5
-
6
- %w(can? cannot?).each do |name|
7
- define_method name do |action, subject|
8
- Abilities.send name, instance_exec(&Abilities.configuration.fetcher), action, subject
9
- end
10
- end
11
-
12
- end
13
- end
14
- end
@@ -1,12 +0,0 @@
1
- module Abilities
2
- module Concern
3
- extend ActiveSupport::Concern
4
-
5
- %w(can? cannot?).each do |name|
6
- define_method name do |action, subject|
7
- Abilities.send name, self, action, subject
8
- end
9
- end
10
-
11
- end
12
- end
@@ -1,13 +0,0 @@
1
- module Abilities
2
- class Configuration
3
-
4
- def fetcher(&block)
5
- if block_given?
6
- @fetcher = block
7
- else
8
- @fetcher
9
- end
10
- end
11
-
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- require 'rails/generators'
2
-
3
- module Abilities
4
- class InstallGenerator < Rails::Generators::Base
5
-
6
- source_root File.expand_path('../templates', __FILE__)
7
-
8
- def create_capable_concern
9
- copy_file 'abilities.rb', 'config/abilities.rb'
10
- end
11
-
12
- end
13
- end
@@ -1,12 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ChangesTest < ActiveSupport::TestCase
4
-
5
- test 'record changes' do
6
- user = User.new
7
- assert user.cannot?(:destroy, Post)
8
- user.admin = true
9
- assert user.can?(:destroy, Post)
10
- end
11
-
12
- end
@@ -1,64 +0,0 @@
1
- require 'test_helper'
2
-
3
- class CheckingTest < ActiveSupport::TestCase
4
-
5
- test 'can definition with model' do
6
- assert user.can?(:create, Post)
7
- assert !user.cannot?(:create, Post)
8
- end
9
-
10
- test 'can definition with instance' do
11
- assert user.can?(:create, post)
12
- assert !user.cannot?(:create, post)
13
- end
14
-
15
- test 'cannot definition' do
16
- assert user.cannot?('read', post)
17
- assert !user.can?('read', post)
18
- end
19
-
20
- test 'ability conditions' do
21
- assert admin_user.can?(:destroy, post)
22
- assert user.cannot?(:destroy, post)
23
- end
24
-
25
- test 'ability block' do
26
- assert user.can?(:edit, post_with_user)
27
- end
28
-
29
- test 'manage action' do
30
- assert user.can?(:create, User)
31
- assert user.can?(:read, user)
32
- assert user.can?(:edit, user)
33
- assert user.can?(:destroy, user)
34
- end
35
-
36
- test 'all subject' do
37
- assert user.can?(:touch, post)
38
- assert user.can?(:touch, user)
39
- end
40
-
41
- test 'undefined definition' do
42
- assert user.cannot?(:other, post)
43
- assert user.cannot?(:other, post)
44
- end
45
-
46
- private
47
-
48
- def post_with_user
49
- @post_with_user ||= Post.new(user: user)
50
- end
51
-
52
- def post
53
- @post ||= Post.new
54
- end
55
-
56
- def user
57
- @user ||= User.new
58
- end
59
-
60
- def admin_user
61
- @admin_user ||= User.new(admin: true)
62
- end
63
-
64
- end