active_record-acts_as 4.0.3 → 5.0.0

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
  SHA256:
3
- metadata.gz: ad7cc10dec0e65531ba3493f3951fbd8136fb858d1fc757494faf84d5e70262d
4
- data.tar.gz: 18a893ad2fc804c09db7d9adb219367e64c191cf1f7a9d4f582f39f9a68de548
3
+ metadata.gz: 5bfaa5ca9169073f3896b1aeb86e905e604630d82c41a94ab3686f32da5b6dd7
4
+ data.tar.gz: e7be68ef37b33ff53696b87fa340ba7cd824219907db046f0be8b34631c7b3af
5
5
  SHA512:
6
- metadata.gz: 31d62e2fdd9c141b5081d1db2357b546cd2e6306cd994f14079eaea309e65744457c0eb39782f644227513910c967de62da280d525fc6580b694e510d2501b96
7
- data.tar.gz: c193592e2c20f3820ea80857bea2a8310e18d740637913f64429f4981c62bfad52bb7869c8ce80b8302ef8572d5f6b5674f5c098fd44210fdf1f001bbf9068eb
6
+ metadata.gz: 340035e0b4f8d725a9789e59c54f104c154dc3a142a3e0ba3e32d70ecf7742dfebb5fd8027360451f3e0b63295014ddc231f38d61e7b6e599ece65f39ae4cb19
7
+ data.tar.gz: 7c0ec150bc1d2a64eb2831208919b146f51a35c8397fbf3cd5069353e0ae67f41d28be2afd7da9268f4d65c1489a505d311791c0af037425370d77efbbbc20f7
@@ -1,13 +1,12 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  rvm:
4
- - 2.4
5
- - 2.5
6
4
  - 2.6
5
+ - 2.7
6
+ - 3.0
7
7
  before_install:
8
8
  - gem update --system
9
9
  gemfile:
10
- - gemfiles/rails_4.2.gemfile
11
- - gemfiles/rails_5.0.gemfile
12
- - gemfiles/rails_5.1.gemfile
13
- - gemfiles/rails_5.2.gemfile
10
+ - gemfiles/rails_6.0.gemfile
11
+ - gemfiles/rails_6.1.gemfile
12
+ - gemfiles/rails_master.gemfile
data/Appraisals CHANGED
@@ -1,23 +1,11 @@
1
- appraise 'rails-4.2' do
2
- gem 'rails', '~> 4.2.0'
1
+ appraise "rails-6.0" do
2
+ gem 'rails', '~> 6.0'
3
3
  end
4
4
 
5
- appraise 'rails-5.0' do
6
- gem 'rails', '~> 5.0.0'
5
+ appraise "rails-6.1" do
6
+ gem 'rails', '~> 6.1'
7
7
  end
8
8
 
9
- appraise 'rails-5.1' do
10
- gem 'rails', '~> 5.1.0'
11
- end
12
-
13
- appraise 'rails-5.2.1' do
14
- gem 'rails', '5.2.1'
15
- end
16
-
17
- appraise 'rails-5.2.1.1' do
18
- gem 'rails', '5.2.1.1'
19
- end
20
-
21
- appraise 'rails-5.2' do
22
- gem 'rails', '~> 5.2.0'
9
+ appraise "rails-master" do
10
+ gem 'rails', github: 'rails/rails'
23
11
  end
