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
Hide 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
def
feature_flag
@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
project
.
operations_feature_flags
.
legacy_flag
.
find
(
params
[
:
id
])
project
.
operations_feature_flags
.
legacy_flag
.
find
_by_iid!
(
params
[
:i
id
])
end
end
...
...
ee/app/models/operations/feature_flag.rb
View file @
4c9e2831
...
...
@@ -3,6 +3,7 @@
module
Operations
class
FeatureFlag
<
ApplicationRecord
include
AtomicInternalId
include
IidRoutes
self
.
table_name
=
'operations_feature_flags'
...
...
ee/config/routes/project.rb
View file @
4c9e2831
...
...
@@ -26,7 +26,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
resources
:feature_flags
resources
:feature_flags
,
param: :iid
resource
:feature_flags_client
,
only:
[]
do
post
:reset_token
end
...
...
ee/spec/controllers/projects/feature_flags_controller_spec.rb
View file @
4c9e2831
...
...
@@ -250,7 +250,7 @@ describe Projects::FeatureFlagsController do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
feature_flag
.
id
i
id:
feature_flag
.
i
id
}
end
...
...
@@ -266,6 +266,41 @@ describe Projects::FeatureFlagsController do
is_expected
.
to
match_response_schema
(
'feature_flag'
,
dir:
'ee'
)
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
let!
(
:feature_flag
)
{
}
...
...
@@ -273,7 +308,7 @@ describe Projects::FeatureFlagsController do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
1
i
i
d:
1
}
end
...
...
@@ -339,7 +374,7 @@ describe Projects::FeatureFlagsController do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
new_version_feature_flag
.
id
i
id:
new_version_feature_flag
.
i
id
}
end
...
...
@@ -738,7 +773,7 @@ describe Projects::FeatureFlagsController do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
feature_flag
.
id
i
id:
feature_flag
.
i
id
}
end
...
...
@@ -771,7 +806,7 @@ describe Projects::FeatureFlagsController do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
0
i
i
d:
0
}
end
...
...
@@ -794,7 +829,7 @@ describe Projects::FeatureFlagsController do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
new_version_flag
.
id
i
id:
new_version_flag
.
i
id
}
end
...
...
@@ -827,7 +862,7 @@ describe Projects::FeatureFlagsController do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
name:
'ci_new_live_trace'
}
...
...
@@ -853,7 +888,7 @@ describe Projects::FeatureFlagsController do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
active:
false
}
...
...
@@ -877,7 +912,7 @@ describe Projects::FeatureFlagsController do
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
active:
true
}
}
put
(
:update
,
params:
params
,
format: :json
)
...
...
@@ -903,7 +938,7 @@ describe Projects::FeatureFlagsController do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
scopes_attributes:
[{
environment_scope:
'production'
,
active:
false
}]
}
...
...
@@ -923,7 +958,7 @@ describe Projects::FeatureFlagsController do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
scopes_attributes:
[{
environment_scope:
'*'
,
active:
false
}]
}
...
...
@@ -940,7 +975,7 @@ describe Projects::FeatureFlagsController do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
scopes_attributes:
[
{
...
...
@@ -966,7 +1001,7 @@ describe Projects::FeatureFlagsController do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
scopes_attributes:
[
{
...
...
@@ -988,7 +1023,7 @@ describe Projects::FeatureFlagsController do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
scopes_attributes:
[
{
...
...
@@ -1011,7 +1046,7 @@ describe Projects::FeatureFlagsController do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
scopes_attributes:
[
{
...
...
@@ -1037,7 +1072,7 @@ describe Projects::FeatureFlagsController do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
scopes_attributes:
[
{
...
...
@@ -1163,7 +1198,7 @@ describe Projects::FeatureFlagsController do
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
scopes_attributes:
[{
id:
scope
.
id
}]
}
...
...
@@ -1187,7 +1222,7 @@ describe Projects::FeatureFlagsController do
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
feature_flag
.
id
,
i
id:
feature_flag
.
i
id
,
operations_feature_flag:
{
scopes_attributes:
[{
id:
scope
.
id
}]
}
...
...
@@ -1229,7 +1264,7 @@ describe Projects::FeatureFlagsController do
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
new_version_flag
.
id
,
i
id:
new_version_flag
.
i
id
,
operations_feature_flag:
{
strategies_attributes:
[{
name:
'userWithId'
,
...
...
@@ -1259,7 +1294,7 @@ describe Projects::FeatureFlagsController do
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
new_version_flag
.
id
,
i
id:
new_version_flag
.
i
id
,
operations_feature_flag:
{
strategies_attributes:
[{
name:
'gradualRolloutUserId'
,
...
...
@@ -1286,7 +1321,7 @@ describe Projects::FeatureFlagsController do
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
new_version_flag
.
id
,
i
id:
new_version_flag
.
i
id
,
operations_feature_flag:
{
strategies_attributes:
[{
id:
strategy
.
id
,
...
...
@@ -1313,7 +1348,7 @@ describe Projects::FeatureFlagsController do
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
new_version_flag
.
id
,
i
id:
new_version_flag
.
i
id
,
operations_feature_flag:
{
strategies_attributes:
[{
id:
strategy
.
id
,
...
...
@@ -1339,7 +1374,7 @@ describe Projects::FeatureFlagsController do
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
new_version_flag
.
id
,
i
id:
new_version_flag
.
i
id
,
operations_feature_flag:
{
strategies_attributes:
[{
id:
strategy
.
id
,
...
...
@@ -1360,7 +1395,7 @@ describe Projects::FeatureFlagsController do
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
new_version_flag
.
id
,
i
id:
new_version_flag
.
i
id
,
operations_feature_flag:
{
strategies_attributes:
[{
id:
strategy
.
id
,
...
...
@@ -1383,7 +1418,7 @@ describe Projects::FeatureFlagsController do
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
new_version_flag
.
id
,
i
id:
new_version_flag
.
i
id
,
operations_feature_flag:
{
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