-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using new_petition_path instead of create_petitions_path more accurately reflects where we're POSTing too. Also expand the routing tests to cover other routes and ensure that we don't accidentally start accepting RESTful routes that modify petitions.
- Loading branch information
Showing
3 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<%= form_for @stage_manager.stage_object, :url => create_petitions_path do |f| %> | ||
<%= form_for @stage_manager.stage_object, url: new_petition_path do |f| %> | ||
<%= render_petition_form @stage_manager, f %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,73 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe "routes for petitions", type: :routes do | ||
it "routes GET /petitions to petitions#index" do | ||
expect(get("/petitions")).to route_to(controller: "petitions", action: "index") | ||
expect(petitions_path).to eq("/petitions") | ||
end | ||
|
||
it "routes GET /petitions/new to petitions#new" do | ||
expect({:get => "/petitions/new"}).to route_to({:controller => "petitions", :action => "new"}) | ||
expect(new_petition_path).to eq '/petitions/new' | ||
expect(get("/petitions/new")).to route_to(controller: "petitions", action: "new") | ||
expect(new_petition_path).to eq("/petitions/new") | ||
end | ||
|
||
it "routes POST /petitions/new to petitions#create" do | ||
expect({:post => "/petitions/new"}).to route_to({:controller => "petitions", :action => "create"}) | ||
expect(create_petitions_path).to eq('/petitions/new') | ||
expect(post("/petitions/new")).to route_to(controller: "petitions", action: "create") | ||
expect(new_petition_path).to eq("/petitions/new") | ||
end | ||
|
||
it "doesn't route POST /petitions" do | ||
expect(post("/petitions")).not_to be_routable | ||
end | ||
|
||
it "routes GET /petitions/:id to petitions#show" do | ||
expect(get("/petitions/1")).to route_to(controller: "petitions", action: "show", id: "1") | ||
expect(petition_path("1")).to eq("/petitions/1") | ||
end | ||
|
||
it "doesn't route GET /petitions/:id/edit" do | ||
expect(patch("/petitions/1/edit")).not_to be_routable | ||
end | ||
|
||
it "doesn't route PATCH /petitions/:id" do | ||
expect(patch("/petitions/1")).not_to be_routable | ||
end | ||
|
||
it "doesn't route PUT /petitions/:id" do | ||
expect(put("/petitions/1")).not_to be_routable | ||
end | ||
|
||
it "doesn't route DELETE /petitions/:id" do | ||
expect(delete("/petitions/1")).not_to be_routable | ||
end | ||
|
||
it "routes GET /petitions/check to petitions#check" do | ||
expect(get("/petitions/check")).to route_to(controller: "petitions", action: "check") | ||
expect(check_petitions_path).to eq("/petitions/check") | ||
end | ||
|
||
it "routes GET /petitions/check_results to petitions#check_results" do | ||
expect(get("/petitions/check_results")).to route_to(controller: "petitions", action: "check_results") | ||
expect(check_results_petitions_path).to eq("/petitions/check_results") | ||
end | ||
|
||
it "routes GET /petitions/:id/count to petitions#count" do | ||
expect(get("/petitions/1/count")).to route_to(controller: "petitions", action: "count", id: "1") | ||
expect(count_petition_path("1")).to eq("/petitions/1/count") | ||
end | ||
|
||
it "routes GET /petitions/:id/thank-you to petitions#thank_you" do | ||
expect(get("/petitions/1/thank-you")).to route_to(controller: "petitions", action: "thank_you", id: "1") | ||
expect(thank_you_petition_path("1")).to eq("/petitions/1/thank-you") | ||
end | ||
|
||
it "routes GET /petitions/:id/gathering-support to petitions#gathering_support" do | ||
expect(get("/petitions/1/gathering-support")).to route_to(controller: "petitions", action: "gathering_support", id: "1") | ||
expect(gathering_support_petition_path("1")).to eq("/petitions/1/gathering-support") | ||
end | ||
|
||
it "routes GET /petitions/:id/moderation-info to petitions#moderation_info" do | ||
expect(get("/petitions/1/moderation-info")).to route_to(controller: "petitions", action: "moderation_info", id: "1") | ||
expect(moderation_info_petition_path("1")).to eq("/petitions/1/moderation-info") | ||
end | ||
end |