active_record-acts_as 2.5.0 → 3.0.0

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
- SHA1:
3
- metadata.gz: 381abee602366b8d970bc208a1819ff1fdcabeca
4
- data.tar.gz: 2d91f0310bc581b9f73082de2f4984c31a0f0345
2
+ SHA256:
3
+ metadata.gz: 9a9bc3e4aeba36e8d79f1ae9da8d8a542d8536a40ef33338bb5b6008b7957816
4
+ data.tar.gz: 9a774bbf389710f7abe0fd2aa8a4e212d0198cdc73c4a454be1054680814280d
5
5
  SHA512:
6
- metadata.gz: 613c0f9a5f14344ca1d69f82ad007b18d12d0089a513eebee7119aeef2e317b05d07e569dd5c31de8e8b1cf5786f69e5ec4e085364355ae9d8438b8dfc6d5755
7
- data.tar.gz: 6f4b3bdbda336c4109150a87bb640f2e5e5e7dbe79963a0713c18a08a1cca8aaf564576c05e474ca9d6478d893d71bbcbaf52c6f1cda3c8c00558ad25eb53117
6
+ metadata.gz: b34df64d7c458ccc596f9d6f3a6ccfb32029c98242406205d87af13b2e2a5dfc0aefb779d2ba81fb36c5f5936c074f64307365ccdc5febddee8f92dee5df4ccf
7
+ data.tar.gz: bdb531a26f0e161e58a637ff4f0c1d81b255c7d252a0f7835cc505a748ba119cd4fdec1ded399af018e9e5141903a54d854253ee2e03315b9fd2a2d1d37cd6f7
data/.travis.yml CHANGED
@@ -11,5 +11,4 @@ gemfile:
11
11
  - gemfiles/rails_4.2.gemfile
12
12
  - gemfiles/rails_5.0.gemfile
13
13
  - gemfiles/rails_5.1.gemfile
14
- allow_failures:
15
- - gemfile: gemfiles/rails_5.1.gemfile
14
+ - gemfiles/rails_5.2.gemfile
data/Appraisals CHANGED
@@ -9,3 +9,7 @@ end
9
9
  appraise 'rails-5.1' do
10
10
  gem 'rails', '~> 5.1.0'
11
11
  end
12
+
13
+ appraise 'rails-5.2' do
14
+ gem 'rails', '~> 5.2.0.rc1'
15
+ end
data/README.md CHANGED
@@ -177,7 +177,7 @@ If your `actable` and `acts_as` models are namespaced, you need to configure the
177
177
 
