cancancan 1.15.0 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +38 -0
  3. data/.rubocop_todo.yml +48 -0
  4. data/.travis.yml +8 -2
  5. data/Appraisals +1 -0
  6. data/CHANGELOG.rdoc +5 -0
  7. data/Gemfile +1 -1
  8. data/README.md +58 -41
  9. data/Rakefile +7 -3
  10. data/cancancan.gemspec +13 -12
  11. data/gemfiles/activerecord_4.2.gemfile +1 -0
  12. data/lib/cancan.rb +2 -2
  13. data/lib/cancan/ability.rb +26 -24
  14. data/lib/cancan/controller_additions.rb +33 -23
  15. data/lib/cancan/controller_resource.rb +83 -56
  16. data/lib/cancan/exceptions.rb +1 -1
  17. data/lib/cancan/matchers.rb +2 -2
  18. data/lib/cancan/model_adapters/abstract_adapter.rb +8 -8
  19. data/lib/cancan/model_adapters/active_record_4_adapter.rb +48 -35
  20. data/lib/cancan/model_adapters/active_record_adapter.rb +18 -17
  21. data/lib/cancan/model_adapters/mongoid_adapter.rb +26 -21
  22. data/lib/cancan/model_adapters/sequel_adapter.rb +12 -12
  23. data/lib/cancan/model_additions.rb +0 -1
  24. data/lib/cancan/rule.rb +23 -17
  25. data/lib/cancan/version.rb +1 -1
  26. data/lib/generators/cancan/ability/ability_generator.rb +1 -1
  27. data/spec/cancan/ability_spec.rb +189 -180
  28. data/spec/cancan/controller_additions_spec.rb +77 -64
  29. data/spec/cancan/controller_resource_spec.rb +230 -228
  30. data/spec/cancan/exceptions_spec.rb +20 -20
  31. data/spec/cancan/inherited_resource_spec.rb +21 -21
  32. data/spec/cancan/matchers_spec.rb +12 -12
  33. data/spec/cancan/model_adapters/active_record_4_adapter_spec.rb +38 -32
  34. data/spec/cancan/model_adapters/active_record_adapter_spec.rb +155 -145
  35. data/spec/cancan/model_adapters/default_adapter_spec.rb +2 -2
  36. data/spec/cancan/model_adapters/mongoid_adapter_spec.rb +87 -88
  37. data/spec/cancan/model_adapters/sequel_adapter_spec.rb +44 -47
  38. data/spec/cancan/rule_spec.rb +18 -18
  39. data/spec/spec_helper.rb +2 -2
  40. data/spec/support/ability.rb +0 -1
  41. metadata +60 -19
@@ -1,5 +1,5 @@
1
- require "spec_helper"
2
- require "ostruct" # for OpenStruct below
1
+ require 'spec_helper'
2
+ require 'ostruct' # for OpenStruct below
3
3
 
4
4
  # Most of Rule functionality is tested in Ability specs
5
5
  describe CanCan::Rule do
@@ -8,44 +8,44 @@ describe CanCan::Rule do
8
8
  @rule = CanCan::Rule.new(true, :read, Integer, @conditions, nil)
9
9
  end
10
10
 
11
- it "returns no association joins if none exist" do
11
+ it 'returns no association joins if none exist' do
12
12
  expect(@rule.associations_hash).to eq({})
13
13
  end
14
14
 
15
- it "returns no association for joins if just attributes" do
15
+ it 'returns no association for joins if just attributes' do
16
16
  @conditions[:foo] = :bar
17
17
  expect(@rule.associations_hash).to eq({})
18
18
  end
19
19
 
20
- it "returns single association for joins" do
21
- @conditions[:foo] = {:bar => 1}
22
- expect(@rule.associations_hash).to eq({:foo => {}})
20
+ it 'returns single association for joins' do
21
+ @conditions[:foo] = { bar: 1 }
22
+ expect(@rule.associations_hash).to eq(foo: {})
23
23
  end
24
24
 
