Skip to content

Commit 18eff4b

Browse files
authored
Merge pull request #77 from Exelord/rails-5.1
Support for Rails 5.1
2 parents 762a746 + d64ca8e commit 18eff4b

File tree

8 files changed

+117
-114
lines changed

8 files changed

+117
-114
lines changed

.rubocop.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AllCops:
2-
TargetRubyVersion: 2.3
2+
TargetRubyVersion: 2.4
33
Exclude:
44
- 'dummy/db/seeds.rb'
55
- 'dummy/db/migrate/**'
@@ -13,7 +13,7 @@ Metrics/ModuleLength:
1313
Max: 150
1414
Metrics/BlockLength:
1515
ExcludedMethods: ['describe', 'context']
16-
Style/CaseIndentation:
16+
Layout/CaseIndentation:
1717
Enabled: false
1818
Style/StructInheritance:
1919
Enabled: false

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ addons:
33
repo_token: 60b8a9fc7e8d659c7dd22ed8912651c35b3ca5eebf1c23d5470308e6a802abbd
44
language: ruby
55
rvm:
6-
- 2.4.0
6+
- 2.4.2
77
before_install: gem update --system
88
after_success:
99
- bundle exec codeclimate-test-reporter

Gemfile

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
source 'https://rubygems.org'
4-
ruby '2.4.0'
4+
ruby '2.4.2'
55

66
# Declare your gem's dependencies in monarchy.gemspec.
77
# Bundler will treat runtime dependencies like base dependencies, and
@@ -17,15 +17,15 @@ gemspec
1717
# gem 'byebug', group: [:development, :test]
1818

1919
group :development, :test do
20-
gem 'database_cleaner', '1.5.3'
21-
gem 'db-query-matchers', '0.8.0'
20+
gem 'database_cleaner', '1.6.1'
21+
gem 'db-query-matchers', '0.9.0'
2222
gem 'factory_girl_rails', '4.8.0'
23-
gem 'ffaker', '2.5.0'
23+
gem 'ffaker', '2.7.0'
2424
gem 'pry-rails', '0.3.6'
25-
gem 'rails', '5.0.2'
26-
gem 'rspec-rails', '3.5.2'
27-
gem 'rubocop', '0.48.0'
28-
gem 'shoulda-matchers', '3.1.1'
25+
gem 'rails', '5.1.4'
26+
gem 'rspec-rails', '3.6.1'
27+
gem 'rubocop', '0.50.0'
28+
gem 'shoulda-matchers', '3.1.2'
2929
gem 'sqlite3', '1.3.13'
3030
end
3131

Gemfile.lock

+99-95
Original file line numberDiff line numberDiff line change
@@ -4,183 +4,187 @@ PATH
44
monarchy (2.3.0)
55
active_record_union (= 1.2.0)
66
activerecord (>= 4.2.7.1)
7-
closure_tree (= 6.5.0)
7+
closure_tree (= 6.6.0)
88
configurations (= 2.2.2)
99
tqdm (= 0.3.0)
1010

