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
6303b598
Commit
6303b598
authored
Jul 27, 2020
by
Jason Goodman
Committed by
Shinya Maeda
Jul 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Feature Flags Controller Put Request Specs
parent
2dbcb567
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
220 deletions
+108
-220
ee/spec/controllers/projects/feature_flags_controller_spec.rb
...pec/controllers/projects/feature_flags_controller_spec.rb
+108
-220
No files found.
ee/spec/controllers/projects/feature_flags_controller_spec.rb
View file @
6303b598
...
@@ -903,6 +903,17 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -903,6 +903,17 @@ RSpec.describe Projects::FeatureFlagsController do
end
end
describe
'PUT update.json'
do
describe
'PUT update.json'
do
def
put_request
(
feature_flag
,
feature_flag_params
)
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
iid:
feature_flag
.
iid
,
operations_feature_flag:
feature_flag_params
}
put
(
:update
,
params:
params
,
format: :json
,
as: :json
)
end
subject
{
put
(
:update
,
params:
params
,
format: :json
)
}
subject
{
put
(
:update
,
params:
params
,
format: :json
)
}
let!
(
:feature_flag
)
do
let!
(
:feature_flag
)
do
...
@@ -963,13 +974,7 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -963,13 +974,7 @@ RSpec.describe Projects::FeatureFlagsController do
feature_flag
=
create
(
:operations_feature_flag
,
project:
project
,
name:
'my_flag'
,
active:
false
)
feature_flag
=
create
(
:operations_feature_flag
,
project:
project
,
name:
'my_flag'
,
active:
false
)
create
(
:operations_feature_flag_scope
,
feature_flag:
feature_flag
,
environment_scope:
'production'
,
active:
true
)
create
(
:operations_feature_flag_scope
,
feature_flag:
feature_flag
,
environment_scope:
'production'
,
active:
true
)
params
=
{
put_request
(
feature_flag
,
{
active:
true
})
namespace_id:
project
.
namespace
,
project_id:
project
,
iid:
feature_flag
.
iid
,
operations_feature_flag:
{
active:
true
}
}
put
(
:update
,
params:
params
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'feature_flag'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'feature_flag'
,
dir:
'ee'
)
...
@@ -1122,27 +1127,13 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1122,27 +1127,13 @@ RSpec.describe Projects::FeatureFlagsController do
end
end
describe
"updating the strategy"
do
describe
"updating the strategy"
do
def
request_params
(
scope
,
strategies
)
{
namespace_id:
project
.
namespace
,
project_id:
project
,
iid:
feature_flag
.
iid
,
operations_feature_flag:
{
scopes_attributes:
[
{
id:
scope
.
id
,
strategies:
strategies
}
]
}
}
end
it
'creates a default strategy'
do
it
'creates a default strategy'
do
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[])
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[])
params
=
request_params
(
scope
,
[{
name:
'default'
,
parameters:
{}
}])
put
(
:update
,
params:
params
,
format: :json
,
as: :json
)
put_request
(
feature_flag
,
scopes_attributes:
[{
id:
scope
.
id
,
strategies:
[{
name:
'default'
,
parameters:
{}
}]
}])
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
...
@@ -1156,10 +1147,12 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1156,10 +1147,12 @@ RSpec.describe Projects::FeatureFlagsController do
it
'creates a gradualRolloutUserId strategy'
do
it
'creates a gradualRolloutUserId strategy'
do
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[])
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[])
params
=
request_params
(
scope
,
[{
name:
'gradualRolloutUserId'
,
parameters:
{
groupId:
'default'
,
percentage:
"70"
}
}])
put
(
:update
,
params:
params
,
format: :json
)
put_request
(
feature_flag
,
scopes_attributes:
[{
id:
scope
.
id
,
strategies:
[{
name:
'gradualRolloutUserId'
,
parameters:
{
groupId:
'default'
,
percentage:
"70"
}
}]
}])
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
...
@@ -1176,9 +1169,11 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1176,9 +1169,11 @@ RSpec.describe Projects::FeatureFlagsController do
it
'creates a userWithId strategy'
do
it
'creates a userWithId strategy'
do
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[{
name:
'default'
,
parameters:
{}
}])
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[{
name:
'default'
,
parameters:
{}
}])
params
=
request_params
(
scope
,
[{
name:
'userWithId'
,
parameters:
{
userIds:
'sam,fred'
}
}])
put
(
:update
,
params:
params
,
format: :json
,
as: :json
)
put_request
(
feature_flag
,
scopes_attributes:
[{
id:
scope
.
id
,
strategies:
[{
name:
'userWithId'
,
parameters:
{
userIds:
'sam,fred'
}
}]
}])
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
...
@@ -1192,10 +1187,12 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1192,10 +1187,12 @@ RSpec.describe Projects::FeatureFlagsController do
it
'updates an existing strategy'
do
it
'updates an existing strategy'
do
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[{
name:
'default'
,
parameters:
{}
}])
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[{
name:
'default'
,
parameters:
{}
}])
params
=
request_params
(
scope
,
[{
name:
'gradualRolloutUserId'
,
parameters:
{
groupId:
'default'
,
percentage:
"50"
}
}])
put
(
:update
,
params:
params
,
format: :json
)
put_request
(
feature_flag
,
scopes_attributes:
[{
id:
scope
.
id
,
strategies:
[{
name:
'gradualRolloutUserId'
,
parameters:
{
groupId:
'default'
,
percentage:
"50"
}
}]
}])
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
...
@@ -1212,9 +1209,11 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1212,9 +1209,11 @@ RSpec.describe Projects::FeatureFlagsController do
it
'clears an existing strategy'
do
it
'clears an existing strategy'
do
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[{
name:
'default'
,
parameters:
{}
}])
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[{
name:
'default'
,
parameters:
{}
}])
params
=
request_params
(
scope
,
[])
put
(
:update
,
params:
params
,
format: :json
,
as: :json
)
put_request
(
feature_flag
,
scopes_attributes:
[{
id:
scope
.
id
,
strategies:
[]
}])
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
...
@@ -1225,12 +1224,14 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1225,12 +1224,14 @@ RSpec.describe Projects::FeatureFlagsController do
it
'accepts multiple strategies'
do
it
'accepts multiple strategies'
do
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[{
name:
'default'
,
parameters:
{}
}])
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[{
name:
'default'
,
parameters:
{}
}])
params
=
request_params
(
scope
,
[
put_request
(
feature_flag
,
scopes_attributes:
[{
id:
scope
.
id
,
strategies:
[
{
name:
'gradualRolloutUserId'
,
parameters:
{
groupId:
'mygroup'
,
percentage:
'55'
}
},
{
name:
'gradualRolloutUserId'
,
parameters:
{
groupId:
'mygroup'
,
percentage:
'55'
}
},
{
name:
'userWithId'
,
parameters:
{
userIds:
'joe'
}
}
{
name:
'userWithId'
,
parameters:
{
userIds:
'joe'
}
}
])
]
}])
put
(
:update
,
params:
params
,
format: :json
,
as: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
...
@@ -1249,16 +1250,8 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1249,16 +1250,8 @@ RSpec.describe Projects::FeatureFlagsController do
it
'does not modify strategies when there is no strategies key in the params'
do
it
'does not modify strategies when there is no strategies key in the params'
do
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[{
name:
'default'
,
parameters:
{}
}])
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[{
name:
'default'
,
parameters:
{}
}])
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
iid:
feature_flag
.
iid
,
operations_feature_flag:
{
scopes_attributes:
[{
id:
scope
.
id
}]
}
}
put
(
:update
,
params:
params
,
format: :json
)
put
_request
(
feature_flag
,
scopes_attributes:
[{
id:
scope
.
id
}]
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
...
@@ -1273,16 +1266,8 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1273,16 +1266,8 @@ RSpec.describe Projects::FeatureFlagsController do
it
'leaves an existing strategy when there are no strategies in the params'
do
it
'leaves an existing strategy when there are no strategies in the params'
do
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[{
name:
'gradualRolloutUserId'
,
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[{
name:
'gradualRolloutUserId'
,
parameters:
{
groupId:
'default'
,
percentage:
'10'
}
}])
parameters:
{
groupId:
'default'
,
percentage:
'10'
}
}])
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
iid:
feature_flag
.
iid
,
operations_feature_flag:
{
scopes_attributes:
[{
id:
scope
.
id
}]
}
}
put
(
:update
,
params:
params
,
format: :json
,
as: :json
)
put
_request
(
feature_flag
,
scopes_attributes:
[{
id:
scope
.
id
}]
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
scope_json
=
json_response
[
'scopes'
].
select
do
|
s
|
...
@@ -1296,9 +1281,11 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1296,9 +1281,11 @@ RSpec.describe Projects::FeatureFlagsController do
it
'does not accept extra parameters in the strategy params'
do
it
'does not accept extra parameters in the strategy params'
do
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[{
name:
'default'
,
parameters:
{}
}])
scope
=
create_scope
(
feature_flag
,
'production'
,
true
,
[{
name:
'default'
,
parameters:
{}
}])
params
=
request_params
(
scope
,
[{
name:
'userWithId'
,
parameters:
{
userIds:
'joe'
,
groupId:
'default'
}
}])
put
(
:update
,
params:
params
,
format: :json
,
as: :json
)
put_request
(
feature_flag
,
scopes_attributes:
[{
id:
scope
.
id
,
strategies:
[{
name:
'userWithId'
,
parameters:
{
userIds:
'joe'
,
groupId:
'default'
}
}]
}])
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
]).
to
eq
([
"Scopes strategies parameters are invalid"
])
expect
(
json_response
[
'message'
]).
to
eq
([
"Scopes strategies parameters are invalid"
])
...
@@ -1315,22 +1302,13 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1315,22 +1302,13 @@ RSpec.describe Projects::FeatureFlagsController do
end
end
it
'creates a new strategy and scope'
do
it
'creates a new strategy and scope'
do
params
=
{
put_request
(
new_version_flag
,
strategies_attributes:
[{
namespace_id:
project
.
namespace
,
project_id:
project
,
iid:
new_version_flag
.
iid
,
operations_feature_flag:
{
strategies_attributes:
[{
name:
'userWithId'
,
name:
'userWithId'
,
parameters:
{
userIds:
'user1'
},
parameters:
{
userIds:
'user1'
},
scopes_attributes:
[{
scopes_attributes:
[{
environment_scope:
'production'
environment_scope:
'production'
}]
}]
}]
}])
}
}
put
(
:update
,
params:
params
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'strategies'
].
count
).
to
eq
(
1
)
expect
(
json_response
[
'strategies'
].
count
).
to
eq
(
1
)
...
@@ -1345,19 +1323,10 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1345,19 +1323,10 @@ RSpec.describe Projects::FeatureFlagsController do
end
end
it
'creates a gradualRolloutUserId strategy'
do
it
'creates a gradualRolloutUserId strategy'
do
params
=
{
put_request
(
new_version_flag
,
strategies_attributes:
[{
namespace_id:
project
.
namespace
,
project_id:
project
,
iid:
new_version_flag
.
iid
,
operations_feature_flag:
{
strategies_attributes:
[{
name:
'gradualRolloutUserId'
,
name:
'gradualRolloutUserId'
,
parameters:
{
groupId:
'default'
,
percentage:
'30'
}
parameters:
{
groupId:
'default'
,
percentage:
'30'
}
}]
}])
}
}
put
(
:update
,
params:
params
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'strategies'
].
count
).
to
eq
(
1
)
expect
(
json_response
[
'strategies'
].
count
).
to
eq
(
1
)
...
@@ -1372,20 +1341,12 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1372,20 +1341,12 @@ RSpec.describe Projects::FeatureFlagsController do
it
'creates a gitlabUserList strategy'
do
it
'creates a gitlabUserList strategy'
do
user_list
=
create
(
:operations_feature_flag_user_list
,
project:
project
,
name:
'My List'
,
user_xids:
'user1,user2'
)
user_list
=
create
(
:operations_feature_flag_user_list
,
project:
project
,
name:
'My List'
,
user_xids:
'user1,user2'
)
params
=
{
namespace_id:
project
.
namespace
,
put_request
(
new_version_flag
,
strategies_attributes:
[{
project_id:
project
,
iid:
new_version_flag
.
iid
,
operations_feature_flag:
{
strategies_attributes:
[{
name:
'gitlabUserList'
,
name:
'gitlabUserList'
,
parameters:
{},
parameters:
{},
user_list_id:
user_list
.
id
user_list_id:
user_list
.
id
}]
}])
}
}
put
(
:update
,
params:
params
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'strategies'
]).
to
match
([
a_hash_including
({
expect
(
json_response
[
'strategies'
]).
to
match
([
a_hash_including
({
...
@@ -1406,19 +1367,11 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1406,19 +1367,11 @@ RSpec.describe Projects::FeatureFlagsController do
user_list
=
create
(
:operations_feature_flag_user_list
,
project:
project
,
name:
'My List'
,
user_xids:
'user1,user2'
)
user_list
=
create
(
:operations_feature_flag_user_list
,
project:
project
,
name:
'My List'
,
user_xids:
'user1,user2'
)
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'gitlabUserList'
,
parameters:
{},
user_list:
user_list
)
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'gitlabUserList'
,
parameters:
{},
user_list:
user_list
)
other_user_list
=
create
(
:operations_feature_flag_user_list
,
project:
project
,
name:
'Other List'
,
user_xids:
'user3'
)
other_user_list
=
create
(
:operations_feature_flag_user_list
,
project:
project
,
name:
'Other List'
,
user_xids:
'user3'
)
params
=
{
namespace_id:
project
.
namespace
,
put_request
(
new_version_flag
,
strategies_attributes:
[{
project_id:
project
,
iid:
new_version_flag
.
iid
,
operations_feature_flag:
{
strategies_attributes:
[{
id:
strategy
.
id
,
id:
strategy
.
id
,
user_list_id:
other_user_list
.
id
user_list_id:
other_user_list
.
id
}]
}])
}
}
put
(
:update
,
params:
params
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'strategies'
]).
to
eq
([{
expect
(
json_response
[
'strategies'
]).
to
eq
([{
...
@@ -1438,23 +1391,15 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1438,23 +1391,15 @@ RSpec.describe Projects::FeatureFlagsController do
it
'automatically dissociates the user list when switching the type of an existing gitlabUserList strategy'
do
it
'automatically dissociates the user list when switching the type of an existing gitlabUserList strategy'
do
user_list
=
create
(
:operations_feature_flag_user_list
,
project:
project
,
name:
'My List'
,
user_xids:
'user1,user2'
)
user_list
=
create
(
:operations_feature_flag_user_list
,
project:
project
,
name:
'My List'
,
user_xids:
'user1,user2'
)
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'gitlabUserList'
,
parameters:
{},
user_list:
user_list
)
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'gitlabUserList'
,
parameters:
{},
user_list:
user_list
)
params
=
{
namespace_id:
project
.
namespace
,
put_request
(
new_version_flag
,
strategies_attributes:
[{
project_id:
project
,
iid:
new_version_flag
.
iid
,
operations_feature_flag:
{
strategies_attributes:
[{
id:
strategy
.
id
,
id:
strategy
.
id
,
name:
'gradualRolloutUserId'
,
name:
'gradualRolloutUserId'
,
parameters:
{
parameters:
{
groupId:
'default'
,
groupId:
'default'
,
percentage:
'25'
percentage:
'25'
}
}
}]
}])
}
}
put
(
:update
,
params:
params
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'strategies'
]).
to
eq
([{
expect
(
json_response
[
'strategies'
]).
to
eq
([{
...
@@ -1471,19 +1416,11 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1471,19 +1416,11 @@ RSpec.describe Projects::FeatureFlagsController do
it
'does not delete a user list when deleting a gitlabUserList strategy'
do
it
'does not delete a user list when deleting a gitlabUserList strategy'
do
user_list
=
create
(
:operations_feature_flag_user_list
,
project:
project
,
name:
'My List'
,
user_xids:
'user1,user2'
)
user_list
=
create
(
:operations_feature_flag_user_list
,
project:
project
,
name:
'My List'
,
user_xids:
'user1,user2'
)
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'gitlabUserList'
,
parameters:
{},
user_list:
user_list
)
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'gitlabUserList'
,
parameters:
{},
user_list:
user_list
)
params
=
{
namespace_id:
project
.
namespace
,
put_request
(
new_version_flag
,
strategies_attributes:
[{
project_id:
project
,
iid:
new_version_flag
.
iid
,
operations_feature_flag:
{
strategies_attributes:
[{
id:
strategy
.
id
,
id:
strategy
.
id
,
_destroy:
true
_destroy:
true
}]
}])
}
}
put
(
:update
,
params:
params
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'strategies'
]).
to
eq
([])
expect
(
json_response
[
'strategies'
]).
to
eq
([])
...
@@ -1493,40 +1430,23 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1493,40 +1430,23 @@ RSpec.describe Projects::FeatureFlagsController do
end
end
it
'returns not found when trying to create a gitlabUserList strategy with an invalid user list id'
do
it
'returns not found when trying to create a gitlabUserList strategy with an invalid user list id'
do
params
=
{
put_request
(
new_version_flag
,
strategies_attributes:
[{
namespace_id:
project
.
namespace
,
project_id:
project
,
iid:
new_version_flag
.
iid
,
operations_feature_flag:
{
strategies_attributes:
[{
name:
'gitlabUserList'
,
name:
'gitlabUserList'
,
parameters:
{},
parameters:
{},
user_list_id:
1
user_list_id:
1
}]
}])
}
}
put
(
:update
,
params:
params
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
it
'updates an existing strategy'
do
it
'updates an existing strategy'
do
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'default'
,
parameters:
{})
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'default'
,
parameters:
{})
params
=
{
namespace_id:
project
.
namespace
,
put_request
(
new_version_flag
,
strategies_attributes:
[{
project_id:
project
,
iid:
new_version_flag
.
iid
,
operations_feature_flag:
{
strategies_attributes:
[{
id:
strategy
.
id
,
id:
strategy
.
id
,
name:
'userWithId'
,
name:
'userWithId'
,
parameters:
{
userIds:
'user2,user3'
}
parameters:
{
userIds:
'user2,user3'
}
}]
}])
}
}
put
(
:update
,
params:
params
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'strategies'
]).
to
eq
([{
expect
(
json_response
[
'strategies'
]).
to
eq
([{
...
@@ -1540,22 +1460,14 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1540,22 +1460,14 @@ RSpec.describe Projects::FeatureFlagsController do
it
'updates an existing scope'
do
it
'updates an existing scope'
do
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'default'
,
parameters:
{})
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'default'
,
parameters:
{})
scope
=
create
(
:operations_scope
,
strategy:
strategy
,
environment_scope:
'staging'
)
scope
=
create
(
:operations_scope
,
strategy:
strategy
,
environment_scope:
'staging'
)
params
=
{
namespace_id:
project
.
namespace
,
put_request
(
new_version_flag
,
strategies_attributes:
[{
project_id:
project
,
iid:
new_version_flag
.
iid
,
operations_feature_flag:
{
strategies_attributes:
[{
id:
strategy
.
id
,
id:
strategy
.
id
,
scopes_attributes:
[{
scopes_attributes:
[{
id:
scope
.
id
,
id:
scope
.
id
,
environment_scope:
'sandbox'
environment_scope:
'sandbox'
}]
}]
}]
}])
}
}
put
(
:update
,
params:
params
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'strategies'
].
first
[
'scopes'
]).
to
eq
([{
expect
(
json_response
[
'strategies'
].
first
[
'scopes'
]).
to
eq
([{
...
@@ -1566,19 +1478,11 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1566,19 +1478,11 @@ RSpec.describe Projects::FeatureFlagsController do
it
'deletes an existing strategy'
do
it
'deletes an existing strategy'
do
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'default'
,
parameters:
{})
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'default'
,
parameters:
{})
params
=
{
namespace_id:
project
.
namespace
,
put_request
(
new_version_flag
,
strategies_attributes:
[{
project_id:
project
,
iid:
new_version_flag
.
iid
,
operations_feature_flag:
{
strategies_attributes:
[{
id:
strategy
.
id
,
id:
strategy
.
id
,
_destroy:
true
_destroy:
true
}]
}])
}
}
put
(
:update
,
params:
params
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'strategies'
]).
to
eq
([])
expect
(
json_response
[
'strategies'
]).
to
eq
([])
...
@@ -1587,22 +1491,14 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1587,22 +1491,14 @@ RSpec.describe Projects::FeatureFlagsController do
it
'deletes an existing scope'
do
it
'deletes an existing scope'
do
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'default'
,
parameters:
{})
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'default'
,
parameters:
{})
scope
=
create
(
:operations_scope
,
strategy:
strategy
,
environment_scope:
'staging'
)
scope
=
create
(
:operations_scope
,
strategy:
strategy
,
environment_scope:
'staging'
)
params
=
{
namespace_id:
project
.
namespace
,
put_request
(
new_version_flag
,
strategies_attributes:
[{
project_id:
project
,
iid:
new_version_flag
.
iid
,
operations_feature_flag:
{
strategies_attributes:
[{
id:
strategy
.
id
,
id:
strategy
.
id
,
scopes_attributes:
[{
scopes_attributes:
[{
id:
scope
.
id
,
id:
scope
.
id
,
_destroy:
true
_destroy:
true
}]
}]
}]
}])
}
}
put
(
:update
,
params:
params
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'strategies'
].
first
[
'scopes'
]).
to
eq
([])
expect
(
json_response
[
'strategies'
].
first
[
'scopes'
]).
to
eq
([])
...
@@ -1610,16 +1506,8 @@ RSpec.describe Projects::FeatureFlagsController do
...
@@ -1610,16 +1506,8 @@ RSpec.describe Projects::FeatureFlagsController do
it
'does not update the flag if version 2 flags are disabled'
do
it
'does not update the flag if version 2 flags are disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
stub_feature_flags
(
feature_flags_new_version:
false
)
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
iid:
new_version_flag
.
iid
,
operations_feature_flag:
{
name:
'some-other-name'
}
}
put
(
:update
,
params:
params
,
format: :json
)
put
_request
(
new_version_flag
,
{
name:
'some-other-name'
}
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
new_version_flag
.
reload
.
name
).
to
eq
(
'new-feature'
)
expect
(
new_version_flag
.
reload
.
name
).
to
eq
(
'new-feature'
)
...
...
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