summaryrefslogtreecommitdiff
path: root/spec/features/profiles/preferences_spec.rb
blob: 15c8677fcd36f29762b7343d2d956e8cd2da94b7 (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
require 'spec_helper'

describe 'Profile > Preferences', feature: true do
  let(:user) { create(:user) }

  before do
    login_as(user)
    visit profile_preferences_path
  end

  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'

      allowing_for_delay do
        visit page.current_path
        expect(page).to have_checked_field('user_color_scheme_id_5')
      end
    end
  end

  describe 'User changes their default dashboard', js: true do
    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'

      allowing_for_delay do
        find('#logo').click

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

      click_link 'Your projects'

      expect(page).not_to have_content("You don't have starred projects yet")
      expect(page.current_path).to eq dashboard_projects_path
    end
  end

  def expect_preferences_saved_message
    page.within('.flash-container') do
      expect(page).to have_content('Preferences saved.')
    end
  end
end