Commit 15955f4b authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'pl-service-response-success-http-status' into 'master'

Set default http status of a successful ServiceResponse

See merge request !16608
parents 350bd6dd 28158f95
Pipeline #82403904 passed with stages
in 43 minutes and 19 seconds
# frozen_string_literal: true
class ServiceResponse
def self.success(message: nil, payload: {})
new(status: :success, message: message, payload: payload)
def self.success(message: nil, payload: {}, http_status: :ok)
new(status: :success, message: message, payload: payload, http_status: http_status)
def self.error(message:, payload: {}, http_status: nil)
......@@ -23,6 +23,20 @@ describe ServiceResponse do
expect(response).to be_success
expect(response.payload).to eq(good: 'orange')
it 'creates a successful response with default HTTP status' do
response = described_class.success
expect(response).to be_success
expect(response.http_status).to eq(:ok)
it 'creates a successful response with custom HTTP status' do
response = described_class.success(http_status: 204)
expect(response).to be_success
expect(response.http_status).to eq(204)
describe '.error' 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