active_record-acts_as 2.0.2 → 2.0.3
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 +4 -4
- data/CHANGELOG.md +11 -1
- data/lib/active_record/acts_as/class_methods.rb +1 -2
- data/lib/active_record/acts_as/version.rb +1 -1
- data/spec/acts_as_spec.rb +18 -2
- data/spec/models.rb +19 -0
- data/spec/spec_helper.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bdab6c5656685b37735b973c0469d7685f59184
|
4
|
+
data.tar.gz: 2e194b3da56bf01749ec5b25f6735a44fdbd1db1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dfdd0ed588ae99de26d55c11d27ee9807d2403def3ddb312b7f88fdb2b4be281be9ffbba85ff6b3731a925597b7298c84e724c5b0a6d20b17fa69eb0982d8bb
|
7
|
+
data.tar.gz: 072b7afcbae99749ead9b32e0a2feba7456214a0e58d09f2122a346833d097c98fe6343cb9a70d06263595184cfba3b4bfc624e4070abd9f078745b97fedadbf
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
6
|
|
7
|
+
## [2.0.3] - 2016-11-07
|
8
|
+
### Fixed
|
9
|
+
- Fix defining associations on `acting_as` model after calling `acting_as`
|
10
|
+
|
11
|
+
## [2.0.2] - 2016-11-06
|
12
|
+
### Fixed
|
13
|
+
- Call `#touch` on `actable` object when it's called on the `acting_as` object
|
14
|
+
|
7
15
|
## [2.0.1] - 2016-10-05
|
8
16
|
### Added
|
9
17
|
- Added this changelog
|
@@ -20,7 +28,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
20
28
|
### Fixed
|
21
29
|
- Fixed `remove_actable` migration helper (https://github.com/hzamani/active_record-acts_as/pull/71, thanks to [nuclearpidgeon](https://github.com/nuclearpidgeon)!)
|
22
30
|
|
23
|
-
[Unreleased]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.
|
31
|
+
[Unreleased]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.3...HEAD
|
32
|
+
[2.0.3]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.2...v2.0.3
|
33
|
+
[2.0.2]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.1...v2.0.2
|
24
34
|
[2.0.1]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.0...v2.0.1
|
25
35
|
[2.0.0]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.8...v2.0.0
|
26
36
|
[1.0.8]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.7...v1.0.8
|
data/spec/acts_as_spec.rb
CHANGED
@@ -152,7 +152,7 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
|
|
152
152
|
|
153
153
|
describe "._reflections" do
|
154
154
|
it "merges the reflections on both superclass and subclass" do
|
155
|
-
expect(Pen._reflections.length).to eq(Product._reflections.length +
|
155
|
+
expect(Pen._reflections.length).to eq(Product._reflections.length + 2)
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
@@ -267,8 +267,9 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
|
|
267
267
|
end
|
268
268
|
end
|
269
269
|
|
270
|
-
it "can set
|
270
|
+
it "can set belongs_to associations defined in supermodel" do
|
271
271
|
store.save
|
272
|
+
expect(pen.store).to be_nil
|
272
273
|
pen.store = store
|
273
274
|
pen.save
|
274
275
|
pen.reload
|
@@ -276,6 +277,21 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
|
|
276
277
|
expect(pen.product.store).to eq(store)
|
277
278
|
end
|
278
279
|
|
280
|
+
it "can set has_many associations defined in supermodel" do
|
281
|
+
expect(pen.buyers).to be_empty
|
282
|
+
buyer = Buyer.create!
|
283
|
+
pen.buyers << buyer
|
284
|
+
expect(pen.buyers).to eq([buyer])
|
285
|
+
expect(pen.product.buyers).to eq([buyer])
|
286
|
+
end
|
287
|
+
|
288
|
+
it "can set has_many associations defined in submodel" do
|
289
|
+
expect(pen.pen_caps).to be_empty
|
290
|
+
pen_cap = PenCap.create!
|
291
|
+
pen.pen_caps << pen_cap
|
292
|
+
expect(pen.pen_caps).to eq([pen_cap])
|
293
|
+
end
|
294
|
+
|
279
295
|
it "should be appendable in an has_many relation using << operator" do
|
280
296
|
store.save
|
281
297
|
store.products << pen
|
data/spec/models.rb
CHANGED
@@ -4,6 +4,7 @@ require 'active_record/acts_as'
|
|
4
4
|
class Product < ActiveRecord::Base
|
5
5
|
actable
|
6
6
|
belongs_to :store
|
7
|
+
has_many :buyers
|
7
8
|
validates_presence_of :name, :price
|
8
9
|
store :settings, accessors: [:global_option]
|
9
10
|
|
@@ -20,9 +21,19 @@ class Pen < ActiveRecord::Base
|
|
20
21
|
acts_as :product
|
21
22
|
store_accessor :settings, :option1
|
22
23
|
|
24
|
+
has_many :pen_caps
|
25
|
+
|
23
26
|
validates_presence_of :color
|
24
27
|
end
|
25
28
|
|
29
|
+
class Buyer < ActiveRecord::Base
|
30
|
+
belongs_to :product
|
31
|
+
end
|
32
|
+
|
33
|
+
class PenCap < ActiveRecord::Base
|
34
|
+
belongs_to :pen
|
35
|
+
end
|
36
|
+
|
26
37
|
class IsolatedPen < ActiveRecord::Base
|
27
38
|
self.table_name = :pens
|
28
39
|
acts_as :product, validates_actable: false
|
@@ -73,6 +84,14 @@ def initialize_schema
|
|
73
84
|
t.string :name
|
74
85
|
end
|
75
86
|
|
87
|
+
create_table :buyers do |t|
|
88
|
+
t.integer :product_id
|
89
|
+
end
|
90
|
+
|
91
|
+
create_table :pen_caps do |t|
|
92
|
+
t.integer :buyer_id
|
93
|
+
end
|
94
|
+
|
76
95
|
create_table :inventory_pen_lids do |t|
|
77
96
|
t.string :color
|
78
97
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record-acts_as
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hassan Zamani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|