BigW Consortium Gitlab

user_callout_spec.rb 1.46 KB
Newer Older
1 2 3 4
require 'spec_helper'

describe 'User Callouts', js: true do
  let(:user) { create(:user) }
5
  let(:another_user) { create(:user) }
6
  let(:project) { create(:project, path: 'gitlab', name: 'sample') }
7 8

  before do
9
    sign_in(user)
10
    project.team << [user, :master]
11 12
  end

13
  it 'takes you to the profile preferences when the link is clicked' do
14 15 16 17 18
    visit dashboard_projects_path
    click_link 'Check it out'
    expect(current_path).to eq profile_preferences_path
  end

19 20 21 22
  it 'does not show when cookie is set' do
    visit dashboard_projects_path

    within('.user-callout') do
Annabel Dunstone Gray committed
23
      find('.close').trigger('click')
24 25 26 27 28 29 30
    end

    visit dashboard_projects_path

    expect(page).not_to have_selector('.user-callout')
  end

31 32 33
  describe 'user callout should appear in two routes' do
    it 'shows up on the user profile' do
      visit user_path(user)
34
      expect(find('.user-callout')).to have_content 'Customize your experience'
35 36 37 38
    end

    it 'shows up on the dashboard projects' do
      visit dashboard_projects_path
39
      expect(find('.user-callout')).to have_content 'Customize your experience'
40 41 42 43 44
    end
  end

  it 'hides the user callout when click on the dismiss icon' do
    visit user_path(user)
45
    within('.user-callout') do
46
      find('.close').click
47
    end
48 49 50 51 52 53
    expect(page).not_to have_selector('.user-callout')
  end

  it 'does not show callout on another users profile' do
    visit user_path(another_user)
    expect(page).not_to have_selector('.user-callout')
54
  end
55
end