diff options
author | Robert Speicher <robert@gitlab.com> | 2016-10-04 08:51:24 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-10-04 08:51:24 +0000 |
commit | 77de91e1b02e48cd15a0bced8f5b92f272b82e3a (patch) | |
tree | 28cb7aec7bdd60bc7d4636ff6b6ba82204e7bbaa | |
parent | ccd89ec965aa26812b4e48aabc15ca1594914b66 (diff) | |
parent | 912d7f7b68d5c75d801299a8c9363a257030e142 (diff) | |
download | gitlab-ce-77de91e1b02e48cd15a0bced8f5b92f272b82e3a.tar.gz |
Merge branch 'fix/import-service-issues' into 'master'
Fix issues importing services via Import/Export
Prevents errors when initialising services that do not have any properties set yet - case that could happen when importing projects.
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/22891
See merge request !6667
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/models/service.rb | 1 | ||||
-rw-r--r-- | spec/models/service_spec.rb | 17 |
3 files changed, 19 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG index 57f6034b744..bfc312ca19c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -46,6 +46,7 @@ v 8.13.0 (unreleased) - Add Container Registry on/off status to Admin Area !6638 (the-undefined) v 8.12.4 (unreleased) + - Fix issues importing services via Import/Export - Fix "Copy to clipboard" tooltip to say "Copied!" when clipboard button is clicked. (lukehowell) v 8.12.3 diff --git a/app/models/service.rb b/app/models/service.rb index 80de7175565..66c804f2b06 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -136,6 +136,7 @@ class Service < ActiveRecord::Base end def #{arg}=(value) + self.properties ||= {} updated_properties['#{arg}'] = #{arg} unless #{arg}_changed? self.properties['#{arg}'] = value end diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index 05056a4bb47..ed1bc9271ae 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -203,6 +203,23 @@ describe Service, models: true do end end + describe 'initialize service with no properties' do + let(:service) do + GitlabIssueTrackerService.create( + project: create(:project), + title: 'random title' + ) + end + + it 'does not raise error' do + expect { service }.not_to raise_error + end + + it 'creates the properties' do + expect(service.properties).to eq({ "title" => "random title" }) + end + end + describe "callbacks" do let(:project) { create(:project) } let!(:service) do |