Commit 831ab2f8ac9359dd1167c01cc52699956a36440a
1 parent
7328898f
Exists in
master
and in
1 other branch
Add an endpoint for /notifier_api/v2/notices
Showing
3 changed files
with
37 additions
and
56 deletions
Show diff stats
config/routes.rb
1 | 1 | Hypnotoad::Application.routes.draw do |
2 | - # The priority is based upon order of creation: | |
3 | - # first created -> highest priority. | |
4 | - | |
5 | - # Sample of regular route: | |
6 | - # match 'products/:id' => 'catalog#view' | |
7 | - # Keep in mind you can assign values other than :controller and :action | |
8 | - | |
9 | - # Sample of named route: | |
10 | - # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase | |
11 | - # This route can be invoked with purchase_url(:id => product.id) | |
12 | - | |
13 | - # Sample resource route (maps HTTP verbs to controller actions automatically): | |
14 | - # resources :products | |
15 | - | |
16 | - # Sample resource route with options: | |
17 | - # resources :products do | |
18 | - # member do | |
19 | - # get :short | |
20 | - # post :toggle | |
21 | - # end | |
22 | - # | |
23 | - # collection do | |
24 | - # get :sold | |
25 | - # end | |
26 | - # end | |
27 | - | |
28 | - # Sample resource route with sub-resources: | |
29 | - # resources :products do | |
30 | - # resources :comments, :sales | |
31 | - # resource :seller | |
32 | - # end | |
33 | - | |
34 | - # Sample resource route with more complex sub-resources | |
35 | - # resources :products do | |
36 | - # resources :comments | |
37 | - # resources :sales do | |
38 | - # get :recent, :on => :collection | |
39 | - # end | |
40 | - # end | |
41 | - | |
42 | - # Sample resource route within a namespace: | |
43 | - # namespace :admin do | |
44 | - # # Directs /admin/products/* to Admin::ProductsController | |
45 | - # # (app/controllers/admin/products_controller.rb) | |
46 | - # resources :products | |
47 | - # end | |
48 | - | |
49 | - # You can have the root of your site routed with "root" | |
50 | - # just remember to delete public/index.html. | |
51 | - # root :to => "welcome#index" | |
52 | - | |
53 | - # See how all your routes lay out with "rake routes" | |
54 | - | |
55 | - # This is a legacy wild controller route that's not recommended for RESTful applications. | |
56 | - # Note: This route will make all actions in every controller accessible via GET requests. | |
57 | - # match ':controller(/:action(/:id(.:format)))' | |
2 | + | |
3 | + # Hoptoad Notifier Routes | |
4 | + match '/notifier_api/v2/notices' => 'notices#create' | |
5 | + # match '/deploys.txt' => 'deploys#create' | |
6 | + | |
7 | + resources :notices | |
8 | + | |
58 | 9 | end | ... | ... |
... | ... | @@ -0,0 +1,21 @@ |
1 | +require 'spec_helper' | |
2 | + | |
3 | +describe NoticesController do | |
4 | + | |
5 | + context 'POST[XML] notices#create' do | |
6 | + before do | |
7 | + @xml = Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read | |
8 | + @notice = Notice.from_xml(@xml) | |
9 | + | |
10 | + request.env['Content-type'] = 'text/xml' | |
11 | + request.env['Accept'] = 'text/xml, application/xml' | |
12 | + request.should_receive(:raw_post).and_return(@xml) | |
13 | + end | |
14 | + | |
15 | + it "generates a notice from the xml" do | |
16 | + Notice.should_receive(:from_xml).with(@xml).and_return(@notice) | |
17 | + post :create | |
18 | + end | |
19 | + end | |
20 | + | |
21 | +end | ... | ... |