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
8adaba67
Commit
8adaba67
authored
Jan 02, 2020
by
Etienne Baqué
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added rspec for ReviewAppSetup file
Added relevant tests for this file.
parent
08519db4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
0 deletions
+67
-0
ee/spec/fixtures/api/schemas/environments.json
ee/spec/fixtures/api/schemas/environments.json
+1
-0
ee/spec/fixtures/api/schemas/review_app.json
ee/spec/fixtures/api/schemas/review_app.json
+10
-0
spec/serializers/review_app_setup_entity_spec.rb
spec/serializers/review_app_setup_entity_spec.rb
+56
-0
No files found.
ee/spec/fixtures/api/schemas/environments.json
View file @
8adaba67
...
...
@@ -8,6 +8,7 @@
"minItems"
:
1
,
"type"
:
"array"
},
"review_app"
:
{
"$ref"
:
"review_app.json"
},
"available_count"
:
{
"type"
:
"integer"
},
...
...
ee/spec/fixtures/api/schemas/review_app.json
0 → 100644
View file @
8adaba67
{
"type"
:
"object"
,
"required"
:
[
"can_setup_review_app?"
],
"properties"
:
{
"can_setup_review_app?"
:
{
"type"
:
"boolean"
},
"clusters_empty?"
:
{
"type"
:
"boolean"
},
"review_snippet"
:
{
"type"
:
"string "
}
},
"additionalProperties"
:
false
}
spec/serializers/review_app_setup_entity_spec.rb
0 → 100644
View file @
8adaba67
# frozen_string_literal: true
require
'spec_helper'
describe
ReviewAppSetupEntity
do
let_it_be
(
:user
)
{
create
(
:admin
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:presenter
)
{
ProjectPresenter
.
new
(
project
,
current_user:
user
)
}
let
(
:entity
)
{
described_class
.
new
(
presenter
)
}
let
(
:request
)
{
double
(
'request'
)
}
before
do
allow
(
request
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
request
).
to
receive
(
:project
).
and_return
(
project
)
end
subject
{
entity
.
as_json
}
describe
'#as_json'
do
it
'contains can_setup_review_app?'
do
expect
(
subject
).
to
include
(
:can_setup_review_app?
)
end
context
'when the user can setup a review app'
do
before
do
allow
(
presenter
).
to
receive
(
:can_setup_review_app?
).
and_return
(
true
)
end
it
'contains relevant fields'
do
expect
(
subject
.
keys
).
to
include
(
:clusters_empty?
,
:review_snippet
)
end
it
'exposes the relevant review snippet'
do
review_app_snippet
=
YAML
.
safe_load
(
File
.
read
(
Rails
.
root
.
join
(
'lib'
,
'gitlab'
,
'ci'
,
'snippets'
,
'review_app_default.yml'
))).
inspect
expect
(
subject
[
:review_snippet
]).
to
eq
(
review_app_snippet
)
end
it
'exposes whether the project has associated clusters'
do
allow
(
project
).
to
receive
(
:clusters
).
and_return
([])
expect
(
subject
[
:clusters_empty?
]).
to
be_truthy
end
end
context
'when the user cannot setup a review app'
do
before
do
allow
(
presenter
).
to
receive
(
:can_setup_review_app?
).
and_return
(
false
)
end
it
'does not expose certain fields'
do
expect
(
subject
.
keys
).
not_to
include
(
:clusters_empty?
,
:review_snippet
)
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