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
e5b4bb1b
Commit
e5b4bb1b
authored
Nov 24, 2020
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove feature_flags_new_version feature flag
This commit removes the feature flag
parent
8da6b7f5
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
22 additions
and
554 deletions
+22
-554
app/assets/javascripts/feature_flags/components/edit_feature_flag.vue
...avascripts/feature_flags/components/edit_feature_flag.vue
+1
-15
app/assets/javascripts/feature_flags/components/feature_flags_table.vue
...ascripts/feature_flags/components/feature_flags_table.vue
+1
-4
app/assets/javascripts/feature_flags/components/form.vue
app/assets/javascripts/feature_flags/components/form.vue
+1
-2
app/assets/javascripts/feature_flags/components/new_feature_flag.vue
...javascripts/feature_flags/components/new_feature_flag.vue
+2
-23
app/controllers/projects/feature_flags_controller.rb
app/controllers/projects/feature_flags_controller.rb
+1
-10
app/finders/feature_flags_finder.rb
app/finders/feature_flags_finder.rb
+1
-5
app/services/feature_flags/create_service.rb
app/services/feature_flags/create_service.rb
+0
-9
config/feature_flags/development/feature_flags_new_version.yml
...g/feature_flags/development/feature_flags_new_version.yml
+0
-8
doc/api/feature_flags.md
doc/api/feature_flags.md
+0
-4
doc/operations/feature_flags.md
doc/operations/feature_flags.md
+0
-20
ee/spec/features/projects/feature_flags/user_creates_feature_flag_spec.rb
.../projects/feature_flags/user_creates_feature_flag_spec.rb
+8
-14
lib/api/entities/feature_flag.rb
lib/api/entities/feature_flag.rb
+2
-2
lib/api/feature_flags.rb
lib/api/feature_flags.rb
+3
-21
spec/controllers/projects/feature_flags_controller_spec.rb
spec/controllers/projects/feature_flags_controller_spec.rb
+0
-101
spec/features/projects/feature_flags/user_creates_feature_flag_spec.rb
.../projects/feature_flags/user_creates_feature_flag_spec.rb
+0
-112
spec/finders/feature_flags_finder_spec.rb
spec/finders/feature_flags_finder_spec.rb
+0
-10
spec/frontend/feature_flags/components/edit_feature_flag_spec.js
...ontend/feature_flags/components/edit_feature_flag_spec.js
+1
-33
spec/frontend/feature_flags/components/new_feature_flag_spec.js
...rontend/feature_flags/components/new_feature_flag_spec.js
+1
-44
spec/requests/api/feature_flags_spec.rb
spec/requests/api/feature_flags_spec.rb
+0
-117
No files found.
app/assets/javascripts/feature_flags/components/edit_feature_flag.vue
View file @
e5b4bb1b
...
...
@@ -58,7 +58,7 @@ export default {
:
sprintf
(
s__
(
'
Edit %{name}
'
),
{
name
:
this
.
name
});
},
deprecated
()
{
return
this
.
hasNewVersionFlags
&&
this
.
version
===
LEGACY_FLAG
;
return
this
.
version
===
LEGACY_FLAG
;
},
deprecatedAndEditable
()
{
return
this
.
deprecated
&&
!
this
.
hasLegacyReadOnlyFlags
;
...
...
@@ -66,18 +66,12 @@ export default {
deprecatedAndReadOnly
()
{
return
this
.
deprecated
&&
this
.
hasLegacyReadOnlyFlags
;
},
hasNewVersionFlags
()
{
return
this
.
glFeatures
.
featureFlagsNewVersion
;
},
hasLegacyReadOnlyFlags
()
{
return
(
this
.
glFeatures
.
featureFlagsLegacyReadOnly
&&
!
this
.
glFeatures
.
featureFlagsLegacyReadOnlyOverride
);
},
shouldShowNewFlagAlert
()
{
return
!
this
.
hasNewVersionFlags
&&
this
.
userShouldSeeNewFlagAlert
;
},
},
created
()
{
return
this
.
fetchFeatureFlag
();
...
...
@@ -95,14 +89,6 @@ export default {
</
script
>
<
template
>
<div>
<gl-alert
v-if=
"shouldShowNewFlagAlert"
variant=
"warning"
class=
"gl-my-5"
@
dismiss=
"dismissNewVersionFlagAlert"
>
{{
$options
.
translations
.
newFlagAlert
}}
</gl-alert>
<gl-loading-icon
v-if=
"isLoading"
size=
"xl"
class=
"gl-mt-7"
/>
<template
v-else-if=
"!isLoading && !hasError"
>
...
...
app/assets/javascripts/feature_flags/components/feature_flags_table.vue
View file @
e5b4bb1b
...
...
@@ -38,9 +38,6 @@ export default {
permissions
()
{
return
this
.
glFeatures
.
featureFlagPermissions
;
},
isNewVersionFlagsEnabled
()
{
return
this
.
glFeatures
.
featureFlagsNewVersion
;
},
isLegacyReadOnlyFlagsEnabled
()
{
return
(
this
.
glFeatures
.
featureFlagsLegacyReadOnly
&&
...
...
@@ -68,7 +65,7 @@ export default {
},
methods
:
{
isLegacyFlag
(
flag
)
{
return
!
this
.
isNewVersionFlagsEnabled
||
flag
.
version
!==
NEW_VERSION_FLAG
;
return
flag
.
version
!==
NEW_VERSION_FLAG
;
},
statusToggleDisabled
(
flag
)
{
return
this
.
isLegacyReadOnlyFlagsEnabled
&&
flag
.
version
===
LEGACY_FLAG
;
...
...
app/assets/javascripts/feature_flags/components/form.vue
View file @
e5b4bb1b
...
...
@@ -137,14 +137,13 @@ export default {
return
this
.
glFeatures
.
featureFlagPermissions
;
},
supportsStrategies
()
{
return
this
.
glFeatures
.
featureFlagsNewVersion
&&
this
.
version
===
NEW_VERSION_FLAG
;
return
this
.
version
===
NEW_VERSION_FLAG
;
},
showRelatedIssues
()
{
return
this
.
featureFlagIssuesEndpoint
.
length
>
0
;
},
readOnly
()
{
return
(
this
.
glFeatures
.
featureFlagsNewVersion
&&
this
.
glFeatures
.
featureFlagsLegacyReadOnly
&&
!
this
.
glFeatures
.
featureFlagsLegacyReadOnlyOverride
&&
this
.
version
===
LEGACY_FLAG
...
...
app/assets/javascripts/feature_flags/components/new_feature_flag.vue
View file @
e5b4bb1b
<
script
>
import
{
mapState
,
mapActions
}
from
'
vuex
'
;
import
{
GlAlert
}
from
'
@gitlab/ui
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
FeatureFlagForm
from
'
./form.vue
'
;
import
{
LEGACY_FLAG
,
NEW_VERSION_FLAG
,
NEW_FLAG_ALERT
,
ROLLOUT_STRATEGY_ALL_USERS
,
}
from
'
../constants
'
;
import
{
NEW_VERSION_FLAG
,
NEW_FLAG_ALERT
,
ROLLOUT_STRATEGY_ALL_USERS
}
from
'
../constants
'
;
import
{
createNewEnvironmentScope
}
from
'
../store/helpers
'
;
import
featureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
export
default
{
components
:
{
GlAlert
,
FeatureFlagForm
,
},
mixins
:
[
featureFlagsMixin
()],
...
...
@@ -50,13 +43,7 @@ export default {
];
},
version
()
{
return
this
.
hasNewVersionFlags
?
NEW_VERSION_FLAG
:
LEGACY_FLAG
;
},
hasNewVersionFlags
()
{
return
this
.
glFeatures
.
featureFlagsNewVersion
;
},
shouldShowNewFlagAlert
()
{
return
!
this
.
hasNewVersionFlags
&&
this
.
userShouldSeeNewFlagAlert
;
return
NEW_VERSION_FLAG
;
},
strategies
()
{
return
[{
name
:
ROLLOUT_STRATEGY_ALL_USERS
,
parameters
:
{},
scopes
:
[]
}];
...
...
@@ -75,14 +62,6 @@ export default {
</
script
>
<
template
>
<div>
<gl-alert
v-if=
"shouldShowNewFlagAlert"
variant=
"warning"
class=
"gl-my-5"
@
dismiss=
"dismissNewVersionFlagAlert"
>
{{
$options
.
translations
.
newFlagAlert
}}
</gl-alert>
<h3
class=
"page-title"
>
{{
s__
(
'
FeatureFlags|New feature flag
'
)
}}
</h3>
<div
v-if=
"error.length"
class=
"alert alert-danger"
>
...
...
app/controllers/projects/feature_flags_controller.rb
View file @
e5b4bb1b
...
...
@@ -14,7 +14,6 @@ class Projects::FeatureFlagsController < Projects::ApplicationController
before_action
do
push_frontend_feature_flag
(
:feature_flag_permissions
)
push_frontend_feature_flag
(
:feature_flags_new_version
,
project
,
default_enabled:
true
)
push_frontend_feature_flag
(
:feature_flags_legacy_read_only
,
project
,
default_enabled:
true
)
push_frontend_feature_flag
(
:feature_flags_legacy_read_only_override
,
project
)
end
...
...
@@ -101,15 +100,7 @@ class Projects::FeatureFlagsController < Projects::ApplicationController
protected
def
feature_flag
@feature_flag
||=
@noteable
=
if
new_version_feature_flags_enabled?
project
.
operations_feature_flags
.
find_by_iid!
(
params
[
:iid
])
else
project
.
operations_feature_flags
.
legacy_flag
.
find_by_iid!
(
params
[
:iid
])
end
end
def
new_version_feature_flags_enabled?
::
Feature
.
enabled?
(
:feature_flags_new_version
,
project
,
default_enabled:
true
)
@feature_flag
||=
@noteable
=
project
.
operations_feature_flags
.
find_by_iid!
(
params
[
:iid
])
end
def
ensure_legacy_flags_writable!
...
...
app/finders/feature_flags_finder.rb
View file @
e5b4bb1b
...
...
@@ -24,11 +24,7 @@ class FeatureFlagsFinder
private
def
feature_flags
if
Feature
.
enabled?
(
:feature_flags_new_version
,
project
,
default_enabled:
true
)
project
.
operations_feature_flags
else
project
.
operations_feature_flags
.
legacy_flag
end
project
.
operations_feature_flags
end
def
by_scope
(
items
)
...
...
app/services/feature_flags/create_service.rb
View file @
e5b4bb1b
...
...
@@ -5,7 +5,6 @@ module FeatureFlags
def
execute
return
error
(
'Access Denied'
,
403
)
unless
can_create?
return
error
(
'Version is invalid'
,
:bad_request
)
unless
valid_version?
return
error
(
'New version feature flags are not enabled for this project'
,
:bad_request
)
unless
flag_version_enabled?
ActiveRecord
::
Base
.
transaction
do
feature_flag
=
project
.
operations_feature_flags
.
new
(
params
)
...
...
@@ -40,13 +39,5 @@ module FeatureFlags
def
valid_version?
!
params
.
key?
(
:version
)
||
Operations
::
FeatureFlag
.
versions
.
key?
(
params
[
:version
])
end
def
flag_version_enabled?
params
[
:version
]
!=
'new_version_flag'
||
new_version_feature_flags_enabled?
end
def
new_version_feature_flags_enabled?
::
Feature
.
enabled?
(
:feature_flags_new_version
,
project
,
default_enabled:
true
)
end
end
end
config/feature_flags/development/feature_flags_new_version.yml
deleted
100644 → 0
View file @
8da6b7f5
---
name
:
feature_flags_new_version
introduced_by_url
:
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/258831
milestone
:
'
13.7'
type
:
development
group
:
group::progressive delivery
default_enabled
:
true
doc/api/feature_flags.md
View file @
e5b4bb1b
...
...
@@ -10,10 +10,6 @@ info: To determine the technical writer assigned to the Stage/Group associated w
> - [Moved](https://gitlab.com/gitlab-org/gitlab/-/issues/212318) to [GitLab Starter](https://about.gitlab.com/pricing/) in 13.4.
> - [Moved](https://gitlab.com/gitlab-org/gitlab/-/issues/212318) to [GitLab Core](https://about.gitlab.com/pricing/) in 13.5.
NOTE:
**Note:**
This API is behind a
[
feature flag
](
../operations/feature_flags.md#enable-or-disable-feature-flag-strategies
)
.
If this flag is not enabled in your environment, you can use the
[
legacy feature flags API
](
feature_flags_legacy.md
)
.
API for accessing resources of
[
GitLab Feature Flags
](
../operations/feature_flags.md
)
.
Users with Developer or higher
[
permissions
](
../user/permissions.md
)
can access Feature Flag API.
...
...
doc/operations/feature_flags.md
View file @
e5b4bb1b
...
...
@@ -77,7 +77,6 @@ is 200. On GitLab.com, the maximum number is determined by [GitLab.com tier](htt
> - It became [enabled by default](https://gitlab.com/gitlab-org/gitlab/-/issues/214684) in GitLab 13.2.
> - It's recommended for production use.
> - It's enabled on GitLab.com.
> - For GitLab self-managed instances, a GitLab administrator can choose to [disable it](#enable-or-disable-feature-flag-strategies). **(CORE ONLY)**
You can apply a feature flag strategy across multiple environments, without defining
the strategy multiple times.
...
...
@@ -222,25 +221,6 @@ To remove users from a user list:
1.
Click on the
**{pencil}**
(edit) button next to the list you want to change.
1.
Click on the
**{remove}**
(remove) button next to the ID you want to remove.
### Enable or disable feature flag strategies
This feature is under development, but is ready for production use. It's
deployed behind a feature flag that is
**enabled by default**
.
[
GitLab administrators with access to the GitLab Rails console
](
../administration/feature_flags.md
)
can disable it for your instance.
To disable it:
```
ruby
Feature
.
disable
(
:feature_flags_new_version
)
```
To enable it:
```
ruby
Feature
.
enable
(
:feature_flags_new_version
)
```
## Rollout strategy (legacy)
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/8240) in GitLab 12.2.
...
...
ee/spec/features/projects/feature_flags/user_creates_feature_flag_spec.rb
View file @
e5b4bb1b
...
...
@@ -14,24 +14,18 @@ RSpec.describe 'User creates feature flag', :js do
sign_in
(
user
)
end
context
'w
ith new version flags disabled
'
do
context
'w
hen creates without changing scopes
'
do
before
do
stub_feature_flags
(
feature_flags_new_version:
false
)
visit
(
new_project_feature_flag_path
(
project
))
set_feature_flag_info
(
'ci_live_trace'
,
'For live trace'
)
click_button
'Create feature flag'
expect
(
page
).
to
have_current_path
(
project_feature_flags_path
(
project
))
end
context
'when creates without changing scopes'
do
before
do
visit
(
new_project_feature_flag_path
(
project
))
set_feature_flag_info
(
'ci_live_trace'
,
'For live trace'
)
click_button
'Create feature flag'
expect
(
page
).
to
have_current_path
(
project_feature_flags_path
(
project
))
end
it
'records audit event'
do
visit
(
project_audit_events_path
(
project
))
it
'records audit event'
do
visit
(
project_audit_events_path
(
project
))
expect
(
page
).
to
have_text
(
"Created feature flag ci_live_trace with description
\"
For live trace
\"
."
)
end
expect
(
page
).
to
have_text
(
"Created feature flag ci_live_trace with description
\"
For live trace
\"
."
)
end
end
...
...
lib/api/entities/feature_flag.rb
View file @
e5b4bb1b
...
...
@@ -6,11 +6,11 @@ module API
expose
:name
expose
:description
expose
:active
expose
:version
,
if: :feature_flags_new_version_enabled
expose
:version
expose
:created_at
expose
:updated_at
expose
:scopes
,
using:
FeatureFlag
::
LegacyScope
expose
:strategies
,
using:
FeatureFlag
::
Strategy
,
if: :feature_flags_new_version_enabled
expose
:strategies
,
using:
FeatureFlag
::
Strategy
end
end
end
lib/api/feature_flags.rb
View file @
e5b4bb1b
...
...
@@ -62,8 +62,6 @@ module API
attrs
=
declared_params
(
include_missing:
false
)
ensure_post_version_2_flags_enabled!
if
attrs
[
:version
]
==
'new_version_flag'
rename_key
(
attrs
,
:scopes
,
:scopes_attributes
)
rename_key
(
attrs
,
:strategies
,
:strategies_attributes
)
update_value
(
attrs
,
:strategies_attributes
)
do
|
strategies
|
...
...
@@ -143,7 +141,7 @@ module API
end
desc
'Update a feature flag'
do
detail
'This feature will
be introduced in GitLab 13.1 if feature_flags_new_version feature flag is removed
'
detail
'This feature will
was introduced in GitLab 13.2
'
success
::
API
::
Entities
::
FeatureFlag
end
params
do
...
...
@@ -163,7 +161,6 @@ module API
end
end
put
do
not_found!
unless
feature_flags_new_version_enabled?
authorize_update_feature_flag!
render_api_error!
(
'PUT operations are not supported for legacy feature flags'
,
:unprocessable_entity
)
if
feature_flag
.
legacy_flag?
...
...
@@ -228,32 +225,17 @@ module API
def
present_entity
(
result
)
present
result
,
with:
::
API
::
Entities
::
FeatureFlag
,
feature_flags_new_version_enabled:
feature_flags_new_version_enabled?
end
def
ensure_post_version_2_flags_enabled!
unless
feature_flags_new_version_enabled?
render_api_error!
(
'Version 2 flags are not enabled for this project'
,
:unprocessable_entity
)
end
with:
::
API
::
Entities
::
FeatureFlag
end
def
feature_flag
@feature_flag
||=
if
feature_flags_new_version_enabled?
user_project
.
operations_feature_flags
.
find_by_name!
(
params
[
:feature_flag_name
])
else
user_project
.
operations_feature_flags
.
legacy_flag
.
find_by_name!
(
params
[
:feature_flag_name
])
end
@feature_flag
||=
user_project
.
operations_feature_flags
.
find_by_name!
(
params
[
:feature_flag_name
])
end
def
new_version_flag_present?
user_project
.
operations_feature_flags
.
new_version_flag
.
find_by_name
(
params
[
:name
]).
present?
end
def
feature_flags_new_version_enabled?
Feature
.
enabled?
(
:feature_flags_new_version
,
user_project
,
default_enabled:
true
)
end
def
rename_key
(
hash
,
old_key
,
new_key
)
hash
[
new_key
]
=
hash
.
delete
(
old_key
)
if
hash
.
key?
(
old_key
)
hash
...
...
spec/controllers/projects/feature_flags_controller_spec.rb
View file @
e5b4bb1b
...
...
@@ -217,15 +217,6 @@ RSpec.describe Projects::FeatureFlagsController do
expect
(
json_response
[
'feature_flags'
].
count
).
to
eq
(
3
)
end
it
'returns only version 1 flags when new version flags are disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
subject
expected
=
[
feature_flag_active
.
name
,
feature_flag_inactive
.
name
].
sort
expect
(
json_response
[
'feature_flags'
].
map
{
|
f
|
f
[
'name'
]
}.
sort
).
to
eq
(
expected
)
end
end
end
...
...
@@ -283,24 +274,6 @@ RSpec.describe Projects::FeatureFlagsController do
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
)
{
}
...
...
@@ -386,14 +359,6 @@ RSpec.describe Projects::FeatureFlagsController do
expect
(
json_response
[
'version'
]).
to
eq
(
'new_version_flag'
)
end
it
'returns a 404 when new version flags are disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
subject
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
it
'returns strategies ordered by id'
do
first_strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_feature_flag
)
second_strategy
=
create
(
:operations_strategy
,
feature_flag:
new_version_feature_flag
)
...
...
@@ -791,54 +756,6 @@ RSpec.describe Projects::FeatureFlagsController do
expect
(
Operations
::
FeatureFlag
.
count
).
to
eq
(
0
)
end
end
context
'when version 2 flags are disabled'
do
context
'and attempting to create a version 2 flag'
do
let
(
:params
)
do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
operations_feature_flag:
{
name:
'my_feature_flag'
,
active:
true
,
version:
'new_version_flag'
}
}
end
it
'returns a 400'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
subject
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
Operations
::
FeatureFlag
.
count
).
to
eq
(
0
)
end
end
context
'and attempting to create a version 1 flag'
do
let
(
:params
)
do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
operations_feature_flag:
{
name:
'my_feature_flag'
,
active:
true
}
}
end
it
'creates the flag'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
Operations
::
FeatureFlag
.
count
).
to
eq
(
1
)
expect
(
json_response
[
'version'
]).
to
eq
(
'legacy_flag'
)
end
end
end
end
describe
'DELETE destroy.json'
do
...
...
@@ -913,15 +830,6 @@ RSpec.describe Projects::FeatureFlagsController do
it
'deletes the flag'
do
expect
{
subject
}.
to
change
{
Operations
::
FeatureFlag
.
count
}.
by
(
-
1
)
end
context
'when new version flags are disabled'
do
it
'returns a 404'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
expect
{
subject
}.
not_to
change
{
Operations
::
FeatureFlag
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
...
...
@@ -1576,15 +1484,6 @@ RSpec.describe Projects::FeatureFlagsController do
expect
(
json_response
[
'strategies'
].
first
[
'scopes'
]).
to
eq
([])
end
it
'does not update the flag if version 2 flags are disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
put_request
(
new_version_flag
,
{
name:
'some-other-name'
})
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
new_version_flag
.
reload
.
name
).
to
eq
(
'new-feature'
)
end
it
'updates the flag when legacy feature flags are set to be read only'
do
stub_feature_flags
(
feature_flags_legacy_read_only:
true
)
...
...
spec/features/projects/feature_flags/user_creates_feature_flag_spec.rb
View file @
e5b4bb1b
...
...
@@ -67,118 +67,6 @@ RSpec.describe 'User creates feature flag', :js do
end
end
context
'with new version flags disabled'
do
before
do
stub_feature_flags
(
feature_flags_new_version:
false
)
end
context
'when creates without changing scopes'
do
before
do
visit
(
new_project_feature_flag_path
(
project
))
set_feature_flag_info
(
'ci_live_trace'
,
'For live trace'
)
click_button
'Create feature flag'
expect
(
page
).
to
have_current_path
(
project_feature_flags_path
(
project
))
end
it
'shows the created feature flag'
do
within_feature_flag_row
(
1
)
do
expect
(
page
.
find
(
'.feature-flag-name'
)).
to
have_content
(
'ci_live_trace'
)
expect_status_toggle_button_to_be_checked
within_feature_flag_scopes
do
expect
(
page
.
find
(
'[data-qa-selector="feature-flag-scope-info-badge"]:nth-child(1)'
)).
to
have_content
(
'*'
)
end
end
end
end
context
'when creates with disabling the default scope'
do
before
do
visit
(
new_project_feature_flag_path
(
project
))
set_feature_flag_info
(
'ci_live_trace'
,
'For live trace'
)
within_scope_row
(
1
)
do
within_status
{
find
(
'.project-feature-toggle'
).
click
}
end
click_button
'Create feature flag'
end
it
'shows the created feature flag'
do
within_feature_flag_row
(
1
)
do
expect
(
page
.
find
(
'.feature-flag-name'
)).
to
have_content
(
'ci_live_trace'
)
expect_status_toggle_button_to_be_checked
within_feature_flag_scopes
do
expect
(
page
.
find
(
'[data-qa-selector="feature-flag-scope-muted-badge"]:nth-child(1)'
)).
to
have_content
(
'*'
)
end
end
end
end
context
'when creates with an additional scope'
do
before
do
visit
(
new_project_feature_flag_path
(
project
))
set_feature_flag_info
(
'mr_train'
,
''
)
within_scope_row
(
2
)
do
within_environment_spec
do
find
(
'.js-env-search > input'
).
set
(
"review/*"
)
find
(
'.js-create-button'
).
click
end
end
within_scope_row
(
2
)
do
within_status
{
find
(
'.project-feature-toggle'
).
click
}
end
click_button
'Create feature flag'
end
it
'shows the created feature flag'
do
within_feature_flag_row
(
1
)
do
expect
(
page
.
find
(
'.feature-flag-name'
)).
to
have_content
(
'mr_train'
)
expect_status_toggle_button_to_be_checked
within_feature_flag_scopes
do
expect
(
page
.
find
(
'[data-qa-selector="feature-flag-scope-info-badge"]:nth-child(1)'
)).
to
have_content
(
'*'
)
expect
(
page
.
find
(
'[data-qa-selector="feature-flag-scope-info-badge"]:nth-child(2)'
)).
to
have_content
(
'review/*'
)
end
end
end
end
context
'when searches an environment name for scope creation'
do
let!
(
:environment
)
{
create
(
:environment
,
name:
'production'
,
project:
project
)
}
before
do
visit
(
new_project_feature_flag_path
(
project
))
set_feature_flag_info
(
'mr_train'
,
''
)
within_scope_row
(
2
)
do
within_environment_spec
do
find
(
'.js-env-search > input'
).
set
(
'prod'
)
click_button
'production'
end
end
click_button
'Create feature flag'
end
it
'shows the created feature flag'
do
within_feature_flag_row
(
1
)
do
expect
(
page
.
find
(
'.feature-flag-name'
)).
to
have_content
(
'mr_train'
)
expect_status_toggle_button_to_be_checked
within_feature_flag_scopes
do
expect
(
page
.
find
(
'[data-qa-selector="feature-flag-scope-info-badge"]:nth-child(1)'
)).
to
have_content
(
'*'
)
expect
(
page
.
find
(
'[data-qa-selector="feature-flag-scope-muted-badge"]:nth-child(2)'
)).
to
have_content
(
'production'
)
end
end
end
end
end
private
def
set_feature_flag_info
(
name
,
description
)
...
...
spec/finders/feature_flags_finder_spec.rb
View file @
e5b4bb1b
...
...
@@ -80,15 +80,5 @@ RSpec.describe FeatureFlagsFinder do
is_expected
.
to
eq
([
feature_flag_1
,
feature_flag_2
,
feature_flag_3
])
end
end
context
'when new version flags are disabled'
do
let!
(
:feature_flag_3
)
{
create
(
:operations_feature_flag
,
:new_version_flag
,
name:
'flag-c'
,
project:
project
)
}
it
'returns only legacy flags'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
is_expected
.
to
eq
([
feature_flag_1
,
feature_flag_2
])
end
end
end
end
spec/frontend/feature_flags/components/edit_feature_flag_spec.js
View file @
e5b4bb1b
...
...
@@ -4,7 +4,7 @@ import MockAdapter from 'axios-mock-adapter';
import
{
GlToggle
,
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
{
mockTracking
}
from
'
helpers/tracking_helper
'
;
import
{
LEGACY_FLAG
,
NEW_VERSION_FLAG
,
NEW_FLAG_ALERT
}
from
'
~/feature_flags/constants
'
;
import
{
LEGACY_FLAG
,
NEW_VERSION_FLAG
}
from
'
~/feature_flags/constants
'
;
import
Form
from
'
~/feature_flags/components/form.vue
'
;
import
createStore
from
'
~/feature_flags/store/edit
'
;
import
EditFeatureFlag
from
'
~/feature_flags/components/edit_feature_flag.vue
'
;
...
...
@@ -37,9 +37,6 @@ describe('Edit feature flag form', () => {
showUserCallout
:
true
,
userCalloutId
,
userCalloutsPath
,
glFeatures
:
{
featureFlagsNewVersion
:
true
,
},
...
opts
,
},
});
...
...
@@ -151,33 +148,4 @@ describe('Edit feature flag form', () => {
});
});
});
describe
(
'
without new version flags
'
,
()
=>
{
beforeEach
(()
=>
factory
({
glFeatures
:
{
featureFlagsNewVersion
:
false
}
}));
it
(
'
should alert users that feature flags are changing soon
'
,
()
=>
{
expect
(
findAlert
().
text
()).
toBe
(
NEW_FLAG_ALERT
);
});
});
describe
(
'
dismissing new version alert
'
,
()
=>
{
beforeEach
(()
=>
{
factory
({
glFeatures
:
{
featureFlagsNewVersion
:
false
}
});
mock
.
onPost
(
userCalloutsPath
,
{
feature_name
:
userCalloutId
}).
reply
(
200
);
findAlert
().
vm
.
$emit
(
'
dismiss
'
);
return
wrapper
.
vm
.
$nextTick
();
});
afterEach
(()
=>
{
mock
.
restore
();
});
it
(
'
should hide the alert
'
,
()
=>
{
expect
(
findAlert
().
exists
()).
toBe
(
false
);
});
it
(
'
should send the dismissal event
'
,
()
=>
{
expect
(
mock
.
history
.
post
.
length
).
toBe
(
1
);
});
});
});
spec/frontend/feature_flags/components/new_feature_flag_spec.js
View file @
e5b4bb1b
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
Vuex
from
'
vuex
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
Form
from
'
~/feature_flags/components/form.vue
'
;
import
createStore
from
'
~/feature_flags/store/new
'
;
import
NewFeatureFlag
from
'
~/feature_flags/components/new_feature_flag.vue
'
;
import
{
ROLLOUT_STRATEGY_ALL_USERS
,
DEFAULT_PERCENT_ROLLOUT
,
NEW_FLAG_ALERT
,
}
from
'
~/feature_flags/constants
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
ROLLOUT_STRATEGY_ALL_USERS
,
DEFAULT_PERCENT_ROLLOUT
}
from
'
~/feature_flags/constants
'
;
import
{
allUsersStrategy
}
from
'
../mock_data
'
;
const
userCalloutId
=
'
feature_flags_new_version
'
;
...
...
@@ -42,9 +36,6 @@ describe('New feature flag form', () => {
userCalloutsPath
,
environmentsEndpoint
:
'
environments.json
'
,
projectId
:
'
8
'
,
glFeatures
:
{
featureFlagsNewVersion
:
true
,
},
...
opts
,
},
});
...
...
@@ -58,8 +49,6 @@ describe('New feature flag form', () => {
wrapper
.
destroy
();
});
const
findAlert
=
()
=>
wrapper
.
find
(
GlAlert
);
describe
(
'
with error
'
,
()
=>
{
it
(
'
should render the error
'
,
()
=>
{
store
.
dispatch
(
'
receiveCreateFeatureFlagError
'
,
{
message
:
[
'
The name is required
'
]
});
...
...
@@ -101,36 +90,4 @@ describe('New feature flag form', () => {
expect
(
strategies
).
toEqual
([
allUsersStrategy
]);
});
describe
(
'
without new version flags
'
,
()
=>
{
beforeEach
(()
=>
factory
({
glFeatures
:
{
featureFlagsNewVersion
:
false
}
}));
it
(
'
should alert users that feature flags are changing soon
'
,
()
=>
{
expect
(
findAlert
().
text
()).
toBe
(
NEW_FLAG_ALERT
);
});
});
describe
(
'
dismissing new version alert
'
,
()
=>
{
let
mock
;
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
mock
.
onPost
(
userCalloutsPath
,
{
feature_name
:
userCalloutId
}).
reply
(
200
);
factory
({
glFeatures
:
{
featureFlagsNewVersion
:
false
}
});
findAlert
().
vm
.
$emit
(
'
dismiss
'
);
return
wrapper
.
vm
.
$nextTick
();
});
afterEach
(()
=>
{
mock
.
restore
();
});
it
(
'
should hide the alert
'
,
()
=>
{
expect
(
findAlert
().
exists
()).
toBe
(
false
);
});
it
(
'
should send the dismissal event
'
,
()
=>
{
expect
(
mock
.
history
.
post
.
length
).
toBe
(
1
);
});
});
});
spec/requests/api/feature_flags_spec.rb
View file @
e5b4bb1b
...
...
@@ -65,26 +65,6 @@ RSpec.describe API::FeatureFlags do
expect
(
json_response
.
map
{
|
f
|
f
[
'version'
]
}).
to
eq
(
%w[legacy_flag legacy_flag]
)
end
it
'does not return the legacy flag version when the feature flag is disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/feature_flags'
)
expect
(
json_response
.
select
{
|
f
|
f
.
key?
(
'version'
)
}).
to
eq
([])
end
it
'does not return strategies if the new flag is disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/feature_flags'
)
expect
(
json_response
.
select
{
|
f
|
f
.
key?
(
'strategies'
)
}).
to
eq
([])
end
it
'does not have N+1 problem'
do
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
...
...
@@ -134,16 +114,6 @@ RSpec.describe API::FeatureFlags do
}]
}])
end
it
'does not return a version 2 flag when the feature flag is disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/feature_flags'
)
expect
(
json_response
).
to
eq
([])
end
end
context
'with version 1 and 2 feature flags'
do
...
...
@@ -159,20 +129,6 @@ RSpec.describe API::FeatureFlags do
expect
(
response
).
to
match_response_schema
(
'public_api/v4/feature_flags'
)
expect
(
json_response
.
map
{
|
f
|
f
[
'name'
]
}).
to
eq
(
%w[legacy_flag new_version_flag]
)
end
it
'returns only version 1 flags when the feature flag is disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
create
(
:operations_feature_flag
,
project:
project
,
name:
'legacy_flag'
)
feature_flag
=
create
(
:operations_feature_flag
,
:new_version_flag
,
project:
project
,
name:
'new_version_flag'
)
strategy
=
create
(
:operations_strategy
,
feature_flag:
feature_flag
,
name:
'default'
,
parameters:
{})
create
(
:operations_scope
,
strategy:
strategy
,
environment_scope:
'production'
)
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/feature_flags'
)
expect
(
json_response
.
map
{
|
f
|
f
[
'name'
]
}).
to
eq
([
'legacy_flag'
])
end
end
end
...
...
@@ -224,18 +180,6 @@ RSpec.describe API::FeatureFlags do
}]
})
end
it
'returns a 404 when the feature is disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
feature_flag
=
create
(
:operations_feature_flag
,
:new_version_flag
,
project:
project
,
name:
'feature1'
)
strategy
=
create
(
:operations_strategy
,
feature_flag:
feature_flag
,
name:
'default'
,
parameters:
{})
create
(
:operations_scope
,
strategy:
strategy
,
environment_scope:
'production'
)
get
api
(
"/projects/
#{
project
.
id
}
/feature_flags/feature1"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
json_response
).
to
eq
({
'message'
=>
'404 Not found'
})
end
end
end
...
...
@@ -290,16 +234,6 @@ RSpec.describe API::FeatureFlags do
expect
(
json_response
[
'version'
]).
to
eq
(
'legacy_flag'
)
end
it
'does not return version when new version flags are disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
subject
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/feature_flag'
)
expect
(
json_response
.
key?
(
'version'
)).
to
eq
(
false
)
end
context
'with active set to false in the params for a legacy flag'
do
let
(
:params
)
do
{
...
...
@@ -505,20 +439,6 @@ RSpec.describe API::FeatureFlags do
environment_scope:
'staging'
}])
end
it
'returns a 422 when the feature flag is disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
params
=
{
name:
'new-feature'
,
version:
'new_version_flag'
}
post
api
(
"/projects/
#{
project
.
id
}
/feature_flags"
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
:unprocessable_entity
)
expect
(
json_response
).
to
eq
({
'message'
=>
'Version 2 flags are not enabled for this project'
})
expect
(
project
.
operations_feature_flags
.
count
).
to
eq
(
0
)
end
end
context
'when given invalid parameters'
do
...
...
@@ -744,16 +664,6 @@ RSpec.describe API::FeatureFlags do
name:
'feature1'
,
description:
'old description'
)
end
it
'returns a 404 if the feature is disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
params
=
{
description:
'new description'
}
put
api
(
"/projects/
#{
project
.
id
}
/feature_flags/feature1"
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
feature_flag
.
reload
.
description
).
to
eq
(
'old description'
)
end
it
'returns a 422'
do
params
=
{
description:
'new description'
}
...
...
@@ -771,16 +681,6 @@ RSpec.describe API::FeatureFlags do
name:
'feature1'
,
description:
'old description'
)
end
it
'returns a 404 if the feature is disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
params
=
{
description:
'new description'
}
put
api
(
"/projects/
#{
project
.
id
}
/feature_flags/feature1"
,
user
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
feature_flag
.
reload
.
description
).
to
eq
(
'old description'
)
end
it
'returns a 404 if the feature flag does not exist'
do
params
=
{
description:
'new description'
}
...
...
@@ -1100,15 +1000,6 @@ RSpec.describe API::FeatureFlags do
expect
(
json_response
[
'version'
]).
to
eq
(
'legacy_flag'
)
end
it
'does not return version when new version flags are disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
key?
(
'version'
)).
to
eq
(
false
)
end
context
'with a version 2 feature flag'
do
let!
(
:feature_flag
)
{
create
(
:operations_feature_flag
,
:new_version_flag
,
project:
project
)
}
...
...
@@ -1117,14 +1008,6 @@ RSpec.describe API::FeatureFlags do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
it
'returns a 404 if the feature is disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
expect
{
subject
}.
not_to
change
{
Operations
::
FeatureFlag
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
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