mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-04-04 23:24:49 -04:00
Rubocop corrections
This commit is contained in:
@@ -155,24 +155,6 @@ RSpec/AnyInstance:
|
||||
- 'spec/controllers/harvests_controller_spec.rb'
|
||||
- 'spec/controllers/photos_controller_spec.rb'
|
||||
|
||||
# Offense count: 78
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
RSpec/BeEq:
|
||||
Exclude:
|
||||
- 'spec/controllers/admin/roles_controller_spec.rb'
|
||||
- 'spec/controllers/harvests_controller_spec.rb'
|
||||
- 'spec/features/members/deletion_spec.rb'
|
||||
- 'spec/features/unsubscribing_spec.rb'
|
||||
- 'spec/helpers/application_helper_spec.rb'
|
||||
- 'spec/lib/actions/oauth_signup_action_spec.rb'
|
||||
- 'spec/models/crop_spec.rb'
|
||||
- 'spec/models/garden_spec.rb'
|
||||
- 'spec/models/harvest_spec.rb'
|
||||
- 'spec/models/member_spec.rb'
|
||||
- 'spec/models/planting_spec.rb'
|
||||
- 'spec/models/post_spec.rb'
|
||||
- 'spec/models/seed_spec.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnabledMethods.
|
||||
|
||||
@@ -11,12 +11,12 @@ describe Admin::RolesController do
|
||||
|
||||
describe "GET index" do
|
||||
before { get :index }
|
||||
it { expect(assigns(:roles)).to eq(nil) }
|
||||
it { expect(assigns(:roles)).to be_nil }
|
||||
end
|
||||
|
||||
describe "GET new" do
|
||||
before { get :new }
|
||||
it { expect(assigns(:role)).to eq nil }
|
||||
it { expect(assigns(:role)).to be_nil }
|
||||
end
|
||||
|
||||
describe "create" do
|
||||
@@ -27,7 +27,7 @@ describe Admin::RolesController do
|
||||
|
||||
describe "GET edit" do
|
||||
before { get :edit, params: { id: role.to_param } }
|
||||
it { expect(assigns(:role)).to eq(nil) }
|
||||
it { expect(assigns(:role)).to be_nil }
|
||||
end
|
||||
|
||||
describe "update" do
|
||||
|
||||
@@ -201,7 +201,7 @@ describe HarvestsController, :search do
|
||||
}
|
||||
end
|
||||
|
||||
it { expect(harvest.planting_id).to eq(nil) }
|
||||
it { expect(harvest.planting_id).to be_nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -90,7 +90,7 @@ describe "member deletion" do
|
||||
describe 'member exists but is marked deleted' do
|
||||
subject { Member.all.find(member.id) }
|
||||
it { expect(subject).to eq member }
|
||||
it { expect(subject.discarded?).to eq true }
|
||||
it { expect(subject.discarded?).to be true }
|
||||
it { expect(Member.kept).not_to include(member) }
|
||||
end
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ describe "unsubscribe" do
|
||||
# TODO: get these working again with chrome headless
|
||||
pending "from planting reminder mailing list" do
|
||||
# verifying the initial subscription status of the member
|
||||
expect(member.send_planting_reminder).to eq(true)
|
||||
expect(member.send_notification_email).to eq(true)
|
||||
expect(member.send_planting_reminder).to be(true)
|
||||
expect(member.send_notification_email).to be(true)
|
||||
|
||||
# generate planting reminder email
|
||||
NotifierMailer.planting_reminder(member).deliver_now
|
||||
@@ -23,15 +23,15 @@ describe "unsubscribe" do
|
||||
current_email.click_link 'Unsubscribe from planting reminders'
|
||||
expect(page).to have_content "You have been unsubscribed from planting reminders"
|
||||
updated_member = Member.find(member.id) # reload the member
|
||||
expect(updated_member.send_planting_reminder).to eq(false)
|
||||
expect(updated_member.send_notification_email).to eq(true)
|
||||
expect(updated_member.send_planting_reminder).to be(false)
|
||||
expect(updated_member.send_notification_email).to be(true)
|
||||
end
|
||||
|
||||
# TODO: get these working again with chrome headless
|
||||
pending "from inbox notification mailing list" do
|
||||
# verifying the initial subscription status of the member
|
||||
expect(member.send_planting_reminder).to eq(true)
|
||||
expect(member.send_notification_email).to eq(true)
|
||||
expect(member.send_planting_reminder).to be(true)
|
||||
expect(member.send_notification_email).to be(true)
|
||||
|
||||
# generate inbox notification email
|
||||
notification.recipient = member
|
||||
@@ -42,19 +42,19 @@ describe "unsubscribe" do
|
||||
current_email.click_link 'Unsubscribe from direct message notifications'
|
||||
expect(page).to have_content "You have been unsubscribed from direct message notifications"
|
||||
updated_member = Member.find(member.id) # reload the member
|
||||
expect(updated_member.send_planting_reminder).to eq(true)
|
||||
expect(updated_member.send_notification_email).to eq(false)
|
||||
expect(updated_member.send_planting_reminder).to be(true)
|
||||
expect(updated_member.send_notification_email).to be(false)
|
||||
end
|
||||
|
||||
it "visit unsubscribe page with a non-encrypted parameter" do
|
||||
# verifying the initial subscription status of the member
|
||||
expect(member.send_planting_reminder).to eq(true)
|
||||
expect(member.send_notification_email).to eq(true)
|
||||
expect(member.send_planting_reminder).to be(true)
|
||||
expect(member.send_notification_email).to be(true)
|
||||
|
||||
# visit /members/unsubscribe/somestring ie.parameter to the URL is a random string
|
||||
visit unsubscribe_member_path("type=send_planting_reminder&member_id=#{member.id}")
|
||||
expect(page).to have_content "We're sorry, there was an error"
|
||||
expect(member.send_planting_reminder).to eq(true)
|
||||
expect(member.send_notification_email).to eq(true)
|
||||
expect(member.send_planting_reminder).to be(true)
|
||||
expect(member.send_notification_email).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,8 +4,8 @@ require 'rails_helper'
|
||||
|
||||
describe ApplicationHelper do
|
||||
it "parses dates" do
|
||||
parse_date(nil).should eq nil
|
||||
parse_date('').should eq nil
|
||||
parse_date(nil).should be_nil
|
||||
parse_date('').should be_nil
|
||||
parse_date('2012-05-12').should eq Date.new(2012, 5, 12)
|
||||
parse_date('may 12th 2012').should eq Date.new(2012, 5, 12)
|
||||
end
|
||||
|
||||
@@ -40,7 +40,7 @@ describe 'Growstuff::OauthSignupAction' do
|
||||
end
|
||||
|
||||
it 'creates a new user' do
|
||||
expect(@action.member_created?).to eq true
|
||||
expect(@action.member_created?).to be true
|
||||
end
|
||||
|
||||
it 'sets the right email' do
|
||||
@@ -56,11 +56,11 @@ describe 'Growstuff::OauthSignupAction' do
|
||||
end
|
||||
|
||||
it 'generates a random password' do
|
||||
expect(@member.password).not_to eq nil
|
||||
expect(@member.password).not_to be_nil
|
||||
end
|
||||
|
||||
it 'does not agree to the tos' do
|
||||
expect(@member.tos_agreement).to eq nil
|
||||
expect(@member.tos_agreement).to be_nil
|
||||
end
|
||||
|
||||
it 'stores the uid and provider for the member' do
|
||||
@@ -91,7 +91,7 @@ describe 'Growstuff::OauthSignupAction' do
|
||||
end
|
||||
|
||||
it 'does not create a new user' do
|
||||
expect(@action.member_created?).to eq nil
|
||||
expect(@action.member_created?).to be_nil
|
||||
end
|
||||
|
||||
it 'locates the existing member by email' do
|
||||
@@ -141,7 +141,7 @@ describe 'Growstuff::OauthSignupAction' do
|
||||
end
|
||||
|
||||
it 'does not create a new user' do
|
||||
expect(@action.member_created?).to eq nil
|
||||
expect(@action.member_created?).to be_nil
|
||||
end
|
||||
|
||||
it 'locates the existing member by uid and provider' do
|
||||
|
||||
@@ -64,7 +64,7 @@ describe Crop do
|
||||
|
||||
it 'finds a default scientific name' do
|
||||
@crop = FactoryBot.create(:tomato)
|
||||
expect(@crop.default_scientific_name).to eq nil
|
||||
expect(@crop.default_scientific_name).to be_nil
|
||||
@sn = FactoryBot.create(:solanum_lycopersicum, crop: @crop)
|
||||
@crop.reload
|
||||
expect(@crop.default_scientific_name.to_s).to eq @sn.name
|
||||
@@ -178,7 +178,7 @@ describe Crop do
|
||||
|
||||
context 'with no plantings or harvests' do
|
||||
it 'has no default photo' do
|
||||
expect(crop.default_photo).to eq nil
|
||||
expect(crop.default_photo).to be_nil
|
||||
end
|
||||
|
||||
it { expect(crop.photos.size).to eq 0 }
|
||||
@@ -535,7 +535,7 @@ describe Crop do
|
||||
end
|
||||
|
||||
it "does not delete the posts" do
|
||||
expect(Post.find(post.id)).not_to eq nil
|
||||
expect(Post.find(post.id)).not_to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -126,7 +126,7 @@ describe Garden do
|
||||
it 'sets area unit to blank if area is blank' do
|
||||
garden = FactoryBot.build(:garden, area: '', area_unit: 'acre')
|
||||
garden.should be_valid
|
||||
expect(garden.area_unit).to eq nil
|
||||
expect(garden.area_unit).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -149,16 +149,16 @@ describe Garden do
|
||||
p1 = FactoryBot.create(:planting, garden:, owner: garden.owner)
|
||||
p2 = FactoryBot.create(:planting, garden:, owner: garden.owner)
|
||||
|
||||
expect(p1.finished).to eq false
|
||||
expect(p2.finished).to eq false
|
||||
expect(p1.finished).to be false
|
||||
expect(p2.finished).to be false
|
||||
|
||||
garden.active = false
|
||||
garden.save
|
||||
|
||||
p1.reload
|
||||
expect(p1.finished).to eq true
|
||||
expect(p1.finished).to be true
|
||||
p2.reload
|
||||
expect(p2.finished).to eq true
|
||||
expect(p2.finished).to be true
|
||||
end
|
||||
|
||||
it "doesn't mark the wrong plantings as finished" do
|
||||
@@ -173,11 +173,11 @@ describe Garden do
|
||||
|
||||
# plantings in that garden should be "finished"
|
||||
p1.reload
|
||||
expect(p1.finished).to eq true
|
||||
expect(p1.finished).to be true
|
||||
|
||||
# plantings in other gardens should not be.
|
||||
p2.reload
|
||||
expect(p2.finished).to eq false
|
||||
expect(p2.finished).to be false
|
||||
end
|
||||
|
||||
context 'photos' do
|
||||
|
||||
@@ -63,7 +63,7 @@ describe Harvest do
|
||||
it 'sets unit to blank if quantity is blank' do
|
||||
@harvest = FactoryBot.build(:harvest, quantity: '', unit: 'individual')
|
||||
@harvest.should be_valid
|
||||
expect(@harvest.unit).to eq nil
|
||||
expect(@harvest.unit).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -116,7 +116,7 @@ describe Harvest do
|
||||
it 'sets weight_unit to blank if quantity is blank' do
|
||||
@harvest = FactoryBot.build(:harvest, weight_quantity: '', weight_unit: 'kg')
|
||||
@harvest.should be_valid
|
||||
expect(@harvest.weight_unit).to eq nil
|
||||
expect(@harvest.weight_unit).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -231,7 +231,7 @@ describe Harvest do
|
||||
|
||||
context 'without a photo' do
|
||||
it 'has no default photo' do
|
||||
expect(@harvest.default_photo).to eq nil
|
||||
expect(@harvest.default_photo).to be_nil
|
||||
end
|
||||
|
||||
context 'and with a crop(planting) photo' do
|
||||
|
||||
@@ -27,7 +27,7 @@ describe Member do
|
||||
end
|
||||
|
||||
it "doesn't show email by default" do
|
||||
expect(member.show_email).to eq false
|
||||
expect(member.show_email).to be false
|
||||
end
|
||||
|
||||
it 'stringifies as the login_name' do
|
||||
@@ -185,19 +185,19 @@ describe Member do
|
||||
|
||||
it 'has a role' do
|
||||
member.roles.first.should eq role
|
||||
member.role?(:moderator).should eq true
|
||||
member.role?(:moderator).should be true
|
||||
end
|
||||
|
||||
it 'sets up roles in factories' do
|
||||
admin = FactoryBot.create(:admin_member)
|
||||
admin.role?(:admin).should eq true
|
||||
admin.role?(:admin).should be true
|
||||
end
|
||||
|
||||
it 'converts role names properly' do
|
||||
# need to make sure spaces get turned to underscores
|
||||
role = FactoryBot.create(:role, name: "a b c")
|
||||
member.roles << role
|
||||
member.role?(:a_b_c).should eq true
|
||||
member.role?(:a_b_c).should be true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -303,11 +303,11 @@ describe Member do
|
||||
|
||||
context 'already_following' do
|
||||
it 'detects that member is already following a member' do
|
||||
expect(member1.already_following?(member2)).to eq true
|
||||
expect(member1.already_following?(member2)).to be true
|
||||
end
|
||||
|
||||
it 'detects that member is not already following a member' do
|
||||
expect(member1.already_following?(member3)).to eq false
|
||||
expect(member1.already_following?(member3)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -13,34 +13,34 @@ describe Planting do
|
||||
describe 'planting planted, not finished' do
|
||||
let(:planting) { FactoryBot.create :planting, planted_at: 30.days.ago, finished_at: nil, finished: false }
|
||||
|
||||
it { expect(planting.crop.median_lifespan).to eq(nil) }
|
||||
it { expect(planting.expected_lifespan).to eq(nil) }
|
||||
it { expect(planting.crop.median_lifespan).to be_nil }
|
||||
it { expect(planting.expected_lifespan).to be_nil }
|
||||
it { expect(planting.age_in_days).to eq(30) }
|
||||
it { expect(planting.percentage_grown).to eq(nil) }
|
||||
it { expect(planting.percentage_grown).to be_nil }
|
||||
end
|
||||
|
||||
describe 'planting not planted yet' do
|
||||
let(:planting) { FactoryBot.create :planting, planted_at: nil, finished_at: nil, finished: false }
|
||||
|
||||
it { expect(planting.crop.median_lifespan).to eq(nil) }
|
||||
it { expect(planting.expected_lifespan).to eq(nil) }
|
||||
it { expect(planting.age_in_days).to eq(nil) }
|
||||
it { expect(planting.crop.median_lifespan).to be_nil }
|
||||
it { expect(planting.expected_lifespan).to be_nil }
|
||||
it { expect(planting.age_in_days).to be_nil }
|
||||
it { expect(planting.percentage_grown).to eq(0) }
|
||||
end
|
||||
|
||||
describe 'planting finished, no planted_at' do
|
||||
let(:planting) { FactoryBot.create :planting, planted_at: nil, finished_at: 1.day.ago, finished: true }
|
||||
|
||||
it { expect(planting.crop.median_lifespan).to eq(nil) }
|
||||
it { expect(planting.expected_lifespan).to eq(nil) }
|
||||
it { expect(planting.age_in_days).to eq(nil) }
|
||||
it { expect(planting.crop.median_lifespan).to be_nil }
|
||||
it { expect(planting.expected_lifespan).to be_nil }
|
||||
it { expect(planting.age_in_days).to be_nil }
|
||||
it { expect(planting.percentage_grown).to eq(100) }
|
||||
end
|
||||
|
||||
describe 'planting all finished' do
|
||||
let(:planting) { FactoryBot.create :planting, planted_at: 30.days.ago, finished_at: 10.days.ago, finished: true }
|
||||
|
||||
it { expect(planting.crop.median_lifespan).to eq(nil) }
|
||||
it { expect(planting.crop.median_lifespan).to be_nil }
|
||||
it { expect(planting.expected_lifespan).to eq(20) }
|
||||
it { expect(planting.age_in_days).to eq(20) }
|
||||
it { expect(planting.percentage_grown).to eq(100) }
|
||||
@@ -75,7 +75,7 @@ describe Planting do
|
||||
let(:child_planting) { FactoryBot.create :planting, crop: child_crop, planted_at: 30.days.ago }
|
||||
|
||||
# not data for this crop
|
||||
it { expect(child_crop.median_lifespan).to eq nil }
|
||||
it { expect(child_crop.median_lifespan).to be_nil }
|
||||
# 30 / 50 = 60%
|
||||
it { expect(child_planting.percentage_grown).to eq 60.0 }
|
||||
# planted 30 days ago
|
||||
@@ -109,11 +109,11 @@ describe Planting do
|
||||
context 'no data' do
|
||||
let(:planting) { FactoryBot.create :planting }
|
||||
|
||||
it { expect(planting.crop.median_days_to_first_harvest).to eq(nil) }
|
||||
it { expect(planting.crop.median_days_to_last_harvest).to eq(nil) }
|
||||
it { expect(planting.days_to_first_harvest).to eq(nil) }
|
||||
it { expect(planting.days_to_last_harvest).to eq(nil) }
|
||||
it { expect(planting.expected_lifespan).to eq(nil) }
|
||||
it { expect(planting.crop.median_days_to_first_harvest).to be_nil }
|
||||
it { expect(planting.crop.median_days_to_last_harvest).to be_nil }
|
||||
it { expect(planting.days_to_first_harvest).to be_nil }
|
||||
it { expect(planting.days_to_last_harvest).to be_nil }
|
||||
it { expect(planting.expected_lifespan).to be_nil }
|
||||
end
|
||||
|
||||
context 'lots of data' do
|
||||
@@ -149,16 +149,16 @@ describe Planting do
|
||||
describe 'harvest still growing' do
|
||||
let(:planting) { FactoryBot.create :planting, crop:, planted_at: Time.zone.today }
|
||||
|
||||
it { expect(planting.before_harvest_time?).to eq true }
|
||||
it { expect(planting.harvest_time?).to eq false }
|
||||
it { expect(planting.before_harvest_time?).to be true }
|
||||
it { expect(planting.harvest_time?).to be false }
|
||||
end
|
||||
|
||||
describe 'harvesting ready now' do
|
||||
let(:planting) { FactoryBot.create :planting, crop:, planted_at: 21.days.ago }
|
||||
|
||||
it { expect(planting.first_harvest_predicted_at).to eq(1.day.ago.to_date) }
|
||||
it { expect(planting.before_harvest_time?).to eq false }
|
||||
it { expect(planting.harvest_time?).to eq true }
|
||||
it { expect(planting.before_harvest_time?).to be false }
|
||||
it { expect(planting.harvest_time?).to be true }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -170,8 +170,8 @@ describe Planting do
|
||||
planting.crop.update_harvest_medians
|
||||
end
|
||||
|
||||
it { expect(planting.days_to_first_harvest).to eq(nil) }
|
||||
it { expect(planting.days_to_last_harvest).to eq(nil) }
|
||||
it { expect(planting.days_to_first_harvest).to be_nil }
|
||||
it { expect(planting.days_to_last_harvest).to be_nil }
|
||||
end
|
||||
|
||||
describe 'planting has first harvest' do
|
||||
@@ -187,9 +187,9 @@ describe Planting do
|
||||
end
|
||||
|
||||
it { expect(planting.days_to_first_harvest).to eq(90) }
|
||||
it { expect(planting.days_to_last_harvest).to eq(nil) }
|
||||
it { expect(planting.days_to_last_harvest).to be_nil }
|
||||
it { expect(planting.crop.median_days_to_first_harvest).to eq(90) }
|
||||
it { expect(planting.crop.median_days_to_last_harvest).to eq(nil) }
|
||||
it { expect(planting.crop.median_days_to_last_harvest).to be_nil }
|
||||
end
|
||||
|
||||
describe 'planting has last harvest' do
|
||||
@@ -211,7 +211,7 @@ describe Planting do
|
||||
|
||||
describe 'planting perennial' do
|
||||
let(:crop) { FactoryBot.create(:crop, name: 'feijoa', perennial: true) }
|
||||
it { expect(planting.perennial?).to eq true }
|
||||
it { expect(planting.perennial?).to be true }
|
||||
describe 'no harvest to predict from' do
|
||||
it { expect(planting.harvest_months).to eq({}) }
|
||||
end
|
||||
@@ -275,15 +275,15 @@ describe Planting do
|
||||
describe '#planted?' do
|
||||
it "is false for future plantings" do
|
||||
planting = FactoryBot.create :planting, planted_at: Time.zone.today + 1
|
||||
expect(planting.planted?).to eq(false)
|
||||
expect(planting.planted?).to be(false)
|
||||
end
|
||||
it "is false for never planted" do
|
||||
planting = FactoryBot.create :planting, planted_at: nil
|
||||
expect(planting.planted?).to eq(false)
|
||||
expect(planting.planted?).to be(false)
|
||||
end
|
||||
it "is true for past plantings" do
|
||||
planting = FactoryBot.create :planting, planted_at: Time.zone.today - 1
|
||||
expect(planting.planted?).to eq(true)
|
||||
expect(planting.planted?).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -167,8 +167,8 @@ describe Post do
|
||||
end
|
||||
|
||||
it "does not delete the crops" do
|
||||
expect(Crop.find(tomato.id)).not_to eq nil
|
||||
expect(Crop.find(maize.id)).not_to eq nil
|
||||
expect(Crop.find(tomato.id)).not_to be_nil
|
||||
expect(Crop.find(maize.id)).not_to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -65,13 +65,13 @@ describe Seed do
|
||||
|
||||
it 'tradable gives the right answers' do
|
||||
@seed = FactoryBot.create(:seed, tradable_to: 'nowhere')
|
||||
@seed.tradable.should eq false
|
||||
@seed.tradable.should be false
|
||||
@seed = FactoryBot.create(:seed, tradable_to: 'locally')
|
||||
@seed.tradable.should eq true
|
||||
@seed.tradable.should be true
|
||||
@seed = FactoryBot.create(:seed, tradable_to: 'nationally')
|
||||
@seed.tradable.should eq true
|
||||
@seed.tradable.should be true
|
||||
@seed = FactoryBot.create(:seed, tradable_to: 'internationally')
|
||||
@seed.tradable.should eq true
|
||||
@seed.tradable.should be true
|
||||
end
|
||||
|
||||
it 'recognises a tradable seed' do
|
||||
@@ -178,7 +178,7 @@ describe Seed do
|
||||
describe 'has finished fields' do
|
||||
let(:seed) { FactoryBot.create(:finished_seed) }
|
||||
|
||||
it { expect(seed.finished).to eq true }
|
||||
it { expect(seed.finished).to be true }
|
||||
it { expect(seed.finished_at).to be_an_instance_of Date }
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user