active_interaction 2.1.2 → 2.1.3

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: 9329a7a03500b2df126c515a11207fa2857aa369
4
- data.tar.gz: b4435673bededceaf5b4fc71bbe025d032b126d9
3
+ metadata.gz: 12ca7dc31a385a251040b047f2ebbd4021b66e42
4
+ data.tar.gz: e7b0bccef0972305632647ea92a7900befce5b8d
5
5
  SHA512:
6
- metadata.gz: baef9f6307c852cba7b5bba252fa567641fccdab1840211abfb73fb88f537367f2305cdd00ffa4f8fac6c692e8f9dbe7d42ecd8a5b27cfa81db479dcc72c012d
7
- data.tar.gz: 9f6fa9fb6e2049ea8bbf9c5770132fd991b2644dffea2472530870676955185039010b6b193d5294338da9d8677e17aadd8a1f91764abfbfe43f9634590c5dd1
6
+ metadata.gz: 0b59c1e221db8a9ac461ed422c35d1b0df70991cb7202c7c29f4e3d6da258db91e520d839cb2fdc442e43a21d4f56c575e677ed192adbe7e1c98c78b64da197f
7
+ data.tar.gz: 2a418966e8f5d576a610d96aec2b79242398fcab79c55c624317eab94509099d8d0fe3eaba92a4804320fff299bf7786ce15d571755918c005d61b937989dac3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ # [2.1.3][] (2015-10-02)
2
+
3
+ ## Fixed
4
+
5
+ - [#303][]: Allowed ActiveRecord associations as inputs to array filters.
6
+
7
+ ## Changed
8
+
9
+ - [#304][]: Improved the error message for object filters when the class does
10
+ not exist.
11
+
1
12
  # [2.1.2][] (2015-09-03)
2
13
 
3
14
  ## Fixed
@@ -444,6 +455,7 @@ For help upgrading to version 2, please read [the announcement post][].
444
455
 
445
456
  - Initial release.
446
457
 
458
+ [2.1.3]: https://github.com/orgsync/active_interaction/compare/v2.1.2...v2.1.3
447
459
  [2.1.2]: https://github.com/orgsync/active_interaction/compare/v2.1.1...v2.1.2
448
460
  [2.1.1]: https://github.com/orgsync/active_interaction/compare/v2.1.0...v2.1.1
449
461
  [2.1.0]: https://github.com/orgsync/active_interaction/compare/v2.0.1...v2.1.0
@@ -583,5 +595,7 @@ For help upgrading to version 2, please read [the announcement post][].
583
595
  [#295]: https://github.com/orgsync/active_interaction/issues/295
584
596
  [#296]: https://github.com/orgsync/active_interaction/issues/296
585
597
  [#298]: https://github.com/orgsync/active_interaction/issues/298
598
+ [#303]: https://github.com/orgsync/active_interaction/issues/303
599
+ [#304]: https://github.com/orgsync/active_interaction/issues/304
586
600
 
587
601
  [the announcement post]: http://devblog.orgsync.com/2015/05/06/announcing-active-interaction-2/
@@ -9,7 +9,7 @@ require 'active_model'
9
9
  #
10
10
  # @since 1.0.0
11
11
  #
12
- # @version 2.1.2
12
+ # @version 2.1.3
13
13
  module ActiveInteraction
14
14
  end
15
15
 
@@ -13,12 +13,12 @@ module ActiveInteraction
13
13
 
14
14
  def cast(value)
15
15
  case value
16
- when *klasses
17
- value
18
16
  when String
19
17
  convert(value)
20
18
  when GroupedInput
21
19
  convert(stringify(value))
20
+ when *klasses
21
+ value
22
22
  else
23
23
  super
24
24
  end
@@ -59,10 +59,16 @@ module ActiveInteraction
59
59
  # @return [Array<Class>]
60
60
  def classes
61
61
  result = [Array]
62
- return result unless Object.const_defined?(:ActiveRecord)
63
- return result unless ActiveRecord.const_defined?(:Relation)
64
62
 
65
- result.push(ActiveRecord::Relation)
63
+ %w[
64
+ ActiveRecord::Relation
65
+ ActiveRecord::Associations::CollectionProxy
66
+ ].each do |name|
67
+ next unless (klass = name.safe_constantize)
68
+ result.push(klass)
69
+ end
70
+
71
+ result
66
72
  end
67
73
 
68
74
  # @param filter [Filter]
@@ -42,7 +42,7 @@ module ActiveInteraction
42
42
  klass_name = options.fetch(:class, name).to_s.camelize
43
43
  Object.const_get(klass_name)
44
44
  rescue NameError
45
- raise InvalidClassError, klass_name.inspect
45
+ raise InvalidClassError, "class #{klass_name.inspect} does not exist"
46
46
  end
47
47
 
48
48
  # @param value [Object]
@@ -5,5 +5,5 @@ module ActiveInteraction
5
5
  # The version number.
6
6
  #
7
7
  # @return [Gem::Version]
8
- VERSION = Gem::Version.new('2.1.2')
8
+ VERSION = Gem::Version.new('2.1.3')
9
9
  end
@@ -2,6 +2,16 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
+ module ActiveRecord
6
+ class Relation
7
+ end
8
+
9
+ module Associations
10
+ class CollectionProxy
11
+ end
12
+ end
13
+ end
14
+
5
15
  ArrayInteraction = Class.new(TestInteraction) do
6
16
  array :a do
7
17
  array
@@ -14,6 +24,9 @@ end
14
24
  describe ArrayInteraction do
15
25
  include_context 'interactions'
16
26
  it_behaves_like 'an interaction', :array, -> { [] }
27
+ it_behaves_like 'an interaction', :array, -> { ActiveRecord::Relation.new }
28
+ it_behaves_like 'an interaction', :array,
29
+ -> { ActiveRecord::Associations::CollectionProxy.new }
17
30
 
18
31
  context 'with inputs[:a]' do
19
32
  let(:a) { [[]] }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_interaction
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Lasseigne
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-03 00:00:00.000000000 Z
12
+ date: 2015-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel