rolify 5.2.0 → 6.0.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 +5 -5
- data/.github/workflows/activerecord.yml +27 -0
- data/.github/workflows/mongoid.yml +32 -0
- data/.hakiri.yml +1 -0
- data/Appraisals +27 -26
- data/CHANGELOG.rdoc +29 -8
- data/Gemfile +6 -5
- data/README.md +16 -5
- data/Rakefile +2 -1
- data/gemfiles/activerecord_4.gemfile +7 -6
- data/gemfiles/activerecord_5.gemfile +9 -14
- data/gemfiles/{activerecord_3.gemfile → activerecord_6.gemfile} +9 -6
- data/gemfiles/mongoid_5.gemfile +6 -5
- data/gemfiles/{mongoid_3.gemfile → mongoid_6.gemfile} +6 -6
- data/gemfiles/{mongoid_4.gemfile → mongoid_7.gemfile} +7 -6
- data/lib/generators/active_record/rolify_generator.rb +3 -3
- data/lib/generators/active_record/templates/model.rb +13 -14
- data/lib/rolify/adapters/active_record/resource_adapter.rb +1 -1
- data/lib/rolify/adapters/active_record/role_adapter.rb +19 -19
- data/lib/rolify/adapters/mongoid/role_adapter.rb +17 -10
- data/lib/rolify/finders.rb +6 -1
- data/lib/rolify/resource.rb +1 -1
- data/lib/rolify/role.rb +1 -1
- data/lib/rolify/version.rb +1 -1
- data/lib/rolify.rb +2 -2
- data/rolify.gemspec +6 -4
- data/spec/generators/rolify/rolify_activerecord_generator_spec.rb +8 -0
- data/spec/rolify/shared_examples/shared_examples_for_finders.rb +50 -32
- data/spec/rolify/utils_spec.rb +19 -0
- data/spec/support/adapters/{mongoid_3.yml → mongoid_6.yml} +2 -2
- data/spec/support/adapters/{mongoid_4.yml → mongoid_7.yml} +2 -2
- metadata +39 -25
- data/.travis.yml +0 -93
- data/gemfiles/Gemfile.rails-3.2 +0 -27
- data/gemfiles/Gemfile.rails-4.0 +0 -33
- data/gemfiles/Gemfile.rails-4.1 +0 -37
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 39183b0e66a9dfdbe636059ec28145106f14347129676c334598ff4f330edfc0
|
|
4
|
+
data.tar.gz: 686c5b98efcc79e84b104cca586053b920032cbc0bf7978baa0b1caa04e021bb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a24f0ef337c8c5d1b9381e30020ba18c790193f4b00085cbd2581f25d6322d5ffeee099a22a43b4b4c86de66a2774364f799426ae71ed331027d5e565a06be72
|
|
7
|
+
data.tar.gz: b1d55761a7a5df75a9c1f462ca04232c44e81adcc180ece7232386f0c6f4dff0441cc463e674075c5906fc3c3ddcc71922dd20cf2129eecff099fa604db56b94
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: activerecord
|
|
2
|
+
on: [push]
|
|
3
|
+
jobs:
|
|
4
|
+
ubuntu:
|
|
5
|
+
runs-on: ubuntu-latest
|
|
6
|
+
continue-on-error: true
|
|
7
|
+
strategy:
|
|
8
|
+
matrix:
|
|
9
|
+
gemfile: [activerecord_4, activerecord_5, activerecord_6]
|
|
10
|
+
ruby: [2.5.7, 2.6.5, 2.7.2]
|
|
11
|
+
env:
|
|
12
|
+
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
|
13
|
+
ADAPTER: active_record
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v2
|
|
16
|
+
- name: Setup ruby
|
|
17
|
+
uses: ruby/setup-ruby@v1
|
|
18
|
+
with:
|
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
|
20
|
+
- run: sudo apt-get install -y libsqlite3-dev
|
|
21
|
+
- run: gem update --system
|
|
22
|
+
- run: gem install bundler
|
|
23
|
+
- run: gem --version
|
|
24
|
+
- run: bundle install
|
|
25
|
+
- name: Run Tests
|
|
26
|
+
run: |
|
|
27
|
+
bundle exec rake
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: mongoid
|
|
2
|
+
on: [push]
|
|
3
|
+
jobs:
|
|
4
|
+
ubuntu:
|
|
5
|
+
runs-on: ubuntu-latest
|
|
6
|
+
continue-on-error: true
|
|
7
|
+
services:
|
|
8
|
+
mongodb:
|
|
9
|
+
image: mongo:3.4.23
|
|
10
|
+
ports:
|
|
11
|
+
- 27017:27017
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
gemfile: [mongoid_5]
|
|
15
|
+
ruby: [2.5.7, 2.6.5, 2.7.2]
|
|
16
|
+
env:
|
|
17
|
+
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
|
18
|
+
ADAPTER: mongoid
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v2
|
|
21
|
+
- name: Setup ruby
|
|
22
|
+
uses: ruby/setup-ruby@v1
|
|
23
|
+
with:
|
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
|
25
|
+
- run: sudo apt-get install -y libsqlite3-dev
|
|
26
|
+
- run: gem update --system
|
|
27
|
+
- run: gem install bundler
|
|
28
|
+
- run: gem --version
|
|
29
|
+
- run: bundle install
|
|
30
|
+
- name: Run Tests
|
|
31
|
+
run: |
|
|
32
|
+
bundle exec rake
|
data/.hakiri.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dependency_source: gemspec_file
|
data/Appraisals
CHANGED
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
appraise 'mongoid-3' do
|
|
2
|
-
gem "mongoid", "~> 3"
|
|
3
|
-
gem "bson_ext", :platform => "ruby"
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
appraise 'mongoid-4' do
|
|
7
|
-
gem "mongoid", "~> 4"
|
|
8
|
-
gem "bson_ext", :platform => "ruby"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
1
|
appraise 'mongoid-5' do
|
|
12
2
|
gem "mongoid", "~> 5"
|
|
13
|
-
gem "bson_ext",
|
|
3
|
+
gem "bson_ext", "1.5.1"
|
|
4
|
+
gem 'bigdecimal', '1.4.2'
|
|
14
5
|
end
|
|
15
6
|
|
|
16
|
-
appraise '
|
|
17
|
-
gem "
|
|
18
|
-
gem "
|
|
7
|
+
appraise 'mongoid-6' do
|
|
8
|
+
gem "mongoid", "~> 6"
|
|
9
|
+
gem "bson_ext", "1.5.1"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
appraise 'mongoid-7' do
|
|
13
|
+
gem "mongoid", "~> 7"
|
|
14
|
+
gem "bson_ext", "1.5.1"
|
|
15
|
+
gem "railties", "5.2.4.1"
|
|
19
16
|
end
|
|
20
17
|
|
|
21
18
|
appraise 'activerecord-4' do
|
|
22
|
-
gem "sqlite3",
|
|
23
|
-
gem "activerecord", "~> 4.2.
|
|
19
|
+
gem "sqlite3", "~> 1.3.6"
|
|
20
|
+
gem "activerecord", "~> 4.2.11", :require => "active_record"
|
|
21
|
+
gem 'bigdecimal', '1.4.2'
|
|
24
22
|
end
|
|
25
23
|
|
|
26
24
|
appraise 'activerecord-5' do
|
|
27
|
-
gem "sqlite3",
|
|
28
|
-
gem "activerecord", "
|
|
25
|
+
gem "sqlite3", "~> 1.3.6"
|
|
26
|
+
gem "activerecord", "~> 5.2.4", :require => "active_record"
|
|
29
27
|
|
|
30
28
|
# Ammeter dependencies:
|
|
31
|
-
gem "actionpack", "
|
|
32
|
-
gem "activemodel", "
|
|
33
|
-
gem "railties", "
|
|
29
|
+
gem "actionpack", "~> 5.2.4"
|
|
30
|
+
gem "activemodel", "~> 5.2.4"
|
|
31
|
+
gem "railties", "~> 5.2.4"
|
|
32
|
+
end
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
gem
|
|
37
|
-
gem
|
|
38
|
-
gem 'rspec-mocks' , github: 'rspec/rspec-mocks'
|
|
39
|
-
gem 'rspec-support' , github: 'rspec/rspec-support'
|
|
34
|
+
appraise 'activerecord-6' do
|
|
35
|
+
gem "sqlite3", "~> 1.4", :platform => "ruby"
|
|
36
|
+
gem "activerecord", ">= 6.0.0", :require => "active_record"
|
|
40
37
|
|
|
38
|
+
# Ammeter dependencies:
|
|
39
|
+
gem "actionpack", ">= 6.0.0"
|
|
40
|
+
gem "activemodel", ">= 6.0.0"
|
|
41
|
+
gem "railties", ">= 6.0.0"
|
|
41
42
|
end
|
data/CHANGELOG.rdoc
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
= 6.0.0 (April 2, 2021)
|
|
2
|
+
|
|
3
|
+
Breaking changes:
|
|
4
|
+
|
|
5
|
+
* Support strict <tt>with_role</tt> queries. Note this changes behaviour of with_role when running in strict mode to behave as previously documented. #543 describes the behaviour change.
|
|
6
|
+
* Dropped support for Ruby 2.3 and 2.4
|
|
7
|
+
|
|
8
|
+
Improvements:
|
|
9
|
+
|
|
10
|
+
* Updated ActiveRecord adapters implementation of <tt>in</tt> to utilise a subquery instead of two queries
|
|
11
|
+
|
|
12
|
+
= 5.3.0 (June 1, 2020)
|
|
13
|
+
|
|
14
|
+
5.3.0 will be the last version to support Ruby < 2.5 and Rails < 5.2. Support for these will be dropped in the next major release.
|
|
15
|
+
|
|
16
|
+
* Fix deprecation warning in Ruby 2.7
|
|
17
|
+
* Add Rails 6 support to migration generator
|
|
18
|
+
* Significant ActiveRecord performance improvements to <tt>add_role</tt> and <tt>without_role</tt>
|
|
19
|
+
* Mongoid fix and performance improvement and to <tt>roles_name</tt>
|
|
20
|
+
* Make it safe to call <tt>Thing.with_role(:admin, user)</tt> with new record
|
|
21
|
+
|
|
1
22
|
= 5.2.0 (Dec 14, 2017)
|
|
2
23
|
* Fix regression in generator around belongs_to options compatibility
|
|
3
24
|
* Update version of database_cleaner
|
|
@@ -126,7 +147,7 @@
|
|
|
126
147
|
* fixed a backward incompatible change introduced in Rails 3.2 release (<tt>find_or_create_by_* generated methods</tt>)
|
|
127
148
|
|
|
128
149
|
= 2.2 (Jan 18, 2012)
|
|
129
|
-
* fixed a bug in the initializer file regarding dynamic shortcuts
|
|
150
|
+
* fixed a bug in the initializer file regarding dynamic shortcuts
|
|
130
151
|
|
|
131
152
|
= 2.1 (Nov 30, 2011)
|
|
132
153
|
* added syntactic sugar: <tt>grant</tt> and <tt>revoke</tt> are aliases for <tt>has_role</tt> and <tt>has_no_role</tt>
|
|
@@ -167,8 +188,8 @@
|
|
|
167
188
|
|
|
168
189
|
= 1.0 (Aug 25, 2011)
|
|
169
190
|
* added a new parameter to disable dynamic shortcut methods due to potential incompatibility with other gems using method_missing with the same pattern
|
|
170
|
-
* add <tt>Rolify.dynamic_shortcuts = false</tt> in the initializer file or
|
|
171
|
-
* use the generator command with a third parameter:
|
|
191
|
+
* add <tt>Rolify.dynamic_shortcuts = false</tt> in the initializer file or
|
|
192
|
+
* use the generator command with a third parameter:
|
|
172
193
|
* <tt>rails g rolify:role Role User false</tt>
|
|
173
194
|
* removed the railtie as it created more problems than it solved
|
|
174
195
|
* code refactoring to do some speed improvements and code clean up
|
|
@@ -177,16 +198,16 @@
|
|
|
177
198
|
* rolify is now on travis-ci to monitor build status
|
|
178
199
|
|
|
179
200
|
= 0.7 (June 20, 2011)
|
|
180
|
-
* added a method_missing to catch newly created role outside the current ruby process (i.e. dynamic shortcut methods are not defined within this process)
|
|
181
|
-
* dynamic shortcut is created on the fly in the method_missing to avoid extra method_missing for the same dynamic shortcut
|
|
182
|
-
* check if the role actually exists in the database before defining the new method
|
|
201
|
+
* added a method_missing to catch newly created role outside the current ruby process (i.e. dynamic shortcut methods are not defined within this process)
|
|
202
|
+
* dynamic shortcut is created on the fly in the method_missing to avoid extra method_missing for the same dynamic shortcut
|
|
203
|
+
* check if the role actually exists in the database before defining the new method
|
|
183
204
|
* first call is slower due to method_missing but next calls are fast
|
|
184
205
|
* avoid strange bugs when spawning many ruby processes as the dynamic shortcut methods were only defined in the process that used the <tt>has_role</tt> command
|
|
185
206
|
|
|
186
207
|
= 0.6 (June 19, 2011)
|
|
187
208
|
* custom User and Role class names support
|
|
188
209
|
* can now use other class names for Role and User classes
|
|
189
|
-
* fixed generators and templates
|
|
210
|
+
* fixed generators and templates
|
|
190
211
|
* join table is explicitly set to avoid alphabetical order issue
|
|
191
212
|
* created a new railtie to load the dynamic shortcuts at startup
|
|
192
213
|
|
|
@@ -208,7 +229,7 @@
|
|
|
208
229
|
* Trying to remove a role scoped to a resource whereas the user has a global role won't remove it
|
|
209
230
|
|
|
210
231
|
= v0.3 (June 06, 2011)
|
|
211
|
-
* multiple roles check:
|
|
232
|
+
* multiple roles check:
|
|
212
233
|
* <tt>has_all_roles?</tt> returns true if the user has ALL the roles in arguments
|
|
213
234
|
* <tt>has_any_role?</tt> returns true if the user has ANY the roles in arguments
|
|
214
235
|
|
data/Gemfile
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
source "https://rubygems.org"
|
|
2
2
|
|
|
3
3
|
group :test do
|
|
4
|
-
gem '
|
|
5
|
-
gem 'coveralls', :
|
|
4
|
+
gem 'codeclimate-test-reporter', require: nil
|
|
5
|
+
gem 'coveralls', require: false
|
|
6
|
+
gem 'database_cleaner', '~> 1.6.2'
|
|
6
7
|
gem 'its'
|
|
8
|
+
gem 'test-unit' # Implicitly loaded by ammeter
|
|
9
|
+
|
|
7
10
|
gem 'byebug'
|
|
11
|
+
gem 'pry'
|
|
8
12
|
gem 'pry-byebug'
|
|
9
|
-
gem 'test-unit' # Implicitly loaded by ammeter
|
|
10
|
-
gem 'database_cleaner', '~> 1.6.2'
|
|
11
|
-
gem 'codeclimate-test-reporter', :require => nil
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
gemspec
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# rolify [](http://badge.fury.io/rb/rolify) [](http://badge.fury.io/rb/rolify) [](http://travis-ci.org/RolifyCommunity/rolify) [](https://codeclimate.com/github/RolifyCommunity/rolify) [](https://coveralls.io/github/RolifyCommunity/rolify?branch=master)
|
|
2
2
|
|
|
3
3
|
Very simple Roles library without any authorization enforcement supporting scope on resource object.
|
|
4
4
|
|
|
@@ -15,9 +15,9 @@ This library can be easily integrated with any authentication gem ([devise](http
|
|
|
15
15
|
|
|
16
16
|
## Requirements
|
|
17
17
|
|
|
18
|
-
* Rails >=
|
|
19
|
-
* ActiveRecord >=
|
|
20
|
-
* supports ruby 2.
|
|
18
|
+
* Rails >= 4.2
|
|
19
|
+
* ActiveRecord >= 4.2 <b>or</b> Mongoid >= 4.0
|
|
20
|
+
* supports ruby 2.2+, JRuby 1.6.0+ (in 1.9 mode) and Rubinius 2.0.0dev (in 1.9 mode)
|
|
21
21
|
* support of ruby 1.8 has been dropped due to Mongoid >=3.0 that only supports 1.9 new hash syntax
|
|
22
22
|
|
|
23
23
|
## Installation
|
|
@@ -46,7 +46,7 @@ rails g rolify Role User
|
|
|
46
46
|
rails g rolify:role Role User
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
The generator will create your Role model, add a migration file, and update your User class with new class methods.
|
|
49
|
+
The generator will create your Role model, add a migration file, and update your User class with new class methods.
|
|
50
50
|
|
|
51
51
|
### 2. Run the migration (only required when using ActiveRecord)
|
|
52
52
|
|
|
@@ -181,6 +181,17 @@ user.has_role? :moderator, Forum.last
|
|
|
181
181
|
=> true
|
|
182
182
|
```
|
|
183
183
|
|
|
184
|
+
To check if a user has the exact role scoped to a resource class:
|
|
185
|
+
|
|
186
|
+
```ruby
|
|
187
|
+
user = User.find(5)
|
|
188
|
+
user.add_role :moderator # sets a global role
|
|
189
|
+
user.has_role? :moderator, Forum.first
|
|
190
|
+
=> true
|
|
191
|
+
user.has_strict_role? :moderator, Forum.last
|
|
192
|
+
=> false
|
|
193
|
+
```
|
|
194
|
+
|
|
184
195
|
### 6. Resource roles querying
|
|
185
196
|
|
|
186
197
|
Starting from rolify 3.0, you can search roles on instance level or class level resources.
|
data/Rakefile
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'bundler'
|
|
2
2
|
require 'rspec/core/rake_task'
|
|
3
3
|
require 'coveralls/rake/task'
|
|
4
|
+
require 'appraisal'
|
|
4
5
|
|
|
5
6
|
Bundler::GemHelper.install_tasks
|
|
6
7
|
|
|
@@ -14,7 +15,7 @@ RSpec::Core::RakeTask.new(:rolify) do |task|
|
|
|
14
15
|
task.pattern = 'spec/rolify/**/*_spec.rb'
|
|
15
16
|
end
|
|
16
17
|
|
|
17
|
-
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["
|
|
18
|
+
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["CI"]
|
|
18
19
|
task :default => :appraisal
|
|
19
20
|
else
|
|
20
21
|
task :default => [ :spec, 'coveralls:push' ]
|
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "sqlite3",
|
|
6
|
-
gem "activerecord", "~> 4.2.
|
|
5
|
+
gem "sqlite3", "~> 1.3.6"
|
|
6
|
+
gem "activerecord", "~> 4.2.11", require: "active_record"
|
|
7
|
+
gem "bigdecimal", "1.4.2"
|
|
7
8
|
|
|
8
9
|
group :test do
|
|
9
|
-
gem "
|
|
10
|
+
gem "codeclimate-test-reporter", require: nil
|
|
10
11
|
gem "coveralls", require: false
|
|
12
|
+
gem "database_cleaner", "~> 1.6.2"
|
|
11
13
|
gem "its"
|
|
14
|
+
gem "test-unit"
|
|
12
15
|
gem "byebug"
|
|
16
|
+
gem "pry"
|
|
13
17
|
gem "pry-byebug"
|
|
14
|
-
gem "test-unit"
|
|
15
|
-
gem "database_cleaner", "~> 1.6.2"
|
|
16
|
-
gem "codeclimate-test-reporter", require: nil
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
gemspec path: "../"
|
|
@@ -2,26 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "sqlite3",
|
|
6
|
-
gem "activerecord", "
|
|
7
|
-
gem "actionpack", "
|
|
8
|
-
gem "activemodel", "
|
|
9
|
-
gem "railties", "
|
|
10
|
-
gem "rspec-rails", github: "rspec/rspec-rails"
|
|
11
|
-
gem "rspec-core", github: "rspec/rspec-core"
|
|
12
|
-
gem "rspec-expectations", github: "rspec/rspec-expectations"
|
|
13
|
-
gem "rspec-mocks", github: "rspec/rspec-mocks"
|
|
14
|
-
gem "rspec-support", github: "rspec/rspec-support"
|
|
5
|
+
gem "sqlite3", "~> 1.3.6"
|
|
6
|
+
gem "activerecord", "~> 5.2.4", require: "active_record"
|
|
7
|
+
gem "actionpack", "~> 5.2.4"
|
|
8
|
+
gem "activemodel", "~> 5.2.4"
|
|
9
|
+
gem "railties", "~> 5.2.4"
|
|
15
10
|
|
|
16
11
|
group :test do
|
|
17
|
-
gem "
|
|
12
|
+
gem "codeclimate-test-reporter", require: nil
|
|
18
13
|
gem "coveralls", require: false
|
|
14
|
+
gem "database_cleaner", "~> 1.6.2"
|
|
19
15
|
gem "its"
|
|
16
|
+
gem "test-unit"
|
|
20
17
|
gem "byebug"
|
|
18
|
+
gem "pry"
|
|
21
19
|
gem "pry-byebug"
|
|
22
|
-
gem "test-unit"
|
|
23
|
-
gem "database_cleaner", "~> 1.6.2"
|
|
24
|
-
gem "codeclimate-test-reporter", require: nil
|
|
25
20
|
end
|
|
26
21
|
|
|
27
22
|
gemspec path: "../"
|
|
@@ -2,18 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "sqlite3", platform: "ruby"
|
|
6
|
-
gem "activerecord", "
|
|
5
|
+
gem "sqlite3", "~> 1.4", platform: "ruby"
|
|
6
|
+
gem "activerecord", ">= 6.0.0", require: "active_record"
|
|
7
|
+
gem "actionpack", ">= 6.0.0"
|
|
8
|
+
gem "activemodel", ">= 6.0.0"
|
|
9
|
+
gem "railties", ">= 6.0.0"
|
|
7
10
|
|
|
8
11
|
group :test do
|
|
9
|
-
gem "
|
|
12
|
+
gem "codeclimate-test-reporter", require: nil
|
|
10
13
|
gem "coveralls", require: false
|
|
14
|
+
gem "database_cleaner", "~> 1.6.2"
|
|
11
15
|
gem "its"
|
|
16
|
+
gem "test-unit"
|
|
12
17
|
gem "byebug"
|
|
18
|
+
gem "pry"
|
|
13
19
|
gem "pry-byebug"
|
|
14
|
-
gem "test-unit"
|
|
15
|
-
gem "database_cleaner", "~> 1.6.2"
|
|
16
|
-
gem "codeclimate-test-reporter", require: nil
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
gemspec path: "../"
|
data/gemfiles/mongoid_5.gemfile
CHANGED
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
5
|
gem "mongoid", "~> 5"
|
|
6
|
-
gem "bson_ext",
|
|
6
|
+
gem "bson_ext", "1.5.1"
|
|
7
|
+
gem "bigdecimal", "1.4.2"
|
|
7
8
|
|
|
8
9
|
group :test do
|
|
9
|
-
gem "
|
|
10
|
+
gem "codeclimate-test-reporter", require: nil
|
|
10
11
|
gem "coveralls", require: false
|
|
12
|
+
gem "database_cleaner", "~> 1.6.2"
|
|
11
13
|
gem "its"
|
|
14
|
+
gem "test-unit"
|
|
12
15
|
gem "byebug"
|
|
16
|
+
gem "pry"
|
|
13
17
|
gem "pry-byebug"
|
|
14
|
-
gem "test-unit"
|
|
15
|
-
gem "database_cleaner", "~> 1.6.2"
|
|
16
|
-
gem "codeclimate-test-reporter", require: nil
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
gemspec path: "../"
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "mongoid", "~>
|
|
6
|
-
gem "bson_ext",
|
|
5
|
+
gem "mongoid", "~> 6"
|
|
6
|
+
gem "bson_ext", "1.5.1"
|
|
7
7
|
|
|
8
8
|
group :test do
|
|
9
|
-
gem "
|
|
9
|
+
gem "codeclimate-test-reporter", require: nil
|
|
10
10
|
gem "coveralls", require: false
|
|
11
|
+
gem "database_cleaner", "~> 1.6.2"
|
|
11
12
|
gem "its"
|
|
13
|
+
gem "test-unit"
|
|
12
14
|
gem "byebug"
|
|
15
|
+
gem "pry"
|
|
13
16
|
gem "pry-byebug"
|
|
14
|
-
gem "test-unit"
|
|
15
|
-
gem "database_cleaner", "~> 1.6.2"
|
|
16
|
-
gem "codeclimate-test-reporter", require: nil
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
gemspec path: "../"
|
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "mongoid", "~>
|
|
6
|
-
gem "bson_ext",
|
|
5
|
+
gem "mongoid", "~> 7"
|
|
6
|
+
gem "bson_ext", "1.5.1"
|
|
7
|
+
gem "railties", "5.2.4.1"
|
|
7
8
|
|
|
8
9
|
group :test do
|
|
9
|
-
gem "
|
|
10
|
+
gem "codeclimate-test-reporter", require: nil
|
|
10
11
|
gem "coveralls", require: false
|
|
12
|
+
gem "database_cleaner", "~> 1.6.2"
|
|
11
13
|
gem "its"
|
|
14
|
+
gem "test-unit"
|
|
12
15
|
gem "byebug"
|
|
16
|
+
gem "pry"
|
|
13
17
|
gem "pry-byebug"
|
|
14
|
-
gem "test-unit"
|
|
15
|
-
gem "database_cleaner", "~> 1.6.2"
|
|
16
|
-
gem "codeclimate-test-reporter", require: nil
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
gemspec path: "../"
|
|
@@ -82,12 +82,12 @@ Please ensure that this model exists and is not mis-spelled and re-run the gener
|
|
|
82
82
|
MSG
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
def
|
|
86
|
-
Rails
|
|
85
|
+
def versioned_migrations?
|
|
86
|
+
Rails::VERSION::MAJOR >= 5
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
def migration_version
|
|
90
|
-
if
|
|
90
|
+
if versioned_migrations?
|
|
91
91
|
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
|
92
92
|
end
|
|
93
93
|
end
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
has_and_belongs_to_many :<%= user_class.table_name %>, :join_table => :<%= join_table %>
|
|
1
|
+
has_and_belongs_to_many :<%= user_class.table_name %>, :join_table => :<%= join_table %>
|
|
2
|
+
<% if Rails::VERSION::MAJOR < 5 %>
|
|
3
|
+
belongs_to :resource,
|
|
4
|
+
:polymorphic => true
|
|
5
|
+
<% else %>
|
|
6
|
+
belongs_to :resource,
|
|
7
|
+
:polymorphic => true,
|
|
8
|
+
:optional => true
|
|
9
|
+
<% end %>
|
|
2
10
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<% else %>
|
|
7
|
-
belongs_to :resource,
|
|
8
|
-
:polymorphic => true,
|
|
9
|
-
:optional => true
|
|
10
|
-
<% end %>
|
|
11
|
+
validates :resource_type,
|
|
12
|
+
:inclusion => { :in => Rolify.resource_types },
|
|
13
|
+
:allow_nil => true
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
:inclusion => { :in => Rolify.resource_types },
|
|
14
|
-
:allow_nil => true
|
|
15
|
-
|
|
16
|
-
scopify
|
|
15
|
+
scopify
|
|
@@ -40,7 +40,7 @@ module Rolify
|
|
|
40
40
|
|
|
41
41
|
def all_except(resource, excluded_obj)
|
|
42
42
|
prime_key = resource.primary_key.to_sym
|
|
43
|
-
resource.where(prime_key =>
|
|
43
|
+
resource.where.not(prime_key => excluded_obj.pluck(prime_key))
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
private
|
|
@@ -9,14 +9,20 @@ module Rolify
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def where_strict(relation, args)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
wrap_conditions = relation.name != role_class.name
|
|
13
|
+
|
|
14
|
+
conditions = if args[:resource].is_a?(Class)
|
|
15
|
+
{:resource_type => args[:resource].to_s, :resource_id => nil }
|
|
16
|
+
elsif args[:resource].present?
|
|
17
|
+
{:resource_type => args[:resource].class.name, :resource_id => args[:resource].id}
|
|
18
|
+
else
|
|
19
|
+
{}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
conditions.merge!(:name => args[:name])
|
|
23
|
+
conditions = wrap_conditions ? { role_table => conditions } : conditions
|
|
24
|
+
|
|
25
|
+
relation.where(conditions)
|
|
20
26
|
end
|
|
21
27
|
|
|
22
28
|
def find_cached(relation, args)
|
|
@@ -46,7 +52,7 @@ module Rolify
|
|
|
46
52
|
end
|
|
47
53
|
|
|
48
54
|
def add(relation, role)
|
|
49
|
-
relation.
|
|
55
|
+
relation.roles << role unless relation.roles.include?(role)
|
|
50
56
|
end
|
|
51
57
|
|
|
52
58
|
def remove(relation, role_name, resource = nil)
|
|
@@ -67,20 +73,14 @@ module Rolify
|
|
|
67
73
|
relation.where("#{column} IS NOT NULL")
|
|
68
74
|
end
|
|
69
75
|
|
|
70
|
-
def scope(relation, conditions)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
else
|
|
74
|
-
query = relation.all
|
|
75
|
-
end
|
|
76
|
-
query = query.joins(:roles)
|
|
77
|
-
query = where(query, conditions)
|
|
76
|
+
def scope(relation, conditions, strict)
|
|
77
|
+
query = relation.joins(:roles)
|
|
78
|
+
query = strict ? where_strict(query, conditions) : where(query, conditions)
|
|
78
79
|
query
|
|
79
80
|
end
|
|
80
81
|
|
|
81
82
|
def all_except(user, excluded_obj)
|
|
82
|
-
|
|
83
|
-
user.where(prime_key => (user.all - excluded_obj).map(&prime_key))
|
|
83
|
+
user.where.not(user.primary_key => excluded_obj)
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
private
|
|
@@ -9,14 +9,20 @@ module Rolify
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def where_strict(relation, args)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
wrap_conditions = relation.name != role_class.name
|
|
13
|
+
|
|
14
|
+
conditions = if args[:resource].is_a?(Class)
|
|
15
|
+
{:resource_type => args[:resource].to_s, :resource_id => nil }
|
|
16
|
+
elsif args[:resource].present?
|
|
17
|
+
{:resource_type => args[:resource].class.name, :resource_id => args[:resource].id}
|
|
18
|
+
else
|
|
19
|
+
{}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
conditions.merge!(:name => args[:name])
|
|
23
|
+
conditions = wrap_conditions ? { role_table => conditions } : conditions
|
|
24
|
+
|
|
25
|
+
relation.where(conditions)
|
|
20
26
|
end
|
|
21
27
|
|
|
22
28
|
def find_cached(relation, args)
|
|
@@ -84,8 +90,9 @@ module Rolify
|
|
|
84
90
|
relation.where(column.to_sym.ne => nil)
|
|
85
91
|
end
|
|
86
92
|
|
|
87
|
-
def scope(relation, conditions)
|
|
88
|
-
|
|
93
|
+
def scope(relation, conditions, strict)
|
|
94
|
+
query = strict ? where_strict(role_class, conditions) : where(role_class, conditions)
|
|
95
|
+
roles = query.map { |role| role.id }
|
|
89
96
|
return [] if roles.size.zero?
|
|
90
97
|
query = relation.any_in(:role_ids => roles)
|
|
91
98
|
query
|
data/lib/rolify/finders.rb
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
module Rolify
|
|
2
2
|
module Finders
|
|
3
3
|
def with_role(role_name, resource = nil)
|
|
4
|
-
self.
|
|
4
|
+
strict = self.strict_rolify and resource and resource != :any
|
|
5
|
+
self.adapter.scope(
|
|
6
|
+
self,
|
|
7
|
+
{ :name => role_name, :resource => resource },
|
|
8
|
+
strict
|
|
9
|
+
)
|
|
5
10
|
end
|
|
6
11
|
|
|
7
12
|
def without_role(role_name, resource = nil)
|
data/lib/rolify/resource.rb
CHANGED
data/lib/rolify/role.rb
CHANGED
data/lib/rolify/version.rb
CHANGED
data/lib/rolify.rb
CHANGED
|
@@ -27,7 +27,7 @@ module Rolify
|
|
|
27
27
|
rolify_options.merge!({ :join_table => self.role_join_table_name }) if Rolify.orm == "active_record"
|
|
28
28
|
rolify_options.merge!(options.reject{ |k,v| ![ :before_add, :after_add, :before_remove, :after_remove, :inverse_of ].include? k.to_sym })
|
|
29
29
|
|
|
30
|
-
has_and_belongs_to_many :roles, rolify_options
|
|
30
|
+
has_and_belongs_to_many :roles, **rolify_options
|
|
31
31
|
|
|
32
32
|
self.adapter = Rolify::Adapter::Base.create("role_adapter", self.role_cname, self.name)
|
|
33
33
|
|
|
@@ -48,7 +48,7 @@ module Rolify
|
|
|
48
48
|
self.role_cname = options[:role_cname]
|
|
49
49
|
self.role_table_name = self.role_cname.tableize.gsub(/\//, "_")
|
|
50
50
|
|
|
51
|
-
has_many association_name, resourcify_options
|
|
51
|
+
has_many association_name, **resourcify_options
|
|
52
52
|
|
|
53
53
|
self.resource_adapter = Rolify::Adapter::Base.create("resource_adapter", self.role_cname, self.name)
|
|
54
54
|
@@resource_types << self.name
|
data/rolify.gemspec
CHANGED
|
@@ -9,7 +9,6 @@ Gem::Specification.new do |s|
|
|
|
9
9
|
s.version = Rolify::VERSION
|
|
10
10
|
s.platform = Gem::Platform::RUBY
|
|
11
11
|
s.homepage = 'https://github.com/RolifyCommunity/rolify'
|
|
12
|
-
s.rubyforge_project = s.name
|
|
13
12
|
|
|
14
13
|
s.license = 'MIT'
|
|
15
14
|
|
|
@@ -27,8 +26,11 @@ Gem::Specification.new do |s|
|
|
|
27
26
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
28
27
|
s.require_paths = ['lib']
|
|
29
28
|
|
|
29
|
+
s.required_ruby_version = '>= 2.5'
|
|
30
|
+
|
|
30
31
|
s.add_development_dependency 'ammeter', '~> 1.1' # Spec generator
|
|
31
|
-
s.add_development_dependency '
|
|
32
|
-
s.add_development_dependency '
|
|
33
|
-
s.add_development_dependency '
|
|
32
|
+
s.add_development_dependency 'appraisal', '~> 2.0'
|
|
33
|
+
s.add_development_dependency 'bundler', '~> 2.0' # packaging feature
|
|
34
|
+
s.add_development_dependency 'rake', '~> 12.3' # Tasks manager
|
|
35
|
+
s.add_development_dependency 'rspec-rails', '~> 3.8'
|
|
34
36
|
end
|
|
@@ -71,6 +71,7 @@ describe Rolify::Generators::RolifyGenerator, :if => ENV['ADAPTER'] == 'active_r
|
|
|
71
71
|
it { should contain "validates :resource_type,\n"
|
|
72
72
|
" :inclusion => { :in => Rolify.resource_types },\n"
|
|
73
73
|
" :allow_nil => true" }
|
|
74
|
+
it { should contain "scopify" }
|
|
74
75
|
end
|
|
75
76
|
|
|
76
77
|
describe 'app/models/user.rb' do
|
|
@@ -240,6 +241,13 @@ describe Rolify::Generators::RolifyGenerator, :if => ENV['ADAPTER'] == 'active_r
|
|
|
240
241
|
it { should be_a_migration }
|
|
241
242
|
it { should contain "create_table(:admin_roles)" }
|
|
242
243
|
it { should contain "create_table(:admin_users_admin_roles, :id => false) do" }
|
|
244
|
+
it do
|
|
245
|
+
if Rails::VERSION::MAJOR < 5
|
|
246
|
+
should contain "< ActiveRecord::Migration"
|
|
247
|
+
else
|
|
248
|
+
should contain "< ActiveRecord::Migration[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
|
249
|
+
end
|
|
250
|
+
end
|
|
243
251
|
|
|
244
252
|
context 'mysql2' do
|
|
245
253
|
let(:adapter) { 'Mysql2Adapter' }
|
|
@@ -4,47 +4,65 @@ shared_examples_for :finders do |param_name, param_method|
|
|
|
4
4
|
it { should respond_to(:with_role).with(1).argument }
|
|
5
5
|
it { should respond_to(:with_role).with(2).arguments }
|
|
6
6
|
|
|
7
|
-
context "
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
context "with a class scoped role" do
|
|
14
|
-
context "on Forum class" do
|
|
15
|
-
it { subject.with_role("admin".send(param_method), Forum).should eq([ root ]) }
|
|
16
|
-
it { subject.with_role("moderator".send(param_method), Forum).should eq([ modo ]) }
|
|
17
|
-
it { subject.with_role("visitor".send(param_method), Forum).should be_empty }
|
|
7
|
+
context "when resource setting: strict is set to false" do
|
|
8
|
+
context "with a global role" do
|
|
9
|
+
it { subject.with_role("admin".send(param_method)).should eq([ root ]) }
|
|
10
|
+
it { subject.with_role("moderator".send(param_method)).should be_empty }
|
|
11
|
+
it { subject.with_role("visitor".send(param_method)).should be_empty }
|
|
18
12
|
end
|
|
19
13
|
|
|
20
|
-
context "
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
context "with a class scoped role" do
|
|
15
|
+
context "on Forum class" do
|
|
16
|
+
it { subject.with_role("admin".send(param_method), Forum).should eq([ root ]) }
|
|
17
|
+
it { subject.with_role("moderator".send(param_method), Forum).should eq([ modo ]) }
|
|
18
|
+
it { subject.with_role("visitor".send(param_method), Forum).should be_empty }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "on Group class" do
|
|
22
|
+
it { subject.with_role("admin".send(param_method), Group).should eq([ root ]) }
|
|
23
|
+
it { subject.with_role("moderator".send(param_method), Group).should eq([ root ]) }
|
|
24
|
+
it { subject.with_role("visitor".send(param_method), Group).should be_empty }
|
|
25
|
+
end
|
|
24
26
|
end
|
|
25
|
-
end
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
context "with an instance scoped role" do
|
|
29
|
+
context "on Forum.first instance" do
|
|
30
|
+
it { subject.with_role("admin".send(param_method), Forum.first).should eq([ root ]) }
|
|
31
|
+
it { subject.with_role("moderator".send(param_method), Forum.first).should eq([ modo ]) }
|
|
32
|
+
it { subject.with_role("visitor".send(param_method), Forum.first).should be_empty }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
context "on Forum.last instance" do
|
|
36
|
+
it { subject.with_role("admin".send(param_method), Forum.last).should eq([ root ]) }
|
|
37
|
+
it { subject.with_role("moderator".send(param_method), Forum.last).should eq([ modo ]) }
|
|
38
|
+
it { subject.with_role("visitor".send(param_method), Forum.last).should include(root, visitor) } # =~ doesn't pass using mongoid, don't know why...
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
context "on Group.first instance" do
|
|
42
|
+
it { subject.with_role("admin".send(param_method), Group.first).should eq([ root ]) }
|
|
43
|
+
it { subject.with_role("moderator".send(param_method), Group.first).should eq([ root ]) }
|
|
44
|
+
it { subject.with_role("visitor".send(param_method), Group.first).should eq([ modo ]) }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context "on Company.first_instance" do
|
|
48
|
+
it { subject.with_role("owner".send(param_method), Company.first).should eq([ owner ]) }
|
|
49
|
+
end
|
|
32
50
|
end
|
|
51
|
+
end
|
|
33
52
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
it { subject.with_role("visitor".send(param_method), Forum.last).should include(root, visitor) } # =~ doesn't pass using mongoid, don't know why...
|
|
53
|
+
context "when resource setting: strict is set to true" do
|
|
54
|
+
before(:context) do
|
|
55
|
+
user_class.strict_rolify = true
|
|
38
56
|
end
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
it { subject.with_role("admin".send(param_method), Group.first).should eq([ root ]) }
|
|
42
|
-
it { subject.with_role("moderator".send(param_method), Group.first).should eq([ root ]) }
|
|
43
|
-
it { subject.with_role("visitor".send(param_method), Group.first).should eq([ modo ]) }
|
|
57
|
+
after(:context) do
|
|
58
|
+
user_class.strict_rolify = false
|
|
44
59
|
end
|
|
45
60
|
|
|
46
|
-
context "
|
|
47
|
-
|
|
61
|
+
context "with an instance scoped role" do
|
|
62
|
+
context "on Forum.first instance" do
|
|
63
|
+
it { subject.with_role("admin".send(param_method), Forum.first).should be_empty }
|
|
64
|
+
it { subject.with_role("moderator".send(param_method), Forum.first).should be_empty }
|
|
65
|
+
end
|
|
48
66
|
end
|
|
49
67
|
end
|
|
50
68
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Rolify::Utils do
|
|
4
|
+
class Harness
|
|
5
|
+
extend Rolify::Utils
|
|
6
|
+
define_method(:new_method) { |*_args| true }
|
|
7
|
+
deprecate :old_method, :new_method
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
let(:harness) { Harness.new }
|
|
11
|
+
|
|
12
|
+
context '#deprecate' do
|
|
13
|
+
it 'calls new method with same arguments' do
|
|
14
|
+
expect(harness).to receive(:warn).once
|
|
15
|
+
expect(harness).to receive(:new_method).once.with(1, 2, 3)
|
|
16
|
+
harness.old_method(1, 2, 3)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
metadata
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rolify
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 6.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florent Monbillard
|
|
8
8
|
- Wellington Cordeiro
|
|
9
|
-
autorequire:
|
|
9
|
+
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2021-04-25 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: ammeter
|
|
@@ -25,48 +25,62 @@ dependencies:
|
|
|
25
25
|
- - "~>"
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
27
|
version: '1.1'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: appraisal
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - "~>"
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '2.0'
|
|
35
|
+
type: :development
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - "~>"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '2.0'
|
|
28
42
|
- !ruby/object:Gem::Dependency
|
|
29
43
|
name: bundler
|
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
|
31
45
|
requirements:
|
|
32
46
|
- - "~>"
|
|
33
47
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: '
|
|
48
|
+
version: '2.0'
|
|
35
49
|
type: :development
|
|
36
50
|
prerelease: false
|
|
37
51
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
52
|
requirements:
|
|
39
53
|
- - "~>"
|
|
40
54
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: '
|
|
55
|
+
version: '2.0'
|
|
42
56
|
- !ruby/object:Gem::Dependency
|
|
43
57
|
name: rake
|
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
|
45
59
|
requirements:
|
|
46
60
|
- - "~>"
|
|
47
61
|
- !ruby/object:Gem::Version
|
|
48
|
-
version: '
|
|
62
|
+
version: '12.3'
|
|
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: '
|
|
69
|
+
version: '12.3'
|
|
56
70
|
- !ruby/object:Gem::Dependency
|
|
57
71
|
name: rspec-rails
|
|
58
72
|
requirement: !ruby/object:Gem::Requirement
|
|
59
73
|
requirements:
|
|
60
74
|
- - "~>"
|
|
61
75
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: '3.
|
|
76
|
+
version: '3.8'
|
|
63
77
|
type: :development
|
|
64
78
|
prerelease: false
|
|
65
79
|
version_requirements: !ruby/object:Gem::Requirement
|
|
66
80
|
requirements:
|
|
67
81
|
- - "~>"
|
|
68
82
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: '3.
|
|
83
|
+
version: '3.8'
|
|
70
84
|
description: Very simple Roles library without any authorization enforcement supporting
|
|
71
85
|
scope on resource objects (instance or class). Supports ActiveRecord and Mongoid
|
|
72
86
|
ORMs.
|
|
@@ -77,8 +91,10 @@ executables: []
|
|
|
77
91
|
extensions: []
|
|
78
92
|
extra_rdoc_files: []
|
|
79
93
|
files:
|
|
94
|
+
- ".github/workflows/activerecord.yml"
|
|
95
|
+
- ".github/workflows/mongoid.yml"
|
|
80
96
|
- ".gitignore"
|
|
81
|
-
- ".
|
|
97
|
+
- ".hakiri.yml"
|
|
82
98
|
- Appraisals
|
|
83
99
|
- CHANGELOG.rdoc
|
|
84
100
|
- CONTRIBUTORS
|
|
@@ -87,15 +103,12 @@ files:
|
|
|
87
103
|
- README.md
|
|
88
104
|
- Rakefile
|
|
89
105
|
- UPGRADE.rdoc
|
|
90
|
-
- gemfiles/Gemfile.rails-3.2
|
|
91
|
-
- gemfiles/Gemfile.rails-4.0
|
|
92
|
-
- gemfiles/Gemfile.rails-4.1
|
|
93
|
-
- gemfiles/activerecord_3.gemfile
|
|
94
106
|
- gemfiles/activerecord_4.gemfile
|
|
95
107
|
- gemfiles/activerecord_5.gemfile
|
|
96
|
-
- gemfiles/
|
|
97
|
-
- gemfiles/mongoid_4.gemfile
|
|
108
|
+
- gemfiles/activerecord_6.gemfile
|
|
98
109
|
- gemfiles/mongoid_5.gemfile
|
|
110
|
+
- gemfiles/mongoid_6.gemfile
|
|
111
|
+
- gemfiles/mongoid_7.gemfile
|
|
99
112
|
- lib/generators/active_record/rolify_generator.rb
|
|
100
113
|
- lib/generators/active_record/templates/README
|
|
101
114
|
- lib/generators/active_record/templates/migration.rb
|
|
@@ -153,12 +166,13 @@ files:
|
|
|
153
166
|
- spec/rolify/shared_examples/shared_examples_for_remove_role.rb
|
|
154
167
|
- spec/rolify/shared_examples/shared_examples_for_roles.rb
|
|
155
168
|
- spec/rolify/shared_examples/shared_examples_for_scopes.rb
|
|
169
|
+
- spec/rolify/utils_spec.rb
|
|
156
170
|
- spec/spec_helper.rb
|
|
157
171
|
- spec/support/adapters/active_record.rb
|
|
158
172
|
- spec/support/adapters/mongoid.rb
|
|
159
|
-
- spec/support/adapters/mongoid_3.yml
|
|
160
|
-
- spec/support/adapters/mongoid_4.yml
|
|
161
173
|
- spec/support/adapters/mongoid_5.yml
|
|
174
|
+
- spec/support/adapters/mongoid_6.yml
|
|
175
|
+
- spec/support/adapters/mongoid_7.yml
|
|
162
176
|
- spec/support/adapters/utils/active_record.rb
|
|
163
177
|
- spec/support/adapters/utils/mongoid.rb
|
|
164
178
|
- spec/support/data.rb
|
|
@@ -168,7 +182,7 @@ homepage: https://github.com/RolifyCommunity/rolify
|
|
|
168
182
|
licenses:
|
|
169
183
|
- MIT
|
|
170
184
|
metadata: {}
|
|
171
|
-
post_install_message:
|
|
185
|
+
post_install_message:
|
|
172
186
|
rdoc_options: []
|
|
173
187
|
require_paths:
|
|
174
188
|
- lib
|
|
@@ -176,16 +190,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
176
190
|
requirements:
|
|
177
191
|
- - ">="
|
|
178
192
|
- !ruby/object:Gem::Version
|
|
179
|
-
version: '
|
|
193
|
+
version: '2.5'
|
|
180
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
195
|
requirements:
|
|
182
196
|
- - ">="
|
|
183
197
|
- !ruby/object:Gem::Version
|
|
184
198
|
version: '0'
|
|
185
199
|
requirements: []
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
signing_key:
|
|
200
|
+
rubygems_version: 3.2.15
|
|
201
|
+
signing_key:
|
|
189
202
|
specification_version: 4
|
|
190
203
|
summary: Roles library with resource scoping
|
|
191
204
|
test_files:
|
|
@@ -216,12 +229,13 @@ test_files:
|
|
|
216
229
|
- spec/rolify/shared_examples/shared_examples_for_remove_role.rb
|
|
217
230
|
- spec/rolify/shared_examples/shared_examples_for_roles.rb
|
|
218
231
|
- spec/rolify/shared_examples/shared_examples_for_scopes.rb
|
|
232
|
+
- spec/rolify/utils_spec.rb
|
|
219
233
|
- spec/spec_helper.rb
|
|
220
234
|
- spec/support/adapters/active_record.rb
|
|
221
235
|
- spec/support/adapters/mongoid.rb
|
|
222
|
-
- spec/support/adapters/mongoid_3.yml
|
|
223
|
-
- spec/support/adapters/mongoid_4.yml
|
|
224
236
|
- spec/support/adapters/mongoid_5.yml
|
|
237
|
+
- spec/support/adapters/mongoid_6.yml
|
|
238
|
+
- spec/support/adapters/mongoid_7.yml
|
|
225
239
|
- spec/support/adapters/utils/active_record.rb
|
|
226
240
|
- spec/support/adapters/utils/mongoid.rb
|
|
227
241
|
- spec/support/data.rb
|
data/.travis.yml
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
sudo: false
|
|
3
|
-
|
|
4
|
-
before_install:
|
|
5
|
-
- gem update --system
|
|
6
|
-
- gem install bundler
|
|
7
|
-
- gem --version
|
|
8
|
-
|
|
9
|
-
script: bundle exec rake
|
|
10
|
-
|
|
11
|
-
after_success:
|
|
12
|
-
- bundle exec codeclimate-test-reporter
|
|
13
|
-
|
|
14
|
-
matrix:
|
|
15
|
-
include:
|
|
16
|
-
- rvm: 2.3.0
|
|
17
|
-
gemfile: gemfiles/activerecord_3.gemfile
|
|
18
|
-
env: ADAPTER=active_record
|
|
19
|
-
- rvm: 2.2.4
|
|
20
|
-
gemfile: gemfiles/activerecord_3.gemfile
|
|
21
|
-
env: ADAPTER=active_record
|
|
22
|
-
- rvm: 2.1.8
|
|
23
|
-
gemfile: gemfiles/activerecord_3.gemfile
|
|
24
|
-
env: ADAPTER=active_record
|
|
25
|
-
- rvm: 2.0.0
|
|
26
|
-
gemfile: gemfiles/activerecord_3.gemfile
|
|
27
|
-
env: ADAPTER=active_record
|
|
28
|
-
|
|
29
|
-
- rvm: 2.3.0
|
|
30
|
-
gemfile: gemfiles/activerecord_4.gemfile
|
|
31
|
-
env: ADAPTER=active_record
|
|
32
|
-
- rvm: 2.2.4
|
|
33
|
-
gemfile: gemfiles/activerecord_4.gemfile
|
|
34
|
-
env: ADAPTER=active_record
|
|
35
|
-
- rvm: 2.1.8
|
|
36
|
-
gemfile: gemfiles/activerecord_4.gemfile
|
|
37
|
-
env: ADAPTER=active_record
|
|
38
|
-
- rvm: 2.0.0
|
|
39
|
-
gemfile: gemfiles/activerecord_4.gemfile
|
|
40
|
-
env: ADAPTER=active_record
|
|
41
|
-
|
|
42
|
-
- rvm: 2.3.0
|
|
43
|
-
gemfile: gemfiles/activerecord_5.gemfile
|
|
44
|
-
env: ADAPTER=active_record
|
|
45
|
-
- rvm: 2.2.4
|
|
46
|
-
gemfile: gemfiles/activerecord_5.gemfile
|
|
47
|
-
env: ADAPTER=active_record
|
|
48
|
-
|
|
49
|
-
- rvm: 2.3.0
|
|
50
|
-
gemfile: gemfiles/mongoid_3.gemfile
|
|
51
|
-
env: ADAPTER=mongoid
|
|
52
|
-
- rvm: 2.2.4
|
|
53
|
-
gemfile: gemfiles/mongoid_3.gemfile
|
|
54
|
-
env: ADAPTER=mongoid
|
|
55
|
-
- rvm: 2.1.8
|
|
56
|
-
gemfile: gemfiles/mongoid_3.gemfile
|
|
57
|
-
env: ADAPTER=mongoid
|
|
58
|
-
- rvm: 2.0.0
|
|
59
|
-
gemfile: gemfiles/mongoid_3.gemfile
|
|
60
|
-
env: ADAPTER=mongoid
|
|
61
|
-
|
|
62
|
-
- rvm: 2.3.0
|
|
63
|
-
gemfile: gemfiles/mongoid_4.gemfile
|
|
64
|
-
env: ADAPTER=mongoid
|
|
65
|
-
- rvm: 2.2.4
|
|
66
|
-
gemfile: gemfiles/mongoid_4.gemfile
|
|
67
|
-
env: ADAPTER=mongoid
|
|
68
|
-
- rvm: 2.1.8
|
|
69
|
-
gemfile: gemfiles/mongoid_4.gemfile
|
|
70
|
-
env: ADAPTER=mongoid
|
|
71
|
-
- rvm: 2.0.0
|
|
72
|
-
gemfile: gemfiles/mongoid_4.gemfile
|
|
73
|
-
env: ADAPTER=mongoid
|
|
74
|
-
|
|
75
|
-
- rvm: 2.3.0
|
|
76
|
-
gemfile: gemfiles/mongoid_5.gemfile
|
|
77
|
-
env: ADAPTER=mongoid
|
|
78
|
-
- rvm: 2.2.4
|
|
79
|
-
gemfile: gemfiles/mongoid_5.gemfile
|
|
80
|
-
env: ADAPTER=mongoid
|
|
81
|
-
- rvm: 2.1.8
|
|
82
|
-
gemfile: gemfiles/mongoid_5.gemfile
|
|
83
|
-
env: ADAPTER=mongoid
|
|
84
|
-
- rvm: 2.0.0
|
|
85
|
-
gemfile: gemfiles/mongoid_5.gemfile
|
|
86
|
-
env: ADAPTER=mongoid
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
services: mongodb
|
|
90
|
-
|
|
91
|
-
addons:
|
|
92
|
-
code_climate:
|
|
93
|
-
repo_token: 6bd8d374b120a5449b9a4b7dfda40cc0609dbade48a1b6655f04a9bc8de3a3ee
|
data/gemfiles/Gemfile.rails-3.2
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
platforms :rbx do
|
|
4
|
-
gem 'psych'
|
|
5
|
-
gem 'rubinius-coverage', '~> 2.0'
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
group :test do
|
|
9
|
-
gem 'railties', '~> 3.2', '< 4.0'
|
|
10
|
-
case ENV['ADAPTER']
|
|
11
|
-
when nil, 'active_record'
|
|
12
|
-
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0.rc', :platform => 'jruby'
|
|
13
|
-
#Fix sqlite3 version for rbx until rubinus is updated
|
|
14
|
-
#https://github.com/travis-ci/travis-ci/issues/2006
|
|
15
|
-
gem 'sqlite3', '1.3.8', :platform => 'ruby'
|
|
16
|
-
gem 'activerecord', '~> 3.2.0', :require => 'active_record'
|
|
17
|
-
when 'mongoid'
|
|
18
|
-
gem 'mongoid', '>= 3.1'
|
|
19
|
-
gem 'bson_ext', :platform => 'ruby'
|
|
20
|
-
else
|
|
21
|
-
raise "Unknown model adapter: #{ENV['ADAPTER']}"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
gem 'coveralls', :require => false
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
gemspec :path => '../'
|
data/gemfiles/Gemfile.rails-4.0
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
platforms :rbx do
|
|
4
|
-
gem 'psych'
|
|
5
|
-
gem 'rubinius-coverage', '~> 2.0'
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
group :test do
|
|
9
|
-
gem 'railties', '~> 4.0.1', '< 4.1'
|
|
10
|
-
gem 'ammeter'
|
|
11
|
-
gem 'rake'
|
|
12
|
-
gem 'rspec'
|
|
13
|
-
gem 'its'
|
|
14
|
-
gem 'rspec-rails'
|
|
15
|
-
gem 'fuubar'
|
|
16
|
-
gem 'bundler'
|
|
17
|
-
|
|
18
|
-
gem 'coveralls', :require => false
|
|
19
|
-
|
|
20
|
-
case ENV['ADAPTER']
|
|
21
|
-
when nil, 'active_record'
|
|
22
|
-
gem 'activerecord', '~> 4.0.1', :require => 'active_record'
|
|
23
|
-
gem 'activerecord-jdbcsqlite3-adapter', '~> 1.3.5', :platform => 'jruby'
|
|
24
|
-
#Fix sqlite3 version for rbx until rubinus is updated
|
|
25
|
-
#https://github.com/travis-ci/travis-ci/issues/2006
|
|
26
|
-
gem 'sqlite3', '1.3.8', :platform => 'ruby'
|
|
27
|
-
when 'mongoid'
|
|
28
|
-
gem 'mongoid', github: 'mongoid/mongoid'
|
|
29
|
-
gem 'bson_ext', :platform => 'ruby'
|
|
30
|
-
else
|
|
31
|
-
raise "Unknown model adapter: #{ENV['ADAPTER']}"
|
|
32
|
-
end
|
|
33
|
-
end
|
data/gemfiles/Gemfile.rails-4.1
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
platforms :rbx do
|
|
4
|
-
gem 'psych'
|
|
5
|
-
gem 'rubinius-coverage', '~> 2.0'
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
group :test do
|
|
9
|
-
gem 'rails', github: 'rails/rails', branch: '4-1-stable'
|
|
10
|
-
# There is currently an active record bug in Rails 4.1.0, this is a workaround until 4.1.1 is released
|
|
11
|
-
# See https://github.com/rails/rails/issues/13648
|
|
12
|
-
# Without this patch, Resource.with_role(:role, User.first).count throws an SQL syntax exception
|
|
13
|
-
#gem 'railties', '~> 4.1.0'
|
|
14
|
-
gem 'ammeter'
|
|
15
|
-
gem 'rake'
|
|
16
|
-
gem 'rspec'
|
|
17
|
-
gem 'its'
|
|
18
|
-
gem 'rspec-rails'
|
|
19
|
-
gem 'fuubar'
|
|
20
|
-
gem 'bundler'
|
|
21
|
-
|
|
22
|
-
gem 'coveralls', :require => false
|
|
23
|
-
|
|
24
|
-
case ENV['ADAPTER']
|
|
25
|
-
when nil, 'active_record'
|
|
26
|
-
gem 'activerecord', '~> 4.1.0', :require => 'active_record'
|
|
27
|
-
gem 'activerecord-jdbcsqlite3-adapter', '~> 1.3.5', :platform => 'jruby'
|
|
28
|
-
#Fix sqlite3 version for rbx until rubinus is updated
|
|
29
|
-
#https://github.com/travis-ci/travis-ci/issues/2006
|
|
30
|
-
gem 'sqlite3', '1.3.8', :platform => 'ruby'
|
|
31
|
-
when 'mongoid'
|
|
32
|
-
gem 'mongoid', github: 'mongoid/mongoid'
|
|
33
|
-
gem 'bson_ext', :platform => 'ruby'
|
|
34
|
-
else
|
|
35
|
-
raise "Unknown model adapter: #{ENV['ADAPTER']}"
|
|
36
|
-
end
|
|
37
|
-
end
|