rolify 5.3.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/activerecord.yml +27 -0
- data/.github/workflows/mongoid.yml +32 -0
- data/Appraisals +0 -12
- data/CHANGELOG.rdoc +11 -0
- data/Gemfile +7 -7
- data/Rakefile +1 -1
- data/gemfiles/activerecord_4.gemfile +5 -6
- data/gemfiles/activerecord_5.gemfile +5 -11
- data/gemfiles/activerecord_6.gemfile +5 -11
- data/gemfiles/mongoid_5.gemfile +5 -6
- data/gemfiles/mongoid_6.gemfile +5 -6
- data/gemfiles/mongoid_7.gemfile +5 -6
- data/lib/rolify/adapters/active_record/resource_adapter.rb +1 -1
- data/lib/rolify/adapters/active_record/role_adapter.rb +16 -10
- 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/version.rb +1 -1
- data/rolify.gemspec +2 -1
- data/spec/rolify/shared_examples/shared_examples_for_finders.rb +50 -32
- metadata +23 -8
- data/.travis.yml +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
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/Appraisals
CHANGED
@@ -29,12 +29,6 @@ appraise 'activerecord-5' do
|
|
29
29
|
gem "actionpack", "~> 5.2.4"
|
30
30
|
gem "activemodel", "~> 5.2.4"
|
31
31
|
gem "railties", "~> 5.2.4"
|
32
|
-
|
33
|
-
gem 'rspec-rails' , github: 'rspec/rspec-rails'
|
34
|
-
gem 'rspec-core' , github: 'rspec/rspec-core'
|
35
|
-
gem 'rspec-expectations', github: 'rspec/rspec-expectations'
|
36
|
-
gem 'rspec-mocks' , github: 'rspec/rspec-mocks'
|
37
|
-
gem 'rspec-support' , github: 'rspec/rspec-support'
|
38
32
|
end
|
39
33
|
|
40
34
|
appraise 'activerecord-6' do
|
@@ -45,10 +39,4 @@ appraise 'activerecord-6' do
|
|
45
39
|
gem "actionpack", ">= 6.0.0"
|
46
40
|
gem "activemodel", ">= 6.0.0"
|
47
41
|
gem "railties", ">= 6.0.0"
|
48
|
-
|
49
|
-
gem 'rspec-rails' , github: 'rspec/rspec-rails'
|
50
|
-
gem 'rspec-core' , github: 'rspec/rspec-core'
|
51
|
-
gem 'rspec-expectations', github: 'rspec/rspec-expectations'
|
52
|
-
gem 'rspec-mocks' , github: 'rspec/rspec-mocks'
|
53
|
-
gem 'rspec-support' , github: 'rspec/rspec-support'
|
54
42
|
end
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,14 @@
|
|
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
|
+
|
1
12
|
= 5.3.0 (June 1, 2020)
|
2
13
|
|
3
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.
|
data/Gemfile
CHANGED
@@ -1,15 +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'
|
7
|
-
gem 'pry', '< 0.13.0' # pry pins can be removed when we drop Ruby 2.3
|
8
|
-
gem 'byebug'
|
9
|
-
gem 'pry-byebug', '< 3.8.0'
|
10
8
|
gem 'test-unit' # Implicitly loaded by ammeter
|
11
|
-
|
12
|
-
gem '
|
9
|
+
|
10
|
+
gem 'byebug'
|
11
|
+
gem 'pry'
|
12
|
+
gem 'pry-byebug'
|
13
13
|
end
|
14
14
|
|
15
15
|
gemspec
|
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ RSpec::Core::RakeTask.new(:rolify) do |task|
|
|
15
15
|
task.pattern = 'spec/rolify/**/*_spec.rb'
|
16
16
|
end
|
17
17
|
|
18
|
-
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["
|
18
|
+
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["CI"]
|
19
19
|
task :default => :appraisal
|
20
20
|
else
|
21
21
|
task :default => [ :spec, 'coveralls:push' ]
|
@@ -7,15 +7,14 @@ gem "activerecord", "~> 4.2.11", require: "active_record"
|
|
7
7
|
gem "bigdecimal", "1.4.2"
|
8
8
|
|
9
9
|
group :test do
|
10
|
-
gem "
|
10
|
+
gem "codeclimate-test-reporter", require: nil
|
11
11
|
gem "coveralls", require: false
|
12
|
+
gem "database_cleaner", "~> 1.6.2"
|
12
13
|
gem "its"
|
13
|
-
gem "pry", "< 0.13.0"
|
14
|
-
gem "byebug"
|
15
|
-
gem "pry-byebug", "< 3.8.0"
|
16
14
|
gem "test-unit"
|
17
|
-
gem "
|
18
|
-
gem "
|
15
|
+
gem "byebug"
|
16
|
+
gem "pry"
|
17
|
+
gem "pry-byebug"
|
19
18
|
end
|
20
19
|
|
21
20
|
gemspec path: "../"
|
@@ -7,22 +7,16 @@ gem "activerecord", "~> 5.2.4", require: "active_record"
|
|
7
7
|
gem "actionpack", "~> 5.2.4"
|
8
8
|
gem "activemodel", "~> 5.2.4"
|
9
9
|
gem "railties", "~> 5.2.4"
|
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"
|
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"
|
20
|
-
gem "pry", "< 0.13.0"
|
21
|
-
gem "byebug"
|
22
|
-
gem "pry-byebug", "< 3.8.0"
|
23
16
|
gem "test-unit"
|
24
|
-
gem "
|
25
|
-
gem "
|
17
|
+
gem "byebug"
|
18
|
+
gem "pry"
|
19
|
+
gem "pry-byebug"
|
26
20
|
end
|
27
21
|
|
28
22
|
gemspec path: "../"
|
@@ -7,22 +7,16 @@ gem "activerecord", ">= 6.0.0", require: "active_record"
|
|
7
7
|
gem "actionpack", ">= 6.0.0"
|
8
8
|
gem "activemodel", ">= 6.0.0"
|
9
9
|
gem "railties", ">= 6.0.0"
|
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"
|
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"
|
20
|
-
gem "pry", "< 0.13.0"
|
21
|
-
gem "byebug"
|
22
|
-
gem "pry-byebug", "< 3.8.0"
|
23
16
|
gem "test-unit"
|
24
|
-
gem "
|
25
|
-
gem "
|
17
|
+
gem "byebug"
|
18
|
+
gem "pry"
|
19
|
+
gem "pry-byebug"
|
26
20
|
end
|
27
21
|
|
28
22
|
gemspec path: "../"
|
data/gemfiles/mongoid_5.gemfile
CHANGED
@@ -7,15 +7,14 @@ gem "bson_ext", "1.5.1"
|
|
7
7
|
gem "bigdecimal", "1.4.2"
|
8
8
|
|
9
9
|
group :test do
|
10
|
-
gem "
|
10
|
+
gem "codeclimate-test-reporter", require: nil
|
11
11
|
gem "coveralls", require: false
|
12
|
+
gem "database_cleaner", "~> 1.6.2"
|
12
13
|
gem "its"
|
13
|
-
gem "pry", "< 0.13.0"
|
14
|
-
gem "byebug"
|
15
|
-
gem "pry-byebug", "< 3.8.0"
|
16
14
|
gem "test-unit"
|
17
|
-
gem "
|
18
|
-
gem "
|
15
|
+
gem "byebug"
|
16
|
+
gem "pry"
|
17
|
+
gem "pry-byebug"
|
19
18
|
end
|
20
19
|
|
21
20
|
gemspec path: "../"
|
data/gemfiles/mongoid_6.gemfile
CHANGED
@@ -6,15 +6,14 @@ gem "mongoid", "~> 6"
|
|
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"
|
12
|
-
gem "pry", "< 0.13.0"
|
13
|
-
gem "byebug"
|
14
|
-
gem "pry-byebug", "< 3.8.0"
|
15
13
|
gem "test-unit"
|
16
|
-
gem "
|
17
|
-
gem "
|
14
|
+
gem "byebug"
|
15
|
+
gem "pry"
|
16
|
+
gem "pry-byebug"
|
18
17
|
end
|
19
18
|
|
20
19
|
gemspec path: "../"
|
data/gemfiles/mongoid_7.gemfile
CHANGED
@@ -7,15 +7,14 @@ gem "bson_ext", "1.5.1"
|
|
7
7
|
gem "railties", "5.2.4.1"
|
8
8
|
|
9
9
|
group :test do
|
10
|
-
gem "
|
10
|
+
gem "codeclimate-test-reporter", require: nil
|
11
11
|
gem "coveralls", require: false
|
12
|
+
gem "database_cleaner", "~> 1.6.2"
|
12
13
|
gem "its"
|
13
|
-
gem "pry", "< 0.13.0"
|
14
|
-
gem "byebug"
|
15
|
-
gem "pry-byebug", "< 3.8.0"
|
16
14
|
gem "test-unit"
|
17
|
-
gem "
|
18
|
-
gem "
|
15
|
+
gem "byebug"
|
16
|
+
gem "pry"
|
17
|
+
gem "pry-byebug"
|
19
18
|
end
|
20
19
|
|
21
20
|
gemspec path: "../"
|
@@ -26,7 +26,7 @@ module Rolify
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def in(relation, user, role_names)
|
29
|
-
roles = user.roles.where(:name => role_names).select("#{quote_table(role_class.table_name)}.#{quote_column(role_class.primary_key)}")
|
29
|
+
roles = user.roles.where(:name => role_names).select("#{quote_table(role_class.table_name)}.#{quote_column(role_class.primary_key)}")
|
30
30
|
relation.where("#{quote_table(role_class.table_name)}.#{quote_column(role_class.primary_key)} IN (?) AND ((#{quote_table(role_class.table_name)}.resource_id = #{quote_table(relation.table_name)}.#{quote_column(relation.primary_key)}) OR (#{quote_table(role_class.table_name)}.resource_id IS NULL))", roles)
|
31
31
|
end
|
32
32
|
|
@@ -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)
|
@@ -67,9 +73,9 @@ module Rolify
|
|
67
73
|
relation.where("#{column} IS NOT NULL")
|
68
74
|
end
|
69
75
|
|
70
|
-
def scope(relation, conditions)
|
76
|
+
def scope(relation, conditions, strict)
|
71
77
|
query = relation.joins(:roles)
|
72
|
-
query = where(query, conditions)
|
78
|
+
query = strict ? where_strict(query, conditions) : where(query, conditions)
|
73
79
|
query
|
74
80
|
end
|
75
81
|
|
@@ -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/version.rb
CHANGED
data/rolify.gemspec
CHANGED
@@ -26,9 +26,10 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
27
27
|
s.require_paths = ['lib']
|
28
28
|
|
29
|
-
s.required_ruby_version = '>= 2.
|
29
|
+
s.required_ruby_version = '>= 2.5'
|
30
30
|
|
31
31
|
s.add_development_dependency 'ammeter', '~> 1.1' # Spec generator
|
32
|
+
s.add_development_dependency 'appraisal', '~> 2.0'
|
32
33
|
s.add_development_dependency 'bundler', '~> 2.0' # packaging feature
|
33
34
|
s.add_development_dependency 'rake', '~> 12.3' # Tasks manager
|
34
35
|
s.add_development_dependency 'rspec-rails', '~> 3.8'
|
@@ -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
|
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,6 +25,20 @@ 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
|
@@ -77,9 +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
|
-
- ".travis.yml"
|
83
98
|
- Appraisals
|
84
99
|
- CHANGELOG.rdoc
|
85
100
|
- CONTRIBUTORS
|
@@ -167,7 +182,7 @@ homepage: https://github.com/RolifyCommunity/rolify
|
|
167
182
|
licenses:
|
168
183
|
- MIT
|
169
184
|
metadata: {}
|
170
|
-
post_install_message:
|
185
|
+
post_install_message:
|
171
186
|
rdoc_options: []
|
172
187
|
require_paths:
|
173
188
|
- lib
|
@@ -175,15 +190,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
175
190
|
requirements:
|
176
191
|
- - ">="
|
177
192
|
- !ruby/object:Gem::Version
|
178
|
-
version: '2.
|
193
|
+
version: '2.5'
|
179
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
195
|
requirements:
|
181
196
|
- - ">="
|
182
197
|
- !ruby/object:Gem::Version
|
183
198
|
version: '0'
|
184
199
|
requirements: []
|
185
|
-
rubygems_version: 3.
|
186
|
-
signing_key:
|
200
|
+
rubygems_version: 3.2.15
|
201
|
+
signing_key:
|
187
202
|
specification_version: 4
|
188
203
|
summary: Roles library with resource scoping
|
189
204
|
test_files:
|
data/.travis.yml
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
before_install:
|
4
|
-
- gem update --system
|
5
|
-
- gem install bundler
|
6
|
-
- gem --version
|
7
|
-
|
8
|
-
script: bundle exec rake
|
9
|
-
|
10
|
-
after_success:
|
11
|
-
- bundle exec codeclimate-test-reporter
|
12
|
-
|
13
|
-
rvm:
|
14
|
-
- 2.7.0
|
15
|
-
- 2.6.3
|
16
|
-
- 2.5.5
|
17
|
-
- 2.4.6
|
18
|
-
- 2.3.8
|
19
|
-
|
20
|
-
gemfile:
|
21
|
-
- gemfiles/activerecord_4.gemfile
|
22
|
-
- gemfiles/activerecord_5.gemfile
|
23
|
-
- gemfiles/activerecord_6.gemfile
|
24
|
-
- gemfiles/mongoid_5.gemfile
|
25
|
-
- gemfiles/mongoid_6.gemfile
|
26
|
-
- gemfiles/mongoid_7.gemfile
|
27
|
-
|
28
|
-
env:
|
29
|
-
- ADAPTER=active_record
|
30
|
-
- ADAPTER=mongoid
|
31
|
-
|
32
|
-
matrix:
|
33
|
-
exclude:
|
34
|
-
- gemfile: gemfiles/activerecord_4.gemfile
|
35
|
-
env: ADAPTER=mongoid
|
36
|
-
- gemfile: gemfiles/activerecord_5.gemfile
|
37
|
-
env: ADAPTER=mongoid
|
38
|
-
- gemfile: gemfiles/activerecord_6.gemfile
|
39
|
-
env: ADAPTER=mongoid
|
40
|
-
- gemfile: gemfiles/activerecord_6.gemfile
|
41
|
-
rvm: 2.4.6
|
42
|
-
- gemfile: gemfiles/activerecord_6.gemfile
|
43
|
-
rvm: 2.3.8
|
44
|
-
- gemfile: gemfiles/mongoid_5.gemfile
|
45
|
-
env: ADAPTER=active_record
|
46
|
-
- gemfile: gemfiles/mongoid_6.gemfile
|
47
|
-
env: ADAPTER=active_record
|
48
|
-
- gemfile: gemfiles/mongoid_7.gemfile
|
49
|
-
env: ADAPTER=active_record
|
50
|
-
allow_failures:
|
51
|
-
- gemfile: gemfiles/mongoid_6.gemfile
|
52
|
-
- gemfile: gemfiles/mongoid_7.gemfile
|
53
|
-
|
54
|
-
services: mongodb
|
55
|
-
|
56
|
-
addons:
|
57
|
-
code_climate:
|
58
|
-
repo_token: 6bd8d374b120a5449b9a4b7dfda40cc0609dbade48a1b6655f04a9bc8de3a3ee
|