Remove unused variables following their parent
There's a very common pattern in our test, where the setup only has two lines: variable = create(:something) unused_variable = create(:something_else, something: variable) In this case, since there's a blank line below these ones and then we'll get to the body of the test, and the second variable is going to be created based on the first variable, we can remove the useless assignment and the readability is still OK. Another option we almost unanimously discarded was: variable = create(:something) _unused_variable = create(:something_else, something: variable) We don't use it anywhere else, either. One more option we considered but found a bit too much for simple tests: variable = create(:something) do |something| create(:something_else, something: variable) end Then of course we could move the setup to `let` and `before` blocks, but the tests could get over-structured really quickly.
This commit is contained in:
@@ -69,7 +69,7 @@ describe "Admin legislation draft versions" do
|
|||||||
context "Update" do
|
context "Update" do
|
||||||
scenario "Valid legislation draft version", :js do
|
scenario "Valid legislation draft version", :js do
|
||||||
process = create(:legislation_process, title: "An example legislation process")
|
process = create(:legislation_process, title: "An example legislation process")
|
||||||
draft_version = create(:legislation_draft_version, title: "Version 1", process: process)
|
create(:legislation_draft_version, title: "Version 1", process: process)
|
||||||
|
|
||||||
visit admin_root_path
|
visit admin_root_path
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ describe "Answers" do
|
|||||||
|
|
||||||
scenario "Create second answer and place after the first one" do
|
scenario "Create second answer and place after the first one" do
|
||||||
question = create(:poll_question)
|
question = create(:poll_question)
|
||||||
answer = create(:poll_question_answer, title: "First", question: question, given_order: 1)
|
create(:poll_question_answer, title: "First", question: question, given_order: 1)
|
||||||
|
|
||||||
visit admin_question_path(question)
|
visit admin_question_path(question)
|
||||||
click_link "Add answer"
|
click_link "Add answer"
|
||||||
|
|||||||
@@ -291,8 +291,7 @@ describe "Executions" do
|
|||||||
|
|
||||||
scenario "Milestone not yet published" do
|
scenario "Milestone not yet published" do
|
||||||
status = create(:milestone_status)
|
status = create(:milestone_status)
|
||||||
unpublished_milestone = create(:milestone, milestoneable: investment1,
|
create(:milestone, milestoneable: investment1, status: status, publication_date: Date.tomorrow)
|
||||||
status: status, publication_date: Date.tomorrow)
|
|
||||||
|
|
||||||
visit budget_executions_path(budget, status: status.id)
|
visit budget_executions_path(budget, status: status.id)
|
||||||
|
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ describe "Proposal's dashboard" do
|
|||||||
|
|
||||||
scenario "Dashboard progress can unexecute proposed action" do
|
scenario "Dashboard progress can unexecute proposed action" do
|
||||||
action = create(:dashboard_action, :proposed_action, :active)
|
action = create(:dashboard_action, :proposed_action, :active)
|
||||||
executed_action = create(:dashboard_executed_action, proposal: proposal, action: action)
|
create(:dashboard_executed_action, proposal: proposal, action: action)
|
||||||
|
|
||||||
visit progress_proposal_dashboard_path(proposal)
|
visit progress_proposal_dashboard_path(proposal)
|
||||||
expect(page).to have_content(action.title)
|
expect(page).to have_content(action.title)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ describe "Notifications" do
|
|||||||
|
|
||||||
scenario "View single notification" do
|
scenario "View single notification" do
|
||||||
proposal = create(:proposal)
|
proposal = create(:proposal)
|
||||||
notification = create(:notification, user: user, notifiable: proposal)
|
create(:notification, user: user, notifiable: proposal)
|
||||||
|
|
||||||
click_notifications_icon
|
click_notifications_icon
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ describe "Voters" do
|
|||||||
|
|
||||||
scenario "Cannot vote" do
|
scenario "Cannot vote" do
|
||||||
unvotable_poll = create(:poll, :current, geozone_restricted: true, geozones: [create(:geozone, census_code: "02")])
|
unvotable_poll = create(:poll, :current, geozone_restricted: true, geozones: [create(:geozone, census_code: "02")])
|
||||||
officer_assignment = create(:poll_officer_assignment, officer: officer, poll: unvotable_poll, booth: booth)
|
create(:poll_officer_assignment, officer: officer, poll: unvotable_poll, booth: booth)
|
||||||
|
|
||||||
set_officing_booth(booth)
|
set_officing_booth(booth)
|
||||||
visit new_officing_residence_path
|
visit new_officing_residence_path
|
||||||
@@ -87,7 +87,7 @@ describe "Voters" do
|
|||||||
|
|
||||||
scenario "Display current polls assigned to a booth" do
|
scenario "Display current polls assigned to a booth" do
|
||||||
poll = create(:poll, :current)
|
poll = create(:poll, :current)
|
||||||
officer_assignment = create(:poll_officer_assignment, officer: officer, poll: poll, booth: booth)
|
create(:poll_officer_assignment, officer: officer, poll: poll, booth: booth)
|
||||||
|
|
||||||
set_officing_booth(booth)
|
set_officing_booth(booth)
|
||||||
visit new_officing_residence_path
|
visit new_officing_residence_path
|
||||||
@@ -99,7 +99,7 @@ describe "Voters" do
|
|||||||
|
|
||||||
scenario "Display polls that the user can vote" do
|
scenario "Display polls that the user can vote" do
|
||||||
votable_poll = create(:poll, :current, geozone_restricted: true, geozones: [Geozone.first])
|
votable_poll = create(:poll, :current, geozone_restricted: true, geozones: [Geozone.first])
|
||||||
officer_assignment = create(:poll_officer_assignment, officer: officer, poll: votable_poll, booth: booth)
|
create(:poll_officer_assignment, officer: officer, poll: votable_poll, booth: booth)
|
||||||
|
|
||||||
set_officing_booth(booth)
|
set_officing_booth(booth)
|
||||||
visit new_officing_residence_path
|
visit new_officing_residence_path
|
||||||
@@ -111,7 +111,7 @@ describe "Voters" do
|
|||||||
|
|
||||||
scenario "Display polls that the user cannot vote" do
|
scenario "Display polls that the user cannot vote" do
|
||||||
unvotable_poll = create(:poll, :current, geozone_restricted: true, geozones: [create(:geozone, census_code: "02")])
|
unvotable_poll = create(:poll, :current, geozone_restricted: true, geozones: [create(:geozone, census_code: "02")])
|
||||||
officer_assignment = create(:poll_officer_assignment, officer: officer, poll: unvotable_poll, booth: booth)
|
create(:poll_officer_assignment, officer: officer, poll: unvotable_poll, booth: booth)
|
||||||
|
|
||||||
set_officing_booth(booth)
|
set_officing_booth(booth)
|
||||||
visit new_officing_residence_path
|
visit new_officing_residence_path
|
||||||
@@ -123,7 +123,7 @@ describe "Voters" do
|
|||||||
|
|
||||||
scenario "Do not display expired polls" do
|
scenario "Do not display expired polls" do
|
||||||
expired_poll = create(:poll, :expired)
|
expired_poll = create(:poll, :expired)
|
||||||
officer_assignment = create(:poll_officer_assignment, officer: officer, poll: expired_poll, booth: booth)
|
create(:poll_officer_assignment, officer: officer, poll: expired_poll, booth: booth)
|
||||||
|
|
||||||
set_officing_booth(booth)
|
set_officing_booth(booth)
|
||||||
visit new_officing_residence_path
|
visit new_officing_residence_path
|
||||||
|
|||||||
Reference in New Issue
Block a user