Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'sign-in-out'

  • Loading branch information...
commit f6d54698271b53348adb11f395f1475942585cc8 2 parents 280949c + d6d6323
@mattrubin authored
View
6 app/helpers/sessions_helper.rb
@@ -1,6 +1,10 @@
module SessionsHelper
def sign_in(user)
- cookies.permanent[:remember_token] = user.remember_token
+ if params[:remember_me]
+ cookies.permanent[:remember_token] = user.remember_token
+ else
+ cookies[:remember_token] = user.remember_token
+ end
current_user = user
end
View
7 app/views/sessions/new.html.erb
@@ -6,11 +6,16 @@
<%= form_for(:session, url: sessions_path) do |f| %>
<%= f.label :email %>
- <%= f.text_field :email %>
+ <%= f.text_field :email, value: (params[:session][:email] if params[:session]) %>
<%= f.label :password %>
<%= f.password_field :password %>
+ <label class="checkbox">
+ <%= check_box_tag :remember_me, 1, params[:remember_me] %>
+ Remember Me
+ </label>
+
<%= f.submit "Sign in", class: "btn btn-large btn-primary" %>
<% end %>
View
10 spec/requests/authentication_pages_spec.rb
@@ -15,10 +15,18 @@
before { visit signin_path }
describe "with invalid information" do
+ let(:user) { FactoryGirl.create(:user) }
+ before do
+ fill_in "Email", with: user.email
+ check "Remember Me"
+ click_button "Sign in"
+ end
before { click_button "Sign in" }
it { should have_selector('title', text: 'Sign in') }
it { should have_selector('div.alert.alert-error', text: 'Invalid') }
+ it { should have_field('Email', :with => user.email)}
+ specify { find_field('Remember Me').should be_checked}
describe "after visiting another page" do
before { click_link "Home" }
@@ -29,7 +37,7 @@
describe "with valid information" do
let(:user) { FactoryGirl.create(:user) }
before do
- fill_in "Email", with: user.email
+ fill_in "Email", with: user.email.upcase # ensures case-insensitivity
fill_in "Password", with: user.password
click_button "Sign in"
end
Please sign in to comment.
Something went wrong with that request. Please try again.