- <% flash.each do |type, msg| %> + <% if flash.notice %> <%= govuk_notification_banner( title_text: 'Success', success: true, title_heading_level: 3, title_id: "swanky-notifications") do |notification_banner| - notification_banner.heading(text: msg) + notification_banner.heading(text: flash.notice) end %> <% end %> diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index e41551845..561a25e02 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -13,6 +13,7 @@ RSpec.describe "User Features" do fill_in("user[password]", with: "pAssword1") click_button("Sign in") expect(page).to have_current_path("/case_logs") + expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success") end end @@ -80,6 +81,17 @@ RSpec.describe "User Features" do end end + context "Trying to log in with incorrect credentials" do + it "shows a gov uk error summary and no flash message" do + visit("/case_logs") + fill_in("user[email]", with: user.email) + fill_in("user[password]", with: "nonsense") + click_button("Sign in") + expect(page).to have_selector("#error-summary-title") + expect(page).to have_no_css(".govuk-notification-banner.govuk-notification-banner--success") + end + end + context "Your Account " do before(:each) do visit("/case_logs")