-
Notifications
You must be signed in to change notification settings - Fork 0
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
f901e80
commit ac90b81
Showing
7 changed files
with
78 additions
and
58 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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,15 @@ | ||
def login_with(credentials) | ||
visit new_user_session_path if current_path != new_user_session_path | ||
fill_in 'user_email', :with => credentials[:email] | ||
fill_in 'user_password', :with => credentials[:password] | ||
click_button 'login' | ||
end | ||
module EmailAndPasswordAuthenticationHelpers | ||
def login(user) | ||
credentials = { :email => user.email, :password => user.password } | ||
login_with_credentials credentials | ||
end | ||
|
||
def login_with_credentials(credentials) | ||
visit new_user_session_path if current_path != new_user_session_path | ||
fill_in 'user_email', :with => credentials[:email] | ||
fill_in 'user_password', :with => credentials[:password] | ||
click_button 'login' | ||
end | ||
end | ||
|
||
World(EmailAndPasswordAuthenticationHelpers) |
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,7 +1,19 @@ | ||
def get_user(name) | ||
first_name = name.split(' ')[0] | ||
return @user if @user.first_name == first_name | ||
user = User.find_by_first_name(first_name) | ||
raise "Couldn't find a user with first name #{first_name}" if user.nil? | ||
user | ||
end | ||
module UserHelpers | ||
def create_user(attributes = {}) | ||
# Make sure all keys are symbols | ||
attributes.keys.each { |key| attributes[key.to_sym] = attributes.delete(key) } | ||
|
||
attributes[:password_confirmation] ||= attributes[:password] | ||
Factory.create(:user, attributes) | ||
end | ||
|
||
def get_user(name) | ||
first_name = name.split(' ')[0] | ||
return @user if @user.first_name == first_name | ||
user = User.find_by_first_name(first_name) | ||
raise "Couldn't find a user with first name #{first_name}" if user.nil? | ||
user | ||
end | ||
end | ||
|
||
World(UserHelpers) |