Skip to content

Commit

Permalink
fix: display custom success/error messages for actions (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthv authored Jan 28, 2025
1 parent 57871a9 commit 083c8e0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def success(message: 'Success', options: {})
{
headers: @headers,
type: 'Success',
message: message,
success: message,
refresh: { relationships: options.key?(:invalidated) ? options[:invalidated] : [] },
html: options.key?(:html) ? options[:html] : nil
}
Expand All @@ -27,7 +27,7 @@ def error(message: 'Error', options: {})
headers: @headers,
type: 'Error',
status: 400,
message: message,
error: message,
html: options.key?(:html) ? options[:html] : nil
}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ module Action

it 'execute and return default response' do
result = @decorated_book.execute(caller, 'make photocopy', {}, Filter.new)
expect(result).to eq({ headers: {}, type: 'Success', message: 'Success', refresh: { relationships: [] }, html: nil })
expect(result).to eq({ headers: {}, type: 'Success', success: 'Success', refresh: { relationships: [] }, html: nil })
end

it 'generate empty form' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Action
{
headers: { 'header_key' => 'header_value' },
type: 'Success',
message: 'Success',
success: 'Success',
refresh: { relationships: [] },
html: nil
}
Expand All @@ -28,7 +28,7 @@ module Action
{
headers: {},
type: 'Success',
message: 'Success',
success: 'Success',
refresh: { relationships: [] },
html: nil
}
Expand All @@ -38,7 +38,7 @@ module Action
{
headers: {},
type: 'Success',
message: 'foo',
success: 'foo',
refresh: { relationships: [] },
html: '<div>That worked!</div>'
}
Expand All @@ -50,7 +50,7 @@ module Action
{
headers: {},
type: 'Error',
message: 'Error',
error: 'Error',
status: 400,
html: nil
}
Expand All @@ -60,7 +60,7 @@ module Action
{
headers: {},
type: 'Error',
message: 'foo',
error: 'foo',
status: 400,
html: '<div>That worked!</div>'
}
Expand Down

0 comments on commit 083c8e0

Please sign in to comment.