diff options
author | Rémy Coutable <remy@rymai.me> | 2017-09-11 13:10:50 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-09-11 13:10:50 +0000 |
commit | b22a48d5371887eaa32f286dced8cc8f16d29b55 (patch) | |
tree | cc6f5a30356632fc6c262ce5cd01c56a1deb8717 /spec | |
parent | c20c6982655a8e245fe15e48bc39baa311bd26f2 (diff) | |
parent | 3525d5df65d2b1215bb08d5efa4aec86c4a26dc1 (diff) | |
download | gitlab-ce-b22a48d5371887eaa32f286dced8cc8f16d29b55.tar.gz |
Merge branch 'replace_emails.feature' into 'master'
Replace the 'profile/emails.feature' spinach test with an rspec analog
See merge request !14172
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/profiles/user_manages_emails_spec.rb | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/spec/features/profiles/user_manages_emails_spec.rb b/spec/features/profiles/user_manages_emails_spec.rb new file mode 100644 index 00000000000..7283c76eb54 --- /dev/null +++ b/spec/features/profiles/user_manages_emails_spec.rb @@ -0,0 +1,78 @@ +require 'spec_helper' + +describe 'User manages emails' do + let(:user) { create(:user) } + + before do + sign_in(user) + + visit(profile_emails_path) + end + + it "shows user's emails" do + expect(page).to have_content(user.email) + + user.emails.each do |email| + expect(page).to have_content(email.email) + end + end + + it 'adds an email' do + fill_in('email_email', with: 'my@email.com') + click_button('Add') + + email = user.emails.find_by(email: 'my@email.com') + + expect(email).not_to be_nil + expect(page).to have_content('my@email.com') + expect(page).to have_content(user.email) + + user.emails.each do |email| + expect(page).to have_content(email.email) + end + end + + it 'does not add a duplicate email' do + fill_in('email_email', with: user.email) + click_button('Add') + + email = user.emails.find_by(email: user.email) + + expect(email).to be_nil + expect(page).to have_content(user.email) + + user.emails.each do |email| + expect(page).to have_content(email.email) + end + end + + it 'removes an email' do + fill_in('email_email', with: 'my@email.com') + click_button('Add') + + email = user.emails.find_by(email: 'my@email.com') + + expect(email).not_to be_nil + expect(page).to have_content('my@email.com') + expect(page).to have_content(user.email) + + user.emails.each do |email| + expect(page).to have_content(email.email) + end + + # There should be only one remove button at this time + click_link('Remove') + + # Force these to reload as they have been cached + user.emails.reload + email = user.emails.find_by(email: 'my@email.com') + + expect(email).to be_nil + expect(page).not_to have_content('my@email.com') + expect(page).to have_content(user.email) + + user.emails.each do |email| + expect(page).to have_content(email.email) + end + end +end |