@@ -4,6 +4,29 @@ 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
+ ## [Unreleased] -
8
+
9
+ ## [5.0.0] - 2019-12-29 by @chaadow
10
+ ### Added
11
+ - Add support for rails 6 and 6.1 while removing rails 4.x and 5.x
12
+ from the travis matrix.
13
+ - Remove last ruby 3 warnings and make the gem **totally compatible with
14
+ ruby 3**
15
+ - Add support for rails master ( aka rails 6.2) to catch any upcoming
16
+ breaking change up front.
17
+ - bump minimum ruby version to 2.5
18
+ - Update test coverage
19
+
20
+ ### Fixed
21
+ - Fix `#touch` API to match rails 5/6 API and make it ruby 3 compatible
22
+ - collection methods such as `<<` work now under rails 6.1
23
+ - Prepare for Rails 6.2 breaking change by updating how errors
24
+ are accessed and removing warning. They are now ruby objects.
25
+ see [this](https://api.rubyonrails.org/v6.1.0/classes/ActiveModel/Errors.html)
26
+
27
+ ### Removed
28
+ - Remove support for rails 4.x and 5.x
29
+
7
30
  ## [4.0.0] - 2019-01-09
8
31
 
9
32
  ## [3.1.0] - 2018-12-13
@@ -37,10 +60,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
37
60
 
38
61
  ## [2.3.0] - 2017-04-12
39
62
  ### Fixed
40
- - Prevent duplicate validation errors (fixes https://github.com/manuelmeurer/active_record-acts_as/issues/2)
63
+ - Prevent duplicate validation errors (fixes https://github.com/chaadow/active_record-acts_as/issues/2)
41
64
 
42
65
  ### Added
43
- - Added support for touching submodel attributes (https://github.com/manuelmeurer/active_record-acts_as/pull/3, thanks to [dezmathio](https://github.com/dezmathio)!)
66
+ - Added support for touching submodel attributes (https://github.com/chaadow/active_record-acts_as/pull/3, thanks to [dezmathio](https://github.com/dezmathio)!)
44
67
 
45
68
  ## [2.2.1] - 2017-04-08
46
69
  ### Fixed
@@ -107,38 +130,39 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
107
130
  ### Fixed
108
131
  - Fixed `remove_actable` migration helper (https://github.com/hzamani/active_record-acts_as/pull/71, thanks to [nuclearpidgeon](https://github.com/nuclearpidgeon)!)
109
132
 
110
- [Unreleased]: https://github.com/manuelmeurer/active_record-acts_as/compare/v4.0.0...HEAD
111
- [3.1.0]: https://github.com/manuelmeurer/active_record-acts_as/compare/v3.1.0...v4.0.0
112
- [3.0.2]: https://github.com/manuelmeurer/active_record-acts_as/compare/v3.0.1...v3.0.2
113
- [3.0.1]: https://github.com/manuelmeurer/active_record-acts_as/compare/v3.0.0...v3.0.1
114
- [3.0.0]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.5.0...v3.0.0
115
- [2.5.0]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.4.2...v2.5.0
116
- [2.4.2]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.4.1...v2.4.2
117
- [2.4.1]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.4.0...v2.4.1
118
- [2.4.0]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.3.1...v2.4.0
119
- [2.3.1]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.3.0...v2.3.1
120
- [2.3.0]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.2.1...v2.3.0
121
- [2.2.1]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.2.0...v2.2.1
122
- [2.2.0]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.1.1...v2.2.0
123
- [2.1.1]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.1.0...v2.1.1
124
- [2.1.0]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.0.9...v2.1.0
125
- [2.0.9]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.0.8...v2.0.9
126
- [2.0.8]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.0.7...v2.0.8
127
- [2.0.7]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.0.6...v2.0.7
128
- [2.0.6]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.0.5...v2.0.6
129
- [2.0.5]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.0.4...v2.0.5
130
- [2.0.4]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.0.3...v2.0.4
131
- [2.0.3]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.0.2...v2.0.3
132
- [2.0.2]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.0.1...v2.0.2
133
- [2.0.1]: https://github.com/manuelmeurer/active_record-acts_as/compare/v2.0.0...v2.0.1
134
- [2.0.0]: https://github.com/manuelmeurer/active_record-acts_as/compare/v1.0.8...v2.0.0
135
- [1.0.8]: https://github.com/manuelmeurer/active_record-acts_as/compare/v1.0.7...v1.0.8
136
- [1.0.7]: https://github.com/manuelmeurer/active_record-acts_as/compare/v1.0.6...v1.0.7
137
- [1.0.6]: https://github.com/manuelmeurer/active_record-acts_as/compare/v1.0.5...v1.0.6
138
- [1.0.5]: https://github.com/manuelmeurer/active_record-acts_as/compare/v1.0.4...v1.0.5
139
- [1.0.4]: https://github.com/manuelmeurer/active_record-acts_as/compare/v1.0.3...v1.0.4
140
- [1.0.3]: https://github.com/manuelmeurer/active_record-acts_as/compare/v1.0.2...v1.0.3
141
- [1.0.2]: https://github.com/manuelmeurer/active_record-acts_as/compare/v1.0.1...v1.0.2
142
- [1.0.1]: https://github.com/manuelmeurer/active_record-acts_as/compare/v1.0.0...v1.0.1
143
- [1.0.0]: https://github.com/manuelmeurer/active_record-acts_as/compare/v1.0.0.rc...v1.0.0
144
- [1.0.0.rc]: https://github.com/manuelmeurer/active_record-acts_as/compare/v1.0.0.pre...v1.0.0.rc
133
+ [Unreleased]: https://github.com/chaadow/active_record-acts_as/compare/v5.0.0...HEAD
134
+ [5.0.0]: https://github.com/chaadow/active_record-acts_as/compare/v4.0.0...v5.0.0
135
+ [3.1.0]: https://github.com/chaadow/active_record-acts_as/compare/v3.1.0...v4.0.0
136
+ [3.0.2]: https://github.com/chaadow/active_record-acts_as/compare/v3.0.1...v3.0.2
137
+ [3.0.1]: https://github.com/chaadow/active_record-acts_as/compare/v3.0.0...v3.0.1
138
+ [3.0.0]: https://github.com/chaadow/active_record-acts_as/compare/v2.5.0...v3.0.0
139
+ [2.5.0]: https://github.com/chaadow/active_record-acts_as/compare/v2.4.2...v2.5.0
140
+ [2.4.2]: https://github.com/chaadow/active_record-acts_as/compare/v2.4.1...v2.4.2
141
+ [2.4.1]: https://github.com/chaadow/active_record-acts_as/compare/v2.4.0...v2.4.1
142
+ [2.4.0]: https://github.com/chaadow/active_record-acts_as/compare/v2.3.1...v2.4.0
143
+ [2.3.1]: https://github.com/chaadow/active_record-acts_as/compare/v2.3.0...v2.3.1
144
+ [2.3.0]: https://github.com/chaadow/active_record-acts_as/compare/v2.2.1...v2.3.0
145
+ [2.2.1]: https://github.com/chaadow/active_record-acts_as/compare/v2.2.0...v2.2.1
146
+ [2.2.0]: https://github.com/chaadow/active_record-acts_as/compare/v2.1.1...v2.2.0
147
+ [2.1.1]: https://github.com/chaadow/active_record-acts_as/compare/v2.1.0...v2.1.1
148
+ [2.1.0]: https://github.com/chaadow/active_record-acts_as/compare/v2.0.9...v2.1.0
149
+ [2.0.9]: https://github.com/chaadow/active_record-acts_as/compare/v2.0.8...v2.0.9
150
+ [2.0.8]: https://github.com/chaadow/active_record-acts_as/compare/v2.0.7...v2.0.8
151
+ [2.0.7]: https://github.com/chaadow/active_record-acts_as/compare/v2.0.6...v2.0.7
152
+ [2.0.6]: https://github.com/chaadow/active_record-acts_as/compare/v2.0.5...v2.0.6
153
+ [2.0.5]: https://github.com/chaadow/active_record-acts_as/compare/v2.0.4...v2.0.5
154
+ [2.0.4]: https://github.com/chaadow/active_record-acts_as/compare/v2.0.3...v2.0.4
155
+ [2.0.3]: https://github.com/chaadow/active_record-acts_as/compare/v2.0.2...v2.0.3
156
+ [2.0.2]: https://github.com/chaadow/active_record-acts_as/compare/v2.0.1...v2.0.2
157
+ [2.0.1]: https://github.com/chaadow/active_record-acts_as/compare/v2.0.0...v2.0.1
158
+ [2.0.0]: https://github.com/chaadow/active_record-acts_as/compare/v1.0.8...v2.0.0
159
+ [1.0.8]: https://github.com/chaadow/active_record-acts_as/compare/v1.0.7...v1.0.8
160
+ [1.0.7]: https://github.com/chaadow/active_record-acts_as/compare/v1.0.6...v1.0.7
161
+ [1.0.6]: https://github.com/chaadow/active_record-acts_as/compare/v1.0.5...v1.0.6
162
+ [1.0.5]: https://github.com/chaadow/active_record-acts_as/compare/v1.0.4...v1.0.5
163
+ [1.0.4]: https://github.com/chaadow/active_record-acts_as/compare/v1.0.3...v1.0.4
164
+ [1.0.3]: https://github.com/chaadow/active_record-acts_as/compare/v1.0.2...v1.0.3
165
+ [1.0.2]: https://github.com/chaadow/active_record-acts_as/compare/v1.0.1...v1.0.2
166
+ [1.0.1]: https://github.com/chaadow/active_record-acts_as/compare/v1.0.0...v1.0.1
167
+ [1.0.0]: https://github.com/chaadow/active_record-acts_as/compare/v1.0.0.rc...v1.0.0
168
+ [1.0.0.rc]: https://github.com/chaadow/active_record-acts_as/compare/v1.0.0.pre...v1.0.0.rc
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/active_record-acts_as.svg)](http://badge.fury.io/rb/active_record-acts_as)
2
- [![Build Status](https://travis-ci.org/manuelmeurer/active_record-acts_as.svg)](https://travis-ci.org/manuelmeurer/active_record-acts_as)
2
+ [![Build Status](https://travis-ci.org/chaadow/active_record-acts_as.svg)](https://travis-ci.org/chaadow/active_record-acts_as)
3
3
 
4
4
  # ActiveRecord::ActsAs
5
5
 
@@ -18,9 +18,11 @@ a separate table for each product type, i.e. a `pens` table with `color` column.
18
18
 
19
19
  ## Requirements
20
20
 
21
- * Ruby >= 2.4
22
- * ActiveSupport >= 4.2
23
- * ActiveRecord >= 4.2
21
+ * Ruby >= `2.5`
22
+ * ActiveSupport >= `6.0`
23
+ * ActiveRecord >= `6.0`
24
+ * Regarding ActiveRecord `5.2.x` please use version `4.0.3` of this gem. If you encounter any bug you can open an issue.
25
+ Maintenance will be stopped after the release of ActiveRecord `6.2`
24
26
 
25
27
  ## Installation
26
28
 
@@ -217,7 +219,7 @@ end
217
219
 
218
220
  ## Contributing
219
221
 
220
- 1. Fork it (https://github.com/manuelmeurer/active_record-acts_as/fork)
222
+ 1. Fork it (https://github.com/chaadow/active_record-acts_as/fork)
221
223
  2. Create your feature branch (`git checkout -b my-new-feature`)
222
224
  3. Test changes don't break anything (`rspec`)
223
225
  4. Add specs for your new feature
@@ -6,11 +6,11 @@ require 'active_record/acts_as/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "active_record-acts_as"
8
8
  spec.version = ActiveRecord::ActsAs::VERSION
9
- spec.authors = ["Hassan Zamani", "Manuel Meurer"]
10
- spec.email = ["hsn.zamani@gmail.com", "manuel@krautcomputing.com"]
9
+ spec.authors = ["Hassan Zamani", "Manuel Meurer", "Chedli Bourguiba"]
10
+ spec.email = ["hsn.zamani@gmail.com", "manuel@krautcomputing.com", "bourguiba.chedli@gmail.com"]
11
11
  spec.summary = %q{Simulate multi-table inheritance for activerecord models}
12
12
  spec.description = %q{Simulate multi-table inheritance for activerecord models using a polymorphic association}
13
- spec.homepage = "http://github.com/manuelmeurer/active_record-acts_as"
13
+ spec.homepage = "http://github.com/chaadow/active_record-acts_as"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -18,15 +18,16 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.required_ruby_version = ">= 2.4"
21
+ spec.required_ruby_version = ">= 2.5"
22
22
 
23
- spec.add_development_dependency "sqlite3", "~> 1.3.6"
23
+ spec.add_development_dependency "sqlite3"
24
24
  spec.add_development_dependency "bundler"
25
25
  spec.add_development_dependency "rspec", "~> 3"
26
26
  spec.add_development_dependency "rake", "~> 10"
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"
31
- spec.add_dependency "activerecord", ">= 4.2"
30
+ spec.add_dependency "activesupport", ">= 6.0"
31
+ spec.add_dependency "activerecord", ">= 6.0"
32
+
32
33
  end
@@ -3,6 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "coveralls", require: false
6
- gem "rails", "5.2.1"
6
+ gem "rails", "~> 6.0"
7
7
 
8
8
  gemspec path: "../"
@@ -3,6 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "coveralls", require: false
6
- gem "rails", "5.2.1.1"
6
+ gem "rails", "~> 6.1"
7
7
 
8
8
  gemspec path: "../"
@@ -3,6 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "coveralls", require: false
6
- gem "rails", "~> 4.2.0"
6
+ gem "rails", git: 'https://github.com/rails/rails.git'
7
7
 
8
8
  gemspec path: "../"
@@ -19,8 +19,8 @@ module ActiveRecord
19
19
 
20
20
  def actable_must_be_valid
21
21
  unless acting_as.valid?
22
- acting_as.errors.each do |attribute, message|
23
- errors.add(attribute, message) unless errors[attribute].include?(message)
22
+ acting_as.errors.each do |error|
23
+ errors.add(error.attribute, error.message) unless errors[error.attribute].include?(error.message)
24
24
  end
25
25
  end
26
26
  end
@@ -42,6 +42,14 @@ module ActiveRecord
42
42
  end
43
43
  end
44
44
 
45
+ def _write_attribute(attr_name, value, *args, &block)
46
+ if attribute_method?(attr_name.to_s)
47
+ super
48
+ else
49
+ acting_as.send(:_write_attribute, attr_name, value, *args, &block)
50
+ end
51
+ end
52
+
45
53
  def read_store_attribute(store_attribute, key)
46
54
  if attribute_method?(store_attribute.to_s)
47
55
  super
@@ -83,10 +91,10 @@ module ActiveRecord
83
91
  end
84
92
  end
85
93
 
86
- def touch(*args)
94
+ def touch(*args, time: nil)
87
95
  self_args, acting_as_args = args.partition { |arg| has_attribute?(arg, true) }
88
- super(*self_args) if self_args.any?
89
- acting_as.touch(*acting_as_args) if acting_as.persisted?
96
+ super(*self_args, time: time) if self_args.any?
97
+ acting_as.touch(*acting_as_args, time: time) if acting_as.persisted?
90
98
  end
91
99
 
92
100
  def respond_to?(name, include_private = false, as_original_class = false)
@@ -2,20 +2,20 @@ module ActiveRecord
2
2
  module ActsAs
3
3
  module Migration
4
4
  module TableDefinition
5
- def actable(options = {})
5
+ def actable(**options)
6
6
  name = options.delete(:as) || :actable
7
7
  options[:polymorphic] = true
8
- references(name, options)
8
+ references(name, **options)
9
9
  end
10
10
  end
11
11
 
12
12
  module Table
13
13
  include TableDefinition
14
14
 
15
- def remove_actable(options = {})
15
+ def remove_actable(**options)
16
16
  name = options.delete(:as) || :actable
17
17
  options[:polymorphic] = true
18
- @base.remove_reference(@name, name, options)
18
+ @base.remove_reference(@name, name, **options)
19
19
  end
20
20
  end
21
21
  end
@@ -28,13 +28,7 @@ module ActiveRecord
28
28
 
29
29
  module ScopeForCreate
30
30
  def scope_for_create(attributes = nil)
31
- unless acting_as?
32
- if Gem::Dependency.new('', '>= 5.2.1', '< 5.2.2').match?('', ActiveRecord.version)
33
- return super(attributes)
34
- else
35
- return super()
36
- end
37
- end
31
+ return super() unless acting_as?
38
32
 
39
33
  scope = respond_to?(:values_for_create) ? values_for_create(attributes) : where_values_hash
40
34
  scope.merge!(where_values_hash(acting_as_model.table_name))
@@ -28,11 +28,11 @@ module ActiveRecord
28
28
  validate :actable_must_be_valid if validates_actable
29
29
 
30
30
  unless touch == false
31
- after_update :touch, if: ActiveRecord.version.to_s.to_f >= 5.1 ? :saved_changes? : :changed?
31
+ after_update :touch, if: :saved_changes?
32
32
  end
33
33
 
34
34
  before_save do
35
- @_acting_as_changed = ActiveRecord.version.to_s.to_f >= 5.1 ? acting_as.has_changes_to_save? : acting_as.changed?
35
+ @_acting_as_changed = acting_as.has_changes_to_save?
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 = "4.0.3"
3
+ VERSION = "5.0.0"
4
4
  end
5
5
  end
6
6
 
@@ -221,10 +221,11 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
221
221
 
222
222
  context 'touching' do
223
223
  describe '#touch with arguments' do
224
- it "forwards supermodel arguments tothe supermodel" do
224
+ it "forwards supermodel arguments to the supermodel" do
225
+ now = Time.current
225
226
  pen.save!
226
- expect(pen.product).to receive(:touch).with(:updated_at)
227
- pen.touch(:updated_at, :designed_at)
227
+ expect(pen.product).to receive(:touch).with(:updated_at, {time: now})
228
+ pen.touch(:updated_at, time: now)
228
229
  end
229
230
 
230
231
  it "updates submodel arguments" do
@@ -236,7 +237,7 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
236
237
  describe '#touch without arguments' do
237
238
  it "touches the supermodel" do
238
239
  pen.save!
239
- expect(pen.product).to receive(:touch).with(no_args)
240
+ expect(pen.product).to receive(:touch).with(time: nil)
240
241
  pen.touch
241
242
  end
242
243
  end
@@ -299,21 +300,21 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
299
300
  it "combines supermodel and submodel errors" do
300
301
  pen = Pen.new
301
302
  expect(pen).to be_invalid
302
- expect(pen.errors.to_h).to eq(
303
- name: "can't be blank",
304
- price: "can't be blank",
305
- color: "can't be blank"
303
+ expect(pen.errors.to_hash).to eq(
304
+ name: ["can't be blank"],
305
+ price: ["can't be blank"],
306
+ color: ["can't be blank"]
306
307
  )
307
308
  pen.name = 'testing'
308
309
  expect(pen).to be_invalid
309
- expect(pen.errors.to_h).to eq(
310
- price: "can't be blank",
311
- color: "can't be blank"
310
+ expect(pen.errors.to_hash).to eq(
311
+ price: ["can't be blank"],
312
+ color: ["can't be blank"]
312
313
  )
313
314
  pen.color = 'red'
314
315
  expect(pen).to be_invalid
315
- expect(pen.errors.to_h).to eq(
316
- price: "can't be blank"
316
+ expect(pen.errors.to_hash).to eq(
317
+ price: ["can't be blank"]
317
318
  )
318
319
  pen.price = 0.8
319
320
  expect(pen).to be_valid
@@ -324,8 +325,8 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
324
325
  it "unless validates_actable is set to false" do
325
326
  pen = IsolatedPen.new
326
327
  expect(pen).to be_invalid
327
- expect(pen.errors.to_h).to eq(
328
- color: "can't be blank"
328
+ expect(pen.errors.to_hash).to eq(
329
+ color: ["can't be blank"]
329
330
  )
330
331
  pen.color = 'red'
331
332
  expect(pen).to be_valid
@@ -402,7 +403,7 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
402
403
  it "returns a query for the actable records" do
403
404
  red_pen = Pen.create!(name: 'red pen', price: 0.8, color: 'red')
404
405
  blue_pen = Pen.create!(name: 'blue pen', price: 0.8, color: 'blue')
405
- black_pen = Pen.create!(name: 'black pen', price: 0.9, color: 'black')
406
+ _black_pen = Pen.create!(name: 'black pen', price: 0.9, color: 'black')
406
407
 
407
408
  actables = Pen.where(price: 0.8).actables
408
409
 
@@ -438,7 +439,7 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
438
439
 
439
440
  context 'when they are defined via `scope`' do
440
441
  it 'can be called from the submodel' do
441
- cheap_pen = Pen.create!(name: 'cheap pen', price: 0.5, color: 'blue')
442
+ _cheap_pen = Pen.create!(name: 'cheap pen', price: 0.5, color: 'blue')
442
443
  expensive_pen = Pen.create!(name: 'expensive pen', price: 1, color: 'red')
443
444
 
444
445
  expect(Product.with_price_higher_than(0.5).to_a).to eq([expensive_pen.acting_as])
@@ -528,6 +529,7 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
528
529
  describe '.scope_for_create' do
529
530
  it 'includes supermodel attributes' do
530
531
  relation = Pen.where(name: 'new name', price: 1.4, color: 'red')
532
+
531
533
  expect(relation.scope_for_create).to include('name')
532
534
  expect(relation.scope_for_create['name']).to eq('new name')
533
535
  end
@@ -562,7 +564,7 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
562
564
  Object.send(:remove_const, :Pen)
563
565
  end
564
566
 
565
- it "should not include the selected attribute when associating using 'eager_load'" do
567
+ it "should include the selected attribute when associating using 'eager_load'" do
566
568
  class Pen < ActiveRecord::Base
567
569
  acts_as :product , {association_method: :eager_load}
568
570
  store_accessor :settings, :option1
@@ -570,7 +572,7 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
570
572
  end
571
573
  Pen.create pen_attributes
572
574
 
573
- expect(Pen.select("'something' as thing").first['thing']).to be_nil
575
+ expect(Pen.select("'something' as thing").first['thing']).to eq 'something'
574
576
  end
575
577
 
576
578
  it "should include the selected attribute in the model when associating using 'includes'" do
metadata CHANGED
@@ -1,30 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record-acts_as
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hassan Zamani
8
8
  - Manuel Meurer
9
+ - Chedli Bourguiba
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2020-07-14 00:00:00.000000000 Z
13
+ date: 2020-12-29 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: sqlite3
16
17
  requirement: !ruby/object:Gem::Requirement
17
18
  requirements:
18
- - - "~>"
19
+ - - ">="
19
20
  - !ruby/object:Gem::Version
20
- version: 1.3.6
21
+ version: '0'
21
22
  type: :development
22
23
  prerelease: false
23
24
  version_requirements: !ruby/object:Gem::Requirement
24
25
  requirements:
25
- - - "~>"
26
+ - - ">="
26
27
  - !ruby/object:Gem::Version
27
- version: 1.3.6
28
+ version: '0'
28
29
  - !ruby/object:Gem::Dependency
29
30
  name: bundler
30
31
  requirement: !ruby/object:Gem::Requirement
@@ -101,33 +102,34 @@ dependencies:
101
102
  requirements:
102
103
  - - ">="
103
104
  - !ruby/object:Gem::Version
104
- version: '4.2'
105
+ version: '6.0'
105
106
  type: :runtime
106
107
  prerelease: false
107
108
  version_requirements: !ruby/object:Gem::Requirement
108
109
  requirements:
109
110
  - - ">="
110
111
  - !ruby/object:Gem::Version
111
- version: '4.2'
112
+ version: '6.0'
112
113
  - !ruby/object:Gem::Dependency
113
114
  name: activerecord
114
115
  requirement: !ruby/object:Gem::Requirement
115
116
  requirements:
116
117
  - - ">="
117
118
  - !ruby/object:Gem::Version
118
- version: '4.2'
119
+ version: '6.0'
119
120
  type: :runtime
120
121
  prerelease: false
121
122
  version_requirements: !ruby/object:Gem::Requirement
122
123
  requirements:
123
124
  - - ">="
124
125
  - !ruby/object:Gem::Version
125
- version: '4.2'
126
+ version: '6.0'
126
127
  description: Simulate multi-table inheritance for activerecord models using a polymorphic
127
128
  association
128
129
  email:
129
130
  - hsn.zamani@gmail.com
130
131
  - manuel@krautcomputing.com
132
+ - bourguiba.chedli@gmail.com
131
133
  executables:
132
134
  - console
133
135
  extensions: []
@@ -146,12 +148,9 @@ files:
146
148
  - _config.yml
147
149
  - active_record-acts_as.gemspec
148
150
  - bin/console
149
- - gemfiles/rails_4.2.gemfile
150
- - gemfiles/rails_5.0.gemfile
151
- - gemfiles/rails_5.1.gemfile
152
- - gemfiles/rails_5.2.1.1.gemfile
153
- - gemfiles/rails_5.2.1.gemfile
154
- - gemfiles/rails_5.2.gemfile
151
+ - gemfiles/rails_6.0.gemfile
152
+ - gemfiles/rails_6.1.gemfile
153
+ - gemfiles/rails_master.gemfile
155
154
  - lib/active_record/acts_as.rb
156
155
  - lib/active_record/acts_as/class_methods.rb
157
156
  - lib/active_record/acts_as/instance_methods.rb
@@ -169,7 +168,7 @@ files:
169
168
  - spec/models.rb
170
169
  - spec/rspec_matchers_spec.rb
171
170
  - spec/spec_helper.rb
172
- homepage: http://github.com/manuelmeurer/active_record-acts_as
171
+ homepage: http://github.com/chaadow/active_record-acts_as
173
172
  licenses:
174
173
  - MIT
175
174
  metadata: {}
@@ -181,14 +180,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
180
  requirements:
182
181
  - - ">="
183
182
  - !ruby/object:Gem::Version
184
- version: '2.4'
183
+ version: '2.5'
185
184
  required_rubygems_version: !ruby/object:Gem::Requirement
186
185
  requirements:
187
186
  - - ">="
188
187
  - !ruby/object:Gem::Version
189
188
  version: '0'
190
189
  requirements: []
191
- rubygems_version: 3.1.3
190
+ rubygems_version: 3.2.3
192
191
  signing_key:
193
192
  specification_version: 4
194
193
  summary: Simulate multi-table inheritance for activerecord models
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "coveralls", require: false
6
- gem "rails", "~> 5.0.0"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "coveralls", require: false
6
- gem "rails", "~> 5.1.0"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
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"
7
-
8
- gemspec path: "../"