178
178
  ```
179
179
  class MyApp::Product < ApplicationRecord
180
- actable inverse_of: :pen
180
+ actable inverse_of: :product
181
181
  end
182
182
 
183
183
  class MyApp::Pen < ApplicationRecord
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "appraisal", "~> 2.1"
28
28
  spec.add_development_dependency "guard-rspec", "~> 4.7"
29
29
 
30
- spec.add_dependency "activesupport", ">= 4.2", "<= 5.0"
31
- spec.add_dependency "activerecord", ">= 4.2", "<= 5.0"
30
+ spec.add_dependency "activesupport", ">= 4.2"
31
+ spec.add_dependency "activerecord", ">= 4.2"
32
32
  end
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "coveralls", require: false
6
+ gem "rails", "~> 5.2.0.rc1"
7
+
8
+ gemspec path: "../"
@@ -9,6 +9,10 @@ module ActiveRecord
9
9
  super || acting_as?(klass)
10
10
  end
11
11
 
12
+ def saved_changes?
13
+ super || acting_as.has_changes_to_save? || (defined?(@_acting_as_changed) ? @_acting_as_changed : false)
14
+ end
15
+
12
16
  def changed?
13
17
  super || acting_as.changed? || (defined?(@_acting_as_changed) ? @_acting_as_changed : false)
14
18
  end
@@ -26,12 +26,12 @@ module ActiveRecord
26
26
  end
27
27
 
28
28
  module ScopeForCreate
29
- def scope_for_create
30
- @scope_for_create ||= if acting_as?
31
- where_values_hash.merge(where_values_hash(acting_as_model.table_name)).merge(create_with_value)
32
- else
33
- where_values_hash.merge(create_with_value)
29
+ def scope_for_create(attributes = nil)
30
+ scope = ActiveRecord.version.to_s.to_f >= 5.2 ? super(attributes) : where_values_hash
31
+ if acting_as?
32
+ scope.merge!(where_values_hash(acting_as_model.table_name))
34
33
  end
34
+ scope.merge(create_with_value)
35
35
  end
36
36
  end
37
37
  end
@@ -32,7 +32,7 @@ module ActiveRecord
32
32
  end
33
33
 
34
34
  before_save do
35
- @_acting_as_changed = ActiveRecord.version.to_s.to_f >= 5.1 ? acting_as.saved_changes? : acting_as.changed?
35
+ @_acting_as_changed = ActiveRecord.version.to_s.to_f >= 5.1 ? acting_as.has_changes_to_save? : acting_as.changed?
36
36
  true
37
37
  end
38
38
  after_commit do
@@ -1,6 +1,6 @@
1
1
  module ActiveRecord
2
2
  module ActsAs
3
- VERSION = "2.5.0"
3
+ VERSION = "3.0.0"
4
4
  end
5
5
  end
6
6
 
data/spec/acts_as_spec.rb CHANGED
@@ -496,8 +496,7 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
496
496
  describe '.scope_for_create' do
497
497
  it 'includes supermodel attributes' do
498
498
  relation = Pen.where(name: 'new name', price: 1.4, color: 'red')
499
-
500
- expect(relation.scope_for_create.keys).to include('name')
499
+ expect(relation.scope_for_create).to include('name')
501
500
  expect(relation.scope_for_create['name']).to eq('new name')
502
501
  end
503
502
  end
@@ -516,6 +515,14 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
516
515
  it "has a cattr_reader for the acting_as_model" do
517
516
  expect(subject.acting_as_model).to eq Inventory::ProductFeature
518
517
  end
518
+
519
+ it "can be created" do
520
+ expect(
521
+ Inventory::PenLid.create name: 'steve',
522
+ price: 10.1,
523
+ color: 'beige'
524
+ ).to be_a_kind_of Inventory::PenLid
525
+ end
519
526
  end
520
527
 
521
528
  context 'different association_methods' do
data/spec/models.rb CHANGED
@@ -73,7 +73,7 @@ end
73
73
  module Inventory
74
74
  class ProductFeature < ActiveRecord::Base
75
75
  self.table_name = 'inventory_product_features'
76
- actable
76
+ actable inverse_of: 'product_feature'
77
77
  validates_presence_of :name, :price
78
78
 
79
79
  def present
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.5.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hassan Zamani
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-07-29 00:00:00.000000000 Z
12
+ date: 2018-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sqlite3
@@ -102,9 +102,6 @@ dependencies:
102
102
  - - ">="
103
103
  - !ruby/object:Gem::Version
104
104
  version: '4.2'
105
- - - "<="
106
- - !ruby/object:Gem::Version
107
- version: '5.0'
108
105
  type: :runtime
109
106
  prerelease: false
110
107
  version_requirements: !ruby/object:Gem::Requirement
@@ -112,9 +109,6 @@ dependencies:
112
109
  - - ">="
113
110
  - !ruby/object:Gem::Version
114
111
  version: '4.2'
115
- - - "<="
116
- - !ruby/object:Gem::Version
117
- version: '5.0'
118
112
  - !ruby/object:Gem::Dependency
119
113
  name: activerecord
120
114
  requirement: !ruby/object:Gem::Requirement
@@ -122,9 +116,6 @@ dependencies:
122
116
  - - ">="
123
117
  - !ruby/object:Gem::Version
124
118
  version: '4.2'
125
- - - "<="
126
- - !ruby/object:Gem::Version
127
- version: '5.0'
128
119
  type: :runtime
129
120
  prerelease: false
130
121
  version_requirements: !ruby/object:Gem::Requirement
@@ -132,9 +123,6 @@ dependencies:
132
123
  - - ">="
133
124
  - !ruby/object:Gem::Version
134
125
  version: '4.2'
135
- - - "<="
136
- - !ruby/object:Gem::Version
137
- version: '5.0'
138
126
  description: Simulate multi-table inheritance for activerecord models using a plymorphic
139
127
  association
140
128
  email:
@@ -161,6 +149,7 @@ files:
161
149
  - gemfiles/rails_4.2.gemfile
162
150
  - gemfiles/rails_5.0.gemfile
163
151
  - gemfiles/rails_5.1.gemfile
152
+ - gemfiles/rails_5.2.gemfile
164
153
  - lib/active_record/acts_as.rb
165
154
  - lib/active_record/acts_as/class_methods.rb
166
155
  - lib/active_record/acts_as/instance_methods.rb
@@ -197,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
186
  version: '0'
198
187
  requirements: []
199
188
  rubyforge_project:
200
- rubygems_version: 2.6.12
189
+ rubygems_version: 2.7.6
201
190
  signing_key:
202
191
  specification_version: 4
203
192
  summary: Simulate multi-table inheritance for activerecord models