active_record-acts_as 2.0.8 → 2.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -4
- data/lib/active_record/acts_as/querying.rb +12 -4
- data/lib/active_record/acts_as/version.rb +1 -1
- data/spec/acts_as_spec.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfc78a4f0d220edb01b5336e81199401fc1da77c
|
4
|
+
data.tar.gz: 2d09cdc24ca238012d043badca0a143a67942e2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2afb1348df5ac807e39ffaa3ad9cad8ca02fb6177d39a20f03dbedb80f1abab1750096d20c1db652846f81c933c4caecfa8627306032bebb8843dc66e3314052
|
7
|
+
data.tar.gz: ba3005c9fcf570174d6908a939209d0df816b147090554946a6b6321af61d0b25bd950f85d1ce8649473c6db74ef08a71b2175b78c2fe4c19afa1d0d1607dc6f
|
data/.travis.yml
CHANGED
@@ -3,11 +3,19 @@ module ActiveRecord
|
|
3
3
|
module QueryMethods
|
4
4
|
def where(opts = :chain, *rest)
|
5
5
|
if acting_as? && opts.is_a?(Hash)
|
6
|
-
|
6
|
+
if table_name_opts = opts.delete(klass.table_name)
|
7
|
+
opts = opts.merge(table_name_opts)
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
# Filter out the conditions that should be
|
11
|
+
# applied to the `acting_as_model`. Ignore
|
12
|
+
# conditions that contain a dot or are attributes
|
13
|
+
# of the submodel.
|
14
|
+
opts, acts_as_opts = opts.stringify_keys.partition { |k, _| k =~ /\./ || attribute_method?(k) }.map(&:to_h)
|
15
|
+
|
16
|
+
if acts_as_opts.any?
|
17
|
+
opts[acting_as_model.table_name] = acts_as_opts
|
18
|
+
end
|
11
19
|
end
|
12
20
|
|
13
21
|
super
|
data/spec/acts_as_spec.rb
CHANGED
@@ -416,6 +416,12 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
|
|
416
416
|
expect(relation.scope_for_create.keys).to include('name')
|
417
417
|
expect(relation.scope_for_create['name']).to eq('new name')
|
418
418
|
end
|
419
|
+
|
420
|
+
it "works when the submodel table name is specified" do
|
421
|
+
red_pen = Pen.create!(name: 'red pen', price: 0.8, color: 'red')
|
422
|
+
|
423
|
+
expect(Pen.find_by('pens.color' => 'red')).to eq(red_pen)
|
424
|
+
end
|
419
425
|
end
|
420
426
|
|
421
427
|
context 'Namespaces' do
|
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: 2.0.
|
4
|
+
version: 2.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hassan Zamani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02
|
11
|
+
date: 2017-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|