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
7b2af27a
Commit
7b2af27a
authored
Oct 02, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename feature_flags_instances to feature_flags_clients
parent
97a24815
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
52 additions
and
18 deletions
+52
-18
db/schema.rb
db/schema.rb
+3
-3
ee/app/helpers/feature_flags_helper.rb
ee/app/helpers/feature_flags_helper.rb
+1
-1
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+3
-3
ee/app/models/operations/feature_flag.rb
ee/app/models/operations/feature_flag.rb
+1
-1
ee/app/models/operations/feature_flags_client.rb
ee/app/models/operations/feature_flags_client.rb
+2
-2
ee/db/migrate/20180626171125_add_feature_flags_to_projects.rb
...b/migrate/20180626171125_add_feature_flags_to_projects.rb
+2
-7
ee/spec/factories/operations/feature_flags_clients.rb
ee/spec/factories/operations/feature_flags_clients.rb
+5
-0
ee/spec/models/operations/feature_flag_spec.rb
ee/spec/models/operations/feature_flag_spec.rb
+15
-0
ee/spec/models/operations/feature_flags_client_spec.rb
ee/spec/models/operations/feature_flags_client_spec.rb
+19
-0
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+1
-1
No files found.
db/schema.rb
View file @
7b2af27a
...
@@ -1954,12 +1954,12 @@ ActiveRecord::Schema.define(version: 20180926140319) do
...
@@ -1954,12 +1954,12 @@ ActiveRecord::Schema.define(version: 20180926140319) do
add_index
"operations_feature_flags"
,
[
"project_id"
,
"name"
],
name:
"index_operations_feature_flags_on_project_id_and_name"
,
unique:
true
,
using: :btree
add_index
"operations_feature_flags"
,
[
"project_id"
,
"name"
],
name:
"index_operations_feature_flags_on_project_id_and_name"
,
unique:
true
,
using: :btree
create_table
"operations_feature_flags_
instance
s"
,
force: :cascade
do
|
t
|
create_table
"operations_feature_flags_
client
s"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
,
null:
false
t
.
integer
"project_id"
,
null:
false
t
.
string
"token"
,
null:
false
t
.
string
"token"
,
null:
false
end
end
add_index
"operations_feature_flags_
instances"
,
[
"token"
],
name:
"index_operations_feature_flags_instance
s_on_token"
,
unique:
true
,
using: :btree
add_index
"operations_feature_flags_
clients"
,
[
"token"
],
name:
"index_operations_feature_flags_client
s_on_token"
,
unique:
true
,
using: :btree
create_table
"packages_maven_metadata"
,
id: :bigserial
,
force: :cascade
do
|
t
|
create_table
"packages_maven_metadata"
,
id: :bigserial
,
force: :cascade
do
|
t
|
t
.
integer
"package_id"
,
limit:
8
,
null:
false
t
.
integer
"package_id"
,
limit:
8
,
null:
false
...
@@ -3252,7 +3252,7 @@ ActiveRecord::Schema.define(version: 20180926140319) do
...
@@ -3252,7 +3252,7 @@ ActiveRecord::Schema.define(version: 20180926140319) do
add_foreign_key
"notification_settings"
,
"users"
,
name:
"fk_0c95e91db7"
,
on_delete: :cascade
add_foreign_key
"notification_settings"
,
"users"
,
name:
"fk_0c95e91db7"
,
on_delete: :cascade
add_foreign_key
"oauth_openid_requests"
,
"oauth_access_grants"
,
column:
"access_grant_id"
,
name:
"fk_oauth_openid_requests_oauth_access_grants_access_grant_id"
add_foreign_key
"oauth_openid_requests"
,
"oauth_access_grants"
,
column:
"access_grant_id"
,
name:
"fk_oauth_openid_requests_oauth_access_grants_access_grant_id"
add_foreign_key
"operations_feature_flags"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"operations_feature_flags"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"operations_feature_flags_
instance
s"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"operations_feature_flags_
client
s"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"packages_maven_metadata"
,
"packages_packages"
,
column:
"package_id"
,
name:
"fk_be88aed360"
,
on_delete: :cascade
add_foreign_key
"packages_maven_metadata"
,
"packages_packages"
,
column:
"package_id"
,
name:
"fk_be88aed360"
,
on_delete: :cascade
add_foreign_key
"packages_package_files"
,
"packages_packages"
,
column:
"package_id"
,
name:
"fk_86f0f182f8"
,
on_delete: :cascade
add_foreign_key
"packages_package_files"
,
"packages_packages"
,
column:
"package_id"
,
name:
"fk_86f0f182f8"
,
on_delete: :cascade
add_foreign_key
"packages_packages"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"packages_packages"
,
"projects"
,
on_delete: :cascade
...
...
ee/app/helpers/feature_flags_helper.rb
View file @
7b2af27a
...
@@ -6,6 +6,6 @@ module FeatureFlagsHelper
...
@@ -6,6 +6,6 @@ module FeatureFlagsHelper
end
end
def
unleash_api_instanceid
(
project
)
def
unleash_api_instanceid
(
project
)
project
.
feature_flags_
instance
_token
project
.
feature_flags_
client
_token
end
end
end
end
ee/app/models/ee/project.rb
View file @
7b2af27a
...
@@ -51,7 +51,7 @@ module EE
...
@@ -51,7 +51,7 @@ module EE
has_many
:prometheus_alert_events
,
inverse_of: :project
has_many
:prometheus_alert_events
,
inverse_of: :project
has_many
:operations_feature_flags
,
class_name:
'Operations::FeatureFlag'
has_many
:operations_feature_flags
,
class_name:
'Operations::FeatureFlag'
has_one
:operations_feature_flags_
instance
,
class_name:
'Operations::FeatureFlagsInstance
'
has_one
:operations_feature_flags_
client
,
class_name:
'Operations::FeatureFlagsClient
'
scope
:with_shared_runners_limit_enabled
,
->
{
with_shared_runners
.
non_public_only
}
scope
:with_shared_runners_limit_enabled
,
->
{
with_shared_runners
.
non_public_only
}
...
@@ -562,8 +562,8 @@ module EE
...
@@ -562,8 +562,8 @@ module EE
change_head
(
root_ref
)
if
root_ref
.
present?
&&
root_ref
!=
default_branch
change_head
(
root_ref
)
if
root_ref
.
present?
&&
root_ref
!=
default_branch
end
end
def
feature_flags_
instance
_token
def
feature_flags_
client
_token
instance
=
operations_feature_flags_
instance
||
create_operations_feature_flags_instance
!
instance
=
operations_feature_flags_
client
||
create_operations_feature_flags_client
!
instance
.
token
instance
.
token
end
end
...
...
ee/app/models/operations/feature_flag.rb
View file @
7b2af27a
...
@@ -13,6 +13,6 @@ module Operations
...
@@ -13,6 +13,6 @@ module Operations
message:
Gitlab
::
Regex
.
feature_flag_regex_message
message:
Gitlab
::
Regex
.
feature_flag_regex_message
}
}
validates
:name
,
uniqueness:
{
scope: :project_id
}
validates
:name
,
uniqueness:
{
scope: :project_id
}
validates
:description
,
length:
0
..
255
validates
:description
,
allow_blank:
true
,
length:
0
..
255
end
end
end
end
ee/app/models/operations/feature_flags_
instance
.rb
→
ee/app/models/operations/feature_flags_
client
.rb
View file @
7b2af27a
module
Operations
module
Operations
class
FeatureFlags
Instance
<
ActiveRecord
::
Base
class
FeatureFlags
Client
<
ActiveRecord
::
Base
include
TokenAuthenticatable
include
TokenAuthenticatable
self
.
table_name
=
'operations_feature_flags_
instance
s'
self
.
table_name
=
'operations_feature_flags_
client
s'
belongs_to
:project
belongs_to
:project
...
...
ee/db/migrate/20180626171125_add_feature_flags_to_projects.rb
View file @
7b2af27a
...
@@ -4,7 +4,7 @@ class AddFeatureFlagsToProjects < ActiveRecord::Migration
...
@@ -4,7 +4,7 @@ class AddFeatureFlagsToProjects < ActiveRecord::Migration
# Set this constant to true if this migration requires downtime.
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
DOWNTIME
=
false
def
up
def
change
create_table
:operations_feature_flags
do
|
t
|
create_table
:operations_feature_flags
do
|
t
|
t
.
integer
:project_id
,
null:
false
t
.
integer
:project_id
,
null:
false
t
.
datetime_with_timezone
:created_at
,
null:
false
t
.
datetime_with_timezone
:created_at
,
null:
false
...
@@ -19,7 +19,7 @@ class AddFeatureFlagsToProjects < ActiveRecord::Migration
...
@@ -19,7 +19,7 @@ class AddFeatureFlagsToProjects < ActiveRecord::Migration
t
.
index
[
:project_id
,
:name
],
unique:
true
t
.
index
[
:project_id
,
:name
],
unique:
true
end
end
create_table
:operations_feature_flags_
instance
s
do
|
t
|
create_table
:operations_feature_flags_
client
s
do
|
t
|
t
.
integer
:project_id
,
null:
false
t
.
integer
:project_id
,
null:
false
t
.
string
:token
,
null:
false
t
.
string
:token
,
null:
false
...
@@ -28,9 +28,4 @@ class AddFeatureFlagsToProjects < ActiveRecord::Migration
...
@@ -28,9 +28,4 @@ class AddFeatureFlagsToProjects < ActiveRecord::Migration
t
.
foreign_key
:projects
,
column: :project_id
,
on_delete: :cascade
t
.
foreign_key
:projects
,
column: :project_id
,
on_delete: :cascade
end
end
end
end
def
down
drop_table
:operations_feature_flags
drop_table
:operations_feature_flags_instances
end
end
end
ee/spec/factories/operations/feature_flags_
instance
s.rb
→
ee/spec/factories/operations/feature_flags_
client
s.rb
View file @
7b2af27a
FactoryBot
.
define
do
FactoryBot
.
define
do
factory
:operations_feature_flags_
instance
,
class:
Operations
::
FeatureFlagsInstance
do
factory
:operations_feature_flags_
client
,
class:
Operations
::
FeatureFlagsClient
do
project
project
end
end
end
end
ee/spec/models/operations/feature_flag_spec.rb
View file @
7b2af27a
require
'spec_helper'
describe
Operations
::
FeatureFlag
do
subject
{
create
(
:operations_feature_flag
)
}
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:project
)
}
end
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
it
{
is_expected
.
to
validate_presence_of
(
:name
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:name
).
scoped_to
(
:project_id
)
}
end
end
ee/spec/models/operations/feature_flags_client_spec.rb
0 → 100644
View file @
7b2af27a
require
'spec_helper'
describe
Operations
::
FeatureFlagsClient
do
subject
{
create
(
:operations_feature_flags_client
)
}
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:project
)
}
end
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
end
describe
'#token'
do
it
"ensures that token is always set"
do
expect
(
subject
.
token
).
not_to
be_empty
end
end
end
ee/spec/models/project_spec.rb
View file @
7b2af27a
...
@@ -1780,7 +1780,7 @@ describe Project do
...
@@ -1780,7 +1780,7 @@ describe Project do
end
end
context
'when there is access token'
do
context
'when there is access token'
do
let!
(
:instance
)
{
create
(
:operations_feature_flags_
instance
,
project:
project
,
token:
'token'
)
}
let!
(
:instance
)
{
create
(
:operations_feature_flags_
client
,
project:
project
,
token:
'token'
)
}
it
"provides an existing one"
do
it
"provides an existing one"
do
is_expected
.
to
eq
(
'token'
)
is_expected
.
to
eq
(
'token'
)
...
...
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