cancancan 1.10.0 → 1.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +1 -0
- data/CHANGELOG.rdoc +5 -0
- data/README.md +1 -1
- data/gemfiles/activerecord_4.2.gemfile +1 -0
- data/lib/cancan/model_adapters/active_record_4_adapter.rb +10 -6
- data/lib/cancan/version.rb +1 -1
- data/spec/cancan/model_adapters/active_record_4_adapter_spec.rb +67 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21431fc240e1b6a6093c6b9020f3804be1dc4b92
|
4
|
+
data.tar.gz: 604de9f26326c369c30746aee8103e9761c8319f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05de9daae982bbf29448fbbcc5f15ea074ab8d33a4cef3b84555c494c9a2f8fabe759b09241d593de05ffb83c7c579de25445c6b88cc398cf9f4da39008ba57e
|
7
|
+
data.tar.gz: 040dbc4c5450a992bd3ce233435a44faac4aedba9cbec03387242bb8e84933f315135955765d318da58b0f0b40d9f0825c2bccf9bf2a6b2e1a552e613ed88826
|
data/Appraisals
CHANGED
data/CHANGELOG.rdoc
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
Develop
|
2
2
|
|
3
3
|
|
4
|
+
1.10.1 (January 13th, 2015)
|
5
|
+
|
6
|
+
* Fix cancancan#168 - A bug with ActiveRecord 4.2 support causing ProtocolViolation due to named parameters not being passed in.
|
7
|
+
|
8
|
+
|
4
9
|
1.10.0 (January 7th, 2015)
|
5
10
|
|
6
11
|
* Fix i18n issue for Ruby < 1.9.3 (bryanrite)
|
data/README.md
CHANGED
@@ -134,7 +134,7 @@ You can also use a string that will be evaluated in the context of the controlle
|
|
134
134
|
|
135
135
|
Finally, it's possible to associate `param_method` with a Proc object which will be called with the controller as the only argument:
|
136
136
|
|
137
|
-
load_and_authorize_resource param_method: Proc.new
|
137
|
+
load_and_authorize_resource param_method: Proc.new { |c| c.params.require(:article).permit(:name) }
|
138
138
|
|
139
139
|
See [Strong Parameters](https://github.com/CanCanCommunity/cancancan/wiki/Strong-Parameters) for more information.
|
140
140
|
|
@@ -21,13 +21,17 @@ module CanCan
|
|
21
21
|
# Rails 4.2 deprecates `sanitize_sql_hash_for_conditions`
|
22
22
|
def sanitize_sql(conditions)
|
23
23
|
if ActiveRecord::VERSION::MINOR >= 2 && Hash === conditions
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
table = Arel::Table.new(@model_class.send(:table_name))
|
25
|
+
|
26
|
+
conditions = ActiveRecord::PredicateBuilder.resolve_column_aliases @model_class, conditions
|
27
|
+
conditions = @model_class.send(:expand_hash_conditions_for_aggregates, conditions)
|
28
|
+
|
29
|
+
ActiveRecord::PredicateBuilder.build_from_hash(@model_class, conditions, table).map { |b|
|
30
|
+
@model_class.send(:connection).visitor.compile b
|
31
|
+
}.join(' AND ')
|
32
|
+
else
|
33
|
+
@model_class.send(:sanitize_sql, conditions)
|
29
34
|
end
|
30
|
-
@model_class.send(:sanitize_sql, conditions)
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
data/lib/cancan/version.rb
CHANGED
@@ -2,39 +2,84 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
if defined? CanCan::ModelAdapters::ActiveRecord4Adapter
|
4
4
|
describe CanCan::ModelAdapters::ActiveRecord4Adapter do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
context 'with sqlite3' do
|
6
|
+
before :each do
|
7
|
+
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
8
|
+
ActiveRecord::Migration.verbose = false
|
9
|
+
ActiveRecord::Schema.define do
|
10
|
+
create_table(:parents) do |t|
|
11
|
+
t.timestamps :null => false
|
12
|
+
end
|
13
|
+
|
14
|
+
create_table(:children) do |t|
|
15
|
+
t.timestamps :null => false
|
16
|
+
t.integer :parent_id
|
17
|
+
end
|
11
18
|
end
|
12
19
|
|
13
|
-
|
14
|
-
|
15
|
-
t.integer :parent_id
|
20
|
+
class Parent < ActiveRecord::Base
|
21
|
+
has_many :children, lambda { order(:id => :desc) }
|
16
22
|
end
|
17
|
-
end
|
18
23
|
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
class Child < ActiveRecord::Base
|
25
|
+
belongs_to :parent
|
26
|
+
end
|
22
27
|
|
23
|
-
|
24
|
-
belongs_to :parent
|
28
|
+
(@ability = double).extend(CanCan::Ability)
|
25
29
|
end
|
26
30
|
|
27
|
-
|
31
|
+
it "respects scope on included associations" do
|
32
|
+
@ability.can :read, [Parent, Child]
|
33
|
+
|
34
|
+
parent = Parent.create!
|
35
|
+
child1 = Child.create!(:parent => parent, :created_at => 1.hours.ago)
|
36
|
+
child2 = Child.create!(:parent => parent, :created_at => 2.hours.ago)
|
37
|
+
|
38
|
+
expect(Parent.accessible_by(@ability).order(:created_at => :asc).includes(:children).first.children).to eq [child2, child1]
|
39
|
+
end
|
28
40
|
end
|
29
41
|
|
30
|
-
|
31
|
-
|
42
|
+
if Gem::Specification.find_all_by_name('pg').any?
|
43
|
+
context 'with postgresql' do
|
44
|
+
before :each do
|
45
|
+
ActiveRecord::Base.establish_connection(:adapter => "postgresql", :database => "postgres", :schema_search_path => 'public')
|
46
|
+
ActiveRecord::Base.connection.drop_database('cancan_postgresql_spec')
|
47
|
+
ActiveRecord::Base.connection.create_database 'cancan_postgresql_spec', 'encoding' => 'utf-8', 'adapter' => 'postgresql'
|
48
|
+
ActiveRecord::Base.establish_connection(:adapter => "postgresql", :database => "cancan_postgresql_spec")
|
49
|
+
ActiveRecord::Migration.verbose = false
|
50
|
+
ActiveRecord::Schema.define do
|
51
|
+
create_table(:parents) do |t|
|
52
|
+
t.timestamps :null => false
|
53
|
+
end
|
54
|
+
|
55
|
+
create_table(:children) do |t|
|
56
|
+
t.timestamps :null => false
|
57
|
+
t.integer :parent_id
|
58
|
+
end
|
59
|
+
end
|
32
60
|
|
33
|
-
|
34
|
-
|
35
|
-
|
61
|
+
class Parent < ActiveRecord::Base
|
62
|
+
has_many :children, lambda { order(:id => :desc) }
|
63
|
+
end
|
36
64
|
|
37
|
-
|
65
|
+
class Child < ActiveRecord::Base
|
66
|
+
belongs_to :parent
|
67
|
+
end
|
68
|
+
|
69
|
+
(@ability = double).extend(CanCan::Ability)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "allows overlapping conditions in SQL and merge with hash conditions" do
|
73
|
+
@ability.can :read, Parent, :children => {:parent_id => 1}
|
74
|
+
@ability.can :read, Parent, :children => {:parent_id => 1}
|
75
|
+
|
76
|
+
parent = Parent.create!
|
77
|
+
child1 = Child.create!(:parent => parent, :created_at => 1.hours.ago)
|
78
|
+
child2 = Child.create!(:parent => parent, :created_at => 2.hours.ago)
|
79
|
+
|
80
|
+
expect(Parent.accessible_by(@ability)).to eq([parent])
|
81
|
+
end
|
82
|
+
end
|
38
83
|
end
|
39
84
|
end
|
40
85
|
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.10.
|
4
|
+
version: 1.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Rite
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-01-
|
12
|
+
date: 2015-01-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|