BigW Consortium Gitlab

profile_spec.rb 1.56 KB
Newer Older
1 2
require 'spec_helper'

3
describe 'Profile account page', feature: true do
4 5 6 7 8 9
  let(:user) { create(:user) }

  before do
    login_as :user
  end

10
  describe 'when signup is enabled' do
11
    before do
12
      stub_application_setting(signup_enabled: true)
Dmitriy Zaporozhets committed
13
      visit profile_account_path
14
    end
Dmitriy Zaporozhets committed
15

16
    it { expect(page).to have_content('Remove account') }
Dmitriy Zaporozhets committed
17

18
    it 'deletes the account' do
19
      expect { click_link 'Delete account' }.to change { User.count }.by(-1)
20
      expect(current_path).to eq(new_user_session_path)
21 22 23
    end
  end

24
  describe 'when signup is disabled' do
25
    before do
26
      stub_application_setting(signup_enabled: false)
Dmitriy Zaporozhets committed
27
      visit profile_account_path
28 29
    end

30
    it 'does not have option to remove account' do
31
      expect(page).not_to have_content('Remove account')
32
      expect(current_path).to eq(profile_account_path)
33 34
    end
  end
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

  describe 'when I reset private token' do
    before do
      visit profile_account_path
    end

    it 'resets private token' do
      previous_token = find("#private-token").value

      click_link('Reset private token')

      expect(find('#private-token').value).not_to eq(previous_token)
    end
  end

  describe 'when I reset incoming email token' do
    before do
      allow(Gitlab.config.incoming_email).to receive(:enabled).and_return(true)
      visit profile_account_path
    end

    it 'resets incoming email token' do
      previous_token = find('#incoming-email-token').value

      click_link('Reset incoming email token')

      expect(find('#incoming-email-token').value).not_to eq(previous_token)
    end
  end
Dmitriy Zaporozhets committed
64
end