2011-10-08 23:36:38 +02:00
|
|
|
module LoginMacros
|
|
|
|
def login_as role
|
2012-08-11 00:07:50 +02:00
|
|
|
@user = User.create(email: "user#{User.count}@mail.com",
|
|
|
|
name: "John Smith",
|
|
|
|
password: "123456",
|
|
|
|
password_confirmation: "123456",
|
|
|
|
skype: 'user_skype')
|
2011-10-26 15:46:25 +02:00
|
|
|
|
|
|
|
if role == :admin
|
2011-10-08 23:36:38 +02:00
|
|
|
@user.admin = true
|
|
|
|
@user.save!
|
|
|
|
end
|
|
|
|
|
|
|
|
visit new_user_session_path
|
2012-08-11 00:07:50 +02:00
|
|
|
fill_in "user_email", with: @user.email
|
|
|
|
fill_in "user_password", with: "123456"
|
2011-10-08 23:36:38 +02:00
|
|
|
click_button "Sign in"
|
|
|
|
end
|
|
|
|
|
|
|
|
def login_with(user)
|
|
|
|
visit new_user_session_path
|
2012-08-11 00:07:50 +02:00
|
|
|
fill_in "user_email", with: user.email
|
|
|
|
fill_in "user_password", with: "123456"
|
2011-10-08 23:36:38 +02:00
|
|
|
click_button "Sign in"
|
|
|
|
end
|
2011-10-26 15:46:25 +02:00
|
|
|
|
2011-10-08 23:36:38 +02:00
|
|
|
def logout
|
|
|
|
click_link "Logout" rescue nil
|
|
|
|
end
|
|
|
|
end
|