cancancan 1.14.0 → 1.15.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +9 -1
- data/Appraisals +24 -1
- data/CHANGELOG.rdoc +7 -0
- data/gemfiles/activerecord_3.2.gemfile +1 -0
- data/gemfiles/activerecord_4.0.gemfile +1 -0
- data/gemfiles/activerecord_4.1.gemfile +1 -0
- data/gemfiles/activerecord_4.2.gemfile +1 -0
- data/gemfiles/activerecord_5.0.gemfile +19 -0
- data/gemfiles/mongoid_2.x.gemfile +1 -0
- data/gemfiles/sequel_3.x.gemfile +2 -1
- data/lib/cancan/controller_additions.rb +16 -12
- data/lib/cancan/controller_resource.rb +11 -3
- data/lib/cancan/model_adapters/active_record_4_adapter.rb +15 -2
- data/lib/cancan/version.rb +1 -1
- data/spec/cancan/controller_additions_spec.rb +20 -10
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f603bcd9b02f8b042e5de713df94cb01abec7486
|
|
4
|
+
data.tar.gz: 358a5080dcef4525f7993d9c1383daffc147d169
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c56c8b9e82e5ab6868a5dafcf811d2363b023c4f1eb05149de64996919e6da6e60dff583e7d1b9f1c1eeb277a52a5327e03b52bf753b3ed79ce2cc22fad0b431
|
|
7
|
+
data.tar.gz: a1be98535ecbcde3db1b8accc41446bbb139b413b544a2541af00f699e5e5a548d3fdfdb41b09ed951504d4c8a6a31fc24a50aea690ad70ed2fb224a1676d954
|
data/.travis.yml
CHANGED
|
@@ -5,12 +5,14 @@ rvm:
|
|
|
5
5
|
- 2.0.0
|
|
6
6
|
- 2.1.0
|
|
7
7
|
- 2.2.0
|
|
8
|
+
- 2.2.2
|
|
8
9
|
- jruby-9.0.5.0
|
|
9
10
|
gemfile:
|
|
10
11
|
- gemfiles/activerecord_3.2.gemfile
|
|
11
12
|
- gemfiles/activerecord_4.0.gemfile
|
|
12
13
|
- gemfiles/activerecord_4.1.gemfile
|
|
13
14
|
- gemfiles/activerecord_4.2.gemfile
|
|
15
|
+
- gemfiles/activerecord_5.0.gemfile
|
|
14
16
|
- gemfiles/mongoid_2.x.gemfile
|
|
15
17
|
- gemfiles/sequel_3.x.gemfile
|
|
16
18
|
services:
|
|
@@ -18,8 +20,14 @@ services:
|
|
|
18
20
|
matrix:
|
|
19
21
|
fast_finish: true
|
|
20
22
|
exclude:
|
|
23
|
+
- rvm: 2.0.0
|
|
24
|
+
gemfile: gemfiles/activerecord_5.0.gemfile
|
|
25
|
+
- rvm: 2.1.0
|
|
26
|
+
gemfile: gemfiles/activerecord_5.0.gemfile
|
|
21
27
|
- rvm: 2.2.0
|
|
22
|
-
gemfile: gemfiles/
|
|
28
|
+
gemfile: gemfiles/activerecord_5.0.gemfile
|
|
29
|
+
- rvm: jruby-9.0.5.0
|
|
30
|
+
gemfile: gemfiles/activerecord_5.0.gemfile
|
|
23
31
|
notifications:
|
|
24
32
|
recipients:
|
|
25
33
|
- bryan@bryanrite.com
|
data/Appraisals
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
appraise "activerecord_3.2" do
|
|
2
2
|
gem "activerecord", "~> 3.2.0", :require => "active_record"
|
|
3
|
+
gem "actionpack", "~> 3.2.0", :require => "action_pack"
|
|
3
4
|
|
|
4
5
|
gemfile.platforms :jruby do
|
|
5
6
|
gem "activerecord-jdbcsqlite3-adapter"
|
|
@@ -14,6 +15,8 @@ end
|
|
|
14
15
|
appraise "activerecord_4.0" do
|
|
15
16
|
gem "activerecord", "~> 4.0.5", :require => "active_record"
|
|
16
17
|
gem "activesupport", "~> 4.0.5", :require => "active_support/all"
|
|
18
|
+
gem "actionpack", "~> 4.0.5", :require => "action_pack"
|
|
19
|
+
|
|
17
20
|
|
|
18
21
|
gemfile.platforms :jruby do
|
|
19
22
|
gem "activerecord-jdbcsqlite3-adapter"
|
|
@@ -28,6 +31,7 @@ end
|
|
|
28
31
|
appraise "activerecord_4.1" do
|
|
29
32
|
gem "activerecord", "~> 4.1.1", :require => "active_record"
|
|
30
33
|
gem "activesupport", "~> 4.1.1", :require => "active_support/all"
|
|
34
|
+
gem "actionpack", "~> 4.1.1", :require => "action_pack"
|
|
31
35
|
|
|
32
36
|
gemfile.platforms :jruby do
|
|
33
37
|
gem "activerecord-jdbcsqlite3-adapter"
|
|
@@ -42,6 +46,23 @@ end
|
|
|
42
46
|
appraise "activerecord_4.2" do
|
|
43
47
|
gem "activerecord", "~> 4.2.0", :require => "active_record"
|
|
44
48
|
gem 'activesupport', '~> 4.2.0', :require => 'active_support/all'
|
|
49
|
+
gem "actionpack", "~> 4.2.0", :require => "action_pack"
|
|
50
|
+
|
|
51
|
+
gemfile.platforms :jruby do
|
|
52
|
+
gem "activerecord-jdbcsqlite3-adapter"
|
|
53
|
+
gem "jdbc-sqlite3"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
gemfile.platforms :ruby, :mswin, :mingw do
|
|
57
|
+
gem "sqlite3"
|
|
58
|
+
gem "pg"
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
appraise "activerecord_5.0" do
|
|
63
|
+
gem "activerecord", "~> 5.0.0.rc1", :require => "active_record"
|
|
64
|
+
gem 'activesupport', '~> 5.0.0.rc1', :require => 'active_support/all'
|
|
65
|
+
gem "actionpack", "~> 5.0.0.rc1", :require => "action_pack"
|
|
45
66
|
|
|
46
67
|
gemfile.platforms :jruby do
|
|
47
68
|
gem "activerecord-jdbcsqlite3-adapter"
|
|
@@ -56,6 +77,7 @@ end
|
|
|
56
77
|
|
|
57
78
|
appraise "mongoid_2.x" do
|
|
58
79
|
gem "activesupport", "~> 3.0", :require => "active_support/all"
|
|
80
|
+
gem "actionpack", "~> 3.0", :require => "action_pack"
|
|
59
81
|
gem "mongoid", "~> 2.0.0"
|
|
60
82
|
|
|
61
83
|
gemfile.platforms :ruby, :mswin, :mingw do
|
|
@@ -68,8 +90,9 @@ appraise "mongoid_2.x" do
|
|
|
68
90
|
end
|
|
69
91
|
|
|
70
92
|
appraise "sequel_3.x" do
|
|
71
|
-
gem "sequel", "~> 3.
|
|
93
|
+
gem "sequel", "~> 3.48.0"
|
|
72
94
|
gem "activesupport", "~> 3.0", :require => "active_support/all"
|
|
95
|
+
gem "actionpack", "~> 3.0", :require => "action_pack"
|
|
73
96
|
|
|
74
97
|
gemfile.platforms :jruby do
|
|
75
98
|
gem "jdbc-sqlite3"
|
data/CHANGELOG.rdoc
CHANGED
|
@@ -4,6 +4,7 @@ source "https://rubygems.org"
|
|
|
4
4
|
|
|
5
5
|
gem "activerecord", "~> 4.0.5", :require => "active_record"
|
|
6
6
|
gem "activesupport", "~> 4.0.5", :require => "active_support/all"
|
|
7
|
+
gem "actionpack", "~> 4.0.5", :require => "action_pack"
|
|
7
8
|
|
|
8
9
|
platforms :jruby do
|
|
9
10
|
gem "activerecord-jdbcsqlite3-adapter"
|
|
@@ -4,6 +4,7 @@ source "https://rubygems.org"
|
|
|
4
4
|
|
|
5
5
|
gem "activerecord", "~> 4.1.1", :require => "active_record"
|
|
6
6
|
gem "activesupport", "~> 4.1.1", :require => "active_support/all"
|
|
7
|
+
gem "actionpack", "~> 4.1.1", :require => "action_pack"
|
|
7
8
|
|
|
8
9
|
platforms :jruby do
|
|
9
10
|
gem "activerecord-jdbcsqlite3-adapter"
|
|
@@ -4,6 +4,7 @@ source "https://rubygems.org"
|
|
|
4
4
|
|
|
5
5
|
gem "activerecord", "~> 4.2.0", :require => "active_record"
|
|
6
6
|
gem "activesupport", "~> 4.2.0", :require => "active_support/all"
|
|
7
|
+
gem "actionpack", "~> 4.2.0", :require => "action_pack"
|
|
7
8
|
|
|
8
9
|
platforms :jruby do
|
|
9
10
|
gem "activerecord-jdbcsqlite3-adapter"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "activerecord", "~> 5.0.0.rc1", :require => "active_record"
|
|
6
|
+
gem "activesupport", "~> 5.0.0.rc1", :require => "active_support/all"
|
|
7
|
+
gem "actionpack", "~> 5.0.0.rc1", :require => "action_pack"
|
|
8
|
+
|
|
9
|
+
platforms :jruby do
|
|
10
|
+
gem "activerecord-jdbcsqlite3-adapter"
|
|
11
|
+
gem "jdbc-sqlite3"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
platforms :ruby, :mswin, :mingw do
|
|
15
|
+
gem "sqlite3"
|
|
16
|
+
gem "pg"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
gemspec :path => "../"
|
data/gemfiles/sequel_3.x.gemfile
CHANGED
|
@@ -12,7 +12,7 @@ module CanCan
|
|
|
12
12
|
# end
|
|
13
13
|
#
|
|
14
14
|
def load_and_authorize_resource(*args)
|
|
15
|
-
cancan_resource_class.
|
|
15
|
+
cancan_resource_class.add_before_action(self, :load_and_authorize_resource, *args)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# Sets up a before filter which loads the model resource into an instance variable.
|
|
@@ -32,10 +32,10 @@ module CanCan
|
|
|
32
32
|
# end
|
|
33
33
|
#
|
|
34
34
|
# A resource is not loaded if the instance variable is already set. This makes it easy to override
|
|
35
|
-
# the behavior through a
|
|
35
|
+
# the behavior through a before_action on certain actions.
|
|
36
36
|
#
|
|
37
37
|
# class BooksController < ApplicationController
|
|
38
|
-
#
|
|
38
|
+
# before_action :find_book_by_permalink, :only => :show
|
|
39
39
|
# load_resource
|
|
40
40
|
#
|
|
41
41
|
# private
|
|
@@ -115,10 +115,10 @@ module CanCan
|
|
|
115
115
|
# load_resource :new => :build
|
|
116
116
|
#
|
|
117
117
|
# [:+prepend+]
|
|
118
|
-
# Passing +true+ will use
|
|
118
|
+
# Passing +true+ will use prepend_before_action instead of a normal before_action.
|
|
119
119
|
#
|
|
120
120
|
def load_resource(*args)
|
|
121
|
-
cancan_resource_class.
|
|
121
|
+
cancan_resource_class.add_before_action(self, :load_resource, *args)
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
# Sets up a before filter which authorizes the resource using the instance variable.
|
|
@@ -174,10 +174,10 @@ module CanCan
|
|
|
174
174
|
# Authorize conditions on this parent resource when instance isn't available.
|
|
175
175
|
#
|
|
176
176
|
# [:+prepend+]
|
|
177
|
-
# Passing +true+ will use
|
|
177
|
+
# Passing +true+ will use prepend_before_action instead of a normal before_action.
|
|
178
178
|
#
|
|
179
179
|
def authorize_resource(*args)
|
|
180
|
-
cancan_resource_class.
|
|
180
|
+
cancan_resource_class.add_before_action(self, :authorize_resource, *args)
|
|
181
181
|
end
|
|
182
182
|
|
|
183
183
|
# Skip both the loading and authorization behavior of CanCan for this given controller. This is primarily
|
|
@@ -254,12 +254,16 @@ module CanCan
|
|
|
254
254
|
# check_authorization :unless => :devise_controller?
|
|
255
255
|
#
|
|
256
256
|
def check_authorization(options = {})
|
|
257
|
-
|
|
257
|
+
method_name = ActiveSupport.respond_to?(:version) && ActiveSupport.version >= Gem::Version.new("4") ? :after_action : :after_filter
|
|
258
|
+
|
|
259
|
+
block = Proc.new do |controller|
|
|
258
260
|
next if controller.instance_variable_defined?(:@_authorized)
|
|
259
261
|
next if options[:if] && !controller.send(options[:if])
|
|
260
262
|
next if options[:unless] && controller.send(options[:unless])
|
|
261
263
|
raise AuthorizationNotPerformed, "This action failed the check_authorization because it does not authorize_resource. Add skip_authorization_check to bypass this check."
|
|
262
264
|
end
|
|
265
|
+
|
|
266
|
+
self.send(method_name, options.slice(:only, :except), &block)
|
|
263
267
|
end
|
|
264
268
|
|
|
265
269
|
# Call this in the class of a controller to skip the check_authorization behavior on the actions.
|
|
@@ -268,11 +272,11 @@ module CanCan
|
|
|
268
272
|
# skip_authorization_check :only => :index
|
|
269
273
|
# end
|
|
270
274
|
#
|
|
271
|
-
# Any arguments are passed to the +
|
|
275
|
+
# Any arguments are passed to the +before_action+ it triggers.
|
|
272
276
|
def skip_authorization_check(*args)
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
277
|
+
method_name = ActiveSupport.respond_to?(:version) && ActiveSupport.version >= Gem::Version.new("4") ? :before_action : :before_filter
|
|
278
|
+
block = Proc.new{ |controller| controller.instance_variable_set(:@_authorized, true) }
|
|
279
|
+
self.send(method_name, *args, &block)
|
|
276
280
|
end
|
|
277
281
|
|
|
278
282
|
def skip_authorization(*args)
|
|
@@ -2,15 +2,23 @@ module CanCan
|
|
|
2
2
|
# Handle the load and authorization controller logic so we don't clutter up all controllers with non-interface methods.
|
|
3
3
|
# This class is used internally, so you do not need to call methods directly on it.
|
|
4
4
|
class ControllerResource # :nodoc:
|
|
5
|
-
def self.
|
|
5
|
+
def self.add_before_action(controller_class, method, *args)
|
|
6
6
|
options = args.extract_options!
|
|
7
7
|
resource_name = args.first
|
|
8
|
-
|
|
9
|
-
controller_class.send(
|
|
8
|
+
before_action_method = before_callback_name(options)
|
|
9
|
+
controller_class.send(before_action_method, options.slice(:only, :except, :if, :unless)) do |controller|
|
|
10
10
|
controller.class.cancan_resource_class.new(controller, resource_name, options.except(:only, :except, :if, :unless)).send(method)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
def self.before_callback_name(options)
|
|
15
|
+
if ActiveSupport.respond_to?(:version) && ActiveSupport.version >= Gem::Version.new("4")
|
|
16
|
+
options.delete(:prepend) ? :prepend_before_action : :before_action
|
|
17
|
+
else
|
|
18
|
+
options.delete(:prepend) ? :prepend_before_filter : :before_filter
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
14
22
|
def initialize(controller, *args)
|
|
15
23
|
@controller = controller
|
|
16
24
|
@params = controller.params
|
|
@@ -20,7 +20,7 @@ module CanCan
|
|
|
20
20
|
|
|
21
21
|
def self.override_condition_matching?(subject, name, value)
|
|
22
22
|
# ActiveRecord introduced enums in version 4.1.
|
|
23
|
-
ActiveRecord::VERSION::MINOR >= 1 &&
|
|
23
|
+
(ActiveRecord::VERSION::MAJOR > 4 || ActiveRecord::VERSION::MINOR >= 1) &&
|
|
24
24
|
subject.class.defined_enums.include?(name.to_s)
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -37,7 +37,20 @@ module CanCan
|
|
|
37
37
|
|
|
38
38
|
# Rails 4.2 deprecates `sanitize_sql_hash_for_conditions`
|
|
39
39
|
def sanitize_sql(conditions)
|
|
40
|
-
if ActiveRecord::VERSION::
|
|
40
|
+
if ActiveRecord::VERSION::MAJOR > 4 && Hash === conditions
|
|
41
|
+
table = @model_class.send(:arel_table)
|
|
42
|
+
table_metadata = ActiveRecord::TableMetadata.new(@model_class, table)
|
|
43
|
+
predicate_builder = ActiveRecord::PredicateBuilder.new(table_metadata)
|
|
44
|
+
|
|
45
|
+
conditions = predicate_builder.resolve_column_aliases(conditions)
|
|
46
|
+
conditions = @model_class.send(:expand_hash_conditions_for_aggregates, conditions)
|
|
47
|
+
|
|
48
|
+
conditions.stringify_keys!
|
|
49
|
+
|
|
50
|
+
predicate_builder.build_from_hash(conditions).map { |b|
|
|
51
|
+
@model_class.send(:connection).visitor.compile b
|
|
52
|
+
}.join(' AND ')
|
|
53
|
+
elsif ActiveRecord::VERSION::MINOR >= 2 && Hash === conditions
|
|
41
54
|
table = Arel::Table.new(@model_class.send(:table_name))
|
|
42
55
|
|
|
43
56
|
conditions = ActiveRecord::PredicateBuilder.resolve_column_aliases @model_class, conditions
|
data/lib/cancan/version.rb
CHANGED
|
@@ -33,44 +33,44 @@ describe CanCan::ControllerAdditions do
|
|
|
33
33
|
it "load_and_authorize_resource setups a before filter which passes call to ControllerResource" do
|
|
34
34
|
expect(cancan_resource_class = double).to receive(:load_and_authorize_resource)
|
|
35
35
|
allow(CanCan::ControllerResource).to receive(:new).with(@controller, nil, :foo => :bar) {cancan_resource_class }
|
|
36
|
-
expect(@controller_class).to receive(:
|
|
36
|
+
expect(@controller_class).to receive(callback_action(:before_action)).with({}) { |options, &block| block.call(@controller) }
|
|
37
37
|
@controller_class.load_and_authorize_resource :foo => :bar
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "load_and_authorize_resource properly passes first argument as the resource name" do
|
|
41
41
|
expect(cancan_resource_class = double).to receive(:load_and_authorize_resource)
|
|
42
42
|
allow(CanCan::ControllerResource).to receive(:new).with(@controller, :project, :foo => :bar) {cancan_resource_class}
|
|
43
|
-
expect(@controller_class).to receive(:
|
|
43
|
+
expect(@controller_class).to receive(callback_action(:before_action)).with({}) { |options, &block| block.call(@controller) }
|
|
44
44
|
@controller_class.load_and_authorize_resource :project, :foo => :bar
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "load_and_authorize_resource with :prepend prepends the before filter" do
|
|
48
|
-
expect(@controller_class).to receive(:
|
|
48
|
+
expect(@controller_class).to receive(callback_action(:prepend_before_action)).with({})
|
|
49
49
|
@controller_class.load_and_authorize_resource :foo => :bar, :prepend => true
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
it "authorize_resource setups a before filter which passes call to ControllerResource" do
|
|
53
53
|
expect(cancan_resource_class = double).to receive(:authorize_resource)
|
|
54
54
|
allow(CanCan::ControllerResource).to receive(:new).with(@controller, nil, :foo => :bar) {cancan_resource_class}
|
|
55
|
-
expect(@controller_class).to receive(:
|
|
55
|
+
expect(@controller_class).to receive(callback_action(:before_action)).with(:except => :show, :if => true) { |options, &block| block.call(@controller) }
|
|
56
56
|
@controller_class.authorize_resource :foo => :bar, :except => :show, :if => true
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
it "load_resource setups a before filter which passes call to ControllerResource" do
|
|
60
60
|
expect(cancan_resource_class = double).to receive(:load_resource)
|
|
61
61
|
allow(CanCan::ControllerResource).to receive(:new).with(@controller, nil, :foo => :bar) {cancan_resource_class}
|
|
62
|
-
expect(@controller_class).to receive(:
|
|
62
|
+
expect(@controller_class).to receive(callback_action(:before_action)).with(:only => [:show, :index], :unless => false) { |options, &block| block.call(@controller) }
|
|
63
63
|
@controller_class.load_resource :foo => :bar, :only => [:show, :index], :unless => false
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
it "skip_authorization_check setups a before filter which sets @_authorized to true" do
|
|
67
|
-
expect(@controller_class).to receive(:
|
|
67
|
+
expect(@controller_class).to receive(callback_action(:before_action)).with(:filter_options) { |options, &block| block.call(@controller) }
|
|
68
68
|
@controller_class.skip_authorization_check(:filter_options)
|
|
69
69
|
expect(@controller.instance_variable_get(:@_authorized)).to be(true)
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
it "check_authorization triggers AuthorizationNotPerformed in after filter" do
|
|
73
|
-
expect(@controller_class).to receive(:
|
|
73
|
+
expect(@controller_class).to receive(callback_action(:after_action)).with(:only => [:test]) { |options, &block| block.call(@controller) }
|
|
74
74
|
expect {
|
|
75
75
|
@controller_class.check_authorization(:only => [:test])
|
|
76
76
|
}.to raise_error(CanCan::AuthorizationNotPerformed)
|
|
@@ -78,7 +78,7 @@ describe CanCan::ControllerAdditions do
|
|
|
78
78
|
|
|
79
79
|
it "check_authorization does not trigger AuthorizationNotPerformed when :if is false" do
|
|
80
80
|
allow(@controller).to receive(:check_auth?) { false }
|
|
81
|
-
allow(@controller_class).to receive(:
|
|
81
|
+
allow(@controller_class).to receive(callback_action(:after_action)).with({}) { |options, &block| block.call(@controller) }
|
|
82
82
|
expect {
|
|
83
83
|
@controller_class.check_authorization(:if => :check_auth?)
|
|
84
84
|
}.not_to raise_error
|
|
@@ -86,7 +86,7 @@ describe CanCan::ControllerAdditions do
|
|
|
86
86
|
|
|
87
87
|
it "check_authorization does not trigger AuthorizationNotPerformed when :unless is true" do
|
|
88
88
|
allow(@controller).to receive(:engine_controller?) { true }
|
|
89
|
-
expect(@controller_class).to receive(:
|
|
89
|
+
expect(@controller_class).to receive(callback_action(:after_action)).with({}) { |options, &block| block.call(@controller) }
|
|
90
90
|
expect {
|
|
91
91
|
@controller_class.check_authorization(:unless => :engine_controller?)
|
|
92
92
|
}.not_to raise_error
|
|
@@ -94,7 +94,7 @@ describe CanCan::ControllerAdditions do
|
|
|
94
94
|
|
|
95
95
|
it "check_authorization does not raise error when @_authorized is set" do
|
|
96
96
|
@controller.instance_variable_set(:@_authorized, true)
|
|
97
|
-
expect(@controller_class).to receive(:
|
|
97
|
+
expect(@controller_class).to receive(callback_action(:after_action)).with(:only => [:test]) { |options, &block| block.call(@controller) }
|
|
98
98
|
expect {
|
|
99
99
|
@controller_class.check_authorization(:only => [:test])
|
|
100
100
|
}.not_to raise_error
|
|
@@ -138,4 +138,14 @@ describe CanCan::ControllerAdditions do
|
|
|
138
138
|
expect(@controller_class.cancan_skipper[:load][:project]).to eq({:only => [:index, :show]})
|
|
139
139
|
expect(@controller_class.cancan_skipper[:authorize][:project]).to eq({:only => [:index, :show]})
|
|
140
140
|
end
|
|
141
|
+
|
|
142
|
+
private
|
|
143
|
+
|
|
144
|
+
def callback_action(action)
|
|
145
|
+
if ActiveSupport.respond_to?(:version) && ActiveSupport.version >= Gem::Version.new("4")
|
|
146
|
+
action
|
|
147
|
+
else
|
|
148
|
+
action.to_s.sub(/_action/, '_filter')
|
|
149
|
+
end
|
|
150
|
+
end
|
|
141
151
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cancancan
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.15.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bryan Rite
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2016-
|
|
13
|
+
date: 2016-06-13 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: bundler
|
|
@@ -90,6 +90,7 @@ files:
|
|
|
90
90
|
- gemfiles/activerecord_4.0.gemfile
|
|
91
91
|
- gemfiles/activerecord_4.1.gemfile
|
|
92
92
|
- gemfiles/activerecord_4.2.gemfile
|
|
93
|
+
- gemfiles/activerecord_5.0.gemfile
|
|
93
94
|
- gemfiles/mongoid_2.x.gemfile
|
|
94
95
|
- gemfiles/sequel_3.x.gemfile
|
|
95
96
|
- init.rb
|
|
@@ -151,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
151
152
|
version: '0'
|
|
152
153
|
requirements: []
|
|
153
154
|
rubyforge_project:
|
|
154
|
-
rubygems_version: 2.5.1
|
|
155
|
+
rubygems_version: 2.4.5.1
|
|
155
156
|
signing_key:
|
|
156
157
|
specification_version: 4
|
|
157
158
|
summary: Simple authorization solution for Rails.
|