BigW Consortium Gitlab

preferences_spec.rb 1.48 KB
Newer Older
1 2
require 'spec_helper'

3
describe 'Profile > Preferences', feature: true do
4 5 6 7
  let(:user) { create(:user) }

  before do
    login_as(user)
8
    visit profile_preferences_path
9 10
  end

11 12 13 14 15 16 17 18 19 20
  describe 'User changes their syntax highlighting theme', js: true do
    it 'creates a flash message' do
      choose 'user_color_scheme_id_5'

      expect_preferences_saved_message
    end

    it 'updates their preference' do
      choose 'user_color_scheme_id_5'

21 22 23 24
      allowing_for_delay do
        visit page.current_path
        expect(page).to have_checked_field('user_color_scheme_id_5')
      end
25 26 27
    end
  end

28
  describe 'User changes their default dashboard', js: true do
29 30 31 32 33 34 35 36 37 38 39
    it 'creates a flash message' do
      select 'Starred Projects', from: 'user_dashboard'
      click_button 'Save'

      expect_preferences_saved_message
    end

    it 'updates their preference' do
      select 'Starred Projects', from: 'user_dashboard'
      click_button 'Save'

40 41
      allowing_for_delay do
        find('#logo').click
Phil Hughes committed
42

43
        expect(page).to have_content("You don't have starred projects yet")
44 45
        expect(page.current_path).to eq starred_dashboard_projects_path
      end
46

47
      click_link 'Your projects'
Phil Hughes committed
48

49
      expect(page).not_to have_content("You don't have starred projects yet")
Douwe Maan committed
50
      expect(page.current_path).to eq dashboard_projects_path
51 52 53 54
    end
  end

  def expect_preferences_saved_message
Robert Speicher committed
55
    page.within('.flash-container') do
56
      expect(page).to have_content('Preferences saved.')
57 58 59
    end
  end
end