active_record-acts_as 2.0.9 → 2.1.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
2
  SHA1:
3
- metadata.gz: dfc78a4f0d220edb01b5336e81199401fc1da77c
4
- data.tar.gz: 2d09cdc24ca238012d043badca0a143a67942e2f
3
+ metadata.gz: 72b7784416ad69a0731cce15396045c59b98c4c2
4
+ data.tar.gz: 7afa85a1598de8f937c6c6c91b7eea2b97862c09
5
5
  SHA512:
6
- metadata.gz: 2afb1348df5ac807e39ffaa3ad9cad8ca02fb6177d39a20f03dbedb80f1abab1750096d20c1db652846f81c933c4caecfa8627306032bebb8843dc66e3314052
7
- data.tar.gz: ba3005c9fcf570174d6908a939209d0df816b147090554946a6b6321af61d0b25bd950f85d1ce8649473c6db74ef08a71b2175b78c2fe4c19afa1d0d1607dc6f
6
+ metadata.gz: b789d5515ffe491052354386627199337c2ca975513d41755a0519d07158ea9393da5e346c501af60efe23c604dd1ad9f70f0e9cd7507738c0e3846c4a870fb0
7
+ data.tar.gz: 9c2c0991e5ce87f8b39eb04898fa0e2c8aa9469e29ee388f6b2a9e9b644f6dd91c858007bb45fe3d00727e0f8b492c2496150dff5614132ac0b03ea9a50148e8
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.0.9] - 2017-03-02
8
+ ### Fixed
9
+ - Fix handling of query conditions that contain a dot
10
+
7
11
  ## [2.0.8] - 2017-02-17
8
12
  ### Fixed
9
13
  - Avoid circular dependency on destroy
@@ -49,22 +53,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
49
53
  ### Fixed
