Commit 0cb71896 authored by Ash McKenzie's avatar Ash McKenzie

Merge branch...

Merge branch '34770-error-500-for-api-v4-projects-id-services-jira-nomethoderror-undefined-method-slice-for-nil' into 'master'

Resolve "Error 500 for /api/v4/projects/ID/services/jira"

Closes #34770

See merge request gitlab-org/gitlab!19367
parents 9faa870e e96401c4
......@@ -50,7 +50,7 @@ module DataFields
end
def data_fields_present?
data_fields.persisted?
data_fields.present?
rescue NotImplementedError
false
end
......
---
title: Fix project service API 500 error
merge_request: 19367
author:
type: fixed
......@@ -74,6 +74,12 @@ describe DataFields do
expect(service.url_changed?).to be_falsy
end
end
describe 'data_fields_present?' do
it 'returns true from the issue tracker service' do
expect(service.data_fields_present?).to be true
end
end
end
context 'when data are stored in data_fields' do
......@@ -92,6 +98,18 @@ describe DataFields do
end
end
context 'when service and data_fields are not persisted' do
let(:service) do
JiraService.new
end
describe 'data_fields_present?' do
it 'returns true' do
expect(service.data_fields_present?).to be true
end
end
end
context 'when data are stored in properties' do
let(:service) { create(:jira_service, :without_properties_callback, properties: properties) }
......
......@@ -102,7 +102,7 @@ describe API::Services do
expect(json_response['properties'].keys).to match_array(service_instance.api_field_names)
end
it "returns empty hash if properties and data fields are empty" do
it "returns empty hash or nil values if properties and data fields are empty" do
# deprecated services are not valid for update
initialized_service.update_attribute(:properties, {})
......@@ -114,7 +114,7 @@ describe API::Services do
get api("/projects/#{project.id}/services/#{dashed_service}", user)
expect(response).to have_gitlab_http_status(200)
expect(json_response['properties'].keys).to be_empty
expect(json_response['properties'].values.compact).to be_empty
end
it "returns error when authenticated but not a project owner" 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