2014-09-22 14:30:25 +00:00
|
|
|
class Spinach::Features::ProfileEmails < Spinach::FeatureSteps
|
2014-02-09 03:08:49 +00:00
|
|
|
include SharedAuthentication
|
|
|
|
|
2014-09-21 21:40:22 +00:00
|
|
|
step 'I visit profile emails page' do
|
2014-02-09 03:08:49 +00:00
|
|
|
visit profile_emails_path
|
|
|
|
end
|
|
|
|
|
2014-09-21 21:40:22 +00:00
|
|
|
step 'I should see my emails' do
|
2015-06-12 04:44:13 +00:00
|
|
|
expect(page).to have_content(@user.email)
|
2014-02-09 03:08:49 +00:00
|
|
|
@user.emails.each do |email|
|
2015-06-12 04:44:13 +00:00
|
|
|
expect(page).to have_content(email.email)
|
2014-02-09 03:08:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-21 21:40:22 +00:00
|
|
|
step 'I submit new email "my@email.com"' do
|
2014-02-09 03:08:49 +00:00
|
|
|
fill_in "email_email", with: "my@email.com"
|
|
|
|
click_button "Add"
|
|
|
|
end
|
|
|
|
|
2014-09-21 21:40:22 +00:00
|
|
|
step 'I should see new email "my@email.com"' do
|
2014-02-09 03:08:49 +00:00
|
|
|
email = @user.emails.find_by(email: "my@email.com")
|
2015-06-12 04:44:13 +00:00
|
|
|
expect(email).not_to be_nil
|
|
|
|
expect(page).to have_content("my@email.com")
|
2014-02-09 03:08:49 +00:00
|
|
|
end
|
|
|
|
|
2014-09-21 21:40:22 +00:00
|
|
|
step 'I should not see email "my@email.com"' do
|
2014-02-09 03:08:49 +00:00
|
|
|
email = @user.emails.find_by(email: "my@email.com")
|
2015-06-12 04:44:13 +00:00
|
|
|
expect(email).to be_nil
|
|
|
|
expect(page).not_to have_content("my@email.com")
|
2014-02-09 03:08:49 +00:00
|
|
|
end
|
|
|
|
|
2014-09-21 21:40:22 +00:00
|
|
|
step 'I click link "Remove" for "my@email.com"' do
|
2014-02-09 03:08:49 +00:00
|
|
|
# there should only be one remove button at this time
|
|
|
|
click_link "Remove"
|
|
|
|
# force these to reload as they have been cached
|
|
|
|
@user.emails.reload
|
|
|
|
end
|
|
|
|
|
2014-09-21 21:40:22 +00:00
|
|
|
step 'I submit duplicate email @user.email' do
|
2014-02-09 03:08:49 +00:00
|
|
|
fill_in "email_email", with: @user.email
|
|
|
|
click_button "Add"
|
|
|
|
end
|
|
|
|
|
2014-09-21 21:40:22 +00:00
|
|
|
step 'I should not have @user.email added' do
|
2014-02-09 03:08:49 +00:00
|
|
|
email = @user.emails.find_by(email: @user.email)
|
2015-06-12 04:44:13 +00:00
|
|
|
expect(email).to be_nil
|
2014-02-09 03:08:49 +00:00
|
|
|
end
|
|
|
|
end
|