Commit 7b2af27a authored by Kamil Trzciński's avatar Kamil Trzciński

Rename feature_flags_instances to feature_flags_clients

parent 97a24815
...@@ -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_instances", force: :cascade do |t| create_table "operations_feature_flags_clients", 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_instances_on_token", unique: true, using: :btree add_index "operations_feature_flags_clients", ["token"], name: "index_operations_feature_flags_clients_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_instances", "projects", on_delete: :cascade add_foreign_key "operations_feature_flags_clients", "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
......
...@@ -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
...@@ -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
......
...@@ -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
module Operations module Operations
class FeatureFlagsInstance < ActiveRecord::Base class FeatureFlagsClient < ActiveRecord::Base
include TokenAuthenticatable include TokenAuthenticatable
self.table_name = 'operations_feature_flags_instances' self.table_name = 'operations_feature_flags_clients'
belongs_to :project belongs_to :project
......
...@@ -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_instances do |t| create_table :operations_feature_flags_clients 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
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
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
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
...@@ -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')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment