Welcome to mirror list, hosted at ThFree Co, Russian Federation.

signup_spec.rb « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7b62438a533485d748b3d8e4323a40cf3e28a5c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
require 'spec_helper'

feature 'Signup', :js, :feature do
  describe 'signup with no errors' do
    context "when sending confirmation email" do
      before { allow_any_instance_of(ApplicationSetting).to receive(:send_user_confirmation_email).and_return(true) }

      it 'creates the user account and sends a confirmation email' do
        user = build(:user)

        visit root_path

        click_link 'Register'

        fill_in 'new_user_name',                with: user.name
        fill_in 'new_user_username',            with: user.username
        fill_in 'new_user_email',               with: user.email
        fill_in 'new_user_email_confirmation',  with: user.email
        fill_in 'new_user_password',            with: user.password
        click_button "Register"

        expect(current_path).to eq users_almost_there_path
        expect(page).to have_content("Please check your email to confirm your account")
      end
    end

    context "when not sending confirmation email" do
      before { allow_any_instance_of(ApplicationSetting).to receive(:send_user_confirmation_email).and_return(false) }

      it 'creates the user account and goes to dashboard' do
        user = build(:user)

        visit root_path

        click_link 'Register'

        fill_in 'new_user_name',                with: user.name
        fill_in 'new_user_username',            with: user.username
        fill_in 'new_user_email',               with: user.email
        fill_in 'new_user_email_confirmation',  with: user.email
        fill_in 'new_user_password',            with: user.password
        click_button "Register"

        expect(current_path).to eq dashboard_projects_path
        expect(page).to have_content("Welcome! You have signed up successfully.")
      end
    end
  end

  describe 'signup with errors' do
    it "displays a form incomplete error" do
      user = build(:user)

      visit root_path

      click_link 'Register'

      fill_in 'new_user_name',     with: user.name
      fill_in 'new_user_username', with: user.username
      fill_in 'new_user_email',    with: user.email
      fill_in 'new_user_password', with: user.password
      click_button "Register"

      expect(page).to have_content('Please retype the email address')
    end

    it "displays an existing email error" do
      existing_user = create(:user)
      user = build(:user)

      visit root_path

      click_link 'Register'

      fill_in 'new_user_name',                  with: user.name
      fill_in 'new_user_username',              with: user.username
      fill_in 'new_user_email',                 with: existing_user.email
      fill_in 'new_user_email_confirmation',    with: existing_user.email
      fill_in 'new_user_password',              with: user.password
      click_button "Register"

      expect(page).to have_content('1 error prohibited this user from being saved')
      expect(page).to have_content('Email has already been taken')
    end

    it 'does not redisplay the password' do
      user = build(:user)

      visit root_path

      click_link 'Register'

      fill_in 'new_user_name',     with: user.name
      fill_in 'new_user_username', with: user.username
      fill_in 'new_user_email',    with: existing_user.email
      fill_in 'new_user_password', with: user.password
      click_button "Register"

      expect(page.body).not_to match(/#{user.password}/)
    end
  end
end