active_record-acts_as 1.0.4 → 1.0.5

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: 35b482727f031a96a8549a8a8801a8cd8ee4f2af
4
- data.tar.gz: fbd614d7466868481fae7ea7fe20930c19310124
3
+ metadata.gz: 05ede0788d02924d7ddfff896c7afc9cfd65699e
4
+ data.tar.gz: 6c07973b511504c7fbc59648560a3bab71799620
5
5
  SHA512:
6
- metadata.gz: 60436ebc291619e730fcd600429378d82e4647ae5ed17ddffe3df9c596798b9a7ba0d98000ccd4a59b7ecdd18079d620e14b904c9f1b9c55e7cb3aa3915e9d0f
7
- data.tar.gz: d0c69a18ef2329e3fcdfbc751c73d68ef28ea76f798f2c717e9c5693547443bf401a3a07bd5bc6cc1597b934b05a676c002dfec1fc7b167211c947ef472aed78
6
+ metadata.gz: ec862802c12677bd788fceade3c11d7204163d0d223a477852fbec7a2f617218b8f96f80032c377284d4d6ef62844cff164af7a64af17f95277baf87b0032a60
7
+ data.tar.gz: a1ede8555a018302ca0ce07d48e065f0d920240cceadb4cfb4acda9297f43de92b1f99927d69590e7447352cd945c11ae57c58dd35c24ec79a26f04448570aa2
@@ -10,10 +10,14 @@ module ActiveRecord
10
10
  super || acting_as?(klass)
11
11
  end
12
12
 
13
+ def acting_as_foreign_key
14
+ acting_as[acting_as_reflection.foreign_key]
15
+ end
16
+
13
17
  # Is the superclass persisted to the database?
14
18
  def acting_as_persisted?
15
19
  return false if acting_as.nil?
16
- !acting_as.id.nil? && !acting_as.actable_id.nil?
20
+ !acting_as.id.nil? && !acting_as_foreign_key.nil?
17
21
  end
18
22
 
19
23
  def actable_must_be_valid
@@ -1,6 +1,6 @@
1
1
 
2
2
  module ActiveRecord
3
3
  module ActsAs
4
- VERSION = "1.0.4"
4
+ VERSION = "1.0.5"
5
5
  end
6
6
  end
data/spec/acts_as_spec.rb CHANGED
@@ -82,6 +82,17 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
82
82
  end
83
83
  end
84
84
 
85
+ describe "#acting_as_foreign_key" do
86
+ let(:product_foreign_key_value) do
87
+ pen.acting_as[pen.acting_as.actable_reflection.foreign_key]
88
+ end
89
+ it "return acts_as foreign key value" do
90
+ pen.save
91
+ expect(pen.acting_as_foreign_key).to eq(product_foreign_key_value)
92
+ expect(pen.acting_as_foreign_key).to eq(pen.id)
93
+ end
94
+ end
95
+
85
96
  describe "#acting_as=" do
86
97
  it "sets acts_as model" do
87
98
  product = Product.new(name: 'new product', price: 0.99)
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: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hassan Zamani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-23 00:00:00.000000000 Z
11
+ date: 2015-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3