Skip to content

Commit

Permalink
fix #511 by making sure we set the class when options are passed and …
Browse files Browse the repository at this point in the history
…`:class` is not one of them
  • Loading branch information
AaronLasseigne committed Jul 3, 2021
1 parent 19daacc commit ec2e8d3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [4.0.4][] (TBD)

## Fix

- [#510][] - Hash parameters failed when working outside of Rails.
- [#511][] - Nested filters with options but no `:class` failed to have `:class` automatically added.

# [4.0.3][] (2021-06-24)

## Fix
Expand Down Expand Up @@ -951,7 +958,8 @@ Example.run

- Initial release.

[4.0.2]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.2...v4.0.3
[4.0.4]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.3...v4.0.4
[4.0.3]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.2...v4.0.3
[4.0.2]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.1...v4.0.2
[4.0.1]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.0...v4.0.1
[4.0.0]: https://github.com/AaronLasseigne/active_interaction/compare/v3.8.3...v4.0.0
Expand Down Expand Up @@ -1163,3 +1171,4 @@ Example.run
[#505]: https://github.com/AaronLasseigne/active_interaction/issues/505
[#499]: https://github.com/AaronLasseigne/active_interaction/issues/499
[#493]: https://github.com/AaronLasseigne/active_interaction/issues/493
[#510]: https://github.com/AaronLasseigne/active_interaction/issues/510
2 changes: 1 addition & 1 deletion lib/active_interaction/filters/array_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def convert(value)
end

def add_option_in_place_of_name(klass, options)
if (keys = FILTER_NAME_OR_OPTION[klass.to_s]) && (keys && options.keys).empty?
if (keys = FILTER_NAME_OR_OPTION[klass.to_s]) && (keys & options.keys).empty?
options.merge(
"#{keys.first}": name.to_s.singularize.camelize.to_sym
)
Expand Down
12 changes: 12 additions & 0 deletions spec/active_interaction/filters/array_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ def to_ary
expect(filter.filters[:'0'].options[:methods]).to eql %i[to_s]
end
end

context 'with another option set' do
let(:block) { proc { public_send(:object, converter: :new) } }
let(:name) { :objects }

it 'has a filter with the right options' do
expect(filter.filters[:'0'].options).to have_key(:class)
expect(filter.filters[:'0'].options[:class]).to eql :Object
expect(filter.filters[:'0'].options).to have_key(:converter)
expect(filter.filters[:'0'].options[:converter]).to eql :new
end
end
end
end

Expand Down

0 comments on commit ec2e8d3

Please sign in to comment.