Files
nairobi/spec/system/sdg_management/targets_spec.rb
Javi Martín c025fef50b Add short titles to SDG targets
Since targets didn't have a title but only a long description, every
form allowing to select targets was pretty much unusable: we either
displayed just the code or the whole description.

Now, with a concise title, it's easier to find and select the desired
target.

The titles have been copied from The Global Goals page [1].

Note we're using the `short_title` I18n key for the `title` method and
the `long_title` I18n key for the `long_title` method. We can't use
`title` as I18n key instead of `short_title` because it would affect
existing translations.

[1] https://www.globalgoals.org/
2021-10-01 16:19:10 +02:00

36 lines
1.2 KiB
Ruby

require "rails_helper"
describe "Targets" do
before do
login_as(create(:administrator).user)
Setting["feature.sdg"] = true
end
describe "Index" do
scenario "Visit the index" do
visit sdg_management_goals_path
click_link "Targets"
expect(page).to have_title "SDG content - Targets"
within("table") { expect(page).to have_content "By 2030, eradicate extreme poverty" }
end
scenario "Show targets grouped by goal and sorted asc by code" do
goal_8 = SDG::Goal[8]
goal_8_target_2 = SDG::Target["8.2"]
goal_8_target_10 = SDG::Target["8.10"]
goal_16 = SDG::Goal[16]
goal_16_target_10 = SDG::Target["16.10"]
goal_16_target_a = SDG::Target["16.A"]
visit sdg_management_targets_path
expect(goal_8.title).to appear_before(goal_8_target_2.long_title)
expect(goal_8_target_2.long_title).to appear_before(goal_8_target_10.long_title)
expect(goal_8_target_10.long_title).to appear_before(goal_16.title)
expect(goal_16.title).to appear_before(goal_16_target_10.long_title)
expect(goal_16_target_10.long_title).to appear_before(goal_16_target_a.long_title)
end
end
end