Extract repeating code to a method
This commit is contained in:
@@ -43,4 +43,14 @@ module CommonActions
|
|||||||
allow_any_instance_of(Officing::BaseController).
|
allow_any_instance_of(Officing::BaseController).
|
||||||
to receive(:current_booth).and_return(booth)
|
to receive(:current_booth).and_return(booth)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def click_sdg_goal(code)
|
||||||
|
find("li[data-code='#{code}']").click
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_sdg_goal_or_target_tag(code)
|
||||||
|
within "span[data-val='#{code}']" do
|
||||||
|
click_button "Remove"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -218,13 +218,8 @@ describe "SDG Relations", :js do
|
|||||||
|
|
||||||
visit sdg_management_edit_legislation_process_path(process)
|
visit sdg_management_edit_legislation_process_path(process)
|
||||||
|
|
||||||
within "span[data-val='2']" do
|
remove_sdg_goal_or_target_tag(2)
|
||||||
click_button "Remove"
|
remove_sdg_goal_or_target_tag(3.3)
|
||||||
end
|
|
||||||
|
|
||||||
within "span[data-val='3.3']" do
|
|
||||||
click_button "Remove"
|
|
||||||
end
|
|
||||||
|
|
||||||
click_button "Update Process"
|
click_button "Update Process"
|
||||||
|
|
||||||
@@ -293,7 +288,7 @@ describe "SDG Relations", :js do
|
|||||||
process = create(:legislation_process, title: "SDG process")
|
process = create(:legislation_process, title: "SDG process")
|
||||||
|
|
||||||
visit sdg_management_edit_legislation_process_path(process)
|
visit sdg_management_edit_legislation_process_path(process)
|
||||||
find("li[data-code='1']").click
|
click_sdg_goal(1)
|
||||||
click_button "Update Process"
|
click_button "Update Process"
|
||||||
click_link "Marked as reviewed"
|
click_link "Marked as reviewed"
|
||||||
|
|
||||||
@@ -307,7 +302,7 @@ describe "SDG Relations", :js do
|
|||||||
process.sdg_goals = [SDG::Goal[1], SDG::Goal[2]]
|
process.sdg_goals = [SDG::Goal[1], SDG::Goal[2]]
|
||||||
|
|
||||||
visit sdg_management_edit_legislation_process_path(process)
|
visit sdg_management_edit_legislation_process_path(process)
|
||||||
find("li[data-code='1']").click
|
click_sdg_goal(1)
|
||||||
click_button "Update Process"
|
click_button "Update Process"
|
||||||
click_link "Marked as reviewed"
|
click_link "Marked as reviewed"
|
||||||
|
|
||||||
@@ -322,7 +317,7 @@ describe "SDG Relations", :js do
|
|||||||
process = create(:legislation_process, title: "SDG process")
|
process = create(:legislation_process, title: "SDG process")
|
||||||
|
|
||||||
visit sdg_management_edit_legislation_process_path(process)
|
visit sdg_management_edit_legislation_process_path(process)
|
||||||
find("li[data-code='1']").click
|
click_sdg_goal(1)
|
||||||
|
|
||||||
expect(find("li[data-code='1']")["aria-checked"]).to eq "true"
|
expect(find("li[data-code='1']")["aria-checked"]).to eq "true"
|
||||||
end
|
end
|
||||||
@@ -333,15 +328,11 @@ describe "SDG Relations", :js do
|
|||||||
process.sdg_targets = [SDG::Target[1.1]]
|
process.sdg_targets = [SDG::Target[1.1]]
|
||||||
|
|
||||||
visit sdg_management_edit_legislation_process_path(process)
|
visit sdg_management_edit_legislation_process_path(process)
|
||||||
within "span[data-val='1']" do
|
remove_sdg_goal_or_target_tag(1)
|
||||||
click_button "Remove"
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(find("li[data-code='1']")["aria-checked"]).to eq "true"
|
expect(find("li[data-code='1']")["aria-checked"]).to eq "true"
|
||||||
|
|
||||||
within "span[data-val='1.1']" do
|
remove_sdg_goal_or_target_tag(1.1)
|
||||||
click_button "Remove"
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(find("li[data-code='1']")["aria-checked"]).to eq "false"
|
expect(find("li[data-code='1']")["aria-checked"]).to eq "false"
|
||||||
end
|
end
|
||||||
@@ -352,7 +343,7 @@ describe "SDG Relations", :js do
|
|||||||
process = create(:legislation_process, title: "SDG process")
|
process = create(:legislation_process, title: "SDG process")
|
||||||
|
|
||||||
visit sdg_management_edit_legislation_process_path(process)
|
visit sdg_management_edit_legislation_process_path(process)
|
||||||
find("li[data-code='1']").click
|
click_sdg_goal(1)
|
||||||
|
|
||||||
within(".help-section") { expect(page).to have_content "No Poverty" }
|
within(".help-section") { expect(page).to have_content "No Poverty" }
|
||||||
end
|
end
|
||||||
@@ -365,9 +356,7 @@ describe "SDG Relations", :js do
|
|||||||
|
|
||||||
within(".help-section") { expect(page).to have_content "No Poverty" }
|
within(".help-section") { expect(page).to have_content "No Poverty" }
|
||||||
|
|
||||||
within "span[data-val='1']" do
|
remove_sdg_goal_or_target_tag(1)
|
||||||
click_button "Remove"
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(page).not_to have_content "No Poverty"
|
expect(page).not_to have_content "No Poverty"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user