diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 98ec37d23..e5ee529a3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -8,12 +8,15 @@ module ApplicationHelper end def flash_class(level, sticky: false, fixed: false) - class_names = case level + class_names = [] + + case level when 'notice' - ['alert-success'] - when 'alert' - ['alert-danger'] + class_names << 'alert-success' + when 'alert', 'error' + class_names << 'alert-danger' end + if sticky class_names << 'sticky' end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index ff70654fd..7fd93a96c 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -18,6 +18,13 @@ describe ApplicationHelper do end end + 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 + describe "#try_format_date" do subject { try_format_date(date) }