Add basic SDG Management content section

Note using `params[:relatable_type].classify` is recognized as a
security risk by some tools. However, it's a false positive, since we've
added constraints to the URL so that paramenter can only have the values
we trust.
This commit is contained in:
Javi Martín
2020-11-23 20:51:51 +01:00
parent 5590ecaaa6
commit ed51c5dcd3
15 changed files with 233 additions and 3 deletions

View File

@@ -0,0 +1,32 @@
require "rails_helper"
describe "SDG Management routes" do
it "maps routes for relatable classes" do
expect(get("/sdg_management/proposals")).to route_to(
controller: "sdg_management/relations",
action: "index",
relatable_type: "proposals"
)
end
it "admits named routes" do
expect(get(sdg_management_polls_path)).to route_to(
controller: "sdg_management/relations",
action: "index",
relatable_type: "polls"
)
end
it "routes relatable types containing a slash" do
expect(url_for(
controller: "sdg_management/relations",
action: "index",
relatable_type: "legislation/processes",
only_path: true
)).to eq "/sdg_management/legislation/processes"
end
it "does not accept non-relatable classes" do
expect(get("/sdg_management/tags")).not_to be_routable
end
end