Rubocop - auto corrections

This commit is contained in:
Daniel O'Connor committed 2022-11-06 16:34:36 +10:30
1 parent dd54cf2288
commit b24b9f82e6
86 files changed
+331 -330

No files matched your search

@@ -14,14 +14,14 @@ class AuthenticationsController < ApplicationController
@authentication = current_member.authentications
.create_with(
name: name,
name:,
token: auth['credentials']['token'],
secret: auth['credentials']['secret']
)
.find_or_create_by(
provider: auth['provider'],
uid: auth['uid'],
name: name
name:
)
flash[:notice] = "Authentication successful."
+1 -1
View File
@@ -71,7 +71,7 @@ class ConversationsController < ApplicationController
@conversation = Mailboxer::Conversation.find_by(id: params[:id])
return unless @conversation.nil? || !@conversation.is_participant?(current_member)
redirect_to conversations_path(box: box)
redirect_to conversations_path(box:)
nil
end
end
+1 -1
View File
@@ -57,7 +57,7 @@ class CropsController < ApplicationController
@crops = CropSearchService.search(@term,
page: params[:page],
per_page: Crop.per_page,
current_member: current_member)
current_member:)
respond_with @crops
end
+1 -1
View File
@@ -20,7 +20,7 @@ class HarvestsController < DataController
where['planting_id'] = @planting.id
end
@harvests = Harvest.search('*', where: where,
@harvests = Harvest.search('*', where:,
limit: 100,
page: params[:page],
load: false,
+2 -2
View File
@@ -39,7 +39,7 @@ class LikesController < ApplicationController
{
id: like.likeable.id,
like_count: like.likeable.likes.count,
liked_by_member: liked_by_member,
liked_by_member:,
description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like")
}
end
@@ -50,7 +50,7 @@ class LikesController < ApplicationController
format.json do
render(json: render_json(
like,
liked_by_member: liked_by_member
liked_by_member:
), status: status_code)
end
end
+1 -1
View File
@@ -21,7 +21,7 @@ class PlantingsController < DataController
end
@plantings = Planting.search(
where: where,
where:,
page: params[:page],
limit: 30,
boost_by: [:created_at],
+1 -1
View File
@@ -24,7 +24,7 @@ class SeedsController < DataController
@filename = csv_filename
@seeds = Seed.search(
where: where,
where:,
page: params[:page],
limit: 30,
boost_by: [:created_at],
+4 -4
View File
@@ -55,7 +55,7 @@ module ApplicationHelper
return uri.to_s
end
Gravatar.new(member.email).image_url(size: size,
Gravatar.new(member.email).image_url(size:,
default: :identicon,
ssl: true)
end
@@ -70,11 +70,11 @@ module ApplicationHelper
all = show_all ? '' : 1
if owner.present?
public_send("member_#{type}_path", owner, all: all)
public_send("member_#{type}_path", owner, all:)
elsif crop.present?
public_send("crop_#{type}_path", crop, all: all)
public_send("crop_#{type}_path", crop, all:)
else
public_send("#{type}_path", all: all)
public_send("#{type}_path", all:)
end
end
+4 -4
View File
@@ -44,19 +44,19 @@ module ButtonsHelper
end
def seed_edit_button(seed, classes: "btn btn-raised btn-info")
edit_button(edit_seed_path(seed), classes: classes)
edit_button(edit_seed_path(seed), classes:)
end
def harvest_edit_button(harvest, classes: "btn btn-raised btn-info")
edit_button(edit_harvest_path(harvest), classes: classes)
edit_button(edit_harvest_path(harvest), classes:)
end
def garden_edit_button(garden, classes: "btn btn-raised btn-info")
edit_button(edit_garden_path(garden), classes: classes)
edit_button(edit_garden_path(garden), classes:)
end
def planting_edit_button(planting, classes: "btn btn-raised btn-info")
edit_button(edit_planting_path(planting), classes: classes)
edit_button(edit_planting_path(planting), classes:)
end
def planting_finish_button(planting, classes: 'btn btn-default btn-secondary')
+1 -1
View File
@@ -2,7 +2,7 @@
module CropsHelper
def display_seed_availability(member, crop)
seeds = member.seeds.where(crop: crop)
seeds = member.seeds.where(crop:)
total_quantity = seeds.where.not(quantity: nil).sum(:quantity)
return "You don't have any seeds of this crop." if seeds.none?
+2 -2
View File
@@ -2,7 +2,7 @@
module EditableFormHelper
def editable(field_type, model, field, display_field:, collection: [])
render 'shared/editable/form', field_type: field_type,
model: model, field: field, display_field: display_field, collection: collection
render 'shared/editable/form', field_type:,
model:, field:, display_field:, collection:
end
end
+2 -2
View File
@@ -2,11 +2,11 @@
module PostsHelper
def display_post_truncated(post, length: 300)
truncate(strip_tags(post.body), length: length,
truncate(strip_tags(post.body), length:,
separator: ' ', omission: '... ') { link_to "Read more", post_path(post) }
end
def post_stripped_tags(post, length: 300)
truncate(strip_tags(post.body), length: length)
truncate(strip_tags(post.body), length:)
end
end
+1 -1
View File
@@ -15,7 +15,7 @@ class Comment < ApplicationRecord
recipient_id: recipient,
sender_id: sender,
subject: "#{author} commented on #{post.subject}",
body: body,
body:,
post_id: post.id
)
end
+3 -3
View File
@@ -32,8 +32,8 @@ module MemberNewsletter
gibbon.lists.subscribe(
id: Rails.application.config.newsletter_list_id,
email: { email: email },
merge_vars: { login_name: login_name },
email: { email: },
merge_vars: { login_name: },
double_optin: false # they already confirmed their email with us
)
end
@@ -42,7 +42,7 @@ module MemberNewsletter
return true if Rails.env.test? && !testing
gibbon.lists.unsubscribe(id: Rails.application.config.newsletter_list_id,
email: { email: email })
email: { email: })
end
end
end
+1 -1
View File
@@ -33,7 +33,7 @@ module PredictHarvest
days_to_first_harvest = (first_harvest_date - planted_at).to_i
days_to_last_harvest = (last_harvest_date - planted_at).to_i if finished?
end
update(days_to_first_harvest: days_to_first_harvest, days_to_last_harvest: days_to_last_harvest)
update(days_to_first_harvest:, days_to_last_harvest:)
end
# status
+6 -6
View File
@@ -29,19 +29,19 @@ module SearchCrops
def search_data
{
name: name,
description: description,
slug: slug,
name:,
description:,
slug:,
alternate_names: alternate_names.pluck(:name),
scientific_names: scientific_names.pluck(:name),
photos_count: photo_associations_count,
# boost the crops that are planted the most
plantings_count: plantings_count,
harvests_count: harvests_count,
plantings_count:,
harvests_count:,
# boost this crop for these members
planters_ids: plantings.pluck(:owner_id),
has_photos: photos.size.positive?,
thumbnail_url: thumbnail_url,
thumbnail_url:,
scientific_name: default_scientific_name&.name,
created_at: created_at.to_i
}
+10 -10
View File
@@ -17,22 +17,22 @@ module SearchHarvests
def search_data
{
slug: slug,
quantity: quantity,
slug:,
quantity:,
# crop
crop_id: crop_id,
crop_name: crop_name,
crop_id:,
crop_name:,
crop_slug: crop.slug,
# owner
owner_id: owner_id,
owner_login_name: owner_login_name,
owner_slug: owner_slug,
owner_id:,
owner_login_name:,
owner_slug:,
plant_part_name: plant_part&.name,
# planting
planting_id: planting_id,
planting_id:,
planting_slug: planting&.slug,
# photo
@@ -43,7 +43,7 @@ module SearchHarvests
photos_count: photos.count,
# timestamps
harvested_at: harvested_at,
harvested_at:,
created_at: created_at.to_i
}
end
@@ -58,7 +58,7 @@ module SearchHarvests
}
one_record = search('*',
limit: 1,
where: where,
where:,
boost_by: [:created_at],
load: false).first
return records if one_record.nil?
+9 -9
View File
@@ -15,20 +15,20 @@ module SearchPhotos
def search_data
{
id: id,
title: title,
thumbnail_url: thumbnail_url,
fullsize_url: fullsize_url,
id:,
title:,
thumbnail_url:,
fullsize_url:,
# crops
crops: crops.pluck(:id),
# likes
liked_by_members_names: liked_by_members_names,
liked_by_members_names:,
# owner
owner_id: owner_id,
owner_login_name: owner_login_name,
owner_slug: owner_slug,
owner_id:,
owner_login_name:,
owner_slug:,
# counts
likes_count: likes_count,
likes_count:,
created_at: created_at.to_i
}
+20 -20
View File
@@ -18,39 +18,39 @@ module SearchPlantings
def search_data
{
slug: slug,
active: active,
slug:,
active:,
finished: finished?,
has_photos: photos.size.positive?,
location: location,
location:,
percentage_grown: percentage_grown.to_i,
planted_at: planted_at,
planted_from: planted_from,
planted_at:,
planted_from:,
planted_year: planted_at&.year,
quantity: quantity,
sunniness: sunniness,
garden_id: garden_id,
quantity:,
sunniness:,
garden_id:,
first_harvest_predicted_at: first_harvest_predicted_at,
finish_predicted_at: finish_predicted_at,
first_harvest_predicted_at:,
finish_predicted_at:,
# crops
crop_id: crop_id,
crop_name: crop_name,
crop_slug: crop_slug,
crop_perennial: crop_perennial,
crop_id:,
crop_name:,
crop_slug:,
crop_perennial:,
# owner
owner_id: owner_id,
owner_location: owner_location,
owner_login_name: owner_login_name,
owner_slug: owner_slug,
owner_id:,
owner_location:,
owner_login_name:,
owner_slug:,
# photos
thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url,
# counts
photos_count: photos.size,
harvests_count: harvests_count,
harvests_count:,
# timestamps
created_at: created_at.to_i
@@ -67,7 +67,7 @@ module SearchPlantings
}
one_record = search('*',
limit: 1,
where: where,
where:,
boost_by: [:created_at],
load: false).first
return records if one_record.nil?
+15 -15
View File
@@ -18,31 +18,31 @@ module SearchSeeds
def search_data
{
slug: slug,
slug:,
finished: finished?,
gmo: gmo,
active: active,
heirloom: heirloom,
gmo:,
active:,
heirloom:,
location: owner.location,
organic: organic,
quantity: quantity,
organic:,
quantity:,
plant_before: plant_before&.to_fs(:ymd),
tradable_to: tradable_to,
tradable: tradable,
tradable_to:,
tradable:,
# crop
crop_id: crop_id,
crop_id:,
crop_name: crop.name,
crop_slug: crop.slug,
# owner
owner_id: owner_id,
owner_location: owner_location,
owner_login_name: owner_login_name,
owner_slug: owner_slug,
owner_id:,
owner_location:,
owner_login_name:,
owner_slug:,
# planting
parent_planting: parent_planting,
parent_planting:,
# counts
photos_count: photos.size,
@@ -56,7 +56,7 @@ module SearchSeeds
end
def self.homepage_records(limit)
search('*', limit: limit,
search('*', limit:,
where: {
finished: false,
tradable: true
+5 -5
View File
@@ -10,9 +10,9 @@ class CsvImporter
def import_crop(row)
name, en_wikipedia_url, parent_name, scientific_names, alternate_names = row
@crop = Crop.find_or_create_by(name: name)
@crop = Crop.find_or_create_by(name:)
@crop.update(
en_wikipedia_url: en_wikipedia_url,
en_wikipedia_url:,
creator_id: cropbot.id
)
@@ -47,8 +47,8 @@ class CsvImporter
return if names_to_add.empty?
names_to_add.each do |name|
sciname = ScientificName.find_by(name: name, crop: @crop)
sciname ||= ScientificName.create!(name: name, crop: @crop, creator: cropbot)
sciname = ScientificName.find_by(name:, crop: @crop)
sciname ||= ScientificName.create!(name:, crop: @crop, creator: cropbot)
@crop.scientific_names << sciname
end
end
@@ -58,7 +58,7 @@ class CsvImporter
return if alternate_names.blank?
alternate_names.split(/,\s*/).each do |name|
altname = AlternateName.find_by(name: name, crop: @crop)
altname = AlternateName.find_by(name:, crop: @crop)
altname ||= AlternateName.create! name: name, crop: @crop, creator: cropbot
@crop.alternate_names << altname
end
+1 -1
View File
@@ -127,7 +127,7 @@ class Member < ApplicationRecord
end
def auth(provider)
authentications.find_by(provider: provider)
authentications.find_by(provider:)
end
def unread_count
+1 -1
View File
@@ -27,7 +27,7 @@ class Photo < ApplicationRecord
source_type: type
end
scope :by_crop, ->(crop) { joins(:photo_associations).where(photo_associations: { crop: crop }) }
scope :by_crop, ->(crop) { joins(:photo_associations).where(photo_associations: { crop: }) }
scope :by_model, lambda { |model_name|
joins(:photo_associations).where(photo_associations: { photographable_type: model_name.to_s })
}
+2 -2
View File
@@ -89,7 +89,7 @@ class Planting < ApplicationRecord
# stringify as "beet in Skud's backyard" or similar
def to_s
I18n.t('plantings.string', crop: crop.name, garden: garden.name, owner: owner)
I18n.t('plantings.string', crop: crop.name, garden: garden.name, owner:)
end
def finished?
@@ -109,7 +109,7 @@ class Planting < ApplicationRecord
# latitude, longitude = Geocoder.coordinates(location, params: { limit: 1 })
Planting.joins(:garden)
.where(crop: crop)
.where(crop:)
.located
.where('gardens.latitude < ? AND gardens.latitude > ?',
latitude + 10, latitude - 10)
+2 -2
View File
@@ -90,10 +90,10 @@ class Post < ApplicationRecord
next unless recipient_id != sender
Notification.create(
recipient_id: recipient_id,
recipient_id:,
sender_id: sender,
subject: "#{author} mentioned you in their post #{subject}",
body: body
body:
)
end
end
+1 -1
View File
@@ -11,7 +11,7 @@ class Role < ApplicationRecord
%i(crop_wranglers admins).each do |method|
define_method method do
slug = method.to_s.singularize.dasherize
Role.where(slug: slug).try(:first).try(:members)
Role.where(slug:).try(:first).try(:members)
end
end
end
+1 -1
View File
@@ -69,6 +69,6 @@ class Seed < ApplicationRecord
end
def to_s
I18n.t('seeds.string', crop: crop.name, owner: owner)
I18n.t('seeds.string', crop: crop.name, owner:)
end
end
+1 -1
View File
@@ -64,7 +64,7 @@ class OpenfarmService
if photo.valid?
Photo.transaction do
photo.save
PhotoAssociation.find_or_create_by! photo: photo, photographable: crop
PhotoAssociation.find_or_create_by! photo:, photographable: crop
end
Rails.logger.debug "\t saved photo #{photo.id} #{photo.source_id}"
else
+2 -1
View File
@@ -235,5 +235,6 @@ Devise.setup do |config|
# config.omniauth_path_prefix = "/my_engine/users/auth"
# Later we may wish to ask for user_photos,user_location, however this means we need to be reviewed by facebook
config.omniauth :facebook, ENV['GROWSTUFF_FACEBOOK_KEY'], ENV['GROWSTUFF_FACEBOOK_SECRET'], scope: 'email,public_profile', display: 'page', info_fields: 'email,name,first_name,last_name,id'
config.omniauth :facebook, ENV['GROWSTUFF_FACEBOOK_KEY'], ENV['GROWSTUFF_FACEBOOK_SECRET'], scope: 'email,public_profile',
display: 'page', info_fields: 'email,name,first_name,last_name,id'
end
+1 -1
View File
@@ -3,7 +3,7 @@
if ENV['MY_RUBY_HOME']&.include?('rvm')
begin
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
RVM.use_from_path! File.dirname(__FILE__, 2)
rescue LoadError
# RVM is unavailable at this point.
raise "RVM ruby lib is currently unavailable."
+1 -1
View File
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class CreateCms < ActiveRecord::Migration[4.2]
def self.up # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
def self.up # rubocop:disable Metrics/MethodLength
# -- Sites --------------------------------------------------------------
create_table :comfy_cms_sites do |t|
t.string :label, null: false
@@ -13,7 +13,7 @@ class CreateGardenTypes < ActiveRecord::Migration[5.2]
'wicking bed', 'permaculture', 'hydroponic', 'aquaponic', 'orchard', 'food forest',
'biodynamic'].each do |name|
say "Creating #{name}"
GardenType.create! name: name
GardenType.create! name:
end
end
end
+2 -2
View File
@@ -75,8 +75,8 @@ def load_test_users
suburb, _country, _state, latitude, longitude = row[0]
# Using 'update_column' method instead of 'update' so that
# it avoids accessing Geocoding service for faster processing
@user.gardens.first.update_columns(location: suburb, latitude: latitude, longitude: longitude)
@user.update_columns(location: suburb, latitude: latitude, longitude: longitude)
@user.gardens.first.update_columns(location: suburb, latitude:, longitude:)
@user.update_columns(location: suburb, latitude:, longitude:)
end
# Create a planting by the member
+2 -2
View File
@@ -43,14 +43,14 @@ class Growstuff::OauthSignupAction
member.authentications
.create_with(
name: name,
name:,
token: auth['credentials']['token'],
secret: auth['credentials']['secret']
)
.find_or_create_by(
provider: auth['provider'],
uid: auth['uid'],
name: name,
name:,
member_id: member.id
)
end
+1 -1
View File
@@ -20,7 +20,7 @@ namespace :growstuff do
raise "Usage: rake growstuff:[rolename] name=[username] "\
"\n (login name is case-sensitive)\n"
end
member = Member.find_by!(login_name: login_name)
member = Member.find_by!(login_name:)
role = Role.find_by!(name: role_name)
member.roles << role
end
+5 -5
View File
@@ -37,7 +37,7 @@ describe CommentsController do
describe "with valid params" do
before { get :new, params: { post_id: post.id } }
let(:old_comment) { FactoryBot.create(:comment, post: post) }
let(:old_comment) { FactoryBot.create(:comment, post:) }
it "picks up post from params" do
expect(assigns(:post)).to eq(post)
@@ -60,8 +60,8 @@ describe CommentsController do
before { get :edit, params: { id: comment.to_param } }
describe "my comment" do
let!(:comment) { FactoryBot.create :comment, author: member, post: post }
let!(:old_comment) { FactoryBot.create(:comment, post: post, created_at: Time.zone.yesterday) }
let!(:comment) { FactoryBot.create :comment, author: member, post: }
let!(:old_comment) { FactoryBot.create(:comment, post:, created_at: Time.zone.yesterday) }
it "assigns previous comments as @comments" do
expect(assigns(:comments)).to eq([comment, old_comment])
@@ -69,7 +69,7 @@ describe CommentsController do
end
describe "not my comment" do
let(:comment) { FactoryBot.create :comment, post: post }
let(:comment) { FactoryBot.create :comment, post: }
it { expect(response).not_to be_successful }
end
@@ -96,7 +96,7 @@ describe CommentsController do
let(:post) { FactoryBot.create :post, subject: 'our post' }
let(:other_post) { FactoryBot.create :post, subject: 'the other post' }
let(:valid_attributes) { { post_id: other_post.id, body: "kōrero" } }
let(:comment) { FactoryBot.create :comment, author: member, post: post }
let(:comment) { FactoryBot.create :comment, author: member, post: }
it "does not change post_id" do
comment.reload
+1 -1
View File
@@ -3,7 +3,7 @@
require 'rails_helper'
describe LikesController do
let(:like) { FactoryBot.create :like, member: member }
let(:like) { FactoryBot.create :like, member: }
let(:member) { FactoryBot.create(:member) }
let(:blogpost) { FactoryBot.create(:post) }
+5 -5
View File
@@ -23,8 +23,8 @@ describe PhotosController, :search do
describe '#index crop photos' do
let!(:photo) { FactoryBot.create :photo, :reindex, owner: member, title: 'no assocations photo' }
let!(:crop_photo) { FactoryBot.create :photo, :reindex, owner: member, title: 'photos of planting' }
let!(:planting) { FactoryBot.create :planting, :reindex, crop: crop, owner: member }
let!(:crop) { FactoryBot.create :crop, :reindex }
let!(:planting) { FactoryBot.create :planting, :reindex, crop:, owner: member }
let!(:crop) { FactoryBot.create :crop, :reindex }
before do
planting.photos << crop_photo
@@ -53,7 +53,7 @@ describe PhotosController, :search do
let(:garden) { FactoryBot.create(:garden, owner: member) }
let(:harvest) { FactoryBot.create(:harvest, owner: member) }
let(:member) { FactoryBot.create(:member) }
let!(:auth) { FactoryBot.create(:flickr_authentication, member: member) }
let!(:auth) { FactoryBot.create(:flickr_authentication, member:) }
before do
sign_in member
@@ -98,7 +98,7 @@ describe PhotosController, :search do
let(:member) { FactoryBot.create(:member) }
let(:garden) { FactoryBot.create(:garden, owner: member) }
let(:planting) { FactoryBot.create(:planting, garden: garden, owner: member) }
let(:planting) { FactoryBot.create(:planting, garden:, owner: member) }
let(:harvest) { FactoryBot.create(:harvest, owner: member) }
let(:photo) { FactoryBot.create(:photo, owner: member) }
@@ -173,7 +173,7 @@ describe PhotosController, :search do
before { controller.stub(:current_member) { member } }
describe "creates the planting/photo link" do
let(:planting) { FactoryBot.create(:planting, garden: garden, owner: member) }
let(:planting) { FactoryBot.create(:planting, garden:, owner: member) }
let(:photo) { FactoryBot.create(:photo, owner: member) }
before { post :create, params: { photo: { source_id: photo.source_id, source: 'flickr' }, type: "planting", id: planting.id } }
it { expect(flash[:alert]).not_to be_present }
+1 -1
View File
@@ -26,7 +26,7 @@ describe SeedsController, :search do
end
context 'with parent planting' do
let!(:planting) { FactoryBot.create :planting, owner: owner }
let!(:planting) { FactoryBot.create :planting, owner: }
before do
Seed.reindex
+1 -1
View File
@@ -3,7 +3,7 @@
FactoryBot.define do
factory :planting do
owner
garden { FactoryBot.create :garden, owner: owner }
garden { FactoryBot.create :garden, owner: }
crop
planted_at { Time.zone.local(2014, 7, 30) }
quantity { 33 }
+1 -1
View File
@@ -6,7 +6,7 @@ FactoryBot.define do
factory :role do
name { "Moderator" }
description { "These people moderate the forums" }
initialize_with { Role.find_or_create_by(name: name) }
initialize_with { Role.find_or_create_by(name:) }
factory :admin do
name { "admin" }
@@ -18,7 +18,7 @@ describe 'Commenting on a post' do
end
context "editing a comment" do
let(:existing_comment) { create :comment, post: post, author: member }
let(:existing_comment) { create :comment, post:, author: member }
before do
visit edit_comment_path existing_comment
+8 -8
View File
@@ -84,7 +84,7 @@ describe "crop detail page", js: true do
end
context "seed quantity for a crop" do
let(:seed) { create :seed, crop: crop, quantity: 20 }
let(:seed) { create :seed, crop:, quantity: 20 }
it "User not signed in" do
visit crop_path(seed.crop)
@@ -110,14 +110,14 @@ describe "crop detail page", js: true do
describe 'with harvest history data' do
before do
# 50 days to harvest
FactoryBot.create(:harvest, harvested_at: 150.days.ago, crop: crop,
planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop))
FactoryBot.create(:harvest, harvested_at: 150.days.ago, crop:,
planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop:))
# 20 days to harvest
FactoryBot.create(:harvest, harvested_at: 180.days.ago, crop: crop,
planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop))
FactoryBot.create(:harvest, harvested_at: 180.days.ago, crop:,
planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop:))
# 10 days to harvest
FactoryBot.create(:harvest, harvested_at: 190.days.ago, crop: crop,
planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop))
FactoryBot.create(:harvest, harvested_at: 190.days.ago, crop:,
planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop:))
crop.update_medians
end
@@ -129,7 +129,7 @@ describe "crop detail page", js: true do
context 'predictions' do
let!(:planting) do
FactoryBot.create(:planting, crop: crop,
FactoryBot.create(:planting, crop:,
planted_at: 100.days.ago,
finished_at: 1.day.ago)
end
+3 -3
View File
@@ -11,9 +11,9 @@ describe "crop detail page", :js, :search do
let(:plant_part) { FactoryBot.create :plant_part, name: 'fruit' }
let!(:harvest) { FactoryBot.create :harvest, crop: crop, owner: owner_member, plant_part: plant_part }
let!(:planting) { FactoryBot.create :planting, crop: crop, owner: owner_member }
let!(:seed) { FactoryBot.create :seed, crop: crop, owner: owner_member }
let!(:harvest) { FactoryBot.create :harvest, crop:, owner: owner_member, plant_part: }
let!(:planting) { FactoryBot.create :planting, crop:, owner: owner_member }
let!(:seed) { FactoryBot.create :seed, crop:, owner: owner_member }
let!(:photo1) { FactoryBot.create(:photo, owner: owner_member) }
let!(:photo2) { FactoryBot.create(:photo, owner: owner_member) }
+4 -4
View File
@@ -7,9 +7,9 @@ describe "Planting a crop", js: true do
include_context 'signed in member'
# name is aaa to ensure it is ordered first
let!(:garden) { create :garden, name: 'aaa', owner: member }
let!(:planting) { create :planting, garden: garden, owner: garden.owner, planted_at: Date.parse("2013-3-10") }
let!(:tomato) { create :tomato }
let!(:finished_planting) { create :finished_planting, owner: garden.owner, garden: garden, crop: tomato }
let!(:planting) { create :planting, garden:, owner: garden.owner, planted_at: Date.parse("2013-3-10") }
let!(:tomato) { create :tomato }
let!(:finished_planting) { create :finished_planting, owner: garden.owner, garden:, crop: tomato }
it "View gardens" do
visit gardens_path
@@ -75,7 +75,7 @@ describe "Planting a crop", js: true do
context 'When a garden has a garden type' do
let(:garden_type) { create :garden_type }
let(:garden_with_type) { create :garden, garden_type: garden_type }
let(:garden_with_type) { create :garden, garden_type: }
it "Shows a garden type for a garden" do
visit garden_path(garden_with_type)
+8 -8
View File
@@ -80,9 +80,9 @@ describe "Gardens#index", :js do
# time to finished = 90 days
FactoryBot.create(:harvest,
harvested_at: 50.days.ago,
crop: crop,
crop:,
planting: FactoryBot.create(:planting,
crop: crop,
crop:,
planted_at: 100.days.ago,
finished_at: 10.days.ago))
crop.plantings.each(&:update_harvest_days!)
@@ -97,9 +97,9 @@ describe "Gardens#index", :js do
describe 'harvest still growing' do
let!(:planting) do
FactoryBot.create :planting,
crop: crop,
crop:,
owner: member,
garden: garden,
garden:,
planted_at: Time.zone.today
end
@@ -112,8 +112,8 @@ describe "Gardens#index", :js do
describe 'harvesting now' do
let!(:planting) do
FactoryBot.create :planting,
crop: crop,
owner: member, garden: garden,
crop:,
owner: member, garden:,
planted_at: 51.days.ago
end
@@ -127,8 +127,8 @@ describe "Gardens#index", :js do
describe 'super late' do
let!(:planting) do
FactoryBot.create :planting,
crop: crop, owner: member,
garden: garden, planted_at: 260.days.ago
crop:, owner: member,
garden:, planted_at: 260.days.ago
end
it { expect(page).to have_text 'super late' }
+3 -3
View File
@@ -10,9 +10,9 @@ describe "home page", :search do
let(:photo) { FactoryBot.create :photo, owner: member }
let(:crop) { FactoryBot.create :crop, created_at: 1.day.ago }
let(:planting) { FactoryBot.create :planting, owner: member, crop: crop }
let(:seed) { FactoryBot.create :tradable_seed, owner: member, crop: crop }
let(:harvest) { FactoryBot.create :harvest, owner: member, crop: crop }
let(:planting) { FactoryBot.create :planting, owner: member, crop: }
let(:seed) { FactoryBot.create :tradable_seed, owner: member, crop: }
let(:harvest) { FactoryBot.create :harvest, owner: member, crop: }
let!(:tradable_seed) { FactoryBot.create :tradable_seed, :reindex, finished: false }
let!(:finished_seed) { FactoryBot.create :tradable_seed, :reindex, finished: true }
+1 -1
View File
@@ -61,7 +61,7 @@ describe 'Likeable', :js, search: true do
end
describe 'crops#show' do
let(:crop) { FactoryBot.create :crop }
let(:planting) { FactoryBot.create :planting, owner: member, crop: crop }
let(:planting) { FactoryBot.create :planting, owner: member, crop: }
let(:path) { crop_path(crop) }
before { planting.photos << photo }
include_examples 'photo can be liked'
+6 -6
View File
@@ -137,7 +137,7 @@ describe "member profile", js: true do
context 'member has comments' do
let(:post) { FactoryBot.create :post }
let!(:comment) { FactoryBot.create :comment, post: post, author: member }
let!(:comment) { FactoryBot.create :comment, post:, author: member }
before { visit member_path(member) }
it { expect(page).to have_link href: post_path(post) }
it { expect(page).to have_link href: comment_path(comment) }
@@ -158,9 +158,9 @@ describe "member profile", js: true do
# time to finished = 90 days
FactoryBot.create(:harvest,
harvested_at: 50.days.ago,
crop: crop,
crop:,
planting: FactoryBot.create(:planting,
crop: crop,
crop:,
planted_at: 100.days.ago,
finished_at: 10.days.ago))
crop.plantings.each(&:update_harvest_days!)
@@ -176,21 +176,21 @@ describe "member profile", js: true do
let(:growing_planting) do
FactoryBot.create :planting,
crop: crop,
crop:,
owner: member,
planted_at: Time.zone.today
end
let(:harvesting_planting) do
FactoryBot.create :planting,
crop: crop,
crop:,
owner: member,
planted_at: 51.days.ago
end
let(:super_late_planting) do
FactoryBot.create :planting,
crop: crop, owner: member,
crop:, owner: member,
planted_at: 260.days.ago
end
+4 -4
View File
@@ -82,7 +82,7 @@ rest of the garden.
crop.reindex
owner = FactoryBot.create :interesting_member, login_name: crop_type.to_s.reverse, email: "#{crop.name}@example.com"
planting = FactoryBot.create :planting, crop: crop, owner: owner, garden: owner.gardens.first
photo = FactoryBot.create(:photo, owner: owner,
photo = FactoryBot.create(:photo, owner:,
thumbnail_url: "#{photo_url}_q.jpg", fullsize_url: "#{photo_url}_z.jpg")
planting.photos << photo
@@ -114,7 +114,7 @@ rest of the garden.
FactoryBot.create(:harvest,
crop: tomato,
plant_part: FactoryBot.create(:plant_part, name: 'berry'),
planting: planting,
planting:,
harvested_at: 1.day.ago)
post = FactoryBot.create :post, subject: 'tomatoes are delicious'
@@ -155,7 +155,7 @@ rest of the garden.
# with some lettuce (finished)
FactoryBot.create(
:planting, crop: FactoryBot.create(:crop, name: 'lettuce'),
garden: garden, owner: member, finished_at: 2.weeks.ago
garden:, owner: member, finished_at: 2.weeks.ago
)
# tomato still growing
tomato_planting = FactoryBot.create :planting, garden: garden, owner: member, crop: tomato
@@ -194,7 +194,7 @@ rest of the garden.
FactoryBot.create_list :post, 12, author: member
end
Post.all.order(id: :desc).limit(4) do |post|
FactoryBot.create_list :comment, rand(1..5), post: post
FactoryBot.create_list :comment, rand(1..5), post:
end
visit posts_path
page.percy_snapshot(page, name: "#{prefix}/posts#index")
@@ -7,7 +7,7 @@ describe "User searches" do
let!(:maize) { create :maize }
let(:garden) { create :garden, owner: located_member }
let!(:seed1) { create :seed, owner: located_member }
let!(:planting) { create :planting, garden: garden, owner: located_member, planted_at: Date.parse("2013-3-10") }
let!(:planting) { create :planting, garden:, owner: located_member, planted_at: Date.parse("2013-3-10") }
describe "with a valid place" do
before do
@@ -7,7 +7,7 @@ describe "Planting a crop", :js, :search do
let!(:maize) { FactoryBot.create :maize }
let(:garden) { FactoryBot.create :garden, owner: member, name: 'Orchard' }
let!(:planting) do
FactoryBot.create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-03-10")
FactoryBot.create :planting, garden:, owner: member, planted_at: Date.parse("2013-03-10")
end
before { Planting.reindex }
+3 -3
View File
@@ -6,7 +6,7 @@ describe "Display a planting", :js do
describe 'planting perennial' do
let(:garden) { FactoryBot.create :garden, location: 'Edinburgh' }
let(:crop) { FactoryBot.create(:crop, name: 'feijoa', perennial: true) }
let(:planting) { FactoryBot.create :planting, crop: crop, garden: garden, owner: garden.owner }
let(:planting) { FactoryBot.create :planting, crop:, garden:, owner: garden.owner }
describe 'no harvest to predict from' do
before { visit planting_path(planting) }
@@ -18,7 +18,7 @@ describe "Display a planting", :js do
before do
FactoryBot.create :harvest, planting: planting, crop: crop, harvested_at: '1 May 2019'
FactoryBot.create :harvest, planting: planting, crop: crop, harvested_at: '18 June 2019'
FactoryBot.create_list :harvest, 4, planting: planting, crop: crop, harvested_at: '18 August 2019'
FactoryBot.create_list :harvest, 4, planting:, crop:, harvested_at: '18 August 2019'
end
before { visit planting_path(planting) }
it { expect(page.find("#month-1")[:class]).not_to include("badge-harvesting") }
@@ -48,7 +48,7 @@ describe "Display a planting", :js do
faraway_planting = FactoryBot.create :planting, garden: faraway_garden, crop: crop,
owner: faraway_garden.owner, planted_at: '16 May 2001'
FactoryBot.create_list :harvest, 4, planting: faraway_planting, crop: crop,
FactoryBot.create_list :harvest, 4, planting: faraway_planting, crop:,
harvested_at: '18 December 2006'
end
before { visit planting_path(planting) }
+7 -7
View File
@@ -44,17 +44,17 @@ describe "Display a planting", :js do
let(:planting) do
crop = FactoryBot.create :annual_crop
# 50 days to harvest
FactoryBot.create(:harvest, harvested_at: 150.days.ago, crop: crop,
planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop))
FactoryBot.create(:harvest, harvested_at: 150.days.ago, crop:,
planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop:))
# 20 days to harvest
FactoryBot.create(:harvest, harvested_at: 180.days.ago, crop: crop,
planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop))
FactoryBot.create(:harvest, harvested_at: 180.days.ago, crop:,
planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop:))
# 10 days to harvest
FactoryBot.create(:harvest, harvested_at: 190.days.ago, crop: crop,
planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop))
FactoryBot.create(:harvest, harvested_at: 190.days.ago, crop:,
planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop:))
crop.update_medians
FactoryBot.create :annual_planting, planted_at: 200.days.ago, crop: crop
FactoryBot.create :annual_planting, planted_at: 200.days.ago, crop:
end
it { expect(page).to have_text 'First harvest expected' }
end
+2 -2
View File
@@ -48,7 +48,7 @@ describe ApplicationHelper do
context 'with a populated collection' do
context 'with one element' do
before { create(:comment, post: post) }
before { create(:comment, post:) }
it 'returns a string with the quantity and the plural of the model' do
expect(localize_plural(post.comments, Comment)).to eq '1 comment'
@@ -56,7 +56,7 @@ describe ApplicationHelper do
end
context 'with more than one element' do
before { create_list(:comment, 2, post: post) }
before { create_list(:comment, 2, post:) }
it 'returns a string with the quantity and the plural of the model' do
expect(localize_plural(post.comments, Comment)).to eq '2 comments'
+1 -1
View File
@@ -41,7 +41,7 @@ describe GardensHelper do
it "has 1 planting" do
crop = FactoryBot.create(:crop)
plantings = [FactoryBot.create(:planting, quantity: 10, crop: crop)]
plantings = [FactoryBot.create(:planting, quantity: 10, crop:)]
result = helper.display_garden_plantings(plantings)
output = '<ul class="plantings"><li>'
+3 -3
View File
@@ -8,11 +8,11 @@ describe PhotosHelper do
let(:crop_photo_flickr) { FactoryBot.create(:photo, source: 'flickr') }
let(:garden) { FactoryBot.create :garden }
let(:planting) { FactoryBot.create :planting, crop: crop, owner: garden.owner }
let(:planting) { FactoryBot.create :planting, crop:, owner: garden.owner }
let(:planting_photo) { FactoryBot.create(:photo, owner: garden.owner) }
let(:harvest) { FactoryBot.create :harvest, crop: crop, owner: garden.owner }
let(:harvest) { FactoryBot.create :harvest, crop:, owner: garden.owner }
let(:harvest_photo) { FactoryBot.create(:photo, owner: garden.owner) }
let(:seed) { FactoryBot.create :seed, crop: crop, owner: garden.owner }
let(:seed) { FactoryBot.create :seed, crop:, owner: garden.owner }
let(:seed_photo) { FactoryBot.create(:photo, owner: garden.owner) }
describe "crops" do
+1 -1
View File
@@ -107,7 +107,7 @@ describe Ability do
end
it "can't delete a plant part that has harvests" do
@harvest = FactoryBot.create(:harvest, plant_part: plant_part)
@harvest = FactoryBot.create(:harvest, plant_part:)
ability.should_not be_able_to(:destroy, plant_part)
end
end
+1 -1
View File
@@ -22,7 +22,7 @@ describe AlternateName do
end
describe 'relationships' do
let(:alternate_name) { FactoryBot.create :alternate_name, crop: crop, creator: member }
let(:alternate_name) { FactoryBot.create :alternate_name, crop:, creator: member }
let(:crop) { FactoryBot.create :crop }
let(:member) { FactoryBot.create :member }
+34 -34
View File
@@ -147,7 +147,7 @@ describe Crop do
context 'with a planting photo' do
let!(:photo) { FactoryBot.create(:photo, owner: planting.owner) }
let!(:planting) { FactoryBot.create(:planting, crop: crop) }
let!(:planting) { FactoryBot.create(:planting, crop:) }
before { planting.photos << photo }
@@ -156,7 +156,7 @@ describe Crop do
end
context 'with a harvest photo' do
let!(:harvest) { FactoryBot.create(:harvest, crop: crop) }
let!(:harvest) { FactoryBot.create(:harvest, crop:) }
let!(:photo) { FactoryBot.create(:photo, owner: harvest.owner) }
before { harvest.photos << photo }
@@ -165,7 +165,7 @@ describe Crop do
include_examples 'has default photo'
context 'and planting photo' do
let(:planting) { FactoryBot.create(:planting, crop: crop) }
let(:planting) { FactoryBot.create(:planting, crop:) }
let!(:planting_photo) { FactoryBot.create(:photo, owner: planting.owner) }
before { planting.photos << planting_photo }
@@ -188,9 +188,9 @@ describe Crop do
end
describe 'finding all photos' do
let(:planting) { FactoryBot.create :planting, crop: crop }
let(:harvest) { FactoryBot.create :harvest, crop: crop }
let(:seed) { FactoryBot.create :seed, crop: crop }
let(:planting) { FactoryBot.create :planting, crop: }
let(:harvest) { FactoryBot.create :harvest, crop: }
let(:seed) { FactoryBot.create :seed, crop: }
before do
# Add photos to all
@@ -210,25 +210,25 @@ describe Crop do
let(:crop) { FactoryBot.create(:tomato) }
it 'returns a hash of sunniness values' do
FactoryBot.create(:sunny_planting, crop: crop)
FactoryBot.create(:sunny_planting, crop: crop)
FactoryBot.create(:semi_shady_planting, crop: crop)
FactoryBot.create(:shady_planting, crop: crop)
FactoryBot.create(:sunny_planting, crop:)
FactoryBot.create(:sunny_planting, crop:)
FactoryBot.create(:semi_shady_planting, crop:)
FactoryBot.create(:shady_planting, crop:)
crop.sunniness.should be_an_instance_of Hash
end
it 'counts each sunniness value' do
FactoryBot.create(:sunny_planting, crop: crop)
FactoryBot.create(:sunny_planting, crop: crop)
FactoryBot.create(:semi_shady_planting, crop: crop)
FactoryBot.create(:shady_planting, crop: crop)
FactoryBot.create(:sunny_planting, crop:)
FactoryBot.create(:sunny_planting, crop:)
FactoryBot.create(:semi_shady_planting, crop:)
FactoryBot.create(:shady_planting, crop:)
crop.sunniness.should == { 'sun' => 2, 'shade' => 1, 'semi-shade' => 1 }
end
it 'ignores unused sunniness values' do
FactoryBot.create(:sunny_planting, crop: crop)
FactoryBot.create(:sunny_planting, crop: crop)
FactoryBot.create(:semi_shady_planting, crop: crop)
FactoryBot.create(:sunny_planting, crop:)
FactoryBot.create(:sunny_planting, crop:)
FactoryBot.create(:semi_shady_planting, crop:)
crop.sunniness.should == { 'sun' => 2, 'semi-shade' => 1 }
end
end
@@ -237,25 +237,25 @@ describe Crop do
let(:crop) { FactoryBot.create(:tomato) }
it 'returns a hash of sunniness values' do
FactoryBot.create(:seed_planting, crop: crop)
FactoryBot.create(:seed_planting, crop: crop)
FactoryBot.create(:seedling_planting, crop: crop)
FactoryBot.create(:cutting_planting, crop: crop)
FactoryBot.create(:seed_planting, crop:)
FactoryBot.create(:seed_planting, crop:)
FactoryBot.create(:seedling_planting, crop:)
FactoryBot.create(:cutting_planting, crop:)
crop.planted_from.should be_an_instance_of Hash
end
it 'counts each planted_from value' do
FactoryBot.create(:seed_planting, crop: crop)
FactoryBot.create(:seed_planting, crop: crop)
FactoryBot.create(:seedling_planting, crop: crop)
FactoryBot.create(:cutting_planting, crop: crop)
FactoryBot.create(:seed_planting, crop:)
FactoryBot.create(:seed_planting, crop:)
FactoryBot.create(:seedling_planting, crop:)
FactoryBot.create(:cutting_planting, crop:)
crop.planted_from.should == { 'seed' => 2, 'seedling' => 1, 'cutting' => 1 }
end
it 'ignores unused planted_from values' do
FactoryBot.create(:seed_planting, crop: crop)
FactoryBot.create(:seed_planting, crop: crop)
FactoryBot.create(:seedling_planting, crop: crop)
FactoryBot.create(:seed_planting, crop:)
FactoryBot.create(:seed_planting, crop:)
FactoryBot.create(:seedling_planting, crop:)
crop.planted_from.should == { 'seed' => 2, 'seedling' => 1 }
end
end
@@ -273,16 +273,16 @@ describe Crop do
@root = FactoryBot.create(:plant_part, name: 'root')
@bulb = FactoryBot.create(:plant_part, name: 'bulb')
@harvest1 = FactoryBot.create(:harvest,
crop: crop,
crop:,
plant_part: @fruit)
@harvest2 = FactoryBot.create(:harvest,
crop: crop,
crop:,
plant_part: @fruit)
@harvest3 = FactoryBot.create(:harvest,
crop: crop,
crop:,
plant_part: @seed)
@harvest4 = FactoryBot.create(:harvest,
crop: crop,
crop:,
plant_part: @root)
crop.popular_plant_parts.should == { [@fruit.id, @fruit.name] => 2,
[@seed.id, @seed.name] => 1,
@@ -346,8 +346,8 @@ describe Crop do
end
context "harvests" do
let!(:crop) { FactoryBot.create(:crop) }
let!(:harvest) { FactoryBot.create(:harvest, crop: crop) }
let!(:crop) { FactoryBot.create(:crop) }
let!(:harvest) { FactoryBot.create(:harvest, crop:) }
it "has harvests" do
expect(crop.harvests).to eq [harvest]
+2 -2
View File
@@ -18,8 +18,8 @@ describe Forum do
end
it "has many posts" do
@post1 = FactoryBot.create(:forum_post, forum: forum)
@post2 = FactoryBot.create(:forum_post, forum: forum)
@post1 = FactoryBot.create(:forum_post, forum:)
@post2 = FactoryBot.create(:forum_post, forum:)
forum.posts.size.should == 2
end
end
+7 -7
View File
@@ -3,8 +3,8 @@
require 'rails_helper'
describe Garden do
let(:owner) { FactoryBot.create(:member, login_name: 'hatupatu') }
let(:garden) { FactoryBot.create(:garden, owner: owner, name: 'Springfield Community Garden') }
let(:owner) { FactoryBot.create(:member, login_name: 'hatupatu') }
let(:garden) { FactoryBot.create(:garden, owner:, name: 'Springfield Community Garden') }
it "has a slug" do
garden.slug.should match(/hatupatu-springfield-community-garden/)
@@ -63,9 +63,9 @@ describe Garden do
end
it "destroys plantings when deleted" do
garden = FactoryBot.create(:garden, owner: owner)
@planting1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner)
@planting2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner)
garden = FactoryBot.create(:garden, owner:)
@planting1 = FactoryBot.create(:planting, garden:, owner: garden.owner)
@planting2 = FactoryBot.create(:planting, garden:, owner: garden.owner)
expect(garden.plantings.size).to eq(2)
all = Planting.count
garden.destroy
@@ -146,8 +146,8 @@ describe Garden do
it "marks plantings as finished when garden is inactive" do
garden = FactoryBot.create(:garden)
p1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner)
p2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner)
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
+1 -1
View File
@@ -30,7 +30,7 @@ describe GardenType do
end
describe "does not delete gardens when deleted" do
before { FactoryBot.create :garden, garden_type: garden_type }
before { FactoryBot.create :garden, garden_type: }
let(:garden_type) { FactoryBot.create(:garden_type, name: "Massive Flower Pot") }
+8 -8
View File
@@ -152,7 +152,7 @@ describe Harvest do
let(:crop) { FactoryBot.create(:crop, name: "apricot") }
it "apricots" do
@h = FactoryBot.create(:harvest, crop: crop,
@h = FactoryBot.create(:harvest, crop:,
quantity: nil,
unit: nil,
weight_quantity: nil,
@@ -161,7 +161,7 @@ describe Harvest do
end
it "1 individual apricot" do
@h = FactoryBot.create(:harvest, crop: crop,
@h = FactoryBot.create(:harvest, crop:,
quantity: 1,
unit: 'individual',
weight_quantity: nil,
@@ -170,7 +170,7 @@ describe Harvest do
end
it "10 individual apricots" do
@h = FactoryBot.create(:harvest, crop: crop,
@h = FactoryBot.create(:harvest, crop:,
quantity: 10,
unit: 'individual',
weight_quantity: nil,
@@ -179,7 +179,7 @@ describe Harvest do
end
it "1 bushel of apricots" do
@h = FactoryBot.create(:harvest, crop: crop,
@h = FactoryBot.create(:harvest, crop:,
quantity: 1,
unit: 'bushel',
weight_quantity: nil,
@@ -188,7 +188,7 @@ describe Harvest do
end
it "1.5 bushels of apricots" do
@h = FactoryBot.create(:harvest, crop: crop,
@h = FactoryBot.create(:harvest, crop:,
quantity: 1.5,
unit: 'bushel',
weight_quantity: nil,
@@ -197,7 +197,7 @@ describe Harvest do
end
it "10 bushels of apricots" do
@h = FactoryBot.create(:harvest, crop: crop,
@h = FactoryBot.create(:harvest, crop:,
quantity: 10,
unit: 'bushel',
weight_quantity: nil,
@@ -206,7 +206,7 @@ describe Harvest do
end
it "apricots weighing 1.2 kg" do
@h = FactoryBot.create(:harvest, crop: crop,
@h = FactoryBot.create(:harvest, crop:,
quantity: nil,
unit: nil,
weight_quantity: 1.2,
@@ -215,7 +215,7 @@ describe Harvest do
end
it "10 bushels of apricots weighing 100 kg" do
@h = FactoryBot.create(:harvest, crop: crop,
@h = FactoryBot.create(:harvest, crop:,
quantity: 10,
unit: 'bushel',
weight_quantity: 100,
+8 -8
View File
@@ -9,7 +9,7 @@ describe 'like' do
context 'existing like' do
before do
@like = Like.create(member: member, likeable: post)
@like = Like.create(member:, likeable: post)
end
it 'is valid' do
@@ -40,36 +40,36 @@ describe 'like' do
end
it 'does not allow duplicate likes by the same member' do
Like.create(member: member, likeable: post)
second_like = Like.new(member: member, likeable: post)
Like.create(member:, likeable: post)
second_like = Like.new(member:, likeable: post)
expect(second_like).not_to be_valid
end
it 'destroys like if post no longer exists' do
like = Like.create(member: member, likeable: post)
like = Like.create(member:, likeable: post)
post.destroy
expect(Like.all).not_to include like
end
it 'destroys like if post no longer exists' do
like = Like.create(member: member, likeable: post)
like = Like.create(member:, likeable: post)
post.destroy
expect(Like.all).not_to include like
end
it 'destroys like if member no longer exists' do
like = Like.create(member: member, likeable: post)
like = Like.create(member:, likeable: post)
member.destroy
expect(Like.all).not_to include like
end
it 'liked_by_members_names' do
expect(post.liked_by_members_names).to eq []
Like.create(member: member, likeable: post)
Like.create(member:, likeable: post)
expect(post.liked_by_members_names).to eq [member.login_name]
expect(photo.liked_by_members_names).to eq []
Like.create(member: member, likeable: photo)
Like.create(member:, likeable: photo)
expect(photo.liked_by_members_names).to eq [member.login_name]
end
end
+2 -2
View File
@@ -63,8 +63,8 @@ describe 'member' do
it "has many likes" do
@post1 = FactoryBot.create(:post, author: member)
@post2 = FactoryBot.create(:post, author: member)
@like1 = FactoryBot.create(:like, member: member, likeable: @post1)
@like2 = FactoryBot.create(:like, member: member, likeable: @post2)
@like1 = FactoryBot.create(:like, member:, likeable: @post1)
@like2 = FactoryBot.create(:like, member:, likeable: @post2)
expect(member.likes.length).to eq 2
end
+10 -10
View File
@@ -6,7 +6,7 @@ describe Planting do
let(:crop) { FactoryBot.create(:tomato) }
let(:garden_owner) { FactoryBot.create(:member, login_name: 'hatupatu') }
let(:garden) { FactoryBot.create(:garden, owner: garden_owner, name: 'Springfield Community Garden') }
let(:planting) { FactoryBot.create(:planting, crop: crop, garden: garden, owner: garden.owner) }
let(:planting) { FactoryBot.create(:planting, crop:, garden:, owner: garden.owner) }
describe 'planting lifespan predictions' do
context 'no predications data yet' do
@@ -121,7 +121,7 @@ describe Planting do
# this is a method so it creates a new one each time
def one_hundred_day_old_planting
FactoryBot.create(:planting, crop: crop, planted_at: 100.days.ago)
FactoryBot.create(:planting, crop:, planted_at: 100.days.ago)
end
before do
# 50 days to harvest
@@ -141,20 +141,20 @@ describe Planting do
it { expect(crop.median_days_to_first_harvest).to eq(20) }
describe 'sets median time to harvest' do
let(:planting) { FactoryBot.create :planting, crop: crop, planted_at: Time.zone.today }
let(:planting) { FactoryBot.create :planting, crop:, planted_at: Time.zone.today }
it { expect(planting.first_harvest_predicted_at).to eq(Time.zone.today + 20.days) }
end
describe 'harvest still growing' do
let(:planting) { FactoryBot.create :planting, crop: crop, planted_at: Time.zone.today }
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 }
end
describe 'harvesting ready now' do
let(:planting) { FactoryBot.create :planting, crop: crop, planted_at: 21.days.ago }
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 }
@@ -179,7 +179,7 @@ describe Planting do
before do
FactoryBot.create(:harvest,
planting: planting,
planting:,
crop: planting.crop,
harvested_at: 10.days.ago)
planting.update_harvest_days!
@@ -220,7 +220,7 @@ describe Planting do
before do
FactoryBot.create :harvest, planting: planting, crop: crop, harvested_at: '1 May 2019'
FactoryBot.create :harvest, planting: planting, crop: crop, harvested_at: '18 June 2019'
FactoryBot.create_list :harvest, 4, planting: planting, crop: crop, harvested_at: '18 August 2019'
FactoryBot.create_list :harvest, 4, planting:, crop:, harvested_at: '18 August 2019'
end
it { expect(planting.harvest_months).to eq(5 => 1, 6 => 1, 8 => 4) }
end
@@ -233,7 +233,7 @@ describe Planting do
# Near by planting with harvests
nearby_garden = FactoryBot.create :garden, location: 'Greenwich, UK'
nearby_planting = FactoryBot.create(:planting,
crop: crop,
crop:,
garden: nearby_garden,
owner: nearby_garden.owner,
planted_at: '1 January 2000')
@@ -249,7 +249,7 @@ describe Planting do
faraway_planting = FactoryBot.create :planting, garden: faraway_garden, crop: crop,
owner: faraway_garden.owner, planted_at: '16 May 2001'
FactoryBot.create_list :harvest, 4, planting: faraway_planting, crop: crop,
FactoryBot.create_list :harvest, 4, planting: faraway_planting, crop:,
harvested_at: '18 December 2006'
end
it { expect(planting.harvest_months).to eq(5 => 1, 6 => 1, 8 => 4) }
@@ -513,7 +513,7 @@ describe Planting do
context 'ancestry' do
let(:parent_seed) { FactoryBot.create :seed }
let(:planting) { FactoryBot.create :planting, parent_seed: parent_seed }
let(:planting) { FactoryBot.create :planting, parent_seed: }
it "planting has a parent seed" do
expect(planting.parent_seed).to eq(parent_seed)
+8 -8
View File
@@ -19,22 +19,22 @@ describe Post do
it "has many comments" do
post = FactoryBot.create(:post, author: member)
FactoryBot.create(:comment, post: post)
FactoryBot.create(:comment, post: post)
FactoryBot.create(:comment, post:)
FactoryBot.create(:comment, post:)
post.comments.size.should == 2
end
it "supports counting comments" do
post = FactoryBot.create(:post, author: member)
FactoryBot.create(:comment, post: post)
FactoryBot.create(:comment, post: post)
FactoryBot.create(:comment, post:)
FactoryBot.create(:comment, post:)
post.comment_count.should == 2
end
it "destroys comments when deleted" do
post = FactoryBot.create(:post, author: member)
FactoryBot.create(:comment, post: post)
FactoryBot.create(:comment, post: post)
FactoryBot.create(:comment, post:)
FactoryBot.create(:comment, post:)
post.comments.size.should eq(2)
all = Comment.count
post.destroy
@@ -73,7 +73,7 @@ describe Post do
end
it "sets recent activity to comment time" do
comment = FactoryBot.create(:comment, post: post,
comment = FactoryBot.create(:comment, post:,
created_at: 1.hour.ago)
post.recent_activity.to_i.should eq comment.created_at.to_i
end
@@ -88,7 +88,7 @@ describe Post do
it "new comment on old post is recently active" do
# now comment on an older post
post2 = FactoryBot.create(:post, created_at: 1.minute.ago)
FactoryBot.create(:comment, post: post, created_at: 1.second.ago)
FactoryBot.create(:comment, post:, created_at: 1.second.ago)
described_class.recently_active.first.should eq post
described_class.recently_active.second.should eq post2
end
+3 -3
View File
@@ -4,7 +4,7 @@ require 'rails_helper'
describe Seed do
let(:owner) { FactoryBot.create :owner, login_name: 'tamateapokaiwhenua' }
let(:seed) { FactoryBot.build(:seed, owner: owner) }
let(:seed) { FactoryBot.build(:seed, owner:) }
it 'saves a basic seed' do
seed.save.should be(true)
@@ -163,8 +163,8 @@ describe Seed do
end
context 'ancestry' do
let(:parent_planting) { FactoryBot.create :planting }
let(:seed) { FactoryBot.create :seed, parent_planting: parent_planting, owner: parent_planting.owner }
let(:parent_planting) { FactoryBot.create :planting }
let(:seed) { FactoryBot.create :seed, parent_planting:, owner: parent_planting.owner }
it "seed has a parent planting" do
expect(seed.parent_planting).to eq(parent_planting)
+5 -5
View File
@@ -66,13 +66,13 @@ RSpec.describe 'Crops', type: :request do
end
describe '#index' do
before { get '/api/v1/crops', params: {}, headers: headers }
before { get '/api/v1/crops', params: {}, headers: }
it { expect(subject['data']).to include(crop_encoded_as_json_api) }
end
describe '#show' do
before { get "/api/v1/crops/#{crop.id}", params: {}, headers: headers }
before { get "/api/v1/crops/#{crop.id}", params: {}, headers: }
it { expect(subject['data']['attributes']).to eq(attributes) }
it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) }
@@ -85,19 +85,19 @@ RSpec.describe 'Crops', type: :request do
it '#create' do
expect do
post '/api/v1/crops', params: { 'crop' => { 'name' => 'can i make this' } }, headers: headers
post '/api/v1/crops', params: { 'crop' => { 'name' => 'can i make this' } }, headers:
end.to raise_error ActionController::RoutingError
end
it '#update' do
expect do
post "/api/v1/crops/#{crop.id}", params: { 'crop' => { 'name' => 'can i modify this' } }, headers: headers
post "/api/v1/crops/#{crop.id}", params: { 'crop' => { 'name' => 'can i modify this' } }, headers:
end.to raise_error ActionController::RoutingError
end
it '#delete' do
expect do
delete "/api/v1/crops/#{crop.id}", params: {}, headers: headers
delete "/api/v1/crops/#{crop.id}", params: {}, headers:
end.to raise_error ActionController::RoutingError
end
end
+3 -3
View File
@@ -52,19 +52,19 @@ RSpec.describe 'Gardens', type: :request do
it '#create' do
expect do
post '/api/v1/gardens', params: { 'garden' => { 'name' => 'can i make this' } }, headers: headers
post '/api/v1/gardens', params: { 'garden' => { 'name' => 'can i make this' } }, headers:
end.to raise_error ActionController::RoutingError
end
it '#update' do
expect do
post "/api/v1/gardens/#{garden.id}", params: { 'garden' => { 'name' => 'can i modify this' } }, headers: headers
post "/api/v1/gardens/#{garden.id}", params: { 'garden' => { 'name' => 'can i modify this' } }, headers:
end.to raise_error ActionController::RoutingError
end
it '#delete' do
expect do
delete "/api/v1/gardens/#{garden.id}", params: {}, headers: headers
delete "/api/v1/gardens/#{garden.id}", params: {}, headers:
end.to raise_error ActionController::RoutingError
end
end
+5 -5
View File
@@ -60,13 +60,13 @@ RSpec.describe 'Harvests', type: :request do
end
describe '#index' do
before { get '/api/v1/harvests', params: {}, headers: headers }
before { get '/api/v1/harvests', params: {}, headers: }
it { expect(subject['data']).to include(harvest_encoded_as_json_api) }
end
describe '#show' do
before { get "/api/v1/harvests/#{harvest.id}", params: {}, headers: headers }
before { get "/api/v1/harvests/#{harvest.id}", params: {}, headers: }
it { expect(subject['data']['attributes']).to eq(attributes) }
it { expect(subject['data']['relationships']).to include("planting" => planting_as_json_api) }
@@ -78,7 +78,7 @@ RSpec.describe 'Harvests', type: :request do
it '#create' do
expect do
put '/api/v1/harvests', headers: headers, params: {
put '/api/v1/harvests', headers:, params: {
'harvest' => { 'description' => 'can i make this' }
}
end.to raise_error ActionController::RoutingError
@@ -86,7 +86,7 @@ RSpec.describe 'Harvests', type: :request do
it '#update' do
expect do
post "/api/v1/harvests/#{harvest.id}", headers: headers, params: {
post "/api/v1/harvests/#{harvest.id}", headers:, params: {
'harvest' => { 'description' => 'can i modify this' }
}
end.to raise_error ActionController::RoutingError
@@ -94,7 +94,7 @@ RSpec.describe 'Harvests', type: :request do
it '#delete' do
expect do
delete "/api/v1/harvests/#{harvest.id}", headers: headers, params: {}
delete "/api/v1/harvests/#{harvest.id}", headers:, params: {}
end.to raise_error ActionController::RoutingError
end
end
+7 -7
View File
@@ -61,13 +61,13 @@ RSpec.describe 'Members', type: :request do
end
describe '#index' do
before { get '/api/v1/members', params: {}, headers: headers }
before { get '/api/v1/members', params: {}, headers: }
it { expect(subject['data']).to include(member_encoded_as_json_api) }
end
describe '#show' do
before { get "/api/v1/members/#{member.id}", params: {}, headers: headers }
before { get "/api/v1/members/#{member.id}", params: {}, headers: }
it { expect(subject['data']['relationships']).to include("gardens" => gardens_as_json_api) }
it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) }
@@ -79,22 +79,22 @@ RSpec.describe 'Members', type: :request do
it '#create' do
expect do
post '/api/v1/members', params: { 'member' => { 'login_name' => 'can i make this' } }, headers: headers
post '/api/v1/members', params: { 'member' => { 'login_name' => 'can i make this' } }, headers:
end.to raise_error ActionController::RoutingError
end
it '#update' do
expect do
post "/api/v1/members/#{member.id}", params: {
'member' => { 'login_name' => 'can i modify this' }
},
headers: headers
'member' => { 'login_name' => 'can i modify this' }
},
headers:
end.to raise_error ActionController::RoutingError
end
it '#delete' do
expect do
delete "/api/v1/members/#{member.id}", params: {}, headers: headers
delete "/api/v1/members/#{member.id}", params: {}, headers:
end.to raise_error ActionController::RoutingError
end
end
+5 -5
View File
@@ -58,13 +58,13 @@ RSpec.describe 'Photos', type: :request do
end
describe '#index' do
before { get '/api/v1/photos', params: {}, headers: headers }
before { get '/api/v1/photos', params: {}, headers: }
it { expect(subject['data']).to include(photo_encoded_as_json_api) }
end
describe '#show' do
before { get "/api/v1/photos/#{photo.id}", params: {}, headers: headers }
before { get "/api/v1/photos/#{photo.id}", params: {}, headers: }
it { expect(subject['data']['attributes']).to eq(attributes) }
it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) }
@@ -75,19 +75,19 @@ RSpec.describe 'Photos', type: :request do
it '#create' do
expect do
post '/api/v1/photos', params: { 'photo' => { 'name' => 'can i make this' } }, headers: headers
post '/api/v1/photos', params: { 'photo' => { 'name' => 'can i make this' } }, headers:
end.to raise_error ActionController::RoutingError
end
it '#update' do
expect do
post "/api/v1/photos/#{photo.id}", params: { 'photo' => { 'name' => 'can i modify this' } }, headers: headers
post "/api/v1/photos/#{photo.id}", params: { 'photo' => { 'name' => 'can i modify this' } }, headers:
end.to raise_error ActionController::RoutingError
end
it '#delete' do
expect do
delete "/api/v1/photos/#{photo.id}", params: {}, headers: headers
delete "/api/v1/photos/#{photo.id}", params: {}, headers:
end.to raise_error ActionController::RoutingError
end
end
@@ -96,13 +96,13 @@ RSpec.describe 'Plantings', type: :request do
it '#create' do
expect do
post '/api/v1/plantings', params: { 'planting' => { 'description' => 'can i make this' } }, headers: headers
post '/api/v1/plantings', params: { 'planting' => { 'description' => 'can i make this' } }, headers:
end.to raise_error ActionController::RoutingError
end
it '#update' do
expect do
post "/api/v1/plantings/#{planting.id}", headers: headers, params: {
post "/api/v1/plantings/#{planting.id}", headers:, params: {
'planting' => { 'description' => 'can i modify this' }
}
end.to raise_error ActionController::RoutingError
@@ -110,7 +110,7 @@ RSpec.describe 'Plantings', type: :request do
it '#delete' do
expect do
delete "/api/v1/plantings/#{planting.id}", params: {}, headers: headers
delete "/api/v1/plantings/#{planting.id}", params: {}, headers:
end.to raise_error ActionController::RoutingError
end
+5 -5
View File
@@ -47,13 +47,13 @@ RSpec.describe 'Photos', type: :request do
end
describe '#index' do
before { get '/api/v1/seeds', params: {}, headers: headers }
before { get '/api/v1/seeds', params: {}, headers: }
it { expect(subject['data']).to include(seed_encoded_as_json_api) }
end
describe '#show' do
before { get "/api/v1/seeds/#{seed.id}", params: {}, headers: headers }
before { get "/api/v1/seeds/#{seed.id}", params: {}, headers: }
it { expect(subject['data']['attributes']).to eq(attributes) }
it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) }
@@ -63,19 +63,19 @@ RSpec.describe 'Photos', type: :request do
it '#create' do
expect do
post '/api/v1/seeds', params: { 'seed' => { 'name' => 'can i make this' } }, headers: headers
post '/api/v1/seeds', params: { 'seed' => { 'name' => 'can i make this' } }, headers:
end.to raise_error ActionController::RoutingError
end
it '#update' do
expect do
post "/api/v1/seeds/#{seed.id}", params: { 'seed' => { 'name' => 'can i modify this' } }, headers: headers
post "/api/v1/seeds/#{seed.id}", params: { 'seed' => { 'name' => 'can i modify this' } }, headers:
end.to raise_error ActionController::RoutingError
end
it '#delete' do
expect do
delete "/api/v1/seeds/#{seed.id}", params: {}, headers: headers
delete "/api/v1/seeds/#{seed.id}", params: {}, headers:
end.to raise_error ActionController::RoutingError
end
end
@@ -7,12 +7,12 @@ describe "crops/_grown_for" do
let(:plant_path) { FactoryBot.create(:plant_part) }
let!(:harvest) do
FactoryBot.create(:harvest,
crop: crop,
crop:,
plant_part: plant_path)
end
it 'shows plant parts' do
render partial: 'crops/grown_for', locals: { crop: crop }
render partial: 'crops/grown_for', locals: { crop: }
rendered.should have_content plant_path.name
assert_select "a", href: plant_part_path(plant_path)
end
+1 -1
View File
@@ -23,7 +23,7 @@ describe "forums/index" do
context "posts" do
let!(:post) { FactoryBot.create(:forum_post, forum: forum1) }
let!(:comment) { FactoryBot.create(:comment, post: post) }
let!(:comment) { FactoryBot.create(:comment, post:) }
before { render }
describe "displays posts" do
+1 -1
View File
@@ -3,7 +3,7 @@
require 'rails_helper'
describe 'home/_seeds.html.haml', type: "view", search: true do
let!(:seed) { FactoryBot.create(:tradable_seed, owner: owner) }
let!(:seed) { FactoryBot.create(:tradable_seed, owner:) }
let(:owner) { FactoryBot.create(:london_member) }
before do
Seed.searchkick_index.refresh
@@ -6,7 +6,7 @@ describe "members/_location" do
context "member with location" do
let(:member) { FactoryBot.create(:london_member) }
before { render partial: 'members/location', locals: { member: member } }
before { render partial: 'members/location', locals: { member: } }
it 'shows location if available' do
expect(rendered).to have_content member.location
@@ -20,7 +20,7 @@ describe "members/_location" do
context "member with no location" do
before do
member = FactoryBot.create(:member)
render partial: 'members/location', locals: { member: member }
render partial: 'members/location', locals: { member: }
end
it 'shows unknown location' do
+3 -3
View File
@@ -16,17 +16,17 @@ describe "plantings/index.html.haml" do
plantings = WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
pager.replace([
FactoryBot.create(:planting,
garden: garden,
garden:,
crop: tomato,
owner: member),
FactoryBot.create(:planting,
garden: garden,
garden:,
crop: maize,
owner: garden.owner,
description: '',
planted_at: Time.zone.local(2013, 1, 13)),
FactoryBot.create(:planting,
garden: garden,
garden:,
owner: garden.owner,
crop: tomato,
planted_at: Time.zone.local(2013, 1, 13),
+1 -1
View File
@@ -7,7 +7,7 @@ describe "plantings/show" do
let(:member) { FactoryBot.create(:member) }
let(:garden) { FactoryBot.create(:garden, owner: member) }
let(:planting) do
FactoryBot.create(:planting, garden: garden, crop: crop,
FactoryBot.create(:planting, garden:, crop:,
owner: garden.owner,
planted_from: 'cutting')
end
+2 -2
View File
@@ -6,8 +6,8 @@ describe 'posts/index.rss.haml', type: "view" do
before do
controller.stub(:current_user) { nil }
author = FactoryBot.create(:member)
@post1 = FactoryBot.create(:post, id: 1, author: author, body: 'This is some text.')
@post2 = FactoryBot.create(:post, id: 2, author: author)
@post1 = FactoryBot.create(:post, id: 1, author:, body: 'This is some text.')
@post2 = FactoryBot.create(:post, id: 2, author:)
assign(:posts, [@post1, @post2])
render
end
+2 -2
View File
@@ -6,7 +6,7 @@ describe "posts/new" do
let(:author) { FactoryBot.create(:member) }
before do
assign(:post, FactoryBot.create(:post, author: author))
assign(:post, FactoryBot.create(:post, author:))
# assign(:forum, Forum.new)
sign_in author
controller.stub(:current_user) { author }
@@ -41,7 +41,7 @@ describe "posts/new" do
before do
assign(:forum, forum)
assign(:post, FactoryBot.create(:post, forum: forum))
assign(:post, FactoryBot.create(:post, forum:))
render
end
+15 -15
View File
@@ -16,7 +16,7 @@ describe "posts/show" do
before { render }
describe "basic post" do
let(:post) { FactoryBot.create(:post, author: author, body: 'hello there') }
let(:post) { FactoryBot.create(:post, author:, body: 'hello there') }
# show the name of the member who posted the post
it { is_expected.to have_text author.login_name }
@@ -28,40 +28,40 @@ describe "posts/show" do
end
describe "should parse markdown into html" do
let(:post) { FactoryBot.create(:markdown_post, author: author) }
let(:post) { FactoryBot.create(:markdown_post, author:) }
it { assert_select "strong", "strong" }
end
describe "shouldn't let html through in body" do
let(:post) { FactoryBot.create(:post, author: author, body: '<a href="http://evil.com">EVIL</a>') }
let(:post) { FactoryBot.create(:post, author:, body: '<a href="http://evil.com">EVIL</a>') }
it { is_expected.to have_content('EVIL') }
it { is_expected.not_to have_link("http://evil.com") }
end
describe 'script tag in post body' do
let(:post) { FactoryBot.create(:post, author: author, body: "<script>alert('hakker!')</script>") }
let(:post) { FactoryBot.create(:post, author:, body: "<script>alert('hakker!')</script>") }
it { is_expected.not_to have_selector('script') }
end
describe 'script tag in post title' do
let(:post) { FactoryBot.create(:post, author: author, subject: "<script>alert('hakker!')</script>") }
let(:post) { FactoryBot.create(:post, author:, subject: "<script>alert('hakker!')</script>") }
it { is_expected.not_to have_selector('script') }
end
describe 'has an anchor to the comments' do
let(:post) { FactoryBot.create(:post, author: author) }
let(:post) { FactoryBot.create(:post, author:) }
it { is_expected.to have_selector('a[name=comments]') }
end
end
context "when there is one comment" do
let(:post) { FactoryBot.create(:html_post, author: author) }
let!(:comment) { FactoryBot.create(:comment, post: post) }
let(:post) { FactoryBot.create(:html_post, author:) }
let!(:comment) { FactoryBot.create(:comment, post:) }
before do
@comments = post.comments
@@ -82,15 +82,15 @@ describe "posts/show" do
end
context "when there is more than one comment" do
let(:post) { FactoryBot.create(:html_post, author: author) }
let(:post) { FactoryBot.create(:html_post, author:) }
before do
@comment1 = FactoryBot.create(:comment, post: post, body: "F1rst!!!",
@comment1 = FactoryBot.create(:comment, post:, body: "F1rst!!!",
created_at: Date.new(2010, 5, 17))
@comment3 = FactoryBot.create(:comment, post: post, body: "Th1rd!!!",
@comment3 = FactoryBot.create(:comment, post:, body: "Th1rd!!!",
created_at: Date.new(2012, 5, 17))
@comment4 = FactoryBot.create(:comment, post: post, body: "F0urth!!!")
@comment2 = FactoryBot.create(:comment, post: post, body: "S3c0nd!!1!",
@comment4 = FactoryBot.create(:comment, post:, body: "F0urth!!!")
@comment2 = FactoryBot.create(:comment, post:, body: "S3c0nd!!1!",
created_at: Date.new(2011, 5, 17))
@comments = post.comments
render
@@ -102,7 +102,7 @@ describe "posts/show" do
end
context "forum post" do
let(:post) { FactoryBot.create(:forum_post, author: author) }
let(:post) { FactoryBot.create(:forum_post, author:) }
before { render }
@@ -112,7 +112,7 @@ describe "posts/show" do
end
context "signed in" do
let(:post) { FactoryBot.create(:post, author: author) }
let(:post) { FactoryBot.create(:post, author:) }
before do
sign_in author
+3 -3
View File
@@ -19,8 +19,8 @@ describe "seeds/show" do
context "tradable" do
context 'with location' do
let!(:owner) { FactoryBot.create(:london_member) }
let!(:seed) { FactoryBot.create(:tradable_seed, owner: owner) }
let!(:member) { FactoryBot.create(:member) }
let!(:seed) { FactoryBot.create(:tradable_seed, owner:) }
let!(:member) { FactoryBot.create(:member) }
before do
assign(:seed, seed)
@@ -47,7 +47,7 @@ describe "seeds/show" do
context 'with no location' do
# no location
let(:owner) { FactoryBot.create(:member) }
let!(:seed) { FactoryBot.create(:tradable_seed, owner: owner) }
let!(:seed) { FactoryBot.create(:tradable_seed, owner:) }
before do
sign_in owner