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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Users > User browses projects on user page', :js, feature_category: :projects do
let!(:user) { create :user }
let!(:private_project) do
create :project, :private, name: 'private', namespace: user.namespace do |project|
project.add_maintainer(user)
end
end
let!(:internal_project) do
create :project, :internal, name: 'internal', namespace: user.namespace do |project|
project.add_maintainer(user)
end
end
let!(:public_project) do
create :project, :public, name: 'public', namespace: user.namespace do |project|
project.add_maintainer(user)
end
end
def click_nav_link(name)
page.within '.nav-links' do
click_link name
end
end
before do
stub_feature_flags(profile_tabs_vue: false)
end
it 'hides loading spinner after load', :js do
visit user_path(user)
click_nav_link('Personal projects')
wait_for_requests
expect(page).not_to have_selector('.loading-status .loading', visible: true)
end
it 'paginates projects', :js do
project = create(:project, namespace: user.namespace, updated_at: 2.minutes.since)
project2 = create(:project, namespace: user.namespace, updated_at: 1.minute.since)
allow(Project).to receive(:default_per_page).and_return(1)
sign_in(user)
visit user_path(user)
click_nav_link('Personal projects')
wait_for_requests
expect(page).to have_content(project.name)
click_link('Next')
expect(page).to have_content(project2.name)
end
it 'does not have incorrectly interpolated message', :js do
project = create(:project, namespace: user.namespace, updated_at: 2.minutes.since)
sign_in(user)
visit user_path(user)
click_nav_link('Personal projects')
wait_for_requests
expect(page).to have_content(project.name)
expect(page).not_to have_content("_('Updated')")
end
context 'when not signed in' do
it 'renders user public project' do
visit user_path(user)
click_nav_link('Personal projects')
expect(page).to have_css('.tab-content #projects.active')
expect(title).to start_with(user.name)
expect(page).to have_content(public_project.name)
expect(page).not_to have_content(private_project.name)
expect(page).not_to have_content(internal_project.name)
end
end
context 'when signed in as another user' do
let(:another_user) { create :user }
before do
sign_in(another_user)
end
it 'renders user public and internal projects' do
visit user_path(user)
click_nav_link('Personal projects')
expect(title).to start_with(user.name)
expect(page).not_to have_content(private_project.name)
expect(page).to have_content(public_project.name)
expect(page).to have_content(internal_project.name)
end
end
context 'when signed in as user' do
before do
sign_in(user)
end
describe 'personal projects' do
it 'renders all user projects' do
visit user_path(user)
click_nav_link('Personal projects')
expect(title).to start_with(user.name)
expect(page).to have_content(private_project.name)
expect(page).to have_content(public_project.name)
expect(page).to have_content(internal_project.name)
end
end
describe 'contributed projects' do
context 'when user has contributions' do
let(:contributed_project) do
create :project, :public, :empty_repo
end
before do
Issues::CreateService.new(container: contributed_project, current_user: user, params: { title: 'Bug in old browser' }, spam_params: nil).execute
event = create(:push_event, project: contributed_project, author: user)
create(:push_event_payload, event: event, commit_count: 3)
end
it 'renders contributed project' do
visit user_path(user)
expect(title).to start_with(user.name)
expect(page).to have_css('.js-contrib-calendar')
click_nav_link('Contributed projects')
page.within '#contributed' do
expect(page).to have_content(contributed_project.name)
end
end
end
end
end
end
|