25
- it "returns multiple associations for joins" do
26
- @conditions[:foo] = {:bar => 1}
27
- @conditions[:test] = {1 => 2}
28
- expect(@rule.associations_hash).to eq({:foo => {}, :test => {}})
25
+ it 'returns multiple associations for joins' do
26
+ @conditions[:foo] = { bar: 1 }
27
+ @conditions[:test] = { 1 => 2 }
28
+ expect(@rule.associations_hash).to eq(foo: {}, test: {})
29
29
  end
30
30
 
31
- it "returns nested associations for joins" do
32
- @conditions[:foo] = {:bar => {1 => 2}}
33
- expect(@rule.associations_hash).to eq({:foo => {:bar => {}}})
31
+ it 'returns nested associations for joins' do
32
+ @conditions[:foo] = { bar: { 1 => 2 } }
33
+ expect(@rule.associations_hash).to eq(foo: { bar: {} })
34
34
  end
35
35
 
36
- it "returns no association joins if conditions is nil" do
36
+ it 'returns no association joins if conditions is nil' do
37
37
  rule = CanCan::Rule.new(true, :read, Integer, nil, nil)
38
38
  expect(rule.associations_hash).to eq({})
39
39
  end
40
40
 
41
- it "is not mergeable if conditions are not simple hashes" do
42
- meta_where = OpenStruct.new(:name => 'metawhere', :column => 'test')
41
+ it 'is not mergeable if conditions are not simple hashes' do
42
+ meta_where = OpenStruct.new(name: 'metawhere', column: 'test')
43
43
  @conditions[meta_where] = :bar
44
44
 
45
45
  expect(@rule).to be_unmergeable
46
46
  end
47
47
 
48
- it "is not mergeable if conditions is an empty hash" do
48
+ it 'is not mergeable if conditions is an empty hash' do
49
49
  @conditions = {}
50
50
  expect(@rule).to_not be_unmergeable
51
51
  end
@@ -12,11 +12,11 @@ if defined?(I18n) && I18n.respond_to?('enforce_available_locales=')
12
12
  end
13
13
 
14
14
  # Add support to load paths
15
- $:.unshift File.expand_path('../support', __FILE__)
15
+ $LOAD_PATH.unshift File.expand_path('../support', __FILE__)
16
16
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
17
17
 
18
18
  RSpec.configure do |config|
19
- config.filter_run :focus => true
19
+ config.filter_run focus: true
20
20
  config.run_all_when_everything_filtered = true
21
21
  config.mock_with :rspec
22
22
  config.order = 'random'
@@ -4,4 +4,3 @@ class Ability
4
4
  def initialize(user)
5
5
  end
6
6
  end
7
-
metadata CHANGED
@@ -1,83 +1,100 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cancancan
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.0
4
+ version: 1.16.0
5
5
  platform: ruby
6
6
  authors:
7
+ - Alessandro Rodi (Renuo AG)
7
8
  - Bryan Rite
8
9
  - Ryan Bates
9
10
  - Richard Wilson
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2016-06-13 00:00:00.000000000 Z
14
+ date: 2017-02-10 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: bundler
17
18
  requirement: !ruby/object:Gem::Requirement
18
19
  requirements:
19
- - - "~>"
20
+ - - ~>
20
21
  - !ruby/object:Gem::Version
21
22
  version: '1.3'
22
23
  type: :development
23
24
  prerelease: false
24
25
  version_requirements: !ruby/object:Gem::Requirement
25
26
  requirements:
26
- - - "~>"
27
+ - - ~>
27
28
  - !ruby/object:Gem::Version
28
29
  version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rubocop
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ~>
35
+ - !ruby/object:Gem::Version
36
+ version: '0.46'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '0.46'
29
44
  - !ruby/object:Gem::Dependency
30
45
  name: rake
31
46
  requirement: !ruby/object:Gem::Requirement
32
47
  requirements:
33
- - - "~>"
48
+ - - ~>
34
49
  - !ruby/object:Gem::Version
35
50
  version: 10.1.1
36
51
  type: :development
37
52
  prerelease: false
38
53
  version_requirements: !ruby/object:Gem::Requirement
39
54
  requirements:
40
- - - "~>"
55
+ - - ~>
41
56
  - !ruby/object:Gem::Version
42
57
  version: 10.1.1
43
58
  - !ruby/object:Gem::Dependency
44
59
  name: rspec
