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
0104420a
Commit
0104420a
authored
May 29, 2020
by
Jason Goodman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support changing type of feature flag strategy from gitlabUserList
Automatically dissociate the user list
parent
997e6bd8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
ee/app/services/feature_flags/update_service.rb
ee/app/services/feature_flags/update_service.rb
+6
-0
ee/spec/controllers/projects/feature_flags_controller_spec.rb
...pec/controllers/projects/feature_flags_controller_spec.rb
+33
-0
No files found.
ee/app/services/feature_flags/update_service.rb
View file @
0104420a
...
...
@@ -14,6 +14,12 @@ module FeatureFlags
ActiveRecord
::
Base
.
transaction
do
feature_flag
.
assign_attributes
(
params
)
feature_flag
.
strategies
.
each
do
|
strategy
|
if
strategy
.
name_changed?
&&
strategy
.
name_was
==
::
Operations
::
FeatureFlags
::
Strategy
::
STRATEGY_GITLABUSERLIST
strategy
.
user_list
=
nil
end
end
audit_event
=
audit_event
(
feature_flag
)
if
feature_flag
.
save
...
...
ee/spec/controllers/projects/feature_flags_controller_spec.rb
View file @
0104420a
...
...
@@ -1425,6 +1425,39 @@ describe Projects::FeatureFlagsController do
}])
end
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'
)
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'gitlabUserList'
,
parameters:
{},
user_list:
user_list
)
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
iid:
new_version_flag
.
iid
,
operations_feature_flag:
{
strategies_attributes:
[{
id:
strategy
.
id
,
name:
'gradualRolloutUserId'
,
parameters:
{
groupId:
'default'
,
percentage:
'25'
}
}]
}
}
put
(
:update
,
params:
params
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'strategies'
]).
to
eq
([{
'id'
=>
strategy
.
id
,
'name'
=>
'gradualRolloutUserId'
,
'parameters'
=>
{
'groupId'
=>
'default'
,
'percentage'
=>
'25'
},
'scopes'
=>
[]
}])
end
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'
)
strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_flag
,
name:
'gitlabUserList'
,
parameters:
{},
user_list:
user_list
)
...
...
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