Commit 700f6c4
Changed files (5)
app
helpers
views
layouts
shared
spec
features
helpers
app/helpers/application_helper.rb
@@ -1,2 +1,5 @@
module ApplicationHelper
+ def alert_class_for(flash_type)
+ "alert-#{{ success: 'success', error: 'danger', alert: 'warning', notice: 'info' }.fetch(flash_type.to_sym, flash_type)}"
+ end
end
app/views/layouts/public.html.erb
@@ -14,6 +14,7 @@
</head>
<body>
<div class="container">
+ <%= render partial: 'shared/flash' %>
<%= yield %>
</div> <!-- /container -->
</body>
spec/features/login_spec.rb
@@ -12,4 +12,16 @@ describe "the signin process", type: :feature do
click_button "Sign in"
expect(page).to have_content("Dashboard")
end
+
+ context "when the password is incorrect" do
+ it 'displays an error' do
+ visit root_path
+ within ".form-signin" do
+ fill_in 'email', with: user.email
+ fill_in 'password', with: 'wrong'
+ end
+ click_button "Sign in"
+ expect(page).to have_content(I18n.translate(:invalid_credentials))
+ end
+ end
end
spec/helpers/application_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+describe ApplicationHelper do
+ describe "#alert_class_for" do
+ it { expect(alert_class_for(:success)).to eql('alert-success') }
+
+ it { expect(alert_class_for(:error)).to eql('alert-danger') }
+
+ it { expect(alert_class_for(:alert)).to eql('alert-warning') }
+
+ it { expect(alert_class_for(:notice)).to eql('alert-info') }
+
+ it { expect(alert_class_for(:unknown)).to eql('alert-unknown') }
+ end
+end