Commit 1031f6c9d3a9d9a087c5f591337debf3f976f0c3
1 parent
b540b519
Exists in
master
Fixes #967 return 201 on create notice (json api)
Showing
3 changed files
with
7 additions
and
2 deletions
Show diff stats
app/controllers/api/v3/notices_controller.rb
@@ -14,7 +14,7 @@ class Api::V3::NoticesController < ApplicationController | @@ -14,7 +14,7 @@ class Api::V3::NoticesController < ApplicationController | ||
14 | if report.valid? | 14 | if report.valid? |
15 | if report.should_keep? | 15 | if report.should_keep? |
16 | report.generate_notice! | 16 | report.generate_notice! |
17 | - render json: { | 17 | + render status: 201, json: { |
18 | id: report.notice.id, | 18 | id: report.notice.id, |
19 | url: app_problem_url( | 19 | url: app_problem_url( |
20 | report.app, | 20 | report.app, |
config/routes.rb
@@ -5,7 +5,7 @@ Rails.application.routes.draw do | @@ -5,7 +5,7 @@ Rails.application.routes.draw do | ||
5 | match '/notifier_api/v2/notices' => 'notices#create', via: [:get, :post] | 5 | match '/notifier_api/v2/notices' => 'notices#create', via: [:get, :post] |
6 | get '/locate/:id' => 'notices#locate', :as => :locate | 6 | get '/locate/:id' => 'notices#locate', :as => :locate |
7 | 7 | ||
8 | - resources :notices, only: [:show] | 8 | + resources :notices, only: [:show] |
9 | resources :users do | 9 | resources :users do |
10 | member do | 10 | member do |
11 | delete :unlink_github | 11 | delete :unlink_github |
spec/controllers/api/v3/notices_controller_spec.rb
@@ -21,6 +21,11 @@ describe Api::V3::NoticesController, type: :controller do | @@ -21,6 +21,11 @@ describe Api::V3::NoticesController, type: :controller do | ||
21 | ) | 21 | ) |
22 | end | 22 | end |
23 | 23 | ||
24 | + it 'responds with 201 created on success' do | ||
25 | + post :create, legit_body, legit_params | ||
26 | + expect(response.status).to be(201) | ||
27 | + end | ||
28 | + | ||
24 | it 'responds with 400 when request attributes are not valid' do | 29 | it 'responds with 400 when request attributes are not valid' do |
25 | allow_any_instance_of(AirbrakeApi::V3::NoticeParser). | 30 | allow_any_instance_of(AirbrakeApi::V3::NoticeParser). |
26 | to receive(:report).and_raise(AirbrakeApi::ParamsError) | 31 | to receive(:report).and_raise(AirbrakeApi::ParamsError) |