active_record-acts_as 2.0.6 → 2.0.8

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: 9c9748df03b3540052a5ffdc565d4e7e1533c295
4
- data.tar.gz: 6e9bd73f2ca3999edc268e6c40b12510bc76e46c
3
+ metadata.gz: 8708651ac6d764497b6c4e8da34acae1475c3f7d
4
+ data.tar.gz: aa82c12e20fa93ac1f42af1e642dd5340cc06076
5
5
  SHA512:
6
- metadata.gz: 5103fa9f9a3e0cc57ab76270ca05db23008938c7090aa0af4bb9c0fce2b9a4e947a804d512138f4560ceae982e1e15f63bb9073b8ad1d0b15533f1592a23b5ab
7
- data.tar.gz: b00229a569085953c49aff5095fc6b1475916cd50979172e84c1cca6f9b790f1a005761aa498745bd14978d484f91a3885a81b841ca639e389d76c252bdb1e90
6
+ metadata.gz: 1e03ca44f4700ac019b97995bfb7e2c52d281e2357accb77a007f9ad8589f6fb862d0c67910500195925d90d7944a5fec68a5ffbd4dba1835a7a44f593b8b5b2
7
+ data.tar.gz: 75a8d285074080eb20731ae14a6c4c9713820f7d5bc3513deecea27ba9e51cb786ed8a574dd201d122223c5241343a5a991cf5c051a9393c3178dfc46d0acfb3
data/.travis.yml CHANGED
@@ -1,8 +1,16 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  rvm:
4
- - 2.2.5
5
- - 2.3.1
4
+ - 2.2.6
5
+ - 2.3.3
6
+ - 2.4.0
7
+ before_install:
8
+ - gem update --system
9
+ - gem update bundler
6
10
  gemfile:
7
11
  - gemfiles/rails_4.2.gemfile
8
12
  - gemfiles/rails_5.0.gemfile
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: 2.4.0
16
+ gemfile: gemfiles/rails_4.2.gemfile
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.8] - 2017-02-17
8
+ ### Fixed
9
+ - Avoid circular dependency on destroy
10
+
11
+ ## [2.0.7] - 2017-02-17 [YANKED]
12
+ ### Fixed
13
+ - Set reference to submodel when building supermodel
14
+
7
15
  ## [2.0.6] - 2017-02-17
8
16
  ### Added
9
17
  - Allow arguments to #touch and forward them to the supermodel
@@ -41,7 +49,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
41
49
  ### Fixed
42
50
  - Fixed `remove_actable` migration helper (https://github.com/hzamani/active_record-acts_as/pull/71, thanks to [nuclearpidgeon](https://github.com/nuclearpidgeon)!)
43
51
 
44
- [Unreleased]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.6...HEAD
52
+ [Unreleased]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.7...HEAD
53
+ [2.0.7]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.6...v2.0.7
45
54
  [2.0.6]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.5...v2.0.6
46
55
  [2.0.5]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.4...v2.0.5
47
56
  [2.0.4]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.3...v2.0.4
@@ -8,7 +8,7 @@ module ActiveRecord
8
8
  options, scope = scope, nil if Hash === scope
9
9
  association_method = options.delete(:association_method)
10
10
  touch = options.delete(:touch)
11
- options = {as: :actable, dependent: :destroy, validate: false, autosave: true}.merge options
11
+ options = options.reverse_merge(as: :actable, validate: false, autosave: true)
12
12
 
13
13
  cattr_reader(:validates_actable) { options.delete(:validates_actable) == false ? false : true }
14
14
 
@@ -36,11 +36,15 @@ module ActiveRecord
36
36
  after_commit do
37
37
  @_acting_as_changed = nil
38
38
  end
39
+ # Workaround for https://github.com/rails/rails/issues/13609
40
+ after_destroy do
41
+ acting_as.destroy if acting_as && !acting_as.destroyed?
42
+ end
39
43
 
40
44
  cattr_reader(:acting_as_reflection) { reflections.stringify_keys[name.to_s] }
41
45
  cattr_reader(:acting_as_name) { name.to_s }
42
46
  cattr_reader(:acting_as_model) { (options[:class_name] || name.to_s.camelize).constantize }
43
- class_eval "def #{name}; super || build_#{name} end"
47
+ class_eval "def #{name}; super || build_#{name}(acting_as_model.actable_reflection.name => self); end"
44
48
  alias_method :acting_as, name
45
49
  alias_method :acting_as=, "#{name}=".to_sym
46
50
 
@@ -1,6 +1,6 @@
1
1
  module ActiveRecord
2
2
  module ActsAs
3
- VERSION = "2.0.6"
3
+ VERSION = "2.0.8"
4
4
  end
5
5
  end
6
6
 
data/spec/acts_as_spec.rb CHANGED
@@ -80,9 +80,9 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
80
80
  end
81
81
 
82
82
  describe "#acting_as" do
83
- it "returns autobuilded acts_as model" do
84
- expect(pen.acting_as).to_not be_nil
83
+ it "builds acts_as model with actable relation set" do
85
84
  expect(pen.acting_as).to be_instance_of(Product)
85
+ expect(pen.acting_as.actable).to be_instance_of(Pen)
86
86
  end
87
87
  end
88
88
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record-acts_as
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hassan Zamani
@@ -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.8
167
+ rubygems_version: 2.6.6
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: Simulate multi-table inheritance for activerecord models
@@ -177,3 +177,4 @@ test_files:
177
177
  - spec/models.rb
178
178
  - spec/rspec_matchers_spec.rb
179
179
  - spec/spec_helper.rb
180
+ has_rdoc: