Add SDG page to update local targets

This commit is contained in:
Senén Rodero Rodríguez
2020-11-25 10:59:55 +01:00
parent eb0f13018c
commit a211937744
9 changed files with 64 additions and 4 deletions

View File

@@ -14,8 +14,10 @@ describe "Local Targets", :js do
click_link "Local Targets"
expect(page).to have_title "SDG content - Local Targets"
within("table") { expect(page).to have_content "Affordable food for everyone" }
expect(page).to have_link "Create local target", href: new_sdg_management_local_target_path
within("table tr", text: "Affordable food") do
expect(page).to have_link "Edit"
end
expect(page).to have_link "Create local target"
end
scenario "Show local targets grouped by target" do
@@ -59,4 +61,27 @@ describe "Local Targets", :js do
expect(page).to have_select("Target", selected: code_and_title)
end
end
describe "Update" do
let!(:local_target) { create(:sdg_local_target, code: "1.1.1") }
scenario "Shows succesful notice when form is fullfilled correctly" do
visit edit_sdg_management_local_target_path(local_target)
fill_in "Title", with: "Local target title update"
click_button "Update local target"
expect(page).to have_content("Local target updated successfully")
expect(page).to have_content("Local target title update")
end
scenario "Shows form errors when changes are not valid" do
visit edit_sdg_management_local_target_path(local_target)
fill_in "Title", with: ""
click_button "Update local target"
expect(page).to have_content("1 error prevented this local target from being saved.")
end
end
end