Skip to content

Commit

Permalink
fixed indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mhartl committed Sep 18, 2010
1 parent 5de06f9 commit e92a8f7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 25 deletions.
31 changes: 30 additions & 1 deletion app/helpers/sessions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,34 @@ module SessionsHelper

def sign_in(user)
cookies.permanent.signed[:remember_token] = [user.id, user.salt]
current_user = user
end
end

def current_user=(user)
@current_user = user
end

def current_user
@current_user ||= user_from_remember_token
end

def signed_in?
!current_user.nil?
end

def sign_out
cookies.delete(:remember_token)
self.current_user = nil
end

private

def user_from_remember_token
User.authenticate_with_salt(*remember_token)
end

def remember_token
cookies.signed[:remember_token] || [nil, nil]
end
end

48 changes: 24 additions & 24 deletions spec/requests/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,32 @@
end.should change(User, :count).by(1)
end
end
end

describe "signin" do

describe "signin" do

describe "failure" do
it "should not sign a user in" do
visit signin_path
fill_in "Email", :with => ""
fill_in "Password", :with => ""
click_button
response.should have_selector('div.flash.error',
:content => "Invalid")
response.should render_template('sessions/new')
end
describe "failure" do
it "should not sign a user in" do
visit signin_path
fill_in "Email", :with => ""
fill_in "Password", :with => ""
click_button
response.should have_selector('div.flash.error',
:content => "Invalid")
response.should render_template('sessions/new')
end
describe "success" do
it "should sign a user in and out" do
user = Factory(:user)
visit signin_path
fill_in "Email", :with => user.email
fill_in "Password", :with => user.password
click_button
controller.should be_signed_in
click_link "Sign out"
controller.should_not be_signed_in
end
end

describe "success" do
it "should sign a user in and out" do
user = Factory(:user)
visit signin_path
fill_in "Email", :with => user.email
fill_in "Password", :with => user.password
click_button
controller.should be_signed_in
click_link "Sign out"
controller.should_not be_signed_in
end
end
end
Expand Down

0 comments on commit e92a8f7

Please sign in to comment.