cancancan 1.7.1 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -3
- data/Appraisals +50 -4
- data/CHANGELOG.rdoc +12 -1
- data/README.rdoc +12 -2
- data/Rakefile +0 -2
- data/cancancan.gemspec +3 -2
- data/gemfiles/activerecord_3.0.gemfile +18 -0
- data/gemfiles/{rails_3.0.gemfile → activerecord_3.1.gemfile} +2 -4
- data/gemfiles/activerecord_3.2.gemfile +16 -0
- data/gemfiles/{rails_3.0_datamapper.gemfile → datamapper_1.x.gemfile} +2 -1
- data/gemfiles/{rails_3.0_mongoid.gemfile → mongoid_2.x.gemfile} +6 -1
- data/gemfiles/sequel_3.x.gemfile +17 -0
- data/lib/cancan.rb +1 -0
- data/lib/cancan/ability.rb +24 -4
- data/lib/cancan/controller_resource.rb +6 -2
- data/lib/cancan/model_adapters/sequel_adapter.rb +87 -0
- data/lib/cancan/rule.rb +29 -24
- data/lib/cancan/version.rb +1 -1
- data/lib/cancancan.rb +3 -0
- data/spec/cancan/ability_spec.rb +26 -0
- data/spec/cancan/controller_resource_spec.rb +520 -447
- data/spec/cancan/inherited_resource_spec.rb +49 -38
- data/spec/cancan/model_adapters/active_record_adapter_spec.rb +106 -92
- data/spec/cancan/model_adapters/sequel_adapter_spec.rb +148 -0
- data/spec/spec_helper.rb +6 -61
- data/spec/support/ability.rb +7 -0
- metadata +41 -16
data/spec/spec_helper.rb
CHANGED
@@ -3,79 +3,24 @@ require 'bundler/setup'
|
|
3
3
|
|
4
4
|
Bundler.require
|
5
5
|
|
6
|
-
require 'supermodel'
|
7
6
|
require 'matchers'
|
8
7
|
require 'cancan/matchers'
|
9
|
-
require 'i18n'
|
10
8
|
|
11
9
|
# I8n setting to fix deprecation.
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
I18n.enforce_available_locales = false if defined? I18n
|
11
|
+
|
12
|
+
# Add support to load paths
|
13
|
+
$:.unshift File.expand_path('../support', __FILE__)
|
14
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
15
15
|
|
16
16
|
RSpec.configure do |config|
|
17
17
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
18
18
|
config.filter_run :focus => true
|
19
19
|
config.run_all_when_everything_filtered = true
|
20
20
|
config.mock_with :rspec
|
21
|
+
config.order = 'random'
|
21
22
|
|
22
23
|
config.expect_with :rspec do |c|
|
23
24
|
c.syntax = :expect
|
24
25
|
end
|
25
|
-
|
26
|
-
config.before(:each) do
|
27
|
-
Project.delete_all
|
28
|
-
Category.delete_all
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# Working around CVE-2012-5664 requires us to convert all ID params
|
33
|
-
# to strings. Let's switch to using string IDs in tests, otherwise
|
34
|
-
# SuperModel and/or RR will fail (as strings are not fixnums).
|
35
|
-
|
36
|
-
module SuperModel
|
37
|
-
class Base
|
38
|
-
def generate_id
|
39
|
-
object_id.to_s
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class Ability
|
45
|
-
include CanCan::Ability
|
46
|
-
|
47
|
-
def initialize(user)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class Category < SuperModel::Base
|
52
|
-
has_many :projects
|
53
|
-
end
|
54
|
-
|
55
|
-
module Sub
|
56
|
-
class Project < SuperModel::Base
|
57
|
-
belongs_to :category
|
58
|
-
attr_accessor :category # why doesn't SuperModel do this automatically?
|
59
|
-
|
60
|
-
def self.respond_to?(method, include_private = false)
|
61
|
-
if method.to_s == "find_by_name!" # hack to simulate ActiveRecord
|
62
|
-
true
|
63
|
-
else
|
64
|
-
super
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
class Project < SuperModel::Base
|
71
|
-
belongs_to :category
|
72
|
-
attr_accessor :category # why doesn't SuperModel do this automatically?
|
73
|
-
|
74
|
-
def self.respond_to?(method, include_private = false)
|
75
|
-
if method.to_s == "find_by_name!" # hack to simulate ActiveRecord
|
76
|
-
true
|
77
|
-
else
|
78
|
-
super
|
79
|
-
end
|
80
|
-
end
|
81
26
|
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.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Rite
|
@@ -9,50 +9,64 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '1.3'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '1.3'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 10.1.1
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 10.1.1
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.14'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.14'
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: appraisal
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
45
59
|
requirements:
|
46
60
|
- - ">="
|
47
61
|
- !ruby/object:Gem::Version
|
48
|
-
version: 1.0.0
|
62
|
+
version: 1.0.0
|
49
63
|
type: :development
|
50
64
|
prerelease: false
|
51
65
|
version_requirements: !ruby/object:Gem::Requirement
|
52
66
|
requirements:
|
53
67
|
- - ">="
|
54
68
|
- !ruby/object:Gem::Version
|
55
|
-
version: 1.0.0
|
69
|
+
version: 1.0.0
|
56
70
|
description: Continuation of the simple authorization solution for Rails which is
|
57
71
|
decoupled from user roles. All permissions are stored in a single location.
|
58
72
|
email: bryan@bryanrite.com
|
@@ -71,9 +85,12 @@ files:
|
|
71
85
|
- README.rdoc
|
72
86
|
- Rakefile
|
73
87
|
- cancancan.gemspec
|
74
|
-
- gemfiles/
|
75
|
-
- gemfiles/
|
76
|
-
- gemfiles/
|
88
|
+
- gemfiles/activerecord_3.0.gemfile
|
89
|
+
- gemfiles/activerecord_3.1.gemfile
|
90
|
+
- gemfiles/activerecord_3.2.gemfile
|
91
|
+
- gemfiles/datamapper_1.x.gemfile
|
92
|
+
- gemfiles/mongoid_2.x.gemfile
|
93
|
+
- gemfiles/sequel_3.x.gemfile
|
77
94
|
- init.rb
|
78
95
|
- lib/cancan.rb
|
79
96
|
- lib/cancan/ability.rb
|
@@ -87,6 +104,7 @@ files:
|
|
87
104
|
- lib/cancan/model_adapters/data_mapper_adapter.rb
|
88
105
|
- lib/cancan/model_adapters/default_adapter.rb
|
89
106
|
- lib/cancan/model_adapters/mongoid_adapter.rb
|
107
|
+
- lib/cancan/model_adapters/sequel_adapter.rb
|
90
108
|
- lib/cancan/model_additions.rb
|
91
109
|
- lib/cancan/rule.rb
|
92
110
|
- lib/cancan/version.rb
|
@@ -105,10 +123,12 @@ files:
|
|
105
123
|
- spec/cancan/model_adapters/data_mapper_adapter_spec.rb
|
106
124
|
- spec/cancan/model_adapters/default_adapter_spec.rb
|
107
125
|
- spec/cancan/model_adapters/mongoid_adapter_spec.rb
|
126
|
+
- spec/cancan/model_adapters/sequel_adapter_spec.rb
|
108
127
|
- spec/cancan/rule_spec.rb
|
109
128
|
- spec/matchers.rb
|
110
129
|
- spec/spec.opts
|
111
130
|
- spec/spec_helper.rb
|
131
|
+
- spec/support/ability.rb
|
112
132
|
homepage: https://github.com/CanCanCommunity/cancancan
|
113
133
|
licenses:
|
114
134
|
- MIT
|
@@ -135,9 +155,12 @@ specification_version: 4
|
|
135
155
|
summary: Simple authorization solution for Rails.
|
136
156
|
test_files:
|
137
157
|
- Appraisals
|
138
|
-
- gemfiles/
|
139
|
-
- gemfiles/
|
140
|
-
- gemfiles/
|
158
|
+
- gemfiles/activerecord_3.0.gemfile
|
159
|
+
- gemfiles/activerecord_3.1.gemfile
|
160
|
+
- gemfiles/activerecord_3.2.gemfile
|
161
|
+
- gemfiles/datamapper_1.x.gemfile
|
162
|
+
- gemfiles/mongoid_2.x.gemfile
|
163
|
+
- gemfiles/sequel_3.x.gemfile
|
141
164
|
- spec/README.rdoc
|
142
165
|
- spec/cancan/ability_spec.rb
|
143
166
|
- spec/cancan/controller_additions_spec.rb
|
@@ -149,7 +172,9 @@ test_files:
|
|
149
172
|
- spec/cancan/model_adapters/data_mapper_adapter_spec.rb
|
150
173
|
- spec/cancan/model_adapters/default_adapter_spec.rb
|
151
174
|
- spec/cancan/model_adapters/mongoid_adapter_spec.rb
|
175
|
+
- spec/cancan/model_adapters/sequel_adapter_spec.rb
|
152
176
|
- spec/cancan/rule_spec.rb
|
153
177
|
- spec/matchers.rb
|
154
178
|
- spec/spec.opts
|
155
179
|
- spec/spec_helper.rb
|
180
|
+
- spec/support/ability.rb
|