helpers: handle flash[:error]

Errors generated by the `invisible-catcha` gem are reported as
`flash[:error]` (which differs from Rail's usual `flash[:alert]`).

We probably shouldn't use flash[:error] in our own codebase; but we can
handle its use in third-party libraries.
This commit is contained in:
Pierre de La Morinerie 2022-01-06 13:21:47 +01:00
parent 68b112e00a
commit 2e1a3c32cb
2 changed files with 2 additions and 1 deletions

View file

@ -13,7 +13,7 @@ module ApplicationHelper
case level
when 'notice'
class_names << 'alert-success'
when 'alert'
when 'alert', 'error'
class_names << 'alert-danger'
end

View file

@ -21,6 +21,7 @@ describe ApplicationHelper do
describe "#flash_class" do
it { expect(flash_class('notice')).to eq 'alert-success' }
it { expect(flash_class('alert', sticky: true, fixed: true)).to eq 'alert-danger sticky alert-fixed' }
it { expect(flash_class('error')).to eq 'alert-danger' }
it { expect(flash_class('unknown-level')).to eq '' }
end