Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
10e18de6
Commit
10e18de6
authored
Jun 14, 2021
by
GitLab Bot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add latest changes from gitlab-org/gitlab@13-12-stable-ee
parent
757327a5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
130 additions
and
4 deletions
+130
-4
app/controllers/projects/merge_requests/diffs_controller.rb
app/controllers/projects/merge_requests/diffs_controller.rb
+4
-1
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-1
app/models/application_setting_implementation.rb
app/models/application_setting_implementation.rb
+1
-0
spec/controllers/projects/merge_requests/diffs_controller_spec.rb
...trollers/projects/merge_requests/diffs_controller_spec.rb
+20
-2
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+17
-0
spec/models/application_setting_spec.rb
spec/models/application_setting_spec.rb
+79
-0
spec/services/submit_usage_ping_service_spec.rb
spec/services/submit_usage_ping_service_spec.rb
+8
-0
No files found.
app/controllers/projects/merge_requests/diffs_controller.rb
View file @
10e18de6
...
@@ -163,7 +163,10 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
...
@@ -163,7 +163,10 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
end
end
def
render_merge_ref_head_diff?
def
render_merge_ref_head_diff?
Gitlab
::
Utils
.
to_boolean
(
params
[
:diff_head
])
&&
@merge_request
.
diffable_merge_ref?
&&
@start_sha
.
nil?
params
[
:diff_id
].
blank?
&&
Gitlab
::
Utils
.
to_boolean
(
params
[
:diff_head
])
&&
@merge_request
.
diffable_merge_ref?
&&
@start_sha
.
nil?
end
end
def
note_positions
def
note_positions
...
...
app/controllers/projects_controller.rb
View file @
10e18de6
...
@@ -510,7 +510,7 @@ class ProjectsController < Projects::ApplicationController
...
@@ -510,7 +510,7 @@ class ProjectsController < Projects::ApplicationController
# `project` calls `find_routable!`, so this will trigger the usual not-found
# `project` calls `find_routable!`, so this will trigger the usual not-found
# behaviour when the user isn't authorized to see the project
# behaviour when the user isn't authorized to see the project
return
unless
project
return
if
project
.
nil?
||
performed?
redirect_to
(
request
.
original_url
.
sub
(
%r{
\.
git/?
\Z
}
,
''
))
redirect_to
(
request
.
original_url
.
sub
(
%r{
\.
git/?
\Z
}
,
''
))
end
end
...
...
app/models/application_setting_implementation.rb
View file @
10e18de6
...
@@ -374,6 +374,7 @@ module ApplicationSettingImplementation
...
@@ -374,6 +374,7 @@ module ApplicationSettingImplementation
def
usage_ping_enabled
def
usage_ping_enabled
usage_ping_can_be_configured?
&&
super
usage_ping_can_be_configured?
&&
super
end
end
alias_method
:usage_ping_enabled?
,
:usage_ping_enabled
def
allowed_key_types
def
allowed_key_types
SUPPORTED_KEY_TYPES
.
select
do
|
type
|
SUPPORTED_KEY_TYPES
.
select
do
|
type
|
...
...
spec/controllers/projects/merge_requests/diffs_controller_spec.rb
View file @
10e18de6
...
@@ -69,6 +69,20 @@ RSpec.describe Projects::MergeRequests::DiffsController do
...
@@ -69,6 +69,20 @@ RSpec.describe Projects::MergeRequests::DiffsController do
end
end
end
end
shared_examples
'show the right diff files with previous diff_id'
do
context
'with previous diff_id'
do
let!
(
:merge_request_diff_1
)
{
merge_request
.
merge_request_diffs
.
create!
(
head_commit_sha:
'6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
)
}
let!
(
:merge_request_diff_2
)
{
merge_request
.
merge_request_diffs
.
create!
(
head_commit_sha:
'5937ac0a7beb003549fc5fd26fc247adbce4a52e'
,
diff_type: :merge_head
)
}
subject
{
go
(
diff_id:
merge_request_diff_1
.
id
,
diff_head:
true
)
}
it
'shows the right diff files'
do
subject
expect
(
json_response
[
"diff_files"
].
size
).
to
eq
(
merge_request_diff_1
.
files_count
)
end
end
end
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:merge_request
)
{
create
(
:merge_request_with_diffs
,
target_project:
project
,
source_project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request_with_diffs
,
target_project:
project
,
source_project:
project
)
}
...
@@ -142,6 +156,8 @@ RSpec.describe Projects::MergeRequests::DiffsController do
...
@@ -142,6 +156,8 @@ RSpec.describe Projects::MergeRequests::DiffsController do
it_behaves_like
'404 for unexistent diffable'
it_behaves_like
'404 for unexistent diffable'
it_behaves_like
'show the right diff files with previous diff_id'
context
'when not authorized'
do
context
'when not authorized'
do
let
(
:another_user
)
{
create
(
:user
)
}
let
(
:another_user
)
{
create
(
:user
)
}
...
@@ -480,6 +496,8 @@ RSpec.describe Projects::MergeRequests::DiffsController do
...
@@ -480,6 +496,8 @@ RSpec.describe Projects::MergeRequests::DiffsController do
it_behaves_like
'404 for unexistent diffable'
it_behaves_like
'404 for unexistent diffable'
it_behaves_like
'show the right diff files with previous diff_id'
context
'when not authorized'
do
context
'when not authorized'
do
let
(
:other_user
)
{
create
(
:user
)
}
let
(
:other_user
)
{
create
(
:user
)
}
...
@@ -499,7 +517,7 @@ RSpec.describe Projects::MergeRequests::DiffsController do
...
@@ -499,7 +517,7 @@ RSpec.describe Projects::MergeRequests::DiffsController do
it_behaves_like
'serializes diffs with expected arguments'
do
it_behaves_like
'serializes diffs with expected arguments'
do
let
(
:collection
)
{
Gitlab
::
Diff
::
FileCollection
::
MergeRequestDiffBatch
}
let
(
:collection
)
{
Gitlab
::
Diff
::
FileCollection
::
MergeRequestDiffBatch
}
let
(
:expected_options
)
{
collection_arguments
(
current_page:
1
,
total_pages:
1
)
}
let
(
:expected_options
)
{
collection_arguments
(
current_page:
1
,
total_pages:
1
)
.
merge
(
merge_ref_head_diff:
false
)
}
end
end
it_behaves_like
'successful request'
it_behaves_like
'successful request'
...
@@ -522,7 +540,7 @@ RSpec.describe Projects::MergeRequests::DiffsController do
...
@@ -522,7 +540,7 @@ RSpec.describe Projects::MergeRequests::DiffsController do
it_behaves_like
'serializes diffs with expected arguments'
do
it_behaves_like
'serializes diffs with expected arguments'
do
let
(
:collection
)
{
Gitlab
::
Diff
::
FileCollection
::
Compare
}
let
(
:collection
)
{
Gitlab
::
Diff
::
FileCollection
::
Compare
}
let
(
:expected_options
)
{
collection_arguments
}
let
(
:expected_options
)
{
collection_arguments
.
merge
(
merge_ref_head_diff:
false
)
}
end
end
it_behaves_like
'successful request'
it_behaves_like
'successful request'
...
...
spec/controllers/projects_controller_spec.rb
View file @
10e18de6
...
@@ -375,6 +375,23 @@ RSpec.describe ProjectsController do
...
@@ -375,6 +375,23 @@ RSpec.describe ProjectsController do
end
end
end
end
context
'when project is moved and git format is requested'
do
let
(
:old_path
)
{
project
.
path
+
'old'
}
before
do
project
.
redirect_routes
.
create!
(
path:
"
#{
project
.
namespace
.
full_path
}
/
#{
old_path
}
"
)
project
.
add_developer
(
user
)
sign_in
(
user
)
end
it
'redirects to new project path'
do
get
:show
,
params:
{
namespace_id:
project
.
namespace
,
id:
old_path
},
format: :git
expect
(
response
).
to
redirect_to
(
project_path
(
project
,
format: :git
))
end
end
context
'when the project is forked and has a repository'
,
:request_store
do
context
'when the project is forked and has a repository'
,
:request_store
do
let
(
:public_project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:public_project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:other_user
)
{
create
(
:user
)
}
let
(
:other_user
)
{
create
(
:user
)
}
...
...
spec/models/application_setting_spec.rb
View file @
10e18de6
...
@@ -363,6 +363,85 @@ RSpec.describe ApplicationSetting do
...
@@ -363,6 +363,85 @@ RSpec.describe ApplicationSetting do
.
is_less_than
(
65536
)
.
is_less_than
(
65536
)
end
end
describe
'usage_ping_enabled setting'
do
shared_examples
'usage ping enabled'
do
it
do
expect
(
setting
.
usage_ping_enabled
).
to
eq
(
true
)
expect
(
setting
.
usage_ping_enabled?
).
to
eq
(
true
)
end
end
shared_examples
'usage ping disabled'
do
it
do
expect
(
setting
.
usage_ping_enabled
).
to
eq
(
false
)
expect
(
setting
.
usage_ping_enabled?
).
to
eq
(
false
)
end
end
context
'when setting is in database'
do
context
'with usage_ping_enabled disabled'
do
before
do
setting
.
update!
(
usage_ping_enabled:
false
)
end
it_behaves_like
'usage ping disabled'
end
context
'with usage_ping_enabled enabled'
do
before
do
setting
.
update!
(
usage_ping_enabled:
true
)
end
it_behaves_like
'usage ping enabled'
end
end
context
'when setting is in GitLab config'
do
context
'with usage_ping_enabled disabled'
do
before
do
allow
(
Settings
.
gitlab
).
to
receive
(
:usage_ping_enabled
).
and_return
(
false
)
end
it_behaves_like
'usage ping disabled'
end
context
'with usage_ping_enabled enabled'
do
before
do
allow
(
Settings
.
gitlab
).
to
receive
(
:usage_ping_enabled
).
and_return
(
true
)
end
it_behaves_like
'usage ping enabled'
end
end
context
'when setting in database false and setting in GitLab config true'
do
before
do
setting
.
update!
(
usage_ping_enabled:
false
)
allow
(
Settings
.
gitlab
).
to
receive
(
:usage_ping_enabled
).
and_return
(
true
)
end
it_behaves_like
'usage ping disabled'
end
context
'when setting database true and setting in GitLab config false'
do
before
do
setting
.
update!
(
usage_ping_enabled:
true
)
allow
(
Settings
.
gitlab
).
to
receive
(
:usage_ping_enabled
).
and_return
(
false
)
end
it_behaves_like
'usage ping disabled'
end
context
'when setting database true and setting in GitLab config true'
do
before
do
setting
.
update!
(
usage_ping_enabled:
true
)
allow
(
Settings
.
gitlab
).
to
receive
(
:usage_ping_enabled
).
and_return
(
true
)
end
it_behaves_like
'usage ping enabled'
end
end
context
'key restrictions'
do
context
'key restrictions'
do
it
'supports all key types'
do
it
'supports all key types'
do
expect
(
described_class
::
SUPPORTED_KEY_TYPES
).
to
contain_exactly
(
:rsa
,
:dsa
,
:ecdsa
,
:ed25519
)
expect
(
described_class
::
SUPPORTED_KEY_TYPES
).
to
contain_exactly
(
:rsa
,
:dsa
,
:ecdsa
,
:ed25519
)
...
...
spec/services/submit_usage_ping_service_spec.rb
View file @
10e18de6
...
@@ -90,6 +90,14 @@ RSpec.describe SubmitUsagePingService do
...
@@ -90,6 +90,14 @@ RSpec.describe SubmitUsagePingService do
it_behaves_like
'does not run'
it_behaves_like
'does not run'
end
end
context
'when usage ping is disabled from GitLab config file'
do
before
do
stub_config_setting
(
usage_ping_enabled:
false
)
end
it_behaves_like
'does not run'
end
context
'when usage ping is enabled'
do
context
'when usage ping is enabled'
do
before
do
before
do
stub_usage_data_connections
stub_usage_data_connections
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment