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
...
@@ -26,13 +26,7 @@ RSpec.describe GitlabSubscriptions::ApplyTrialService do
expect
(
execute
).
to
eq
({
success:
true
})
expect
(
execute
).
to
eq
({
success:
true
})
end
end
it
'records a namespace onboarding progress action'
do
it_behaves_like
'records an onboarding progress action'
,
:trial_started
expect_next_instance_of
(
OnboardingProgressService
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
).
with
(
action: :trial_started
)
end
execute
end
end
end
context
'error while applying the trial'
do
context
'error while applying the trial'
do
...
@@ -47,11 +41,7 @@ RSpec.describe GitlabSubscriptions::ApplyTrialService do
...
@@ -47,11 +41,7 @@ RSpec.describe GitlabSubscriptions::ApplyTrialService do
expect
(
execute
).
to
eq
(
expected_response
)
expect
(
execute
).
to
eq
(
expected_response
)
end
end
it
'does not record a namespace onboarding progress action'
do
it_behaves_like
'does not record an onboarding progress action'
expect
(
OnboardingProgressService
).
not_to
receive
(
:new
)
execute
end
end
end
end
end
end
end
ee/spec/services/subscriptions/create_service_spec.rb
View file @
eacf3983
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
Subscriptions
::
CreateService
do
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
(
: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'
)
}
let_it_be
(
:group
)
{
create
(
:group
,
id:
222
,
name:
'Group name'
)
}
...
@@ -39,7 +39,7 @@ RSpec.describe Subscriptions::CreateService do
...
@@ -39,7 +39,7 @@ RSpec.describe Subscriptions::CreateService do
end
end
it
'returns the response hash'
do
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
end
end
...
@@ -54,7 +54,7 @@ RSpec.describe Subscriptions::CreateService do
...
@@ -54,7 +54,7 @@ RSpec.describe Subscriptions::CreateService do
.
with
(
anything
,
customer_email
,
'token'
)
.
with
(
anything
,
customer_email
,
'token'
)
.
and_return
(
success:
true
,
data:
{
success:
true
,
subscription_id:
'xxx'
})
.
and_return
(
success:
true
,
data:
{
success:
true
,
subscription_id:
'xxx'
})
subject
.
execute
execute
end
end
context
'when failing to create a subscription'
do
context
'when failing to create a subscription'
do
...
@@ -63,16 +63,10 @@ RSpec.describe Subscriptions::CreateService do
...
@@ -63,16 +63,10 @@ RSpec.describe Subscriptions::CreateService do
end
end
it
'returns the response hash'
do
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
end
it
'does not register a namespace onboarding progress action'
do
it_behaves_like
'does not record an onboarding progress action'
OnboardingProgress
.
onboard
(
group
)
subject
.
execute
expect
(
OnboardingProgress
.
completed?
(
group
,
:subscription_created
)).
to
eq
(
false
)
end
end
end
context
'when successfully creating a subscription'
do
context
'when successfully creating a subscription'
do
...
@@ -81,7 +75,7 @@ RSpec.describe Subscriptions::CreateService do
...
@@ -81,7 +75,7 @@ RSpec.describe Subscriptions::CreateService do
end
end
it
'returns the response hash'
do
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
end
end
end
...
@@ -95,21 +89,17 @@ RSpec.describe Subscriptions::CreateService do
...
@@ -95,21 +89,17 @@ RSpec.describe Subscriptions::CreateService do
it
'passes the correct parameters for creating a customer'
do
it
'passes the correct parameters for creating a customer'
do
expect
(
client
).
to
receive
(
:create_customer
).
with
(
create_service_params
[
:customer
])
expect
(
client
).
to
receive
(
:create_customer
).
with
(
create_service_params
[
:customer
])
subject
.
execute
execute
end
end
it
'passes the correct parameters for creating a subscription'
do
it
'passes the correct parameters for creating a subscription'
do
expect
(
client
).
to
receive
(
:create_subscription
).
with
(
create_service_params
[
:subscription
],
customer_email
,
'token'
)
expect
(
client
).
to
receive
(
:create_subscription
).
with
(
create_service_params
[
:subscription
],
customer_email
,
'token'
)
subject
.
execute
execute
end
end
it
'registers a namespace onboarding progress action'
do
it_behaves_like
'records an onboarding progress action'
,
:subscription_created
do
OnboardingProgress
.
onboard
(
group
)
let
(
:namespace
)
{
group
}
subject
.
execute
expect
(
OnboardingProgress
.
completed?
(
group
,
:subscription_created
)).
to
eq
(
true
)
end
end
end
end
end
end
...
...
spec/controllers/repositories/git_http_controller_spec.rb
View file @
eacf3983
...
@@ -52,12 +52,10 @@ RSpec.describe Repositories::GitHttpController do
...
@@ -52,12 +52,10 @@ RSpec.describe Repositories::GitHttpController do
}.
from
(
0
).
to
(
1
)
}.
from
(
0
).
to
(
1
)
end
end
it
'records an onboarding progress action'
do
it_behaves_like
'records an onboarding progress action'
,
:git_read
do
expect_next_instance_of
(
OnboardingProgressService
)
do
|
service
|
let
(
:namespace
)
{
project
.
namespace
}
expect
(
service
).
to
receive
(
:execute
).
with
(
action: :git_read
)
end
s
end_request
s
ubject
{
send_request
}
end
end
end
end
end
end
...
...
spec/services/merge_requests/after_create_service_spec.rb
View file @
eacf3983
...
@@ -3,8 +3,6 @@
...
@@ -3,8 +3,6 @@
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
...
@@ -66,15 +64,8 @@ RSpec.describe MergeRequests::AfterCreateService do
...
@@ -66,15 +64,8 @@ RSpec.describe MergeRequests::AfterCreateService do
execute_service
execute_service
end
end
it
'registers an onboarding progress action'
do
it_behaves_like
'records an onboarding progress action'
,
:merge_request_created
do
OnboardingProgress
.
onboard
(
merge_request
.
target_project
.
namespace
)
let
(
:namespace
)
{
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
)
end
end
end
end
end
end
spec/services/post_receive_service_spec.rb
View file @
eacf3983
...
@@ -4,7 +4,6 @@ require 'spec_helper'
...
@@ -4,7 +4,6 @@ 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
)
}
...
@@ -47,11 +46,7 @@ RSpec.describe PostReceiveService do
...
@@ -47,11 +46,7 @@ RSpec.describe PostReceiveService do
expect
(
subject
).
to
be_empty
expect
(
subject
).
to
be_empty
end
end
it
'does not record an onboarding progress action'
do
it_behaves_like
'does not record an onboarding progress action'
expect_next
(
OnboardingProgressService
).
not_to
receive
(
:execute
)
subject
end
end
end
context
'when repository is nil'
do
context
'when repository is nil'
do
...
@@ -88,11 +83,8 @@ RSpec.describe PostReceiveService do
...
@@ -88,11 +83,8 @@ RSpec.describe PostReceiveService do
expect
(
response
.
reference_counter_decreased
).
to
be
(
true
)
expect
(
response
.
reference_counter_decreased
).
to
be
(
true
)
end
end
it
'records an onboarding progress action'
do
it_behaves_like
'records an onboarding progress action'
,
:git_write
do
expect_next
(
OnboardingProgressService
,
project
.
namespace
)
let
(
:namespace
)
{
project
.
namespace
}
.
to
receive
(
:execute
).
with
(
action: :git_write
)
subject
end
end
end
end
...
...
spec/workers/namespaces/onboarding_pipeline_created_worker_spec.rb
View file @
eacf3983
...
@@ -3,30 +3,15 @@
...
@@ -3,30 +3,15 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
Namespaces
::
OnboardingPipelineCreatedWorker
,
'#perform'
do
RSpec
.
describe
Namespaces
::
OnboardingPipelineCreatedWorker
,
'#perform'
do
include
AfterNextHelpers
let_it_be
(
:ci_pipeline
)
{
create
(
:ci_pipeline
)
}
let_it_be
(
:ci_pipeline
)
{
create
(
:ci_pipeline
)
}
before
do
it_behaves_like
'records an onboarding progress action'
,
:pipeline_created
do
OnboardingProgress
.
onboard
(
ci_pipeline
.
project
.
namespace
)
let
(
:namespace
)
{
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
subject
.
perform
(
ci_pipeline
.
project
.
namespace_id
)
subject
{
described_class
.
new
.
perform
(
ci_pipeline
.
project
.
namespace_id
)
}
expect
(
OnboardingProgress
.
completed?
(
ci_pipeline
.
project
.
namespace
,
:pipeline_created
)).
to
eq
(
true
)
end
end
context
"when a namespace doesn't exist"
do
it_behaves_like
'does not record an onboarding progress action'
do
it
'does not register an onboarding progress action'
do
subject
{
described_class
.
new
.
perform
(
nil
)
}
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
end
end
end
end
spec/workers/namespaces/onboarding_user_added_worker_spec.rb
View file @
eacf3983
...
@@ -3,20 +3,9 @@
...
@@ -3,20 +3,9 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
Namespaces
::
OnboardingUserAddedWorker
,
'#perform'
do
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
it_behaves_like
'records an onboarding progress action'
,
:user_added
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
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