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:
parent
68b112e00a
commit
2e1a3c32cb
2 changed files with 2 additions and 1 deletions
|
@ -13,7 +13,7 @@ module ApplicationHelper
|
||||||
case level
|
case level
|
||||||
when 'notice'
|
when 'notice'
|
||||||
class_names << 'alert-success'
|
class_names << 'alert-success'
|
||||||
when 'alert'
|
when 'alert', 'error'
|
||||||
class_names << 'alert-danger'
|
class_names << 'alert-danger'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ describe ApplicationHelper do
|
||||||
describe "#flash_class" do
|
describe "#flash_class" do
|
||||||
it { expect(flash_class('notice')).to eq 'alert-success' }
|
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('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 '' }
|
it { expect(flash_class('unknown-level')).to eq '' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue