active_record-acts_as 2.0.2 → 2.0.3

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: 761438498f49dac20f75381f874a88e27ec138cd
4
- data.tar.gz: 36469a2966a6daf4b2c949f7d470ec2b2a83493a
3
+ metadata.gz: 3bdab6c5656685b37735b973c0469d7685f59184
4
+ data.tar.gz: 2e194b3da56bf01749ec5b25f6735a44fdbd1db1
5
5
  SHA512:
6
- metadata.gz: 7c5a6238806ba9f7c760ac24c234f3862fa4439b31504d98162482bd86d4b74b4fcaa272941fc62d3abd91053bf5ecc8ce1e52a2d2b1cef9bdfe2fee396a29d1
7
- data.tar.gz: b4a41d99a5da3cc2c7bf64ffc0ba1cfb4941558d25ee03324c3610fbf7b72a3f80d4640c322db23bce2059bdc09dc006b80632e1cb546e7267449d6eb04fb534
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.1...HEAD
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
@@ -2,8 +2,7 @@ module ActiveRecord
2
2
  module ActsAs
3
3
  module ReflectionsWithActsAs
4
4
  def _reflections
5
- @_reflections_acts_as_cache ||=
6
- super.reverse_merge(acting_as_model._reflections)
5
+ super.reverse_merge(acting_as_model._reflections)
7
6
  end
8
7
  end
9
8
 
@@ -1,6 +1,6 @@
1
1
  module ActiveRecord
2
2
  module ActsAs
3
- VERSION = "2.0.2"
3
+ VERSION = "2.0.3"
4
4
  end
5
5
  end
6
6
 
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 + 1)
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 assosications defined in supermodel" do
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
@@ -3,4 +3,6 @@ Coveralls.wear!
3
3
 
4
4
  RSpec.configure do |config|
5
5
  config.disable_monkey_patching!
6
+ config.filter_run_including focus: true
7
+ config.run_all_when_everything_filtered = true
6
8
  end
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.2
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-06 00:00:00.000000000 Z
11
+ date: 2016-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3