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
|
require 'spec_helper'
describe 'Projects > Show > User sees Git instructions' do
set(:user) { create(:user) }
shared_examples_for 'redirects to the sign in page' do
it 'redirects to the sign in page' do
expect(current_path).to eq(new_user_session_path)
end
end
shared_examples_for 'shows details of empty project with no repo' do
it 'shows Git command line instructions' do
click_link 'Create empty repository'
page.within '.empty_wrapper' do
expect(page).to have_content('Command line instructions')
end
end
end
shared_examples_for 'shows details of empty project' do
let(:user_has_ssh_key) { false }
it 'shows details' do
expect(page).not_to have_content('Git global setup')
page.all(:css, '.git-empty .clone').each do |element|
expect(element.text).to include(project.http_url_to_repo)
end
expect(page).to have_field('project_clone', with: project.http_url_to_repo) unless user_has_ssh_key
end
end
shared_examples_for 'shows details of non empty project' do
let(:user_has_ssh_key) { false }
it 'shows details' do
page.within('.breadcrumbs .breadcrumb-item-text') do
expect(page).to have_content(project.title)
end
expect(page).to have_field('project_clone', with: project.http_url_to_repo) unless user_has_ssh_key
end
end
context 'when project is public' do
context 'when project has no repo' do
set(:project) { create(:project, :public) }
before do
sign_in(project.owner)
visit project_path(project)
end
include_examples 'shows details of empty project with no repo'
end
context 'when project is empty' do
set(:project) { create(:project_empty_repo, :public) }
context 'when not signed in' do
before do
visit(project_path(project))
end
include_examples 'shows details of empty project'
end
context 'when signed in' do
before do
sign_in(user)
end
context 'when user does not have ssh keys' do
before do
visit(project_path(project))
end
include_examples 'shows details of empty project'
end
context 'when user has ssh keys' do
before do
create(:personal_key, user: user)
visit(project_path(project))
end
include_examples 'shows details of empty project' do
let(:user_has_ssh_key) { true }
end
end
end
end
context 'when project is not empty' do
set(:project) { create(:project, :public, :repository) }
before do
visit(project_path(project))
end
context 'when not signed in' do
before do
allow(Gitlab.config.gitlab).to receive(:host).and_return('www.example.com')
end
include_examples 'shows details of non empty project'
end
context 'when signed in' do
before do
sign_in(user)
end
context 'when user does not have ssh keys' do
before do
visit(project_path(project))
end
include_examples 'shows details of non empty project'
end
context 'when user has ssh keys' do
before do
create(:personal_key, user: user)
visit(project_path(project))
end
include_examples 'shows details of non empty project' do
let(:user_has_ssh_key) { true }
end
end
end
end
end
context 'when project is internal' do
set(:project) { create(:project, :internal, :repository) }
context 'when not signed in' do
before do
visit(project_path(project))
end
include_examples 'redirects to the sign in page'
end
context 'when signed in' do
before do
sign_in(user)
visit(project_path(project))
end
include_examples 'shows details of non empty project'
end
end
context 'when project is private' do
set(:project) { create(:project, :private) }
before do
visit(project_path(project))
end
include_examples 'redirects to the sign in page'
end
end
|