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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8708651ac6d764497b6c4e8da34acae1475c3f7d
4
- data.tar.gz: aa82c12e20fa93ac1f42af1e642dd5340cc06076
3
+ metadata.gz: dfc78a4f0d220edb01b5336e81199401fc1da77c
4
+ data.tar.gz: 2d09cdc24ca238012d043badca0a143a67942e2f
5
5
  SHA512:
6
- metadata.gz: 1e03ca44f4700ac019b97995bfb7e2c52d281e2357accb77a007f9ad8589f6fb862d0c67910500195925d90d7944a5fec68a5ffbd4dba1835a7a44f593b8b5b2
7
- data.tar.gz: 75a8d285074080eb20731ae14a6c4c9713820f7d5bc3513deecea27ba9e51cb786ed8a574dd201d122223c5241343a5a991cf5c051a9393c3178dfc46d0acfb3
6
+ metadata.gz: 2afb1348df5ac807e39ffaa3ad9cad8ca02fb6177d39a20f03dbedb80f1abab1750096d20c1db652846f81c933c4caecfa8627306032bebb8843dc66e3314052
7
+ data.tar.gz: ba3005c9fcf570174d6908a939209d0df816b147090554946a6b6321af61d0b25bd950f85d1ce8649473c6db74ef08a71b2175b78c2fe4c19afa1d0d1607dc6f
data/.travis.yml CHANGED
@@ -10,7 +10,3 @@ before_install:
10
10
  gemfile:
11
11
  - gemfiles/rails_4.2.gemfile
12
12
  - gemfiles/rails_5.0.gemfile
13
- matrix:
14
- allow_failures:
15
- - rvm: 2.4.0
16
- gemfile: gemfiles/rails_4.2.gemfile
@@ -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
- opts = opts.merge(opts.delete(klass.table_name) || {})
6
+ if table_name_opts = opts.delete(klass.table_name)
7
+ opts = opts.merge(table_name_opts)
8
+ end
7
9
 
8
- opts, acts_as_opts = opts.stringify_keys.partition { |k,v| attribute_method?(k) }
9
- opts, acts_as_opts = Hash[opts], Hash[acts_as_opts]
10
- opts[acting_as_model.table_name] = acts_as_opts unless acts_as_opts.empty?
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
@@ -1,6 +1,6 @@
1
1
  module ActiveRecord
2
2
  module ActsAs
3
- VERSION = "2.0.8"
3
+ VERSION = "2.0.9"
4
4
  end
5
5
  end
6
6
 
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.8
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-17 00:00:00.000000000 Z
11
+ date: 2017-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3