active_interaction 4.0.3 → 4.0.4

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
  SHA256:
3
- metadata.gz: 965fd20ed2231b6cb6a86c1849e11138cb694a77e05cb24e0091674964bbbd51
4
- data.tar.gz: b86949412bf7a60d767fa27dec8b0092f0c0b053afb11bd50a5a5f09f83dc921
3
+ metadata.gz: 24af31782cca3b666b2f211506cb3ca39e362ffcb665ae509bda892b13e65934
4
+ data.tar.gz: 3a139e271e9d19ac23cdea62a5bbe882889f50483647951289623b8f3aaaf97f
5
5
  SHA512:
6
- metadata.gz: 31878456f6b33fb902254fd44cc532d411a97db32ff347ca8bc8164166897d54cd0eae31e0add30f4f130f4e744a16cdb8970859d8bf79a842258b4c0ec38c0f
7
- data.tar.gz: 17addfece52ce88fe5757eae06e14930508d209747caba20bd3e1d9b1aff140d2525e9548ec4a19dd1388dc7ef7e780706e35850351e8b487cda36c3f5b10bd9
6
+ metadata.gz: 574d84a7a67526dcb2b7f64ca885d6cccb3115612e731b4091bd1bb122446a88ce81ad791196c6bd33555122e9b2c8b07ac1924cecbe400f4d541906274fcd3c
7
+ data.tar.gz: 1260eae401d19342ef4b8e2ada334553e7b99672b3257ec9b5880d0c6566eb8dc86e8de9fc5c5a3d0ed37485f86fc88cdb3adc2abe6299ac60d049f1d0713474
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [4.0.4][] (2021-07-03)
2
+
3
+ ## Fix
4
+
5
+ - [#510][] - Hash parameters failed when working outside of Rails.
6
+ - [#511][] - Nested filters with options but no `:class` failed to have `:class` automatically added.
7
+
1
8
  # [4.0.3][] (2021-06-24)
2
9
 
3
10
  ## Fix
@@ -77,7 +84,7 @@ class Example < ActiveInteraction::Base
77
84
 
78
85
  validates :first_name,
79
86
  presence: true,
80
- unless: 'first_name.nil?'
87
+ unless: -> { first_name.nil? }
81
88
 
82
89
  def execute
83
90
  # ...
@@ -951,7 +958,8 @@ Example.run
951
958
 
952
959
  - Initial release.
953
960
 
954
- [4.0.2]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.2...v4.0.3
961
+ [4.0.4]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.3...v4.0.4
962
+ [4.0.3]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.2...v4.0.3
955
963
  [4.0.2]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.1...v4.0.2
956
964
  [4.0.1]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.0...v4.0.1
957
965
  [4.0.0]: https://github.com/AaronLasseigne/active_interaction/compare/v3.8.3...v4.0.0
@@ -1163,3 +1171,4 @@ Example.run
1163
1171
  [#505]: https://github.com/AaronLasseigne/active_interaction/issues/505
1164
1172
  [#499]: https://github.com/AaronLasseigne/active_interaction/issues/499
1165
1173
  [#493]: https://github.com/AaronLasseigne/active_interaction/issues/493
1174
+ [#510]: https://github.com/AaronLasseigne/active_interaction/issues/510
data/README.md CHANGED
@@ -5,7 +5,6 @@ It's an implementation of the command pattern in Ruby.
5
5
 
6
6
  [![Version](https://img.shields.io/gem/v/active_interaction.svg?style=flat-square)](https://rubygems.org/gems/active_interaction)
7
7
  [![Test](https://img.shields.io/github/workflow/status/AaronLasseigne/active_interaction/Test?label=Test&style=flat-square)](https://github.com/AaronLasseigne/active_interaction/actions?query=workflow%3ATest)
8
- [![Coverage](https://img.shields.io/coveralls/github/AaronLasseigne/active_interaction.svg?style=flat-square)](https://coveralls.io/r/orgsync/active_interaction)
9
8
  [![Climate](https://img.shields.io/codeclimate/maintainability/orgsync/active_interaction.svg?style=flat-square)](https://codeclimate.com/github/orgsync/active_interaction)
10
9
 
11
10
  ---
@@ -58,7 +57,7 @@ handles your verbs.
58
57
  - [Translations](#translations)
59
58
  - [Credits](#credits)
60
59
 
61
- [Full Documentation][]
60
+ [API Documentation][]
62
61
 
63
62
  ## Installation
64
63
 
@@ -977,10 +976,10 @@ class UpdateAccount < ActiveInteraction::Base
977
976
 
978
977
  validates :first_name,
979
978
  presence: true,
980
- unless: 'first_name.nil?'
979
+ unless: -> { first_name.nil? }
981
980
  validates :last_name,
982
981
  presence: true,
983
- unless: 'last_name.nil?'
982
+ unless: -> { last_name.nil? }
984
983
 
985
984
  def execute
986
985
  account.first_name = first_name if first_name.present?
@@ -1448,8 +1447,8 @@ I18nInteraction.run(name: false).errors.messages[:name]
1448
1447
 
1449
1448
  ## Credits
1450
1449
 
1451
- ActiveInteraction is brought to you by [Aaron Lasseigne][] and
1452
- [Taylor Fausak][] and was originally built at [OrgSync][].
1450
+ ActiveInteraction is brought to you by [Aaron Lasseigne][].
1451
+ Along with Aaron, [Taylor Fausak][] helped create and maintain ActiveInteraction but has since moved on.
1453
1452
 
1454
1453
  If you want to contribute to ActiveInteraction, please read
1455
1454
  [our contribution guidelines][]. A [complete list of contributors][] is
@@ -1458,14 +1457,11 @@ available on GitHub.
1458
1457
  ActiveInteraction is licensed under [the MIT License][].
1459
1458
 
1460
1459
  [activeinteraction]: https://github.com/AaronLasseigne/active_interaction
1461
- [Full Documentation]: http://rubydoc.info/github/orgsync/active_interaction
1460
+ [API Documentation]: http://rubydoc.info/github/AaronLasseigne/active_interaction
1462
1461
  [semantic versioning]: http://semver.org/spec/v2.0.0.html
1463
1462
  [GitHub releases]: https://github.com/AaronLasseigne/active_interaction/releases
1464
- [the announcement post]: http://devblog.orgsync.com/2015/05/06/announcing-active-interaction-2/
1465
- [active_model-errors_details]: https://github.com/cowbell/active_model-errors_details
1466
1463
  [aaron lasseigne]: https://github.com/AaronLasseigne
1467
1464
  [taylor fausak]: https://github.com/tfausak
1468
- [orgsync]: https://github.com/orgsync
1469
1465
  [our contribution guidelines]: CONTRIBUTING.md
1470
1466
  [complete list of contributors]: https://github.com/AaronLasseigne/active_interaction/graphs/contributors
1471
1467
  [the mit license]: LICENSE.md
@@ -1474,5 +1470,4 @@ ActiveInteraction is licensed under [the MIT License][].
1474
1470
  [the filters section]: #filters
1475
1471
  [the errors section]: #errors
1476
1472
  [the optional inputs section]: #optional-inputs
1477
- [aire]: example
1478
1473
  [`with_options`]: http://api.rubyonrails.org/classes/Object.html#method-i-with_options
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_model'
4
+ require 'active_support/hash_with_indifferent_access'
4
5
 
5
6
  # Manage application specific business logic.
6
7
  #
@@ -73,7 +73,7 @@ module ActiveInteraction
73
73
  end
74
74
 
75
75
  def add_option_in_place_of_name(klass, options)
76
- if (keys = FILTER_NAME_OR_OPTION[klass.to_s]) && (keys && options.keys).empty?
76
+ if (keys = FILTER_NAME_OR_OPTION[klass.to_s]) && (keys & options.keys).empty?
77
77
  options.merge(
78
78
  "#{keys.first}": name.to_s.singularize.camelize.to_sym
79
79
  )
@@ -44,7 +44,7 @@ module ActiveInteraction
44
44
  end
45
45
 
46
46
  def adjust_output(value, context)
47
- value = value.to_hash.with_indifferent_access
47
+ value = ActiveSupport::HashWithIndifferentAccess.new(value.to_hash)
48
48
 
49
49
  initial = strip? ? ActiveSupport::HashWithIndifferentAccess.new : value
50
50
 
@@ -14,26 +14,17 @@ module ActiveInteraction
14
14
  filter.clean(inputs[name], context)
15
15
  rescue NoDefaultError
16
16
  nil
17
- rescue InvalidNestedValueError,
18
- InvalidValueError,
19
- MissingValueError => e
20
- errors << error_args(filter, e)
17
+ rescue InvalidNestedValueError => e
18
+ errors << [filter.name, :invalid_nested, { name: e.filter_name.inspect, value: e.input_value.inspect }]
19
+ rescue InvalidValueError
20
+ errors << [filter.name, :invalid_type, { type: type(filter) }]
21
+ rescue MissingValueError
22
+ errors << [filter.name, :missing]
21
23
  end
22
24
  end
23
25
 
24
26
  private
25
27
 
26
- def error_args(filter, error)
27
- case error
28
- when InvalidNestedValueError
29
- [filter.name, :invalid_nested, { name: error.filter_name.inspect, value: error.input_value.inspect }]
30
- when InvalidValueError
31
- [filter.name, :invalid_type, { type: type(filter) }]
32
- when MissingValueError
33
- [filter.name, :missing]
34
- end
35
- end
36
-
37
28
  # @param filter [Filter]
38
29
  def type(filter)
39
30
  I18n.translate("#{Base.i18n_scope}.types.#{filter.class.slug}")
@@ -4,5 +4,5 @@ module ActiveInteraction
4
4
  # The version number.
5
5
  #
6
6
  # @return [Gem::Version]
7
- VERSION = Gem::Version.new('4.0.3')
7
+ VERSION = Gem::Version.new('4.0.4')
8
8
  end
@@ -137,6 +137,18 @@ describe ActiveInteraction::ArrayFilter, :filter do
137
137
  expect(filter.filters[:'0'].options[:methods]).to eql %i[to_s]
138
138
  end
139
139
  end
140
+
141
+ context 'with another option set' do
142
+ let(:block) { proc { public_send(:object, converter: :new) } }
143
+ let(:name) { :objects }
144
+
145
+ it 'has a filter with the right options' do
146
+ expect(filter.filters[:'0'].options).to have_key(:class)
147
+ expect(filter.filters[:'0'].options[:class]).to eql :Object
148
+ expect(filter.filters[:'0'].options).to have_key(:converter)
149
+ expect(filter.filters[:'0'].options[:converter]).to eql :new
150
+ end
151
+ end
140
152
  end
141
153
  end
142
154
 
@@ -19,7 +19,7 @@ describe HashInteraction do
19
19
  before { inputs[:a] = a }
20
20
 
21
21
  it 'returns the correct value for :a' do
22
- expect(result[:a]).to eql a.with_indifferent_access
22
+ expect(result[:a]).to eql ActiveSupport::HashWithIndifferentAccess.new(a)
23
23
  end
24
24
 
25
25
  it 'returns the correct value for :b' do
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,3 @@
1
- # Disable code coverage for JRuby because it always reports 0% coverage.
2
- if RUBY_ENGINE != 'jruby'
3
- require 'coveralls'
4
- Coveralls.wear!
5
- end
6
-
7
1
  require 'i18n'
8
2
  I18n.config.enforce_available_locales = true if I18n.config.respond_to?(:enforce_available_locales)
9
3
 
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: 4.0.3
4
+ version: 4.0.4
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: 2021-06-25 00:00:00.000000000 Z
12
+ date: 2021-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -32,21 +32,27 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: '7'
34
34
  - !ruby/object:Gem::Dependency
35
- name: actionpack
35
+ name: activesupport
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
41
- type: :development
40
+ version: '5'
41
+ - - "<"
42
+ - !ruby/object:Gem::Version
43
+ version: '7'
44
+ type: :runtime
42
45
  prerelease: false
43
46
  version_requirements: !ruby/object:Gem::Requirement
44
47
  requirements:
45
48
  - - ">="
46
49
  - !ruby/object:Gem::Version
47
- version: '0'
50
+ version: '5'
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '7'
48
54
  - !ruby/object:Gem::Dependency
49
- name: activerecord
55
+ name: actionpack
50
56
  requirement: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - ">="
@@ -60,33 +66,33 @@ dependencies:
60
66
  - !ruby/object:Gem::Version
61
67
  version: '0'
62
68
  - !ruby/object:Gem::Dependency
63
- name: benchmark-ips
69
+ name: activerecord
64
70
  requirement: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - "~>"
72
+ - - ">="
67
73
  - !ruby/object:Gem::Version
68
- version: '2.7'
74
+ version: '0'
69
75
  type: :development
70
76
  prerelease: false
71
77
  version_requirements: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - "~>"
79
+ - - ">="
74
80
  - !ruby/object:Gem::Version
75
- version: '2.7'
81
+ version: '0'
76
82
  - !ruby/object:Gem::Dependency
77
- name: coveralls
83
+ name: benchmark-ips
78
84
  requirement: !ruby/object:Gem::Requirement
79
85
  requirements:
80
86
  - - "~>"
81
87
  - !ruby/object:Gem::Version
82
- version: '0.8'
88
+ version: '2.7'
83
89
  type: :development
84
90
  prerelease: false
85
91
  version_requirements: !ruby/object:Gem::Requirement
86
92
  requirements:
87
93
  - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: '0.8'
95
+ version: '2.7'
90
96
  - !ruby/object:Gem::Dependency
91
97
  name: kramdown
92
98
  requirement: !ruby/object:Gem::Requirement