Apply rubocop Rails/FindBy rule everywhere

We didn't detect these cases because by default the rule only searches
for offenses in `app/models/`.
This commit is contained in:
Javi Martín
2019-11-08 18:49:57 +01:00
parent 84bbd81d95
commit ea2aeab383
28 changed files with 48 additions and 44 deletions

View File

@@ -399,7 +399,7 @@ describe Debate do
describe "custom tag counters when hiding/restoring" do
it "decreases the tag counter when hiden, and increases it when restored" do
debate = create(:debate, tag_list: "foo")
tag = Tag.where(name: "foo").first
tag = Tag.find_by(name: "foo")
expect(tag.debates_count).to eq(1)
debate.hide

View File

@@ -117,8 +117,8 @@ describe Newsletter do
expect(Activity.count).to eq(3)
recipients.each do |email|
user = User.where(email: email).first
activity = Activity.where(user: user).first
user = User.find_by(email: email)
activity = Activity.find_by(user: user)
expect(activity.user_id).to eq(user.id)
expect(activity.action).to eq("email")

View File

@@ -341,7 +341,7 @@ describe Proposal do
describe "custom tag counters when hiding/restoring" do
it "decreases the tag counter when hiden, and increases it when restored" do
proposal = create(:proposal, tag_list: "foo")
tag = Tag.where(name: "foo").first
tag = Tag.find_by(name: "foo")
expect(tag.proposals_count).to eq(1)
proposal.hide