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
Jérome Perrin
gitlab-ce
Commits
04ee970c
Commit
04ee970c
authored
Aug 16, 2017
by
Jarka Kadlecova
Committed by
Douwe Maan
Aug 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't create event in Merge Request Create Service
parent
aae23494
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
2 deletions
+63
-2
app/services/merge_requests/create_service.rb
app/services/merge_requests/create_service.rb
+0
-1
db/post_migrate/20170815060945_remove_duplicate_mr_events.rb
db/post_migrate/20170815060945_remove_duplicate_mr_events.rb
+26
-0
db/schema.rb
db/schema.rb
+1
-1
spec/migrations/remove_duplicate_mr_events_spec.rb
spec/migrations/remove_duplicate_mr_events_spec.rb
+26
-0
spec/services/merge_requests/create_service_spec.rb
spec/services/merge_requests/create_service_spec.rb
+10
-0
No files found.
app/services/merge_requests/create_service.rb
View file @
04ee970c
...
...
@@ -25,7 +25,6 @@ module MergeRequests
end
def
after_create
(
issuable
)
event_service
.
open_mr
(
issuable
,
current_user
)
todo_service
.
new_merge_request
(
issuable
,
current_user
)
issuable
.
cache_merge_request_closes_issues!
(
current_user
)
update_merge_requests_head_pipeline
(
issuable
)
...
...
db/post_migrate/20170815060945_remove_duplicate_mr_events.rb
0 → 100644
View file @
04ee970c
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
RemoveDuplicateMrEvents
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
class
Event
<
ActiveRecord
::
Base
self
.
table_name
=
'events'
end
def
up
base_condition
=
"action = 1 AND target_type = 'MergeRequest' AND created_at > '2017-08-13'"
Event
.
select
(
'target_id, count(*)'
)
.
where
(
base_condition
)
.
group
(
'target_id'
).
having
(
'count(*) > 1'
).
each
do
|
event
|
duplicates
=
Event
.
where
(
"
#{
base_condition
}
AND target_id =
#{
event
.
target_id
}
"
).
pluck
(
:id
)
duplicates
.
shift
Event
.
where
(
id:
duplicates
).
delete_all
end
end
def
down
end
end
db/schema.rb
View file @
04ee970c
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201708
09161910
)
do
ActiveRecord
::
Schema
.
define
(
version:
201708
15060945
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
spec/migrations/remove_duplicate_mr_events_spec.rb
0 → 100644
View file @
04ee970c
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20170815060945_remove_duplicate_mr_events.rb'
)
describe
RemoveDuplicateMrEvents
,
truncate:
true
do
let
(
:migration
)
{
described_class
.
new
}
describe
'#up'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:merge_requests
)
{
create_list
(
:merge_request
,
2
)
}
let
(
:issue
)
{
create
(
:issue
)
}
let!
(
:events
)
do
[
create
(
:event
,
:created
,
author:
user
,
target:
merge_requests
.
first
),
create
(
:event
,
:created
,
author:
user
,
target:
merge_requests
.
first
),
create
(
:event
,
:updated
,
author:
user
,
target:
merge_requests
.
first
),
create
(
:event
,
:created
,
author:
user
,
target:
merge_requests
.
second
),
create
(
:event
,
:created
,
author:
user
,
target:
issue
),
create
(
:event
,
:created
,
author:
user
,
target:
issue
)
]
end
it
'removes duplicated merge request create records'
do
expect
{
migration
.
up
}.
to
change
{
Event
.
count
}.
from
(
6
).
to
(
5
)
end
end
end
spec/services/merge_requests/create_service_spec.rb
View file @
04ee970c
...
...
@@ -48,6 +48,16 @@ describe MergeRequests::CreateService do
expect
(
Todo
.
where
(
attributes
).
count
).
to
be_zero
end
it
'creates exactly 1 create MR event'
do
attributes
=
{
action:
Event
::
CREATED
,
target_id:
@merge_request
.
id
,
target_type:
@merge_request
.
class
.
name
}
expect
(
Event
.
where
(
attributes
).
count
).
to
eq
(
1
)
end
context
'when merge request is assigned to someone'
do
let
(
:opts
)
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