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
Boxiang Sun
gitlab-ce
Commits
ce418036
Commit
ce418036
authored
May 05, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add callbacks in bulk
parent
606584c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
6 deletions
+42
-6
app/services/projects/propagate_service.rb
app/services/projects/propagate_service.rb
+24
-6
spec/services/projects/propagate_service_spec.rb
spec/services/projects/propagate_service_spec.rb
+18
-0
No files found.
app/services/projects/propagate_service.rb
View file @
ce418036
...
@@ -35,12 +35,12 @@ module Projects
...
@@ -35,12 +35,12 @@ module Projects
service_hash
.
merge
(
'project_id'
=>
project_id
).
values
service_hash
.
merge
(
'project_id'
=>
project_id
).
values
end
end
#
Project.transaction do
Project
.
transaction
do
# Service.create!(service_hash_list)
Gitlab
::
SQL
::
BulkInsert
.
new
(
service_hash
.
keys
+
[
'project_id'
],
# end
service_list
,
Gitlab
::
SQL
::
BulkInsert
.
new
(
service_hash
.
keys
+
[
'project_id'
],
'services'
).
execute
service_list
,
run_callbacks
(
batch
)
'services'
).
execute
end
end
end
def
project_ids_batch
def
project_ids_batch
...
@@ -72,5 +72,23 @@ module Projects
...
@@ -72,5 +72,23 @@ module Projects
end
end
end
end
end
end
def
run_callbacks
(
batch
)
if
active_external_issue_tracker?
Project
.
where
(
id:
batch
).
update_all
(
has_external_issue_tracker:
true
)
end
if
active_external_wiki?
Project
.
where
(
id:
batch
).
update_all
(
has_external_wiki:
true
)
end
end
def
active_external_issue_tracker?
@template
[
'category'
]
==
'issue_tracker'
&&
@template
[
'active'
]
&&
!
@template
[
'default'
]
end
def
active_external_wiki?
@template
[
'type'
]
==
'ExternalWikiService'
&&
@template
[
'active'
]
end
end
end
end
end
spec/services/projects/propagate_service_spec.rb
View file @
ce418036
...
@@ -78,5 +78,23 @@ describe Projects::PropagateService, services: true do
...
@@ -78,5 +78,23 @@ describe Projects::PropagateService, services: true do
to
change
{
Service
.
count
}.
by
(
project_total
+
1
)
to
change
{
Service
.
count
}.
by
(
project_total
+
1
)
end
end
end
end
describe
'external tracker'
do
it
'updates the project external tracker'
do
service_template
.
update
(
category:
'issue_tracker'
,
default:
false
)
expect
{
described_class
.
propagate
(
service_template
)
}.
to
change
{
project
.
reload
.
has_external_issue_tracker
}.
to
(
true
)
end
end
describe
'external wiki'
do
it
'updates the project external tracker'
do
service_template
.
update
(
type:
'ExternalWikiService'
)
expect
{
described_class
.
propagate
(
service_template
)
}.
to
change
{
project
.
reload
.
has_external_wiki
}.
to
(
true
)
end
end
end
end
end
end
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