BigW Consortium Gitlab

preferences_spec.rb 2.27 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 11
  end

  describe 'User changes their application theme', js: true do
12 13
    let(:default) { Gitlab::Themes.default }
    let(:theme)   { Gitlab::Themes.by_id(5) }
14

15 16 17 18
    it 'creates a flash message' do
      choose "user_theme_id_#{theme.id}"

      expect_preferences_saved_message
19 20
    end

21
    it 'updates their preference' do
22 23
      choose "user_theme_id_#{theme.id}"

24 25 26 27
      allowing_for_delay do
        visit page.current_path
        expect(page).to have_checked_field("user_theme_id_#{theme.id}")
      end
28 29
    end

30
    it 'reflects the changes immediately' do
31 32 33 34 35 36 37 38 39
      expect(page).to have_selector("body.#{default.css_class}")

      choose "user_theme_id_#{theme.id}"

      expect(page).not_to have_selector("body.#{default.css_class}")
      expect(page).to have_selector("body.#{theme.css_class}")
    end
  end

40 41 42 43 44 45 46 47 48 49
  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'

50 51 52 53
      allowing_for_delay do
        visit page.current_path
        expect(page).to have_checked_field('user_color_scheme_id_5')
      end
54 55 56
    end
  end

57
  describe 'User changes their default dashboard', js: true do
58 59 60 61 62 63 64 65 66 67 68
    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'

69 70
      allowing_for_delay do
        find('#logo').click
Phil Hughes committed
71

72
        expect(page).to have_content("You don't have starred projects yet")
73 74
        expect(page.current_path).to eq starred_dashboard_projects_path
      end
75 76

      click_link 'Your Projects'
Phil Hughes committed
77

78
      expect(page).not_to have_content("You don't have starred projects yet")
Douwe Maan committed
79
      expect(page.current_path).to eq dashboard_projects_path
80 81 82 83
    end
  end

  def expect_preferences_saved_message
Robert Speicher committed
84
    page.within('.flash-container') do
85
      expect(page).to have_content('Preferences saved.')
86 87 88
    end
  end
end