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