Commit 0d5290a8 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Use symbols instead strings on controller service result flow

parent 9fbd168f
......@@ -11,10 +11,10 @@ module Projects
opts = params.slice(:issue_references)
result = RelatedIssues::CreateService.new(issue, current_user, opts).execute
if result['status'] == :success
render json: { result: result, issues: issues }, status: result['http_status']
if result[:status] == :success
render json: { result: result, issues: issues }, status: result[:http_status]
else
render json: { result: result }, status: result['http_status']
render json: { result: result }, status: result[:http_status]
end
end
......
......@@ -34,7 +34,7 @@ describe Projects::RelatedIssuesController, type: :controller do
describe 'POST #create' do
let(:service) { double(RelatedIssues::CreateService, execute: service_response) }
let(:list_service) { double(RelatedIssues::ListService, execute: list_service_response) }
let(:service_response) { { 'message' => 'yay', 'status' => :success } }
let(:service_response) { { message: 'yay', status: :success } }
let(:list_service_response) { [{ 'foo' => 'bar' }] }
let(:issue_references) { double }
let(:user_role) { :developer }
......@@ -78,11 +78,11 @@ describe Projects::RelatedIssuesController, type: :controller do
end
context 'when failing service result' do
let(:service_response) { { 'http_status' => 401, 'status' => 'error' } }
let(:service_response) { { http_status: 401, status: 'error' } }
it 'returns failure JSON' do
is_expected.to have_http_status(401)
expect(json_response).to eq('result' => service_response)
expect(json_response).to eq('result' => { 'http_status' => 401, 'status' => 'error' })
end
end
end
......
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