|
1 | 1 | require 'rails_helper' |
2 | 2 |
|
3 | 3 | RSpec.describe "routes for petitions", type: :routes do |
| 4 | + it "routes GET /petitions to petitions#index" do |
| 5 | + expect(get("/petitions")).to route_to(controller: "petitions", action: "index") |
| 6 | + expect(petitions_path).to eq("/petitions") |
| 7 | + end |
| 8 | + |
4 | 9 | it "routes GET /petitions/new to petitions#new" do |
5 | | - expect({:get => "/petitions/new"}).to route_to({:controller => "petitions", :action => "new"}) |
6 | | - expect(new_petition_path).to eq '/petitions/new' |
| 10 | + expect(get("/petitions/new")).to route_to(controller: "petitions", action: "new") |
| 11 | + expect(new_petition_path).to eq("/petitions/new") |
7 | 12 | end |
8 | 13 |
|
9 | 14 | it "routes POST /petitions/new to petitions#create" do |
10 | | - expect({:post => "/petitions/new"}).to route_to({:controller => "petitions", :action => "create"}) |
11 | | - expect(create_petitions_path).to eq('/petitions/new') |
| 15 | + expect(post("/petitions/new")).to route_to(controller: "petitions", action: "create") |
| 16 | + expect(new_petition_path).to eq("/petitions/new") |
| 17 | + end |
| 18 | + |
| 19 | + it "doesn't route POST /petitions" do |
| 20 | + expect(post("/petitions")).not_to be_routable |
| 21 | + end |
| 22 | + |
| 23 | + it "routes GET /petitions/:id to petitions#show" do |
| 24 | + expect(get("/petitions/1")).to route_to(controller: "petitions", action: "show", id: "1") |
| 25 | + expect(petition_path("1")).to eq("/petitions/1") |
| 26 | + end |
| 27 | + |
| 28 | + it "doesn't route GET /petitions/:id/edit" do |
| 29 | + expect(patch("/petitions/1/edit")).not_to be_routable |
| 30 | + end |
| 31 | + |
| 32 | + it "doesn't route PATCH /petitions/:id" do |
| 33 | + expect(patch("/petitions/1")).not_to be_routable |
| 34 | + end |
| 35 | + |
| 36 | + it "doesn't route PUT /petitions/:id" do |
| 37 | + expect(put("/petitions/1")).not_to be_routable |
| 38 | + end |
| 39 | + |
| 40 | + it "doesn't route DELETE /petitions/:id" do |
| 41 | + expect(delete("/petitions/1")).not_to be_routable |
| 42 | + end |
| 43 | + |
| 44 | + it "routes GET /petitions/check to petitions#check" do |
| 45 | + expect(get("/petitions/check")).to route_to(controller: "petitions", action: "check") |
| 46 | + expect(check_petitions_path).to eq("/petitions/check") |
| 47 | + end |
| 48 | + |
| 49 | + it "routes GET /petitions/check_results to petitions#check_results" do |
| 50 | + expect(get("/petitions/check_results")).to route_to(controller: "petitions", action: "check_results") |
| 51 | + expect(check_results_petitions_path).to eq("/petitions/check_results") |
| 52 | + end |
| 53 | + |
| 54 | + it "routes GET /petitions/:id/count to petitions#count" do |
| 55 | + expect(get("/petitions/1/count")).to route_to(controller: "petitions", action: "count", id: "1") |
| 56 | + expect(count_petition_path("1")).to eq("/petitions/1/count") |
| 57 | + end |
| 58 | + |
| 59 | + it "routes GET /petitions/:id/thank-you to petitions#thank_you" do |
| 60 | + expect(get("/petitions/1/thank-you")).to route_to(controller: "petitions", action: "thank_you", id: "1") |
| 61 | + expect(thank_you_petition_path("1")).to eq("/petitions/1/thank-you") |
| 62 | + end |
| 63 | + |
| 64 | + it "routes GET /petitions/:id/gathering-support to petitions#gathering_support" do |
| 65 | + expect(get("/petitions/1/gathering-support")).to route_to(controller: "petitions", action: "gathering_support", id: "1") |
| 66 | + expect(gathering_support_petition_path("1")).to eq("/petitions/1/gathering-support") |
| 67 | + end |
| 68 | + |
| 69 | + it "routes GET /petitions/:id/moderation-info to petitions#moderation_info" do |
| 70 | + expect(get("/petitions/1/moderation-info")).to route_to(controller: "petitions", action: "moderation_info", id: "1") |
| 71 | + expect(moderation_info_petition_path("1")).to eq("/petitions/1/moderation-info") |
12 | 72 | end |
13 | 73 | end |
0 commit comments