monarchy 2.2.1 → 2.2.2

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
2
  SHA1:
3
- metadata.gz: c15282927b5b58ca3da1c4102405a299faa6e6a9
4
- data.tar.gz: 0ad457f343ef448dbede073ade8fe820011b13dc
3
+ metadata.gz: 815ca965ee47bec334658cc90ce50557a8d0154e
4
+ data.tar.gz: 8353cc02f268a429bf61b117c421b5481942a2c4
5
5
  SHA512:
6
- metadata.gz: 79f77cba2b572d85260f640727bdca9dc6f3b53d80e72e5cab50e2f48f5584a19ed03d31d0d1e2128e0c3b66ea366e0a923c8541f606bb13e3e616ba22c571e7
7
- data.tar.gz: ea747c578065b293e644d3b4ef982a9b6b62c21e50636895a39ed5898779ef217d0fbf1e72205fe3bf9fb5a464744b89bd02b49c943effa164e3cd13d90d1898
6
+ metadata.gz: 3a11658a76ea5dc9cf75567c7c2485c0501fb95cc8003ed64b650bfdc13c6ae64db63037ee30b8c79d7c9b2c48a55e585faec53a99e26483f5d260568b55d143
7
+ data.tar.gz: aa8c93f91f7a4bcf48154e1207bd7bdfd81f58f5391a8488eade7a16da410a9507286f3425442ab928ff91b1f087b1f4a5646ad9de65d9c6f52fef81796c1a82
@@ -1 +1 @@
1
- future-release=2.2.1
1
+ future-release=2.2.2
data/CHANGELOG.md CHANGED
@@ -1,7 +1,15 @@
1
1
  # Change Log
2
2
 
