monarchy 2.5.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6a80bd2e8d032b4834201948fb4135eaf256b141
4
- data.tar.gz: 1a61890bfb9ea9ec1d0401d578baad846db6a452
2
+ SHA256:
3
+ metadata.gz: 255ffc319f1777f817bfef1e2e954fdce1093a3896f881e18f86fc1b7f27e583
4
+ data.tar.gz: b1499d2a8a58ee38ed24adda728d3fc2d0a89bca17a7ca167748948f974267a4
5
5
  SHA512:
6
- metadata.gz: 2ee33caaa89899299d26e7d1e84c43c0ac5bfb1b2d050d086c6d40c7874393281ea0d1643d33ac0dcf9fc73c03130bcac9322ef5ddd7afa23254cdb950d97e59
7
- data.tar.gz: 6194f5ea16ba70b1ef9adf245530b770ed071f4719defeb6a5b9fcf63d673c752c910877f3297f7a17d79de5ede614b97654958ee56f239e2d4c5693ff69e8c6
6
+ metadata.gz: 2d2b3568b5c05ec75e5d865fce5c59e396c445078db6593497e5d0754bb3732033c38e99b93b507ec0c368e7c00abef487d295b5df490e3a661e604a233688e8
7
+ data.tar.gz: cabed35ab71fdab6e7d4049c66056feb712a6df5f665a96b9229c37e0d0b5f52a046cacd84e25fce09839cc7d678eea019524534fd0e2386b302344bc44ef0d0
@@ -1 +1 @@
1
- future-release=2.5.0
1
+ future-release=2.6.0
data/.rubocop.yml CHANGED
@@ -1,5 +1,7 @@
1
+ require: rubocop-rspec
2
+
1
3
  AllCops:
2
- TargetRubyVersion: 2.4
4
+ TargetRubyVersion: 2.5
3
5
  Exclude:
4
6
  - 'dummy/db/seeds.rb'
5
7
  - 'dummy/db/migrate/**'
data/.travis.yml CHANGED
@@ -1,9 +1,9 @@
1
- addons:
2
- code_climate:
3
- repo_token: 60b8a9fc7e8d659c7dd22ed8912651c35b3ca5eebf1c23d5470308e6a802abbd
4
1
  language: ruby
5
2
  rvm:
6
- - 2.4.2
7
- before_install: gem update --system
8
- after_success:
9
- - bundle exec codeclimate-test-reporter
3
+ - 2.5.3
4
+ before_script:
5
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
6
+ - chmod +x ./cc-test-reporter
7
+ - ./cc-test-reporter before-build
8
+ after_script:
9
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/CHANGELOG.md CHANGED
@@ -1,7 +1,14 @@
1
1
  # Change Log
2
2
 
