2015-04-26 12:48:37 +05:30
|
|
|
class Spinach::Features::ProfileEmails < Spinach::FeatureSteps
|
2014-09-02 18:07:02 +05:30
|
|
|
include SharedAuthentication
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
step 'I visit profile emails page' do
|
2014-09-02 18:07:02 +05:30
|
|
|
visit profile_emails_path
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
step 'I should see my emails' do
|
2014-09-02 18:07:02 +05:30
|
|
|
page.should have_content(@user.email)
|
|
|
|
@user.emails.each do |email|
|
|
|
|
page.should have_content(email.email)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
step 'I submit new email "my@email.com"' do
|
2014-09-02 18:07:02 +05:30
|
|
|
fill_in "email_email", with: "my@email.com"
|
|
|
|
click_button "Add"
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
step 'I should see new email "my@email.com"' do
|
2014-09-02 18:07:02 +05:30
|
|
|
email = @user.emails.find_by(email: "my@email.com")
|
|
|
|
email.should_not be_nil
|
|
|
|
page.should have_content("my@email.com")
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
step 'I should not see email "my@email.com"' do
|
2014-09-02 18:07:02 +05:30
|
|
|
email = @user.emails.find_by(email: "my@email.com")
|
|
|
|
email.should be_nil
|
|
|
|
page.should_not have_content("my@email.com")
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
step 'I click link "Remove" for "my@email.com"' do
|
2014-09-02 18:07:02 +05:30
|
|
|
# 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
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
step 'I submit duplicate email @user.email' do
|
2014-09-02 18:07:02 +05:30
|
|
|
fill_in "email_email", with: @user.email
|
|
|
|
click_button "Add"
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
step 'I should not have @user.email added' do
|
2014-09-02 18:07:02 +05:30
|
|
|
email = @user.emails.find_by(email: @user.email)
|
|
|
|
email.should be_nil
|
|
|
|
end
|
|
|
|
end
|