diff options
author | Adam Niedzielski <adamsunday@gmail.com> | 2016-11-16 12:46:07 +0100 |
---|---|---|
committer | Adam Niedzielski <adamsunday@gmail.com> | 2016-11-16 12:46:07 +0100 |
commit | ef3be00a0297dfa31002616df6ee49a0e2132cb7 (patch) | |
tree | 2316894b87a84db4ecb8ddcd96eba046aeb2a47b /spec/models | |
parent | 0f48abf24b0ba34aebfc1d0d52e9e22648b7da1a (diff) | |
download | gitlab-ce-ef3be00a0297dfa31002616df6ee49a0e2132cb7.tar.gz |
Defer saving project services to the database if there are no user changesadam-build-missing-services-when-necessary
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/project_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/service_spec.rb | 10 |
2 files changed, 3 insertions, 13 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 0810d06b50f..642f1edfe3f 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -496,9 +496,6 @@ describe Project, models: true do end it 'returns nil and does not query services when there is no external issue tracker' do - project.build_missing_services - project.reload - expect(project).not_to receive(:services) expect(project.external_issue_tracker).to eq(nil) @@ -506,9 +503,6 @@ describe Project, models: true do it 'retrieves external_issue_tracker querying services and cache it when there is external issue tracker' do ext_project.reload # Factory returns a project with changed attributes - ext_project.build_missing_services - ext_project.reload - expect(ext_project).to receive(:services).once.and_call_original 2.times { expect(ext_project.external_issue_tracker).to be_a_kind_of(RedmineService) } diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index 43937a54b2c..b1615a95004 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -53,7 +53,7 @@ describe Service, models: true do describe "Template" do describe "for pushover service" do - let(:service_template) do + let!(:service_template) do PushoverService.create( template: true, properties: { @@ -66,13 +66,9 @@ describe Service, models: true do let(:project) { create(:project) } describe 'is prefilled for projects pushover service' do - before do - service_template - project.build_missing_services - end - it "has all fields prefilled" do - service = project.pushover_service + service = project.find_or_initialize_service('pushover') + expect(service.template).to eq(false) expect(service.device).to eq('MyDevice') expect(service.sound).to eq('mic') |