1111
GEM
1212
remote: https://rubygems.org/
1313
specs:
14-
actioncable (5.0.2)
15-
actionpack (= 5.0.2)
16-
nio4r (>= 1.2, < 3.0)
14+
actioncable (5.1.4)
15+
actionpack (= 5.1.4)
16+
nio4r (~> 2.0)
1717
websocket-driver (~> 0.6.1)
18-
actionmailer (5.0.2)
19-
actionpack (= 5.0.2)
20-
actionview (= 5.0.2)
21-
activejob (= 5.0.2)
18+
actionmailer (5.1.4)
19+
actionpack (= 5.1.4)
20+
actionview (= 5.1.4)
21+
activejob (= 5.1.4)
2222
mail (~> 2.5, >= 2.5.4)
2323
rails-dom-testing (~> 2.0)
24-
actionpack (5.0.2)
25-
actionview (= 5.0.2)
26-
activesupport (= 5.0.2)
24+
actionpack (5.1.4)
25+
actionview (= 5.1.4)
26+
activesupport (= 5.1.4)
2727
rack (~> 2.0)
28-
rack-test (~> 0.6.3)
28+
rack-test (>= 0.6.3)
2929
rails-dom-testing (~> 2.0)
3030
rails-html-sanitizer (~> 1.0, >= 1.0.2)
31-
actionview (5.0.2)
32-
activesupport (= 5.0.2)
31+
actionview (5.1.4)
32+
activesupport (= 5.1.4)
3333
builder (~> 3.1)
34-
erubis (~> 2.7.0)
34+
erubi (~> 1.4)
3535
rails-dom-testing (~> 2.0)
3636
rails-html-sanitizer (~> 1.0, >= 1.0.3)
3737
active_record_union (1.2.0)
3838
activerecord (>= 4.0)
39-
activejob (5.0.2)
40-
activesupport (= 5.0.2)
39+
activejob (5.1.4)
40+
activesupport (= 5.1.4)
4141
globalid (>= 0.3.6)
42-
activemodel (5.0.2)
43-
activesupport (= 5.0.2)
44-
activerecord (5.0.2)
45-
activemodel (= 5.0.2)
46-
activesupport (= 5.0.2)
47-
arel (~> 7.0)
48-
activesupport (5.0.2)
42+
activemodel (5.1.4)
43+
activesupport (= 5.1.4)
44+
activerecord (5.1.4)
45+
activemodel (= 5.1.4)
46+
activesupport (= 5.1.4)
47+
arel (~> 8.0)
48+
activesupport (5.1.4)
4949
concurrent-ruby (~> 1.0, >= 1.0.2)
5050
i18n (~> 0.7)
5151
minitest (~> 5.1)
5252
tzinfo (~> 1.1)
53-
arel (7.1.4)
53+
arel (8.0.0)
5454
ast (2.3.0)
5555
builder (3.2.3)
56-
closure_tree (6.5.0)
56+
closure_tree (6.6.0)
5757
activerecord (>= 4.1.0)
5858
with_advisory_lock (>= 3.0.0)
5959
codeclimate-test-reporter (1.0.8)
6060
simplecov (<= 0.13)
61-
coderay (1.1.1)
61+
coderay (1.1.2)
6262
concurrent-ruby (1.0.5)
6363
configurations (2.2.2)
64-
database_cleaner (1.5.3)
65-
db-query-matchers (0.8.0)
64+
crass (1.0.2)
65+
database_cleaner (1.6.1)
66+
db-query-matchers (0.9.0)
67+
activesupport (>= 4.0, <= 6.0)
68+
rspec (~> 3.0)
6669
diff-lcs (1.3)
6770
docile (1.1.5)
68-
erubis (2.7.0)
69-
factory_girl (4.8.0)
71+
erubi (1.6.1)
72+
factory_girl (4.8.1)
7073
activesupport (>= 3.0.0)
7174
factory_girl_rails (4.8.0)
7275
factory_girl (~> 4.8.0)
7376
railties (>= 3.0.0)
74-
ffaker (2.5.0)
77+
ffaker (2.7.0)
7578
globalid (0.4.0)
7679
activesupport (>= 4.2.0)
77-
i18n (0.8.4)
80+
i18n (0.8.6)
7881
json (2.1.0)
79-
loofah (2.0.3)
82+
loofah (2.1.1)
83+
crass (~> 1.0.2)
8084
nokogiri (>= 1.5.9)
8185
mail (2.6.6)
8286
mime-types (>= 1.16, < 4)
83-
method_source (0.8.2)
87+
method_source (0.9.0)
8488
mime-types (3.1)
8589
mime-types-data (~> 3.2015)
8690
mime-types-data (3.2016.0521)
87-
mini_portile2 (2.2.0)
88-
minitest (5.10.2)
91+
mini_portile2 (2.3.0)
92+
minitest (5.10.3)
8993
nio4r (2.1.0)
90-
nokogiri (1.8.0)
91-
mini_portile2 (~> 2.2.0)
94+
nokogiri (1.8.1)
95+
mini_portile2 (~> 2.3.0)
96+
parallel (1.12.0)
9297
parser (2.4.0.0)
9398
ast (~> 2.2)
9499
powerpack (0.1.1)
95-
pry (0.10.4)
100+
pry (0.11.1)
96101
coderay (~> 1.1.0)
97-
method_source (~> 0.8.1)
98-
slop (~> 3.4)
102+
method_source (~> 0.9.0)
99103
pry-rails (0.3.6)
100104
pry (>= 0.10.4)
101105
rack (2.0.3)
102-
rack-test (0.6.3)
103-
rack (>= 1.0)
104-
rails (5.0.2)
105-
actioncable (= 5.0.2)
106-
actionmailer (= 5.0.2)
107-
actionpack (= 5.0.2)
108-
actionview (= 5.0.2)
109-
activejob (= 5.0.2)
110-
activemodel (= 5.0.2)
111-
activerecord (= 5.0.2)
112-
activesupport (= 5.0.2)
113-
bundler (>= 1.3.0, < 2.0)
114-
railties (= 5.0.2)
106+
rack-test (0.7.0)
107+
rack (>= 1.0, < 3)
108+
rails (5.1.4)
109+
actioncable (= 5.1.4)
110+
actionmailer (= 5.1.4)
111+
actionpack (= 5.1.4)
112+
actionview (= 5.1.4)
113+
activejob (= 5.1.4)
114+
activemodel (= 5.1.4)
115+
activerecord (= 5.1.4)
116+
activesupport (= 5.1.4)
117+
bundler (>= 1.3.0)
118+
railties (= 5.1.4)
115119
sprockets-rails (>= 2.0.0)
116120
rails-dom-testing (2.0.3)
117121
activesupport (>= 4.2.0)
118122
nokogiri (>= 1.6)
119123
rails-html-sanitizer (1.0.3)
120124
loofah (~> 2.0)
121-
railties (5.0.2)
122-
actionpack (= 5.0.2)
123-
activesupport (= 5.0.2)
125+
railties (5.1.4)
126+
actionpack (= 5.1.4)
127+
activesupport (= 5.1.4)
124128
method_source
125129
rake (>= 0.8.7)
126130
thor (>= 0.18.1, < 2.0)
127131
rainbow (2.2.2)
128132
rake
129-
rake (12.0.0)
130-
rspec (3.5.0)
131-
rspec-core (~> 3.5.0)
132-
rspec-expectations (~> 3.5.0)
133-
rspec-mocks (~> 3.5.0)
134-
rspec-core (3.5.4)
135-
rspec-support (~> 3.5.0)
136-
rspec-expectations (3.5.0)
133+
rake (12.1.0)
134+
rspec (3.6.0)
135+
rspec-core (~> 3.6.0)
136+
rspec-expectations (~> 3.6.0)
137+
rspec-mocks (~> 3.6.0)
138+
rspec-core (3.6.0)
139+
rspec-support (~> 3.6.0)
140+
rspec-expectations (3.6.0)
137141
diff-lcs (>= 1.2.0, < 2.0)
138-
rspec-support (~> 3.5.0)
139-
rspec-mocks (3.5.0)
142+
rspec-support (~> 3.6.0)
143+
rspec-mocks (3.6.0)
140144
diff-lcs (>= 1.2.0, < 2.0)
141-
rspec-support (~> 3.5.0)
142-
rspec-rails (3.5.2)
145+
rspec-support (~> 3.6.0)
146+
rspec-rails (3.6.1)
143147
actionpack (>= 3.0)
144148
activesupport (>= 3.0)
145149
railties (>= 3.0)
146-
rspec-core (~> 3.5.0)
147-
rspec-expectations (~> 3.5.0)
148-
rspec-mocks (~> 3.5.0)
149-
rspec-support (~> 3.5.0)
150-
rspec-support (3.5.0)
151-
rubocop (0.48.0)
150+
rspec-core (~> 3.6.0)
151+
rspec-expectations (~> 3.6.0)
152+
rspec-mocks (~> 3.6.0)
153+
rspec-support (~> 3.6.0)
154+
rspec-support (3.6.0)
155+
rubocop (0.50.0)
156+
parallel (~> 1.10)
152157
parser (>= 2.3.3.1, < 3.0)
153158
powerpack (~> 0.1)
154-
rainbow (>= 1.99.1, < 3.0)
159+
rainbow (>= 2.2.2, < 3.0)
155160
ruby-progressbar (~> 1.7)
156161
unicode-display_width (~> 1.0, >= 1.0.1)
157-
ruby-progressbar (1.8.1)
158-
shoulda-matchers (3.1.1)
162+
ruby-progressbar (1.9.0)
163+
shoulda-matchers (3.1.2)
159164
activesupport (>= 4.0.0)
160165
simplecov (0.13.0)
161166
docile (~> 1.1.0)
162167
json (>= 1.8, < 3)
163168
simplecov-html (~> 0.10.0)
164-
simplecov-html (0.10.1)
165-
slop (3.6.0)
169+
simplecov-html (0.10.2)
166170
sprockets (3.7.1)
167171
concurrent-ruby (~> 1.0)
168172
rack (> 1, < 3)
169-
sprockets-rails (3.2.0)
173+
sprockets-rails (3.2.1)
170174
actionpack (>= 4.0)
171175
activesupport (>= 4.0)
172176
sprockets (>= 3.0.0)
173177
sqlite3 (1.3.13)
174-
thor (0.19.4)
178+
thor (0.20.0)
175179
thread_safe (0.3.6)
176180
tqdm (0.3.0)
177181
tzinfo (1.2.3)
178182
thread_safe (~> 0.1)
179-
unicode-display_width (1.2.1)
183+
unicode-display_width (1.3.0)
180184
websocket-driver (0.6.5)
181185
websocket-extensions (>= 0.1.0)
182186
websocket-extensions (0.1.2)
183-
with_advisory_lock (3.1.0)
187+
with_advisory_lock (3.1.1)
184188
activerecord (>= 3.2)
185189
thread_safe
186190

