summaryrefslogtreecommitdiff
path: root/spec/features/profiles/user_visits_profile_spec.rb
blob: 1c90a794099dc8d07c5e437a578450b67bf52853 (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
60
61
62
63
64
# frozen_string_literal: true

require 'spec_helper'

describe 'User visits their profile' do
  let(:user) { create(:user) }

  before do
    sign_in(user)
  end

  it 'shows correct menu item' do
    visit(profile_path)

    expect(page).to have_active_navigation('Profile')
  end

  it 'shows profile info' do
    visit(profile_path)

    expect(page).to have_content "This information will appear on your profile"
  end

  context 'when user has groups' do
    let(:group) do
      create :group do |group|
        group.add_owner(user)
      end
    end

    let!(:project) do
      create(:project, :repository, namespace: group) do |project|
        create(:closed_issue_event, project: project)
        project.add_maintainer(user)
      end
    end

    def click_on_profile_picture
      find(:css, '.header-user-dropdown-toggle').click

      page.within ".header-user" do
        click_link "Profile"
      end
    end

    it 'shows user groups', :js do
      visit(profile_path)
      click_on_profile_picture

      page.within ".cover-block" do
        expect(page).to have_content user.name
        expect(page).to have_content user.username
      end

      page.within ".content" do
        click_link "Groups"
      end

      page.within "#groups" do
        expect(page).to have_content group.name
      end
    end
  end
end