3
- ## [2.5.0](https://github.com/Exelord/Monarchy/tree/2.5.0) (2018-03-25)
4
- [Full Changelog](https://github.com/Exelord/Monarchy/compare/v2.4.0...2.5.0)
3
+ ## [2.6.0](https://github.com/Exelord/Monarchy/tree/2.6.0) (2018-12-19)
4
+ [Full Changelog](https://github.com/Exelord/Monarchy/compare/v2.5.0...2.6.0)
5
+
6
+ **Merged pull requests:**
7
+
8
+ - Updates [\#82](https://github.com/Exelord/Monarchy/pull/82) ([Exelord](https://github.com/Exelord))
9
+
10
+ ## [v2.5.0](https://github.com/Exelord/Monarchy/tree/v2.5.0) (2018-03-25)
11
+ [Full Changelog](https://github.com/Exelord/Monarchy/compare/v2.4.0...v2.5.0)
5
12
 
6
13
  **Fixed bugs:**
7
14
 
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  source 'https://rubygems.org'
4
- ruby '2.4.2'
4
+ ruby '2.5.3'
5
5
 
6
6
  # Declare your gem's dependencies in monarchy.gemspec.
7
7
  # Bundler will treat runtime dependencies like base dependencies, and
@@ -17,17 +17,20 @@ gemspec
17
17
  # gem 'byebug', group: [:development, :test]
18
18
 
19
19
  group :development, :test do
20
- gem 'database_cleaner', '1.6.2'
20
+ gem 'bundler', '~> 1.17'
21
+ gem 'database_cleaner', '1.7.0'
21
22
  gem 'db-query-matchers', '0.9.0'
22
- gem 'factory_girl_rails', '4.9.0'
23
- gem 'ffaker', '2.8.1'
24
- gem 'pry-rails', '0.3.6'
25
- gem 'rails', '5.1.5'
26
- gem 'rspec-rails', '3.7.2'
27
- gem 'rubocop', '0.54.0'
23
+ gem 'factory_bot_rails', '4.11.1'
24
+ gem 'ffaker', '2.10.0'
25
+ gem 'pry-rails', '0.3.8'
26
+ gem 'rails', '5.2.2'
27
+ gem 'rake', '~> 12.3.2'
28
+ gem 'rspec', '3.8.0'
29
+ gem 'rspec-rails', '3.8.1'
30
+ gem 'rubocop', '0.61.1'
31
+ gem 'rubocop-rspec', '1.30.1'
28
32
  gem 'shoulda-matchers', '3.1.2'
29
33
  gem 'sqlite3', '1.3.13'
30
34
  end
31
35
 
32
- gem 'codeclimate-test-reporter', '~>1.0.8', group: :test
33
- gem 'simplecov', '0.13.0', group: :test
36
+ gem 'simplecov', '0.16.1', group: :test
data/Gemfile.lock CHANGED
@@ -1,171 +1,181 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- monarchy (2.5.0)
4
+ monarchy (2.6.0)
5
5
  active_record_union (= 1.3.0)
6
6
  activerecord (>= 4.2.7.1)
7
- closure_tree (= 6.6.0)
7
+ closure_tree (= 7.0.0)
8
8
  configurations (= 2.2.2)
9
9
  tqdm (= 0.3.0)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- actioncable (5.1.5)
15
- actionpack (= 5.1.5)
14
+ actioncable (5.2.2)
15
+ actionpack (= 5.2.2)
16
16
  nio4r (~> 2.0)
17
- websocket-driver (~> 0.6.1)
18
- actionmailer (5.1.5)
19
- actionpack (= 5.1.5)
20
- actionview (= 5.1.5)
21
- activejob (= 5.1.5)
17
+ websocket-driver (>= 0.6.1)
18
+ actionmailer (5.2.2)
19
+ actionpack (= 5.2.2)
20
+ actionview (= 5.2.2)
21
+ activejob (= 5.2.2)
22
22
  mail (~> 2.5, >= 2.5.4)
23
23
  rails-dom-testing (~> 2.0)
24
- actionpack (5.1.5)
25
- actionview (= 5.1.5)
26
- activesupport (= 5.1.5)
24
+ actionpack (5.2.2)
25
+ actionview (= 5.2.2)
26
+ activesupport (= 5.2.2)
27
27
  rack (~> 2.0)
28
28
  rack-test (>= 0.6.3)
29
29
  rails-dom-testing (~> 2.0)
30
30
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
31
- actionview (5.1.5)
32
- activesupport (= 5.1.5)
31
+ actionview (5.2.2)
32
+ activesupport (= 5.2.2)
33
33
  builder (~> 3.1)
34
34
  erubi (~> 1.4)
35
35
  rails-dom-testing (~> 2.0)
36
36
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
37
37
  active_record_union (1.3.0)
38
38
  activerecord (>= 4.0)
39
- activejob (5.1.5)
40
- activesupport (= 5.1.5)
39
+ activejob (5.2.2)
40
+ activesupport (= 5.2.2)
41
41
  globalid (>= 0.3.6)
42
- activemodel (5.1.5)
43
- activesupport (= 5.1.5)
44
- activerecord (5.1.5)
45
- activemodel (= 5.1.5)
46
- activesupport (= 5.1.5)
47
- arel (~> 8.0)
48
- activesupport (5.1.5)
42
+ activemodel (5.2.2)
43
+ activesupport (= 5.2.2)
44
+ activerecord (5.2.2)
45
+ activemodel (= 5.2.2)
46
+ activesupport (= 5.2.2)
47
+ arel (>= 9.0)
48
+ activestorage (5.2.2)
49
+ actionpack (= 5.2.2)
50
+ activerecord (= 5.2.2)
51
+ marcel (~> 0.3.1)
52
+ activesupport (5.2.2)
49
53
  concurrent-ruby (~> 1.0, >= 1.0.2)
50
- i18n (~> 0.7)
54
+ i18n (>= 0.7, < 2)
51
55
  minitest (~> 5.1)
52
56
  tzinfo (~> 1.1)
53
- arel (8.0.0)
57
+ arel (9.0.0)
54
58
  ast (2.4.0)
55
59
  builder (3.2.3)
56
- closure_tree (6.6.0)
57
- activerecord (>= 4.1.0)
58
- with_advisory_lock (>= 3.0.0)
59
- codeclimate-test-reporter (1.0.8)
60
- simplecov (<= 0.13)
60
+ closure_tree (7.0.0)
61
+ activerecord (>= 4.2.10)
62
+ with_advisory_lock (>= 4.0.0)
61
63
  coderay (1.1.2)
62
- concurrent-ruby (1.0.5)
64
+ concurrent-ruby (1.1.4)
63
65
  configurations (2.2.2)
64
- crass (1.0.3)
65
- database_cleaner (1.6.2)
66
+ crass (1.0.4)
67
+ database_cleaner (1.7.0)
66
68
  db-query-matchers (0.9.0)
67
69
  activesupport (>= 4.0, <= 6.0)
68
70
  rspec (~> 3.0)
69
71
  diff-lcs (1.3)
70
- docile (1.1.5)
71
- erubi (1.7.1)
72
- factory_girl (4.9.0)
72
+ docile (1.3.1)
73
+ erubi (1.8.0)
74
+ factory_bot (4.11.1)
73
75
  activesupport (>= 3.0.0)
74
- factory_girl_rails (4.9.0)
75
- factory_girl (~> 4.9.0)
76
+ factory_bot_rails (4.11.1)
77
+ factory_bot (~> 4.11.1)
76
78
  railties (>= 3.0.0)
77
- ffaker (2.8.1)
79
+ ffaker (2.10.0)
78
80
  globalid (0.4.1)
79
81
  activesupport (>= 4.2.0)
80
- i18n (0.9.5)
82
+ i18n (1.2.0)
81
83
  concurrent-ruby (~> 1.0)
84
+ jaro_winkler (1.5.1)
82
85
  json (2.1.0)
83
- loofah (2.2.2)
86
+ loofah (2.2.3)
84
87
  crass (~> 1.0.2)
85
88
  nokogiri (>= 1.5.9)
86
- mail (2.7.0)
89
+ mail (2.7.1)
87
90
  mini_mime (>= 0.1.1)
88
- method_source (0.9.0)
89
- mini_mime (1.0.0)
90
- mini_portile2 (2.3.0)
91
+ marcel (0.3.3)
92
+ mimemagic (~> 0.3.2)
93
+ method_source (0.9.2)
94
+ mimemagic (0.3.2)
95
+ mini_mime (1.0.1)
96
+ mini_portile2 (2.4.0)
91
97
  minitest (5.11.3)
92
- nio4r (2.3.0)
93
- nokogiri (1.8.2)
94
- mini_portile2 (~> 2.3.0)
98
+ nio4r (2.3.1)
99
+ nokogiri (1.9.1)
100
+ mini_portile2 (~> 2.4.0)
95
101
  parallel (1.12.1)
96
- parser (2.5.0.5)
102
+ parser (2.5.3.0)
97
103
  ast (~> 2.4.0)
98
- powerpack (0.1.1)
99
- pry (0.11.3)
104
+ powerpack (0.1.2)
105
+ pry (0.12.2)
100
106
  coderay (~> 1.1.0)
101
107
  method_source (~> 0.9.0)
102
- pry-rails (0.3.6)
108
+ pry-rails (0.3.8)
103
109
  pry (>= 0.10.4)
104
- rack (2.0.4)
105
- rack-test (0.8.3)
110
+ rack (2.0.6)
111
+ rack-test (1.1.0)
106
112
  rack (>= 1.0, < 3)
107
- rails (5.1.5)
108
- actioncable (= 5.1.5)
109
- actionmailer (= 5.1.5)
110
- actionpack (= 5.1.5)
111
- actionview (= 5.1.5)
112
- activejob (= 5.1.5)
113
- activemodel (= 5.1.5)
114
- activerecord (= 5.1.5)
115
- activesupport (= 5.1.5)
113
+ rails (5.2.2)
114
+ actioncable (= 5.2.2)
115
+ actionmailer (= 5.2.2)
116
+ actionpack (= 5.2.2)
117
+ actionview (= 5.2.2)
118
+ activejob (= 5.2.2)
119
+ activemodel (= 5.2.2)
120
+ activerecord (= 5.2.2)
121
+ activestorage (= 5.2.2)
122
+ activesupport (= 5.2.2)
116
123
  bundler (>= 1.3.0)
117
- railties (= 5.1.5)
124
+ railties (= 5.2.2)
118
125
  sprockets-rails (>= 2.0.0)
119
126
  rails-dom-testing (2.0.3)
120
127
  activesupport (>= 4.2.0)
121
128
  nokogiri (>= 1.6)
122
129
  rails-html-sanitizer (1.0.4)
123
130
  loofah (~> 2.2, >= 2.2.2)
124
- railties (5.1.5)
125
- actionpack (= 5.1.5)
126
- activesupport (= 5.1.5)
131
+ railties (5.2.2)
132
+ actionpack (= 5.2.2)
133
+ activesupport (= 5.2.2)
127
134
  method_source
128
135
  rake (>= 0.8.7)
129
- thor (>= 0.18.1, < 2.0)
136
+ thor (>= 0.19.0, < 2.0)
130
137
  rainbow (3.0.0)
131
- rake (12.3.1)
132
- rspec (3.7.0)
133
- rspec-core (~> 3.7.0)
134
- rspec-expectations (~> 3.7.0)
135
- rspec-mocks (~> 3.7.0)
136
- rspec-core (3.7.1)
137
- rspec-support (~> 3.7.0)
138
- rspec-expectations (3.7.0)
138
+ rake (12.3.2)
139
+ rspec (3.8.0)
140
+ rspec-core (~> 3.8.0)
141
+ rspec-expectations (~> 3.8.0)
142
+ rspec-mocks (~> 3.8.0)
143
+ rspec-core (3.8.0)
144
+ rspec-support (~> 3.8.0)
145
+ rspec-expectations (3.8.2)
139
146
  diff-lcs (>= 1.2.0, < 2.0)
140
- rspec-support (~> 3.7.0)
141
- rspec-mocks (3.7.0)
147
+ rspec-support (~> 3.8.0)
148
+ rspec-mocks (3.8.0)
142
149
  diff-lcs (>= 1.2.0, < 2.0)
143
- rspec-support (~> 3.7.0)
144
- rspec-rails (3.7.2)
150
+ rspec-support (~> 3.8.0)
151
+ rspec-rails (3.8.1)
145
152
  actionpack (>= 3.0)
146
153
  activesupport (>= 3.0)
147
154
  railties (>= 3.0)
148
- rspec-core (~> 3.7.0)
149
- rspec-expectations (~> 3.7.0)
150
- rspec-mocks (~> 3.7.0)
151
- rspec-support (~> 3.7.0)
152
- rspec-support (3.7.1)
153
- rubocop (0.54.0)
155
+ rspec-core (~> 3.8.0)
156
+ rspec-expectations (~> 3.8.0)
157
+ rspec-mocks (~> 3.8.0)
158
+ rspec-support (~> 3.8.0)
159
+ rspec-support (3.8.0)
160
+ rubocop (0.61.1)
161
+ jaro_winkler (~> 1.5.1)
154
162
  parallel (~> 1.10)
155
- parser (>= 2.5)
163
+ parser (>= 2.5, != 2.5.1.1)
156
164
  powerpack (~> 0.1)
157
165
  rainbow (>= 2.2.2, < 4.0)
158
166
  ruby-progressbar (~> 1.7)
159
- unicode-display_width (~> 1.0, >= 1.0.1)
160
- ruby-progressbar (1.9.0)
167
+ unicode-display_width (~> 1.4.0)
168
+ rubocop-rspec (1.30.1)
169
+ rubocop (>= 0.60.0)
170
+ ruby-progressbar (1.10.0)
161
171
  shoulda-matchers (3.1.2)
162
172
  activesupport (>= 4.0.0)
163
- simplecov (0.13.0)
164
- docile (~> 1.1.0)
173
+ simplecov (0.16.1)
174
+ docile (~> 1.1)
165
175
  json (>= 1.8, < 3)
166
176
  simplecov-html (~> 0.10.0)
167
177
  simplecov-html (0.10.2)
168
- sprockets (3.7.1)
178
+ sprockets (3.7.2)
169
179
  concurrent-ruby (~> 1.0)
170
180
  rack (> 1, < 3)
171
181
  sprockets-rails (3.2.1)
@@ -173,41 +183,41 @@ GEM
173
183
  activesupport (>= 4.0)
174
184
  sprockets (>= 3.0.0)
175
185
  sqlite3 (1.3.13)
176
- thor (0.20.0)
186
+ thor (0.20.3)
177
187
  thread_safe (0.3.6)
178
188
  tqdm (0.3.0)
179
189
  tzinfo (1.2.5)
180
190
  thread_safe (~> 0.1)
181
- unicode-display_width (1.3.0)
182
- websocket-driver (0.6.5)
191
+ unicode-display_width (1.4.0)
192
+ websocket-driver (0.7.0)
183
193
  websocket-extensions (>= 0.1.0)
184
194
  websocket-extensions (0.1.3)
185
- with_advisory_lock (3.2.0)
186
- activerecord (>= 3.2)
195
+ with_advisory_lock (4.0.0)
196
+ activerecord (>= 4.2)
187
197
 
188
198
  PLATFORMS
189
199
  ruby
190
200
 
191
201
  DEPENDENCIES
192
- bundler (~> 1.12)
193
- codeclimate-test-reporter (~> 1.0.8)
194
- database_cleaner (= 1.6.2)
202
+ bundler (~> 1.17)
203
+ database_cleaner (= 1.7.0)
195
204
  db-query-matchers (= 0.9.0)
196
- factory_girl_rails (= 4.9.0)
197
- ffaker (= 2.8.1)
205
+ factory_bot_rails (= 4.11.1)
206
+ ffaker (= 2.10.0)
198
207
  monarchy!
199
- pry-rails (= 0.3.6)
200
- rails (= 5.1.5)
201
- rake (~> 12.3.1)
202
- rspec (= 3.7.0)
203
- rspec-rails (= 3.7.2)
204
- rubocop (= 0.54.0)
208
+ pry-rails (= 0.3.8)
209
+ rails (= 5.2.2)
210
+ rake (~> 12.3.2)
211
+ rspec (= 3.8.0)
212
+ rspec-rails (= 3.8.1)
213
+ rubocop (= 0.61.1)
214
+ rubocop-rspec (= 1.30.1)
205
215
  shoulda-matchers (= 3.1.2)
206
- simplecov (= 0.13.0)
216
+ simplecov (= 0.16.1)
207
217
  sqlite3 (= 1.3.13)
208
218
 
209
219
  RUBY VERSION
210
- ruby 2.4.2p198
220
+ ruby 2.5.3p105
211
221
 
212
222
  BUNDLED WITH
213
- 1.16.0
223
+ 1.17.2
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  <p align="center">
2
2
  <img src="monarchy.png?raw=true" alt="Sublime's custom image"/>
3
+ </p>
4
+
5
+ <p align="center">
3
6
  <a href="https://travis-ci.org/Exelord/Monarchy">
4
7
  <img src="https://travis-ci.org/Exelord/Monarchy.svg?branch=master">
5
8
  </a>
6
- <a href="https://gemnasium.com/github.com/Exelord/Monarchy">
7
- <img src="https://gemnasium.com/badges/github.com/Exelord/Monarchy.svg">
8
- </a>
9
9
  <a href="https://gitter.im/Exelord/Monarchy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge">
10
10
  <img src="https://badges.gitter.im/Exelord/Monarchy.svg">
11
11
  </a>
@@ -19,5 +19,7 @@ module Dummy
19
19
  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20
20
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
21
21
  # config.i18n.default_locale = :de
22
+
23
+ config.active_record.sqlite3.represent_boolean_as_integer = true
22
24
  end
23
25
  end
@@ -69,6 +69,26 @@ module Monarchy
69
69
  end
70
70
 
71
71
  module SupportMethods
72
+ def accessible_roots_ids(user_id, parent_access)
73
+ accessible_roots = unscoped.joins('INNER JOIN monarchy_hierarchy_hierarchies ON ' \
74
+ 'monarchy_hierarchies.id = monarchy_hierarchy_hierarchies.ancestor_id')
75
+ .joins('INNER JOIN (SELECT hierarchy_id FROM monarchy_members ' \
76
+ "WHERE monarchy_members.user_id = #{user_id}) as members ON " \
77
+ 'members.hierarchy_id = monarchy_hierarchy_hierarchies.descendant_id').select(:id)
78
+
79
+ parent_access ? roots_with_children(accessible_roots) : accessible_roots
80
+ end
81
+
82
+ def accessible_leaves_ids(user_id, inherited_roles = [])
83
+ ancestor_leaves_for_user(user_id, false)
84
+ .select('monarchy_hierarchy_hierarchies.ancestor_id AS id')
85
+ .union_all(descendant_leaves_for_user(user_id, inherited_roles)).select(:id)
86
+ end
87
+
88
+ def accessible_for_options(options = {})
89
+ Monarchy.configuration.accessible_for_options.to_h.merge(options)
90
+ end
91
+
72
92
  private
73
93
 
74
94
  def include_relations
@@ -98,27 +118,11 @@ module Monarchy
98
118
  end
99
119
  # rubocop:enable all
100
120
 
101
- def accessible_roots_ids(user_id, parent_access)
102
- accessible_roots = unscoped.joins('INNER JOIN monarchy_hierarchy_hierarchies ON ' \
103
- 'monarchy_hierarchies.id = monarchy_hierarchy_hierarchies.ancestor_id')
104
- .joins('INNER JOIN (SELECT hierarchy_id FROM monarchy_members ' \
105
- "WHERE monarchy_members.user_id = #{user_id}) as members ON " \
106
- 'members.hierarchy_id = monarchy_hierarchy_hierarchies.descendant_id').select(:id)
107
-
108
- parent_access ? roots_with_children(accessible_roots) : accessible_roots
109
- end
110
-
111
121
  def roots_with_children(accessible_roots)
112
122
  accessible_children = unscoped.where(parent_id: accessible_roots).select(:id)
113
123
  accessible_roots.union_all(accessible_children)
114
124
  end
115
125
 
116
- def accessible_leaves_ids(user_id, inherited_roles = [])
117
- ancestor_leaves_for_user(user_id, false)
118
- .select('monarchy_hierarchy_hierarchies.ancestor_id AS id')
119
- .union_all(descendant_leaves_for_user(user_id, inherited_roles)).select(:id)
120
- end
121
-
122
126
  def descendant_leaves_for_user(user_id, inherited_roles = [])
123
127
  ancestor_leaves_for_user(user_id, true, inherited_roles)
124
128
  .joins('INNER JOIN monarchy_hierarchy_hierarchies AS monarchy_descendants ON ' \
@@ -145,10 +149,6 @@ module Monarchy
145
149
  Monarchy.role_class.select(:id, :inherited).where(inherited: inherited).to_sql
146
150
  end
147
151
  end
148
-
149
- def accessible_for_options(options = {})
150
- Monarchy.configuration.accessible_for_options.to_h.merge(options)
151
- end
152
152
  end
153
153
  end
154
154
  end
@@ -52,8 +52,6 @@ module Monarchy
52
52
  belongs_to :hierarchy, class_name: "::#{Monarchy.hierarchy_class}"
53
53
  end
54
54
 
55
- private
56
-
57
55
  def with_ancestors_access(resource)
58
56
  unscoped.where(hierarchy: resource.hierarchy.self_and_ancestors)
59
57
  .joins(:roles).where(monarchy_roles: { inherited: true })
@@ -14,7 +14,7 @@ module Monarchy
14
14
  belongs_to :inherited_role, class_name: "::#{Monarchy.role_class}"
15
15
 
16
16
  after_create :default_inherited_role
17
-
17
+
18
18
  validates :name, presence: true
19
19
  validates :level, presence: true
20
20
 
@@ -72,6 +72,7 @@ module Monarchy
72
72
  end
73
73
 
74
74
  return accessible_roles.order(level: :desc, name: :asc) if accessible_roles.present?
75
+
75
76
  inheritnce ? descendant_role(resource) : Monarchy.role_class.none
76
77
  end
77
78
 
@@ -41,16 +41,19 @@ module Monarchy
41
41
 
42
42
  def user(user, allow_nil = false)
43
43
  raise Monarchy::Exceptions::UserIsNil if !user && !allow_nil
44
+
44
45
  model_is_class(user, Monarchy.user_class, 'ModelNotUser')
45
46
  end
46
47
 
47
48
  def member(member, allow_nil = false)
48
49
  raise Monarchy::Exceptions::MemberIsNil if !member && !allow_nil
50
+
49
51
  model_is_class(member, Monarchy.member_class, 'ModelNotMember')
50
52
  end
51
53
 
52
54
  def role(role, allow_nil = false)
53
55
  raise Monarchy::Exceptions::RoleIsNil if !role && !allow_nil
56
+
54
57
  model_is_class(role, Monarchy.role_class, 'ModelNotRole')
55
58
  end
56
59
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Monarchy
4
- VERSION = '2.5.0'
4
+ VERSION = '2.6.0'
5
5
  end
data/monarchy.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.test_files = Dir['test/**/*']
20
20
 
21
21
  raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless s.respond_to?(:metadata)
22
+
22
23
  s.metadata['allowed_push_host'] = 'https://rubygems.org'
23
24
 
24
25
  s.bindir = 'exe'
@@ -28,11 +29,7 @@ Gem::Specification.new do |s|
28
29
 
29
30
  s.add_dependency 'active_record_union', '1.3.0'
30
31
  s.add_dependency 'activerecord', '>=4.2.7.1'
31
- s.add_dependency 'closure_tree', '6.6.0'
32
+ s.add_dependency 'closure_tree', '7.0.0'
32
33
  s.add_dependency 'configurations', '2.2.2'
33
34
  s.add_dependency 'tqdm', '0.3.0'
34
-
35
- s.add_development_dependency 'bundler', '~> 1.12'
36
- s.add_development_dependency 'rake', '~> 12.3.1'
37
- s.add_development_dependency 'rspec', '3.7.0'
38
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monarchy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Exelord
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-25 00:00:00.000000000 Z
11
+ date: 2018-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_record_union
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 6.6.0
47
+ version: 7.0.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 6.6.0
54
+ version: 7.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: configurations
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,48 +80,6 @@ dependencies:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.3.0
83
- - !ruby/object:Gem::Dependency
84
- name: bundler
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.12'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.12'
97
- - !ruby/object:Gem::Dependency
98
- name: rake
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 12.3.1
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 12.3.1
111
- - !ruby/object:Gem::Dependency
112
- name: rspec
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - '='
116
- - !ruby/object:Gem::Version
117
- version: 3.7.0
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - '='
123
- - !ruby/object:Gem::Version
124
- version: 3.7.0
125
83
  description: Hierarchical access management system with roles inheritance.
126
84
  email:
127
85
  - exelord@macsour.com
@@ -259,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
217
  version: '0'
260
218
  requirements: []
261
219
  rubyforge_project:
262
- rubygems_version: 2.6.14
220
+ rubygems_version: 2.7.6
263
221
  signing_key:
264
222
  specification_version: 4
265
223
  summary: Hierarchical access management system with roles inheritance.