Commit 561dd4d7926bc06f29678d4d0c440346d8509185

Authored by Arthur Nogueira Neves
2 parents fd6f3c06 1ac99bcd
Exists in master and in 1 other branch production

Merge pull request #617 from soberstadt/fix-api-route

fix the api route to work with both get and post
config/routes.rb
... ... @@ -3,7 +3,7 @@ Errbit::Application.routes.draw do
3 3 devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
4 4  
5 5 # Hoptoad Notifier Routes
6   - post '/notifier_api/v2/notices' => 'notices#create'
  6 + match '/notifier_api/v2/notices' => 'notices#create', via: [:get, :post]
7 7 get '/locate/:id' => 'notices#locate', :as => :locate
8 8 post '/deploys.txt' => 'deploys#create'
9 9  
... ...
spec/requests/notices_controller_spec.rb
... ... @@ -45,6 +45,19 @@ describe "Notices management" do
45 45  
46 46 end
47 47  
  48 + # the JS notifier allows for both GET and POST requests
  49 + context "with GET request" do
  50 + let(:xml) { Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read }
  51 + it 'save a new notice' do
  52 + expect {
  53 + get '/notifier_api/v2/notices', :data => xml
  54 + expect(response).to be_success
  55 + }.to change {
  56 + errbit_app.problems.count
  57 + }.by(1)
  58 + end
  59 + end
  60 +
48 61 end
49 62  
50 63 end
... ...