1
0
Fork 0

Add factory "member_person"

This commit is contained in:
Alex Kotov 2019-01-29 06:47:11 +05:00
parent 276d9131bc
commit 4252b1f214
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
4 changed files with 38 additions and 2 deletions

View file

@ -6,4 +6,8 @@ FactoryBot.define do
factory :supporter_person, parent: :initial_person do
supporter_since { rand(10_000).days.ago.to_date }
end
factory :member_person, parent: :supporter_person do
member_since { rand(10_000).days.ago.to_date }
end
end

View file

@ -16,6 +16,12 @@ Feature: Membership application
And I click the form button "Отправить заявление"
Then I see the membership application tracking page
Scenario: as a supporter
Given I am signed in as party supporter
When I visit the main page
And I click the button "Ваше заявление"
Then I see that I am already a party supporter
Scenario: as a member
Given I am signed in as party member
When I visit the main page

View file

@ -22,11 +22,19 @@ Then 'I see the membership application tracking page' do
)
end
Then 'I see that I am already a party supporter' do
expect(page.current_path).to eq '/application'
expect(page).to have_css 'h1', text: 'Поздравляем!'
expect(page).to have_css 'p.lead',
text: 'Вы уже являетесь сторонником ' \
'Либертарианской партии России!'
end
Then 'I see that I am already a party member' do
expect(page.current_path).to eq '/application'
expect(page).to have_css 'h1', text: 'Поздравляем!'
expect(page).to have_css 'p.lead',
text: 'Вы уже являетесь членом или сторонником ' \
text: 'Вы уже являетесь членом ' \
'Либертарианской партии России!'
end

View file

@ -40,7 +40,7 @@ Given 'I am signed in with email {string} ' \
expect(page).to have_css 'ul > li > a', text: @user.email
end
Given 'I am signed in as party member' do
Given 'I am signed in as party supporter' do
@person = create :supporter_person
@account = create :usual_account, person: @person
create :membership_app, account: @account
@ -58,6 +58,24 @@ Given 'I am signed in as party member' do
expect(page).to have_css 'ul > li > a', text: @user.email
end
Given 'I am signed in as party member' do
@person = create :member_person
@account = create :usual_account, person: @person
create :membership_app, account: @account
@user = @account.user
visit '/users/sign_in'
within 'form' do
fill_in 'Email', with: @user.email
fill_in 'Пароль', with: @user.password
click_on 'Войти'
end
expect(page).to have_css 'ul > li > a', text: @user.email
end
When 'I try to sign in with email {string} ' \
'and password {string}' do |email, password|
visit '/users/sign_in'