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
4c9e2831
Commit
4c9e2831
authored
Apr 22, 2020
by
Jason Goodman
Committed by
Shinya Maeda
Apr 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Route feature flags based on internal id
Add spec for routing
parent
68d82ed0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
28 deletions
+69
-28
changelogs/unreleased/ff-iid-routing.yml
changelogs/unreleased/ff-iid-routing.yml
+5
-0
ee/app/controllers/projects/feature_flags_controller.rb
ee/app/controllers/projects/feature_flags_controller.rb
+2
-2
ee/app/models/operations/feature_flag.rb
ee/app/models/operations/feature_flag.rb
+1
-0
ee/config/routes/project.rb
ee/config/routes/project.rb
+1
-1
ee/spec/controllers/projects/feature_flags_controller_spec.rb
...pec/controllers/projects/feature_flags_controller_spec.rb
+60
-25
No files found.
changelogs/unreleased/ff-iid-routing.yml
0 → 100644
View file @
4c9e2831
---
title
:
Route to feature flags based on internal id
merge_request
:
29740
author
:
type
:
added
ee/app/controllers/projects/feature_flags_controller.rb
View file @
4c9e2831
...
@@ -96,9 +96,9 @@ class Projects::FeatureFlagsController < Projects::ApplicationController
...
@@ -96,9 +96,9 @@ class Projects::FeatureFlagsController < Projects::ApplicationController
def
feature_flag
def
feature_flag
@feature_flag
||=
if
new_version_feature_flags_enabled?
@feature_flag
||=
if
new_version_feature_flags_enabled?
project
.
operations_feature_flags
.
find
(
params
[
:
id
])
project
.
operations_feature_flags
.
find
_by_iid!
(
params
[
:i
id
])
else
else
project
.
operations_feature_flags
.
legacy_flag
.
find
(
params
[
:
id
])
project
.
operations_feature_flags
.
legacy_flag
.
find
_by_iid!
(
params
[
:i
id
])
end
end
end
end
...
...
ee/app/models/operations/feature_flag.rb
View file @
4c9e2831
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
module
Operations
module
Operations
class
FeatureFlag
<
ApplicationRecord
class
FeatureFlag
<
ApplicationRecord
include
AtomicInternalId
include
AtomicInternalId
include
IidRoutes
self
.
table_name
=
'operations_feature_flags'
self
.
table_name
=
'operations_feature_flags'
...
...
ee/config/routes/project.rb
View file @
4c9e2831
...
@@ -26,7 +26,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
...
@@ -26,7 +26,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
end
end
resources
:feature_flags
resources
:feature_flags
,
param: :iid
resource
:feature_flags_client
,
only:
[]
do
resource
:feature_flags_client
,
only:
[]
do
post
:reset_token
post
:reset_token
end
end
...
...
ee/spec/controllers/projects/feature_flags_controller_spec.rb
View file @
4c9e2831
...
@@ -250,7 +250,7 @@ describe Projects::FeatureFlagsController do
...
@@ -250,7 +250,7 @@ describe Projects::FeatureFlagsController do
{
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
feature_flag
.
id
i
id:
feature_flag
.
i
id
}
}
end
end
...
@@ -266,6 +266,41 @@ describe Projects::FeatureFlagsController do
...
@@ -266,6 +266,41 @@ describe Projects::FeatureFlagsController do
is_expected
.
to
match_response_schema
(
'feature_flag'
,
dir:
'ee'
)
is_expected
.
to
match_response_schema
(
'feature_flag'
,
dir:
'ee'
)
end
end
it
'routes based on iid'
do
other_project
=
create
(
:project
)
other_project
.
add_developer
(
user
)
other_feature_flag
=
create
(
:operations_feature_flag
,
project:
other_project
,
name:
'other_flag'
)
params
=
{
namespace_id:
other_project
.
namespace
,
project_id:
other_project
,
iid:
other_feature_flag
.
iid
}
get
(
:show
,
params:
params
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'name'
]).
to
eq
(
other_feature_flag
.
name
)
end
it
'routes based on iid when new version flags are disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
other_project
=
create
(
:project
)
other_project
.
add_developer
(
user
)
other_feature_flag
=
create
(
:operations_feature_flag
,
project:
other_project
,
name:
'other_flag'
)
params
=
{
namespace_id:
other_project
.
namespace
,
project_id:
other_project
,
iid:
other_feature_flag
.
iid
}
get
(
:show
,
params:
params
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'name'
]).
to
eq
(
other_feature_flag
.
name
)
end
context
'when feature flag is not found'
do
context
'when feature flag is not found'
do
let!
(
:feature_flag
)
{
}
let!
(
:feature_flag
)
{
}
...
@@ -273,7 +308,7 @@ describe Projects::FeatureFlagsController do
...
@@ -273,7 +308,7 @@ describe Projects::FeatureFlagsController do
{
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
id:
1
i
i
d:
1
}
}
end
end
...
@@ -339,7 +374,7 @@ describe Projects::FeatureFlagsController do
...
@@ -339,7 +374,7 @@ describe Projects::FeatureFlagsController do
{
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
new_version_feature_flag
.
id
i
id:
new_version_feature_flag
.
i
id
}
}
end
end
...
@@ -738,7 +773,7 @@ describe Projects::FeatureFlagsController do
...
@@ -738,7 +773,7 @@ describe Projects::FeatureFlagsController do
{
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
feature_flag
.
id
i
id:
feature_flag
.
i
id
}
}
end
end
...
@@ -771,7 +806,7 @@ describe Projects::FeatureFlagsController do
...
@@ -771,7 +806,7 @@ describe Projects::FeatureFlagsController do
{
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
id:
0
i
i
d:
0
}
}
end
end
...
@@ -794,7 +829,7 @@ describe Projects::FeatureFlagsController do
...
@@ -794,7 +829,7 @@ describe Projects::FeatureFlagsController do
{
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
new_version_flag
.
id
i
id:
new_version_flag
.
i
id
}
}
end
end
...
@@ -827,7 +862,7 @@ describe Projects::FeatureFlagsController do
...
@@ -827,7 +862,7 @@ describe Projects::FeatureFlagsController do
{
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
name:
'ci_new_live_trace'
name:
'ci_new_live_trace'
}
}
...
@@ -853,7 +888,7 @@ describe Projects::FeatureFlagsController do
...
@@ -853,7 +888,7 @@ describe Projects::FeatureFlagsController do
{
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
active:
false
active:
false
}
}
...
@@ -877,7 +912,7 @@ describe Projects::FeatureFlagsController do
...
@@ -877,7 +912,7 @@ describe Projects::FeatureFlagsController do
params
=
{
params
=
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
active:
true
}
operations_feature_flag:
{
active:
true
}
}
}
put
(
:update
,
params:
params
,
format: :json
)
put
(
:update
,
params:
params
,
format: :json
)
...
@@ -903,7 +938,7 @@ describe Projects::FeatureFlagsController do
...
@@ -903,7 +938,7 @@ describe Projects::FeatureFlagsController do
{
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
scopes_attributes:
[{
environment_scope:
'production'
,
active:
false
}]
scopes_attributes:
[{
environment_scope:
'production'
,
active:
false
}]
}
}
...
@@ -923,7 +958,7 @@ describe Projects::FeatureFlagsController do
...
@@ -923,7 +958,7 @@ describe Projects::FeatureFlagsController do
{
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
scopes_attributes:
[{
environment_scope:
'*'
,
active:
false
}]
scopes_attributes:
[{
environment_scope:
'*'
,
active:
false
}]
}
}
...
@@ -940,7 +975,7 @@ describe Projects::FeatureFlagsController do
...
@@ -940,7 +975,7 @@ describe Projects::FeatureFlagsController do
{
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
scopes_attributes:
[
scopes_attributes:
[
{
{
...
@@ -966,7 +1001,7 @@ describe Projects::FeatureFlagsController do
...
@@ -966,7 +1001,7 @@ describe Projects::FeatureFlagsController do
{
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
scopes_attributes:
[
scopes_attributes:
[
{
{
...
@@ -988,7 +1023,7 @@ describe Projects::FeatureFlagsController do
...
@@ -988,7 +1023,7 @@ describe Projects::FeatureFlagsController do
{
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
scopes_attributes:
[
scopes_attributes:
[
{
{
...
@@ -1011,7 +1046,7 @@ describe Projects::FeatureFlagsController do
...
@@ -1011,7 +1046,7 @@ describe Projects::FeatureFlagsController do
{
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
scopes_attributes:
[
scopes_attributes:
[
{
{
...
@@ -1037,7 +1072,7 @@ describe Projects::FeatureFlagsController do
...
@@ -1037,7 +1072,7 @@ describe Projects::FeatureFlagsController do
{
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
scopes_attributes:
[
scopes_attributes:
[
{
{
...
@@ -1163,7 +1198,7 @@ describe Projects::FeatureFlagsController do
...
@@ -1163,7 +1198,7 @@ describe Projects::FeatureFlagsController do
params
=
{
params
=
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
scopes_attributes:
[{
id:
scope
.
id
}]
scopes_attributes:
[{
id:
scope
.
id
}]
}
}
...
@@ -1187,7 +1222,7 @@ describe Projects::FeatureFlagsController do
...
@@ -1187,7 +1222,7 @@ describe Projects::FeatureFlagsController do
params
=
{
params
=
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
scopes_attributes:
[{
id:
scope
.
id
}]
scopes_attributes:
[{
id:
scope
.
id
}]
}
}
...
@@ -1229,7 +1264,7 @@ describe Projects::FeatureFlagsController do
...
@@ -1229,7 +1264,7 @@ describe Projects::FeatureFlagsController do
params
=
{
params
=
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
new_version_flag
.
id
,
i
id:
new_version_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
strategies_attributes:
[{
strategies_attributes:
[{
name:
'userWithId'
,
name:
'userWithId'
,
...
@@ -1259,7 +1294,7 @@ describe Projects::FeatureFlagsController do
...
@@ -1259,7 +1294,7 @@ describe Projects::FeatureFlagsController do
params
=
{
params
=
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
new_version_flag
.
id
,
i
id:
new_version_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
strategies_attributes:
[{
strategies_attributes:
[{
name:
'gradualRolloutUserId'
,
name:
'gradualRolloutUserId'
,
...
@@ -1286,7 +1321,7 @@ describe Projects::FeatureFlagsController do
...
@@ -1286,7 +1321,7 @@ describe Projects::FeatureFlagsController do
params
=
{
params
=
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
new_version_flag
.
id
,
i
id:
new_version_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
strategies_attributes:
[{
strategies_attributes:
[{
id:
strategy
.
id
,
id:
strategy
.
id
,
...
@@ -1313,7 +1348,7 @@ describe Projects::FeatureFlagsController do
...
@@ -1313,7 +1348,7 @@ describe Projects::FeatureFlagsController do
params
=
{
params
=
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
new_version_flag
.
id
,
i
id:
new_version_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
strategies_attributes:
[{
strategies_attributes:
[{
id:
strategy
.
id
,
id:
strategy
.
id
,
...
@@ -1339,7 +1374,7 @@ describe Projects::FeatureFlagsController do
...
@@ -1339,7 +1374,7 @@ describe Projects::FeatureFlagsController do
params
=
{
params
=
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
new_version_flag
.
id
,
i
id:
new_version_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
strategies_attributes:
[{
strategies_attributes:
[{
id:
strategy
.
id
,
id:
strategy
.
id
,
...
@@ -1360,7 +1395,7 @@ describe Projects::FeatureFlagsController do
...
@@ -1360,7 +1395,7 @@ describe Projects::FeatureFlagsController do
params
=
{
params
=
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
new_version_flag
.
id
,
i
id:
new_version_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
strategies_attributes:
[{
strategies_attributes:
[{
id:
strategy
.
id
,
id:
strategy
.
id
,
...
@@ -1383,7 +1418,7 @@ describe Projects::FeatureFlagsController do
...
@@ -1383,7 +1418,7 @@ describe Projects::FeatureFlagsController do
params
=
{
params
=
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
i
d:
new_version_flag
.
id
,
i
id:
new_version_flag
.
i
id
,
operations_feature_flag:
{
operations_feature_flag:
{
name:
'some-other-name'
name:
'some-other-name'
}
}
...
...
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