active_record-acts_as 2.2.0 → 2.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12fa1c4f20906b7d2352269034b053732a66ff54
4
- data.tar.gz: 7589a0647e201e2d3105344038e71aa1bb66508a
3
+ metadata.gz: 343f5f0ec73829580cfedcf39acaf118c672a73b
4
+ data.tar.gz: 07f06e2d9e8102b00030627222b2c9781593396b
5
5
  SHA512:
6
- metadata.gz: e147a8073f32ee2c4ee4bb81c5f13e45e88f2057eac38c8c22b1a7165123a7a5d69550fb719626e76deb2598fa6a9c3b780861c4ff6b31b6f000fc4f33aa33c2
7
- data.tar.gz: 378cf9642978a153cbf16a4c2339d21b9fde016724f540fb0df5dbc3be60f7a7bceca384c5d5098fd311ee18fb8f0e49f772fc9c86e8f9a6d155d18d61e18dd5
6
+ metadata.gz: 6e48b05426332a971ab3b175178ff758ff5a67b38892f1e98c101eb23cdbbc5ae5543b7ed29ff50af4708a03ec2a0ac446547dd7469080b24d7306d28449c13d
7
+ data.tar.gz: f642986b3c589b62663b94641abd58aacb1260e1ae85bc237ab3ef539e6572eb17bee0096989ab6f78ccc1b490ec9012b6532196915bbd880105a467c09937d3
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ 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.2.0] - 2017-04-08
8
+ ### Added
9
+ - Added support for calling superclass methods on the subclass or subclass relations
10
+
7
11
  ## [2.1.1] - 2017-03-22
8
12
  ### Fixed
9
13
  - Fix querying subclass with `where`, for `enum` (and possibly other) attributes the detection whether the attribute is defined on the superclass or subclass didn't work.
@@ -61,7 +65,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
61
65
  ### Fixed
62
66
  - Fixed `remove_actable` migration helper (https://github.com/hzamani/active_record-acts_as/pull/71, thanks to [nuclearpidgeon](https://github.com/nuclearpidgeon)!)
63
67
 
64
- [Unreleased]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.1.1...HEAD
68
+ [Unreleased]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.2.0...HEAD
69
+ [2.2.0]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.1.1...v2.2.0
65
70
  [2.1.1]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.1.0...v2.1.1
66
71
  [2.1.0]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.0.9...v2.1.0
67
72
  [2.0.9]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.0.8...v2.0.9
@@ -8,7 +8,8 @@ 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 = options.reverse_merge(as: :actable, validate: false, autosave: true)
11
+ as = options.delete(:as) || :actable
12
+ options = options.reverse_merge(as: as, validate: false, autosave: true, inverse_of: as)
12
13
 
13
14
  cattr_reader(:validates_actable) { options.delete(:validates_actable) == false ? false : true }
14
15
 
@@ -77,7 +78,7 @@ module ActiveRecord
77
78
  def actable(options = {})
78
79
  name = options.delete(:as) || :actable
79
80
 
80
- reflections = belongs_to(name, options.reverse_merge(polymorphic: true, dependent: :destroy, autosave: true))
81
+ reflections = belongs_to(name, options.reverse_merge(polymorphic: true, dependent: :destroy, autosave: true, inverse_of: to_s.underscore))
81
82
 
82
83
  cattr_reader(:actable_reflection) { reflections.stringify_keys[name.to_s] }
83
84
 
@@ -1,6 +1,6 @@
1
1
  module ActiveRecord
2
2
  module ActsAs
3
- VERSION = "2.2.0"
3
+ VERSION = "2.2.1"
4
4
  end
5
5
  end
6
6
 
data/spec/actable_spec.rb CHANGED
@@ -30,14 +30,19 @@ RSpec.describe "ActiveRecord::Base subclass with #actable" do
30
30
  end
31
31
  end
32
32
 
33
- describe ".specific" do
34
- context "returns specific submodel" do
35
- it "unless the submodel instance association doesn't exist" do
36
- expect(subject.new.specific).to be_nil
33
+ describe "#specific" do
34
+ context "when a submodel instance exists" do
35
+ it 'returns it' do
36
+ pen.save!
37
+ pen.color = 'cyan'
38
+ expect(pen.acting_as.specific).to eq(pen)
39
+ expect(pen.acting_as.specific.color).to eq('cyan')
37
40
  end
38
- it "if the submodel instance association exists" do
39
- pen.save
40
- expect(Product.find(pen.acting_as.id).specific).to eq(pen)
41
+ end
42
+
43
+ context "when no submodel instance exists" do
44
+ it 'returns nil' do
45
+ expect(subject.new.specific).to be_nil
41
46
  end
42
47
  end
43
48
  end
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.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hassan Zamani