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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'User visits their profile', feature_category: :user_profile do
let_it_be_with_refind(:user) { create(:user, :no_super_sidebar) }
before do
stub_feature_flags(profile_tabs_vue: false)
stub_feature_flags(edit_user_profile_vue: false)
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
it 'shows user readme' do
create(:project, :repository, :public, path: user.username, namespace: user.namespace)
visit(user_path(user))
expect(find('.file-content')).to have_content('testme')
end
it 'hides empty user readme' do
project = create(:project, :repository, :public, path: user.username, namespace: user.namespace)
Files::UpdateService.new(
project,
user,
start_branch: 'master',
branch_name: 'master',
commit_message: 'Update feature',
file_path: 'README.md',
file_content: ''
).execute
visit(user_path(user))
expect(page).not_to have_selector('.file-content')
end
context 'for tabs' do
shared_examples_for 'shows expected content' do
it 'shows expected content', :js do
visit(user_path(user))
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 link
end
page.within div do
expect(page).to have_content expected_content
end
end
end
context 'for Groups' do
let_it_be(:group) do
create :group do |group|
group.add_owner(user)
end
end
let_it_be(:project) do
create(:project, :repository, namespace: group) do |project|
create(:closed_issue_event, project: project)
project.add_maintainer(user)
end
end
it_behaves_like 'shows expected content' do
let(:link) { 'Groups' }
let(:div) { '#groups' }
let(:expected_content) { group.name }
end
end
context 'for Contributed projects' do
let_it_be(:project) do
create(:project) do |project|
project.add_maintainer(user)
end
end
before do
push_event = create(:push_event, project: project, author: user)
create(:push_event_payload, event: push_event)
end
it_behaves_like 'shows expected content' do
let(:link) { 'Contributed projects' }
let(:div) { '#contributed' }
let(:expected_content) { project.name }
end
end
context 'for personal projects' do
let_it_be(:project) do
create(:project, namespace: user.namespace)
end
it_behaves_like 'shows expected content' do
let(:link) { 'Personal projects' }
let(:div) { '#projects' }
let(:expected_content) { project.name }
end
end
context 'for starred projects' do
let_it_be(:project) { create(:project, :public) }
before do
user.toggle_star(project)
end
it_behaves_like 'shows expected content' do
let(:link) { 'Starred projects' }
let(:div) { '#starred' }
let(:expected_content) { project.name }
end
end
context 'for snippets' do
let_it_be(:snippet) { create(:snippet, :public, author: user) }
it_behaves_like 'shows expected content' do
let(:link) { 'Snippets' }
let(:div) { '#snippets' }
let(:expected_content) { snippet.title }
end
end
context 'for followers' do
let_it_be(:fan) { create(:user) }
before do
fan.follow(user)
end
it_behaves_like 'shows expected content' do
let(:link) { 'Followers' }
let(:div) { '#followers' }
let(:expected_content) { fan.name }
end
end
context 'for following' do
let_it_be(:star) { create(:user) }
before do
user.follow(star)
end
it_behaves_like 'shows expected content' do
let(:link) { 'Following' }
let(:div) { '#following' }
let(:expected_content) { star.name }
end
end
end
end
|