50
54
  - Fixed `remove_actable` migration helper (https://github.com/hzamani/active_record-acts_as/pull/71, thanks to [nuclearpidgeon](https://github.com/nuclearpidgeon)!)
51
55
 
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
54
- [2.0.6]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.5...v2.0.6
55
- [2.0.5]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.4...v2.0.5
56
- [2.0.4]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.3...v2.0.4
57
- [2.0.3]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.2...v2.0.3
58
- [2.0.2]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.1...v2.0.2
59
- [2.0.1]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.0...v2.0.1
60
- [2.0.0]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.8...v2.0.0
61
- [1.0.8]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.7...v1.0.8
62
- [1.0.7]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.6...v1.0.7
63
- [1.0.6]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.5...v1.0.6
64
- [1.0.5]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.4...v1.0.5
65
- [1.0.4]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.3...v1.0.4
66
- [1.0.3]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.2...v1.0.3
67
- [1.0.2]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.1...v1.0.2
68
- [1.0.1]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.0...v1.0.1
69
- [1.0.0]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.0.rc...v1.0.0
70
- [1.0.0.rc]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.0.pre...v1.0.0.rc
56
+ [Unreleased]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.0.9...HEAD
57
+ [2.0.9]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.0.8...v2.0.9
58
+ [2.0.8]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.0.7...v2.0.8
59
+ [2.0.7]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.0.6...v2.0.7
60
+ [2.0.6]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.0.5...v2.0.6
61
+ [2.0.5]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.0.4...v2.0.5
62
+ [2.0.4]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.0.3...v2.0.4
63
+ [2.0.3]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.0.2...v2.0.3
64
+ [2.0.2]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.0.1...v2.0.2
65
+ [2.0.1]: https://github.com/krautcomputing/active_record-acts_as/compare/v2.0.0...v2.0.1
66
+ [2.0.0]: https://github.com/krautcomputing/active_record-acts_as/compare/v1.0.8...v2.0.0
67
+ [1.0.8]: https://github.com/krautcomputing/active_record-acts_as/compare/v1.0.7...v1.0.8
68
+ [1.0.7]: https://github.com/krautcomputing/active_record-acts_as/compare/v1.0.6...v1.0.7
69
+ [1.0.6]: https://github.com/krautcomputing/active_record-acts_as/compare/v1.0.5...v1.0.6
70
+ [1.0.5]: https://github.com/krautcomputing/active_record-acts_as/compare/v1.0.4...v1.0.5
71
+ [1.0.4]: https://github.com/krautcomputing/active_record-acts_as/compare/v1.0.3...v1.0.4
72
+ [1.0.3]: https://github.com/krautcomputing/active_record-acts_as/compare/v1.0.2...v1.0.3
73
+ [1.0.2]: https://github.com/krautcomputing/active_record-acts_as/compare/v1.0.1...v1.0.2
74
+ [1.0.1]: https://github.com/krautcomputing/active_record-acts_as/compare/v1.0.0...v1.0.1
75
+ [1.0.0]: https://github.com/krautcomputing/active_record-acts_as/compare/v1.0.0.rc...v1.0.0
76
+ [1.0.0.rc]: https://github.com/krautcomputing/active_record-acts_as/compare/v1.0.0.pre...v1.0.0.rc
data/Guardfile ADDED
@@ -0,0 +1,15 @@
1
+ guard :rspec, cmd: 'bundle exec rspec' do
2
+ require 'guard/rspec/dsl'
3
+
4
+ dsl = Guard::RSpec::Dsl.new(self)
5
+
6
+ # RSpec files
7
+ rspec = dsl.rspec
8
+ watch(rspec.spec_helper) { rspec.spec_dir }
9
+ watch(rspec.spec_support) { rspec.spec_dir }
10
+ watch(rspec.spec_files)
11
+
12
+ # Ruby files
13
+ ruby = dsl.ruby
14
+ dsl.watch_spec_files_for(ruby.lib_files)
15
+ end
data/README.md CHANGED
@@ -1,8 +1,8 @@
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/hzamani/active_record-acts_as.svg)](https://travis-ci.org/hzamani/active_record-acts_as)
3
- [![Code Climate](https://codeclimate.com/github/hzamani/active_record-acts_as.png)](https://codeclimate.com/github/hzamani/active_record-acts_as)
4
- [![Coverage Status](https://coveralls.io/repos/hzamani/active_record-acts_as/badge.png)](https://coveralls.io/r/hzamani/active_record-acts_as)
5
- [![Dependency Status](https://gemnasium.com/hzamani/active_record-acts_as.svg)](https://gemnasium.com/hzamani/active_record-acts_as)
2
+ [![Build Status](https://travis-ci.org/krautcomputing/active_record-acts_as.svg)](https://travis-ci.org/krautcomputing/active_record-acts_as)
3
+ [![Code Climate](https://codeclimate.com/github/krautcomputing/active_record-acts_as.png)](https://codeclimate.com/github/krautcomputing/active_record-acts_as)
4
+ [![Coverage Status](https://coveralls.io/repos/krautcomputing/active_record-acts_as/badge.png)](https://coveralls.io/r/krautcomputing/active_record-acts_as)
5
+ [![Dependency Status](https://gemnasium.com/krautcomputing/active_record-acts_as.svg)](https://gemnasium.com/krautcomputing/active_record-acts_as)
6
6
 
7
7
  # ActiveRecord::ActsAs
8
8
 
@@ -202,7 +202,7 @@ end
202
202
 
203
203
  ## Contributing
204
204
 
205
- 1. Fork it ( https://github.com/hzamani/active_record-acts_as/fork )
205
+ 1. Fork it ( https://github.com/krautcomputing/active_record-acts_as/fork )
206
206
  2. Create your feature branch (`git checkout -b my-new-feature`)
207
207
  3. Test changes don't break anything (`rspec`)
208
208
  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"]
10
- spec.email = ["hsn.zamani@gmail.com"]
9
+ spec.authors = ["Hassan Zamani", "Manuel Meurer"]
10
+ spec.email = ["hsn.zamani@gmail.com", "manuel@krautcomputing.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 plymorphic association}
13
- spec.homepage = "http://github.com/hzamani/active_record-acts_as"
13
+ spec.homepage = "http://github.com/krautcomputing/active_record-acts_as"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
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
+ spec.add_development_dependency "guard-rspec", "~> 4.7"
28
29
 
29
30
  spec.add_dependency "activesupport", ">= 4.2"
30
31
  spec.add_dependency "activerecord", ">= 4.2"
@@ -14,6 +14,10 @@ module ActiveRecord
14
14
  def validators_on(*args)
15
15
  super + acting_as_model.validators_on(*args)
16
16
  end
17
+
18
+ def actables
19
+ acting_as_model.where(actable_id: select(:id))
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -10,7 +10,7 @@ module ActiveRecord
10
10
  end
11
11
 
12
12
  def changed?
13
- super || acting_as.changed? || @_acting_as_changed
13
+ super || acting_as.changed? || (defined?(@_acting_as_changed) ? @_acting_as_changed : false)
14
14
  end
15
15
 
16
16
  def acting_as_foreign_key
@@ -68,11 +68,11 @@ module ActiveRecord
68
68
  private :write_attribute, :write_store_attribute
69
69
 
70
70
  def attributes
71
- acting_as_persisted? ? acting_as.attributes.except(acting_as_reflection.type, acting_as_reflection.foreign_key).merge(super) : super
71
+ acting_as.attributes.except(acting_as_reflection.type, acting_as_reflection.foreign_key).merge(super)
72
72
  end
73
73
 
74
74
  def attribute_names
75
- acting_as_persisted? ? super | (acting_as.attribute_names - [acting_as_reflection.type, acting_as_reflection.foreign_key]) : super
75
+ super | (acting_as.attribute_names - [acting_as_reflection.type, acting_as_reflection.foreign_key])
76
76
  end
77
77
 
78
78
  def has_attribute?(attr_name, as_original_class = false)
@@ -1,6 +1,6 @@
1
1
  module ActiveRecord
2
2
  module ActsAs
3
- VERSION = "2.0.9"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
6
6
 
data/spec/acts_as_spec.rb CHANGED
@@ -306,6 +306,7 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
306
306
  p.price = 0.8
307
307
  expect(p).to be_valid
308
308
  end
309
+
309
310
  it "unless validates_actable is set to false" do
310
311
  p = IsolatedPen.new
311
312
  expect(p).to be_invalid
@@ -345,46 +346,42 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
345
346
  store.products << pen
346
347
  expect(pen.store).to eq(store)
347
348
  end
349
+ end
348
350
 
349
- context "includes supermodel attributes in .to_json response" do
350
- it "unless the submodel instance association doesn't exist" do
351
- expect(JSON.parse(isolated_pen.to_json)).to eq(JSON.parse('''
352
- {
353
- "id": null,
354
- "color": "red",
355
- "pen_collection_id": null
356
- }
357
- '''))
358
- end
351
+ describe "#attributes" do
352
+ it "returns the attribute names of the supermodel and submodel" do
353
+ expect(pen.attributes).to eq(
354
+ "id" => nil,
355
+ "name" => "pen",
356
+ "price" => 0.8,
357
+ "store_id" => nil,
358
+ "settings" => {},
359
+ "created_at" => nil,
360
+ "updated_at" => nil,
361
+ "color" => "red",
362
+ "pen_collection_id" => nil
363
+ )
364
+ end
365
+ end
359
366
 
360
- it "if the submodel instance association exists" do
361
- p = Product.new(name: 'Test Pen', price: 0.8, actable: pen)
362
- p.save
363
- expect(JSON.parse(pen.to_json)).to eq(JSON.parse('''
364
- {
365
- "id": '+ pen.id.to_s + ',
366
- "name": "pen",
367
- "price": 0.8,
368
- "store_id": null,
369
- "pen_collection_id": null,
370
- "settings": {},
371
- "color": "red",
372
- "created_at": ' + pen.created_at.to_json + ',
373
- "updated_at": ' + pen.updated_at.to_json + '
374
- }
375
- '''))
376
- end
367
+ describe "#attribute_names" do
368
+ it "returns the attribute names of the supermodel and submodel" do
369
+ expect(pen.attribute_names).to eq(["id", "color", "pen_collection_id", "name", "price", "store_id", "settings", "created_at", "updated_at"])
377
370
  end
371
+ end
378
372
 
379
- context "includes supermodel attribute names in .attribute_names response" do
380
- it "unless the submodel instance association doesn't exist" do
381
- expect(pen.attribute_names).to include("id", "color")
382
- end
383
- it "if the submodel instance association exists" do
384
- p = Product.new(name: 'Test Pen', price: 0.8, actable: pen)
385
- p.save
386
- expect(pen.attribute_names).to include("id", "color", "name", "price", "store_id")
387
- end
373
+ describe ".actables" do
374
+ before(:each) { clear_database }
375
+
376
+ it "returns a query for the actable records" do
377
+ red_pen = Pen.create!(name: 'red pen', price: 0.8, color: 'red')
378
+ blue_pen = Pen.create!(name: 'blue pen', price: 0.8, color: 'blue')
379
+ black_pen = Pen.create!(name: 'black pen', price: 0.9, color: 'black')
380
+
381
+ actables = Pen.where(price: 0.8).actables
382
+
383
+ expect(actables).to be_kind_of(ActiveRecord::Relation)
384
+ expect(actables.to_a).to eq([red_pen.acting_as, blue_pen.acting_as])
388
385
  end
389
386
  end
390
387
 
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record-acts_as
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.9
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hassan Zamani
8
+ - Manuel Meurer
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2017-03-02 00:00:00.000000000 Z
12
+ date: 2017-03-17 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: sqlite3
@@ -80,6 +81,20 @@ dependencies:
80
81
  - - "~>"
81
82
  - !ruby/object:Gem::Version
82
83
  version: '2.1'
84
+ - !ruby/object:Gem::Dependency
85
+ name: guard-rspec
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '4.7'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '4.7'
83
98
  - !ruby/object:Gem::Dependency
84
99
  name: activesupport
85
100
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +127,7 @@ description: Simulate multi-table inheritance for activerecord models using a pl
112
127
  association
113
128
  email:
114
129
  - hsn.zamani@gmail.com
130
+ - manuel@krautcomputing.com
115
131
  executables: []
116
132
  extensions: []
117
133
  extra_rdoc_files: []
@@ -122,6 +138,7 @@ files:
122
138
  - Appraisals
123
139
  - CHANGELOG.md
124
140
  - Gemfile
141
+ - Guardfile
125
142
  - LICENSE.txt
126
143
  - README.md
127
144
  - Rakefile
@@ -144,7 +161,7 @@ files:
144
161
  - spec/models.rb
145
162
  - spec/rspec_matchers_spec.rb
146
163
  - spec/spec_helper.rb
147
- homepage: http://github.com/hzamani/active_record-acts_as
164
+ homepage: http://github.com/krautcomputing/active_record-acts_as
148
165
  licenses:
149
166
  - MIT
150
167
  metadata: {}
@@ -164,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
181
  version: '0'
165
182
  requirements: []
166
183
  rubyforge_project:
167
- rubygems_version: 2.6.6
184
+ rubygems_version: 2.6.8
168
185
  signing_key:
169
186
  specification_version: 4
170
187
  summary: Simulate multi-table inheritance for activerecord models
@@ -177,4 +194,3 @@ test_files:
177
194
  - spec/models.rb
178
195
  - spec/rspec_matchers_spec.rb
179
196
  - spec/spec_helper.rb
180
- has_rdoc: