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
e460ade7
Commit
e460ade7
authored
Dec 31, 2020
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move all create_action calls to service
As an abstraction layer for the model
parent
d6d1304e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
12 deletions
+15
-12
app/services/merge_requests/after_create_service.rb
app/services/merge_requests/after_create_service.rb
+1
-1
app/services/post_receive_service.rb
app/services/post_receive_service.rb
+1
-1
ee/app/services/subscriptions/create_service.rb
ee/app/services/subscriptions/create_service.rb
+1
-1
spec/controllers/repositories/git_http_controller_spec.rb
spec/controllers/repositories/git_http_controller_spec.rb
+1
-1
spec/services/merge_requests/after_create_service_spec.rb
spec/services/merge_requests/after_create_service_spec.rb
+5
-3
spec/services/post_receive_service_spec.rb
spec/services/post_receive_service_spec.rb
+6
-5
No files found.
app/services/merge_requests/after_create_service.rb
View file @
e460ade7
...
@@ -12,7 +12,7 @@ module MergeRequests
...
@@ -12,7 +12,7 @@ module MergeRequests
merge_request
.
diffs
(
include_stats:
false
).
write_cache
merge_request
.
diffs
(
include_stats:
false
).
write_cache
merge_request
.
create_cross_references!
(
current_user
)
merge_request
.
create_cross_references!
(
current_user
)
NamespaceOnboardingAction
.
create_action
(
merge_request
.
target_project
.
namespace
,
:merge_request_created
)
OnboardingProgressService
.
new
(
merge_request
.
target_project
.
namespace
).
execute
(
action:
:merge_request_created
)
end
end
end
end
end
end
...
...
app/services/post_receive_service.rb
View file @
e460ade7
...
@@ -94,7 +94,7 @@ class PostReceiveService
...
@@ -94,7 +94,7 @@ class PostReceiveService
end
end
def
record_onboarding_progress
def
record_onboarding_progress
NamespaceOnboardingAction
.
create_action
(
project
.
namespace
,
:git_write
)
OnboardingProgressService
.
new
(
project
.
namespace
).
execute
(
action:
:git_write
)
end
end
end
end
...
...
ee/app/services/subscriptions/create_service.rb
View file @
e460ade7
...
@@ -24,7 +24,7 @@ module Subscriptions
...
@@ -24,7 +24,7 @@ module Subscriptions
response
=
client
.
create_subscription
(
create_subscription_params
,
billing_email
,
token
)
response
=
client
.
create_subscription
(
create_subscription_params
,
billing_email
,
token
)
NamespaceOnboardingAction
.
create_action
(
@group
,
:subscription_created
)
if
response
[
:success
]
OnboardingProgressService
.
new
(
@group
).
execute
(
action:
:subscription_created
)
if
response
[
:success
]
response
response
end
end
...
...
spec/controllers/repositories/git_http_controller_spec.rb
View file @
e460ade7
...
@@ -52,7 +52,7 @@ RSpec.describe Repositories::GitHttpController do
...
@@ -52,7 +52,7 @@ RSpec.describe Repositories::GitHttpController do
}.
from
(
0
).
to
(
1
)
}.
from
(
0
).
to
(
1
)
end
end
it
'records a
namespace
onboarding progress action'
do
it
'records a
n
onboarding progress action'
do
expect_next_instance_of
(
OnboardingProgressService
)
do
|
service
|
expect_next_instance_of
(
OnboardingProgressService
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
).
with
(
action: :git_read
)
expect
(
service
).
to
receive
(
:execute
).
with
(
action: :git_read
)
end
end
...
...
spec/services/merge_requests/after_create_service_spec.rb
View file @
e460ade7
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
MergeRequests
::
AfterCreateService
do
RSpec
.
describe
MergeRequests
::
AfterCreateService
do
include
AfterNextHelpers
let_it_be
(
:merge_request
)
{
create
(
:merge_request
)
}
let_it_be
(
:merge_request
)
{
create
(
:merge_request
)
}
subject
(
:after_create_service
)
do
subject
(
:after_create_service
)
do
...
@@ -56,9 +58,9 @@ RSpec.describe MergeRequests::AfterCreateService do
...
@@ -56,9 +58,9 @@ RSpec.describe MergeRequests::AfterCreateService do
execute_service
execute_service
end
end
it
'records a
namespace
onboarding progress action'
do
it
'records a
n
onboarding progress action'
do
expect
(
NamespaceOnboardingAction
).
to
receive
(
:create_action
)
expect
_next
(
OnboardingProgressService
,
merge_request
.
target_project
.
namespace
)
.
with
(
merge_request
.
target_project
.
namespace
,
:merge_request_created
).
and_call_original
.
to
receive
(
:execute
).
with
(
action:
:merge_request_created
).
and_call_original
expect
{
execute_service
}.
to
change
(
NamespaceOnboardingAction
,
:count
).
by
(
1
)
expect
{
execute_service
}.
to
change
(
NamespaceOnboardingAction
,
:count
).
by
(
1
)
end
end
...
...
spec/services/post_receive_service_spec.rb
View file @
e460ade7
...
@@ -4,6 +4,7 @@ require 'spec_helper'
...
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec
.
describe
PostReceiveService
do
RSpec
.
describe
PostReceiveService
do
include
Gitlab
::
Routing
include
Gitlab
::
Routing
include
AfterNextHelpers
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:wiki_repo
,
namespace:
user
.
namespace
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:wiki_repo
,
namespace:
user
.
namespace
)
}
...
@@ -46,8 +47,8 @@ RSpec.describe PostReceiveService do
...
@@ -46,8 +47,8 @@ RSpec.describe PostReceiveService do
expect
(
subject
).
to
be_empty
expect
(
subject
).
to
be_empty
end
end
it
'does not record a
namespace
onboarding progress action'
do
it
'does not record a
n
onboarding progress action'
do
expect
(
NamespaceOnboardingAction
).
not_to
receive
(
:create_action
)
expect
_next
(
OnboardingProgressService
).
not_to
receive
(
:execute
)
subject
subject
end
end
...
@@ -87,9 +88,9 @@ RSpec.describe PostReceiveService do
...
@@ -87,9 +88,9 @@ RSpec.describe PostReceiveService do
expect
(
response
.
reference_counter_decreased
).
to
be
(
true
)
expect
(
response
.
reference_counter_decreased
).
to
be
(
true
)
end
end
it
'records a
namespace
onboarding progress action'
do
it
'records a
n
onboarding progress action'
do
expect
(
NamespaceOnboardingAction
).
to
receive
(
:create_action
)
expect
_next
(
OnboardingProgressService
,
project
.
namespace
)
.
with
(
project
.
namespace
,
:git_write
)
.
to
receive
(
:execute
).
with
(
action:
:git_write
)
subject
subject
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