active_record-acts_as 2.0.5 → 2.0.6

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: 5f5963e720c4d133aec9bbcadb5d8034e805c5da
4
- data.tar.gz: b72a5773b65e24a08baa22ef43ff420f25d24d29
3
+ metadata.gz: 9c9748df03b3540052a5ffdc565d4e7e1533c295
4
+ data.tar.gz: 6e9bd73f2ca3999edc268e6c40b12510bc76e46c
5
5
  SHA512:
6
- metadata.gz: 6308fb4da307ca8d479ed40e6f6e1245dec31cbdc031ed28f6ebb4832dc1d282f28622235d074b296c9783ee1eb7c82e1aab6a93cc5fbf03f96918e824927a29
7
- data.tar.gz: cb452a38e28515964324e1540cf562631cdb0c3e403fdb9f512682a36d5076a9ad0f31d4b989fffc2fe65da828fe46266a91ed3cd3991985088821bca482f016
6
+ metadata.gz: 5103fa9f9a3e0cc57ab76270ca05db23008938c7090aa0af4bb9c0fce2b9a4e947a804d512138f4560ceae982e1e15f63bb9073b8ad1d0b15533f1592a23b5ab
7
+ data.tar.gz: b00229a569085953c49aff5095fc6b1475916cd50979172e84c1cca6f9b790f1a005761aa498745bd14978d484f91a3885a81b841ca639e389d76c252bdb1e90
data/CHANGELOG.md CHANGED
@@ -4,6 +4,15 @@ 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.6] - 2017-02-17
8
+ ### Added
9
+ - Allow arguments to #touch and forward them to the supermodel
10
+
11
+ ## [2.0.5] - 2016-12-20
12
+ ### Fixed
13
+ - Don't try to touch supermodel if it's not persisted
14
+ - Call `#destroy`, not `#delete`, on the submodule by default to trigger callbacks
15
+
7
16
  ## [2.0.4] - 2016-12-07
8
17
  ### Fixed
9
18
  - Touch associated objects if supermodel is updated
@@ -32,7 +41,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
32
41
  ### Fixed
33
42
  - Fixed `remove_actable` migration helper (https://github.com/hzamani/active_record-acts_as/pull/71, thanks to [nuclearpidgeon](https://github.com/nuclearpidgeon)!)
34
43
 
35
- [Unreleased]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.4...HEAD
44
+ [Unreleased]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.6...HEAD
45
+ [2.0.6]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.5...v2.0.6
46
+ [2.0.5]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.4...v2.0.5
36
47
  [2.0.4]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.3...v2.0.4
37
48
  [2.0.3]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.2...v2.0.3
38
49
  [2.0.2]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.1...v2.0.2
@@ -91,8 +91,8 @@ module ActiveRecord
91
91
  end
92
92
  end
93
93
 
94
- def touch
95
- acting_as.touch if acting_as.persisted?
94
+ def touch(*args)
95
+ acting_as.touch(*args) if acting_as.persisted?
96
96
  end
97
97
 
98
98
  def respond_to?(name, include_private = false, as_original_class = false)
@@ -1,6 +1,6 @@
1
1
  module ActiveRecord
2
2
  module ActsAs
3
- VERSION = "2.0.5"
3
+ VERSION = "2.0.6"
4
4
  end
5
5
  end
6
6
 
data/spec/acts_as_spec.rb CHANGED
@@ -230,6 +230,12 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
230
230
  end
231
231
 
232
232
  context "touching" do
233
+ it "forwards arguments to #touch to the supermodel" do
234
+ pen.save!
235
+ expect(pen.product).to receive(:touch).with(:one, :two)
236
+ pen.touch(:one, :two)
237
+ end
238
+
233
239
  it "touches supermodel on save" do
234
240
  pen.save
235
241
  pen.reload
@@ -266,11 +272,22 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
266
272
  end
267
273
  end
268
274
 
275
+ context "polymorphic associations" do
276
+ it "handles them correctly" do
277
+ payment = Payment.new
278
+ pen.payment = payment
279
+ pen.save!
280
+ expect(pen.reload.payment).to eq(payment)
281
+ expect(pen.payment.payable_type).to eq(pen.acting_as.class.to_s)
282
+ expect(pen.payment.payable_id).to eq(pen.acting_as.id)
283
+ end
284
+ end
285
+
269
286
  it "raises NoMethodEror on unexisting method call" do
270
287
  expect { pen.unexisted_method }.to raise_error(NoMethodError)
271
288
  end
272
289
 
273
- it "destroies Supermodel on destroy" do
290
+ it "destroys Supermodel on destroy" do
274
291
  pen.save
275
292
  product_id = pen.product.id
276
293
  pen.destroy
data/spec/models.rb CHANGED
@@ -5,6 +5,7 @@ class Product < ActiveRecord::Base
5
5
  actable
6
6
  belongs_to :store, touch: true
7
7
  has_many :buyers, dependent: :destroy
8
+ has_one :payment, as: :payable
8
9
  validates_presence_of :name, :price
9
10
  store :settings, accessors: [:global_option]
10
11
 
@@ -17,6 +18,10 @@ class Product < ActiveRecord::Base
17
18
  end
18
19
  end
19
20
 
21
+ class Payment < ActiveRecord::Base
22
+ belongs_to :payable, polymorphic: true
23
+ end
24
+
20
25
  class PenCollection < ActiveRecord::Base
21
26
  has_many :pens
22
27
  end
@@ -90,6 +95,11 @@ def initialize_schema
90
95
  t.actable
91
96
  end
92
97
 
98
+ create_table :payments do |t|
99
+ t.references :payable, polymorphic: true
100
+ t.timestamps null: true
101
+ end
102
+
93
103
  create_table :stores do |t|
94
104
  t.string :name
95
105
  t.timestamps null: true
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.5
4
+ version: 2.0.6
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-12-20 00:00:00.000000000 Z
11
+ date: 2017-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  requirements: []
166
166
  rubyforge_project:
167
- rubygems_version: 2.6.6
167
+ rubygems_version: 2.6.8
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: Simulate multi-table inheritance for activerecord models
@@ -177,4 +177,3 @@ test_files:
177
177
  - spec/models.rb
178
178
  - spec/rspec_matchers_spec.rb
179
179
  - spec/spec_helper.rb
180
- has_rdoc: