Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules. Personally I prefer no empty lines around blocks, clases, etc... as recommended by the Ruby style guide [1], and they're the default values in rubocop, so those are the settings I'm applying. The exception is the `private` access modifier, since we were leaving empty lines around it most of the time. That's the default rubocop rule as well. Personally I don't have a strong preference about this one. [1] https://rubystyle.guide/#empty-lines-around-bodies
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Poll::Answer do
|
||||
|
||||
describe "validations" do
|
||||
|
||||
let(:answer) { build(:poll_answer) }
|
||||
|
||||
it "is valid" do
|
||||
@@ -40,7 +38,6 @@ describe Poll::Answer do
|
||||
end
|
||||
|
||||
describe "#record_voter_participation" do
|
||||
|
||||
let(:author) { create(:user, :level_two) }
|
||||
let(:poll) { create(:poll) }
|
||||
let(:question) { create(:poll_question, :yes_no, poll: poll) }
|
||||
@@ -74,5 +71,4 @@ describe Poll::Answer do
|
||||
expect(voter.poll_id).to eq(answer.poll.id)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,7 +8,6 @@ describe Poll::BallotSheet do
|
||||
end
|
||||
|
||||
context "Validations" do
|
||||
|
||||
it "is valid" do
|
||||
expect(ballot_sheet).to be_valid
|
||||
end
|
||||
@@ -27,15 +26,12 @@ describe Poll::BallotSheet do
|
||||
ballot_sheet.data = nil
|
||||
expect(ballot_sheet).not_to be_valid
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "#author" do
|
||||
|
||||
it "returns the officer's name" do
|
||||
expect(ballot_sheet.author).to be(ballot_sheet.officer_assignment.officer.user.name)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#verify_ballots" do
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Poll::Ballot do
|
||||
|
||||
let(:budget) { create(:budget) }
|
||||
let(:group) { create(:budget_group, budget: budget) }
|
||||
let(:heading) { create(:budget_heading, group: group, price: 10000000) }
|
||||
@@ -12,7 +11,6 @@ describe Poll::Ballot do
|
||||
before { create(:budget_ballot, budget: budget, physical: true, poll_ballot: poll_ballot) }
|
||||
|
||||
describe "#verify" do
|
||||
|
||||
it "adds ballot lines until there are sufficiente funds" do
|
||||
investment2 = create(:budget_investment, :selected, price: 2000000, heading: heading)
|
||||
investment3 = create(:budget_investment, :selected, price: 2000000, heading: heading)
|
||||
@@ -47,11 +45,9 @@ describe Poll::Ballot do
|
||||
|
||||
expect(poll_ballot.ballot.lines.pluck(:investment_id)).to match_array [investment.id, investment2.id, investment3.id]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#add_investment" do
|
||||
|
||||
describe "Money" do
|
||||
it "is not valid if insufficient funds" do
|
||||
investment.update!(price: heading.price + 1)
|
||||
@@ -129,5 +125,4 @@ describe Poll::Ballot do
|
||||
expect(poll_ballot.find_investment("00#{investment.id}")).to eq(investment)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Poll::Booth do
|
||||
|
||||
let(:booth) { build(:poll_booth) }
|
||||
|
||||
it "is valid" do
|
||||
@@ -45,7 +44,6 @@ describe Poll::Booth do
|
||||
end
|
||||
|
||||
describe ".available" do
|
||||
|
||||
it "returns booths associated to current polls" do
|
||||
booth_for_current_poll = create(:poll_booth, polls: [create(:poll, :current)])
|
||||
booth_for_expired_poll = create(:poll_booth, polls: [create(:poll, :expired)])
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Poll::Officer do
|
||||
|
||||
describe "#name" do
|
||||
let(:officer) { create(:poll_officer) }
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Poll::PairAnswer do
|
||||
|
||||
describe "validations" do
|
||||
|
||||
let(:pair_answer) { build(:poll_pair_answer) }
|
||||
|
||||
it "is valid" do
|
||||
@@ -50,24 +48,20 @@ describe Poll::PairAnswer do
|
||||
let(:pair_answer_2) { create(:poll_pair_answer) }
|
||||
|
||||
describe "#by_author" do
|
||||
|
||||
it "returns pair_answers associated to an user" do
|
||||
author = pair_answer_1.author
|
||||
|
||||
expect(Poll::PairAnswer.by_author(author)).to eq [pair_answer_1]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#by_question" do
|
||||
|
||||
it "returns pair_answers associated to a question" do
|
||||
question = pair_answer_1.question
|
||||
|
||||
expect(Poll::PairAnswer.by_question(question)).to eq [pair_answer_1]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#generate_pair" do
|
||||
@@ -75,7 +69,6 @@ describe Poll::PairAnswer do
|
||||
let(:question) { create(:poll_question) }
|
||||
|
||||
context "without question_answers" do
|
||||
|
||||
it "assigns nil value to pair_answers" do
|
||||
pair_answer = Poll::PairAnswer.generate_pair(question, user)
|
||||
|
||||
@@ -122,5 +115,4 @@ describe Poll::PairAnswer do
|
||||
expect(pair_answer.answers).to eq [pair_answer.answer_left, pair_answer.answer_right]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Poll::PartialResult do
|
||||
|
||||
describe "validations" do
|
||||
it "validates that the answers are included in the Poll::Question's list" do
|
||||
question = create(:poll_question)
|
||||
@@ -81,5 +80,4 @@ describe Poll::PartialResult do
|
||||
expect(partial_result.author_id_log).to eq(":#{author1.id}:#{author2.id}")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Poll do
|
||||
|
||||
let(:poll) { build(:poll) }
|
||||
|
||||
describe "Concerns" do
|
||||
@@ -233,7 +232,6 @@ describe Poll do
|
||||
|
||||
expect(Poll.votable_by(user)).to eq [poll]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#votable_by" do
|
||||
@@ -344,9 +342,7 @@ describe Poll do
|
||||
end
|
||||
|
||||
context "scopes" do
|
||||
|
||||
describe "#not_budget" do
|
||||
|
||||
it "returns polls not associated to a budget" do
|
||||
poll1 = create(:poll)
|
||||
poll2 = create(:poll)
|
||||
@@ -355,9 +351,7 @@ describe Poll do
|
||||
expect(Poll.not_budget).to match_array [poll1, poll2]
|
||||
expect(Poll.not_budget).not_to include(poll3)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#sort_for_list" do
|
||||
|
||||
@@ -47,7 +47,6 @@ RSpec.describe Poll::Question, type: :model do
|
||||
end
|
||||
|
||||
describe "#enum_type" do
|
||||
|
||||
it "returns nil if not has votation_type association" do
|
||||
expect(poll_question.votation_type).to be_nil
|
||||
expect(poll_question.enum_type).to be_nil
|
||||
@@ -59,11 +58,9 @@ RSpec.describe Poll::Question, type: :model do
|
||||
expect(question.votation_type).not_to be_nil
|
||||
expect(question.enum_type).to eq("answer_couples_open")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#max_votes" do
|
||||
|
||||
it "returns nil if not has votation_type association" do
|
||||
expect(poll_question.votation_type).to be_nil
|
||||
expect(poll_question.max_votes).to be_nil
|
||||
@@ -75,6 +72,5 @@ RSpec.describe Poll::Question, type: :model do
|
||||
expect(question.votation_type).not_to be_nil
|
||||
expect(question.max_votes).to eq(5)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Poll::Recount do
|
||||
|
||||
describe "logging changes" do
|
||||
let(:author) { create(:user) }
|
||||
let(:officer_assignment) { create(:poll_officer_assignment) }
|
||||
@@ -100,5 +99,4 @@ describe Poll::Recount do
|
||||
expect(poll_recount.author_id_log).to eq(":#{author.id}:#{first_author.id}:#{second_author.id}")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -51,11 +51,9 @@ describe Poll::Shift do
|
||||
|
||||
expect(build(:poll_shift, booth: booth, officer: officer, date: Date.tomorrow, task: :recount_scrutiny)).to be_valid
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "officer_assignments" do
|
||||
|
||||
it "creates and destroy corresponding officer_assignments" do
|
||||
booth_assignment1 = create(:poll_booth_assignment, booth: booth)
|
||||
booth_assignment2 = create(:poll_booth_assignment, booth: booth)
|
||||
@@ -95,7 +93,6 @@ describe Poll::Shift do
|
||||
expect(officer_assignment.booth_assignment).to eq(booth_assignment)
|
||||
expect(officer_assignment.final).to be_truthy
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#persist_data" do
|
||||
@@ -114,7 +111,5 @@ describe Poll::Shift do
|
||||
expect(shift.officer_name).to eq "Ana"
|
||||
expect(shift.officer_email).to eq "ana@example.com"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -73,7 +73,6 @@ describe Poll::Voter do
|
||||
end
|
||||
|
||||
context "origin" do
|
||||
|
||||
it "is not valid without an origin" do
|
||||
voter.origin = nil
|
||||
expect(voter).not_to be_valid
|
||||
@@ -116,11 +115,9 @@ describe Poll::Voter do
|
||||
expect(voter).to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "scopes" do
|
||||
|
||||
describe "#web" do
|
||||
it "returns voters with a web origin" do
|
||||
voter = create(:poll_voter, :from_web)
|
||||
@@ -148,11 +145,9 @@ describe Poll::Voter do
|
||||
expect(Poll::Voter.booth).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "save" do
|
||||
|
||||
it "sets demographic info" do
|
||||
geozone = create(:geozone)
|
||||
user = create(:user, :level_two,
|
||||
|
||||
Reference in New Issue
Block a user