Read about our upcoming Code of Conduct on this issue

Commit 339700d9 authored by Alexis Reigel's avatar Alexis Reigel
Browse files

project#group_runner_enabled -> project_settings

parent 8507ddde8802
......@@ -53,7 +53,7 @@ def toggle_shared_runners
end
def toggle_group_runners
project.toggle!(:group_runners_enabled)
project.toggle_settings!(:group_runners_enabled)
redirect_to project_settings_ci_cd_path(@project)
end
......
......@@ -249,6 +249,7 @@ class Project < ActiveRecord::Base
delegate :members, to: :team, prefix: true
delegate :add_user, :add_users, to: :team
delegate :add_guest, :add_reporter, :add_developer, :add_master, :add_role, to: :team
delegate :group_runners_enabled, :group_runners_enabled=, :group_runners_enabled?, to: :settings
# Validations
validates :creator, presence: true, on: :create
......@@ -1893,6 +1894,10 @@ def licensed_features
[]
end
def toggle_settings!(settings_attribute)
settings.toggle!(settings_attribute)
end
private
def storage
......
class AddGroupRunnersEnabledToProjects < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default :projects, :group_runners_enabled, :boolean, default: true
add_concurrent_index :projects, :group_runners_enabled
end
def down
remove_column :projects, :group_runners_enabled
end
end
......@@ -7,6 +7,8 @@ class CreateProjectSettings < ActiveRecord::Migration
def change
create_table :project_settings do |t|
t.references :project, index: true, foreign_key: { on_delete: :cascade }
t.boolean :group_runners_enabled, default: true, index: true
end
end
end
......@@ -1506,8 +1506,10 @@
create_table "project_settings", force: :cascade do |t|
t.integer "project_id"
t.boolean "group_runners_enabled", default: true
end
add_index "project_settings", ["group_runners_enabled"], name: "index_project_settings_on_group_runners_enabled", using: :btree
add_index "project_settings", ["project_id"], name: "index_project_settings_on_project_id", using: :btree
create_table "project_statistics", force: :cascade do |t|
......@@ -1581,7 +1583,6 @@
add_index "projects", ["created_at"], name: "index_projects_on_created_at", using: :btree
add_index "projects", ["creator_id"], name: "index_projects_on_creator_id", using: :btree
add_index "projects", ["description"], name: "index_projects_on_description_trigram", using: :gin, opclasses: {"description"=>"gin_trgm_ops"}
add_index "projects", ["group_runners_enabled"], name: "index_projects_on_group_runners_enabled", using: :btree
add_index "projects", ["id"], name: "index_projects_on_id_partial_for_visibility", unique: true, where: "(visibility_level = ANY (ARRAY[10, 20]))", using: :btree
add_index "projects", ["last_activity_at"], name: "index_projects_on_last_activity_at", using: :btree
add_index "projects", ["last_repository_check_failed"], name: "index_projects_on_last_repository_check_failed", using: :btree
......
......@@ -15,14 +15,18 @@
namespace
creator { group ? create(:user) : namespace&.owner }
# Nest Project Feature attributes
transient do
# Nest Project Feature attributes
wiki_access_level ProjectFeature::ENABLED
builds_access_level ProjectFeature::ENABLED
snippets_access_level ProjectFeature::ENABLED
issues_access_level ProjectFeature::ENABLED
merge_requests_access_level ProjectFeature::ENABLED
repository_access_level ProjectFeature::ENABLED
# we can't assign the delegated `#settings` attributes directly, as the
# `#settings` relation needs to be created first
group_runners_enabled nil
end
after(:create) do |project, evaluator|
......@@ -47,6 +51,9 @@
end
project.group&.refresh_members_authorized_projects
# assign the delegated `#settings` attributes after create
project.reload.group_runners_enabled = evaluator.group_runners_enabled unless evaluator.group_runners_enabled.nil?
end
trait :public do
......
......@@ -3640,4 +3640,16 @@ def domain_variable
it { is_expected.not_to be_valid }
end
end
describe '#toggle_settings!' do
it 'toggles the value on #settings' do
project = create :project, group_runners_enabled: false
expect(project.group_runners_enabled).to be false
project.toggle_settings!(:group_runners_enabled)
expect(project.group_runners_enabled).to be true
end
end
end
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