Commit 351025ec authored by Robert Speicher's avatar Robert Speicher Committed by Rémy Coutable

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
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 1803bc26
......@@ -8,6 +8,7 @@ v 8.12.4 (unreleased)
- Fix type mismatch bug when closing Jira issue. !6619
- Fix lint-doc error. !6623
- Skip wiki creation when GitHub project has wiki enabled. !6665
- Fix issues importing services via Import/Export. !6667
- Restrict failed login attempts for users with 2FA enabled. !6668
- Fix failed project deletion when feature visibility set to private. !6688
- Prevent claiming associated model IDs via import.
......
......@@ -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