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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
694705bc
Commit
694705bc
authored
Aug 25, 2021
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab master
parents
9905d102
b3311e0d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
16 deletions
+54
-16
app/services/merge_requests/merge_to_ref_service.rb
app/services/merge_requests/merge_to_ref_service.rb
+5
-4
ee/spec/frontend/epic/components/epic_header_spec.js
ee/spec/frontend/epic/components/epic_header_spec.js
+1
-1
spec/frontend/members/components/modals/leave_modal_spec.js
spec/frontend/members/components/modals/leave_modal_spec.js
+6
-2
spec/services/merge_requests/merge_to_ref_service_spec.rb
spec/services/merge_requests/merge_to_ref_service_spec.rb
+20
-8
spec/support/database/prevent_cross_database_modification.rb
spec/support/database/prevent_cross_database_modification.rb
+3
-1
spec/support_specs/database/prevent_cross_database_modification_spec.rb
...pecs/database/prevent_cross_database_modification_spec.rb
+19
-0
No files found.
app/services/merge_requests/merge_to_ref_service.rb
View file @
694705bc
...
...
@@ -13,12 +13,12 @@ module MergeRequests
class
MergeToRefService
<
MergeRequests
::
MergeBaseService
extend
::
Gitlab
::
Utils
::
Override
def
execute
(
merge_request
)
def
execute
(
merge_request
,
cache_merge_to_ref_calls
=
false
)
@merge_request
=
merge_request
error_check!
commit_id
=
commit
commit_id
=
commit
(
cache_merge_to_ref_calls
)
raise_error
(
'Conflicts detected during merge'
)
unless
commit_id
...
...
@@ -65,8 +65,9 @@ module MergeRequests
params
[
:allow_conflicts
]
||
false
end
def
commit
if
Feature
.
enabled?
(
:cache_merge_to_ref_calls
,
project
,
default_enabled:
false
)
def
commit
(
cache_merge_to_ref_calls
=
false
)
if
cache_merge_to_ref_calls
&&
Feature
.
enabled?
(
:cache_merge_to_ref_calls
,
project
,
default_enabled:
false
)
Rails
.
cache
.
fetch
(
cache_key
,
expires_in:
1
.
day
)
do
extracted_merge_to_ref
end
...
...
ee/spec/frontend/epic/components/epic_header_spec.js
View file @
694705bc
...
...
@@ -152,7 +152,7 @@ describe('EpicHeaderComponent', () => {
expect
(
toggleButton
.
exists
()).
toBeTruthy
();
expect
(
toggleButton
.
attributes
(
'
aria-label
'
)).
toBe
(
'
Toggle sidebar
'
);
expect
(
toggleButton
.
classes
()).
toEqual
(
expect
.
arrayContaining
([
(
'
d-block
'
,
'
d-sm-none
'
,
'
gutter-toggle
'
)
]),
expect
.
arrayContaining
([
'
gl-display-block
'
,
'
d-sm-none
'
,
'
gutter-toggle
'
]),
);
});
...
...
spec/frontend/members/components/modals/leave_modal_spec.js
View file @
694705bc
...
...
@@ -99,10 +99,14 @@ describe('LeaveModal', () => {
});
});
it
(
"
does NOT display oncall schedules list when member's user is NOT a part of on-call schedules
"
,
()
=>
{
it
(
"
does NOT display oncall schedules list when member's user is NOT a part of on-call schedules
"
,
async
()
=>
{
wrapper
.
destroy
();
const
memberWithoutOncallSchedules
=
cloneDeep
(
member
);
delete
(
memberWithoutOncallSchedules
,
'
user.oncallSchedules
'
)
;
delete
memberWithoutOncallSchedules
.
user
.
oncallSchedules
;
createComponent
({
member
:
memberWithoutOncallSchedules
});
await
nextTick
();
expect
(
findOncallSchedulesList
().
exists
()).
toBe
(
false
);
});
});
...
...
spec/services/merge_requests/merge_to_ref_service_spec.rb
View file @
694705bc
...
...
@@ -43,12 +43,22 @@ RSpec.describe MergeRequests::MergeToRefService do
# warm the cache
#
service
.
execute
(
merge_request
)
service
.
execute
(
merge_request
,
true
)
end
context
'when cache_merge_to_ref_calls parameter is true'
do
it
'caches the response'
,
:request_store
do
expect
{
3
.
times
{
service
.
execute
(
merge_request
,
true
)
}
}
.
not_to
change
(
Gitlab
::
GitalyClient
,
:get_request_count
)
end
end
it
'caches the response'
,
:request_store
do
expect
{
3
.
times
{
service
.
execute
(
merge_request
)
}
}
.
not_to
change
(
Gitlab
::
GitalyClient
,
:get_request_count
)
context
'when cache_merge_to_ref_calls parameter is false'
do
it
'does not cache the response'
,
:request_store
do
expect
(
Gitlab
::
GitalyClient
).
to
receive
(
:call
).
at_least
(
3
).
times
.
and_call_original
3
.
times
{
service
.
execute
(
merge_request
,
false
)
}
end
end
end
...
...
@@ -58,13 +68,15 @@ RSpec.describe MergeRequests::MergeToRefService do
# warm the cache
#
service
.
execute
(
merge_request
)
service
.
execute
(
merge_request
,
true
)
end
it
'does not cache the response'
,
:request_store
do
expect
(
Gitlab
::
GitalyClient
).
to
receive
(
:call
).
at_least
(
3
).
times
.
and_call_original
[
true
,
false
].
each
do
|
cache_merge_to_ref_calls
|
it
'does not cache the response, regardless of cache_merge_to_ref_calls state'
,
:request_store
do
expect
(
Gitlab
::
GitalyClient
).
to
receive
(
:call
).
at_least
(
3
).
times
.
and_call_original
3
.
times
{
service
.
execute
(
merge_request
)
}
3
.
times
{
service
.
execute
(
merge_request
,
cache_merge_to_ref_calls
)
}
end
end
end
end
...
...
spec/support/database/prevent_cross_database_modification.rb
View file @
694705bc
...
...
@@ -74,7 +74,9 @@ module Database
return
if
cross_database_context
[
:transaction_depth_by_db
].
values
.
all?
(
&
:zero?
)
tables
=
PgQuery
.
parse
(
sql
).
dml_tables
parsed_query
=
PgQuery
.
parse
(
sql
)
tables
=
sql
.
downcase
.
include?
(
' for update'
)
?
parsed_query
.
tables
:
parsed_query
.
dml_tables
return
if
tables
.
empty?
cross_database_context
[
:modified_tables_by_db
][
database
].
merge
(
tables
)
...
...
spec/support_specs/database/prevent_cross_database_modification_spec.rb
View file @
694705bc
...
...
@@ -99,6 +99,25 @@ RSpec.describe 'Database::PreventCrossDatabaseModification' do
end
end
end
context
'when executing a SELECT FOR UPDATE query'
do
def
run_queries
project
.
touch
pipeline
.
lock!
end
context
'outside transaction'
do
it
{
expect
{
run_queries
}.
not_to
raise_error
}
end
context
'when data modification happens in a transaction'
do
it
'raises error'
do
Project
.
transaction
do
expect
{
run_queries
}.
to
raise_error
/Cross-database data modification/
end
end
end
end
end
context
'when CI association is modified through project'
do
...
...
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