Skip to content

Commit

Permalink
Change status_api create to use #update to POST
Browse files Browse the repository at this point in the history
because this is the personal preference of our stakeholders.
As we always want to make them happy we do this :)
  • Loading branch information
ChrisBr committed Sep 21, 2018
1 parent 4575ace commit 0619e20
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/api/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -798,10 +798,10 @@ def self.public_or_about_path?(request)
end
controller :checks do
scope :published do
put ':project_name/:repository_name/reports/:report_uuid' => :update
post ':project_name/:repository_name/reports/:report_uuid' => :update
end
scope :requests do
put ':bs_request_number/reports' => :update
post ':bs_request_number/reports' => :update
end
end
end
Expand Down
16 changes: 8 additions & 8 deletions src/api/spec/controllers/status/checks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
login user
end

describe 'PUT update' do
describe 'POST update' do
let(:xml) do
<<~XML
<check>
Expand All @@ -29,7 +29,7 @@
let!(:relationship) { create(:relationship_project_user, user: user, project: project) }

context 'successfully' do
subject! { put :update, body: xml, params: params, format: :xml }
subject! { post :update, body: xml, params: params, format: :xml }

it 'creates create a new check' do
expect(status_report.checks.where(name: 'ci/example: example test', short_description: 'The test failed on Example CI',
Expand All @@ -50,7 +50,7 @@
XML
end

subject! { put :update, body: xml, params: params, format: :xml }
subject! { post :update, body: xml, params: params, format: :xml }

it { is_expected.to have_http_status(:unprocessable_entity) }
it { expect(status_report.checks).to be_empty }
Expand All @@ -63,7 +63,7 @@
login(other_user)
end

subject! { put :update, body: xml, params: params, format: :xml }
subject! { post :update, body: xml, params: params, format: :xml }

it { is_expected.to have_http_status(:forbidden) }
it { expect(status_report.checks).to be_empty }
Expand Down Expand Up @@ -132,15 +132,15 @@
context 'successfully' do
let!(:relationship) { create(:relationship_project_user, user: user, project: project) }

subject! { put :update, body: valid_xml, params: params, format: :xml }
subject! { post :update, body: valid_xml, params: params, format: :xml }

it { is_expected.to have_http_status(:success) }
it { expect(check.reload.state).to eq('success') }
end

context 'without permissions' do
subject! do
put :update, body: valid_xml, params: params, format: :xml
post :update, body: valid_xml, params: params, format: :xml
end

it { is_expected.to have_http_status(:forbidden) }
Expand All @@ -151,7 +151,7 @@
let!(:relationship) { create(:relationship_project_user, user: user, project: project) }
let(:xml_with_empty_field) { '<check><short_description/></check>' }

subject! { put :update, body: xml_with_empty_field, params: params, format: :xml }
subject! { post :update, body: xml_with_empty_field, params: params, format: :xml }

it { is_expected.to have_http_status(:unprocessable_entity) }
it { expect(check.reload.short_description).to eq(check.short_description) }
Expand All @@ -161,7 +161,7 @@
let!(:relationship) { create(:relationship_project_user, user: user, project: project) }
let(:invalid_xml) { '<check><state>not-allowed</state></check>' }

subject! { put :update, body: invalid_xml, params: params, format: :xml }
subject! { post :update, body: invalid_xml, params: params, format: :xml }

it { is_expected.to have_http_status(:unprocessable_entity) }
it { expect(check.reload.state).to eq('pending') }
Expand Down

0 comments on commit 0619e20

Please sign in to comment.