BigW Consortium Gitlab

emails.rb 1.31 KB
Newer Older
1
class Spinach::Features::ProfileEmails < Spinach::FeatureSteps
2 3
  include SharedAuthentication

4
  step 'I visit profile emails page' do
5 6 7
    visit profile_emails_path
  end

8
  step 'I should see my emails' do
9
    expect(page).to have_content(@user.email)
10
    @user.emails.each do |email|
11
      expect(page).to have_content(email.email)
12 13 14
    end
  end

15
  step 'I submit new email "my@email.com"' do
16 17 18 19
    fill_in "email_email", with: "my@email.com"
    click_button "Add"
  end

20
  step 'I should see new email "my@email.com"' do
21
    email = @user.emails.find_by(email: "my@email.com")
22 23
    expect(email).not_to be_nil
    expect(page).to have_content("my@email.com")
24 25
  end

26
  step 'I should not see email "my@email.com"' do
27
    email = @user.emails.find_by(email: "my@email.com")
28 29
    expect(email).to be_nil
    expect(page).not_to have_content("my@email.com")
30 31
  end
  
32
  step 'I click link "Remove" for "my@email.com"' do
33 34 35 36 37 38
    # 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

39
  step 'I submit duplicate email @user.email' do
40 41 42 43
    fill_in "email_email", with: @user.email
    click_button "Add"
  end

44
  step 'I should not have @user.email added' do
45
    email = @user.emails.find_by(email: @user.email)
46
    expect(email).to be_nil
47 48
  end
end