scinote-web/features/step_definitions/users_steps.rb

59 lines
1.4 KiB
Ruby
Raw Normal View History

2017-07-06 15:07:05 +08:00
Given(/^the following users are registered$/) do |table|
table.hashes.each do |hash|
FactoryBot.create(:user, hash)
2017-10-23 17:25:49 +08:00
User.find_by_email(hash.fetch('email')).confirm
2017-07-06 15:07:05 +08:00
end
end
Given(/^I visit the sign up page$/) do
visit new_user_registration_path
end
Then(/^I fill the sign up form with$/) do |table|
table.hashes.each do |hash|
hash.each do |k, v|
fill_in k, with: v
end
end
end
2017-10-10 15:17:55 +08:00
Given(/^"([^"]*)" is signed in with "([^"]*)"$/) do |email, password|
2017-10-10 15:17:55 +08:00
visit '/users/sign_in'
2017-10-11 15:51:20 +08:00
fill_in 'user_email', with: email
fill_in 'user_password', with: password
click_button 'Log in'
2017-10-10 15:17:55 +08:00
@current_user = User.find_by_email(email)
end
Given("I am on Sign in page") do
visit new_user_session_path
end
Given("I am on reset password page") do
visit new_user_password_path
end
Given("I click on Reset Password link in the reset password email for user {string}") do |email|
visit new_user_password_path
fill_in 'user_email', with: email
2020-03-31 16:16:51 +08:00
click_button 'Reset password'
2019-10-01 04:34:33 +08:00
Delayed::Worker.new.work_off
2019-10-01 04:34:33 +08:00
sleep 1
open_email(email)
current_email.click_link 'Change my password'
end
Then("I should be on Change your password page") do
2017-11-23 23:27:49 +08:00
expect(page).to have_current_path(edit_user_password_path, ignore_query: true)
end
Given(/^I am on Log in page$/) do
visit '/users/sign_in'
end
Then(/^I fill in Email "([^"]*)" and Password "([^"]*)"$/) do |email, password|
fill_in 'user_email', with: email
fill_in 'user_password', with: password
end