Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2388c4d
commit 0ed9214
Showing
14 changed files
with
82 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
class SessionsController < ApplicationController | ||
def new | ||
@user = User.new | ||
end | ||
|
||
def create | ||
user = login(params[:email], params[:password]) | ||
if user | ||
redirect_back_or_to root_url, :notice => "Logged in!" | ||
redirect_back_or_to users_path, :notice => "Logged in!" | ||
else | ||
flash.now.alert = "Email or password was invalid." | ||
redirect_to(login_path, :notice => "Email or password invalid!") | ||
end | ||
end | ||
|
||
def destroy | ||
logout | ||
redirect_to root_url, :notice => "Logged out!" | ||
redirect_to home_index_path, :notice => "Logged out!" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
CapybaraIntegration::Application.routes.draw do | ||
get "home/index" | ||
|
||
get "home/secret" | ||
|
||
resources :users | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'spec_helper' | ||
|
||
describe "Friendship request" do | ||
it "An user can do a friendship request" do | ||
User.create(:email => "jessica@redu.com.br", :password => 123456) | ||
User.create(:email => "testuser@redu.com.br", :password => 123456) | ||
visit home_index_path | ||
click_link "Log in" | ||
fill_in 'Email', :with => 'jessica@redu.com.br' | ||
fill_in 'Password', :with => 123456 | ||
click_button 'Log in' | ||
click_link 'show' | ||
current_path.should eq(user_show(1)) | ||
click_link 'add friend' | ||
page.should have_content('waiting answerfor request') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'spec_helper' | ||
|
||
describe "Login" do | ||
it "A person can log with a valid email and password" do | ||
User.create(:email => "jessica@redu.com.br", :password => 123456) | ||
visit home_index_path | ||
click_link "Log in" | ||
fill_in 'Email', :with => 'jessica@redu.com.br' | ||
fill_in 'Password', :with => 123456 | ||
click_button 'Log in' | ||
current_path.should eq(users_path) | ||
page.should have_content("Logged in as jessica@redu.com.br") | ||
end | ||
|
||
it "A person can't log with invalid email or password" do | ||
visit home_index_path | ||
click_link "Log in" | ||
fill_in 'Email', :with => 'jessica@redu.com.br' | ||
fill_in 'Password', :with => 123456 | ||
click_button 'Log in' | ||
current_path.should eq(login_path) | ||
page.should have_content("Email or password invalid!") | ||
end | ||
end | ||
|
||
describe "Logout" do | ||
it "A person can logout" do | ||
User.create(:email => "jessica@redu.com.br", :password => 123456) | ||
visit home_index_path | ||
click_link "Log in" | ||
fill_in 'Email', :with => 'jessica@redu.com.br' | ||
fill_in 'Password', :with => 123456 | ||
click_button 'Log in' | ||
click_link 'Log out' | ||
current_path.should eq(home_index_path) | ||
page.should have_content("Logged out!") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters