Commit 4fb5926f authored by Toon Claes's avatar Toon Claes

Rename project.settings to project.project_setting

Singular is more appropriate and prefixing with project again makes it
more meaningful.
parent e2eb9487
......@@ -190,7 +190,7 @@ class Project < ApplicationRecord
has_one :error_tracking_setting, inverse_of: :project, class_name: 'ErrorTracking::ProjectErrorTrackingSetting'
has_one :metrics_setting, inverse_of: :project, class_name: 'ProjectMetricsSetting'
has_one :grafana_integration, inverse_of: :project
has_one :settings, ->(project) { where_or_create_by(project: project) }, inverse_of: :project, class_name: 'ProjectSettings'
has_one :project_setting, ->(project) { where_or_create_by(project: project) }, inverse_of: :project
# Merge Requests for target project should be removed with it
has_many :merge_requests, foreign_key: 'target_project_id', inverse_of: :target_project
......
# frozen_string_literal: true
class ProjectSettings < ApplicationRecord
belongs_to :project, inverse_of: :settings
class ProjectSetting < ApplicationRecord
belongs_to :project, inverse_of: :project_setting
self.primary_key = :project_id
......
......@@ -90,7 +90,7 @@ module Projects
end
@project.track_project_repository
@project.create_settings
@project.create_project_setting unless @project.project_setting
event_service.create_project(@project, current_user)
system_hook_service.execute_hooks_for(@project, :create)
......
......@@ -452,6 +452,7 @@ project:
- package_files
- tracing_setting
- alerting_setting
- project_setting
- webide_pipelines
- reviews
- incident_management_setting
......
......@@ -2,6 +2,6 @@
require 'spec_helper'
describe ProjectSettings, type: :model do
describe ProjectSetting, type: :model do
it { is_expected.to belong_to(:project) }
end
......@@ -69,7 +69,7 @@ describe Project do
it { is_expected.to have_one(:forked_from_project).through(:fork_network_member) }
it { is_expected.to have_one(:auto_devops).class_name('ProjectAutoDevops') }
it { is_expected.to have_one(:error_tracking_setting).class_name('ErrorTracking::ProjectErrorTrackingSetting') }
it { is_expected.to have_one(:settings).class_name('ProjectSettings') }
it { is_expected.to have_one(:project_setting) }
it { is_expected.to have_many(:commit_statuses) }
it { is_expected.to have_many(:ci_pipelines) }
it { is_expected.to have_many(:builds) }
......@@ -157,10 +157,9 @@ describe Project do
expect(project.pages_metadatum).to be_persisted
end
it 'creates settings if needed when accessed' do
expect do
expect(project.settings).to be_persisted
end.to change { ProjectSettings.count }.by(1)
it 'automatically creates a project setting row' do
expect(project.project_setting).to be_an_instance_of(ProjectSetting)
expect(project.project_setting).to be_persisted
end
end
......
......@@ -47,7 +47,7 @@ describe Projects::CreateService, '#execute' do
it 'creates associated project settings' do
project = create_project(user, opts)
expect(project.settings).to be_persisted
expect(project.project_setting).to be_persisted
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