Add empty SDG goal show page
Note we're using the code instead of the ID to get the goal in the URL. IMHO this is what most people would expect; visiting a URL with a "7" takes you to SDG number 7, and not to the one with "7" as a database ID. In order to avoid tests (either automated tests or manual tests) passing by coincidence due to the goal ID and the goal code being the same, I'm shuffling the codes before entering them in the databse. I've tried using `resolve` in the routes so the code is automatically taken into account, but it doesn't work since `resolve` cannot be used inside a namespace, and here we're within the `sdg` namespace.
This commit is contained in:
19
spec/routing/sdg_routes_spec.rb
Normal file
19
spec/routing/sdg_routes_spec.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "SDG routes" do
|
||||
it "maps goals to their code" do
|
||||
expect(get("/sdg/goals/1")).to route_to(
|
||||
controller: "sdg/goals",
|
||||
action: "show",
|
||||
code: "1"
|
||||
)
|
||||
end
|
||||
|
||||
it "requires using the code instead of the ID" do
|
||||
expect(get(sdg_goal_path(SDG::Goal[2].code))).to route_to(
|
||||
controller: "sdg/goals",
|
||||
action: "show",
|
||||
code: "2"
|
||||
)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user