Commit e96401c4 authored by Nick Nguyen's avatar Nick Nguyen Committed by Ash McKenzie

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

parent 9faa870e
...@@ -50,7 +50,7 @@ module DataFields ...@@ -50,7 +50,7 @@ module DataFields
end end
def data_fields_present? def data_fields_present?
data_fields.persisted? data_fields.present?
rescue NotImplementedError rescue NotImplementedError
false false
end end
......
---
title: Fix project service API 500 error
merge_request: 19367
author:
type: fixed
...@@ -74,6 +74,12 @@ describe DataFields do ...@@ -74,6 +74,12 @@ describe DataFields do
expect(service.url_changed?).to be_falsy expect(service.url_changed?).to be_falsy
end end
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 end
context 'when data are stored in data_fields' do context 'when data are stored in data_fields' do
...@@ -92,6 +98,18 @@ describe DataFields do ...@@ -92,6 +98,18 @@ describe DataFields do
end end
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 context 'when data are stored in properties' do
let(:service) { create(:jira_service, :without_properties_callback, properties: properties) } let(:service) { create(:jira_service, :without_properties_callback, properties: properties) }
......
...@@ -102,7 +102,7 @@ describe API::Services do ...@@ -102,7 +102,7 @@ describe API::Services do
expect(json_response['properties'].keys).to match_array(service_instance.api_field_names) expect(json_response['properties'].keys).to match_array(service_instance.api_field_names)
end 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 # deprecated services are not valid for update
initialized_service.update_attribute(:properties, {}) initialized_service.update_attribute(:properties, {})
...@@ -114,7 +114,7 @@ describe API::Services do ...@@ -114,7 +114,7 @@ describe API::Services do
get api("/projects/#{project.id}/services/#{dashed_service}", user) get api("/projects/#{project.id}/services/#{dashed_service}", user)
expect(response).to have_gitlab_http_status(200) 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 end
it "returns error when authenticated but not a project owner" do 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