1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/features/step_definitions/user.rb

183 lines
5.3 KiB
Ruby
Raw Normal View History

2018-12-12 20:46:24 -05:00
# frozen_string_literal: true
2018-12-12 20:52:40 -05:00
Given 'a user with email {string} and password {string}' do |email, password|
create :user, email: email, password: password
end
2018-12-13 00:46:20 -05:00
Given 'I am signed in as guest' do
2019-03-23 20:48:37 -04:00
@account = create :guest_account
visit root_path guest_token: @account.guest_token
2018-12-13 00:46:20 -05:00
end
2019-02-08 03:35:17 -05:00
Given 'I am signed in as superuser' do
2019-03-23 20:48:37 -04:00
@account = create :superuser_account
2019-02-08 03:35:17 -05:00
visit '/users/sign_in'
within 'form' do
2019-03-23 20:48:37 -04:00
fill_in 'Email', with: @account.user.email
fill_in 'Пароль', with: @account.user.password
2019-02-08 03:35:17 -05:00
click_on 'Войти'
end
2019-03-23 20:48:37 -04:00
expect(page).to have_css 'ul > li > a', text: @account.user.account.username
2019-02-08 03:35:17 -05:00
end
2018-12-12 20:52:40 -05:00
Given 'I am signed in with email {string}' do |email|
2019-03-23 20:48:37 -04:00
@account = create(:user, email: email).account
2018-12-12 20:52:40 -05:00
visit '/users/sign_in'
within 'form' do
2019-03-23 20:48:37 -04:00
fill_in 'Email', with: @account.user.email
fill_in 'Пароль', with: @account.user.password
2018-12-12 20:52:40 -05:00
click_on 'Войти'
end
2019-03-23 20:48:37 -04:00
expect(page).to have_css 'ul > li > a', text: @account.username
2018-12-12 20:52:40 -05:00
end
2018-12-12 20:46:24 -05:00
Given 'I am signed in with email {string} ' \
'and password {string}' do |email, password|
2019-03-23 20:48:37 -04:00
@account = create(:user, email: email, password: password).account
2018-12-12 20:46:24 -05:00
visit '/users/sign_in'
within 'form' do
2019-03-23 20:48:37 -04:00
fill_in 'Email', with: @account.user.email
fill_in 'Пароль', with: @account.user.password
2018-12-12 20:46:24 -05:00
click_on 'Войти'
end
2019-03-23 20:48:37 -04:00
expect(page).to have_css 'ul > li > a', text: @account.username
2018-12-12 20:46:24 -05:00
end
2019-01-28 20:47:11 -05:00
Given 'I am signed in as party supporter' do
2018-12-15 01:01:00 -05:00
@person = create :supporter_person
2018-12-15 00:24:23 -05:00
@account = create :usual_account, person: @person
create :membership_app, account: @account
visit '/users/sign_in'
within 'form' do
2019-03-23 20:48:37 -04:00
fill_in 'Email', with: @account.user.email
fill_in 'Пароль', with: @account.user.password
2018-12-15 00:24:23 -05:00
click_on 'Войти'
end
2019-03-23 20:48:37 -04:00
expect(page).to have_css 'ul > li > a', text: @account.username
2018-12-15 00:24:23 -05:00
end
2019-01-28 20:47:11 -05:00
Given 'I am signed in as party member' do
@person = create :member_person
@account = create :usual_account, person: @person
create :membership_app, account: @account
visit '/users/sign_in'
within 'form' do
2019-03-23 20:48:37 -04:00
fill_in 'Email', with: @account.user.email
fill_in 'Пароль', with: @account.user.password
2019-01-28 20:47:11 -05:00
click_on 'Войти'
end
2019-03-23 20:48:37 -04:00
expect(page).to have_css 'ul > li > a', text: @account.username
2019-01-28 20:47:11 -05:00
end
Given 'I am signed in as excluded party member' do
@person = create :excluded_person
@account = create :usual_account, person: @person
create :membership_app, account: @account
visit '/users/sign_in'
within 'form' do
2019-03-23 20:48:37 -04:00
fill_in 'Email', with: @account.user.email
fill_in 'Пароль', with: @account.user.password
click_on 'Войти'
end
2019-03-23 20:48:37 -04:00
expect(page).to have_css 'ul > li > a', text: @account.username
end
2018-12-12 20:52:40 -05:00
When 'I try to sign in with email {string} ' \
'and password {string}' do |email, password|
visit '/users/sign_in'
within 'form' do
fill_in 'Email', with: email
fill_in 'Пароль', with: password
click_on 'Войти'
end
end
When 'I try to sign out' do
2019-03-23 20:48:37 -04:00
click_on @account.username
2018-12-12 20:52:40 -05:00
click_on 'Выйти'
end
When 'I follow confirmation link for email {string}' do |email|
user = User.find_by! email: email
visit user_confirmation_path confirmation_token: user.confirmation_token
end
Then 'I am signed in as {string}' do |email|
2019-01-31 21:45:49 -05:00
user = User.find_by! email: email
expect(page).to have_css 'ul > li > a', text: user.account.username
2018-12-12 20:52:40 -05:00
end
Then 'I fail to sign in' do
expect(page.current_path).to eq '/users/sign_in'
expect(page).to have_css 'div.alert.alert-warning',
text: 'Неправильный Email или пароль.'
end
Then 'I fail to sign in because of unconfirmed email' do
expect(page.current_path).to eq '/users/sign_in'
expect(page).to have_css 'div.alert.alert-warning',
text: 'Вы должны подтвердить вашу учетную запись.'
end
Then 'I am successfully signed out' do
expect(page.current_path).to eq '/'
2019-03-23 20:48:37 -04:00
expect(page).not_to have_text @account.user.email if @account.user
2018-12-12 20:52:40 -05:00
expect(page).to have_text 'Выход из системы выполнен.'
end
Then 'I am successfully signed up, but my email is unconfirmed' do
expect(page.current_path).to eq '/'
expect(page).to have_css 'h1', text: 'Либертарианская партия России'
expect(page).to have_css(
'div.alert.alert-info',
text: 'Письмо со ссылкой для подтверждения было отправлено ' \
'на ваш адрес эл. почты. Пожалуйста, перейдите по ссылке, ' \
'чтобы подтвердить учетную запись.',
)
end
Then 'I see that my email is confirmed' do
expect(page.current_path).to eq '/users/sign_in'
expect(page).to have_css 'div.alert.alert-info',
text: 'Ваш адрес эл. почты успешно подтвержден.'
end
2018-12-12 20:46:24 -05:00
Then 'the password is successfully changed' do
expect(page.current_path).to eq '/users/edit'
expect(page).to have_css 'div.alert.alert-info',
text: 'Ваша учетная запись изменена.'
end
Then 'the password is failed to change' do
expect(page.current_path).to eq '/users'
expect(page).to have_css 'div.alert.alert-danger',
text: 'Пожалуйста, исправьте следующие ошибки:'
end