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
83634554
Commit
83634554
authored
Feb 13, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add variables environment_scope scoped uniquness specs
parent
8a12ea68
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
0 deletions
+69
-0
spec/ee/spec/controllers/ee/projects/variables_controller_spec.rb
...spec/controllers/ee/projects/variables_controller_spec.rb
+69
-0
No files found.
spec/ee/spec/controllers/ee/projects/variables_controller_spec.rb
0 → 100644
View file @
83634554
require
'spec_helper'
describe
Projects
::
VariablesController
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
sign_in
(
user
)
project
.
add_master
(
user
)
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:variable_environment_scope
).
and_return
(
true
)
end
describe
'PATCH #update'
do
let!
(
:variable
)
{
create
(
:ci_variable
,
project:
project
)
}
let
(
:owner
)
{
project
}
subject
do
patch
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
variables_attributes:
variables_attributes
,
format: :json
end
context
'with same key and different environment scope'
do
let
(
:variable_attributes
)
do
{
id:
variable
.
id
,
key:
variable
.
key
,
value:
variable
.
value
,
protected:
variable
.
protected?
.
to_s
,
environment_scope:
variable
.
environment_scope
}
end
let
(
:new_variable_attributes
)
do
{
key:
variable
.
key
,
value:
'dummy_value'
,
protected:
'false'
,
environment_scope:
'prod'
}
end
let
(
:variables_attributes
)
do
[
variable_attributes
,
new_variable_attributes
]
end
it
'does not update the existing variable'
do
expect
{
subject
}.
not_to
change
{
variable
.
reload
.
value
}
end
it
'creates the new variable'
do
expect
{
subject
}.
to
change
{
owner
.
variables
.
count
}.
by
(
1
)
end
it
'returns a successful response'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
it
'has all variables in response'
do
subject
expect
(
response
).
to
match_response_schema
(
'variables'
)
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