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
eacf3983
Commit
eacf3983
authored
Jan 21, 2021
by
Nicolas Dular
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use shared examples for onboarding progress specs
This is migrating all existing specs to use the shared example.
parent
26d31ce4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
93 deletions
+28
-93
ee/spec/services/gitlab_subscriptions/apply_trial_service_spec.rb
...services/gitlab_subscriptions/apply_trial_service_spec.rb
+2
-12
ee/spec/services/subscriptions/create_service_spec.rb
ee/spec/services/subscriptions/create_service_spec.rb
+10
-20
spec/controllers/repositories/git_http_controller_spec.rb
spec/controllers/repositories/git_http_controller_spec.rb
+3
-5
spec/services/merge_requests/after_create_service_spec.rb
spec/services/merge_requests/after_create_service_spec.rb
+2
-11
spec/services/post_receive_service_spec.rb
spec/services/post_receive_service_spec.rb
+3
-11
spec/workers/namespaces/onboarding_pipeline_created_worker_spec.rb
...ers/namespaces/onboarding_pipeline_created_worker_spec.rb
+5
-20
spec/workers/namespaces/onboarding_user_added_worker_spec.rb
spec/workers/namespaces/onboarding_user_added_worker_spec.rb
+3
-14
No files found.
ee/spec/services/gitlab_subscriptions/apply_trial_service_spec.rb
View file @
eacf3983
...
...
@@ -26,13 +26,7 @@ RSpec.describe GitlabSubscriptions::ApplyTrialService do
expect
(
execute
).
to
eq
({
success:
true
})
end
it
'records a namespace onboarding progress action'
do
expect_next_instance_of
(
OnboardingProgressService
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
).
with
(
action: :trial_started
)
end
execute
end
it_behaves_like
'records an onboarding progress action'
,
:trial_started
end
context
'error while applying the trial'
do
...
...
@@ -47,11 +41,7 @@ RSpec.describe GitlabSubscriptions::ApplyTrialService do
expect
(
execute
).
to
eq
(
expected_response
)
end
it
'does not record a namespace onboarding progress action'
do
expect
(
OnboardingProgressService
).
not_to
receive
(
:new
)
execute
end
it_behaves_like
'does not record an onboarding progress action'
end
end
end
ee/spec/services/subscriptions/create_service_spec.rb
View file @
eacf3983
...
...
@@ -3,7 +3,7 @@
require
'spec_helper'
RSpec
.
describe
Subscriptions
::
CreateService
do
subject
{
described_class
.
new
(
user
,
group:
group
,
customer_params:
customer_params
,
subscription_params:
subscription_params
)
}
subject
(
:execute
)
{
described_class
.
new
(
user
,
group:
group
,
customer_params:
customer_params
,
subscription_params:
subscription_params
).
execute
}
let_it_be
(
:user
)
{
create
(
:user
,
id:
111
,
first_name:
'First name'
,
last_name:
'Last name'
,
email:
'first.last@gitlab.com'
)
}
let_it_be
(
:group
)
{
create
(
:group
,
id:
222
,
name:
'Group name'
)
}
...
...
@@ -39,7 +39,7 @@ RSpec.describe Subscriptions::CreateService do
end
it
'returns the response hash'
do
expect
(
subject
.
execute
).
to
eq
(
success:
false
,
data:
{
errors:
'failed to create customer'
})
expect
(
execute
).
to
eq
(
success:
false
,
data:
{
errors:
'failed to create customer'
})
end
end
...
...
@@ -54,7 +54,7 @@ RSpec.describe Subscriptions::CreateService do
.
with
(
anything
,
customer_email
,
'token'
)
.
and_return
(
success:
true
,
data:
{
success:
true
,
subscription_id:
'xxx'
})
subject
.
execute
execute
end
context
'when failing to create a subscription'
do
...
...
@@ -63,16 +63,10 @@ RSpec.describe Subscriptions::CreateService do
end
it
'returns the response hash'
do
expect
(
subject
.
execute
).
to
eq
(
success:
false
,
data:
{
errors:
'failed to create subscription'
})
expect
(
execute
).
to
eq
(
success:
false
,
data:
{
errors:
'failed to create subscription'
})
end
it
'does not register a namespace onboarding progress action'
do
OnboardingProgress
.
onboard
(
group
)
subject
.
execute
expect
(
OnboardingProgress
.
completed?
(
group
,
:subscription_created
)).
to
eq
(
false
)
end
it_behaves_like
'does not record an onboarding progress action'
end
context
'when successfully creating a subscription'
do
...
...
@@ -81,7 +75,7 @@ RSpec.describe Subscriptions::CreateService do
end
it
'returns the response hash'
do
expect
(
subject
.
execute
).
to
eq
(
success:
true
,
data:
{
success:
true
,
subscription_id:
'xxx'
})
expect
(
execute
).
to
eq
(
success:
true
,
data:
{
success:
true
,
subscription_id:
'xxx'
})
end
end
end
...
...
@@ -95,21 +89,17 @@ RSpec.describe Subscriptions::CreateService do
it
'passes the correct parameters for creating a customer'
do
expect
(
client
).
to
receive
(
:create_customer
).
with
(
create_service_params
[
:customer
])
subject
.
execute
execute
end
it
'passes the correct parameters for creating a subscription'
do
expect
(
client
).
to
receive
(
:create_subscription
).
with
(
create_service_params
[
:subscription
],
customer_email
,
'token'
)
subject
.
execute
execute
end
it
'registers a namespace onboarding progress action'
do
OnboardingProgress
.
onboard
(
group
)
subject
.
execute
expect
(
OnboardingProgress
.
completed?
(
group
,
:subscription_created
)).
to
eq
(
true
)
it_behaves_like
'records an onboarding progress action'
,
:subscription_created
do
let
(
:namespace
)
{
group
}
end
end
end
...
...
spec/controllers/repositories/git_http_controller_spec.rb
View file @
eacf3983
...
...
@@ -52,12 +52,10 @@ RSpec.describe Repositories::GitHttpController do
}.
from
(
0
).
to
(
1
)
end
it
'records an onboarding progress action'
do
expect_next_instance_of
(
OnboardingProgressService
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
).
with
(
action: :git_read
)
end
it_behaves_like
'records an onboarding progress action'
,
:git_read
do
let
(
:namespace
)
{
project
.
namespace
}
s
end_request
s
ubject
{
send_request
}
end
end
end
...
...
spec/services/merge_requests/after_create_service_spec.rb
View file @
eacf3983
...
...
@@ -3,8 +3,6 @@
require
'spec_helper'
RSpec
.
describe
MergeRequests
::
AfterCreateService
do
include
AfterNextHelpers
let_it_be
(
:merge_request
)
{
create
(
:merge_request
)
}
subject
(
:after_create_service
)
do
...
...
@@ -66,15 +64,8 @@ RSpec.describe MergeRequests::AfterCreateService do
execute_service
end
it
'registers an onboarding progress action'
do
OnboardingProgress
.
onboard
(
merge_request
.
target_project
.
namespace
)
expect_next
(
OnboardingProgressService
,
merge_request
.
target_project
.
namespace
)
.
to
receive
(
:execute
).
with
(
action: :merge_request_created
).
and_call_original
execute_service
expect
(
OnboardingProgress
.
completed?
(
merge_request
.
target_project
.
namespace
,
:merge_request_created
)).
to
be
(
true
)
it_behaves_like
'records an onboarding progress action'
,
:merge_request_created
do
let
(
:namespace
)
{
merge_request
.
target_project
.
namespace
}
end
end
end
spec/services/post_receive_service_spec.rb
View file @
eacf3983
...
...
@@ -4,7 +4,6 @@ require 'spec_helper'
RSpec
.
describe
PostReceiveService
do
include
Gitlab
::
Routing
include
AfterNextHelpers
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:wiki_repo
,
namespace:
user
.
namespace
)
}
...
...
@@ -47,11 +46,7 @@ RSpec.describe PostReceiveService do
expect
(
subject
).
to
be_empty
end
it
'does not record an onboarding progress action'
do
expect_next
(
OnboardingProgressService
).
not_to
receive
(
:execute
)
subject
end
it_behaves_like
'does not record an onboarding progress action'
end
context
'when repository is nil'
do
...
...
@@ -88,11 +83,8 @@ RSpec.describe PostReceiveService do
expect
(
response
.
reference_counter_decreased
).
to
be
(
true
)
end
it
'records an onboarding progress action'
do
expect_next
(
OnboardingProgressService
,
project
.
namespace
)
.
to
receive
(
:execute
).
with
(
action: :git_write
)
subject
it_behaves_like
'records an onboarding progress action'
,
:git_write
do
let
(
:namespace
)
{
project
.
namespace
}
end
end
...
...
spec/workers/namespaces/onboarding_pipeline_created_worker_spec.rb
View file @
eacf3983
...
...
@@ -3,30 +3,15 @@
require
'spec_helper'
RSpec
.
describe
Namespaces
::
OnboardingPipelineCreatedWorker
,
'#perform'
do
include
AfterNextHelpers
let_it_be
(
:ci_pipeline
)
{
create
(
:ci_pipeline
)
}
before
do
OnboardingProgress
.
onboard
(
ci_pipeline
.
project
.
namespace
)
end
it
'registers an onboarding progress action'
do
expect_next
(
OnboardingProgressService
,
ci_pipeline
.
project
.
namespace
)
.
to
receive
(
:execute
).
with
(
action: :pipeline_created
).
and_call_original
it_behaves_like
'records an onboarding progress action'
,
:pipeline_created
do
let
(
:namespace
)
{
ci_pipeline
.
project
.
namespace
}
subject
.
perform
(
ci_pipeline
.
project
.
namespace_id
)
expect
(
OnboardingProgress
.
completed?
(
ci_pipeline
.
project
.
namespace
,
:pipeline_created
)).
to
eq
(
true
)
subject
{
described_class
.
new
.
perform
(
ci_pipeline
.
project
.
namespace_id
)
}
end
context
"when a namespace doesn't exist"
do
it
'does not register an onboarding progress action'
do
expect_next
(
OnboardingProgressService
,
ci_pipeline
.
project
.
namespace
).
not_to
receive
(
:execute
)
subject
.
perform
(
nil
)
expect
(
OnboardingProgress
.
completed?
(
ci_pipeline
.
project
.
namespace
,
:pipeline_created
)).
to
eq
(
false
)
end
it_behaves_like
'does not record an onboarding progress action'
do
subject
{
described_class
.
new
.
perform
(
nil
)
}
end
end
spec/workers/namespaces/onboarding_user_added_worker_spec.rb
View file @
eacf3983
...
...
@@ -3,20 +3,9 @@
require
'spec_helper'
RSpec
.
describe
Namespaces
::
OnboardingUserAddedWorker
,
'#perform'
do
include
AfterNextHelpers
let_it_be
(
:namespace
)
{
create
(
:group
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
subject
{
described_class
.
new
.
perform
(
namespace
.
id
)
}
before
do
OnboardingProgress
.
onboard
(
group
)
end
it
'registers an onboarding progress action'
do
expect_next
(
OnboardingProgressService
,
group
)
.
to
receive
(
:execute
).
with
(
action: :user_added
).
and_call_original
subject
.
perform
(
group
.
id
)
expect
(
OnboardingProgress
.
completed?
(
group
,
:user_added
)).
to
be
(
true
)
end
it_behaves_like
'records an onboarding progress action'
,
:user_added
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