3
- ## [2.2.1](https://github.com/Exelord/Monarchy/tree/2.2.1) (2017-05-29)
4
- [Full Changelog](https://github.com/Exelord/Monarchy/compare/v2.2.0...2.2.1)
3
+ ## [2.2.2](https://github.com/Exelord/Monarchy/tree/2.2.2) (2017-06-14)
4
+ [Full Changelog](https://github.com/Exelord/Monarchy/compare/v2.2.1...2.2.2)
5
+
6
+ **Fixed bugs:**
7
+
8
+ - Fix parent as [\#78](https://github.com/Exelord/Monarchy/issues/78)
9
+ - Fix parent\_as [\#75](https://github.com/Exelord/Monarchy/pull/75) ([Exelord](https://github.com/Exelord))
10
+
11
+ ## [v2.2.1](https://github.com/Exelord/Monarchy/tree/v2.2.1) (2017-05-29)
12
+ [Full Changelog](https://github.com/Exelord/Monarchy/compare/v2.2.0...v2.2.1)
5
13
 
6
14
  **Merged pull requests:**
7
15
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- monarchy (2.2.1)
4
+ monarchy (2.2.2)
5
5
  active_record_union (= 1.2.0)
6
6
  activerecord (>= 4.2.7.1)
7
7
  closure_tree (= 6.5.0)
@@ -71,23 +71,23 @@ GEM
71
71
  factory_girl (~> 4.8.0)
72
72
  railties (>= 3.0.0)
73
73
  ffaker (2.5.0)
74
- globalid (0.3.7)
75
- activesupport (>= 4.1.0)
76
- i18n (0.8.1)
77
- json (2.0.3)
74
+ globalid (0.4.0)
75
+ activesupport (>= 4.2.0)
76
+ i18n (0.8.4)
77
+ json (2.1.0)
78
78
  loofah (2.0.3)
79
79
  nokogiri (>= 1.5.9)
80
- mail (2.6.4)
80
+ mail (2.6.6)
81
81
  mime-types (>= 1.16, < 4)
82
82
  method_source (0.8.2)
83
83
  mime-types (3.1)
84
84
  mime-types-data (~> 3.2015)
85
85
  mime-types-data (3.2016.0521)
86
- mini_portile2 (2.1.0)
87
- minitest (5.10.1)
88
- nio4r (2.0.0)
89
- nokogiri (1.7.1)
90
- mini_portile2 (~> 2.1.0)
86
+ mini_portile2 (2.2.0)
87
+ minitest (5.10.2)
88
+ nio4r (2.1.0)
89
+ nokogiri (1.8.0)
90
+ mini_portile2 (~> 2.2.0)
91
91
  parser (2.4.0.0)
92
92
  ast (~> 2.2)
93
93
  powerpack (0.1.1)
@@ -97,7 +97,7 @@ GEM
97
97
  slop (~> 3.4)
98
98
  pry-rails (0.3.6)
99
99
  pry (>= 0.10.4)
100
- rack (2.0.1)
100
+ rack (2.0.3)
101
101
  rack-test (0.6.3)
102
102
  rack (>= 1.0)
103
103
  rails (5.0.2)
@@ -112,9 +112,9 @@ GEM
112
112
  bundler (>= 1.3.0, < 2.0)
113
113
  railties (= 5.0.2)
114
114
  sprockets-rails (>= 2.0.0)
115
- rails-dom-testing (2.0.2)
116
- activesupport (>= 4.2.0, < 6.0)
117
- nokogiri (~> 1.6)
115
+ rails-dom-testing (2.0.3)
116
+ activesupport (>= 4.2.0)
117
+ nokogiri (>= 1.6)
118
118
  rails-html-sanitizer (1.0.3)
119
119
  loofah (~> 2.0)
120
120
  railties (5.0.2)
@@ -123,7 +123,8 @@ GEM
123
123
  method_source
124
124
  rake (>= 0.8.7)
125
125
  thor (>= 0.18.1, < 2.0)
126
- rainbow (2.2.1)
126
+ rainbow (2.2.2)
127
+ rake
127
128
  rake (12.0.0)
128
129
  rspec (3.5.0)
129
130
  rspec-core (~> 3.5.0)
@@ -159,7 +160,7 @@ GEM
159
160
  docile (~> 1.1.0)
160
161
  json (>= 1.8, < 3)
161
162
  simplecov-html (~> 0.10.0)
162
- simplecov-html (0.10.0)
163
+ simplecov-html (0.10.1)
163
164
  slop (3.6.0)
164
165
  sprockets (3.7.1)
165
166
  concurrent-ruby (~> 1.0)
@@ -174,7 +175,7 @@ GEM
174
175
  tqdm (0.3.0)
175
176
  tzinfo (1.2.3)
176
177
  thread_safe (~> 0.1)
177
- unicode-display_width (1.1.3)
178
+ unicode-display_width (1.2.1)
178
179
  websocket-driver (0.6.5)
179
180
  websocket-extensions (>= 0.1.0)
180
181
  websocket-extensions (0.1.2)
@@ -206,4 +207,4 @@ RUBY VERSION
206
207
  ruby 2.4.0p0
207
208
 
208
209
  BUNDLED WITH
209
- 1.14.3
210
+ 1.15.1
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Project < ActiveRecord::Base
4
4
  acts_as_resource parent_as: :resource
5
- belongs_to :resource
5
+ belongs_to :resource, foreign_key: :parent_id
6
6
  has_one :status
7
7
 
8
8
  after_create :create_status
@@ -1,7 +1,7 @@
1
1
  class ParentAsSetup < ActiveRecord::Migration
2
2
  def change
3
3
  remove_column :resources, :memo_id
4
- add_column :projects, :resource_id, :integer
4
+ add_column :projects, :parent_id, :integer
5
5
  add_column :memos, :project_id, :integer
6
6
  end
7
7
  end
data/dummy/db/schema.rb CHANGED
@@ -71,9 +71,9 @@ ActiveRecord::Schema.define(version: 20160818205534) do
71
71
 
72
72
  create_table "projects", force: :cascade do |t|
73
73
  t.string "name"
74
- t.datetime "created_at", null: false
75
- t.datetime "updated_at", null: false
76
- t.integer "resource_id"
74
+ t.datetime "created_at", null: false
75
+ t.datetime "updated_at", null: false
76
+ t.integer "parent_id"
77
77
  end
78
78
 
79
79
  create_table "resources", force: :cascade do |t|
@@ -105,11 +105,17 @@ module Monarchy
105
105
  parentize = self.class.parentize_name
106
106
  return unless parentize
107
107
 
108
- was_changed = changes["#{parentize}_id"] || changes["#{parentize}_type"]
108
+ keys = relation_keys(parentize)
109
+ was_changed = changes[keys[:foreign_key]] || changes[keys[:foreign_type]]
109
110
  Monarchy::Validators.resource(send(parentize), true, false)
110
111
  self.parent = send(parentize) if was_changed || force
111
112
  end
112
113
 
114
+ def relation_keys(relation_name)
115
+ reflection = self.class.reflections[relation_name.to_s]
116
+ { foreign_key: reflection.foreign_key, foreign_type: reflection.foreign_type }
117
+ end
118
+
113
119
  def children_resources
114
120
  c = hierarchy.try(:children)
115
121
  return nil if c.nil?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Monarchy
4
- VERSION = '2.2.1'
4
+ VERSION = '2.2.2'
5
5
  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.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Exelord
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-29 00:00:00.000000000 Z
11
+ date: 2017-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord