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
acdf6fdf
Commit
acdf6fdf
authored
Jul 07, 2021
by
Luke Duncalfe
Committed by
Igor Drozdov
Jul 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Integration#can_test? and #test specs
parent
737ec1bb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
45 deletions
+24
-45
spec/models/integration_spec.rb
spec/models/integration_spec.rb
+24
-45
No files found.
spec/models/integration_spec.rb
View file @
acdf6fdf
...
...
@@ -139,61 +139,40 @@ RSpec.describe Integration do
end
end
describe
"Test Button"
do
let
(
:integration
)
{
build
(
:service
,
project:
project
)
}
describe
'#can_test?'
do
subject
{
integration
.
can_test?
}
context
'when project-level integration
'
do
let
(
:project
)
{
create
(
:
project
)
}
context
'when integration is project-level
'
do
let
(
:integration
)
{
build
(
:service
,
project:
project
)
}
it
{
is_expected
.
to
be
true
}
end
context
'when instance-level integration'
do
Integration
.
available_integration_types
.
each
do
|
type
|
let
(
:integration
)
do
described_class
.
send
(
:integration_type_to_model
,
type
).
new
(
instance:
true
)
end
it
{
is_expected
.
to
be
false
}
end
end
context
'when group-level integration'
do
Integration
.
available_integration_types
.
each
do
|
type
|
let
(
:integration
)
do
described_class
.
send
(
:integration_type_to_model
,
type
).
new
(
group_id:
group
.
id
)
end
context
'when integration is not project-level'
do
let
(
:integration
)
{
build
(
:service
,
project:
nil
)
}
it
{
is_expected
.
to
be
false
}
end
end
end
describe
'#test'
do
let
(
:integration
)
{
build
(
:service
,
project:
project
)
}
let
(
:data
)
{
'test'
}
context
'when repository is not empty'
do
let
(
:project
)
{
build
(
:project
,
:repository
)
}
it
'test runs execute'
do
it
'calls #execute'
do
expect
(
integration
).
to
receive
(
:execute
).
with
(
data
)
integration
.
test
(
data
)
end
end
context
'when repository is empty'
do
let
(
:project
)
{
build
(
:project
)
}
it
'returns a result'
do
result
=
'foo'
allow
(
integration
).
to
receive
(
:execute
).
with
(
data
).
and_return
(
result
)
it
'test runs execute'
do
expect
(
integration
).
to
receive
(
:execute
).
with
(
data
)
integration
.
test
(
data
)
end
end
expect
(
integration
.
test
(
data
)).
to
eq
(
success:
true
,
result:
result
)
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