Skip to content

Commit

Permalink
Merge pull request #297 from orgsync/gh-296
Browse files Browse the repository at this point in the history
Raise InvalidDefaultError instead of silently converting to nil
  • Loading branch information
tfausak committed Aug 3, 2015
2 parents c2e91af + 41f4909 commit 8839c81
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Fixed

- [#296][]: Fixed a bug that silently converted invalid lazy default values to
`nil` instead of raising an `InvalidDefaultError`.

# [2.1.0][] (2015-07-30)

## Added
Expand Down Expand Up @@ -565,5 +570,6 @@ For help upgrading to version 2, please read [the announcement post][].
[#286]: https://github.com/orgsync/active_interaction/issues/286
[#289]: https://github.com/orgsync/active_interaction/issues/289
[#295]: https://github.com/orgsync/active_interaction/issues/295
[#296]: https://github.com/orgsync/active_interaction/issues/296

[the announcement post]: http://devblog.orgsync.com/2015/05/06/announcing-active-interaction-2/
2 changes: 1 addition & 1 deletion lib/active_interaction/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def populate_filters(inputs)
self.class.filters.each do |name, filter|
begin
public_send("#{name}=", filter.clean(inputs[name]))
rescue Error
rescue InvalidValueError, MissingValueError, NoDefaultError
# #type_check will add errors if appropriate.
end
end
Expand Down
13 changes: 13 additions & 0 deletions spec/support/interactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ def execute
end
end

context 'with an invalid lazy default' do
let(:described_class) do
Class.new(TestInteraction) do
public_send(type, :default,
filter_options.merge(default: -> { Object.new }))
end
end

it 'raises an error' do
expect { outcome }.to raise_error ActiveInteraction::InvalidDefaultError
end
end

context 'without required inputs' do
it 'is invalid' do
expect(outcome).to be_invalid
Expand Down

0 comments on commit 8839c81

Please sign in to comment.