Commit 77de91e1 authored by Robert Speicher's avatar Robert Speicher

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
parents ccd89ec9 912d7f7b
......@@ -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
......
......@@ -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
......
......@@ -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
......
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