Add SDG page to create local targets

This commit is contained in:
Senén Rodero Rodríguez
2020-11-24 17:06:54 +01:00
parent 3364423698
commit 5611f58909
13 changed files with 168 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ describe "Local Targets", :js do
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
end
scenario "Show local targets grouped by target" do
@@ -30,4 +31,32 @@ describe "Local Targets", :js do
expect(target_2.title).to appear_before(target_2_local_target.title)
end
end
describe "Create" do
scenario "Shows succesful notice when form is fullfilled correctly" do
visit new_sdg_management_local_target_path
target = SDG::Target["1.1"]
select "#{target.code} #{target.title}", from: "Target"
fill_in "Code", with: "1.1.1"
fill_in "Title", with: "Local target title"
fill_in "Description", with: "Local target description"
click_button "Create local target"
expect(page).to have_content("Local target created successfully")
expect(page).to have_content("1.1.1")
end
scenario "Shows form errors when not valid" do
visit new_sdg_management_local_target_path
target = SDG::Target["2.3"]
code_and_title = "#{target.code} #{target.title}"
select code_and_title, from: "Target"
click_button "Create local target"
expect(page).to have_content("errors prevented this local target from being saved.")
expect(page).to have_select("Target", selected: code_and_title)
end
end
end