diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-04-26 05:39:04 +0300 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-04-26 05:39:04 +0300 |
commit | 92cbf9453a4435976bfe77cafd0f8c5f57833e59 (patch) | |
tree | 73737cc30b6483876cbea36690a0b9830c418071 | |
parent | c80e6b9c1229776cf5af065954b99c182cc046c2 (diff) |
Switch to using ProjectCiCdSetting for group_runners_enabled and remove ProjectSettings
-rw-r--r-- | app/controllers/projects/runners_controller.rb | 2 | ||||
-rw-r--r-- | app/models/project.rb | 14 | ||||
-rw-r--r-- | app/models/project_settings.rb | 3 | ||||
-rw-r--r-- | db/migrate/20171030155459_create_project_settings.rb | 14 | ||||
-rw-r--r-- | db/schema.rb | 9 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 24 |
6 files changed, 6 insertions, 60 deletions
diff --git a/app/controllers/projects/runners_controller.rb b/app/controllers/projects/runners_controller.rb index 992e42d9348..b9bbe7115c4 100644 --- a/app/controllers/projects/runners_controller.rb +++ b/app/controllers/projects/runners_controller.rb @@ -53,7 +53,7 @@ class Projects::RunnersController < Projects::ApplicationController end def toggle_group_runners - project.toggle_settings!(:group_runners_enabled) + project.toggle_ci_cd_settings!(:group_runners_enabled) redirect_to project_settings_ci_cd_path(@project) end diff --git a/app/models/project.rb b/app/models/project.rb index dddc7fb2b27..19024b4ea85 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -236,14 +236,6 @@ class Project < ActiveRecord::Base has_many :project_badges, class_name: 'ProjectBadge' has_one :ci_cd_settings, class_name: 'ProjectCiCdSetting' - has_one :settings, -> (project) { - query = where(project_id: project) - query.presence || begin - ProjectSettings.create(project_id: project.id) - query - end - }, class_name: 'ProjectSettings' - accepts_nested_attributes_for :variables, allow_destroy: true accepts_nested_attributes_for :project_feature, update_only: true accepts_nested_attributes_for :import_data @@ -253,7 +245,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 + delegate :group_runners_enabled, :group_runners_enabled=, :group_runners_enabled?, to: :ci_cd_settings # Validations validates :creator, presence: true, on: :create @@ -1879,8 +1871,8 @@ class Project < ActiveRecord::Base [] end - def toggle_settings!(settings_attribute) - settings.toggle!(settings_attribute) + def toggle_ci_cd_settings!(settings_attribute) + ci_cd_settings.toggle!(settings_attribute) end def gitlab_deploy_token diff --git a/app/models/project_settings.rb b/app/models/project_settings.rb deleted file mode 100644 index b126f66fafa..00000000000 --- a/app/models/project_settings.rb +++ /dev/null @@ -1,3 +0,0 @@ -class ProjectSettings < ActiveRecord::Base - belongs_to :project -end diff --git a/db/migrate/20171030155459_create_project_settings.rb b/db/migrate/20171030155459_create_project_settings.rb deleted file mode 100644 index ebbe4c64fbd..00000000000 --- a/db/migrate/20171030155459_create_project_settings.rb +++ /dev/null @@ -1,14 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CreateProjectSettings < ActiveRecord::Migration - DOWNTIME = false - - 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 diff --git a/db/schema.rb b/db/schema.rb index 7eebe94a8a6..233423aaa90 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1511,14 +1511,6 @@ ActiveRecord::Schema.define(version: 20180425131009) do add_index "project_import_data", ["project_id"], name: "index_project_import_data_on_project_id", using: :btree - 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| t.integer "project_id", null: false t.integer "namespace_id", null: false @@ -2200,7 +2192,6 @@ ActiveRecord::Schema.define(version: 20180425131009) do add_foreign_key "project_features", "projects", name: "fk_18513d9b92", on_delete: :cascade add_foreign_key "project_group_links", "projects", name: "fk_daa8cee94c", on_delete: :cascade add_foreign_key "project_import_data", "projects", name: "fk_ffb9ee3a10", on_delete: :cascade - add_foreign_key "project_settings", "projects", on_delete: :cascade add_foreign_key "project_statistics", "projects", on_delete: :cascade add_foreign_key "protected_branch_merge_access_levels", "protected_branches", name: "fk_8a3072ccb3", on_delete: :cascade add_foreign_key "protected_branch_push_access_levels", "protected_branches", name: "fk_9ffc86a3d9", on_delete: :cascade diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 265941acbe7..7392b75e37c 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -123,26 +123,6 @@ describe Project do expect(subject.boards.size).to eq 1 end end - - describe '#settings' do - it 'creates lazily a settings record when the project does not have one associated' do - project = create :project - expect(ProjectSettings.count).to eq 0 - - expect(project.settings).to be_a ProjectSettings - - expect(ProjectSettings.count).to eq 1 - end - - it 'returns the associated record when the project has one associated' do - project = create :project, settings: create(:project_settings) - expect(ProjectSettings.count).to eq 1 - - expect(project.settings).to be_a ProjectSettings - - expect(ProjectSettings.count).to eq 1 - end - end end describe 'modules' do @@ -3595,13 +3575,13 @@ describe Project do end end - describe '#toggle_settings!' do + describe '#toggle_ci_cd_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) + project.toggle_ci_cd_settings!(:group_runners_enabled) expect(project.group_runners_enabled).to be true end |