1
0

webhooks_controller_spec.rb 1.3 KB

1234567891011121314151617181920212223
  1. require 'rails_helper'
  2. describe "routing for web requests", :type => :routing do
  3. it "routes to handle_request" do
  4. resulting_params = { :user_id => "6", :agent_id => "2", :secret => "foobar" }
  5. expect(get("/users/6/web_requests/2/foobar")).to route_to("web_requests#handle_request", resulting_params)
  6. expect(post("/users/6/web_requests/2/foobar")).to route_to("web_requests#handle_request", resulting_params)
  7. expect(put("/users/6/web_requests/2/foobar")).to route_to("web_requests#handle_request", resulting_params)
  8. expect(delete("/users/6/web_requests/2/foobar")).to route_to("web_requests#handle_request", resulting_params)
  9. end
  10. it "supports the legacy /webhooks/ route" do
  11. expect(post("/users/6/webhooks/2/foobar")).to route_to("web_requests#handle_request", :user_id => "6", :agent_id => "2", :secret => "foobar")
  12. end
  13. it "routes with format" do
  14. expect(get("/users/6/web_requests/2/foobar.json")).to route_to("web_requests#handle_request",
  15. { :user_id => "6", :agent_id => "2", :secret => "foobar", :format => "json" })
  16. expect(get("/users/6/web_requests/2/foobar.atom")).to route_to("web_requests#handle_request",
  17. { :user_id => "6", :agent_id => "2", :secret => "foobar", :format => "atom" })
  18. end
  19. end