@@ -190,23 +194,23 @@ PLATFORMS
190194
DEPENDENCIES
191195
bundler (~> 1.12)
192196
codeclimate-test-reporter (~> 1.0.8)
193-
database_cleaner (= 1.5.3)
194-
db-query-matchers (= 0.8.0)
197+
database_cleaner (= 1.6.1)
198+
db-query-matchers (= 0.9.0)
195199
factory_girl_rails (= 4.8.0)
196-
ffaker (= 2.5.0)
200+
ffaker (= 2.7.0)
197201
monarchy!
198202
pry-rails (= 0.3.6)
199-
rails (= 5.0.2)
203+
rails (= 5.1.4)
200204
rake (~> 12.0)
201-
rspec (= 3.5.0)
202-
rspec-rails (= 3.5.2)
203-
rubocop (= 0.48.0)
204-
shoulda-matchers (= 3.1.1)
205+
rspec (= 3.6.0)
206+
rspec-rails (= 3.6.1)
207+
rubocop (= 0.50.0)
208+
shoulda-matchers (= 3.1.2)
205209
simplecov (= 0.13.0)
206210
sqlite3 (= 1.3.13)
207211

208212
RUBY VERSION
209-
ruby 2.4.0p0
213+
ruby 2.4.2p198
210214

211215
BUNDLED WITH
212-
1.15.1
216+
1.15.4

lib/monarchy/acts_as_resource.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def include_scopes
6363
# rubocop:enable all
6464

6565
def include_relationships
66+
has_one :hierarchy, as: :resource, dependent: :destroy, class_name: "::#{Monarchy.hierarchy_class}"
6667
has_many :members, through: :hierarchy, class_name: "::#{Monarchy.member_class}"
6768
has_many :users, through: :members, class_name: "::#{Monarchy.user_class}"
68-
has_one :hierarchy, as: :resource, dependent: :destroy, class_name: "::#{Monarchy.hierarchy_class}"
6969
end
7070
end
7171

@@ -111,7 +111,7 @@ def assign_parent(force = false)
111111
return unless parentize
112112

113113
keys = relation_keys(parentize)
114-
was_changed = changes[keys[:foreign_key]] || changes[keys[:foreign_type]]
114+
was_changed = saved_changes[keys[:foreign_key]] || saved_changes[keys[:foreign_type]]
115115
Monarchy::Validators.resource(send(parentize), true, false)
116116
self.parent = send(parentize) if was_changed || force
117117
end

0 commit comments

Comments
 (0)