45
60
  requirement: !ruby/object:Gem::Requirement
46
61
  requirements:
47
- - - "~>"
62
+ - - ~>
48
63
  - !ruby/object:Gem::Version
49
64
  version: 3.2.0
50
65
  type: :development
51
66
  prerelease: false
52
67
  version_requirements: !ruby/object:Gem::Requirement
53
68
  requirements:
54
- - - "~>"
69
+ - - ~>
55
70
  - !ruby/object:Gem::Version
56
71
  version: 3.2.0
57
72
  - !ruby/object:Gem::Dependency
58
73
  name: appraisal
59
74
  requirement: !ruby/object:Gem::Requirement
60
75
  requirements:
61
- - - ">="
76
+ - - '>='
62
77
  - !ruby/object:Gem::Version
63
78
  version: 2.0.0
64
79
  type: :development
65
80
  prerelease: false
66
81
  version_requirements: !ruby/object:Gem::Requirement
67
82
  requirements:
68
- - - ">="
83
+ - - '>='
69
84
  - !ruby/object:Gem::Version
70
85
  version: 2.0.0
71
- description: Continuation of the simple authorization solution for Rails which is
72
- decoupled from user roles. All permissions are stored in a single location.
73
- email: r.crawfordwilson@gmail.com
86
+ description: Simple authorization solution for Rails. All permissions are stored in
87
+ a single location.
88
+ email: alessandro.rodi@renuo.ch
74
89
  executables: []
75
90
  extensions: []
76
91
  extra_rdoc_files: []
77
92
  files:
78
- - ".gitignore"
79
- - ".rspec"
80
- - ".travis.yml"
93
+ - .gitignore
94
+ - .rspec
95
+ - .rubocop.yml
96
+ - .rubocop_todo.yml
97
+ - .travis.yml
81
98
  - Appraisals
82
99
  - CHANGELOG.rdoc
83
100
  - CONTRIBUTING.md
@@ -142,19 +159,43 @@ require_paths:
142
159
  - lib
143
160
  required_ruby_version: !ruby/object:Gem::Requirement
144
161
  requirements:
145
- - - ">="
162
+ - - '>='
146
163
  - !ruby/object:Gem::Version
147
164
  version: 2.0.0
148
165
  required_rubygems_version: !ruby/object:Gem::Requirement
149
166
  requirements:
150
- - - ">="
167
+ - - '>='
151
168
  - !ruby/object:Gem::Version
152
169
  version: '0'
153
170
  requirements: []
154
171
  rubyforge_project:
155
- rubygems_version: 2.4.5.1
172
+ rubygems_version: 2.0.14
156
173
  signing_key:
157
174
  specification_version: 4
158
175
  summary: Simple authorization solution for Rails.
159
176
  test_files:
160
177
  - Appraisals
178
+ - gemfiles/activerecord_3.2.gemfile
179
+ - gemfiles/activerecord_4.0.gemfile
180
+ - gemfiles/activerecord_4.1.gemfile
181
+ - gemfiles/activerecord_4.2.gemfile
182
+ - gemfiles/activerecord_5.0.gemfile
183
+ - gemfiles/mongoid_2.x.gemfile
184
+ - gemfiles/sequel_3.x.gemfile
185
+ - spec/README.rdoc
186
+ - spec/cancan/ability_spec.rb
187
+ - spec/cancan/controller_additions_spec.rb
188
+ - spec/cancan/controller_resource_spec.rb
189
+ - spec/cancan/exceptions_spec.rb
190
+ - spec/cancan/inherited_resource_spec.rb
191
+ - spec/cancan/matchers_spec.rb
192
+ - spec/cancan/model_adapters/active_record_4_adapter_spec.rb
193
+ - spec/cancan/model_adapters/active_record_adapter_spec.rb
194
+ - spec/cancan/model_adapters/default_adapter_spec.rb
195
+ - spec/cancan/model_adapters/mongoid_adapter_spec.rb
196
+ - spec/cancan/model_adapters/sequel_adapter_spec.rb
197
+ - spec/cancan/rule_spec.rb
198
+ - spec/matchers.rb
199
+ - spec/spec.opts
200
+ - spec/spec_helper.rb
201
+ - spec/support/ability.rb