diff --git a/app/controllers/api/v3/notices_controller.rb b/app/controllers/api/v3/notices_controller.rb index 74743f4..4789d4e 100644 --- a/app/controllers/api/v3/notices_controller.rb +++ b/app/controllers/api/v3/notices_controller.rb @@ -14,7 +14,7 @@ class Api::V3::NoticesController < ApplicationController if report.valid? if report.should_keep? report.generate_notice! - render json: { + render status: 201, json: { id: report.notice.id, url: app_problem_url( report.app, diff --git a/config/routes.rb b/config/routes.rb index 3164fb5..a0c7a82 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,7 +5,7 @@ Rails.application.routes.draw do match '/notifier_api/v2/notices' => 'notices#create', via: [:get, :post] get '/locate/:id' => 'notices#locate', :as => :locate - resources :notices, only: [:show] + resources :notices, only: [:show] resources :users do member do delete :unlink_github diff --git a/spec/controllers/api/v3/notices_controller_spec.rb b/spec/controllers/api/v3/notices_controller_spec.rb index 60a8885..3c379d2 100644 --- a/spec/controllers/api/v3/notices_controller_spec.rb +++ b/spec/controllers/api/v3/notices_controller_spec.rb @@ -21,6 +21,11 @@ describe Api::V3::NoticesController, type: :controller do ) end + it 'responds with 201 created on success' do + post :create, legit_body, legit_params + expect(response.status).to be(201) + end + it 'responds with 400 when request attributes are not valid' do allow_any_instance_of(AirbrakeApi::V3::NoticeParser). to receive(:report).and_raise(AirbrakeApi::ParamsError) -- libgit2 0.21.2