From bfe1b072db1b1db476e395bdace42a461f59629f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 9 Dec 2019 20:06:48 +1300 Subject: [PATCH 001/188] Memcache caching of harvests --- app/views/harvests/_card.html.haml | 23 ++++++++++++----------- app/views/harvests/_harvest.haml | 6 ++---- app/views/harvests/_thumbnail.html.haml | 17 +++++++++-------- app/views/harvests/index.html.haml | 3 ++- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/app/views/harvests/_card.html.haml b/app/views/harvests/_card.html.haml index 0d51fbb40..0d06351c9 100644 --- a/app/views/harvests/_card.html.haml +++ b/app/views/harvests/_card.html.haml @@ -1,11 +1,12 @@ -.card - = link_to harvest do - = image_tag harvest_image_path(harvest), alt: harvest, class: 'img-card' - .card-body - %h5 - = crop_icon(harvest.crop) - %strong - = link_to harvest.crop, harvest - %span.badge.badge-pill= harvest.plant_part - .card-footer - .float-right=render 'members/tiny', member: harvest.owner \ No newline at end of file +- cache harvest do + .card + = link_to harvest do + = image_tag harvest_image_path(harvest), alt: harvest, class: 'img-card' + .card-body + %h5 + = crop_icon(harvest.crop) + %strong + = link_to harvest.crop, harvest + %span.badge.badge-pill= harvest.plant_part + .card-footer + .float-right=render 'members/tiny', member: harvest.owner \ No newline at end of file diff --git a/app/views/harvests/_harvest.haml b/app/views/harvests/_harvest.haml index 7341875cf..f67725164 100644 --- a/app/views/harvests/_harvest.haml +++ b/app/views/harvests/_harvest.haml @@ -1,6 +1,4 @@ - if local_assigns[:full] - - cache harvest do - = render 'harvests/card', harvest: harvest + = render 'harvests/card', harvest: harvest - else - - cache harvest do - = render 'harvests/thumbnail', harvest: harvest \ No newline at end of file + = render 'harvests/thumbnail', harvest: harvest \ No newline at end of file diff --git a/app/views/harvests/_thumbnail.html.haml b/app/views/harvests/_thumbnail.html.haml index 8539d72d8..5dfe125c3 100644 --- a/app/views/harvests/_thumbnail.html.haml +++ b/app/views/harvests/_thumbnail.html.haml @@ -1,9 +1,10 @@ -.card.harvest-thumbnail - = link_to image_tag(harvest_image_path(harvest), - alt: harvest, - class: 'img img-card'), - harvest +- cache harvest do + .card.harvest-thumbnail + = link_to image_tag(harvest_image_path(harvest), + alt: harvest, + class: 'img img-card'), + harvest - .text - %h3.harvest-plant-part= link_to harvest.plant_part, harvest - %h5.harvest-crop= harvest.crop + .text + %h3.harvest-plant-part= link_to harvest.plant_part, harvest + %h5.harvest-crop= harvest.crop diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index f2a5cb044..eb485d87c 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -32,5 +32,6 @@ %h2 = page_entries_info @harvests = will_paginate @harvests - .index-cards=render @harvests, full: true + .index-cards + = render @harvests, full: true = will_paginate @harvests From 282791d91bcaa4ece547407b305c34a5c451b3dd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 9 Dec 2019 22:19:20 +1300 Subject: [PATCH 002/188] Pull crops and harvests from elasticsearch --- app/controllers/crops_controller.rb | 9 +-------- app/controllers/harvests_controller.rb | 10 ++++++---- app/models/concerns/crop_search.rb | 4 +--- app/models/concerns/harvest_search.rb | 22 ++++++++++++++++++++++ app/models/harvest.rb | 1 + app/views/crops/_search_result.haml | 14 ++++++++++++++ app/views/crops/index.html.haml | 2 +- app/views/harvests/index.html.haml | 17 ++++++++++++++++- app/views/home/_crops.html.haml | 14 +------------- 9 files changed, 63 insertions(+), 30 deletions(-) create mode 100644 app/models/concerns/harvest_search.rb create mode 100644 app/views/crops/_search_result.haml diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index d5eb60573..93b1d7d55 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -9,7 +9,7 @@ class CropsController < ApplicationController def index @sort = params[:sort] - @crops = crops + @crops = Crop.search('*', boost_by: [:plantings_count, :harvests_count], limit: 100, page: params[:page], load: false) @num_requested_crops = requested_crops.size if current_member @filename = filename respond_with @crops @@ -213,13 +213,6 @@ class CropsController < ApplicationController } end - def crops - q = Crop.approved.includes(:scientific_names, plantings: :photos) - q = q.popular unless @sort == 'alpha' - q.order(Arel.sql("LOWER(crops.name)")) - .includes(:photos).paginate(page: params[:page]) - end - def requested_crops current_member.requested_crops.pending_approval end diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index 353e338d6..4dd3ca904 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -11,10 +11,12 @@ class HarvestsController < ApplicationController @crop = Crop.find_by(slug: params[:crop_slug]) @planting = Planting.find_by(slug: params[:planting_id]) - @harvests = @harvests.where(owner: @owner) if @owner.present? - @harvests = @harvests.where(crop: @crop) if @crop.present? - @harvests = @harvests.where(planting: @planting) if @planting.present? - @harvests = @harvests.order(harvested_at: :desc).joins(:owner, :crop).paginate(page: params[:page]) + where = {} + where['owner_id']= @owner.id if @owner.present? + where['crop_id']= @crop.id if @crop.present? + where['planting_id']= @planting.id if @planting.present? + + @harvests = Harvest.search('*', where: where, limit: 100, page: params[:page], load: false, boost_by: [:created_at]) @filename = csv_filename diff --git a/app/models/concerns/crop_search.rb b/app/models/concerns/crop_search.rb index d8de5d5cc..bf251aafd 100644 --- a/app/models/concerns/crop_search.rb +++ b/app/models/concerns/crop_search.rb @@ -2,11 +2,8 @@ module CropSearch extend ActiveSupport::Concern included do - #################################### - # Elastic search configuration searchkick word_start: %i(name alternate_names scientific_names), case_sensitive: false - # Special scope to control if it's in the search index scope :search_import, -> { includes(:scientific_names, :photos) } def should_index? @@ -21,6 +18,7 @@ module CropSearch scientific_names: scientific_names.pluck(:name), # boost the crops that are planted the most plantings_count: plantings_count, + harvests_count: harvests.size, # boost this crop for these members planters_ids: plantings.pluck(:owner_id), has_photos: photos.size.positive?, diff --git a/app/models/concerns/harvest_search.rb b/app/models/concerns/harvest_search.rb new file mode 100644 index 000000000..f373d396d --- /dev/null +++ b/app/models/concerns/harvest_search.rb @@ -0,0 +1,22 @@ +module HarvestSearch + extend ActiveSupport::Concern + + included do + searchkick + + scope :search_import, -> { includes(:owner, :crop, :plant_part) } + + def search_data + { + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + owner_id: owner_id, + planting_id: planting_id, + thumbnail_url: default_photo&.thumbnail_url, + created_at: created_at.to_i + } + end + end +end diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 36f61965f..4f44ee4ee 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -3,6 +3,7 @@ class Harvest < ApplicationRecord extend FriendlyId include PhotoCapable include Ownable + include HarvestSearch friendly_id :harvest_slug, use: %i(slugged finders) diff --git a/app/views/crops/_search_result.haml b/app/views/crops/_search_result.haml new file mode 100644 index 000000000..7a2cb5fcb --- /dev/null +++ b/app/views/crops/_search_result.haml @@ -0,0 +1,14 @@ +.card.crop-thumbnail + = link_to crop_path(slug: crop['slug']) do + + = image_tag(crop['photo'] ? crop['photo'] : placeholder_image, + alt: crop['name'], + class: 'img img-card') + + .text + %h3.crop-name + = link_to crop['name'], crop_path(slug: crop['slug']) + %h5.crop-sci-name +   + = crop['scientific_name'] + diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index 7fc088750..9458b31b9 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -23,7 +23,7 @@ = will_paginate @crops .index-cards - @crops.each do |crop| - = render 'crops/thumbnail', crop: crop + = render 'crops/search_result', crop: crop = will_paginate @crops diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index eb485d87c..a95c70295 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -33,5 +33,20 @@ = page_entries_info @harvests = will_paginate @harvests .index-cards - = render @harvests, full: true + - @harvests.each do |harvest| + - cache harvest do + .card + = link_to harvest_path(id: harvest['id']) do + - if harvest['thumbnail_url'].present? + = image_tag harvest['thumbnail_url'], alt: harvest, class: 'img-card' + - else + = image_tag placeholder_image, alt: harvest, class: 'img-card' + .card-body + %h5 + %strong + = link_to harvest_path(id: harvest['id']) do + = harvest['crop_name'] + %span.badge.badge-pill= harvest['plant_part'] + .card-footer + .float-right=render 'members/tiny', member: Member.find(harvest['owner_id']) = will_paginate @harvests diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index fe4b1492a..5744bc22d 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -1,16 +1,4 @@ - cache cache_key_for(Crop, 'homepage'), expires_in: 1.day do .index-cards - CropSearchService.random_with_photos(16).each do |crop| - .card.crop-thumbnail - = link_to crop_path(slug: crop['slug']) do - = image_tag(crop['photo'], - alt: crop['name'], - class: 'img img-card') - - .text - %h3.crop-name - = link_to crop['name'], crop_path(slug: crop['slug']) - %h5.crop-sci-name -   - = crop['scientific_name'] - + = render 'crops/search_result', crop: crop \ No newline at end of file From 18f016766a72f31e83fc4d4bf99ed11573c963d8 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Mon, 9 Dec 2019 09:20:19 +0000 Subject: [PATCH 003/188] [CodeFactor] Apply fixes to commit 282791d --- app/controllers/crops_controller.rb | 2 +- app/controllers/harvests_controller.rb | 6 +++--- app/models/concerns/harvest_search.rb | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index 93b1d7d55..605a90aac 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -9,7 +9,7 @@ class CropsController < ApplicationController def index @sort = params[:sort] - @crops = Crop.search('*', boost_by: [:plantings_count, :harvests_count], limit: 100, page: params[:page], load: false) + @crops = Crop.search('*', boost_by: %i(plantings_count harvests_count), limit: 100, page: params[:page], load: false) @num_requested_crops = requested_crops.size if current_member @filename = filename respond_with @crops diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index 4dd3ca904..a89099e41 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -12,9 +12,9 @@ class HarvestsController < ApplicationController @planting = Planting.find_by(slug: params[:planting_id]) where = {} - where['owner_id']= @owner.id if @owner.present? - where['crop_id']= @crop.id if @crop.present? - where['planting_id']= @planting.id if @planting.present? + where['owner_id'] = @owner.id if @owner.present? + where['crop_id'] = @crop.id if @crop.present? + where['planting_id'] = @planting.id if @planting.present? @harvests = Harvest.search('*', where: where, limit: 100, page: params[:page], load: false, boost_by: [:created_at]) diff --git a/app/models/concerns/harvest_search.rb b/app/models/concerns/harvest_search.rb index f373d396d..6b3d138c2 100644 --- a/app/models/concerns/harvest_search.rb +++ b/app/models/concerns/harvest_search.rb @@ -8,14 +8,14 @@ module HarvestSearch def search_data { - slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, - crop_id: crop_id, - owner_id: owner_id, - planting_id: planting_id, - thumbnail_url: default_photo&.thumbnail_url, - created_at: created_at.to_i + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + owner_id: owner_id, + planting_id: planting_id, + thumbnail_url: default_photo&.thumbnail_url, + created_at: created_at.to_i } end end From e4b1a2f22184602a2494077f143ad7d1fcdad260 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 10 Dec 2019 09:27:44 +1300 Subject: [PATCH 004/188] Add counter caches --- app/models/harvest.rb | 4 ++-- db/migrate/20191209202348_add_harvest_count_to_crop.rb | 6 ++++++ db/schema.rb | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20191209202348_add_harvest_count_to_crop.rb diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 4f44ee4ee..5588dd639 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -34,8 +34,8 @@ class Harvest < ApplicationRecord ## ## Relationships - belongs_to :crop - belongs_to :plant_part + belongs_to :crop, counter_cache: true + belongs_to :plant_part, counter_cache: true belongs_to :planting, optional: true, counter_cache: true ## diff --git a/db/migrate/20191209202348_add_harvest_count_to_crop.rb b/db/migrate/20191209202348_add_harvest_count_to_crop.rb new file mode 100644 index 000000000..ad38112f0 --- /dev/null +++ b/db/migrate/20191209202348_add_harvest_count_to_crop.rb @@ -0,0 +1,6 @@ +class AddHarvestCountToCrop < ActiveRecord::Migration[5.2] + def change + add_column :crops, :harvests_count, :integer + add_column :plant_parts, :harvests_count, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 06d7be216..cd833e530 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_11_19_030244) do +ActiveRecord::Schema.define(version: 2019_12_09_202348) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -196,6 +196,7 @@ ActiveRecord::Schema.define(version: 2019_11_19_030244) do t.integer "median_days_to_first_harvest" t.integer "median_days_to_last_harvest" t.jsonb "openfarm_data" + t.integer "harvests_count" t.index ["name"], name: "index_crops_on_name" t.index ["requester_id"], name: "index_crops_on_requester_id" t.index ["slug"], name: "index_crops_on_slug", unique: true @@ -458,6 +459,7 @@ ActiveRecord::Schema.define(version: 2019_11_19_030244) do t.datetime "created_at" t.datetime "updated_at" t.string "slug" + t.integer "harvests_count" end create_table "plantings", id: :serial, force: :cascade do |t| From be1ee2098d2e51914918135ddaef018753b4184b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 10 Dec 2019 09:28:20 +1300 Subject: [PATCH 005/188] Use the counter for harvests --- app/models/concerns/crop_search.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/crop_search.rb b/app/models/concerns/crop_search.rb index bf251aafd..5a4f40a8b 100644 --- a/app/models/concerns/crop_search.rb +++ b/app/models/concerns/crop_search.rb @@ -18,7 +18,7 @@ module CropSearch scientific_names: scientific_names.pluck(:name), # boost the crops that are planted the most plantings_count: plantings_count, - harvests_count: harvests.size, + harvests_count: harvests_count, # boost this crop for these members planters_ids: plantings.pluck(:owner_id), has_photos: photos.size.positive?, From 5afe3e1c1e71758fc1d43273f50141eb1a3bd379 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 10 Dec 2019 13:36:23 +1300 Subject: [PATCH 006/188] Pulling plantings from elastic search too --- app/models/concerns/crop_search.rb | 5 ++- app/models/concerns/harvest_search.rb | 15 ++++++++ app/models/concerns/planting_search.rb | 37 +++++++++++++++++++ app/models/photo.rb | 2 +- app/models/photo_association.rb | 2 +- app/models/planting.rb | 2 + app/services/crop_search_service.rb | 4 +- app/views/crops/_search_result.haml | 2 +- app/views/home/_harvests.html.haml | 11 +++--- app/views/home/_plantings.html.haml | 21 +++++------ ...0191209202348_add_harvest_count_to_crop.rb | 11 ++++++ db/schema.rb | 1 + 12 files changed, 90 insertions(+), 23 deletions(-) create mode 100644 app/models/concerns/planting_search.rb diff --git a/app/models/concerns/crop_search.rb b/app/models/concerns/crop_search.rb index 5a4f40a8b..a6d7cb537 100644 --- a/app/models/concerns/crop_search.rb +++ b/app/models/concerns/crop_search.rb @@ -19,10 +19,11 @@ module CropSearch # boost the crops that are planted the most plantings_count: plantings_count, harvests_count: harvests_count, + photos_count: photo_associations_count, # boost this crop for these members planters_ids: plantings.pluck(:owner_id), - has_photos: photos.size.positive?, - photo: default_photo&.thumbnail_url, + has_photos: photo_associations_count.positive?, + thumbnail_url: default_photo&.thumbnail_url, scientific_name: default_scientific_name&.name, description: description, created_at: created_at.to_i diff --git a/app/models/concerns/harvest_search.rb b/app/models/concerns/harvest_search.rb index 6b3d138c2..937b1684c 100644 --- a/app/models/concerns/harvest_search.rb +++ b/app/models/concerns/harvest_search.rb @@ -12,11 +12,26 @@ module HarvestSearch crop_slug: crop.slug, crop_name: crop.name, crop_id: crop_id, + plant_part: plant_part&.name, owner_id: owner_id, + owner_name: owner.login_name, planting_id: planting_id, + photos_count: photos.size, + has_photos: photos.size.positive?, thumbnail_url: default_photo&.thumbnail_url, created_at: created_at.to_i } end + + def self.homepage_records(limit) + self.search('*', + limit: limit, + where: { + photos_count: {gt: 0}, + }, + boost_by: [:created_at], + load: false + ) + end end end diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/planting_search.rb new file mode 100644 index 000000000..0663ebfd9 --- /dev/null +++ b/app/models/concerns/planting_search.rb @@ -0,0 +1,37 @@ +module PlantingSearch + extend ActiveSupport::Concern + + included do + searchkick + + scope :search_import, -> { includes(:owner, :crop) } + + def search_data + { + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + owner_id: owner_id, + owner_name: owner.login_name, + planted_from: planted_from, + photos_count: photos.size, + harvests_count: photos.size, + has_photos: photos.size.positive?, + thumbnail_url: default_photo&.thumbnail_url, + created_at: created_at.to_i + } + end + + def self.homepage_records(limit) + self.search('*', + limit: limit, + where: { + photos_count: {gt: 0}, + }, + boost_by: [:created_at], + load: false + ) + end + end +end diff --git a/app/models/photo.rb b/app/models/photo.rb index 1490c33dc..b2233bf83 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -5,7 +5,7 @@ class Photo < ApplicationRecord PHOTO_CAPABLE = %w(Garden Planting Harvest Seed Post Crop).freeze has_many :photo_associations, foreign_key: :photo_id, dependent: :delete_all, inverse_of: :photo - has_many :crops, through: :photo_associations + has_many :crops, through: :photo_associations, counter_cache: true validates :fullsize_url, url: true validates :thumbnail_url, url: true diff --git a/app/models/photo_association.rb b/app/models/photo_association.rb index 89e495b0f..87126dd0b 100644 --- a/app/models/photo_association.rb +++ b/app/models/photo_association.rb @@ -1,7 +1,7 @@ class PhotoAssociation < ApplicationRecord belongs_to :photo, inverse_of: :photo_associations belongs_to :photographable, polymorphic: true - belongs_to :crop, optional: true + belongs_to :crop, optional: true, counter_cache: true validate :photo_and_item_have_same_owner diff --git a/app/models/planting.rb b/app/models/planting.rb index 5539b6268..a47f53bcc 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -5,6 +5,8 @@ class Planting < ApplicationRecord include Ownable include PredictPlanting include PredictHarvest + include PlantingSearch + friendly_id :planting_slug, use: %i(slugged finders) # Constants diff --git a/app/services/crop_search_service.rb b/app/services/crop_search_service.rb index 57c042e48..be6b2a3de 100644 --- a/app/services/crop_search_service.rb +++ b/app/services/crop_search_service.rb @@ -29,7 +29,7 @@ class CropSearchService limit: limit, load: false, body: body - ).response['hits']['hits'].map { |c| c['_source'] } + ) end def self.recent(limit) @@ -37,6 +37,6 @@ class CropSearchService limit: limit, load: false, boost_by: { created_at: { factor: 100 } } # default factor is 1 - ).response['hits']['hits'].map { |c| c['_source'] } + ) end end diff --git a/app/views/crops/_search_result.haml b/app/views/crops/_search_result.haml index 7a2cb5fcb..649b1729f 100644 --- a/app/views/crops/_search_result.haml +++ b/app/views/crops/_search_result.haml @@ -1,7 +1,7 @@ .card.crop-thumbnail = link_to crop_path(slug: crop['slug']) do - = image_tag(crop['photo'] ? crop['photo'] : placeholder_image, + = image_tag(crop['thumbnail_url'] ? crop['thumbnail_url'] : placeholder_image, alt: crop['name'], class: 'img img-card') diff --git a/app/views/home/_harvests.html.haml b/app/views/home/_harvests.html.haml index cdf7aa589..9799ab284 100644 --- a/app/views/home/_harvests.html.haml +++ b/app/views/home/_harvests.html.haml @@ -1,11 +1,12 @@ %h2= t('.recently_harvested') -- Harvest.has_photos.recent.includes(:crop, :owner, :photos, :plant_part).limit(6).each do |harvest| +- Harvest.homepage_records(6).each do |harvest| - cache harvest do = link_to harvest, class: 'list-group-item list-group-item-action flex-column align-items-start' do .d-flex.w-100.justify-content-between.homepage--list-item %div - %h5= harvest.crop.name - %span.badge.badge-success=harvest.plant_part + %h5= harvest['crop_name'] + %span.badge.badge-success=harvest['plant_part'] %small.text-muted - harvested by #{harvest.owner} - %p.mb-2= image_tag harvest_image_path(harvest), width: 75, class: 'rounded shadow' \ No newline at end of file + harvested by #{harvest['owner_name']} + %p.mb-2 + = image_tag harvest['thumbnail_url'], width: 75, class: 'rounded shadow' \ No newline at end of file diff --git a/app/views/home/_plantings.html.haml b/app/views/home/_plantings.html.haml index 8d26fe455..752c5ff45 100644 --- a/app/views/home/_plantings.html.haml +++ b/app/views/home/_plantings.html.haml @@ -1,12 +1,11 @@ %h2= t('.recently_planted') -- Planting.has_photos.recent.includes(:owner, :crop).limit(6).each do |planting| - - cache planting do - = link_to planting, class: 'list-group-item list-group-item-action flex-column align-items-start' do - .d-flex.w-100.justify-content-between.homepage--list-item - %p.mb-2 - = image_tag planting_image_path(planting), width: 75, class: 'rounded shadow' - .text-right - %h5= planting.crop.name - - if planting.planted_from.present? - %span.badge.badge-success= planting.planted_from.pluralize - %small.text-muted planted by #{planting.owner} +- Planting.homepage_records(6).each do |planting| + = link_to planting, class: 'list-group-item list-group-item-action flex-column align-items-start' do + .d-flex.w-100.justify-content-between.homepage--list-item + %p.mb-2 + = image_tag planting['thumbnail_url'], width: 75, class: 'rounded shadow' + .text-right + %h5= planting['crop_name'] + - if planting['planted_from'].present? + %span.badge.badge-success= planting['planted_from'].pluralize + %small.text-muted planted by #{planting['owner_name']} diff --git a/db/migrate/20191209202348_add_harvest_count_to_crop.rb b/db/migrate/20191209202348_add_harvest_count_to_crop.rb index ad38112f0..27ae37d42 100644 --- a/db/migrate/20191209202348_add_harvest_count_to_crop.rb +++ b/db/migrate/20191209202348_add_harvest_count_to_crop.rb @@ -1,6 +1,17 @@ class AddHarvestCountToCrop < ActiveRecord::Migration[5.2] def change add_column :crops, :harvests_count, :integer + add_column :crops, :photo_associations_count, :integer add_column :plant_parts, :harvests_count, :integer + + Crop.all.each do |crop| + Crop.reset_counters(crop.id, :harvests) + Crop.reset_counters(crop.id, :photos) + say "Crop #{crop.name} counter caches updated" + end + PlantPart.all.each do |pp| + PlantPart.reset_counters(pp.id, :harvests) + say "PlantPart #{pp.name} counter caches updated" + end end end diff --git a/db/schema.rb b/db/schema.rb index cd833e530..8d66e92c0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -197,6 +197,7 @@ ActiveRecord::Schema.define(version: 2019_12_09_202348) do t.integer "median_days_to_last_harvest" t.jsonb "openfarm_data" t.integer "harvests_count" + t.integer "photo_associations_count" t.index ["name"], name: "index_crops_on_name" t.index ["requester_id"], name: "index_crops_on_requester_id" t.index ["slug"], name: "index_crops_on_slug", unique: true From c7e8efb1f1709eacfc1f9f122058ce45a41a1b25 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Tue, 10 Dec 2019 00:37:06 +0000 Subject: [PATCH 007/188] [CodeFactor] Apply fixes to commit 5afe3e1 --- app/models/concerns/harvest_search.rb | 13 +++++---- app/models/concerns/planting_search.rb | 37 +++++++++++++------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/app/models/concerns/harvest_search.rb b/app/models/concerns/harvest_search.rb index 937b1684c..4e10aa98f 100644 --- a/app/models/concerns/harvest_search.rb +++ b/app/models/concerns/harvest_search.rb @@ -25,13 +25,12 @@ module HarvestSearch def self.homepage_records(limit) self.search('*', - limit: limit, - where: { - photos_count: {gt: 0}, - }, - boost_by: [:created_at], - load: false - ) + limit: limit, + where: { + photos_count: { gt: 0 } + }, + boost_by: [:created_at], + load: false) end end end diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/planting_search.rb index 0663ebfd9..6f96c0e10 100644 --- a/app/models/concerns/planting_search.rb +++ b/app/models/concerns/planting_search.rb @@ -8,30 +8,29 @@ module PlantingSearch def search_data { - slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, - crop_id: crop_id, - owner_id: owner_id, - owner_name: owner.login_name, - planted_from: planted_from, - photos_count: photos.size, - harvests_count: photos.size, - has_photos: photos.size.positive?, - thumbnail_url: default_photo&.thumbnail_url, - created_at: created_at.to_i + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + owner_id: owner_id, + owner_name: owner.login_name, + planted_from: planted_from, + photos_count: photos.size, + harvests_count: photos.size, + has_photos: photos.size.positive?, + thumbnail_url: default_photo&.thumbnail_url, + created_at: created_at.to_i } end def self.homepage_records(limit) self.search('*', - limit: limit, - where: { - photos_count: {gt: 0}, - }, - boost_by: [:created_at], - load: false - ) + limit: limit, + where: { + photos_count: { gt: 0 } + }, + boost_by: [:created_at], + load: false) end end end From b0d55ad064253d82c735a3acef9aa5f6d6731be1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 10 Dec 2019 20:30:57 +1300 Subject: [PATCH 008/188] Counter cache for posts --- app/models/comment.rb | 2 +- ...0191209202348_add_harvest_count_to_crop.rb | 58 +++++++++++++++---- db/schema.rb | 7 ++- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 9b0882350..301ca0436 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,6 +1,6 @@ class Comment < ApplicationRecord belongs_to :author, class_name: 'Member', inverse_of: :comments - belongs_to :post + belongs_to :post, counter_cache: true scope :post_order, -> { reorder("created_at ASC") } # for display on post page diff --git a/db/migrate/20191209202348_add_harvest_count_to_crop.rb b/db/migrate/20191209202348_add_harvest_count_to_crop.rb index 27ae37d42..a54779a7b 100644 --- a/db/migrate/20191209202348_add_harvest_count_to_crop.rb +++ b/db/migrate/20191209202348_add_harvest_count_to_crop.rb @@ -1,17 +1,53 @@ class AddHarvestCountToCrop < ActiveRecord::Migration[5.2] def change - add_column :crops, :harvests_count, :integer - add_column :crops, :photo_associations_count, :integer - add_column :plant_parts, :harvests_count, :integer - - Crop.all.each do |crop| - Crop.reset_counters(crop.id, :harvests) - Crop.reset_counters(crop.id, :photos) - say "Crop #{crop.name} counter caches updated" + change_table :crops do |t| + t.integer :harvests_count, default: 0 + t.integer :photo_associations_count, default: 0 end - PlantPart.all.each do |pp| - PlantPart.reset_counters(pp.id, :harvests) - say "PlantPart #{pp.name} counter caches updated" + change_table :plant_parts do |t| + t.integer :harvests_count, default: 0 + end + change_table :posts do |t| + t.integer :comments_count, default: 0 + end + reversible do |dir| + dir.up { data } end end + + def data + execute <<-SQL.squish + UPDATE crops + SET harvests_count = ( + SELECT count(1) + FROM harvests + WHERE harvests.crop_id = crops.id + ) + SQL + execute <<-SQL.squish + UPDATE crops + SET photo_associations_count = ( + SELECT count(1) + FROM photo_associations + WHERE photo_associations.crop_id = crops.id + ) + SQL + execute <<-SQL.squish + UPDATE plant_parts + SET harvests_count = ( + SELECT count(1) + FROM harvests + WHERE harvests.plant_part_id = plant_parts.id + ) + SQL + + execute <<-SQL.squish + UPDATE posts + SET comments_count = ( + SELECT count(1) + FROM comments + WHERE comments.post_id = posts.id + ) + SQL + end end diff --git a/db/schema.rb b/db/schema.rb index 8d66e92c0..a701305f5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -196,8 +196,8 @@ ActiveRecord::Schema.define(version: 2019_12_09_202348) do t.integer "median_days_to_first_harvest" t.integer "median_days_to_last_harvest" t.jsonb "openfarm_data" - t.integer "harvests_count" - t.integer "photo_associations_count" + t.integer "harvests_count", default: 0 + t.integer "photo_associations_count", default: 0 t.index ["name"], name: "index_crops_on_name" t.index ["requester_id"], name: "index_crops_on_requester_id" t.index ["slug"], name: "index_crops_on_slug", unique: true @@ -460,7 +460,7 @@ ActiveRecord::Schema.define(version: 2019_12_09_202348) do t.datetime "created_at" t.datetime "updated_at" t.string "slug" - t.integer "harvests_count" + t.integer "harvests_count", default: 0 end create_table "plantings", id: :serial, force: :cascade do |t| @@ -494,6 +494,7 @@ ActiveRecord::Schema.define(version: 2019_12_09_202348) do t.string "slug" t.integer "forum_id" t.integer "likes_count", default: 0 + t.integer "comments_count", default: 0 t.index ["created_at", "author_id"], name: "index_posts_on_created_at_and_author_id" t.index ["slug"], name: "index_posts_on_slug", unique: true end From b44877a63ece67ecd108c90fd5a59fc55ad877fe Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 11 Dec 2019 11:38:34 +1300 Subject: [PATCH 009/188] Using elastic for plantings look ups --- app/controllers/plantings_controller.rb | 32 ++++++++++++++++++------- app/models/concerns/crop_search.rb | 5 ++-- app/models/concerns/planting_search.rb | 26 ++++++++++---------- app/views/plantings/index.html.haml | 6 ++--- config/routes.rb | 4 ++-- 5 files changed, 44 insertions(+), 29 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index f36a94e39..cb498fafd 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -10,20 +10,28 @@ class PlantingsController < ApplicationController responders :flash def index - @owner = Member.find_by(slug: params[:member_slug]) if params[:member_slug] - @crop = Crop.find_by(slug: params[:crop_slug]) if params[:crop_slug] @show_all = params[:all] == '1' - @plantings = @plantings.where(owner: @owner) if @owner.present? - @plantings = @plantings.where(crop: @crop) if @crop.present? + @where = {} + @where[:active] = true unless @show_all - @plantings = @plantings.active unless params[:all] == '1' + if params[:member_slug] + @owner = Member.find_by(slug: params[:member_slug]) + @where[:owner_id] = @owner.id + end - @plantings = @plantings.joins(:owner, :crop, :garden) - .order(created_at: :desc) - .includes(:owner, :garden, crop: :parent) - .paginate(page: params[:page]) + if params[:crop_slug] + @crop = Crop.find_by(slug: params[:crop_slug]) + @where[:crop_id] = @crop.id + end + + @plantings = Planting.search( + page: params[:page], + limit: 100, + boost_by: [:created_at], + load: false + ) @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv" @@ -31,10 +39,16 @@ class PlantingsController < ApplicationController end def show + @planting = Planting.includes(:owner, :crop, :garden) + .find(params[:slug]) @photos = @planting.photos.includes(:owner).order(date_taken: :desc) + @harvests = Harvest.search(where: { planting_id: @planting.id } ) @matching_seeds = matching_seeds + + # TODO use elastic search long/lat @neighbours = @planting.nearby_same_crop .where.not(id: @planting.id) + .includes(:owner, :crop, :garden) .limit(6) respond_with @planting end diff --git a/app/models/concerns/crop_search.rb b/app/models/concerns/crop_search.rb index a6d7cb537..768cfa4a1 100644 --- a/app/models/concerns/crop_search.rb +++ b/app/models/concerns/crop_search.rb @@ -2,8 +2,7 @@ module CropSearch extend ActiveSupport::Concern included do - searchkick word_start: %i(name alternate_names scientific_names), case_sensitive: false - + searchkick word_start: %i(name description), case_sensitive: false scope :search_import, -> { includes(:scientific_names, :photos) } def should_index? @@ -13,6 +12,7 @@ module CropSearch def search_data { name: name, + description: description, slug: slug, alternate_names: alternate_names.pluck(:name), scientific_names: scientific_names.pluck(:name), @@ -25,7 +25,6 @@ module CropSearch has_photos: photo_associations_count.positive?, thumbnail_url: default_photo&.thumbnail_url, scientific_name: default_scientific_name&.name, - description: description, created_at: created_at.to_i } end diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/planting_search.rb index 0663ebfd9..196eee691 100644 --- a/app/models/concerns/planting_search.rb +++ b/app/models/concerns/planting_search.rb @@ -8,18 +8,20 @@ module PlantingSearch def search_data { - slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, - crop_id: crop_id, - owner_id: owner_id, - owner_name: owner.login_name, - planted_from: planted_from, - photos_count: photos.size, - harvests_count: photos.size, - has_photos: photos.size.positive?, - thumbnail_url: default_photo&.thumbnail_url, - created_at: created_at.to_i + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + owner_id: owner_id, + owner_name: owner.login_name, + planted_from: planted_from, + photos_count: photos.size, + harvests_count: harvests.size, + has_photos: photos.size.positive?, + active: active?, + thumbnail_url: default_photo&.thumbnail_url, + percentage_grown: percentage_grown.to_i, + created_at: created_at.to_i } end diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index c1f21c44b..265d251c3 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -20,9 +20,9 @@ include finished plantings %hr - if @owner.present? - = render @owner + = render @owner, cached: true - if @crop.present? - = render @crop + = render @crop, cached: true %section.open-data %h2 Open Data @@ -41,6 +41,6 @@ = will_paginate @plantings .index-cards - @plantings.each do |planting| - = render planting, full: true + .card= planting = will_paginate @plantings diff --git a/config/routes.rb b/config/routes.rb index e0014ae0d..1988bac83 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -30,7 +30,7 @@ Rails.application.routes.draw do get 'timeline' => 'charts/gardens#timeline', constraints: { format: 'json' } end - resources :plantings, concerns: :has_photos do + resources :plantings, concerns: :has_photos, param: :slug do resources :harvests resources :seeds collection do @@ -43,7 +43,7 @@ Rails.application.routes.draw do get 'crop/:crop' => 'seeds#index', as: 'seeds_by_crop', on: :collection end - resources :harvests, concerns: :has_photos do + resources :harvests, concerns: :has_photos, param: :slug do get 'crop/:crop' => 'harvests#index', as: 'harvests_by_crop', on: :collection end From c772a2984d51a8abfb35b1e1f634ecd08569d745 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 11 Dec 2019 11:40:04 +1300 Subject: [PATCH 010/188] More scaling impromvements --- app/views/home/_discuss.html.haml | 2 +- app/views/home/_harvests.html.haml | 2 +- app/views/home/_plantings.html.haml | 2 +- app/views/plantings/_harvests.html.haml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/home/_discuss.html.haml b/app/views/home/_discuss.html.haml index 7954b536a..96983207b 100644 --- a/app/views/home/_discuss.html.haml +++ b/app/views/home/_discuss.html.haml @@ -12,7 +12,7 @@ %p.mb-2 = truncate(strip_tags(post.body), length: 200) %small - = post.comments.size + = post.comments_count comments %p.text-right = link_to "#{t('.view_all')} ยป", posts_path, class: 'btn btn-block' diff --git a/app/views/home/_harvests.html.haml b/app/views/home/_harvests.html.haml index 9799ab284..7dadbbfbd 100644 --- a/app/views/home/_harvests.html.haml +++ b/app/views/home/_harvests.html.haml @@ -1,7 +1,7 @@ %h2= t('.recently_harvested') - Harvest.homepage_records(6).each do |harvest| - cache harvest do - = link_to harvest, class: 'list-group-item list-group-item-action flex-column align-items-start' do + = link_to harvest_path(slug: harvest['slug']), class: 'list-group-item list-group-item-action flex-column align-items-start' do .d-flex.w-100.justify-content-between.homepage--list-item %div %h5= harvest['crop_name'] diff --git a/app/views/home/_plantings.html.haml b/app/views/home/_plantings.html.haml index 752c5ff45..a3bb79f75 100644 --- a/app/views/home/_plantings.html.haml +++ b/app/views/home/_plantings.html.haml @@ -1,6 +1,6 @@ %h2= t('.recently_planted') - Planting.homepage_records(6).each do |planting| - = link_to planting, class: 'list-group-item list-group-item-action flex-column align-items-start' do + = link_to planting_path(slug: planting['slug']), class: 'list-group-item list-group-item-action flex-column align-items-start' do .d-flex.w-100.justify-content-between.homepage--list-item %p.mb-2 = image_tag planting['thumbnail_url'], width: 75, class: 'rounded shadow' diff --git a/app/views/plantings/_harvests.html.haml b/app/views/plantings/_harvests.html.haml index aa3a0fd40..4f9aa933b 100644 --- a/app/views/plantings/_harvests.html.haml +++ b/app/views/plantings/_harvests.html.haml @@ -10,11 +10,11 @@ = link_to harvests_path(return: 'planting', harvest: {crop_id: @planting.crop_id, planting_id: @planting.id, plant_part_id: plant_part.id}), method: :post, class: 'dropdown-item' do = plant_part.name -- if planting.harvests.empty? +- if @planting.harvests.empty? %p No harvests recorded - if !planting.finished? && can?(:edit, planting) && can?(:create, Harvest) %p Record your harvests here to improve crop predictions, and you'll be able to compare with your garden next season. - else .index-cards - - planting.harvests.order(created_at: :desc).includes(:crop).each do |harvest| + - @planting.harvests.each do |harvest| = render 'harvests/thumbnail', harvest: harvest From b343f899978be9da3bb1b56c3c93561df493f090 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 11 Dec 2019 11:42:12 +1300 Subject: [PATCH 011/188] Photos indexed in elastic search --- .rubocop.yml | 4 +-- .rubocop_todo.yml | 11 -------- app/controllers/application_controller.rb | 32 +++++++++++------------ app/controllers/comments_controller.rb | 2 +- app/controllers/gardens_controller.rb | 2 +- app/controllers/harvests_controller.rb | 4 +-- app/controllers/likes_controller.rb | 2 +- app/controllers/photos_controller.rb | 2 +- app/controllers/plantings_controller.rb | 13 +++++---- app/helpers/buttons_helper.rb | 8 +++--- app/models/concerns/harvest_search.rb | 14 +++++----- app/models/concerns/photo_search.rb | 20 ++++++++++++++ app/models/concerns/planting_search.rb | 14 +++++----- app/models/photo.rb | 1 + app/models/planting.rb | 2 +- spec/factories/crop.rb | 5 ++++ 16 files changed, 75 insertions(+), 61 deletions(-) create mode 100644 app/models/concerns/photo_search.rb diff --git a/.rubocop.yml b/.rubocop.yml index 7d564984d..355a14ac6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -27,13 +27,13 @@ Style/PercentLiteralDelimiters: Layout/MultilineMethodCallIndentation: EnforcedStyle: indented -Layout/AlignHash: +Layout/HashAlignment: EnforcedColonStyle: table EnforcedHashRocketStyle: table # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. # SupportedStyles: with_first_parameter, with_fixed_indentation -Layout/AlignParameters: +Layout/ParameterAlignment: EnforcedStyle: with_fixed_indentation diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 48abddc81..35d8d4d42 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,21 +6,10 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_argument, with_fixed_indentation -Layout/AlignArguments: - Enabled: false - Lint/AmbiguousOperator: Exclude: - 'spec/controllers/crops_controller_spec.rb' -# Configuration parameters: AllowComments. -Lint/HandleExceptions: - Exclude: - - 'lib/tasks/testing.rake' - # Configuration parameters: EnforcedStyle. # SupportedStyles: lowercase, uppercase Naming/HeredocDelimiterCase: diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e30fe25b1..ceafaa6cb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -59,26 +59,26 @@ class ApplicationController < ActionController::Base def configure_permitted_parameters devise_parameter_sanitizer.permit(:sign_up) do |member| member.permit(:login_name, :email, :password, :password_confirmation, - :remember_me, :login, - # terms of service - :tos_agreement, - # profile stuff - :bio, :location, :latitude, :longitude, - # email settings - :show_email, :newsletter, :send_notification_email, :send_planting_reminder) + :remember_me, :login, + # terms of service + :tos_agreement, + # profile stuff + :bio, :location, :latitude, :longitude, + # email settings + :show_email, :newsletter, :send_notification_email, :send_planting_reminder) end devise_parameter_sanitizer.permit(:account_update) do |member| member.permit(:login_name, :email, :password, :password_confirmation, - :remember_me, :login, - # terms of service - :tos_agreement, - # profile stuff - :bio, :location, :latitude, :longitude, - # email settings - :show_email, :newsletter, :send_notification_email, :send_planting_reminder, - # update password - :current_password) + :remember_me, :login, + # terms of service + :tos_agreement, + # profile stuff + :bio, :location, :latitude, :longitude, + # email settings + :show_email, :newsletter, :send_notification_email, :send_planting_reminder, + # update password + :current_password) end end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index f6bbc412c..d47dae87d 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -19,7 +19,7 @@ class CommentsController < ApplicationController respond_with(@comments) else redirect_to(request.referer || root_url, - alert: "Can't post a comment on a non-existent post") + alert: "Can't post a comment on a non-existent post") end end diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index 8a39b6dc1..333fa454d 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -55,6 +55,6 @@ class GardensController < ApplicationController def garden_params params.require(:garden).permit(:name, :slug, :description, :active, - :location, :latitude, :longitude, :area, :area_unit, :garden_type_id) + :location, :latitude, :longitude, :area, :area_unit, :garden_type_id) end end diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index a89099e41..498944fa2 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -67,8 +67,8 @@ class HarvestsController < ApplicationController def harvest_params params.require(:harvest) .permit(:planting_id, :crop_id, :harvested_at, :description, - :quantity, :unit, :weight_quantity, :weight_unit, - :plant_part_id, :slug, :si_weight) + :quantity, :unit, :weight_quantity, :weight_unit, + :plant_part_id, :slug, :si_weight) .merge(owner_id: current_member.id) end diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index 2837dfb0a..b300ab15d 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -41,7 +41,7 @@ class LikesController < ApplicationController format.html { redirect_to like.likeable } format.json do render(json: render_json(like, - liked_by_member: liked_by_member), + liked_by_member: liked_by_member), status: status_code) end end diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index c8908801e..a82127f46 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -65,7 +65,7 @@ class PhotosController < ApplicationController def photo_params params.require(:photo).permit(:source_id, :source, :title, :license_name, - :license_url, :thumbnail_url, :fullsize_url, :link_url) + :license_url, :thumbnail_url, :fullsize_url, :link_url) end # Item with photos attached diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index cb498fafd..dff55bd58 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -10,7 +10,6 @@ class PlantingsController < ApplicationController responders :flash def index - @show_all = params[:all] == '1' @where = {} @@ -27,11 +26,11 @@ class PlantingsController < ApplicationController end @plantings = Planting.search( - page: params[:page], - limit: 100, + page: params[:page], + limit: 100, boost_by: [:created_at], - load: false - ) + load: false + ) @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv" @@ -42,10 +41,10 @@ class PlantingsController < ApplicationController @planting = Planting.includes(:owner, :crop, :garden) .find(params[:slug]) @photos = @planting.photos.includes(:owner).order(date_taken: :desc) - @harvests = Harvest.search(where: { planting_id: @planting.id } ) + @harvests = Harvest.search(where: { planting_id: @planting.id }) @matching_seeds = matching_seeds - # TODO use elastic search long/lat + # TODO: use elastic search long/lat @neighbours = @planting.nearby_same_crop .where.not(id: @planting.id) .includes(:owner, :crop, :garden) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 05fc2798d..1c4eb5306 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -31,14 +31,14 @@ module ButtonsHelper def crop_plant_button(crop) create_button(Planting, - new_planting_path(params: { crop_id: crop.id }), - planting_icon, t('buttons.plant')) + new_planting_path(params: { crop_id: crop.id }), + planting_icon, t('buttons.plant')) end def crop_save_seeds_button(crop) create_button(Seed, - new_seed_path(params: { crop_id: crop.id }), - seed_icon, t('buttons.save_seeds')) + new_seed_path(params: { crop_id: crop.id }), + seed_icon, t('buttons.save_seeds')) end def create_button(model_to_create, path, icon, label) diff --git a/app/models/concerns/harvest_search.rb b/app/models/concerns/harvest_search.rb index 4e10aa98f..ddf2a408b 100644 --- a/app/models/concerns/harvest_search.rb +++ b/app/models/concerns/harvest_search.rb @@ -24,13 +24,13 @@ module HarvestSearch end def self.homepage_records(limit) - self.search('*', - limit: limit, - where: { - photos_count: { gt: 0 } - }, - boost_by: [:created_at], - load: false) + search('*', + limit: limit, + where: { + photos_count: { gt: 0 } + }, + boost_by: [:created_at], + load: false) end end end diff --git a/app/models/concerns/photo_search.rb b/app/models/concerns/photo_search.rb new file mode 100644 index 000000000..548cfa88e --- /dev/null +++ b/app/models/concerns/photo_search.rb @@ -0,0 +1,20 @@ +module PhotoSearch + extend ActiveSupport::Concern + + included do + searchkick + + scope :search_import, -> { includes(:owner, :crop, :plantings, :harvests, :seeds, P:posts) } + + def search_data + { + slug: slug, + crops: crops.map(&:id), + owner_id: owner_id, + owner_name: owner.login_name, + thumbnail_url: thumbnail_url, + created_at: created_at.to_i + } + end + end +end diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/planting_search.rb index 85692fd44..2253852e8 100644 --- a/app/models/concerns/planting_search.rb +++ b/app/models/concerns/planting_search.rb @@ -26,13 +26,13 @@ module PlantingSearch end def self.homepage_records(limit) - self.search('*', - limit: limit, - where: { - photos_count: { gt: 0 } - }, - boost_by: [:created_at], - load: false) + search('*', + limit: limit, + where: { + photos_count: { gt: 0 } + }, + boost_by: [:created_at], + load: false) end end end diff --git a/app/models/photo.rb b/app/models/photo.rb index b2233bf83..2d9e41851 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -1,6 +1,7 @@ class Photo < ApplicationRecord include Likeable include Ownable + include PhotoSearch PHOTO_CAPABLE = %w(Garden Planting Harvest Seed Post Crop).freeze diff --git a/app/models/planting.rb b/app/models/planting.rb index a47f53bcc..ea020c2aa 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -113,7 +113,7 @@ class Planting < ApplicationRecord .where(crop: crop) .located .where('gardens.latitude < ? AND gardens.latitude > ?', - latitude + 10, latitude - 10) + latitude + 10, latitude - 10) end private diff --git a/spec/factories/crop.rb b/spec/factories/crop.rb index b1c23a95b..efb5d05de 100644 --- a/spec/factories/crop.rb +++ b/spec/factories/crop.rb @@ -51,6 +51,11 @@ FactoryBot.define do name { "eggplant" } end + factory :crop_with_photo do + name { 'marshmallow' } + photos { FactoryBot.create_list :photo, 1 } + end + # This should have a name that is alphabetically earlier than :uppercase # crop to ensure that the ordering tests work. factory :lowercasecrop do From 42e69fc1998b2791f4500f1d39c7a12ca9314d1a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 14 Dec 2019 13:51:49 +1300 Subject: [PATCH 012/188] Don't need to say we need ES. --- app.json | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 app.json diff --git a/app.json b/app.json deleted file mode 100644 index d419d8547..000000000 --- a/app.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "growstuff", - "stack": "heroku-18", - "description": "Open data project for small-scale food growers", - "scripts": { - "postdeploy": "bundle exec rails db:seed" - }, - "env": { - "GROWSTUFF_ELASTICSEARCH": { - "required": true - }, - "GROWSTUFF_FACEBOOK_KEY": { - "required": true - }, - "GROWSTUFF_FACEBOOK_SECRET": { - "required": true - }, - "GROWSTUFF_FLICKR_KEY": { - "required": true - }, - "GROWSTUFF_FLICKR_SECRET": { - "required": true - }, - "GROWSTUFF_SITE_NAME": { - "required": true - }, - "GROWSTUFF_EMAIL": { - "required": true - }, - "MAIL_SENDER_HOST": { - "required": true - } - }, - "formation": { - "web": { - "quantity": 1 - } - }, - "addons": [ - "bonsai", - "heroku-postgresql", - "memcachier", - "newrelic", - "scout", - "sendgrid" - ], - "buildpacks": [ - { "url": "heroku/nodejs" }, - { "url": "heroku/ruby" } - ] -} From 0b9b94f1d5fa30c24a460c53e9293b93ae2421c5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 14 Dec 2019 13:52:02 +1300 Subject: [PATCH 013/188] Plantings#index using Elastic Search --- app/controllers/plantings_controller.rb | 9 +++++---- app/models/concerns/planting_search.rb | 1 + app/views/plantings/index.html.haml | 15 ++++++++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index dff55bd58..10c03aea7 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -13,21 +13,22 @@ class PlantingsController < ApplicationController @show_all = params[:all] == '1' @where = {} - @where[:active] = true unless @show_all + @where['active'] = true unless @show_all if params[:member_slug] @owner = Member.find_by(slug: params[:member_slug]) - @where[:owner_id] = @owner.id + @where['owner_id'] = @owner.id end if params[:crop_slug] @crop = Crop.find_by(slug: params[:crop_slug]) - @where[:crop_id] = @crop.id + @where['crop_id'] = @crop.id end @plantings = Planting.search( + where: @where, page: params[:page], - limit: 100, + limit: 30, boost_by: [:created_at], load: false ) diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/planting_search.rb index 2253852e8..d56c89e08 100644 --- a/app/models/concerns/planting_search.rb +++ b/app/models/concerns/planting_search.rb @@ -14,6 +14,7 @@ module PlantingSearch crop_id: crop_id, owner_id: owner_id, owner_name: owner.login_name, + owner_slug: owner.slug, planted_from: planted_from, photos_count: photos.size, harvests_count: harvests.size, diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index 265d251c3..491259221 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -10,7 +10,6 @@ %h1.display-2.text-center = planting_icon = title('plantings', @owner, @crop, @planting) - .row .col-md-2 = render 'layouts/nav', model: Planting @@ -41,6 +40,16 @@ = will_paginate @plantings .index-cards - @plantings.each do |planting| - .card= planting - + .card.planting{class: planting['active'] ? '' : 'card-finished'} + = link_to planting_path(slug: planting['slug']) do + = image_tag planting['thumbnail_url'] ? planting['thumbnail_url'] : placeholder_image, class: 'img-card', alt: planting + = link_to planting_path(slug: planting['slug']) do + .card-body.text-center + %h4= planting['crop_name'] + / = render 'plantings/progress', planting: planting + .card-footer + .float-right + %span.chip.member-chip + = link_to member_path(slug: planting['owner_slug']) do + = planting['owner_name'] = will_paginate @plantings From 2558cb14f876665c2f8553b44c779f2c5a5186fa Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 19 Dec 2019 02:00:25 +0000 Subject: [PATCH 014/188] [CodeFactor] Apply fixes --- app/controllers/plantings_controller.rb | 6 ++--- app/models/concerns/crop_search.rb | 8 +++--- app/models/concerns/harvest_search.rb | 28 ++++++++++---------- app/models/concerns/photo_search.rb | 12 ++++----- app/models/concerns/planting_search.rb | 34 ++++++++++++------------- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index cb2ce133e..768a18b90 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -27,10 +27,10 @@ class PlantingsController < ApplicationController @plantings = Planting.search( where: @where, - page: params[:page], - limit: 30, + page: params[:page], + limit: 30, boost_by: [:created_at], - load: false + load: false ) @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv" diff --git a/app/models/concerns/crop_search.rb b/app/models/concerns/crop_search.rb index 1e336c7c2..65e1499a2 100644 --- a/app/models/concerns/crop_search.rb +++ b/app/models/concerns/crop_search.rb @@ -23,18 +23,18 @@ module CropSearch def search_data { name: name, - description: description, + description: description, slug: slug, alternate_names: alternate_names.pluck(:name), scientific_names: scientific_names.pluck(:name), - photos_count: photo_associations_count, + photos_count: photo_associations_count, # boost the crops that are planted the most plantings_count: plantings_count, - harvests_count: harvests_count, + harvests_count: harvests_count, # boost this crop for these members planters_ids: plantings.pluck(:owner_id), has_photos: photos.size.positive?, - thumbnail_url: default_photo&.thumbnail_url, + thumbnail_url: default_photo&.thumbnail_url, scientific_name: default_scientific_name&.name, created_at: created_at.to_i } diff --git a/app/models/concerns/harvest_search.rb b/app/models/concerns/harvest_search.rb index ddf2a408b..37b3b5496 100644 --- a/app/models/concerns/harvest_search.rb +++ b/app/models/concerns/harvest_search.rb @@ -8,29 +8,29 @@ module HarvestSearch def search_data { - slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, - crop_id: crop_id, - plant_part: plant_part&.name, - owner_id: owner_id, - owner_name: owner.login_name, - planting_id: planting_id, - photos_count: photos.size, - has_photos: photos.size.positive?, + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + plant_part: plant_part&.name, + owner_id: owner_id, + owner_name: owner.login_name, + planting_id: planting_id, + photos_count: photos.size, + has_photos: photos.size.positive?, thumbnail_url: default_photo&.thumbnail_url, - created_at: created_at.to_i + created_at: created_at.to_i } end def self.homepage_records(limit) search('*', - limit: limit, - where: { + limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end diff --git a/app/models/concerns/photo_search.rb b/app/models/concerns/photo_search.rb index 548cfa88e..6668a9189 100644 --- a/app/models/concerns/photo_search.rb +++ b/app/models/concerns/photo_search.rb @@ -4,16 +4,16 @@ module PhotoSearch included do searchkick - scope :search_import, -> { includes(:owner, :crop, :plantings, :harvests, :seeds, P:posts) } + scope :search_import, -> { includes(:owner, :crop, :plantings, :harvests, :seeds, P: posts) } def search_data { - slug: slug, - crops: crops.map(&:id), - owner_id: owner_id, - owner_name: owner.login_name, + slug: slug, + crops: crops.map(&:id), + owner_id: owner_id, + owner_name: owner.login_name, thumbnail_url: thumbnail_url, - created_at: created_at.to_i + created_at: created_at.to_i } end end diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/planting_search.rb index d56c89e08..09d4347f3 100644 --- a/app/models/concerns/planting_search.rb +++ b/app/models/concerns/planting_search.rb @@ -8,32 +8,32 @@ module PlantingSearch def search_data { - slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, - crop_id: crop_id, - owner_id: owner_id, - owner_name: owner.login_name, - owner_slug: owner.slug, - planted_from: planted_from, - photos_count: photos.size, - harvests_count: harvests.size, - has_photos: photos.size.positive?, - active: active?, - thumbnail_url: default_photo&.thumbnail_url, + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + owner_id: owner_id, + owner_name: owner.login_name, + owner_slug: owner.slug, + planted_from: planted_from, + photos_count: photos.size, + harvests_count: harvests.size, + has_photos: photos.size.positive?, + active: active?, + thumbnail_url: default_photo&.thumbnail_url, percentage_grown: percentage_grown.to_i, - created_at: created_at.to_i + created_at: created_at.to_i } end def self.homepage_records(limit) search('*', - limit: limit, - where: { + limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end From 2f3b6b3d225daa9478db79ae58f4aeaba473abc4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 19 Dec 2019 15:33:46 +1300 Subject: [PATCH 015/188] member routing specs --- spec/routing/member_routing_spec.rb | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 spec/routing/member_routing_spec.rb diff --git a/spec/routing/member_routing_spec.rb b/spec/routing/member_routing_spec.rb new file mode 100644 index 000000000..f4a32f229 --- /dev/null +++ b/spec/routing/member_routing_spec.rb @@ -0,0 +1,40 @@ +require "rails_helper" + +describe MembersController do + describe "routing" do + it "routes to #index" do + get("/members").should route_to("members#index") + end + + it "routes to #new" do + get("/members/new").should route_to("members#new") + end + + it "routes to #show" do + get("/members/name").should route_to("members#show", slug: "name") + end + + it "routes to #edit" do + get("/members/name/edit").should route_to("members#edit", slug: "name") + end + + # it "routes to #create" do + # post("/members").should route_to("members#create") + # end + + it "routes to #update" do + put("/members/name").should route_to("members#update", slug: "name") + end + + it "routes to #destroy" do + delete("/members/name").should route_to("members#destroy", slug: "name") + end + + it "routes to harvests#index" do + get("/members/name/harvests").should route_to("harvests#index", member_slug: 'name') + end + it "routes to plantings#index" do + get("/members/name/plantings").should route_to("plantings#index", member_slug: 'name') + end + end +end From 78e111af80780dfd606548a3ad979d687a09779b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 19 Dec 2019 16:52:59 +1300 Subject: [PATCH 016/188] fixing paths to member harvests (with more tests too) --- app/views/harvests/index.html.haml | 6 +++--- app/views/layouts/_menu.haml | 2 +- config/locales/en.yml | 2 +- spec/features/harvests/harvesting_a_crop_spec.rb | 13 ++++++++----- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index a95c70295..65499b848 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -36,7 +36,7 @@ - @harvests.each do |harvest| - cache harvest do .card - = link_to harvest_path(id: harvest['id']) do + = link_to harvest_path(slug: harvest['slug']) do - if harvest['thumbnail_url'].present? = image_tag harvest['thumbnail_url'], alt: harvest, class: 'img-card' - else @@ -44,9 +44,9 @@ .card-body %h5 %strong - = link_to harvest_path(id: harvest['id']) do + = link_to harvest_path(slug: harvest['slug']) do = harvest['crop_name'] %span.badge.badge-pill= harvest['plant_part'] .card-footer - .float-right=render 'members/tiny', member: Member.find(harvest['owner_id']) + .float-right.harvest-owner=render 'members/tiny', member: Member.find(harvest['owner_id']) = will_paginate @harvests diff --git a/app/views/layouts/_menu.haml b/app/views/layouts/_menu.haml index eea460e0d..3703f969b 100644 --- a/app/views/layouts/_menu.haml +++ b/app/views/layouts/_menu.haml @@ -5,7 +5,7 @@ = link_to timeline_index_path, method: :get, class: 'nav-link text-white' do = image_tag 'icons/notification.svg', class: 'img img-icon' %li.nav-item - = link_to member_gardens_path(member_slug: current_member.slug), class: 'nav-link text-white' do + = link_to member_gardens_path(current_member), class: 'nav-link text-white' do = image_icon 'gardens' %li.nav-item.dropdown %a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#", role: "button"} diff --git a/config/locales/en.yml b/config/locales/en.yml index adc90fd09..fccdaf455 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -125,7 +125,7 @@ en: title: crop_harvests: Everyone's %{crop} harvests default: Everyone's harvests - owner_harvests: "%{owner} harvests" + owner_harvests: "%{owner}'s harvests" planting_harvests: Harvests from %{planting} updated: Harvest was successfully updated. home: diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index a551d4dfb..e84fdb7c0 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -38,12 +38,15 @@ describe "Harvesting a crop", :js do expect(page).to have_content "harvest was successfully created." end - it "Clicking link to owner's profile" do - visit member_harvests_path(member) - within '.login-name' do - click_link member.login_name + describe 'member harvests' do + before { visit member_harvests_path(member) } + it { expect(page).to have_text "#{member.login_name}'s harvests" } + it "Clicking link to owner's profile" do + within '.login-name' do + click_link member.login_name + end + expect(current_path).to eq member_path(member) end - expect(current_path).to eq member_path member end describe "Harvesting from crop page" do From 3deafc039d72435daa6a0decd2ad625b3239aea3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 19 Dec 2019 21:26:53 +1300 Subject: [PATCH 017/188] Loading a harvest --- app/controllers/harvests_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index 498944fa2..044f0e7ad 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -16,7 +16,12 @@ class HarvestsController < ApplicationController where['crop_id'] = @crop.id if @crop.present? where['planting_id'] = @planting.id if @planting.present? - @harvests = Harvest.search('*', where: where, limit: 100, page: params[:page], load: false, boost_by: [:created_at]) + @harvests = Harvest.search('*', + where: where, + limit: 100, + page: params[:page], + load: false, + boost_by: [:created_at]) @filename = csv_filename @@ -24,6 +29,7 @@ class HarvestsController < ApplicationController end def show + @harvest = Harvest.find(params[:slug]) @matching_plantings = matching_plantings if @harvest.owner == current_member @photos = @harvest.photos.order(created_at: :desc).paginate(page: params[:page]) respond_with(@harvest) From 700d2b4f30dd5f0469a60870a10cbb02087c22da Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 19 Dec 2019 08:27:22 +0000 Subject: [PATCH 018/188] [CodeFactor] Apply fixes to commit 3deafc0 --- app/controllers/harvests_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index 044f0e7ad..c0bb85cd0 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -17,10 +17,10 @@ class HarvestsController < ApplicationController where['planting_id'] = @planting.id if @planting.present? @harvests = Harvest.search('*', - where: where, - limit: 100, - page: params[:page], - load: false, + where: where, + limit: 100, + page: params[:page], + load: false, boost_by: [:created_at]) @filename = csv_filename From 5e5cdf624603142b565a5bc9cdcff5386c3c4dc9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 19 Dec 2019 21:49:18 +1300 Subject: [PATCH 019/188] Fixing up lookup by slug --- app/controllers/gardens_controller.rb | 5 +++++ app/controllers/harvests_controller.rb | 6 +++++- app/controllers/plantings_controller.rb | 5 +++++ app/controllers/seeds_controller.rb | 3 ++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index 333fa454d..0b815f37e 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -1,5 +1,6 @@ class GardensController < ApplicationController before_action :authenticate_member!, except: %i(index show) + before_action :set_garden, only: %i(edit show update destroy) after_action :expire_homepage, only: %i(create destroy) load_and_authorize_resource responders :flash @@ -53,6 +54,10 @@ class GardensController < ApplicationController private + def set_gardenplanting + @garden = Garden.find(params[:slug]) + end + def garden_params params.require(:garden).permit(:name, :slug, :description, :active, :location, :latitude, :longitude, :area, :area_unit, :garden_type_id) diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index 044f0e7ad..106ec318b 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -1,5 +1,6 @@ class HarvestsController < ApplicationController before_action :authenticate_member!, except: %i(index show) + before_action :set_harvest, only: %i(edit show update destroy) after_action :update_crop_medians, only: %i(create update destroy) load_and_authorize_resource respond_to :html, :json @@ -29,7 +30,6 @@ class HarvestsController < ApplicationController end def show - @harvest = Harvest.find(params[:slug]) @matching_plantings = matching_plantings if @harvest.owner == current_member @photos = @harvest.photos.order(created_at: :desc).paginate(page: params[:page]) respond_with(@harvest) @@ -70,6 +70,10 @@ class HarvestsController < ApplicationController private + def set_harvest + @harvest = Harvest.find(params[:slug]) + end + def harvest_params params.require(:harvest) .permit(:planting_id, :crop_id, :harvested_at, :description, diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 768a18b90..a47c5a94a 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -1,5 +1,6 @@ class PlantingsController < ApplicationController before_action :authenticate_member!, except: %i(index show) + before_action :set_planting, only: %i(edit show update destroy) after_action :expire_homepage, only: %i(create update destroy) after_action :update_crop_medians, only: %i(create update destroy) after_action :update_planting_medians, only: :update @@ -98,6 +99,10 @@ class PlantingsController < ApplicationController private + def set_planting + @planting = Planting.find(params[:slug]) + end + def update_crop_medians @planting.crop.update_lifespan_medians if @planting.crop.present? end diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index b6457edbf..e257d8643 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -1,6 +1,7 @@ class SeedsController < ApplicationController before_action :authenticate_member!, except: %i(index show) - load_and_authorize_resource + load_resource find_by: :slug + authorize_resource responders :flash respond_to :html, :json respond_to :csv, only: :index From c9fddc4b7a12fb85dba29ebf9d9181ec4237b5b3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 19 Dec 2019 21:54:47 +1300 Subject: [PATCH 020/188] Use slugs as params --- config/routes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index cb78ae440..23c49161b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,7 +26,7 @@ Rails.application.routes.draw do resources :photos, only: :index end - resources :gardens, concerns: :has_photos do + resources :gardens, concerns: :has_photos, param: :slug do get 'timeline' => 'charts/gardens#timeline', constraints: { format: 'json' } end @@ -38,7 +38,7 @@ Rails.application.routes.draw do end end - resources :seeds, concerns: :has_photos do + resources :seeds, concerns: :has_photos, param: :slug do resources :plantings get 'crop/:crop' => 'seeds#index', as: 'seeds_by_crop', on: :collection end From 424132d32e86cfd3d96f7848f76cb3738952fda0 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 19 Dec 2019 08:55:10 +0000 Subject: [PATCH 021/188] [CodeFactor] Apply fixes to commit c9fddc4 --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 23c49161b..3a6f0298c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -38,7 +38,7 @@ Rails.application.routes.draw do end end - resources :seeds, concerns: :has_photos, param: :slug do + resources :seeds, concerns: :has_photos, param: :slug do resources :plantings get 'crop/:crop' => 'seeds#index', as: 'seeds_by_crop', on: :collection end From 95c1ee7a814f353a6a2fe72d101381cccabfbacc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 19 Dec 2019 21:56:16 +1300 Subject: [PATCH 022/188] Fixed loading gardens --- app/controllers/gardens_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index 0b815f37e..3e642837a 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -54,7 +54,7 @@ class GardensController < ApplicationController private - def set_gardenplanting + def set_garden @garden = Garden.find(params[:slug]) end From 8c1761d40edeb2eb4e8bd305b8ef6cd2a2cd9608 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 09:18:16 +1300 Subject: [PATCH 023/188] index crops before testing crops#index --- spec/features/crops/browse_crops_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb index d60727bbc..4de6d14ae 100644 --- a/spec/features/crops/browse_crops_spec.rb +++ b/spec/features/crops/browse_crops_spec.rb @@ -7,7 +7,11 @@ describe "browse crops" do let!(:rejected_crop) { FactoryBot.create :rejected_crop } shared_examples 'shows crops' do - before { visit crops_path } + before do + Crop.reindex + visit crops_path + end + it "has a form for sorting by" do expect(page).to have_css "select#sort" end From c0103a3f42e77432e97ef55302bf49c13a8c2e65 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 09:21:47 +1300 Subject: [PATCH 024/188] find seeds by slug --- app/controllers/seeds_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index e257d8643..450cc4331 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -1,6 +1,6 @@ class SeedsController < ApplicationController before_action :authenticate_member!, except: %i(index show) - load_resource find_by: :slug + before_action :set_seed, only: %i(edit show update destroy) authorize_resource responders :flash respond_to :html, :json @@ -62,6 +62,10 @@ class SeedsController < ApplicationController private + def set_seed + @seed = Seed.find(params[:slug]) + end + def seeds records = Seed.all records = records.where(owner: @owner) if @owner.present? From 18cb2188079463a30999d55c13650c01be09fbab Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 09:33:23 +1300 Subject: [PATCH 025/188] Add mappings on crop search --- app/models/concerns/crop_search.rb | 33 ++++++++++++++++-------------- spec/features/rss/crops_spec.rb | 2 ++ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/app/models/concerns/crop_search.rb b/app/models/concerns/crop_search.rb index 65e1499a2..59facda5e 100644 --- a/app/models/concerns/crop_search.rb +++ b/app/models/concerns/crop_search.rb @@ -4,12 +4,15 @@ module CropSearch included do #################################### # Elastic search configuration - searchkick word_start: %i(name description alternate_names scientific_names), + searchkick word_start: %i(name description alternate_names scientific_names), case_sensitive: false, merge_mappings: true, - mappings: { + mappings: { properties: { - created_at: { type: :integer } + created_at: { type: :integer }, + plantings_count: { type: :integer }, + harvests_count: { type: :integer }, + photos_count: { type: :integer } } } @@ -22,21 +25,21 @@ module CropSearch def search_data { - name: name, - description: description, - slug: slug, - alternate_names: alternate_names.pluck(:name), + name: name, + description: description, + slug: slug, + alternate_names: alternate_names.pluck(:name), scientific_names: scientific_names.pluck(:name), - photos_count: photo_associations_count, + photos_count: photo_associations_count, # boost the crops that are planted the most - plantings_count: plantings_count, - harvests_count: harvests_count, + plantings_count: plantings_count, + harvests_count: harvests_count, # boost this crop for these members - planters_ids: plantings.pluck(:owner_id), - has_photos: photos.size.positive?, - thumbnail_url: default_photo&.thumbnail_url, - scientific_name: default_scientific_name&.name, - created_at: created_at.to_i + planters_ids: plantings.pluck(:owner_id), + has_photos: photos.size.positive?, + thumbnail_url: default_photo&.thumbnail_url, + scientific_name: default_scientific_name&.name, + created_at: created_at.to_i } end end diff --git a/spec/features/rss/crops_spec.rb b/spec/features/rss/crops_spec.rb index 704dd60ba..e42c73150 100644 --- a/spec/features/rss/crops_spec.rb +++ b/spec/features/rss/crops_spec.rb @@ -2,11 +2,13 @@ require 'rails_helper' describe 'Crops RSS feed' do it 'The index feed exists' do + Crop.reindex visit crops_path(format: 'rss') # expect(page.status_code).to equal 200 end it 'The index title is what we expect' do + Crop.reindex visit crops_path(format: 'rss') expect(page).to have_content "Recently added crops (#{ENV['GROWSTUFF_SITE_NAME']})" end From 0c338e771c31130eb763830b943e8b9111d46e87 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 19 Dec 2019 20:33:55 +0000 Subject: [PATCH 026/188] [CodeFactor] Apply fixes to commit 18cb218 --- app/models/concerns/crop_search.rb | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/app/models/concerns/crop_search.rb b/app/models/concerns/crop_search.rb index 59facda5e..ccc04cb15 100644 --- a/app/models/concerns/crop_search.rb +++ b/app/models/concerns/crop_search.rb @@ -4,15 +4,15 @@ module CropSearch included do #################################### # Elastic search configuration - searchkick word_start: %i(name description alternate_names scientific_names), + searchkick word_start: %i(name description alternate_names scientific_names), case_sensitive: false, merge_mappings: true, - mappings: { + mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, plantings_count: { type: :integer }, - harvests_count: { type: :integer }, - photos_count: { type: :integer } + harvests_count: { type: :integer }, + photos_count: { type: :integer } } } @@ -25,21 +25,21 @@ module CropSearch def search_data { - name: name, - description: description, - slug: slug, - alternate_names: alternate_names.pluck(:name), + name: name, + description: description, + slug: slug, + alternate_names: alternate_names.pluck(:name), scientific_names: scientific_names.pluck(:name), - photos_count: photo_associations_count, + photos_count: photo_associations_count, # boost the crops that are planted the most - plantings_count: plantings_count, - harvests_count: harvests_count, + plantings_count: plantings_count, + harvests_count: harvests_count, # boost this crop for these members - planters_ids: plantings.pluck(:owner_id), - has_photos: photos.size.positive?, - thumbnail_url: default_photo&.thumbnail_url, - scientific_name: default_scientific_name&.name, - created_at: created_at.to_i + planters_ids: plantings.pluck(:owner_id), + has_photos: photos.size.positive?, + thumbnail_url: default_photo&.thumbnail_url, + scientific_name: default_scientific_name&.name, + created_at: created_at.to_i } end end From 4c91da855c37c89ae5d22c5b8dcb38cf94b96d90 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 09:44:40 +1300 Subject: [PATCH 027/188] Add ES mappings for plantings --- app/models/concerns/planting_search.rb | 43 +++++++++++++++----------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/planting_search.rb index 09d4347f3..1ed3d0244 100644 --- a/app/models/concerns/planting_search.rb +++ b/app/models/concerns/planting_search.rb @@ -2,38 +2,45 @@ module PlantingSearch extend ActiveSupport::Concern included do - searchkick + searchkick merge_mappings: true, + mappings: { + properties: { + created_at: { type: :integer }, + harvests_count: { type: :integer }, + photos_count: { type: :integer } + } + } scope :search_import, -> { includes(:owner, :crop) } def search_data { - slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, - crop_id: crop_id, - owner_id: owner_id, - owner_name: owner.login_name, - owner_slug: owner.slug, - planted_from: planted_from, - photos_count: photos.size, - harvests_count: harvests.size, - has_photos: photos.size.positive?, - active: active?, - thumbnail_url: default_photo&.thumbnail_url, + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + owner_id: owner_id, + owner_name: owner.login_name, + owner_slug: owner.slug, + planted_from: planted_from, + photos_count: photos.size, + harvests_count: harvests.size, + has_photos: photos.size.positive?, + active: active?, + thumbnail_url: default_photo&.thumbnail_url, percentage_grown: percentage_grown.to_i, - created_at: created_at.to_i + created_at: created_at.to_i } end def self.homepage_records(limit) search('*', - limit: limit, - where: { + limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end From bdbcca19f0b0478aa59df84a112a9e38c9e9a88e Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 19 Dec 2019 20:45:06 +0000 Subject: [PATCH 028/188] [CodeFactor] Apply fixes to commit 4c91da8 --- app/models/concerns/planting_search.rb | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/planting_search.rb index 1ed3d0244..5f34d4aa8 100644 --- a/app/models/concerns/planting_search.rb +++ b/app/models/concerns/planting_search.rb @@ -3,11 +3,11 @@ module PlantingSearch included do searchkick merge_mappings: true, - mappings: { + mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, harvests_count: { type: :integer }, - photos_count: { type: :integer } + photos_count: { type: :integer } } } @@ -15,32 +15,32 @@ module PlantingSearch def search_data { - slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, - crop_id: crop_id, - owner_id: owner_id, - owner_name: owner.login_name, - owner_slug: owner.slug, - planted_from: planted_from, - photos_count: photos.size, - harvests_count: harvests.size, - has_photos: photos.size.positive?, - active: active?, - thumbnail_url: default_photo&.thumbnail_url, + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + owner_id: owner_id, + owner_name: owner.login_name, + owner_slug: owner.slug, + planted_from: planted_from, + photos_count: photos.size, + harvests_count: harvests.size, + has_photos: photos.size.positive?, + active: active?, + thumbnail_url: default_photo&.thumbnail_url, percentage_grown: percentage_grown.to_i, - created_at: created_at.to_i + created_at: created_at.to_i } end def self.homepage_records(limit) search('*', - limit: limit, - where: { + limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end From b0b732a5b92ce922f41af487029b1b5012980f82 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 09:50:21 +1300 Subject: [PATCH 029/188] Reindex in tests --- spec/features/home/home_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb index cbd14b4d6..2901787b7 100644 --- a/spec/features/home/home_spec.rb +++ b/spec/features/home/home_spec.rb @@ -19,8 +19,14 @@ describe "home page" do before do # Add photos, so they can appear on home page planting.photos << photo + planting.reindex + seed.photos << photo + seed.reindex + harvest.photos << photo + harvest.reindex + Crop.reindex end From d59f8f4419426ff8ba263e3170ffe255a66df709 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 16:20:31 +1300 Subject: [PATCH 030/188] add ES field mappings --- app/models/concerns/crop_search.rb | 34 ++++++++++---------- app/models/concerns/harvest_search.rb | 37 +++++++++++++--------- app/models/concerns/planting_search.rb | 43 ++++++++++++++------------ 3 files changed, 62 insertions(+), 52 deletions(-) diff --git a/app/models/concerns/crop_search.rb b/app/models/concerns/crop_search.rb index ccc04cb15..59facda5e 100644 --- a/app/models/concerns/crop_search.rb +++ b/app/models/concerns/crop_search.rb @@ -4,15 +4,15 @@ module CropSearch included do #################################### # Elastic search configuration - searchkick word_start: %i(name description alternate_names scientific_names), + searchkick word_start: %i(name description alternate_names scientific_names), case_sensitive: false, merge_mappings: true, - mappings: { + mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, plantings_count: { type: :integer }, - harvests_count: { type: :integer }, - photos_count: { type: :integer } + harvests_count: { type: :integer }, + photos_count: { type: :integer } } } @@ -25,21 +25,21 @@ module CropSearch def search_data { - name: name, - description: description, - slug: slug, - alternate_names: alternate_names.pluck(:name), + name: name, + description: description, + slug: slug, + alternate_names: alternate_names.pluck(:name), scientific_names: scientific_names.pluck(:name), - photos_count: photo_associations_count, + photos_count: photo_associations_count, # boost the crops that are planted the most - plantings_count: plantings_count, - harvests_count: harvests_count, + plantings_count: plantings_count, + harvests_count: harvests_count, # boost this crop for these members - planters_ids: plantings.pluck(:owner_id), - has_photos: photos.size.positive?, - thumbnail_url: default_photo&.thumbnail_url, - scientific_name: default_scientific_name&.name, - created_at: created_at.to_i + planters_ids: plantings.pluck(:owner_id), + has_photos: photos.size.positive?, + thumbnail_url: default_photo&.thumbnail_url, + scientific_name: default_scientific_name&.name, + created_at: created_at.to_i } end end diff --git a/app/models/concerns/harvest_search.rb b/app/models/concerns/harvest_search.rb index 37b3b5496..f54ea996f 100644 --- a/app/models/concerns/harvest_search.rb +++ b/app/models/concerns/harvest_search.rb @@ -2,35 +2,42 @@ module HarvestSearch extend ActiveSupport::Concern included do - searchkick + searchkick merge_mappings: true, + mappings: { + properties: { + created_at: { type: :integer }, + harvests_count: { type: :integer }, + photos_count: { type: :integer } + } + } scope :search_import, -> { includes(:owner, :crop, :plant_part) } def search_data { - slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, - crop_id: crop_id, - plant_part: plant_part&.name, - owner_id: owner_id, - owner_name: owner.login_name, - planting_id: planting_id, - photos_count: photos.size, - has_photos: photos.size.positive?, + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + plant_part: plant_part&.name, + owner_id: owner_id, + owner_name: owner.login_name, + planting_id: planting_id, + photos_count: photos.size, + has_photos: photos.size.positive?, thumbnail_url: default_photo&.thumbnail_url, - created_at: created_at.to_i + created_at: created_at.to_i } end def self.homepage_records(limit) search('*', - limit: limit, - where: { + limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/planting_search.rb index 5f34d4aa8..85f8e48bc 100644 --- a/app/models/concerns/planting_search.rb +++ b/app/models/concerns/planting_search.rb @@ -3,11 +3,12 @@ module PlantingSearch included do searchkick merge_mappings: true, - mappings: { + mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, harvests_count: { type: :integer }, - photos_count: { type: :integer } + photos_count: { type: :integer }, + owner_location: { type: :text } } } @@ -15,32 +16,34 @@ module PlantingSearch def search_data { - slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, - crop_id: crop_id, - owner_id: owner_id, - owner_name: owner.login_name, - owner_slug: owner.slug, - planted_from: planted_from, - photos_count: photos.size, - harvests_count: harvests.size, - has_photos: photos.size.positive?, - active: active?, - thumbnail_url: default_photo&.thumbnail_url, + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + owner_id: owner_id, + owner_name: owner.login_name, + owner_slug: owner.slug, + planted_from: planted_from, + photos_count: photos.size, + harvests_count: harvests.size, + has_photos: photos.size.positive?, + active: active?, + finished: finished?, + thumbnail_url: default_photo&.thumbnail_url, + owner_location: owner.location, percentage_grown: percentage_grown.to_i, - created_at: created_at.to_i + created_at: created_at.to_i } end def self.homepage_records(limit) search('*', - limit: limit, - where: { + limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end From 8789fee3656a0aaae2f75cf72e97f77cec834cb6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 16:20:52 +1300 Subject: [PATCH 031/188] Seeds into elastic search --- app/controllers/seeds_controller.rb | 37 +++++++++++++++--------- app/models/concerns/seed_search.rb | 45 +++++++++++++++++++++++++++++ app/models/seed.rb | 1 + 3 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 app/models/concerns/seed_search.rb diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index 450cc4331..5915c2461 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -8,14 +8,34 @@ class SeedsController < ApplicationController respond_to :rss, only: :index def index - @owner = Member.find_by(slug: params[:member_slug]) if params[:member_slug].present? - @crop = Crop.find_by(slug: params[:crop_slug]) if params[:crop_slug].present? - @planting = Planting.find_by(slug: params[:planting_id]) if params[:planting_id].present? + where = {} + + if params[:member_slug].present? + @owner = Member.find_by(slug: params[:member_slug]) + where['owner_id'] = @owner.id + end + + if params[:crop_slug].present? + @crop = Crop.find_by(slug: params[:crop_slug]) + where['crop_id'] = @crop.id + end + + if params[:planting_id].present? + @planting = Planting.find_by(slug: params[:planting_id]) + where['parent_planting'] = @planting.id + end @show_all = (params[:all] == '1') + where['finished'] = false unless @show_all @filename = csv_filename - @seeds = seeds.order(created_at: :desc).includes(:owner, :crop).paginate(page: params[:page]) + @seeds = Seed.search( + where: where, + page: params[:page], + limit: 30, + boost_by: [:created_at], + load: false + ) respond_with(@seeds) end @@ -66,15 +86,6 @@ class SeedsController < ApplicationController @seed = Seed.find(params[:slug]) end - def seeds - records = Seed.all - records = records.where(owner: @owner) if @owner.present? - records = records.where(crop: @crop) if @crop.present? - records = records.where(parent_planting: @planting) if @planting.present? - records = records.active unless @show_all - records - end - def seed_params params.require(:seed).permit( :crop_id, :description, :quantity, :plant_before, diff --git a/app/models/concerns/seed_search.rb b/app/models/concerns/seed_search.rb new file mode 100644 index 000000000..950b4742f --- /dev/null +++ b/app/models/concerns/seed_search.rb @@ -0,0 +1,45 @@ +module SeedSearch + extend ActiveSupport::Concern + + included do + searchkick merge_mappings: true, + mappings: { + properties: { + created_at: { type: :integer }, + photos_count: { type: :integer }, + tradable_to: { type: :text } + } + } + + scope :search_import, -> { includes(:owner, :crop, :parent_planting) } + + def search_data + { + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + owner_id: owner_id, + owner_name: owner.login_name, + tradable_to: tradable_to, + tradeable: tradable?, + parent_planting: parent_planting, + photos_count: photos.size, + has_photos: photos.size.positive?, + thumbnail_url: default_photo&.thumbnail_url, + finished: finished?, + created_at: created_at.to_i + } + end + + def self.homepage_records(limit) + search('*', + limit: limit, + where: { + photos_count: { gt: 0 } + }, + boost_by: [:created_at], + load: false) + end + end +end diff --git a/app/models/seed.rb b/app/models/seed.rb index cc1cecaa2..21970fba1 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -3,6 +3,7 @@ class Seed < ApplicationRecord include PhotoCapable include Finishable include Ownable + include SeedSearch friendly_id :seed_slug, use: %i(slugged finders) TRADABLE_TO_VALUES = %w(nowhere locally nationally internationally).freeze From e31f6a7c362ffe45a67ffc5b7cf0a15c12f2e65c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 16:21:11 +1300 Subject: [PATCH 032/188] Index into ES after migration --- db/migrate/20191209202348_add_harvest_count_to_crop.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/db/migrate/20191209202348_add_harvest_count_to_crop.rb b/db/migrate/20191209202348_add_harvest_count_to_crop.rb index a54779a7b..e250b4be6 100644 --- a/db/migrate/20191209202348_add_harvest_count_to_crop.rb +++ b/db/migrate/20191209202348_add_harvest_count_to_crop.rb @@ -13,6 +13,11 @@ class AddHarvestCountToCrop < ActiveRecord::Migration[5.2] reversible do |dir| dir.up { data } end + + Crop.reindex + Planting.reindex + Seed.reindex + Harvest.reindex end def data From ef8ec3c603fe92ffce0bf89ed1bfdd418d10d16a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 16:21:23 +1300 Subject: [PATCH 033/188] Reindex plantings in spec --- spec/features/rss/plantings_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/features/rss/plantings_spec.rb b/spec/features/rss/plantings_spec.rb index 7a6e31b95..8e44494cb 100644 --- a/spec/features/rss/plantings_spec.rb +++ b/spec/features/rss/plantings_spec.rb @@ -7,6 +7,7 @@ describe 'Plantings RSS feed' do end it 'The index title is what we expect' do + Planting.reindex visit plantings_path(format: 'rss') expect(page).to have_content "Recent plantings from "\ "#{@owner || 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" From 85f99d3916f6c47a9d73f6894357f4e2a7ef47c3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 16:21:32 +1300 Subject: [PATCH 034/188] Display seeds from elastic search --- app/views/seeds/index.html.haml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index e0d17efed..56542618a 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -39,7 +39,21 @@ .index-cards - @seeds.each do |seed| - = render 'seeds/card', seed: seed + .card.seed-card{class: seed['finished'] ? 'card-finished' : ''} + = link_to seed_path(slug: seed['slug']) do + = image_tag(seed['thumbnail_url'] ? seed['thumbnail_url'] : placeholder_image, alt: seed['crop_name'], class: 'img-card') + .text + %span.chip.member-chip= seed['owner_name'] + .card-body + .card-title + = link_to seed['crop_name'], seed_path(seed['slug']) + - if seed['tradable'] + .text-muted + = icon 'fas', 'map' + Will trade #{seed['tradable_to']} + .badge.badge-pill.badge-location + = icon 'fas', 'map-marker' + = truncate(seed['owner_location'], length: 20, separator: ' ', omission: '... ') = will_paginate @seeds From d95bc774a22a00d682968957725be81effe4d280 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Fri, 20 Dec 2019 03:22:04 +0000 Subject: [PATCH 035/188] [CodeFactor] Apply fixes --- app/controllers/seeds_controller.rb | 8 ++--- app/models/concerns/crop_search.rb | 34 ++++++++++---------- app/models/concerns/harvest_search.rb | 34 ++++++++++---------- app/models/concerns/planting_search.rb | 44 +++++++++++++------------- app/models/concerns/seed_search.rb | 38 +++++++++++----------- 5 files changed, 79 insertions(+), 79 deletions(-) diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index 5915c2461..1cf465ab2 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -30,11 +30,11 @@ class SeedsController < ApplicationController @filename = csv_filename @seeds = Seed.search( - where: where, - page: params[:page], - limit: 30, + where: where, + page: params[:page], + limit: 30, boost_by: [:created_at], - load: false + load: false ) respond_with(@seeds) diff --git a/app/models/concerns/crop_search.rb b/app/models/concerns/crop_search.rb index 59facda5e..ccc04cb15 100644 --- a/app/models/concerns/crop_search.rb +++ b/app/models/concerns/crop_search.rb @@ -4,15 +4,15 @@ module CropSearch included do #################################### # Elastic search configuration - searchkick word_start: %i(name description alternate_names scientific_names), + searchkick word_start: %i(name description alternate_names scientific_names), case_sensitive: false, merge_mappings: true, - mappings: { + mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, plantings_count: { type: :integer }, - harvests_count: { type: :integer }, - photos_count: { type: :integer } + harvests_count: { type: :integer }, + photos_count: { type: :integer } } } @@ -25,21 +25,21 @@ module CropSearch def search_data { - name: name, - description: description, - slug: slug, - alternate_names: alternate_names.pluck(:name), + name: name, + description: description, + slug: slug, + alternate_names: alternate_names.pluck(:name), scientific_names: scientific_names.pluck(:name), - photos_count: photo_associations_count, + photos_count: photo_associations_count, # boost the crops that are planted the most - plantings_count: plantings_count, - harvests_count: harvests_count, + plantings_count: plantings_count, + harvests_count: harvests_count, # boost this crop for these members - planters_ids: plantings.pluck(:owner_id), - has_photos: photos.size.positive?, - thumbnail_url: default_photo&.thumbnail_url, - scientific_name: default_scientific_name&.name, - created_at: created_at.to_i + planters_ids: plantings.pluck(:owner_id), + has_photos: photos.size.positive?, + thumbnail_url: default_photo&.thumbnail_url, + scientific_name: default_scientific_name&.name, + created_at: created_at.to_i } end end diff --git a/app/models/concerns/harvest_search.rb b/app/models/concerns/harvest_search.rb index f54ea996f..2be596aef 100644 --- a/app/models/concerns/harvest_search.rb +++ b/app/models/concerns/harvest_search.rb @@ -3,11 +3,11 @@ module HarvestSearch included do searchkick merge_mappings: true, - mappings: { + mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, harvests_count: { type: :integer }, - photos_count: { type: :integer } + photos_count: { type: :integer } } } @@ -15,29 +15,29 @@ module HarvestSearch def search_data { - slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, - crop_id: crop_id, - plant_part: plant_part&.name, - owner_id: owner_id, - owner_name: owner.login_name, - planting_id: planting_id, - photos_count: photos.size, - has_photos: photos.size.positive?, + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + plant_part: plant_part&.name, + owner_id: owner_id, + owner_name: owner.login_name, + planting_id: planting_id, + photos_count: photos.size, + has_photos: photos.size.positive?, thumbnail_url: default_photo&.thumbnail_url, - created_at: created_at.to_i + created_at: created_at.to_i } end def self.homepage_records(limit) search('*', - limit: limit, - where: { + limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/planting_search.rb index 85f8e48bc..66908079f 100644 --- a/app/models/concerns/planting_search.rb +++ b/app/models/concerns/planting_search.rb @@ -3,11 +3,11 @@ module PlantingSearch included do searchkick merge_mappings: true, - mappings: { + mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, harvests_count: { type: :integer }, - photos_count: { type: :integer }, + photos_count: { type: :integer }, owner_location: { type: :text } } } @@ -16,34 +16,34 @@ module PlantingSearch def search_data { - slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, - crop_id: crop_id, - owner_id: owner_id, - owner_name: owner.login_name, - owner_slug: owner.slug, - planted_from: planted_from, - photos_count: photos.size, - harvests_count: harvests.size, - has_photos: photos.size.positive?, - active: active?, - finished: finished?, - thumbnail_url: default_photo&.thumbnail_url, - owner_location: owner.location, + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + owner_id: owner_id, + owner_name: owner.login_name, + owner_slug: owner.slug, + planted_from: planted_from, + photos_count: photos.size, + harvests_count: harvests.size, + has_photos: photos.size.positive?, + active: active?, + finished: finished?, + thumbnail_url: default_photo&.thumbnail_url, + owner_location: owner.location, percentage_grown: percentage_grown.to_i, - created_at: created_at.to_i + created_at: created_at.to_i } end def self.homepage_records(limit) search('*', - limit: limit, - where: { + limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end diff --git a/app/models/concerns/seed_search.rb b/app/models/concerns/seed_search.rb index 950b4742f..4848e7e5e 100644 --- a/app/models/concerns/seed_search.rb +++ b/app/models/concerns/seed_search.rb @@ -3,11 +3,11 @@ module SeedSearch included do searchkick merge_mappings: true, - mappings: { + mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, photos_count: { type: :integer }, - tradable_to: { type: :text } + tradable_to: { type: :text } } } @@ -15,31 +15,31 @@ module SeedSearch def search_data { - slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, - crop_id: crop_id, - owner_id: owner_id, - owner_name: owner.login_name, - tradable_to: tradable_to, - tradeable: tradable?, + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + owner_id: owner_id, + owner_name: owner.login_name, + tradable_to: tradable_to, + tradeable: tradable?, parent_planting: parent_planting, - photos_count: photos.size, - has_photos: photos.size.positive?, - thumbnail_url: default_photo&.thumbnail_url, - finished: finished?, - created_at: created_at.to_i + photos_count: photos.size, + has_photos: photos.size.positive?, + thumbnail_url: default_photo&.thumbnail_url, + finished: finished?, + created_at: created_at.to_i } end def self.homepage_records(limit) search('*', - limit: limit, - where: { + limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end From be7846d9a26ac5f6fe300e449a091d169c97bcf2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 16:29:56 +1300 Subject: [PATCH 036/188] Moved rubocop yaml around, hoping to fix codefactor --- .rubocop.yml | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 355a14ac6..2c360bcb9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -15,15 +15,6 @@ Naming/FileName: - 'Gemfile' - 'Gemfile.lock' -Style/StringLiterals: - Enabled: false - -Style/PercentLiteralDelimiters: - PreferredDelimiters: - default: () - '%i': () - '%w': () - Layout/MultilineMethodCallIndentation: EnforcedStyle: indented @@ -36,11 +27,16 @@ Layout/HashAlignment: Layout/ParameterAlignment: EnforcedStyle: with_fixed_indentation - -Style/Documentation: +Style/StringLiterals: Enabled: false -Style/FrozenStringLiteralComment: +Style/PercentLiteralDelimiters: + PreferredDelimiters: + default: () + '%i': () + '%w': () + +Style/Documentation: Enabled: false # Configuration parameters: Include. @@ -59,19 +55,6 @@ Metrics/BlockLength: Metrics/LineLength: Max: 140 -# Remove the following once the code style matches -Metrics/MethodLength: - Max: 34 -Metrics/AbcSize: - Max: 33 -# Configuration parameters: CountComments. -Metrics/ClassLength: - Max: 171 -Metrics/CyclomaticComplexity: - Max: 8 -Metrics/PerceivedComplexity: - Max: 9 - # Places we use update_all, etc even though it skips validations. Rails/SkipsModelValidations: Exclude: From 42f1e614968590944d927707b99094efb7697aee Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 16:30:58 +1300 Subject: [PATCH 037/188] controller tidy up --- app/controllers/harvests_controller.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index 29685f3eb..b25752ac6 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class HarvestsController < ApplicationController before_action :authenticate_member!, except: %i(index show) before_action :set_harvest, only: %i(edit show update destroy) @@ -18,10 +20,10 @@ class HarvestsController < ApplicationController where['planting_id'] = @planting.id if @planting.present? @harvests = Harvest.search('*', - where: where, - limit: 100, - page: params[:page], - load: false, + where: where, + limit: 100, + page: params[:page], + load: false, boost_by: [:created_at]) @filename = csv_filename From e8760f9c38c327cf80ee5f9110b5e7b504742e68 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Fri, 20 Dec 2019 03:33:23 +0000 Subject: [PATCH 038/188] [CodeFactor] Apply fixes --- app/controllers/admin/members_controller.rb | 2 ++ app/controllers/admin/roles_controller.rb | 2 ++ app/controllers/admin_controller.rb | 2 ++ app/controllers/alternate_names_controller.rb | 2 ++ app/controllers/api/v1/base_controller.rb | 2 ++ app/controllers/api/v1/crops_controller.rb | 2 ++ app/controllers/api/v1/gardens_controller.rb | 2 ++ app/controllers/api/v1/harvests_controller.rb | 2 ++ app/controllers/api/v1/members_controller.rb | 2 ++ app/controllers/api/v1/photos_controller.rb | 2 ++ app/controllers/api/v1/plantings_controller.rb | 2 ++ app/controllers/api/v1/seeds_controller.rb | 2 ++ app/controllers/application_controller.rb | 2 ++ app/controllers/authentications_controller.rb | 2 ++ app/controllers/charts/crops_controller.rb | 2 ++ app/controllers/charts/gardens_controller.rb | 2 ++ app/controllers/comments_controller.rb | 2 ++ app/controllers/conversations_controller.rb | 2 ++ app/controllers/crops_controller.rb | 2 ++ app/controllers/follows_controller.rb | 2 ++ app/controllers/forums_controller.rb | 2 ++ app/controllers/garden_types_controller.rb | 2 ++ app/controllers/gardens_controller.rb | 2 ++ app/controllers/home_controller.rb | 2 ++ app/controllers/likes_controller.rb | 2 ++ app/controllers/members_controller.rb | 2 ++ app/controllers/messages_controller.rb | 2 ++ app/controllers/omniauth_callbacks_controller.rb | 2 ++ app/controllers/pages_controller.rb | 2 ++ app/controllers/passwords_controller.rb | 2 ++ app/controllers/photo_associations_controller.rb | 2 ++ app/controllers/photos_controller.rb | 2 ++ app/controllers/places_controller.rb | 2 ++ app/controllers/plant_parts_controller.rb | 2 ++ app/controllers/plantings_controller.rb | 2 ++ app/controllers/posts_controller.rb | 2 ++ app/controllers/registrations_controller.rb | 2 ++ app/controllers/robots_controller.rb | 4 +++- app/controllers/scientific_names_controller.rb | 2 ++ app/controllers/seeds_controller.rb | 2 ++ app/controllers/sessions_controller.rb | 2 ++ app/controllers/timeline_controller.rb | 2 ++ app/helpers/application_helper.rb | 2 ++ app/helpers/auto_suggest_helper.rb | 2 ++ app/helpers/buttons_helper.rb | 2 ++ app/helpers/crops_helper.rb | 2 ++ app/helpers/editable_form_helper.rb | 2 ++ app/helpers/event_helper.rb | 2 ++ app/helpers/gardens_helper.rb | 2 ++ app/helpers/harvests_helper.rb | 2 ++ app/helpers/icons_helper.rb | 2 ++ app/helpers/photos_helper.rb | 2 ++ app/helpers/plantings_helper.rb | 2 ++ app/helpers/posts_helper.rb | 2 ++ app/helpers/seeds_helper.rb | 2 ++ app/jobs/application_job.rb | 2 ++ app/mailers/application_mailer.rb | 2 ++ app/mailers/notifier.rb | 2 ++ app/models/ability.rb | 2 ++ app/models/alternate_name.rb | 2 ++ app/models/application_record.rb | 2 ++ app/models/authentication.rb | 2 ++ app/models/comment.rb | 2 ++ app/models/concerns/crop_search.rb | 2 ++ app/models/concerns/finishable.rb | 2 ++ app/models/concerns/harvest_search.rb | 2 ++ app/models/concerns/likeable.rb | 2 ++ app/models/concerns/member_flickr.rb | 2 ++ app/models/concerns/member_newsletter.rb | 2 ++ app/models/concerns/open_farm_data.rb | 2 ++ app/models/concerns/ownable.rb | 2 ++ app/models/concerns/photo_capable.rb | 2 ++ app/models/concerns/photo_search.rb | 2 ++ app/models/concerns/planting_search.rb | 2 ++ app/models/concerns/predict_harvest.rb | 2 ++ app/models/concerns/predict_planting.rb | 2 ++ app/models/concerns/seed_search.rb | 2 ++ app/models/crop.rb | 2 ++ app/models/crop_companion.rb | 2 ++ app/models/crop_post.rb | 2 ++ app/models/csv_importer.rb | 2 ++ app/models/follow.rb | 2 ++ app/models/forum.rb | 2 ++ app/models/garden.rb | 2 ++ app/models/garden_type.rb | 2 ++ app/models/harvest.rb | 2 ++ app/models/like.rb | 2 ++ app/models/member.rb | 2 ++ app/models/notification.rb | 2 ++ app/models/photo.rb | 2 ++ app/models/photo_association.rb | 2 ++ app/models/plant_part.rb | 2 ++ app/models/planting.rb | 2 ++ app/models/post.rb | 2 ++ app/models/role.rb | 2 ++ app/models/scientific_name.rb | 2 ++ app/models/seed.rb | 2 ++ app/resources/api/v1/crop_resource.rb | 2 ++ app/resources/api/v1/garden_resource.rb | 2 ++ app/resources/api/v1/harvest_resource.rb | 2 ++ app/resources/api/v1/member_resource.rb | 2 ++ app/resources/api/v1/photo_resource.rb | 2 ++ app/resources/api/v1/planting_resource.rb | 2 ++ app/resources/api/v1/seed_resource.rb | 2 ++ app/resources/base_resource.rb | 2 ++ app/services/crop_search_service.rb | 2 ++ app/services/timeline_service.rb | 2 ++ app/validators/approved_validator.rb | 2 ++ config.rb | 2 ++ config/application.rb | 2 ++ config/boot.rb | 2 ++ config/compass.rb | 2 ++ config/environment.rb | 2 ++ config/environments/development.rb | 2 ++ config/environments/production.rb | 2 ++ config/environments/test.rb | 2 ++ config/factory_bot.rb | 2 ++ config/initializers/application_controller_renderer.rb | 1 + config/initializers/assets.rb | 2 ++ config/initializers/backtrace_silencers.rb | 1 + config/initializers/comfortable_mexican_sofa.rb | 2 ++ config/initializers/content_security_policy.rb | 1 + config/initializers/cookies_serializer.rb | 2 ++ config/initializers/devise.rb | 2 ++ config/initializers/escaped_markdown.rb | 2 ++ config/initializers/filter_parameter_logging.rb | 2 ++ config/initializers/friendly_id.rb | 2 ++ config/initializers/geocoder.rb | 2 ++ config/initializers/growstuff_markdown.rb | 2 ++ config/initializers/inflections.rb | 2 ++ config/initializers/jsonapi_resources.rb | 2 ++ config/initializers/leaflet.rb | 2 ++ config/initializers/mailboxer.rb | 2 ++ config/initializers/mime_types.rb | 1 + config/initializers/new_framework_defaults_5_1.rb | 2 ++ config/initializers/new_framework_defaults_5_2.rb | 1 + config/initializers/omniauth.rb | 2 ++ config/initializers/rswag_api.rb | 2 ++ config/initializers/rswag_ui.rb | 2 ++ config/initializers/session_store.rb | 2 ++ config/initializers/sidekiq.rb | 2 ++ config/initializers/swagger.rb | 2 ++ config/initializers/time_formats.rb | 2 ++ config/initializers/wrap_parameters.rb | 2 ++ config/routes.rb | 2 ++ config/setup_load_paths.rb | 2 ++ config/spring.rb | 2 ++ config/unicorn.rb | 2 ++ db/migrate/20120903092956_devise_create_users.rb | 2 ++ db/migrate/20120903112806_add_username_to_users.rb | 2 ++ db/migrate/20121001212604_create_crops.rb | 2 ++ db/migrate/20121003190731_require_system_name_for_crops.rb | 2 ++ db/migrate/20121027035231_add_slug_to_crops.rb | 2 ++ db/migrate/20121105032913_create_gardens.rb | 2 ++ db/migrate/20121106101718_add_slug_to_users.rb | 2 ++ db/migrate/20121107012827_create_scientific_names.rb | 2 ++ db/migrate/20121108105440_create_updates.rb | 2 ++ db/migrate/20121109130033_add_creation_index_to_updates.rb | 2 ++ db/migrate/20121203034745_add_tos_agreement_to_users.rb | 2 ++ db/migrate/20121214224227_add_slug_to_updates.rb | 2 ++ db/migrate/20121219022554_create_plantings.rb | 2 ++ db/migrate/20130113045802_rename_updates_to_posts.rb | 2 ++ db/migrate/20130113060852_rename_users_to_members.rb | 2 ++ db/migrate/20130113081521_rename_post_member_to_author.rb | 2 ++ db/migrate/20130113095802_rename_garden_member_to_owner.rb | 2 ++ db/migrate/20130118031942_add_description_to_gardens.rb | 2 ++ db/migrate/20130118043431_add_slug_to_plantings.rb | 2 ++ db/migrate/20130206033956_create_comments.rb | 2 ++ db/migrate/20130206051328_add_show_email_to_member.rb | 2 ++ db/migrate/20130208034248_require_fields_for_comments.rb | 2 ++ db/migrate/20130212001748_add_geo_to_members.rb | 2 ++ db/migrate/20130212123628_create_notifications.rb | 2 ++ db/migrate/20130213014511_create_forums.rb | 2 ++ db/migrate/20130213015708_add_forum_to_posts.rb | 2 ++ db/migrate/20130214024117_create_roles.rb | 2 ++ db/migrate/20130214034838_add_members_roles_table.rb | 2 ++ db/migrate/20130215131921_rename_notification_fields.rb | 2 ++ db/migrate/20130220044605_add_slug_to_forums.rb | 2 ++ db/migrate/20130220044642_add_slug_to_roles.rb | 2 ++ db/migrate/20130222060730_default_read_to_false.rb | 2 ++ db/migrate/20130326092227_change_planted_at_to_date.rb | 2 ++ db/migrate/20130327120024_add_send_email_to_member.rb | 2 ++ db/migrate/20130329045744_add_sunniness_to_planting.rb | 2 ++ db/migrate/20130404174459_create_authentications.rb | 2 ++ db/migrate/20130409103549_make_post_subject_non_null.rb | 2 ++ db/migrate/20130409162140_add_name_to_authentications.rb | 2 ++ db/migrate/20130507105357_create_products.rb | 2 ++ db/migrate/20130507110411_create_orders.rb | 2 ++ db/migrate/20130507113915_add_orders_products_table.rb | 2 ++ db/migrate/20130508050711_add_completed_to_order.rb | 2 ++ db/migrate/20130508104506_create_photos.rb | 2 ++ db/migrate/20130509123711_add_metadata_to_photos.rb | 2 ++ db/migrate/20130514124515_add_parent_to_crop.rb | 2 ++ db/migrate/20130515033842_create_order_items.rb | 2 ++ .../20130515054017_change_order_member_id_to_integer.rb | 2 ++ db/migrate/20130515122301_change_prices_to_integers.rb | 2 ++ db/migrate/20130517015920_create_account_details.rb | 2 ++ db/migrate/20130517051922_create_account_types.rb | 2 ++ db/migrate/20130517234458_require_account_type_name.rb | 2 ++ db/migrate/20130518000339_add_columns_to_product.rb | 2 ++ db/migrate/20130518002942_rename_account_detail_to_account.rb | 2 ++ db/migrate/20130529032813_add_express_token_to_orders.rb | 2 ++ db/migrate/20130531110729_add_photos_plantings_table.rb | 2 ++ db/migrate/20130601011725_change_flickr_photo_id_to_string.rb | 2 ++ .../20130606230333_change_product_description_to_text.rb | 2 ++ db/migrate/20130606233733_add_recommended_price_to_product.rb | 2 ++ db/migrate/20130705104238_add_planted_from_to_planting.rb | 2 ++ db/migrate/20130715110134_create_seeds.rb | 2 ++ .../20130718005600_change_use_by_to_plant_before_on_seed.rb | 2 ++ db/migrate/20130718011247_add_trading_to_seeds.rb | 2 ++ db/migrate/20130722050836_remove_tradable_from_seeds.rb | 2 ++ db/migrate/20130723103128_set_default_tradable_to_on_seed.rb | 2 ++ db/migrate/20130723110702_add_slug_to_seed.rb | 2 ++ db/migrate/20130809012511_add_bio_to_members.rb | 2 ++ db/migrate/20130819004549_add_planting_count_to_crop.rb | 2 ++ db/migrate/20130821011352_add_creator_to_crops.rb | 2 ++ db/migrate/20130821073736_add_creator_to_scientific_name.rb | 2 ++ db/migrate/20130826012139_add_owner_to_planting.rb | 2 ++ db/migrate/20130826023159_add_plantings_count_to_member.rb | 2 ++ db/migrate/20130827105823_add_newsletter_to_member.rb | 2 ++ db/migrate/20130913015118_add_referral_code_to_order.rb | 2 ++ db/migrate/20130917053547_create_harvests.rb | 2 ++ .../20130917060257_change_harvest_notes_to_description.rb | 2 ++ db/migrate/20130917071545_change_harvest_units_to_unit.rb | 2 ++ db/migrate/20130917075803_add_slug_to_harvests.rb | 2 ++ db/migrate/20130925050304_add_weight_to_harvests.rb | 2 ++ db/migrate/20131018101204_rename_system_name_to_name.rb | 2 ++ db/migrate/20131025104228_add_fields_to_gardens.rb | 2 ++ db/migrate/20131029053113_add_plant_part_to_harvests.rb | 2 ++ db/migrate/20131030230908_create_plant_parts.rb | 2 ++ .../20131030231202_change_plant_part_to_plant_part_id.rb | 2 ++ db/migrate/20131031000655_add_slug_to_plant_part.rb | 2 ++ db/migrate/20140718075753_default_plantings_count_to_zero.rb | 2 ++ db/migrate/20140829230600_add_finished_to_planting.rb | 2 ++ db/migrate/20140905001730_add_harvests_photos_table.rb | 2 ++ db/migrate/20140928044231_add_crops_posts_table.rb | 2 ++ .../20140928085713_add_send_planting_reminder_to_member.rb | 2 ++ db/migrate/20141002022459_create_index_harvest_photos.rb | 2 ++ db/migrate/20141018111015_create_alternate_names.rb | 2 ++ db/migrate/20141111130849_create_follows.rb | 2 ++ .../20141119130555_change_follows_member_id_to_follower_id.rb | 2 ++ db/migrate/20150124110540_add_properties_to_seeds.rb | 2 ++ db/migrate/20150127043022_add_gardens_photos_table.rb | 2 ++ db/migrate/20150129034206_add_si_weight_to_harvest.rb | 2 ++ db/migrate/20150130224814_add_requester_to_crops.rb | 2 ++ db/migrate/20150201052245_create_cms.rb | 2 ++ db/migrate/20150201053200_add_approval_status_to_crops.rb | 2 ++ .../20150201062506_add_reason_for_rejection_to_crops.rb | 2 ++ db/migrate/20150201064502_add_request_notes_to_crops.rb | 2 ++ db/migrate/20150203080226_create_likes.rb | 2 ++ db/migrate/20150209105410_add_rejection_notes_to_crops.rb | 2 ++ .../20150625224805_add_days_before_maturity_to_plantings.rb | 2 ++ db/migrate/20150824145414_add_member_preferred_image.rb | 2 ++ db/migrate/20161129021533_rename_scientific_name.rb | 2 ++ db/migrate/20161201154922_add_photos_seeds_table.rb | 2 ++ db/migrate/20170104035248_add_planting_ref_to_harvests.rb | 2 ++ db/migrate/20170413221549_counter_caches.rb | 2 ++ db/migrate/20170520060252_add_deleted_to_members.rb | 2 ++ db/migrate/20171022032108_all_the_predictions.rb | 2 ++ db/migrate/20171028230429_create_median_function.rb | 2 ++ db/migrate/20171105011017_set_prediction_data.rb | 2 ++ db/migrate/20171129041341_create_photographings.rb | 2 ++ db/migrate/20180118112809_add_datetaken_to_photos.rb | 2 ++ db/migrate/20180205000612_remove_shop.rb | 2 ++ db/migrate/20180213005731_seed_usage.rb | 2 ++ db/migrate/20180401220637_add_member_count_caches.rb | 2 ++ db/migrate/20190130090437_add_crop_to_photographings.rb | 2 ++ db/migrate/20190317023129_finished_boolean.rb | 2 ++ db/migrate/20190326063855_create_garden_types.rb | 2 ++ db/migrate/20190326224347_add_harvests_count.rb | 2 ++ db/migrate/20190712003735_add_like_counter_caches.rb | 2 ++ db/migrate/20190712234859_rename_photographings.rb | 2 ++ .../20190720000555_create_mailboxer.mailboxer_engine.rb | 2 ++ ...20190720000556_add_conversation_optout.mailboxer_engine.rb | 2 ++ .../20190720000557_add_missing_indices.mailboxer_engine.rb | 2 ++ ...ry_tracking_info_to_mailboxer_receipts.mailboxer_engine.rb | 2 ++ db/migrate/20190720000625_notifications_to_mailboxer.rb | 2 ++ db/migrate/20190721042146_paranoia_to_discard.rb | 2 ++ db/migrate/20190902004225_add_openfarm_data_to_crops.rb | 2 ++ db/migrate/20190910022329_add_photo_source.rb | 2 ++ db/migrate/20190915065209_create_crop_companions.rb | 2 ++ db/migrate/20190918033319_unique_urls.rb | 2 ++ db/migrate/20190921211652_crop_posts.rb | 2 ++ db/migrate/20191029024101_add_saved_at_to_seeds.rb | 2 ++ db/migrate/20191119020643_upgrade_cms.rb | 2 ++ db/migrate/20191119030244_cms_tags.rb | 2 ++ db/migrate/20191209202348_add_harvest_count_to_crop.rb | 2 ++ db/seeds.rb | 2 ++ lib/actions/oauth_signup_action.rb | 2 ++ lib/geocodable.rb | 2 ++ lib/haml/filters/escaped_markdown.rb | 2 ++ lib/haml/filters/growstuff_markdown.rb | 2 ++ lib/tasks/growstuff.rake | 2 ++ lib/tasks/hooks.rake | 2 ++ lib/tasks/i18n.rake | 2 ++ lib/tasks/openfarm.rake | 2 ++ lib/tasks/search.rake | 2 ++ lib/tasks/testing.rake | 2 ++ script/check_contributors_md.rb | 2 ++ script/check_static.rb | 1 + script/heroku_maintenance.rb | 1 + spec/controllers/admin/roles_controller_spec.rb | 2 ++ spec/controllers/admin_controller_spec.rb | 2 ++ spec/controllers/authentications_controller_spec.rb | 2 ++ spec/controllers/charts/crops_controller_spec.rb | 2 ++ spec/controllers/charts/gardens_controller_spec.rb | 2 ++ spec/controllers/comments_controller_spec.rb | 2 ++ spec/controllers/crops_controller_spec.rb | 2 ++ spec/controllers/forums_controller_spec.rb | 2 ++ spec/controllers/garden_types_controller_spec.rb | 2 ++ spec/controllers/gardens_controller_spec.rb | 2 ++ spec/controllers/harvests_controller_spec.rb | 2 ++ spec/controllers/home_controller_spec.rb | 2 ++ spec/controllers/likes_controller_spec.rb | 2 ++ spec/controllers/member_controller_spec.rb | 2 ++ spec/controllers/photo_associations_controller_spec.rb | 2 ++ spec/controllers/places_controller_spec.rb | 2 ++ spec/controllers/plant_parts_controller_spec.rb | 2 ++ spec/controllers/plantings_controller_spec.rb | 2 ++ spec/controllers/posts_controller_spec.rb | 2 ++ spec/controllers/registrations_controller_spec.rb | 2 ++ spec/controllers/robots_controller_spec.rb | 2 ++ spec/controllers/scientific_names_controller_spec.rb | 2 ++ spec/controllers/seeds_controller_spec.rb | 2 ++ spec/custom_matchers.rb | 2 ++ spec/factories/alternate_names.rb | 2 ++ spec/factories/authentications.rb | 2 ++ spec/factories/comments.rb | 2 ++ spec/factories/crop.rb | 2 ++ spec/factories/crop_companions.rb | 2 ++ spec/factories/follows.rb | 2 ++ spec/factories/forums.rb | 2 ++ spec/factories/garden.rb | 2 ++ spec/factories/garden_types.rb | 2 ++ spec/factories/harvests.rb | 2 ++ spec/factories/like.rb | 2 ++ spec/factories/member.rb | 2 ++ spec/factories/notifications.rb | 2 ++ spec/factories/photos.rb | 2 ++ spec/factories/plant_parts.rb | 2 ++ spec/factories/planting.rb | 2 ++ spec/factories/post.rb | 2 ++ spec/factories/roles.rb | 2 ++ spec/factories/scientific_name.rb | 2 ++ spec/factories/seeds.rb | 2 ++ spec/features/admin/admin_spec.rb | 2 ++ spec/features/admin/forums_spec.rb | 2 ++ spec/features/cms_spec.rb | 2 ++ spec/features/comments/commenting_a_comment_spec.rb | 2 ++ spec/features/conversations/index_spec.rb | 2 ++ spec/features/conversations/show_spec.rb | 2 ++ spec/features/crops/alternate_name_spec.rb | 2 ++ spec/features/crops/browse_crops_spec.rb | 2 ++ spec/features/crops/creating_a_crop_spec.rb | 2 ++ spec/features/crops/crop_detail_page_spec.rb | 2 ++ spec/features/crops/crop_photos_spec.rb | 2 ++ spec/features/crops/crop_search_spec.rb | 2 ++ spec/features/crops/crop_wranglers_spec.rb | 2 ++ spec/features/crops/crop_wrangling_button_spec.rb | 2 ++ spec/features/crops/delete_crop_spec.rb | 2 ++ spec/features/crops/inflections_spec.rb | 2 ++ spec/features/crops/request_new_crop_spec.rb | 2 ++ spec/features/crops/requested_crops_spec.rb | 2 ++ spec/features/crops/scientific_name_spec.rb | 2 ++ spec/features/crops/show_spec.rb | 2 ++ spec/features/footer_spec.rb | 2 ++ spec/features/gardens/actions_spec.rb | 2 ++ spec/features/gardens/adding_gardens_spec.rb | 2 ++ spec/features/gardens/gardens_spec.rb | 2 ++ spec/features/gardens/index_spec.rb | 2 ++ spec/features/harvests/browse_harvests_spec.rb | 2 ++ spec/features/harvests/harvesting_a_crop_spec.rb | 2 ++ spec/features/home/home_spec.rb | 2 ++ spec/features/likeable_spec.rb | 2 ++ spec/features/locale_spec.rb | 2 ++ spec/features/members/ban_spec.rb | 2 ++ spec/features/members/deletion_spec.rb | 2 ++ spec/features/members/following_spec.rb | 2 ++ spec/features/members/list_spec.rb | 2 ++ spec/features/members/profile_spec.rb | 2 ++ spec/features/percy/percy_spec.rb | 2 ++ spec/features/photos/new_photo_spec.rb | 2 ++ spec/features/photos/show_photo_spec.rb | 2 ++ spec/features/places/searching_a_place_spec.rb | 2 ++ spec/features/planting_reminder_spec.rb | 2 ++ spec/features/plantings/planting_a_crop_spec.rb | 2 ++ spec/features/plantings/prediction_spec.rb | 2 ++ spec/features/plantings/show_spec.rb | 2 ++ spec/features/posts/posting_a_post_spec.rb | 2 ++ spec/features/rss/comments_spec.rb | 2 ++ spec/features/rss/crops_spec.rb | 2 ++ spec/features/rss/members_spec.rb | 2 ++ spec/features/rss/plantings_spec.rb | 2 ++ spec/features/rss/posts_spec.rb | 2 ++ spec/features/rss/seeds_spec.rb | 2 ++ spec/features/seeds/adding_seeds_spec.rb | 2 ++ spec/features/seeds/misc_seeds_spec.rb | 2 ++ spec/features/seeds/seed_photos.rb | 2 ++ spec/features/shared_examples/append_date.rb | 2 ++ spec/features/shared_examples/crop_suggest.rb | 2 ++ spec/features/signin_spec.rb | 2 ++ spec/features/signout_spec.rb | 2 ++ spec/features/signup_spec.rb | 2 ++ spec/features/timeline/index_spec.rb | 2 ++ spec/features/unsubscribing_spec.rb | 2 ++ spec/helpers/application_helper_spec.rb | 2 ++ spec/helpers/buttons_helper_spec.rb | 2 ++ spec/helpers/crops_helper_spec.rb | 2 ++ spec/helpers/event_helper_spec.rb | 2 ++ spec/helpers/gardens_helper_spec.rb | 2 ++ spec/helpers/harvests_helper_spec.rb | 2 ++ spec/helpers/photos_helper_spec.rb | 2 ++ spec/helpers/plantings_helper_spec.rb | 2 ++ spec/helpers/seeds_helper_spec.rb | 2 ++ spec/lib/actions/oauth_signup_action_spec.rb | 2 ++ spec/lib/haml/filters/escaped_markdown_spec.rb | 2 ++ spec/lib/haml/filters/growstuff_markdown_spec.rb | 2 ++ spec/models/ability_spec.rb | 2 ++ spec/models/alternate_name_spec.rb | 2 ++ spec/models/authentication_spec.rb | 2 ++ spec/models/comment_spec.rb | 2 ++ spec/models/crop_companion_spec.rb | 2 ++ spec/models/crop_spec.rb | 2 ++ spec/models/follow_spec.rb | 2 ++ spec/models/forum_spec.rb | 2 ++ spec/models/garden_spec.rb | 2 ++ spec/models/garden_type.rb | 2 ++ spec/models/harvest_spec.rb | 2 ++ spec/models/like_spec.rb | 2 ++ spec/models/member_spec.rb | 2 ++ spec/models/notification_spec.rb | 2 ++ spec/models/photo_spec.rb | 2 ++ spec/models/plant_part_spec.rb | 2 ++ spec/models/planting_spec.rb | 2 ++ spec/models/post_spec.rb | 2 ++ spec/models/role_spec.rb | 2 ++ spec/models/scientific_name_spec.rb | 2 ++ spec/models/seed_spec.rb | 2 ++ spec/rails_helper.rb | 2 ++ spec/requests/api/v1/crop_request_spec.rb | 2 ++ spec/requests/api/v1/gardens_request_spec.rb | 2 ++ spec/requests/api/v1/harvest_request_spec.rb | 2 ++ spec/requests/api/v1/member_request_spec.rb | 2 ++ spec/requests/api/v1/photos_request_spec.rb | 2 ++ spec/requests/api/v1/plantings_request_spec.rb | 2 ++ spec/requests/api/v1/seeds_request_spec.rb | 2 ++ spec/requests/authentications_spec.rb | 2 ++ spec/requests/conversations_spec.rb | 2 ++ spec/requests/forums_spec.rb | 2 ++ spec/requests/garden_types_spec.rb | 2 ++ spec/requests/gardens_spec.rb | 2 ++ spec/requests/harvests_spec.rb | 2 ++ spec/requests/photos_spec.rb | 2 ++ spec/requests/plant_parts_spec.rb | 2 ++ spec/requests/plantings_spec.rb | 2 ++ spec/requests/post_spec.rb | 2 ++ spec/requests/scientific_names_spec.rb | 2 ++ spec/requests/seeds_spec.rb | 2 ++ spec/routing/admin_routing_spec.rb | 2 ++ spec/routing/authentications_routing_spec.rb | 2 ++ spec/routing/comments_routing_spec.rb | 2 ++ spec/routing/crops_routing_spec.rb | 2 ++ spec/routing/follows_routing_spec.rb | 2 ++ spec/routing/forums_routing_spec.rb | 2 ++ spec/routing/garden_types_routing_spec.rb | 2 ++ spec/routing/gardens_routing_spec.rb | 2 ++ spec/routing/harvests_routing_spec.rb | 2 ++ spec/routing/member_routing_spec.rb | 2 ++ spec/routing/photos_routing_spec.rb | 2 ++ spec/routing/plant_parts_routing_spec.rb | 2 ++ spec/routing/plantings_routing_spec.rb | 2 ++ spec/routing/roles_routing_spec.rb | 2 ++ spec/routing/scientific_names_routing_spec.rb | 2 ++ spec/routing/seeds_routing_spec.rb | 2 ++ spec/routing/updates_routing_spec.rb | 2 ++ spec/services/timeline_service_spec.rb | 2 ++ spec/spec_helper.rb | 2 ++ spec/support/controller_macros.rb | 2 ++ spec/support/database_cleaner.rb | 2 ++ spec/support/devise.rb | 2 ++ spec/support/feature_helpers.rb | 2 ++ spec/support/is_likeable.rb | 2 ++ spec/swagger_helper.rb | 2 ++ spec/views/admin/index_spec.rb | 2 ++ spec/views/admin/newsletter_spec.rb | 2 ++ spec/views/admin/roles/edit.html.haml_spec.rb | 2 ++ spec/views/admin/roles/index.html.haml_spec.rb | 2 ++ spec/views/admin/roles/new.html.haml_spec.rb | 2 ++ spec/views/comments/edit.html.haml_spec.rb | 2 ++ spec/views/comments/index.rss.haml_spec.rb | 2 ++ spec/views/comments/new.html.haml_spec.rb | 2 ++ spec/views/crops/_grown_for.html.haml_spec.rb | 2 ++ spec/views/crops/_popover.html.haml_spec.rb | 2 ++ spec/views/crops/edit.html.haml_spec.rb | 2 ++ spec/views/crops/hierarchy.html.haml_spec.rb | 2 ++ spec/views/crops/index.html.haml_spec.rb | 2 ++ spec/views/crops/index.rss.haml_spec.rb | 2 ++ spec/views/crops/new.html.haml_spec.rb | 2 ++ spec/views/crops/wrangle.html.haml_spec.rb | 2 ++ spec/views/devise/confirmations/new_spec.rb | 2 ++ spec/views/devise/mailer/confirmation_instructions_spec.rb | 2 ++ spec/views/devise/mailer/reset_password_instructions_spec.rb | 2 ++ spec/views/devise/mailer/unlock_instructions_spec.rb | 2 ++ spec/views/devise/registrations/edit_spec.rb | 2 ++ spec/views/devise/registrations/new_spec.rb | 2 ++ spec/views/devise/sessions/new_spec.rb | 2 ++ spec/views/devise/shared/_links_spec.rb | 2 ++ spec/views/devise/unlocks/new_spec.rb | 2 ++ spec/views/forums/edit.html.haml_spec.rb | 2 ++ spec/views/forums/index.html.haml_spec.rb | 2 ++ spec/views/forums/new.html.haml_spec.rb | 2 ++ spec/views/forums/show.html.haml_spec.rb | 2 ++ spec/views/garden_types/edit.html.haml_spec.rb | 2 ++ spec/views/garden_types/new.html.haml_spec.rb | 2 ++ spec/views/garden_types/show.html.haml_spec.rb | 2 ++ spec/views/gardens/edit.html.haml_spec.rb | 2 ++ spec/views/gardens/new.html.haml_spec.rb | 2 ++ spec/views/gardens/show.html.haml_spec.rb | 2 ++ spec/views/harvests/edit.html.haml_spec.rb | 2 ++ spec/views/harvests/index.html.haml_spec.rb | 2 ++ spec/views/harvests/index.rss.haml_spec.rb | 2 ++ spec/views/harvests/new.html.haml_spec.rb | 2 ++ spec/views/harvests/show.html.haml_spec.rb | 2 ++ spec/views/home/_blurb.html.haml_spec.rb | 2 ++ spec/views/home/_members.html.haml_spec.rb | 2 ++ spec/views/home/_seeds.html.haml_spec.rb | 2 ++ spec/views/home/_stats.html.haml_spec.rb | 2 ++ spec/views/home/index_spec.rb | 2 ++ spec/views/layouts/_head_spec.rb | 2 ++ spec/views/layouts/_header_spec.rb | 2 ++ spec/views/layouts/application_spec.rb | 2 ++ spec/views/members/_location.html.haml_spec.rb | 2 ++ spec/views/members/index.html.haml_spec.rb | 2 ++ spec/views/members/show.rss.haml_spec.rb | 2 ++ spec/views/photos/edit.html.haml_spec.rb | 2 ++ spec/views/photos/index.html.haml_spec.rb | 2 ++ spec/views/photos/new.html.haml_spec.rb | 2 ++ spec/views/photos/show.html.haml_spec.rb | 2 ++ spec/views/places/_map_attribution.html.haml_spec.rb | 2 ++ spec/views/places/index.html.haml_spec.rb | 2 ++ spec/views/places/show.html.haml_spec.rb | 2 ++ spec/views/plant_parts/edit.html.haml_spec.rb | 2 ++ spec/views/plant_parts/index.html.haml_spec.rb | 2 ++ spec/views/plant_parts/new.html.haml_spec.rb | 2 ++ spec/views/plant_parts/show.html.haml_spec.rb | 2 ++ spec/views/plantings/_form.html.haml_spec.rb | 2 ++ spec/views/plantings/edit.html.haml_spec.rb | 2 ++ spec/views/plantings/index.html.haml_spec.rb | 2 ++ spec/views/plantings/index.rss.haml_spec.rb | 2 ++ spec/views/plantings/new.html.haml_spec.rb | 2 ++ spec/views/plantings/show.html.haml_spec.rb | 2 ++ spec/views/posts/_single.html.haml_spec.rb | 2 ++ spec/views/posts/edit.html.haml_spec.rb | 2 ++ spec/views/posts/index.html.haml_spec.rb | 2 ++ spec/views/posts/index.rss.haml_spec.rb | 2 ++ spec/views/posts/new.html.haml_spec.rb | 2 ++ spec/views/posts/show.html.haml_spec.rb | 2 ++ spec/views/posts/show.rss.haml_spec.rb | 2 ++ spec/views/scientific_names/edit.html.haml_spec.rb | 2 ++ spec/views/scientific_names/index.html.haml_spec.rb | 2 ++ spec/views/scientific_names/new.html.haml_spec.rb | 2 ++ spec/views/scientific_names/show.html.haml_spec.rb | 2 ++ spec/views/seeds/edit.html.haml_spec.rb | 2 ++ spec/views/seeds/index.rss.haml_spec.rb | 2 ++ spec/views/seeds/new.html.haml_spec.rb | 2 ++ spec/views/seeds/show.html.haml_spec.rb | 2 ++ 566 files changed, 1126 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/members_controller.rb b/app/controllers/admin/members_controller.rb index 0526a57c0..cf10b5c0d 100644 --- a/app/controllers/admin/members_controller.rb +++ b/app/controllers/admin/members_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class MembersController < ApplicationController before_action :admin! diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb index d08c292dc..3ad46e6ac 100644 --- a/app/controllers/admin/roles_controller.rb +++ b/app/controllers/admin/roles_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class RolesController < ApplicationController before_action :admin! diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 541567430..454faf1c7 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AdminController < ApplicationController respond_to :html def index diff --git a/app/controllers/alternate_names_controller.rb b/app/controllers/alternate_names_controller.rb index 3466f72a9..922c078cf 100644 --- a/app/controllers/alternate_names_controller.rb +++ b/app/controllers/alternate_names_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AlternateNamesController < ApplicationController before_action :authenticate_member!, except: %i(index) load_and_authorize_resource diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb index 4fbc4d806..84eb42dcc 100644 --- a/app/controllers/api/v1/base_controller.rb +++ b/app/controllers/api/v1/base_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class BaseController < JSONAPI::ResourceController diff --git a/app/controllers/api/v1/crops_controller.rb b/app/controllers/api/v1/crops_controller.rb index d67beaa1a..f75516a43 100644 --- a/app/controllers/api/v1/crops_controller.rb +++ b/app/controllers/api/v1/crops_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class CropsController < BaseController diff --git a/app/controllers/api/v1/gardens_controller.rb b/app/controllers/api/v1/gardens_controller.rb index 4343d8014..ff420cf6a 100644 --- a/app/controllers/api/v1/gardens_controller.rb +++ b/app/controllers/api/v1/gardens_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class GardensController < BaseController diff --git a/app/controllers/api/v1/harvests_controller.rb b/app/controllers/api/v1/harvests_controller.rb index bcf735dce..1bef4212d 100644 --- a/app/controllers/api/v1/harvests_controller.rb +++ b/app/controllers/api/v1/harvests_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class HarvestsController < BaseController diff --git a/app/controllers/api/v1/members_controller.rb b/app/controllers/api/v1/members_controller.rb index b9b99956d..7f08067e9 100644 --- a/app/controllers/api/v1/members_controller.rb +++ b/app/controllers/api/v1/members_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class MembersController < BaseController diff --git a/app/controllers/api/v1/photos_controller.rb b/app/controllers/api/v1/photos_controller.rb index a095d24cb..693edd1fa 100644 --- a/app/controllers/api/v1/photos_controller.rb +++ b/app/controllers/api/v1/photos_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class PhotosController < BaseController diff --git a/app/controllers/api/v1/plantings_controller.rb b/app/controllers/api/v1/plantings_controller.rb index d143676ab..dc2bc689f 100644 --- a/app/controllers/api/v1/plantings_controller.rb +++ b/app/controllers/api/v1/plantings_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class PlantingsController < BaseController diff --git a/app/controllers/api/v1/seeds_controller.rb b/app/controllers/api/v1/seeds_controller.rb index 43f5691c6..53722ea6a 100644 --- a/app/controllers/api/v1/seeds_controller.rb +++ b/app/controllers/api/v1/seeds_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class SeedsController < BaseController diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ceafaa6cb..7e01327d6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationController < ActionController::Base protect_from_forgery diff --git a/app/controllers/authentications_controller.rb b/app/controllers/authentications_controller.rb index fc18ff4d7..31056c6e1 100644 --- a/app/controllers/authentications_controller.rb +++ b/app/controllers/authentications_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require './lib/actions/oauth_signup_action' class AuthenticationsController < ApplicationController before_action :authenticate_member! diff --git a/app/controllers/charts/crops_controller.rb b/app/controllers/charts/crops_controller.rb index 9626a76b9..a48ec1ab2 100644 --- a/app/controllers/charts/crops_controller.rb +++ b/app/controllers/charts/crops_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Charts class CropsController < ApplicationController respond_to :json diff --git a/app/controllers/charts/gardens_controller.rb b/app/controllers/charts/gardens_controller.rb index b9d25bb53..a7048c57f 100644 --- a/app/controllers/charts/gardens_controller.rb +++ b/app/controllers/charts/gardens_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Charts class GardensController < ApplicationController respond_to :json diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index d47dae87d..37f2a5b16 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CommentsController < ApplicationController before_action :authenticate_member!, except: %i(index) load_and_authorize_resource diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb index e5da3be93..14b51e8ff 100644 --- a/app/controllers/conversations_controller.rb +++ b/app/controllers/conversations_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ConversationsController < ApplicationController respond_to :html before_action :authenticate_member! diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index eecca829c..994ffe19b 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'will_paginate/array' class CropsController < ApplicationController diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index 1555a4a7c..2caf0f336 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class FollowsController < ApplicationController before_action :set_member, only: %i(index followers) load_and_authorize_resource diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index df6d1cad2..bc75da5fa 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ForumsController < ApplicationController load_and_authorize_resource respond_to :html, :json diff --git a/app/controllers/garden_types_controller.rb b/app/controllers/garden_types_controller.rb index 5fade528a..567af80ff 100644 --- a/app/controllers/garden_types_controller.rb +++ b/app/controllers/garden_types_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class GardenTypesController < ApplicationController respond_to :html, :json load_and_authorize_resource diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index 3e642837a..568f9b69b 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class GardensController < ApplicationController before_action :authenticate_member!, except: %i(index show) before_action :set_garden, only: %i(edit show update destroy) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 1241c70f5..e5ff4d06b 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class HomeController < ApplicationController skip_authorize_resource respond_to :html diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index 501bc6ee1..37d302fcb 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class LikesController < ApplicationController before_action :authenticate_member! respond_to :html, :json diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 0d07b303f..9b65068d0 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class MembersController < ApplicationController load_and_authorize_resource except: %i(finish_signup unsubscribe view_follows view_followers show) skip_authorize_resource only: %i(nearby unsubscribe finish_signup) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 21bb4d0b2..9efc7ae42 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class MessagesController < ApplicationController respond_to :html, :json before_action :authenticate_member! diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 3d642cd3d..c9243c89b 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require './lib/actions/oauth_signup_action' # diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 9ffb98af8..4da0321de 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PagesController < ApplicationController def letsencrypt # use your code here, not mine diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb index fb6852ea9..012cd352b 100644 --- a/app/controllers/passwords_controller.rb +++ b/app/controllers/passwords_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PasswordsController < Devise::PasswordsController protected diff --git a/app/controllers/photo_associations_controller.rb b/app/controllers/photo_associations_controller.rb index 499dbefc0..00655a736 100644 --- a/app/controllers/photo_associations_controller.rb +++ b/app/controllers/photo_associations_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PhotoAssociationsController < ApplicationController before_action :authenticate_member! respond_to :json, :html diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index c6243ad20..9b7fb7c1b 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PhotosController < ApplicationController before_action :authenticate_member!, except: %i(index show) after_action :expire_homepage, only: %i(create destroy) diff --git a/app/controllers/places_controller.rb b/app/controllers/places_controller.rb index 4586b5d39..a30c1ae98 100644 --- a/app/controllers/places_controller.rb +++ b/app/controllers/places_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PlacesController < ApplicationController skip_authorize_resource respond_to :html, :json diff --git a/app/controllers/plant_parts_controller.rb b/app/controllers/plant_parts_controller.rb index 1e594fd72..8fbd23c59 100644 --- a/app/controllers/plant_parts_controller.rb +++ b/app/controllers/plant_parts_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PlantPartsController < ApplicationController load_and_authorize_resource respond_to :html, :json diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index a47c5a94a..f4fbd6e80 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PlantingsController < ApplicationController before_action :authenticate_member!, except: %i(index show) before_action :set_planting, only: %i(edit show update destroy) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index d6561ce8e..40a70fade 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PostsController < ApplicationController before_action :authenticate_member!, except: %i(index show) load_and_authorize_resource diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 24a8ee8e8..530321233 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RegistrationsController < Devise::RegistrationsController respond_to :json diff --git a/app/controllers/robots_controller.rb b/app/controllers/robots_controller.rb index 84f77e906..7a000749a 100644 --- a/app/controllers/robots_controller.rb +++ b/app/controllers/robots_controller.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class RobotsController < ApplicationController - DEFAULT_FILENAME = 'config/robots.txt'.freeze + DEFAULT_FILENAME = 'config/robots.txt' def robots filename = "config/robots.#{subdomain}.txt" if subdomain && subdomain != 'www' diff --git a/app/controllers/scientific_names_controller.rb b/app/controllers/scientific_names_controller.rb index cf58fd4f7..94a18acf9 100644 --- a/app/controllers/scientific_names_controller.rb +++ b/app/controllers/scientific_names_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ScientificNamesController < ApplicationController before_action :authenticate_member!, except: %i(index show) load_and_authorize_resource diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index 1cf465ab2..f53d8c07d 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SeedsController < ApplicationController before_action :authenticate_member!, except: %i(index show) before_action :set_seed, only: %i(edit show update destroy) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index b8de4b54e..47063d75d 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SessionsController < Devise::SessionsController respond_to :html, :json diff --git a/app/controllers/timeline_controller.rb b/app/controllers/timeline_controller.rb index da912e69a..662480525 100644 --- a/app/controllers/timeline_controller.rb +++ b/app/controllers/timeline_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class TimelineController < ApplicationController def index if current_member diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4cdda2b98..0e3a9d86b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ApplicationHelper def parse_date(str) str ||= '' # Date.parse barfs on nil diff --git a/app/helpers/auto_suggest_helper.rb b/app/helpers/auto_suggest_helper.rb index 85a3f0cbc..1b8521c82 100644 --- a/app/helpers/auto_suggest_helper.rb +++ b/app/helpers/auto_suggest_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module AutoSuggestHelper def auto_suggest(resource, source, options = {}) if options[:default] && !options[:default].new_record? diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 1c4eb5306..ca5cc5d78 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ButtonsHelper include IconsHelper def garden_plant_something_button(garden, classes: "btn btn-default") diff --git a/app/helpers/crops_helper.rb b/app/helpers/crops_helper.rb index f307dc791..7d2187e51 100644 --- a/app/helpers/crops_helper.rb +++ b/app/helpers/crops_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module CropsHelper def display_seed_availability(member, crop) seeds = member.seeds.where(crop: crop) diff --git a/app/helpers/editable_form_helper.rb b/app/helpers/editable_form_helper.rb index 007eeb624..527baf5b2 100644 --- a/app/helpers/editable_form_helper.rb +++ b/app/helpers/editable_form_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module EditableFormHelper def editable(field_type, model, field, display_field:, collection: []) render 'shared/editable/form', field_type: field_type, diff --git a/app/helpers/event_helper.rb b/app/helpers/event_helper.rb index f2ff4a5fe..4bc8033b5 100644 --- a/app/helpers/event_helper.rb +++ b/app/helpers/event_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module EventHelper def in_weeks(days) (days / 7.0).round diff --git a/app/helpers/gardens_helper.rb b/app/helpers/gardens_helper.rb index 1f50d18f4..0ae6d1803 100644 --- a/app/helpers/gardens_helper.rb +++ b/app/helpers/gardens_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module GardensHelper def display_garden_description(garden) if garden.description.nil? diff --git a/app/helpers/harvests_helper.rb b/app/helpers/harvests_helper.rb index ff1838ce4..cce5a10fe 100644 --- a/app/helpers/harvests_helper.rb +++ b/app/helpers/harvests_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module HarvestsHelper def display_quantity(harvest) human_quantity = display_human_quantity(harvest) diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 00eb9fc3d..53ceb403d 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module IconsHelper include FontAwesome::Sass::Rails::ViewHelpers diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb index c13168065..9ae42c282 100644 --- a/app/helpers/photos_helper.rb +++ b/app/helpers/photos_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module PhotosHelper def crop_image_path(crop) thumbnail_url(crop.default_photo) diff --git a/app/helpers/plantings_helper.rb b/app/helpers/plantings_helper.rb index 4de9102ed..3b977f656 100644 --- a/app/helpers/plantings_helper.rb +++ b/app/helpers/plantings_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module PlantingsHelper def display_finished(planting) if planting.finished_at.present? diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index fd676e8d9..ad4afd4be 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module PostsHelper def display_post_truncated(post) length = 300 diff --git a/app/helpers/seeds_helper.rb b/app/helpers/seeds_helper.rb index ab9e28e72..e585a2348 100644 --- a/app/helpers/seeds_helper.rb +++ b/app/helpers/seeds_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SeedsHelper def display_seed_quantity(seed) if seed.quantity.nil? diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index a009ace51..d92ffddcb 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class ApplicationJob < ActiveJob::Base end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 286b2239d..d84cb6e71 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationMailer < ActionMailer::Base default from: 'from@example.com' layout 'mailer' diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index d3ab4b2c5..c9727be3a 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Notifier < ApplicationMailer # include NotificationsHelper default from: "Growstuff <#{ENV['GROWSTUFF_EMAIL']}>" diff --git a/app/models/ability.rb b/app/models/ability.rb index b2231e64b..422c5454f 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Ability include CanCan::Ability diff --git a/app/models/alternate_name.rb b/app/models/alternate_name.rb index f40665b1b..c93602131 100644 --- a/app/models/alternate_name.rb +++ b/app/models/alternate_name.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AlternateName < ApplicationRecord belongs_to :crop belongs_to :creator, class_name: 'Member', inverse_of: :created_alternate_names diff --git a/app/models/application_record.rb b/app/models/application_record.rb index e14f64e66..5d2c9a2e9 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationRecord < ActiveRecord::Base self.abstract_class = true self.per_page = 36 diff --git a/app/models/authentication.rb b/app/models/authentication.rb index 91ecc8de9..98a65a633 100644 --- a/app/models/authentication.rb +++ b/app/models/authentication.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Authentication < ApplicationRecord belongs_to :member end diff --git a/app/models/comment.rb b/app/models/comment.rb index 6e34bbc35..7b85f4c0d 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Comment < ApplicationRecord belongs_to :author, class_name: 'Member', inverse_of: :comments belongs_to :post, counter_cache: true diff --git a/app/models/concerns/crop_search.rb b/app/models/concerns/crop_search.rb index ccc04cb15..6cb2d7b5e 100644 --- a/app/models/concerns/crop_search.rb +++ b/app/models/concerns/crop_search.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module CropSearch extend ActiveSupport::Concern diff --git a/app/models/concerns/finishable.rb b/app/models/concerns/finishable.rb index 42fa4e734..6ff68e9c5 100644 --- a/app/models/concerns/finishable.rb +++ b/app/models/concerns/finishable.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Finishable extend ActiveSupport::Concern diff --git a/app/models/concerns/harvest_search.rb b/app/models/concerns/harvest_search.rb index 2be596aef..7850fd8d7 100644 --- a/app/models/concerns/harvest_search.rb +++ b/app/models/concerns/harvest_search.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module HarvestSearch extend ActiveSupport::Concern diff --git a/app/models/concerns/likeable.rb b/app/models/concerns/likeable.rb index 9db3da6e5..911317a6e 100644 --- a/app/models/concerns/likeable.rb +++ b/app/models/concerns/likeable.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Likeable extend ActiveSupport::Concern diff --git a/app/models/concerns/member_flickr.rb b/app/models/concerns/member_flickr.rb index d5d591dc8..363f74d97 100644 --- a/app/models/concerns/member_flickr.rb +++ b/app/models/concerns/member_flickr.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module MemberFlickr extend ActiveSupport::Concern diff --git a/app/models/concerns/member_newsletter.rb b/app/models/concerns/member_newsletter.rb index 882bac7cb..8f92340ce 100644 --- a/app/models/concerns/member_newsletter.rb +++ b/app/models/concerns/member_newsletter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module MemberNewsletter extend ActiveSupport::Concern diff --git a/app/models/concerns/open_farm_data.rb b/app/models/concerns/open_farm_data.rb index e7d2306ed..f051d43ce 100644 --- a/app/models/concerns/open_farm_data.rb +++ b/app/models/concerns/open_farm_data.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module OpenFarmData extend ActiveSupport::Concern diff --git a/app/models/concerns/ownable.rb b/app/models/concerns/ownable.rb index 6cd40a2e6..8dac572a5 100644 --- a/app/models/concerns/ownable.rb +++ b/app/models/concerns/ownable.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Ownable extend ActiveSupport::Concern diff --git a/app/models/concerns/photo_capable.rb b/app/models/concerns/photo_capable.rb index f96258f87..b585d4b6b 100644 --- a/app/models/concerns/photo_capable.rb +++ b/app/models/concerns/photo_capable.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module PhotoCapable extend ActiveSupport::Concern diff --git a/app/models/concerns/photo_search.rb b/app/models/concerns/photo_search.rb index 6668a9189..90647b0b0 100644 --- a/app/models/concerns/photo_search.rb +++ b/app/models/concerns/photo_search.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module PhotoSearch extend ActiveSupport::Concern diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/planting_search.rb index 66908079f..0b2c1cc5f 100644 --- a/app/models/concerns/planting_search.rb +++ b/app/models/concerns/planting_search.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module PlantingSearch extend ActiveSupport::Concern diff --git a/app/models/concerns/predict_harvest.rb b/app/models/concerns/predict_harvest.rb index 4ea241530..bd11fc116 100644 --- a/app/models/concerns/predict_harvest.rb +++ b/app/models/concerns/predict_harvest.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module PredictHarvest extend ActiveSupport::Concern diff --git a/app/models/concerns/predict_planting.rb b/app/models/concerns/predict_planting.rb index e542568ec..b5aca1f9b 100644 --- a/app/models/concerns/predict_planting.rb +++ b/app/models/concerns/predict_planting.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module PredictPlanting extend ActiveSupport::Concern diff --git a/app/models/concerns/seed_search.rb b/app/models/concerns/seed_search.rb index 4848e7e5e..4eb690741 100644 --- a/app/models/concerns/seed_search.rb +++ b/app/models/concerns/seed_search.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SeedSearch extend ActiveSupport::Concern diff --git a/app/models/crop.rb b/app/models/crop.rb index 78da0337a..703576e5d 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Crop < ApplicationRecord extend FriendlyId include PhotoCapable diff --git a/app/models/crop_companion.rb b/app/models/crop_companion.rb index 55d7c27a1..3d09b1947 100644 --- a/app/models/crop_companion.rb +++ b/app/models/crop_companion.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CropCompanion < ApplicationRecord belongs_to :crop_a, class_name: :Crop belongs_to :crop_b, class_name: :Crop diff --git a/app/models/crop_post.rb b/app/models/crop_post.rb index 5c520e3b6..04c8e71ec 100644 --- a/app/models/crop_post.rb +++ b/app/models/crop_post.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CropPost < ApplicationRecord belongs_to :crop belongs_to :post diff --git a/app/models/csv_importer.rb b/app/models/csv_importer.rb index d3b992aba..41ab325ce 100644 --- a/app/models/csv_importer.rb +++ b/app/models/csv_importer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CsvImporter # used by db/seeds.rb and rake growstuff:import_crops # CSV fields: diff --git a/app/models/follow.rb b/app/models/follow.rb index a70fd15f6..1ee678ef2 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Follow < ApplicationRecord belongs_to :follower, class_name: "Member", inverse_of: :follows belongs_to :followed, class_name: "Member", inverse_of: :inverse_follows diff --git a/app/models/forum.rb b/app/models/forum.rb index 664af4f38..2ecae932c 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Forum < ApplicationRecord extend FriendlyId include Ownable diff --git a/app/models/garden.rb b/app/models/garden.rb index 865c11d6d..95c619dbe 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Garden < ApplicationRecord extend FriendlyId include Geocodable diff --git a/app/models/garden_type.rb b/app/models/garden_type.rb index b81789b69..bed371e24 100644 --- a/app/models/garden_type.rb +++ b/app/models/garden_type.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class GardenType < ApplicationRecord extend FriendlyId friendly_id :name, use: %i(slugged finders) diff --git a/app/models/harvest.rb b/app/models/harvest.rb index b0f4701d5..3c9f490bf 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Harvest < ApplicationRecord include ActionView::Helpers::NumberHelper extend FriendlyId diff --git a/app/models/like.rb b/app/models/like.rb index f74903739..5cf7992a0 100644 --- a/app/models/like.rb +++ b/app/models/like.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Like < ApplicationRecord belongs_to :member belongs_to :likeable, polymorphic: true, counter_cache: true diff --git a/app/models/member.rb b/app/models/member.rb index 2762a6020..5d373000c 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Member < ApplicationRecord include Discard::Model acts_as_messageable # messages can be sent to this model diff --git a/app/models/notification.rb b/app/models/notification.rb index 466fe73be..55e270d3d 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Notification < ApplicationRecord belongs_to :sender, class_name: 'Member', inverse_of: :sent_notifications belongs_to :recipient, class_name: 'Member', inverse_of: :notifications diff --git a/app/models/photo.rb b/app/models/photo.rb index feafe8741..258ad62b8 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Photo < ApplicationRecord include Likeable include Ownable diff --git a/app/models/photo_association.rb b/app/models/photo_association.rb index 87126dd0b..36a953230 100644 --- a/app/models/photo_association.rb +++ b/app/models/photo_association.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PhotoAssociation < ApplicationRecord belongs_to :photo, inverse_of: :photo_associations belongs_to :photographable, polymorphic: true diff --git a/app/models/plant_part.rb b/app/models/plant_part.rb index 6fd57bff5..e7e808309 100644 --- a/app/models/plant_part.rb +++ b/app/models/plant_part.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PlantPart < ApplicationRecord extend FriendlyId friendly_id :name, use: %i(slugged finders) diff --git a/app/models/planting.rb b/app/models/planting.rb index d4f3e1130..e73f41849 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Planting < ApplicationRecord extend FriendlyId include PhotoCapable diff --git a/app/models/post.rb b/app/models/post.rb index fd5abb130..659291584 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Post < ApplicationRecord extend FriendlyId include Likeable diff --git a/app/models/role.rb b/app/models/role.rb index cd985d115..b89db3287 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Role < ApplicationRecord extend FriendlyId friendly_id :name, use: %i(slugged finders) diff --git a/app/models/scientific_name.rb b/app/models/scientific_name.rb index b2da3320f..94ab605b6 100644 --- a/app/models/scientific_name.rb +++ b/app/models/scientific_name.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ScientificName < ApplicationRecord belongs_to :crop belongs_to :creator, class_name: 'Member', inverse_of: :created_scientific_names diff --git a/app/models/seed.rb b/app/models/seed.rb index 21970fba1..48e08823d 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Seed < ApplicationRecord extend FriendlyId include PhotoCapable diff --git a/app/resources/api/v1/crop_resource.rb b/app/resources/api/v1/crop_resource.rb index 8eac32091..abbf22584 100644 --- a/app/resources/api/v1/crop_resource.rb +++ b/app/resources/api/v1/crop_resource.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class CropResource < BaseResource diff --git a/app/resources/api/v1/garden_resource.rb b/app/resources/api/v1/garden_resource.rb index cffcb27fb..4b4a32bbe 100644 --- a/app/resources/api/v1/garden_resource.rb +++ b/app/resources/api/v1/garden_resource.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class GardenResource < BaseResource diff --git a/app/resources/api/v1/harvest_resource.rb b/app/resources/api/v1/harvest_resource.rb index c1ce0ae0f..502bee5bf 100644 --- a/app/resources/api/v1/harvest_resource.rb +++ b/app/resources/api/v1/harvest_resource.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class HarvestResource < BaseResource diff --git a/app/resources/api/v1/member_resource.rb b/app/resources/api/v1/member_resource.rb index 4013aeea4..9a2731f2e 100644 --- a/app/resources/api/v1/member_resource.rb +++ b/app/resources/api/v1/member_resource.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class MemberResource < BaseResource diff --git a/app/resources/api/v1/photo_resource.rb b/app/resources/api/v1/photo_resource.rb index 84c7eab16..6da294cd8 100644 --- a/app/resources/api/v1/photo_resource.rb +++ b/app/resources/api/v1/photo_resource.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class PhotoResource < BaseResource diff --git a/app/resources/api/v1/planting_resource.rb b/app/resources/api/v1/planting_resource.rb index 1e41078fb..0db7e40bd 100644 --- a/app/resources/api/v1/planting_resource.rb +++ b/app/resources/api/v1/planting_resource.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class PlantingResource < BaseResource diff --git a/app/resources/api/v1/seed_resource.rb b/app/resources/api/v1/seed_resource.rb index e994ce1a0..82dd53ee2 100644 --- a/app/resources/api/v1/seed_resource.rb +++ b/app/resources/api/v1/seed_resource.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class SeedResource < BaseResource diff --git a/app/resources/base_resource.rb b/app/resources/base_resource.rb index 2d54fdf0d..46de0ce53 100644 --- a/app/resources/base_resource.rb +++ b/app/resources/base_resource.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class BaseResource < JSONAPI::Resource immutable abstract diff --git a/app/services/crop_search_service.rb b/app/services/crop_search_service.rb index 645505e04..274d5a3c0 100644 --- a/app/services/crop_search_service.rb +++ b/app/services/crop_search_service.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CropSearchService # Crop.search(string) def self.search(query, page: 1, per_page: 12, current_member: nil) diff --git a/app/services/timeline_service.rb b/app/services/timeline_service.rb index 8ed765083..328eb17dd 100644 --- a/app/services/timeline_service.rb +++ b/app/services/timeline_service.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class TimelineService def self.member_query(member) query.where(owner_id: member.id) diff --git a/app/validators/approved_validator.rb b/app/validators/approved_validator.rb index 8a77fa2da..179bfef18 100644 --- a/app/validators/approved_validator.rb +++ b/app/validators/approved_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApprovedValidator < ActiveModel::EachValidator def validate_each(record, attribute, _value) record.errors[attribute] << (options[:message] || 'must be approved') unless record.crop.try(:approved?) diff --git a/config.rb b/config.rb index 214d25ef0..328f8a9de 100644 --- a/config.rb +++ b/config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" diff --git a/config/application.rb b/config/application.rb index a42ae3bae..b34bc36f8 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'boot' require 'rails/all' diff --git a/config/boot.rb b/config/boot.rb index 4423c97f2..73bf2c9b7 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/compass.rb b/config/compass.rb index 2b22d5d7c..81dc9bdcd 100644 --- a/config/compass.rb +++ b/config/compass.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + # Require any additional compass plugins here. project_type = :rails diff --git a/config/environment.rb b/config/environment.rb index 426333bb4..d5abe5580 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Load the Rails application. require_relative 'application' diff --git a/config/environments/development.rb b/config/environments/development.rb index 46106e08d..caaf7fcd9 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. diff --git a/config/environments/production.rb b/config/environments/production.rb index 6ffdc773b..882d7a463 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. diff --git a/config/environments/test.rb b/config/environments/test.rb index 2a0efb6bf..8c31b6991 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. diff --git a/config/factory_bot.rb b/config/factory_bot.rb index 43d50d52f..e4925f2a3 100644 --- a/config/factory_bot.rb +++ b/config/factory_bot.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ActionDispatch::Callbacks.after do # Reload the factories return unless Rails.env.development? || Rails.env.test? diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb index 89d2efab2..f4556db39 100644 --- a/config/initializers/application_controller_renderer.rb +++ b/config/initializers/application_controller_renderer.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # ActiveSupport::Reloader.to_prepare do diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 60484d4a4..c3da5a1a6 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 59385cdf3..d0f0d3b5d 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. diff --git a/config/initializers/comfortable_mexican_sofa.rb b/config/initializers/comfortable_mexican_sofa.rb index dc8148fdc..80dce6018 100644 --- a/config/initializers/comfortable_mexican_sofa.rb +++ b/config/initializers/comfortable_mexican_sofa.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ComfortableMexicanSofa.configure do |config| # Title of the admin area # config.cms_title = 'ComfortableMexicanSofa CMS Engine' diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index d3bcaa5ec..497f5667c 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Define an application-wide content security policy diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 5a6a32d37..ee8dff9c9 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Specify a serializer for the signed and encrypted cookie jars. diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 974551c93..7692ebbc7 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # rubocop:disable Metrics/LineLength # Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. diff --git a/config/initializers/escaped_markdown.rb b/config/initializers/escaped_markdown.rb index 87837b0c5..6cad3bdf1 100644 --- a/config/initializers/escaped_markdown.rb +++ b/config/initializers/escaped_markdown.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + require 'haml/filters/escaped_markdown' diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 4a994e1e7..7a4f47b4c 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. diff --git a/config/initializers/friendly_id.rb b/config/initializers/friendly_id.rb index 3a88f87be..90586aa83 100644 --- a/config/initializers/friendly_id.rb +++ b/config/initializers/friendly_id.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # FriendlyId Global Configuration # # Use this to set up shared configuration options for your entire application. diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb index 1a2f76e54..ef916e735 100644 --- a/config/initializers/geocoder.rb +++ b/config/initializers/geocoder.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'geocodable' Geocoder.configure( diff --git a/config/initializers/growstuff_markdown.rb b/config/initializers/growstuff_markdown.rb index a7f6781b2..901237fb3 100644 --- a/config/initializers/growstuff_markdown.rb +++ b/config/initializers/growstuff_markdown.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + require 'haml/filters/growstuff_markdown' diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 039431538..39ff77ae8 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections diff --git a/config/initializers/jsonapi_resources.rb b/config/initializers/jsonapi_resources.rb index 1a17dfc07..d4ddadb44 100644 --- a/config/initializers/jsonapi_resources.rb +++ b/config/initializers/jsonapi_resources.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + JSONAPI.configure do |config| # built in paginators are :none, :offset, :paged config.default_paginator = :offset diff --git a/config/initializers/leaflet.rb b/config/initializers/leaflet.rb index 510a97070..3a8c09b6d 100644 --- a/config/initializers/leaflet.rb +++ b/config/initializers/leaflet.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Leaflet.tile_layer = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' Leaflet.attribution = '© OpenStreetMap contributors, CC-BY-SA' Leaflet.max_zoom = 18 diff --git a/config/initializers/mailboxer.rb b/config/initializers/mailboxer.rb index 6f1b0fa7c..b43a61519 100644 --- a/config/initializers/mailboxer.rb +++ b/config/initializers/mailboxer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Mailboxer.setup do |config| # Configures if your application uses or not email sending for Notifications and Messages config.uses_emails = true diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index dc1899682..6e1d16f02 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: diff --git a/config/initializers/new_framework_defaults_5_1.rb b/config/initializers/new_framework_defaults_5_1.rb index 9010abd5c..b33ee806c 100644 --- a/config/initializers/new_framework_defaults_5_1.rb +++ b/config/initializers/new_framework_defaults_5_1.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # # This file contains migration options to ease your Rails 5.1 upgrade. diff --git a/config/initializers/new_framework_defaults_5_2.rb b/config/initializers/new_framework_defaults_5_2.rb index c383d072b..7df9ce8f4 100644 --- a/config/initializers/new_framework_defaults_5_2.rb +++ b/config/initializers/new_framework_defaults_5_2.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # # This file contains migration options to ease your Rails 5.2 upgrade. diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 160efb102..940d84a48 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.config.middleware.use OmniAuth::Builder do provider :twitter, ENV['GROWSTUFF_TWITTER_KEY'], ENV['GROWSTUFF_TWITTER_SECRET'] provider :flickr, ENV['GROWSTUFF_FLICKR_KEY'], ENV['GROWSTUFF_FLICKR_SECRET'] diff --git a/config/initializers/rswag_api.rb b/config/initializers/rswag_api.rb index 3c027ffd8..307807a93 100644 --- a/config/initializers/rswag_api.rb +++ b/config/initializers/rswag_api.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rswag::Api.configure do |c| # Specify a root folder where Swagger JSON files are located # This is used by the Swagger middleware to serve requests for API descriptions diff --git a/config/initializers/rswag_ui.rb b/config/initializers/rswag_ui.rb index 4d7adbaa8..8b632a43f 100644 --- a/config/initializers/rswag_ui.rb +++ b/config/initializers/rswag_ui.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rswag::Ui.configure do |c| # List the Swagger endpoints that you want to be documented through the swagger-ui # The first parameter is the path (absolute or relative to the UI host) to the corresponding diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 9fc739015..26a833e0b 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. Rails.application.config.session_store :cookie_store, key: '_growstuff_session' diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 4dab98d12..15990b73e 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # config/initializers/sidekiq.rb Sidekiq.configure_server do |config| diff --git a/config/initializers/swagger.rb b/config/initializers/swagger.rb index 0bdadefc0..830a9a36d 100644 --- a/config/initializers/swagger.rb +++ b/config/initializers/swagger.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Jsonapi::Swagger.config do |config| config.use_rswag = false config.version = '2.0' diff --git a/config/initializers/time_formats.rb b/config/initializers/time_formats.rb index 3f3adf454..c56b40bef 100644 --- a/config/initializers/time_formats.rb +++ b/config/initializers/time_formats.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Time::DATE_FORMATS[:default] = '%B %d, %Y at %H:%M' Date::DATE_FORMATS[:default] = "%B %d, %Y" diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index bffab6c85..3d5ac2557 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which diff --git a/config/routes.rb b/config/routes.rb index 3a6f0298c..0be2fc781 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.routes.draw do mount Rswag::Ui::Engine => '/api-docs' mount Rswag::Api::Engine => '/api-docs' diff --git a/config/setup_load_paths.rb b/config/setup_load_paths.rb index b78f9aff0..36e63028a 100644 --- a/config/setup_load_paths.rb +++ b/config/setup_load_paths.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + if ENV['MY_RUBY_HOME']&.include?('rvm') begin require 'rvm' diff --git a/config/spring.rb b/config/spring.rb index c9119b40c..ff5ba06b6 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + %w( .ruby-version .rbenv-vars diff --git a/config/unicorn.rb b/config/unicorn.rb index fa76bae3a..c4218569a 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # from https://blog.heroku.com/archives/2013/2/27/unicorn_rails worker_processes 3 timeout 30 diff --git a/db/migrate/20120903092956_devise_create_users.rb b/db/migrate/20120903092956_devise_create_users.rb index 62d84f3d1..08d044fd0 100644 --- a/db/migrate/20120903092956_devise_create_users.rb +++ b/db/migrate/20120903092956_devise_create_users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DeviseCreateUsers < ActiveRecord::Migration[4.2] def change create_table(:users) do |t| diff --git a/db/migrate/20120903112806_add_username_to_users.rb b/db/migrate/20120903112806_add_username_to_users.rb index 2df3aa569..f27c39cd7 100644 --- a/db/migrate/20120903112806_add_username_to_users.rb +++ b/db/migrate/20120903112806_add_username_to_users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddUsernameToUsers < ActiveRecord::Migration[4.2] def change add_column :users, :username, :string diff --git a/db/migrate/20121001212604_create_crops.rb b/db/migrate/20121001212604_create_crops.rb index 6e6fbcc2c..4c2832f3d 100644 --- a/db/migrate/20121001212604_create_crops.rb +++ b/db/migrate/20121001212604_create_crops.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateCrops < ActiveRecord::Migration[4.2] def change create_table :crops do |t| diff --git a/db/migrate/20121003190731_require_system_name_for_crops.rb b/db/migrate/20121003190731_require_system_name_for_crops.rb index 7989fcecf..1731554ca 100644 --- a/db/migrate/20121003190731_require_system_name_for_crops.rb +++ b/db/migrate/20121003190731_require_system_name_for_crops.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RequireSystemNameForCrops < ActiveRecord::Migration[4.2] def up change_table :crops do |t| diff --git a/db/migrate/20121027035231_add_slug_to_crops.rb b/db/migrate/20121027035231_add_slug_to_crops.rb index d360b4a44..fb31e5622 100644 --- a/db/migrate/20121027035231_add_slug_to_crops.rb +++ b/db/migrate/20121027035231_add_slug_to_crops.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSlugToCrops < ActiveRecord::Migration[4.2] def change add_column :crops, :slug, :string diff --git a/db/migrate/20121105032913_create_gardens.rb b/db/migrate/20121105032913_create_gardens.rb index e6c7834e1..41cee2446 100644 --- a/db/migrate/20121105032913_create_gardens.rb +++ b/db/migrate/20121105032913_create_gardens.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateGardens < ActiveRecord::Migration[4.2] def change create_table :gardens do |t| diff --git a/db/migrate/20121106101718_add_slug_to_users.rb b/db/migrate/20121106101718_add_slug_to_users.rb index 5840e09d2..599eb29c0 100644 --- a/db/migrate/20121106101718_add_slug_to_users.rb +++ b/db/migrate/20121106101718_add_slug_to_users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSlugToUsers < ActiveRecord::Migration[4.2] def change add_column :users, :slug, :string diff --git a/db/migrate/20121107012827_create_scientific_names.rb b/db/migrate/20121107012827_create_scientific_names.rb index 0e6b179f7..bbef3d1b1 100644 --- a/db/migrate/20121107012827_create_scientific_names.rb +++ b/db/migrate/20121107012827_create_scientific_names.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateScientificNames < ActiveRecord::Migration[4.2] def change create_table :scientific_names do |t| diff --git a/db/migrate/20121108105440_create_updates.rb b/db/migrate/20121108105440_create_updates.rb index 3caacb749..35ded8d63 100644 --- a/db/migrate/20121108105440_create_updates.rb +++ b/db/migrate/20121108105440_create_updates.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateUpdates < ActiveRecord::Migration[4.2] def change create_table :updates do |t| diff --git a/db/migrate/20121109130033_add_creation_index_to_updates.rb b/db/migrate/20121109130033_add_creation_index_to_updates.rb index 57c24d559..30652d549 100644 --- a/db/migrate/20121109130033_add_creation_index_to_updates.rb +++ b/db/migrate/20121109130033_add_creation_index_to_updates.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddCreationIndexToUpdates < ActiveRecord::Migration[4.2] def change add_index :updates, %i(created_at user_id) diff --git a/db/migrate/20121203034745_add_tos_agreement_to_users.rb b/db/migrate/20121203034745_add_tos_agreement_to_users.rb index 31354ea58..466d8c452 100644 --- a/db/migrate/20121203034745_add_tos_agreement_to_users.rb +++ b/db/migrate/20121203034745_add_tos_agreement_to_users.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddTosAgreementToUsers < ActiveRecord::Migration[4.2] def change add_column :users, :tos_agreement, :boolean diff --git a/db/migrate/20121214224227_add_slug_to_updates.rb b/db/migrate/20121214224227_add_slug_to_updates.rb index 78d25ef24..e0038dba4 100644 --- a/db/migrate/20121214224227_add_slug_to_updates.rb +++ b/db/migrate/20121214224227_add_slug_to_updates.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSlugToUpdates < ActiveRecord::Migration[4.2] def change add_column :updates, :slug, :string diff --git a/db/migrate/20121219022554_create_plantings.rb b/db/migrate/20121219022554_create_plantings.rb index d586e2426..f618875d3 100644 --- a/db/migrate/20121219022554_create_plantings.rb +++ b/db/migrate/20121219022554_create_plantings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreatePlantings < ActiveRecord::Migration[4.2] def change create_table :plantings do |t| diff --git a/db/migrate/20130113045802_rename_updates_to_posts.rb b/db/migrate/20130113045802_rename_updates_to_posts.rb index 6329df2bb..fecca7c3b 100644 --- a/db/migrate/20130113045802_rename_updates_to_posts.rb +++ b/db/migrate/20130113045802_rename_updates_to_posts.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameUpdatesToPosts < ActiveRecord::Migration[4.2] def change rename_table :updates, :posts diff --git a/db/migrate/20130113060852_rename_users_to_members.rb b/db/migrate/20130113060852_rename_users_to_members.rb index bb248186e..a278a3068 100644 --- a/db/migrate/20130113060852_rename_users_to_members.rb +++ b/db/migrate/20130113060852_rename_users_to_members.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameUsersToMembers < ActiveRecord::Migration[4.2] def change rename_table :users, :members diff --git a/db/migrate/20130113081521_rename_post_member_to_author.rb b/db/migrate/20130113081521_rename_post_member_to_author.rb index a1658925b..6cb4ae04c 100644 --- a/db/migrate/20130113081521_rename_post_member_to_author.rb +++ b/db/migrate/20130113081521_rename_post_member_to_author.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenamePostMemberToAuthor < ActiveRecord::Migration[4.2] def change rename_column :posts, :member_id, :author_id diff --git a/db/migrate/20130113095802_rename_garden_member_to_owner.rb b/db/migrate/20130113095802_rename_garden_member_to_owner.rb index ea6bd4c72..4ebd10d08 100644 --- a/db/migrate/20130113095802_rename_garden_member_to_owner.rb +++ b/db/migrate/20130113095802_rename_garden_member_to_owner.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameGardenMemberToOwner < ActiveRecord::Migration[4.2] def change rename_column :gardens, :member_id, :owner_id diff --git a/db/migrate/20130118031942_add_description_to_gardens.rb b/db/migrate/20130118031942_add_description_to_gardens.rb index f8eb0a441..e846901e4 100644 --- a/db/migrate/20130118031942_add_description_to_gardens.rb +++ b/db/migrate/20130118031942_add_description_to_gardens.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDescriptionToGardens < ActiveRecord::Migration[4.2] def change add_column :gardens, :description, :text diff --git a/db/migrate/20130118043431_add_slug_to_plantings.rb b/db/migrate/20130118043431_add_slug_to_plantings.rb index c4e5d434d..5f451a835 100644 --- a/db/migrate/20130118043431_add_slug_to_plantings.rb +++ b/db/migrate/20130118043431_add_slug_to_plantings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSlugToPlantings < ActiveRecord::Migration[4.2] def change add_column :plantings, :slug, :string diff --git a/db/migrate/20130206033956_create_comments.rb b/db/migrate/20130206033956_create_comments.rb index 0c4663ec7..894da7768 100644 --- a/db/migrate/20130206033956_create_comments.rb +++ b/db/migrate/20130206033956_create_comments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateComments < ActiveRecord::Migration[4.2] def change create_table :comments do |t| diff --git a/db/migrate/20130206051328_add_show_email_to_member.rb b/db/migrate/20130206051328_add_show_email_to_member.rb index 3185b1377..de734d587 100644 --- a/db/migrate/20130206051328_add_show_email_to_member.rb +++ b/db/migrate/20130206051328_add_show_email_to_member.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddShowEmailToMember < ActiveRecord::Migration[4.2] def change add_column :members, :show_email, :boolean diff --git a/db/migrate/20130208034248_require_fields_for_comments.rb b/db/migrate/20130208034248_require_fields_for_comments.rb index da847671b..eb4ca6467 100644 --- a/db/migrate/20130208034248_require_fields_for_comments.rb +++ b/db/migrate/20130208034248_require_fields_for_comments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RequireFieldsForComments < ActiveRecord::Migration[4.2] def up change_table :comments do |t| diff --git a/db/migrate/20130212001748_add_geo_to_members.rb b/db/migrate/20130212001748_add_geo_to_members.rb index e60f355f8..01406871a 100644 --- a/db/migrate/20130212001748_add_geo_to_members.rb +++ b/db/migrate/20130212001748_add_geo_to_members.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddGeoToMembers < ActiveRecord::Migration[4.2] def change add_column :members, :location, :string diff --git a/db/migrate/20130212123628_create_notifications.rb b/db/migrate/20130212123628_create_notifications.rb index b89b13656..978f3054a 100644 --- a/db/migrate/20130212123628_create_notifications.rb +++ b/db/migrate/20130212123628_create_notifications.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateNotifications < ActiveRecord::Migration[4.2] def change create_table :notifications do |t| diff --git a/db/migrate/20130213014511_create_forums.rb b/db/migrate/20130213014511_create_forums.rb index 0df3f00a2..69a4a30e7 100644 --- a/db/migrate/20130213014511_create_forums.rb +++ b/db/migrate/20130213014511_create_forums.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateForums < ActiveRecord::Migration[4.2] def change create_table :forums do |t| diff --git a/db/migrate/20130213015708_add_forum_to_posts.rb b/db/migrate/20130213015708_add_forum_to_posts.rb index 315ae0be5..e6225db23 100644 --- a/db/migrate/20130213015708_add_forum_to_posts.rb +++ b/db/migrate/20130213015708_add_forum_to_posts.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddForumToPosts < ActiveRecord::Migration[4.2] def change add_column :posts, :forum_id, :integer diff --git a/db/migrate/20130214024117_create_roles.rb b/db/migrate/20130214024117_create_roles.rb index e39c7565d..b0799ecb7 100644 --- a/db/migrate/20130214024117_create_roles.rb +++ b/db/migrate/20130214024117_create_roles.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateRoles < ActiveRecord::Migration[4.2] def change create_table :roles do |t| diff --git a/db/migrate/20130214034838_add_members_roles_table.rb b/db/migrate/20130214034838_add_members_roles_table.rb index 502266a87..32c0b191e 100644 --- a/db/migrate/20130214034838_add_members_roles_table.rb +++ b/db/migrate/20130214034838_add_members_roles_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddMembersRolesTable < ActiveRecord::Migration[4.2] def change create_table :members_roles, id: false do |t| diff --git a/db/migrate/20130215131921_rename_notification_fields.rb b/db/migrate/20130215131921_rename_notification_fields.rb index c2294d2fe..7fcdd3372 100644 --- a/db/migrate/20130215131921_rename_notification_fields.rb +++ b/db/migrate/20130215131921_rename_notification_fields.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameNotificationFields < ActiveRecord::Migration[4.2] def change change_table :notifications do |t| diff --git a/db/migrate/20130220044605_add_slug_to_forums.rb b/db/migrate/20130220044605_add_slug_to_forums.rb index 57fbdc145..179f883af 100644 --- a/db/migrate/20130220044605_add_slug_to_forums.rb +++ b/db/migrate/20130220044605_add_slug_to_forums.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSlugToForums < ActiveRecord::Migration[4.2] def change add_column :forums, :slug, :string diff --git a/db/migrate/20130220044642_add_slug_to_roles.rb b/db/migrate/20130220044642_add_slug_to_roles.rb index a3812d77b..e867ce131 100644 --- a/db/migrate/20130220044642_add_slug_to_roles.rb +++ b/db/migrate/20130220044642_add_slug_to_roles.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSlugToRoles < ActiveRecord::Migration[4.2] def change add_column :roles, :slug, :string diff --git a/db/migrate/20130222060730_default_read_to_false.rb b/db/migrate/20130222060730_default_read_to_false.rb index 81a10aa40..40dea83a4 100644 --- a/db/migrate/20130222060730_default_read_to_false.rb +++ b/db/migrate/20130222060730_default_read_to_false.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DefaultReadToFalse < ActiveRecord::Migration[4.2] def up change_table :notifications do |t| diff --git a/db/migrate/20130326092227_change_planted_at_to_date.rb b/db/migrate/20130326092227_change_planted_at_to_date.rb index 089c77ef5..b2bd78ae3 100644 --- a/db/migrate/20130326092227_change_planted_at_to_date.rb +++ b/db/migrate/20130326092227_change_planted_at_to_date.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangePlantedAtToDate < ActiveRecord::Migration[4.2] def change change_column :plantings, :planted_at, :date diff --git a/db/migrate/20130327120024_add_send_email_to_member.rb b/db/migrate/20130327120024_add_send_email_to_member.rb index 5421bb0d7..89ff6126d 100644 --- a/db/migrate/20130327120024_add_send_email_to_member.rb +++ b/db/migrate/20130327120024_add_send_email_to_member.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSendEmailToMember < ActiveRecord::Migration[4.2] def change add_column :members, :send_notification_email, :boolean, default: true diff --git a/db/migrate/20130329045744_add_sunniness_to_planting.rb b/db/migrate/20130329045744_add_sunniness_to_planting.rb index 74fe7a652..ec79264c8 100644 --- a/db/migrate/20130329045744_add_sunniness_to_planting.rb +++ b/db/migrate/20130329045744_add_sunniness_to_planting.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSunninessToPlanting < ActiveRecord::Migration[4.2] def change add_column :plantings, :sunniness, :string diff --git a/db/migrate/20130404174459_create_authentications.rb b/db/migrate/20130404174459_create_authentications.rb index 226f1c34c..809ad60b2 100644 --- a/db/migrate/20130404174459_create_authentications.rb +++ b/db/migrate/20130404174459_create_authentications.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateAuthentications < ActiveRecord::Migration[4.2] def change create_table :authentications do |t| diff --git a/db/migrate/20130409103549_make_post_subject_non_null.rb b/db/migrate/20130409103549_make_post_subject_non_null.rb index ac05aca24..f11815a65 100644 --- a/db/migrate/20130409103549_make_post_subject_non_null.rb +++ b/db/migrate/20130409103549_make_post_subject_non_null.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class MakePostSubjectNonNull < ActiveRecord::Migration[4.2] change_column :posts, :subject, :string, null: false end diff --git a/db/migrate/20130409162140_add_name_to_authentications.rb b/db/migrate/20130409162140_add_name_to_authentications.rb index dabcb623a..a0e530085 100644 --- a/db/migrate/20130409162140_add_name_to_authentications.rb +++ b/db/migrate/20130409162140_add_name_to_authentications.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddNameToAuthentications < ActiveRecord::Migration[4.2] def change add_column :authentications, :name, :string diff --git a/db/migrate/20130507105357_create_products.rb b/db/migrate/20130507105357_create_products.rb index 5a1ddd995..ac2ef8b63 100644 --- a/db/migrate/20130507105357_create_products.rb +++ b/db/migrate/20130507105357_create_products.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateProducts < ActiveRecord::Migration[4.2] def change create_table :products do |t| diff --git a/db/migrate/20130507110411_create_orders.rb b/db/migrate/20130507110411_create_orders.rb index 7974f10e9..1c4c00c3a 100644 --- a/db/migrate/20130507110411_create_orders.rb +++ b/db/migrate/20130507110411_create_orders.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateOrders < ActiveRecord::Migration[4.2] def change create_table :orders do |t| diff --git a/db/migrate/20130507113915_add_orders_products_table.rb b/db/migrate/20130507113915_add_orders_products_table.rb index 3d5845081..33e34e6a3 100644 --- a/db/migrate/20130507113915_add_orders_products_table.rb +++ b/db/migrate/20130507113915_add_orders_products_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddOrdersProductsTable < ActiveRecord::Migration[4.2] def change create_table :orders_products, id: false do |t| diff --git a/db/migrate/20130508050711_add_completed_to_order.rb b/db/migrate/20130508050711_add_completed_to_order.rb index e7c9f422c..6640113ea 100644 --- a/db/migrate/20130508050711_add_completed_to_order.rb +++ b/db/migrate/20130508050711_add_completed_to_order.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddCompletedToOrder < ActiveRecord::Migration[4.2] def change add_column :orders, :completed_at, :datetime diff --git a/db/migrate/20130508104506_create_photos.rb b/db/migrate/20130508104506_create_photos.rb index b6fb3d19f..cb4a55e86 100644 --- a/db/migrate/20130508104506_create_photos.rb +++ b/db/migrate/20130508104506_create_photos.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreatePhotos < ActiveRecord::Migration[4.2] def change create_table :photos do |t| diff --git a/db/migrate/20130509123711_add_metadata_to_photos.rb b/db/migrate/20130509123711_add_metadata_to_photos.rb index e05c260cb..5b62473f8 100644 --- a/db/migrate/20130509123711_add_metadata_to_photos.rb +++ b/db/migrate/20130509123711_add_metadata_to_photos.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddMetadataToPhotos < ActiveRecord::Migration[4.2] def up change_table :photos do |t| diff --git a/db/migrate/20130514124515_add_parent_to_crop.rb b/db/migrate/20130514124515_add_parent_to_crop.rb index 65427c1c8..9557db8e3 100644 --- a/db/migrate/20130514124515_add_parent_to_crop.rb +++ b/db/migrate/20130514124515_add_parent_to_crop.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddParentToCrop < ActiveRecord::Migration[4.2] def change add_column :crops, :parent_id, :integer diff --git a/db/migrate/20130515033842_create_order_items.rb b/db/migrate/20130515033842_create_order_items.rb index ed7966f46..6305b3819 100644 --- a/db/migrate/20130515033842_create_order_items.rb +++ b/db/migrate/20130515033842_create_order_items.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateOrderItems < ActiveRecord::Migration[4.2] def change create_table :order_items do |t| diff --git a/db/migrate/20130515054017_change_order_member_id_to_integer.rb b/db/migrate/20130515054017_change_order_member_id_to_integer.rb index 508fb13ee..4a010dcc2 100644 --- a/db/migrate/20130515054017_change_order_member_id_to_integer.rb +++ b/db/migrate/20130515054017_change_order_member_id_to_integer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangeOrderMemberIdToInteger < ActiveRecord::Migration[4.2] def up remove_column :orders, :member_id diff --git a/db/migrate/20130515122301_change_prices_to_integers.rb b/db/migrate/20130515122301_change_prices_to_integers.rb index ef84683b2..6a232fe20 100644 --- a/db/migrate/20130515122301_change_prices_to_integers.rb +++ b/db/migrate/20130515122301_change_prices_to_integers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangePricesToIntegers < ActiveRecord::Migration[4.2] def up change_column :order_items, :price, :integer diff --git a/db/migrate/20130517015920_create_account_details.rb b/db/migrate/20130517015920_create_account_details.rb index c949798dc..66a04acec 100644 --- a/db/migrate/20130517015920_create_account_details.rb +++ b/db/migrate/20130517015920_create_account_details.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateAccountDetails < ActiveRecord::Migration[4.2] def change create_table :account_details do |t| diff --git a/db/migrate/20130517051922_create_account_types.rb b/db/migrate/20130517051922_create_account_types.rb index 25bef37b0..410b07013 100644 --- a/db/migrate/20130517051922_create_account_types.rb +++ b/db/migrate/20130517051922_create_account_types.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateAccountTypes < ActiveRecord::Migration[4.2] def change create_table :account_types do |t| diff --git a/db/migrate/20130517234458_require_account_type_name.rb b/db/migrate/20130517234458_require_account_type_name.rb index 2b118492a..d638ad3cd 100644 --- a/db/migrate/20130517234458_require_account_type_name.rb +++ b/db/migrate/20130517234458_require_account_type_name.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RequireAccountTypeName < ActiveRecord::Migration[4.2] def up change_column :account_types, :name, :string, null: false diff --git a/db/migrate/20130518000339_add_columns_to_product.rb b/db/migrate/20130518000339_add_columns_to_product.rb index b3bba3023..d6f80fae4 100644 --- a/db/migrate/20130518000339_add_columns_to_product.rb +++ b/db/migrate/20130518000339_add_columns_to_product.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddColumnsToProduct < ActiveRecord::Migration[4.2] def change add_column :products, :account_type_id, :integer diff --git a/db/migrate/20130518002942_rename_account_detail_to_account.rb b/db/migrate/20130518002942_rename_account_detail_to_account.rb index a806c63a7..cb369ce93 100644 --- a/db/migrate/20130518002942_rename_account_detail_to_account.rb +++ b/db/migrate/20130518002942_rename_account_detail_to_account.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameAccountDetailToAccount < ActiveRecord::Migration[4.2] def change rename_table :account_details, :accounts diff --git a/db/migrate/20130529032813_add_express_token_to_orders.rb b/db/migrate/20130529032813_add_express_token_to_orders.rb index e7d40f417..53de7e9a1 100644 --- a/db/migrate/20130529032813_add_express_token_to_orders.rb +++ b/db/migrate/20130529032813_add_express_token_to_orders.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddExpressTokenToOrders < ActiveRecord::Migration[4.2] def change add_column :orders, :paypal_express_token, :string diff --git a/db/migrate/20130531110729_add_photos_plantings_table.rb b/db/migrate/20130531110729_add_photos_plantings_table.rb index f4a3bb7bd..cb9c4c525 100644 --- a/db/migrate/20130531110729_add_photos_plantings_table.rb +++ b/db/migrate/20130531110729_add_photos_plantings_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPhotosPlantingsTable < ActiveRecord::Migration[4.2] def change create_table :photos_plantings, id: false do |t| diff --git a/db/migrate/20130601011725_change_flickr_photo_id_to_string.rb b/db/migrate/20130601011725_change_flickr_photo_id_to_string.rb index 92cfa1683..b46e4ca20 100644 --- a/db/migrate/20130601011725_change_flickr_photo_id_to_string.rb +++ b/db/migrate/20130601011725_change_flickr_photo_id_to_string.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangeFlickrPhotoIdToString < ActiveRecord::Migration[4.2] def up remove_column :photos, :flickr_photo_id diff --git a/db/migrate/20130606230333_change_product_description_to_text.rb b/db/migrate/20130606230333_change_product_description_to_text.rb index 3393a8ae9..7bae1e6ab 100644 --- a/db/migrate/20130606230333_change_product_description_to_text.rb +++ b/db/migrate/20130606230333_change_product_description_to_text.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangeProductDescriptionToText < ActiveRecord::Migration[4.2] def up change_column :products, :description, :text diff --git a/db/migrate/20130606233733_add_recommended_price_to_product.rb b/db/migrate/20130606233733_add_recommended_price_to_product.rb index d424618f5..076e20f3a 100644 --- a/db/migrate/20130606233733_add_recommended_price_to_product.rb +++ b/db/migrate/20130606233733_add_recommended_price_to_product.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddRecommendedPriceToProduct < ActiveRecord::Migration[4.2] def change add_column :products, :recommended_price, :integer diff --git a/db/migrate/20130705104238_add_planted_from_to_planting.rb b/db/migrate/20130705104238_add_planted_from_to_planting.rb index 1dd4e070d..d36ec2358 100644 --- a/db/migrate/20130705104238_add_planted_from_to_planting.rb +++ b/db/migrate/20130705104238_add_planted_from_to_planting.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPlantedFromToPlanting < ActiveRecord::Migration[4.2] def change add_column :plantings, :planted_from, :string diff --git a/db/migrate/20130715110134_create_seeds.rb b/db/migrate/20130715110134_create_seeds.rb index da8955718..8065f9ace 100644 --- a/db/migrate/20130715110134_create_seeds.rb +++ b/db/migrate/20130715110134_create_seeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateSeeds < ActiveRecord::Migration[4.2] def change create_table :seeds do |t| diff --git a/db/migrate/20130718005600_change_use_by_to_plant_before_on_seed.rb b/db/migrate/20130718005600_change_use_by_to_plant_before_on_seed.rb index b440c2704..c33a73988 100644 --- a/db/migrate/20130718005600_change_use_by_to_plant_before_on_seed.rb +++ b/db/migrate/20130718005600_change_use_by_to_plant_before_on_seed.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangeUseByToPlantBeforeOnSeed < ActiveRecord::Migration[4.2] def change rename_column :seeds, :use_by, :plant_before diff --git a/db/migrate/20130718011247_add_trading_to_seeds.rb b/db/migrate/20130718011247_add_trading_to_seeds.rb index 52add7f50..0ca32df9a 100644 --- a/db/migrate/20130718011247_add_trading_to_seeds.rb +++ b/db/migrate/20130718011247_add_trading_to_seeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddTradingToSeeds < ActiveRecord::Migration[4.2] def change add_column :seeds, :tradable, :boolean diff --git a/db/migrate/20130722050836_remove_tradable_from_seeds.rb b/db/migrate/20130722050836_remove_tradable_from_seeds.rb index 9bea0bd10..d668990ed 100644 --- a/db/migrate/20130722050836_remove_tradable_from_seeds.rb +++ b/db/migrate/20130722050836_remove_tradable_from_seeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemoveTradableFromSeeds < ActiveRecord::Migration[4.2] def up remove_column :seeds, :tradable diff --git a/db/migrate/20130723103128_set_default_tradable_to_on_seed.rb b/db/migrate/20130723103128_set_default_tradable_to_on_seed.rb index 56b88aadb..5cecac550 100644 --- a/db/migrate/20130723103128_set_default_tradable_to_on_seed.rb +++ b/db/migrate/20130723103128_set_default_tradable_to_on_seed.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SetDefaultTradableToOnSeed < ActiveRecord::Migration[4.2] def up change_column_default(:seeds, :tradable_to, 'nowhere') diff --git a/db/migrate/20130723110702_add_slug_to_seed.rb b/db/migrate/20130723110702_add_slug_to_seed.rb index ec52bdad6..cb4fb7040 100644 --- a/db/migrate/20130723110702_add_slug_to_seed.rb +++ b/db/migrate/20130723110702_add_slug_to_seed.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSlugToSeed < ActiveRecord::Migration[4.2] def change add_column :seeds, :slug, :string diff --git a/db/migrate/20130809012511_add_bio_to_members.rb b/db/migrate/20130809012511_add_bio_to_members.rb index b63d11bb4..affc7182a 100644 --- a/db/migrate/20130809012511_add_bio_to_members.rb +++ b/db/migrate/20130809012511_add_bio_to_members.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddBioToMembers < ActiveRecord::Migration[4.2] def change add_column :members, :bio, :text diff --git a/db/migrate/20130819004549_add_planting_count_to_crop.rb b/db/migrate/20130819004549_add_planting_count_to_crop.rb index b25fc4a6b..218648531 100644 --- a/db/migrate/20130819004549_add_planting_count_to_crop.rb +++ b/db/migrate/20130819004549_add_planting_count_to_crop.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPlantingCountToCrop < ActiveRecord::Migration[4.2] def change add_column :crops, :plantings_count, :integer diff --git a/db/migrate/20130821011352_add_creator_to_crops.rb b/db/migrate/20130821011352_add_creator_to_crops.rb index 24aab3f74..9847c51af 100644 --- a/db/migrate/20130821011352_add_creator_to_crops.rb +++ b/db/migrate/20130821011352_add_creator_to_crops.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddCreatorToCrops < ActiveRecord::Migration[4.2] def change add_column :crops, :creator_id, :integer diff --git a/db/migrate/20130821073736_add_creator_to_scientific_name.rb b/db/migrate/20130821073736_add_creator_to_scientific_name.rb index e2904811f..eb6577376 100644 --- a/db/migrate/20130821073736_add_creator_to_scientific_name.rb +++ b/db/migrate/20130821073736_add_creator_to_scientific_name.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddCreatorToScientificName < ActiveRecord::Migration[4.2] def change add_column :scientific_names, :creator_id, :integer diff --git a/db/migrate/20130826012139_add_owner_to_planting.rb b/db/migrate/20130826012139_add_owner_to_planting.rb index 3399870d9..9fb48320b 100644 --- a/db/migrate/20130826012139_add_owner_to_planting.rb +++ b/db/migrate/20130826012139_add_owner_to_planting.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddOwnerToPlanting < ActiveRecord::Migration[4.2] def change add_column :plantings, :owner_id, :integer diff --git a/db/migrate/20130826023159_add_plantings_count_to_member.rb b/db/migrate/20130826023159_add_plantings_count_to_member.rb index 973479981..c4ad47295 100644 --- a/db/migrate/20130826023159_add_plantings_count_to_member.rb +++ b/db/migrate/20130826023159_add_plantings_count_to_member.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPlantingsCountToMember < ActiveRecord::Migration[4.2] def change add_column :members, :plantings_count, :integer diff --git a/db/migrate/20130827105823_add_newsletter_to_member.rb b/db/migrate/20130827105823_add_newsletter_to_member.rb index 25f16a69f..806f6ed98 100644 --- a/db/migrate/20130827105823_add_newsletter_to_member.rb +++ b/db/migrate/20130827105823_add_newsletter_to_member.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddNewsletterToMember < ActiveRecord::Migration[4.2] def change add_column :members, :newsletter, :boolean diff --git a/db/migrate/20130913015118_add_referral_code_to_order.rb b/db/migrate/20130913015118_add_referral_code_to_order.rb index ff9e5a6ff..f4cd52ea4 100644 --- a/db/migrate/20130913015118_add_referral_code_to_order.rb +++ b/db/migrate/20130913015118_add_referral_code_to_order.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddReferralCodeToOrder < ActiveRecord::Migration[4.2] def change add_column :orders, :referral_code, :string diff --git a/db/migrate/20130917053547_create_harvests.rb b/db/migrate/20130917053547_create_harvests.rb index f7e529a30..031aeb66e 100644 --- a/db/migrate/20130917053547_create_harvests.rb +++ b/db/migrate/20130917053547_create_harvests.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateHarvests < ActiveRecord::Migration[4.2] def change create_table :harvests do |t| diff --git a/db/migrate/20130917060257_change_harvest_notes_to_description.rb b/db/migrate/20130917060257_change_harvest_notes_to_description.rb index 8359c0b9c..2c09044d3 100644 --- a/db/migrate/20130917060257_change_harvest_notes_to_description.rb +++ b/db/migrate/20130917060257_change_harvest_notes_to_description.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangeHarvestNotesToDescription < ActiveRecord::Migration[4.2] def change rename_column :harvests, :notes, :description diff --git a/db/migrate/20130917071545_change_harvest_units_to_unit.rb b/db/migrate/20130917071545_change_harvest_units_to_unit.rb index 7f859f47d..21f96af13 100644 --- a/db/migrate/20130917071545_change_harvest_units_to_unit.rb +++ b/db/migrate/20130917071545_change_harvest_units_to_unit.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangeHarvestUnitsToUnit < ActiveRecord::Migration[4.2] def change rename_column :harvests, :units, :unit diff --git a/db/migrate/20130917075803_add_slug_to_harvests.rb b/db/migrate/20130917075803_add_slug_to_harvests.rb index b9bc376e0..2cad48d77 100644 --- a/db/migrate/20130917075803_add_slug_to_harvests.rb +++ b/db/migrate/20130917075803_add_slug_to_harvests.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSlugToHarvests < ActiveRecord::Migration[4.2] def change add_column :harvests, :slug, :string diff --git a/db/migrate/20130925050304_add_weight_to_harvests.rb b/db/migrate/20130925050304_add_weight_to_harvests.rb index 1aa43df6b..a567938fc 100644 --- a/db/migrate/20130925050304_add_weight_to_harvests.rb +++ b/db/migrate/20130925050304_add_weight_to_harvests.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddWeightToHarvests < ActiveRecord::Migration[4.2] def change add_column :harvests, :weight_quantity, :decimal diff --git a/db/migrate/20131018101204_rename_system_name_to_name.rb b/db/migrate/20131018101204_rename_system_name_to_name.rb index 6124d1746..d3d3696a5 100644 --- a/db/migrate/20131018101204_rename_system_name_to_name.rb +++ b/db/migrate/20131018101204_rename_system_name_to_name.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameSystemNameToName < ActiveRecord::Migration[4.2] def up # Rails is smart enough to alter the column being indexed, but not the name diff --git a/db/migrate/20131025104228_add_fields_to_gardens.rb b/db/migrate/20131025104228_add_fields_to_gardens.rb index e77a9c6c9..385493b1b 100644 --- a/db/migrate/20131025104228_add_fields_to_gardens.rb +++ b/db/migrate/20131025104228_add_fields_to_gardens.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddFieldsToGardens < ActiveRecord::Migration[4.2] def change add_column :gardens, :active, :boolean, default: true diff --git a/db/migrate/20131029053113_add_plant_part_to_harvests.rb b/db/migrate/20131029053113_add_plant_part_to_harvests.rb index fad21613f..a3e32b44b 100644 --- a/db/migrate/20131029053113_add_plant_part_to_harvests.rb +++ b/db/migrate/20131029053113_add_plant_part_to_harvests.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPlantPartToHarvests < ActiveRecord::Migration[4.2] def change add_column :harvests, :plant_part, :string diff --git a/db/migrate/20131030230908_create_plant_parts.rb b/db/migrate/20131030230908_create_plant_parts.rb index f3454f978..6c0ac4675 100644 --- a/db/migrate/20131030230908_create_plant_parts.rb +++ b/db/migrate/20131030230908_create_plant_parts.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreatePlantParts < ActiveRecord::Migration[4.2] def change create_table :plant_parts do |t| diff --git a/db/migrate/20131030231202_change_plant_part_to_plant_part_id.rb b/db/migrate/20131030231202_change_plant_part_to_plant_part_id.rb index 134eeca97..ae9ce7838 100644 --- a/db/migrate/20131030231202_change_plant_part_to_plant_part_id.rb +++ b/db/migrate/20131030231202_change_plant_part_to_plant_part_id.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangePlantPartToPlantPartId < ActiveRecord::Migration[4.2] def up remove_column :harvests, :plant_part diff --git a/db/migrate/20131031000655_add_slug_to_plant_part.rb b/db/migrate/20131031000655_add_slug_to_plant_part.rb index 242c30776..1078fd4c3 100644 --- a/db/migrate/20131031000655_add_slug_to_plant_part.rb +++ b/db/migrate/20131031000655_add_slug_to_plant_part.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSlugToPlantPart < ActiveRecord::Migration[4.2] def change add_column :plant_parts, :slug, :string diff --git a/db/migrate/20140718075753_default_plantings_count_to_zero.rb b/db/migrate/20140718075753_default_plantings_count_to_zero.rb index 15ee6df8d..472e17405 100644 --- a/db/migrate/20140718075753_default_plantings_count_to_zero.rb +++ b/db/migrate/20140718075753_default_plantings_count_to_zero.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DefaultPlantingsCountToZero < ActiveRecord::Migration[4.2] def up change_column :crops, :plantings_count, :integer, default: 0 diff --git a/db/migrate/20140829230600_add_finished_to_planting.rb b/db/migrate/20140829230600_add_finished_to_planting.rb index 868298f6d..461f49c2b 100644 --- a/db/migrate/20140829230600_add_finished_to_planting.rb +++ b/db/migrate/20140829230600_add_finished_to_planting.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddFinishedToPlanting < ActiveRecord::Migration[4.2] def change add_column :plantings, :finished, :boolean, default: false diff --git a/db/migrate/20140905001730_add_harvests_photos_table.rb b/db/migrate/20140905001730_add_harvests_photos_table.rb index f05ae0135..d83c91f8d 100644 --- a/db/migrate/20140905001730_add_harvests_photos_table.rb +++ b/db/migrate/20140905001730_add_harvests_photos_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddHarvestsPhotosTable < ActiveRecord::Migration[4.2] def change create_table :harvests_photos, id: false do |t| diff --git a/db/migrate/20140928044231_add_crops_posts_table.rb b/db/migrate/20140928044231_add_crops_posts_table.rb index a9e8761f9..529530fef 100644 --- a/db/migrate/20140928044231_add_crops_posts_table.rb +++ b/db/migrate/20140928044231_add_crops_posts_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddCropsPostsTable < ActiveRecord::Migration[4.2] def change create_table :crops_posts, id: false do |t| diff --git a/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb b/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb index cd464eeed..d2f5316d8 100644 --- a/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb +++ b/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSendPlantingReminderToMember < ActiveRecord::Migration[4.2] def change add_column :members, :send_planting_reminder, :boolean, default: true diff --git a/db/migrate/20141002022459_create_index_harvest_photos.rb b/db/migrate/20141002022459_create_index_harvest_photos.rb index f9c8ee911..26e9f8e70 100644 --- a/db/migrate/20141002022459_create_index_harvest_photos.rb +++ b/db/migrate/20141002022459_create_index_harvest_photos.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateIndexHarvestPhotos < ActiveRecord::Migration[4.2] def change add_index(:harvests_photos, %i(harvest_id photo_id)) diff --git a/db/migrate/20141018111015_create_alternate_names.rb b/db/migrate/20141018111015_create_alternate_names.rb index 65400cc22..bd1cd496a 100644 --- a/db/migrate/20141018111015_create_alternate_names.rb +++ b/db/migrate/20141018111015_create_alternate_names.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateAlternateNames < ActiveRecord::Migration[4.2] def change create_table :alternate_names do |t| diff --git a/db/migrate/20141111130849_create_follows.rb b/db/migrate/20141111130849_create_follows.rb index 5ca3f9b12..02f585a6b 100644 --- a/db/migrate/20141111130849_create_follows.rb +++ b/db/migrate/20141111130849_create_follows.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateFollows < ActiveRecord::Migration[4.2] def change create_table :follows do |t| diff --git a/db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb b/db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb index a777fc79f..4d980c526 100644 --- a/db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb +++ b/db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ChangeFollowsMemberIdToFollowerId < ActiveRecord::Migration[4.2] def change rename_column :follows, :member_id, :follower_id diff --git a/db/migrate/20150124110540_add_properties_to_seeds.rb b/db/migrate/20150124110540_add_properties_to_seeds.rb index 0adb96600..48e4f2c33 100644 --- a/db/migrate/20150124110540_add_properties_to_seeds.rb +++ b/db/migrate/20150124110540_add_properties_to_seeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPropertiesToSeeds < ActiveRecord::Migration[4.2] def change add_column :seeds, :days_until_maturity_min, :integer diff --git a/db/migrate/20150127043022_add_gardens_photos_table.rb b/db/migrate/20150127043022_add_gardens_photos_table.rb index 459174245..a2a7a990d 100644 --- a/db/migrate/20150127043022_add_gardens_photos_table.rb +++ b/db/migrate/20150127043022_add_gardens_photos_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddGardensPhotosTable < ActiveRecord::Migration[4.2] def change create_table :gardens_photos, id: false do |t| diff --git a/db/migrate/20150129034206_add_si_weight_to_harvest.rb b/db/migrate/20150129034206_add_si_weight_to_harvest.rb index 881d4ad01..6429ad570 100644 --- a/db/migrate/20150129034206_add_si_weight_to_harvest.rb +++ b/db/migrate/20150129034206_add_si_weight_to_harvest.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSiWeightToHarvest < ActiveRecord::Migration[4.2] def change add_column :harvests, :si_weight, :float diff --git a/db/migrate/20150130224814_add_requester_to_crops.rb b/db/migrate/20150130224814_add_requester_to_crops.rb index 0d9f70943..9d223a5ec 100644 --- a/db/migrate/20150130224814_add_requester_to_crops.rb +++ b/db/migrate/20150130224814_add_requester_to_crops.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddRequesterToCrops < ActiveRecord::Migration[4.2] def change add_column :crops, :requester_id, :integer diff --git a/db/migrate/20150201052245_create_cms.rb b/db/migrate/20150201052245_create_cms.rb index 4dc1a5d2d..9a1937516 100644 --- a/db/migrate/20150201052245_create_cms.rb +++ b/db/migrate/20150201052245_create_cms.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateCms < ActiveRecord::Migration[4.2] def self.up # rubocop:disable Metrics/MethodLength, Metrics/AbcSize text_limit = case ActiveRecord::Base.connection.adapter_name diff --git a/db/migrate/20150201053200_add_approval_status_to_crops.rb b/db/migrate/20150201053200_add_approval_status_to_crops.rb index ff6b12cbb..48101c5db 100644 --- a/db/migrate/20150201053200_add_approval_status_to_crops.rb +++ b/db/migrate/20150201053200_add_approval_status_to_crops.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddApprovalStatusToCrops < ActiveRecord::Migration[4.2] def change add_column :crops, :approval_status, :string, default: "approved" diff --git a/db/migrate/20150201062506_add_reason_for_rejection_to_crops.rb b/db/migrate/20150201062506_add_reason_for_rejection_to_crops.rb index 001cd795b..377036769 100644 --- a/db/migrate/20150201062506_add_reason_for_rejection_to_crops.rb +++ b/db/migrate/20150201062506_add_reason_for_rejection_to_crops.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddReasonForRejectionToCrops < ActiveRecord::Migration[4.2] def change add_column :crops, :reason_for_rejection, :text diff --git a/db/migrate/20150201064502_add_request_notes_to_crops.rb b/db/migrate/20150201064502_add_request_notes_to_crops.rb index 433c5ad35..b2c21a82b 100644 --- a/db/migrate/20150201064502_add_request_notes_to_crops.rb +++ b/db/migrate/20150201064502_add_request_notes_to_crops.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddRequestNotesToCrops < ActiveRecord::Migration[4.2] def change add_column :crops, :request_notes, :text diff --git a/db/migrate/20150203080226_create_likes.rb b/db/migrate/20150203080226_create_likes.rb index b5f7d427b..e49ce9b53 100644 --- a/db/migrate/20150203080226_create_likes.rb +++ b/db/migrate/20150203080226_create_likes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateLikes < ActiveRecord::Migration[4.2] def change create_table :likes do |t| diff --git a/db/migrate/20150209105410_add_rejection_notes_to_crops.rb b/db/migrate/20150209105410_add_rejection_notes_to_crops.rb index 44fc9fb7b..3ee48d7cf 100644 --- a/db/migrate/20150209105410_add_rejection_notes_to_crops.rb +++ b/db/migrate/20150209105410_add_rejection_notes_to_crops.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddRejectionNotesToCrops < ActiveRecord::Migration[4.2] def change add_column :crops, :rejection_notes, :text diff --git a/db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb b/db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb index c60e6f6a3..396303537 100644 --- a/db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb +++ b/db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDaysBeforeMaturityToPlantings < ActiveRecord::Migration[4.2] def change add_column :plantings, :days_before_maturity, :integer diff --git a/db/migrate/20150824145414_add_member_preferred_image.rb b/db/migrate/20150824145414_add_member_preferred_image.rb index c3c563374..9243318da 100644 --- a/db/migrate/20150824145414_add_member_preferred_image.rb +++ b/db/migrate/20150824145414_add_member_preferred_image.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddMemberPreferredImage < ActiveRecord::Migration[4.2] def change add_column :members, :preferred_avatar_uri, :string diff --git a/db/migrate/20161129021533_rename_scientific_name.rb b/db/migrate/20161129021533_rename_scientific_name.rb index 3aac2e5d4..f5a76c5a8 100644 --- a/db/migrate/20161129021533_rename_scientific_name.rb +++ b/db/migrate/20161129021533_rename_scientific_name.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenameScientificName < ActiveRecord::Migration[4.2] def self.up rename_column :scientific_names, :scientific_name, :name diff --git a/db/migrate/20161201154922_add_photos_seeds_table.rb b/db/migrate/20161201154922_add_photos_seeds_table.rb index bbe7478c5..8031d2caf 100644 --- a/db/migrate/20161201154922_add_photos_seeds_table.rb +++ b/db/migrate/20161201154922_add_photos_seeds_table.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPhotosSeedsTable < ActiveRecord::Migration[4.2] def change create_table :photos_seeds, id: false do |t| diff --git a/db/migrate/20170104035248_add_planting_ref_to_harvests.rb b/db/migrate/20170104035248_add_planting_ref_to_harvests.rb index 515ffaa83..3c197dcd7 100644 --- a/db/migrate/20170104035248_add_planting_ref_to_harvests.rb +++ b/db/migrate/20170104035248_add_planting_ref_to_harvests.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPlantingRefToHarvests < ActiveRecord::Migration[4.2] def change add_reference :harvests, :planting, index: true, foreign_key: true diff --git a/db/migrate/20170413221549_counter_caches.rb b/db/migrate/20170413221549_counter_caches.rb index 27f4f1f6b..76e3b72cd 100644 --- a/db/migrate/20170413221549_counter_caches.rb +++ b/db/migrate/20170413221549_counter_caches.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CounterCaches < ActiveRecord::Migration[4.2] def change add_column :members, :gardens_count, :integer diff --git a/db/migrate/20170520060252_add_deleted_to_members.rb b/db/migrate/20170520060252_add_deleted_to_members.rb index 3e7059aec..4e370ff3f 100644 --- a/db/migrate/20170520060252_add_deleted_to_members.rb +++ b/db/migrate/20170520060252_add_deleted_to_members.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDeletedToMembers < ActiveRecord::Migration[4.2] def change add_column :members, :deleted_at, :datetime diff --git a/db/migrate/20171022032108_all_the_predictions.rb b/db/migrate/20171022032108_all_the_predictions.rb index aa0f1bfde..80f18df20 100644 --- a/db/migrate/20171022032108_all_the_predictions.rb +++ b/db/migrate/20171022032108_all_the_predictions.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AllThePredictions < ActiveRecord::Migration[4.2] def change add_column :crops, :perennial, :boolean, default: false diff --git a/db/migrate/20171028230429_create_median_function.rb b/db/migrate/20171028230429_create_median_function.rb index 5e57c01d1..1b1e44e57 100644 --- a/db/migrate/20171028230429_create_median_function.rb +++ b/db/migrate/20171028230429_create_median_function.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateMedianFunction < ActiveRecord::Migration[4.2] def up ActiveMedian.create_function diff --git a/db/migrate/20171105011017_set_prediction_data.rb b/db/migrate/20171105011017_set_prediction_data.rb index 8dfd91b4f..795e6c15b 100644 --- a/db/migrate/20171105011017_set_prediction_data.rb +++ b/db/migrate/20171105011017_set_prediction_data.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SetPredictionData < ActiveRecord::Migration[4.2] def up say "Updating all plantings time to first harvest" diff --git a/db/migrate/20171129041341_create_photographings.rb b/db/migrate/20171129041341_create_photographings.rb index a80245b54..2ae1168df 100644 --- a/db/migrate/20171129041341_create_photographings.rb +++ b/db/migrate/20171129041341_create_photographings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreatePhotographings < ActiveRecord::Migration[4.2] def change create_table :photographings do |t| diff --git a/db/migrate/20180118112809_add_datetaken_to_photos.rb b/db/migrate/20180118112809_add_datetaken_to_photos.rb index 03fae1075..590305591 100644 --- a/db/migrate/20180118112809_add_datetaken_to_photos.rb +++ b/db/migrate/20180118112809_add_datetaken_to_photos.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddDatetakenToPhotos < ActiveRecord::Migration[4.2] def change add_column :photos, :date_taken, :datetime diff --git a/db/migrate/20180205000612_remove_shop.rb b/db/migrate/20180205000612_remove_shop.rb index 6977f127b..17248e3db 100644 --- a/db/migrate/20180205000612_remove_shop.rb +++ b/db/migrate/20180205000612_remove_shop.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RemoveShop < ActiveRecord::Migration[4.2] def up drop_table :order_items diff --git a/db/migrate/20180213005731_seed_usage.rb b/db/migrate/20180213005731_seed_usage.rb index 8f7112e47..ddb2c2378 100644 --- a/db/migrate/20180213005731_seed_usage.rb +++ b/db/migrate/20180213005731_seed_usage.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SeedUsage < ActiveRecord::Migration[4.2] def change # # seed can be all sown, meaning there is none left diff --git a/db/migrate/20180401220637_add_member_count_caches.rb b/db/migrate/20180401220637_add_member_count_caches.rb index 912db008f..8f10b0c66 100644 --- a/db/migrate/20180401220637_add_member_count_caches.rb +++ b/db/migrate/20180401220637_add_member_count_caches.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddMemberCountCaches < ActiveRecord::Migration[4.2] def change add_column :members, :photos_count, :integer diff --git a/db/migrate/20190130090437_add_crop_to_photographings.rb b/db/migrate/20190130090437_add_crop_to_photographings.rb index 3b4ad8788..e74f57b66 100644 --- a/db/migrate/20190130090437_add_crop_to_photographings.rb +++ b/db/migrate/20190130090437_add_crop_to_photographings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddCropToPhotographings < ActiveRecord::Migration[5.2] def change add_column(:photographings, :crop_id, :integer) diff --git a/db/migrate/20190317023129_finished_boolean.rb b/db/migrate/20190317023129_finished_boolean.rb index ac6524316..8ba8c73e3 100644 --- a/db/migrate/20190317023129_finished_boolean.rb +++ b/db/migrate/20190317023129_finished_boolean.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class FinishedBoolean < ActiveRecord::Migration[5.2] def change Planting.unscoped.where('finished_at < now()').update_all(finished: true) diff --git a/db/migrate/20190326063855_create_garden_types.rb b/db/migrate/20190326063855_create_garden_types.rb index 0d7ca230e..d844eb787 100644 --- a/db/migrate/20190326063855_create_garden_types.rb +++ b/db/migrate/20190326063855_create_garden_types.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateGardenTypes < ActiveRecord::Migration[5.2] def change create_table :garden_types do |t| diff --git a/db/migrate/20190326224347_add_harvests_count.rb b/db/migrate/20190326224347_add_harvests_count.rb index 9557ffdae..fc5b6bdc6 100644 --- a/db/migrate/20190326224347_add_harvests_count.rb +++ b/db/migrate/20190326224347_add_harvests_count.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddHarvestsCount < ActiveRecord::Migration[5.2] def change add_column :plantings, :harvests_count, :integer, default: 0 diff --git a/db/migrate/20190712003735_add_like_counter_caches.rb b/db/migrate/20190712003735_add_like_counter_caches.rb index 92c292494..c956d6f83 100644 --- a/db/migrate/20190712003735_add_like_counter_caches.rb +++ b/db/migrate/20190712003735_add_like_counter_caches.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddLikeCounterCaches < ActiveRecord::Migration[5.2] def change change_table :photos do |t| diff --git a/db/migrate/20190712234859_rename_photographings.rb b/db/migrate/20190712234859_rename_photographings.rb index 7f9a5127e..09ea403ed 100644 --- a/db/migrate/20190712234859_rename_photographings.rb +++ b/db/migrate/20190712234859_rename_photographings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RenamePhotographings < ActiveRecord::Migration[5.2] def change rename_table :photographings, :photo_associations diff --git a/db/migrate/20190720000555_create_mailboxer.mailboxer_engine.rb b/db/migrate/20190720000555_create_mailboxer.mailboxer_engine.rb index 943d04e89..04ab2fd9f 100644 --- a/db/migrate/20190720000555_create_mailboxer.mailboxer_engine.rb +++ b/db/migrate/20190720000555_create_mailboxer.mailboxer_engine.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This migration comes from mailboxer_engine (originally 20110511145103) class CreateMailboxer < ActiveRecord::Migration[4.2] def self.up diff --git a/db/migrate/20190720000556_add_conversation_optout.mailboxer_engine.rb b/db/migrate/20190720000556_add_conversation_optout.mailboxer_engine.rb index 50eeeed02..fa062c837 100644 --- a/db/migrate/20190720000556_add_conversation_optout.mailboxer_engine.rb +++ b/db/migrate/20190720000556_add_conversation_optout.mailboxer_engine.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This migration comes from mailboxer_engine (originally 20131206080416) class AddConversationOptout < ActiveRecord::Migration[4.2] def self.up diff --git a/db/migrate/20190720000557_add_missing_indices.mailboxer_engine.rb b/db/migrate/20190720000557_add_missing_indices.mailboxer_engine.rb index 87c154832..b6e793000 100644 --- a/db/migrate/20190720000557_add_missing_indices.mailboxer_engine.rb +++ b/db/migrate/20190720000557_add_missing_indices.mailboxer_engine.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This migration comes from mailboxer_engine (originally 20131206080417) class AddMissingIndices < ActiveRecord::Migration[4.2] def change diff --git a/db/migrate/20190720000558_add_delivery_tracking_info_to_mailboxer_receipts.mailboxer_engine.rb b/db/migrate/20190720000558_add_delivery_tracking_info_to_mailboxer_receipts.mailboxer_engine.rb index 498d152d9..547e3e44c 100644 --- a/db/migrate/20190720000558_add_delivery_tracking_info_to_mailboxer_receipts.mailboxer_engine.rb +++ b/db/migrate/20190720000558_add_delivery_tracking_info_to_mailboxer_receipts.mailboxer_engine.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This migration comes from mailboxer_engine (originally 20151103080417) class AddDeliveryTrackingInfoToMailboxerReceipts < ActiveRecord::Migration[4.2] def change diff --git a/db/migrate/20190720000625_notifications_to_mailboxer.rb b/db/migrate/20190720000625_notifications_to_mailboxer.rb index 1dabd8925..fb488cff0 100644 --- a/db/migrate/20190720000625_notifications_to_mailboxer.rb +++ b/db/migrate/20190720000625_notifications_to_mailboxer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class NotificationsToMailboxer < ActiveRecord::Migration[5.2] def up Mailboxer.setup do |config| diff --git a/db/migrate/20190721042146_paranoia_to_discard.rb b/db/migrate/20190721042146_paranoia_to_discard.rb index 4b8803360..bdebe321a 100644 --- a/db/migrate/20190721042146_paranoia_to_discard.rb +++ b/db/migrate/20190721042146_paranoia_to_discard.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ParanoiaToDiscard < ActiveRecord::Migration[5.2] def change rename_column :members, :deleted_at, :discarded_at diff --git a/db/migrate/20190902004225_add_openfarm_data_to_crops.rb b/db/migrate/20190902004225_add_openfarm_data_to_crops.rb index f8cc4d43d..61b3e1ee0 100644 --- a/db/migrate/20190902004225_add_openfarm_data_to_crops.rb +++ b/db/migrate/20190902004225_add_openfarm_data_to_crops.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddOpenfarmDataToCrops < ActiveRecord::Migration[5.2] def change add_column :crops, :openfarm_data, :jsonb diff --git a/db/migrate/20190910022329_add_photo_source.rb b/db/migrate/20190910022329_add_photo_source.rb index 44e9a9d7d..302cf68c8 100644 --- a/db/migrate/20190910022329_add_photo_source.rb +++ b/db/migrate/20190910022329_add_photo_source.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPhotoSource < ActiveRecord::Migration[5.2] def change add_column :photos, :source, :string diff --git a/db/migrate/20190915065209_create_crop_companions.rb b/db/migrate/20190915065209_create_crop_companions.rb index 1b9d1b974..b50fba284 100644 --- a/db/migrate/20190915065209_create_crop_companions.rb +++ b/db/migrate/20190915065209_create_crop_companions.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateCropCompanions < ActiveRecord::Migration[5.2] def change create_table :crop_companions do |t| diff --git a/db/migrate/20190918033319_unique_urls.rb b/db/migrate/20190918033319_unique_urls.rb index 99b9caf42..ed1da03d2 100644 --- a/db/migrate/20190918033319_unique_urls.rb +++ b/db/migrate/20190918033319_unique_urls.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class UniqueUrls < ActiveRecord::Migration[5.2] def change add_index :photos, :fullsize_url, unique: true diff --git a/db/migrate/20190921211652_crop_posts.rb b/db/migrate/20190921211652_crop_posts.rb index c7f2950c5..de8b5d39c 100644 --- a/db/migrate/20190921211652_crop_posts.rb +++ b/db/migrate/20190921211652_crop_posts.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CropPosts < ActiveRecord::Migration[5.2] def change rename_table :crops_posts, :crop_posts diff --git a/db/migrate/20191029024101_add_saved_at_to_seeds.rb b/db/migrate/20191029024101_add_saved_at_to_seeds.rb index 745bdf5e4..ccbf598e8 100644 --- a/db/migrate/20191029024101_add_saved_at_to_seeds.rb +++ b/db/migrate/20191029024101_add_saved_at_to_seeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddSavedAtToSeeds < ActiveRecord::Migration[5.2] def change add_column :seeds, :saved_at, :date diff --git a/db/migrate/20191119020643_upgrade_cms.rb b/db/migrate/20191119020643_upgrade_cms.rb index 8b2b34f5c..8256e9103 100644 --- a/db/migrate/20191119020643_upgrade_cms.rb +++ b/db/migrate/20191119020643_upgrade_cms.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class UpgradeCms < ActiveRecord::Migration[5.2] def change rename_table :comfy_cms_blocks, :comfy_cms_fragments diff --git a/db/migrate/20191119030244_cms_tags.rb b/db/migrate/20191119030244_cms_tags.rb index fa3ef0d4c..918f6a325 100644 --- a/db/migrate/20191119030244_cms_tags.rb +++ b/db/migrate/20191119030244_cms_tags.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CmsTags < ActiveRecord::Migration[5.2] def up Comfy::Cms::Layout.all.each do |layout| diff --git a/db/migrate/20191209202348_add_harvest_count_to_crop.rb b/db/migrate/20191209202348_add_harvest_count_to_crop.rb index e250b4be6..d57ff6848 100644 --- a/db/migrate/20191209202348_add_harvest_count_to_crop.rb +++ b/db/migrate/20191209202348_add_harvest_count_to_crop.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddHarvestCountToCrop < ActiveRecord::Migration[5.2] def change change_table :crops do |t| diff --git a/db/seeds.rb b/db/seeds.rb index ed57b6b7e..d3ac333b3 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). diff --git a/lib/actions/oauth_signup_action.rb b/lib/actions/oauth_signup_action.rb index de274dc35..cd1f7d768 100644 --- a/lib/actions/oauth_signup_action.rb +++ b/lib/actions/oauth_signup_action.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Growstuff::OauthSignupAction # # Inspects the omniauth information diff --git a/lib/geocodable.rb b/lib/geocodable.rb index f1bb243f6..7d3b3c8e3 100644 --- a/lib/geocodable.rb +++ b/lib/geocodable.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Geocodable def self.included(base) base.extend(self) diff --git a/lib/haml/filters/escaped_markdown.rb b/lib/haml/filters/escaped_markdown.rb index 86345b5a2..d68f0661d 100644 --- a/lib/haml/filters/escaped_markdown.rb +++ b/lib/haml/filters/escaped_markdown.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bluecloth' require 'haml/filters/growstuff_markdown' diff --git a/lib/haml/filters/growstuff_markdown.rb b/lib/haml/filters/growstuff_markdown.rb index 52dff7098..d5869e7fb 100644 --- a/lib/haml/filters/growstuff_markdown.rb +++ b/lib/haml/filters/growstuff_markdown.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bluecloth' module Haml::Filters diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake index 6c185c7bc..137243f03 100644 --- a/lib/tasks/growstuff.rake +++ b/lib/tasks/growstuff.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :growstuff do desc "Add an admin user, by name" # usage: rake growstuff:admin_user name=skud diff --git a/lib/tasks/hooks.rake b/lib/tasks/hooks.rake index 67cc41cba..051902ed5 100644 --- a/lib/tasks/hooks.rake +++ b/lib/tasks/hooks.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + desc "Install git hooks" task :hooks do FileUtils.symlink '../../script/pre-commit.sh', '.git/hooks/pre-commit', diff --git a/lib/tasks/i18n.rake b/lib/tasks/i18n.rake index 04fa8001b..8a0f9d8cf 100644 --- a/lib/tasks/i18n.rake +++ b/lib/tasks/i18n.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :i18n do desc "sort all i18n locale keys" task :normalize do diff --git a/lib/tasks/openfarm.rake b/lib/tasks/openfarm.rake index b6b6ce909..92ca9cc39 100644 --- a/lib/tasks/openfarm.rake +++ b/lib/tasks/openfarm.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :openfarm do desc "Retrieve crop info from open farm" # usage: rake growstuff:admin_user name=skud diff --git a/lib/tasks/search.rake b/lib/tasks/search.rake index 71f9da6bf..d93fd601f 100644 --- a/lib/tasks/search.rake +++ b/lib/tasks/search.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :search do desc 'reindex' task reindex: :environment do diff --git a/lib/tasks/testing.rake b/lib/tasks/testing.rake index 1120f6ca9..d6a5fd5c7 100644 --- a/lib/tasks/testing.rake +++ b/lib/tasks/testing.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rake' begin require 'rspec/core/rake_task' diff --git a/script/check_contributors_md.rb b/script/check_contributors_md.rb index 9aa3fa290..d0013e78c 100755 --- a/script/check_contributors_md.rb +++ b/script/check_contributors_md.rb @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + require "English" puts "Checking to see if you're in CONTRIBUTORS.md..." diff --git a/script/check_static.rb b/script/check_static.rb index e747599f8..f82932a9e 100755 --- a/script/check_static.rb +++ b/script/check_static.rb @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true checks = [ # 'overcommit -r', diff --git a/script/heroku_maintenance.rb b/script/heroku_maintenance.rb index d2a20d67a..1c285a288 100755 --- a/script/heroku_maintenance.rb +++ b/script/heroku_maintenance.rb @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true require 'platform-api' require 'yaml' diff --git a/spec/controllers/admin/roles_controller_spec.rb b/spec/controllers/admin/roles_controller_spec.rb index 86694a74b..cb2a193e8 100644 --- a/spec/controllers/admin/roles_controller_spec.rb +++ b/spec/controllers/admin/roles_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Admin::RolesController do diff --git a/spec/controllers/admin_controller_spec.rb b/spec/controllers/admin_controller_spec.rb index 7f0e56206..b1b222890 100644 --- a/spec/controllers/admin_controller_spec.rb +++ b/spec/controllers/admin_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe AdminController do diff --git a/spec/controllers/authentications_controller_spec.rb b/spec/controllers/authentications_controller_spec.rb index 372d44c42..d4bc8ad50 100644 --- a/spec/controllers/authentications_controller_spec.rb +++ b/spec/controllers/authentications_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe AuthenticationsController do diff --git a/spec/controllers/charts/crops_controller_spec.rb b/spec/controllers/charts/crops_controller_spec.rb index 3a6a40bb4..dd08302bd 100644 --- a/spec/controllers/charts/crops_controller_spec.rb +++ b/spec/controllers/charts/crops_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Charts::CropsController do diff --git a/spec/controllers/charts/gardens_controller_spec.rb b/spec/controllers/charts/gardens_controller_spec.rb index d264388f6..007e7f58c 100644 --- a/spec/controllers/charts/gardens_controller_spec.rb +++ b/spec/controllers/charts/gardens_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Charts::GardensController do diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 741b19ff3..4e8b64ce4 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe CommentsController do diff --git a/spec/controllers/crops_controller_spec.rb b/spec/controllers/crops_controller_spec.rb index 1bb737c99..8681b4790 100644 --- a/spec/controllers/crops_controller_spec.rb +++ b/spec/controllers/crops_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe CropsController do diff --git a/spec/controllers/forums_controller_spec.rb b/spec/controllers/forums_controller_spec.rb index 5c59473cb..065ff32d7 100644 --- a/spec/controllers/forums_controller_spec.rb +++ b/spec/controllers/forums_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe ForumsController do diff --git a/spec/controllers/garden_types_controller_spec.rb b/spec/controllers/garden_types_controller_spec.rb index 53bc9cae8..e3c466750 100644 --- a/spec/controllers/garden_types_controller_spec.rb +++ b/spec/controllers/garden_types_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe GardenTypesController, type: :controller do diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb index 3222829fe..c4b4de332 100644 --- a/spec/controllers/gardens_controller_spec.rb +++ b/spec/controllers/gardens_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe GardensController, type: :controller do diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index b77eb9b57..f4d8871f7 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe HarvestsController do diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index cb12b2bb4..608addc31 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe HomeController do diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb index 6730b0a8f..985678278 100644 --- a/spec/controllers/likes_controller_spec.rb +++ b/spec/controllers/likes_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe LikesController do diff --git a/spec/controllers/member_controller_spec.rb b/spec/controllers/member_controller_spec.rb index 5ec80e344..6e6997e93 100644 --- a/spec/controllers/member_controller_spec.rb +++ b/spec/controllers/member_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe MembersController do diff --git a/spec/controllers/photo_associations_controller_spec.rb b/spec/controllers/photo_associations_controller_spec.rb index 21ed0aa29..65d89e9f2 100644 --- a/spec/controllers/photo_associations_controller_spec.rb +++ b/spec/controllers/photo_associations_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe PhotoAssociationsController do diff --git a/spec/controllers/places_controller_spec.rb b/spec/controllers/places_controller_spec.rb index a32d27c28..640adfcb1 100644 --- a/spec/controllers/places_controller_spec.rb +++ b/spec/controllers/places_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe PlacesController do diff --git a/spec/controllers/plant_parts_controller_spec.rb b/spec/controllers/plant_parts_controller_spec.rb index c6e11f315..94e1e4c83 100644 --- a/spec/controllers/plant_parts_controller_spec.rb +++ b/spec/controllers/plant_parts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe PlantPartsController do diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index c055d7768..fb9f51b53 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe PlantingsController do diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 0842e4a5b..1bae41f14 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe PostsController do diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 82b52652d..71b628101 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe RegistrationsController do diff --git a/spec/controllers/robots_controller_spec.rb b/spec/controllers/robots_controller_spec.rb index b45a8b235..5c94c1ff1 100644 --- a/spec/controllers/robots_controller_spec.rb +++ b/spec/controllers/robots_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe RobotsController do diff --git a/spec/controllers/scientific_names_controller_spec.rb b/spec/controllers/scientific_names_controller_spec.rb index a56735454..d7b1612ae 100644 --- a/spec/controllers/scientific_names_controller_spec.rb +++ b/spec/controllers/scientific_names_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe ScientificNamesController do diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb index 1c6e89bb3..c8fdf27c8 100644 --- a/spec/controllers/seeds_controller_spec.rb +++ b/spec/controllers/seeds_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe SeedsController do diff --git a/spec/custom_matchers.rb b/spec/custom_matchers.rb index 1cb9d61ab..972c939e6 100644 --- a/spec/custom_matchers.rb +++ b/spec/custom_matchers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rspec/expectations' RSpec::Matchers.define :have_optional do |expected| diff --git a/spec/factories/alternate_names.rb b/spec/factories/alternate_names.rb index 44cee8a21..df991c2ba 100644 --- a/spec/factories/alternate_names.rb +++ b/spec/factories/alternate_names.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_bot FactoryBot.define do diff --git a/spec/factories/authentications.rb b/spec/factories/authentications.rb index 97a34f6c4..d93c37bb2 100644 --- a/spec/factories/authentications.rb +++ b/spec/factories/authentications.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_bot FactoryBot.define do diff --git a/spec/factories/comments.rb b/spec/factories/comments.rb index 5b726bd41..e030d34d6 100644 --- a/spec/factories/comments.rb +++ b/spec/factories/comments.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :comment do post diff --git a/spec/factories/crop.rb b/spec/factories/crop.rb index efb5d05de..72e5d1e72 100644 --- a/spec/factories/crop.rb +++ b/spec/factories/crop.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :crop do name { "magic bean" } diff --git a/spec/factories/crop_companions.rb b/spec/factories/crop_companions.rb index 6db4f0eb0..ea58b9e0c 100644 --- a/spec/factories/crop_companions.rb +++ b/spec/factories/crop_companions.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :crop_companion do end diff --git a/spec/factories/follows.rb b/spec/factories/follows.rb index a6c609e48..4f608067e 100644 --- a/spec/factories/follows.rb +++ b/spec/factories/follows.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :follow do follower diff --git a/spec/factories/forums.rb b/spec/factories/forums.rb index ba1e6cf82..795915796 100644 --- a/spec/factories/forums.rb +++ b/spec/factories/forums.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_bot FactoryBot.define do diff --git a/spec/factories/garden.rb b/spec/factories/garden.rb index d11dcd0d7..b7a5edde0 100644 --- a/spec/factories/garden.rb +++ b/spec/factories/garden.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :garden do name { Faker::Vehicle.vin } diff --git a/spec/factories/garden_types.rb b/spec/factories/garden_types.rb index 942fd7932..02d5ec75f 100644 --- a/spec/factories/garden_types.rb +++ b/spec/factories/garden_types.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :garden_type do name { "homemade swamp" } diff --git a/spec/factories/harvests.rb b/spec/factories/harvests.rb index 426c3d24c..d4bd0f18d 100644 --- a/spec/factories/harvests.rb +++ b/spec/factories/harvests.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_bot FactoryBot.define do diff --git a/spec/factories/like.rb b/spec/factories/like.rb index bf19554bb..ffb41c8d3 100644 --- a/spec/factories/like.rb +++ b/spec/factories/like.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :like do member diff --git a/spec/factories/member.rb b/spec/factories/member.rb index 87b5326f3..3a02e2c3c 100644 --- a/spec/factories/member.rb +++ b/spec/factories/member.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :member, aliases: %i(author owner sender recipient creator) do login_name { (0...8).map { rand(65..90).chr }.join } diff --git a/spec/factories/notifications.rb b/spec/factories/notifications.rb index 4d2cee82f..a143c777f 100644 --- a/spec/factories/notifications.rb +++ b/spec/factories/notifications.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_bot FactoryBot.define do diff --git a/spec/factories/photos.rb b/spec/factories/photos.rb index 41e581d29..405edfd7c 100644 --- a/spec/factories/photos.rb +++ b/spec/factories/photos.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_bot FactoryBot.define do diff --git a/spec/factories/plant_parts.rb b/spec/factories/plant_parts.rb index 42a30afd6..7fecd326a 100644 --- a/spec/factories/plant_parts.rb +++ b/spec/factories/plant_parts.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_bot FactoryBot.define do diff --git a/spec/factories/planting.rb b/spec/factories/planting.rb index 8fb709d1c..cfdcd2b1c 100644 --- a/spec/factories/planting.rb +++ b/spec/factories/planting.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :planting do owner diff --git a/spec/factories/post.rb b/spec/factories/post.rb index f3471042f..c035fdbe6 100644 --- a/spec/factories/post.rb +++ b/spec/factories/post.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :post do subject { Faker::Book.title } diff --git a/spec/factories/roles.rb b/spec/factories/roles.rb index 3e33d9720..c7c57f7ea 100644 --- a/spec/factories/roles.rb +++ b/spec/factories/roles.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_bot FactoryBot.define do diff --git a/spec/factories/scientific_name.rb b/spec/factories/scientific_name.rb index 7e0e04462..ec43799ce 100644 --- a/spec/factories/scientific_name.rb +++ b/spec/factories/scientific_name.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :scientific_name do association :crop, factory: :crop diff --git a/spec/factories/seeds.rb b/spec/factories/seeds.rb index 2f5238591..deafb5302 100644 --- a/spec/factories/seeds.rb +++ b/spec/factories/seeds.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_bot FactoryBot.define do diff --git a/spec/features/admin/admin_spec.rb b/spec/features/admin/admin_spec.rb index cbd83bf53..f5b384d59 100644 --- a/spec/features/admin/admin_spec.rb +++ b/spec/features/admin/admin_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "forums", js: true do diff --git a/spec/features/admin/forums_spec.rb b/spec/features/admin/forums_spec.rb index 7a41266c0..ab44e2ae6 100644 --- a/spec/features/admin/forums_spec.rb +++ b/spec/features/admin/forums_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "forums", js: true do diff --git a/spec/features/cms_spec.rb b/spec/features/cms_spec.rb index d13fc1b42..253750cf8 100644 --- a/spec/features/cms_spec.rb +++ b/spec/features/cms_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "cms admin" do diff --git a/spec/features/comments/commenting_a_comment_spec.rb b/spec/features/comments/commenting_a_comment_spec.rb index 6debc9d14..ded092723 100644 --- a/spec/features/comments/commenting_a_comment_spec.rb +++ b/spec/features/comments/commenting_a_comment_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Commenting on a post' do diff --git a/spec/features/conversations/index_spec.rb b/spec/features/conversations/index_spec.rb index 969fc447c..9df3b584e 100644 --- a/spec/features/conversations/index_spec.rb +++ b/spec/features/conversations/index_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Conversations", :js do diff --git a/spec/features/conversations/show_spec.rb b/spec/features/conversations/show_spec.rb index ccf92fb8f..1bcfb8873 100644 --- a/spec/features/conversations/show_spec.rb +++ b/spec/features/conversations/show_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Conversations", :js do diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index adfc3b4e3..bb4843e05 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Alternate names", js: true do diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb index 4de6d14ae..73aa40574 100644 --- a/spec/features/crops/browse_crops_spec.rb +++ b/spec/features/crops/browse_crops_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "browse crops" do diff --git a/spec/features/crops/creating_a_crop_spec.rb b/spec/features/crops/creating_a_crop_spec.rb index 6240db8d5..c47829754 100644 --- a/spec/features/crops/creating_a_crop_spec.rb +++ b/spec/features/crops/creating_a_crop_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Crop", js: true do diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index cec0579ac..ec1ff63cd 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "crop detail page", js: true do diff --git a/spec/features/crops/crop_photos_spec.rb b/spec/features/crops/crop_photos_spec.rb index 13ecc14ac..1fc44772a 100644 --- a/spec/features/crops/crop_photos_spec.rb +++ b/spec/features/crops/crop_photos_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "crop detail page", js: true do diff --git a/spec/features/crops/crop_search_spec.rb b/spec/features/crops/crop_search_spec.rb index b87655a01..af39c1746 100644 --- a/spec/features/crops/crop_search_spec.rb +++ b/spec/features/crops/crop_search_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "crop search" do diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb index 5dd8af71f..328e560cd 100644 --- a/spec/features/crops/crop_wranglers_spec.rb +++ b/spec/features/crops/crop_wranglers_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "crop wranglers", js: true do diff --git a/spec/features/crops/crop_wrangling_button_spec.rb b/spec/features/crops/crop_wrangling_button_spec.rb index 3545db9ff..a081aff74 100644 --- a/spec/features/crops/crop_wrangling_button_spec.rb +++ b/spec/features/crops/crop_wrangling_button_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "crop wrangling button" do diff --git a/spec/features/crops/delete_crop_spec.rb b/spec/features/crops/delete_crop_spec.rb index 41092c895..941496e1c 100644 --- a/spec/features/crops/delete_crop_spec.rb +++ b/spec/features/crops/delete_crop_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Delete crop spec" do diff --git a/spec/features/crops/inflections_spec.rb b/spec/features/crops/inflections_spec.rb index c7ca5ce37..9df145940 100644 --- a/spec/features/crops/inflections_spec.rb +++ b/spec/features/crops/inflections_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "irregular crop inflections" do diff --git a/spec/features/crops/request_new_crop_spec.rb b/spec/features/crops/request_new_crop_spec.rb index da38b1ec9..3964ad6b3 100644 --- a/spec/features/crops/request_new_crop_spec.rb +++ b/spec/features/crops/request_new_crop_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Requesting a new crop" do diff --git a/spec/features/crops/requested_crops_spec.rb b/spec/features/crops/requested_crops_spec.rb index e73292c1e..0556fb2a6 100644 --- a/spec/features/crops/requested_crops_spec.rb +++ b/spec/features/crops/requested_crops_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Requesting Crops" do diff --git a/spec/features/crops/scientific_name_spec.rb b/spec/features/crops/scientific_name_spec.rb index 63fad9ee1..a8a523cb5 100644 --- a/spec/features/crops/scientific_name_spec.rb +++ b/spec/features/crops/scientific_name_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Scientific names", js: true do diff --git a/spec/features/crops/show_spec.rb b/spec/features/crops/show_spec.rb index 48d083257..a219f774d 100644 --- a/spec/features/crops/show_spec.rb +++ b/spec/features/crops/show_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "browse crops" do diff --git a/spec/features/footer_spec.rb b/spec/features/footer_spec.rb index 8d6225ecb..6e5713f62 100644 --- a/spec/features/footer_spec.rb +++ b/spec/features/footer_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "footer", js: true do diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb index 74fc10803..6c1fc8b49 100644 --- a/spec/features/gardens/actions_spec.rb +++ b/spec/features/gardens/actions_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' require 'custom_matchers' diff --git a/spec/features/gardens/adding_gardens_spec.rb b/spec/features/gardens/adding_gardens_spec.rb index 7320a1244..d281e9657 100644 --- a/spec/features/gardens/adding_gardens_spec.rb +++ b/spec/features/gardens/adding_gardens_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' require 'custom_matchers' diff --git a/spec/features/gardens/gardens_spec.rb b/spec/features/gardens/gardens_spec.rb index 6b845bc50..714657952 100644 --- a/spec/features/gardens/gardens_spec.rb +++ b/spec/features/gardens/gardens_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Planting a crop", js: true do diff --git a/spec/features/gardens/index_spec.rb b/spec/features/gardens/index_spec.rb index b5eb5d3dc..00cfad3af 100644 --- a/spec/features/gardens/index_spec.rb +++ b/spec/features/gardens/index_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' require 'custom_matchers' diff --git a/spec/features/harvests/browse_harvests_spec.rb b/spec/features/harvests/browse_harvests_spec.rb index 6ead7e231..2ce14f4a1 100644 --- a/spec/features/harvests/browse_harvests_spec.rb +++ b/spec/features/harvests/browse_harvests_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "browse harvests" do diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index e84fdb7c0..0099c11f6 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' require 'custom_matchers' diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb index 2901787b7..fea8e27e8 100644 --- a/spec/features/home/home_spec.rb +++ b/spec/features/home/home_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "home page" do diff --git a/spec/features/likeable_spec.rb b/spec/features/likeable_spec.rb index 95503efaf..0b44d3741 100644 --- a/spec/features/likeable_spec.rb +++ b/spec/features/likeable_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Likeable', js: true do diff --git a/spec/features/locale_spec.rb b/spec/features/locale_spec.rb index 2dce809ad..ac4ba0818 100644 --- a/spec/features/locale_spec.rb +++ b/spec/features/locale_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Changing locales", js: true do diff --git a/spec/features/members/ban_spec.rb b/spec/features/members/ban_spec.rb index f6f99e698..3395637c2 100644 --- a/spec/features/members/ban_spec.rb +++ b/spec/features/members/ban_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "members list" do diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index ce3ff7769..a8ca9fb83 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "member deletion" do diff --git a/spec/features/members/following_spec.rb b/spec/features/members/following_spec.rb index 42a20df34..a48bed81c 100644 --- a/spec/features/members/following_spec.rb +++ b/spec/features/members/following_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "follows", :js do diff --git a/spec/features/members/list_spec.rb b/spec/features/members/list_spec.rb index f00b1daaf..b26ead439 100644 --- a/spec/features/members/list_spec.rb +++ b/spec/features/members/list_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "members list" do diff --git a/spec/features/members/profile_spec.rb b/spec/features/members/profile_spec.rb index 4b51b5868..08438efda 100644 --- a/spec/features/members/profile_spec.rb +++ b/spec/features/members/profile_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "member profile", js: true do diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 05efb57ff..530a6b540 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Test with visual testing', type: :feature, js: true do diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb index d52a1ef43..b500a89d5 100644 --- a/spec/features/photos/new_photo_spec.rb +++ b/spec/features/photos/new_photo_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "new photo page" do diff --git a/spec/features/photos/show_photo_spec.rb b/spec/features/photos/show_photo_spec.rb index 68bf8ea88..a2a517c15 100644 --- a/spec/features/photos/show_photo_spec.rb +++ b/spec/features/photos/show_photo_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "show photo page" do diff --git a/spec/features/places/searching_a_place_spec.rb b/spec/features/places/searching_a_place_spec.rb index 5b6985322..d31eee6b3 100644 --- a/spec/features/places/searching_a_place_spec.rb +++ b/spec/features/places/searching_a_place_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe "User searches" do diff --git a/spec/features/planting_reminder_spec.rb b/spec/features/planting_reminder_spec.rb index 5caecbc51..8ac7703a0 100644 --- a/spec/features/planting_reminder_spec.rb +++ b/spec/features/planting_reminder_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' require 'capybara/email/rspec' diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 2ca3439d9..7ae4c72ad 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" require 'custom_matchers' diff --git a/spec/features/plantings/prediction_spec.rb b/spec/features/plantings/prediction_spec.rb index 1efa4ac54..c22734a7f 100644 --- a/spec/features/plantings/prediction_spec.rb +++ b/spec/features/plantings/prediction_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" require 'custom_matchers' describe "Display a planting", :js do diff --git a/spec/features/plantings/show_spec.rb b/spec/features/plantings/show_spec.rb index 864aff5d4..ba5bc3426 100644 --- a/spec/features/plantings/show_spec.rb +++ b/spec/features/plantings/show_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" require 'custom_matchers' diff --git a/spec/features/posts/posting_a_post_spec.rb b/spec/features/posts/posting_a_post_spec.rb index f1b61bc83..cd1a4b0a4 100644 --- a/spec/features/posts/posting_a_post_spec.rb +++ b/spec/features/posts/posting_a_post_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Post a post' do diff --git a/spec/features/rss/comments_spec.rb b/spec/features/rss/comments_spec.rb index 1b0263d6d..5b6783300 100644 --- a/spec/features/rss/comments_spec.rb +++ b/spec/features/rss/comments_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Comments RSS feed' do diff --git a/spec/features/rss/crops_spec.rb b/spec/features/rss/crops_spec.rb index e42c73150..7e26d30e9 100644 --- a/spec/features/rss/crops_spec.rb +++ b/spec/features/rss/crops_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Crops RSS feed' do diff --git a/spec/features/rss/members_spec.rb b/spec/features/rss/members_spec.rb index 1daefcd51..ba63a1a23 100644 --- a/spec/features/rss/members_spec.rb +++ b/spec/features/rss/members_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Members RSS feed' do diff --git a/spec/features/rss/plantings_spec.rb b/spec/features/rss/plantings_spec.rb index 8e44494cb..30ffba947 100644 --- a/spec/features/rss/plantings_spec.rb +++ b/spec/features/rss/plantings_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Plantings RSS feed' do diff --git a/spec/features/rss/posts_spec.rb b/spec/features/rss/posts_spec.rb index 0b85590c4..b07ca28cb 100644 --- a/spec/features/rss/posts_spec.rb +++ b/spec/features/rss/posts_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Posts RSS feed' do diff --git a/spec/features/rss/seeds_spec.rb b/spec/features/rss/seeds_spec.rb index 5a50e8811..c0a2e141d 100644 --- a/spec/features/rss/seeds_spec.rb +++ b/spec/features/rss/seeds_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Seeds RSS feed' do diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb index 9ab32788f..622dad584 100644 --- a/spec/features/seeds/adding_seeds_spec.rb +++ b/spec/features/seeds/adding_seeds_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' require 'custom_matchers' diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb index 0aa54f128..8de59ab41 100644 --- a/spec/features/seeds/misc_seeds_spec.rb +++ b/spec/features/seeds/misc_seeds_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "seeds", js: true do diff --git a/spec/features/seeds/seed_photos.rb b/spec/features/seeds/seed_photos.rb index 6f4d9828c..37640f127 100644 --- a/spec/features/seeds/seed_photos.rb +++ b/spec/features/seeds/seed_photos.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' require 'custom_matchers' diff --git a/spec/features/shared_examples/append_date.rb b/spec/features/shared_examples/append_date.rb index 2680dac30..3b8b6ec64 100644 --- a/spec/features/shared_examples/append_date.rb +++ b/spec/features/shared_examples/append_date.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + shared_examples "append date" do let(:this_month) { Time.zone.today.strftime("%b") } let(:this_year) { Time.zone.today.year } diff --git a/spec/features/shared_examples/crop_suggest.rb b/spec/features/shared_examples/crop_suggest.rb index b7e49dbd8..33775c744 100644 --- a/spec/features/shared_examples/crop_suggest.rb +++ b/spec/features/shared_examples/crop_suggest.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' shared_examples "crop suggest" do |resource| diff --git a/spec/features/signin_spec.rb b/spec/features/signin_spec.rb index 5d20b461f..25cf7112c 100644 --- a/spec/features/signin_spec.rb +++ b/spec/features/signin_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "signin", js: true do diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb index 4a2013e5c..ca9d6455f 100644 --- a/spec/features/signout_spec.rb +++ b/spec/features/signout_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "signout" do diff --git a/spec/features/signup_spec.rb b/spec/features/signup_spec.rb index 331dedaa7..c7a136193 100644 --- a/spec/features/signup_spec.rb +++ b/spec/features/signup_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "signup", js: true do diff --git a/spec/features/timeline/index_spec.rb b/spec/features/timeline/index_spec.rb index bf0022df3..134c4a06f 100644 --- a/spec/features/timeline/index_spec.rb +++ b/spec/features/timeline/index_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "timeline", js: true do diff --git a/spec/features/unsubscribing_spec.rb b/spec/features/unsubscribing_spec.rb index 039b536b6..9fff6084b 100644 --- a/spec/features/unsubscribing_spec.rb +++ b/spec/features/unsubscribing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' require 'capybara/email/rspec' diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index ae7230a00..c285f9c5a 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe ApplicationHelper do diff --git a/spec/helpers/buttons_helper_spec.rb b/spec/helpers/buttons_helper_spec.rb index b9bdc41a2..b55a4668a 100644 --- a/spec/helpers/buttons_helper_spec.rb +++ b/spec/helpers/buttons_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' # Specs in this file have access to a helper object that includes diff --git a/spec/helpers/crops_helper_spec.rb b/spec/helpers/crops_helper_spec.rb index 532019e41..07d8bc3fe 100644 --- a/spec/helpers/crops_helper_spec.rb +++ b/spec/helpers/crops_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe CropsHelper do diff --git a/spec/helpers/event_helper_spec.rb b/spec/helpers/event_helper_spec.rb index f90a04c11..634953c50 100644 --- a/spec/helpers/event_helper_spec.rb +++ b/spec/helpers/event_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe EventHelper, type: :helper do diff --git a/spec/helpers/gardens_helper_spec.rb b/spec/helpers/gardens_helper_spec.rb index 57db618bd..3b8094ea6 100644 --- a/spec/helpers/gardens_helper_spec.rb +++ b/spec/helpers/gardens_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe GardensHelper do diff --git a/spec/helpers/harvests_helper_spec.rb b/spec/helpers/harvests_helper_spec.rb index 4286c326a..25be2d248 100644 --- a/spec/helpers/harvests_helper_spec.rb +++ b/spec/helpers/harvests_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe HarvestsHelper do diff --git a/spec/helpers/photos_helper_spec.rb b/spec/helpers/photos_helper_spec.rb index b24a254c7..bbd6a32b0 100644 --- a/spec/helpers/photos_helper_spec.rb +++ b/spec/helpers/photos_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe PhotosHelper do diff --git a/spec/helpers/plantings_helper_spec.rb b/spec/helpers/plantings_helper_spec.rb index d28ed90d4..14192bb14 100644 --- a/spec/helpers/plantings_helper_spec.rb +++ b/spec/helpers/plantings_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe PlantingsHelper do diff --git a/spec/helpers/seeds_helper_spec.rb b/spec/helpers/seeds_helper_spec.rb index 7fa751321..593527fa2 100644 --- a/spec/helpers/seeds_helper_spec.rb +++ b/spec/helpers/seeds_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe SeedsHelper do diff --git a/spec/lib/actions/oauth_signup_action_spec.rb b/spec/lib/actions/oauth_signup_action_spec.rb index dd8310d04..621b29af1 100644 --- a/spec/lib/actions/oauth_signup_action_spec.rb +++ b/spec/lib/actions/oauth_signup_action_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' require './lib/actions/oauth_signup_action' diff --git a/spec/lib/haml/filters/escaped_markdown_spec.rb b/spec/lib/haml/filters/escaped_markdown_spec.rb index 415751293..fd9b4e0b4 100644 --- a/spec/lib/haml/filters/escaped_markdown_spec.rb +++ b/spec/lib/haml/filters/escaped_markdown_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' require 'haml/filters' require 'haml/filters/escaped_markdown' diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb index cc27bd560..ecaf3356e 100644 --- a/spec/lib/haml/filters/growstuff_markdown_spec.rb +++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' require 'haml/filters' require 'haml/filters/growstuff_markdown' diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 389ae9937..c2c206a64 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' require 'cancan/matchers' diff --git a/spec/models/alternate_name_spec.rb b/spec/models/alternate_name_spec.rb index 5881121c8..515fdaa7a 100644 --- a/spec/models/alternate_name_spec.rb +++ b/spec/models/alternate_name_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe AlternateName do diff --git a/spec/models/authentication_spec.rb b/spec/models/authentication_spec.rb index 7e02a57f0..2c91dfac2 100644 --- a/spec/models/authentication_spec.rb +++ b/spec/models/authentication_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Authentication do diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 75166df9f..f684697fc 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Comment do diff --git a/spec/models/crop_companion_spec.rb b/spec/models/crop_companion_spec.rb index 7b6223db5..e1cedbfd0 100644 --- a/spec/models/crop_companion_spec.rb +++ b/spec/models/crop_companion_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe CropCompanion, type: :model do diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 98ba51366..bb3c07b0d 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Crop do diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb index 63e397d95..4a11208b1 100644 --- a/spec/models/follow_spec.rb +++ b/spec/models/follow_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Follow do diff --git a/spec/models/forum_spec.rb b/spec/models/forum_spec.rb index 310c36842..cc5b34a08 100644 --- a/spec/models/forum_spec.rb +++ b/spec/models/forum_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Forum do diff --git a/spec/models/garden_spec.rb b/spec/models/garden_spec.rb index c62fd0f1d..f154eca96 100644 --- a/spec/models/garden_spec.rb +++ b/spec/models/garden_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Garden do diff --git a/spec/models/garden_type.rb b/spec/models/garden_type.rb index cd5862c98..9ea7ac160 100644 --- a/spec/models/garden_type.rb +++ b/spec/models/garden_type.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe GardenType do diff --git a/spec/models/harvest_spec.rb b/spec/models/harvest_spec.rb index f4b110849..5465b43e0 100644 --- a/spec/models/harvest_spec.rb +++ b/spec/models/harvest_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Harvest do diff --git a/spec/models/like_spec.rb b/spec/models/like_spec.rb index 56f35bf1d..aeb5797e3 100644 --- a/spec/models/like_spec.rb +++ b/spec/models/like_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'like' do diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index 10ca3f5e6..f591bd3d5 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'member' do diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 2a4c7e86a..2f504f864 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Notification do diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 1102253f8..b7ca51898 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Photo do diff --git a/spec/models/plant_part_spec.rb b/spec/models/plant_part_spec.rb index ba1e56241..7747ec4e3 100644 --- a/spec/models/plant_part_spec.rb +++ b/spec/models/plant_part_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe PlantPart do diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index f19123d29..18b5e2802 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Planting do diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index e8bf3cf54..5fd8c8f62 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Post do diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb index 0fc5f92b7..5893a9dc1 100644 --- a/spec/models/role_spec.rb +++ b/spec/models/role_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Role do diff --git a/spec/models/scientific_name_spec.rb b/spec/models/scientific_name_spec.rb index 0b170812d..7433182eb 100644 --- a/spec/models/scientific_name_spec.rb +++ b/spec/models/scientific_name_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe ScientificName do diff --git a/spec/models/seed_spec.rb b/spec/models/seed_spec.rb index a2dae3155..1729f5dad 100644 --- a/spec/models/seed_spec.rb +++ b/spec/models/seed_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Seed do diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index d780aedb2..5082ce6ab 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' require 'simplecov' diff --git a/spec/requests/api/v1/crop_request_spec.rb b/spec/requests/api/v1/crop_request_spec.rb index 9eaab0194..06dd0311f 100644 --- a/spec/requests/api/v1/crop_request_spec.rb +++ b/spec/requests/api/v1/crop_request_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe 'Crops', type: :request do diff --git a/spec/requests/api/v1/gardens_request_spec.rb b/spec/requests/api/v1/gardens_request_spec.rb index 12a729a35..3116aa208 100644 --- a/spec/requests/api/v1/gardens_request_spec.rb +++ b/spec/requests/api/v1/gardens_request_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe 'Gardens', type: :request do diff --git a/spec/requests/api/v1/harvest_request_spec.rb b/spec/requests/api/v1/harvest_request_spec.rb index b958f7938..eb6a6e483 100644 --- a/spec/requests/api/v1/harvest_request_spec.rb +++ b/spec/requests/api/v1/harvest_request_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe 'Harvests', type: :request do diff --git a/spec/requests/api/v1/member_request_spec.rb b/spec/requests/api/v1/member_request_spec.rb index 0f1d78122..38021af32 100644 --- a/spec/requests/api/v1/member_request_spec.rb +++ b/spec/requests/api/v1/member_request_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe 'Members', type: :request do diff --git a/spec/requests/api/v1/photos_request_spec.rb b/spec/requests/api/v1/photos_request_spec.rb index d194e237e..1db6cede7 100644 --- a/spec/requests/api/v1/photos_request_spec.rb +++ b/spec/requests/api/v1/photos_request_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe 'Photos', type: :request do diff --git a/spec/requests/api/v1/plantings_request_spec.rb b/spec/requests/api/v1/plantings_request_spec.rb index 8c811f511..26781cc28 100644 --- a/spec/requests/api/v1/plantings_request_spec.rb +++ b/spec/requests/api/v1/plantings_request_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe 'Plantings', type: :request do diff --git a/spec/requests/api/v1/seeds_request_spec.rb b/spec/requests/api/v1/seeds_request_spec.rb index a65243c50..b0157fbfa 100644 --- a/spec/requests/api/v1/seeds_request_spec.rb +++ b/spec/requests/api/v1/seeds_request_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe 'Photos', type: :request do diff --git a/spec/requests/authentications_spec.rb b/spec/requests/authentications_spec.rb index 6cc612f44..6ed6f4ea5 100644 --- a/spec/requests/authentications_spec.rb +++ b/spec/requests/authentications_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Authentications" do diff --git a/spec/requests/conversations_spec.rb b/spec/requests/conversations_spec.rb index 1ed996685..745a0dbd8 100644 --- a/spec/requests/conversations_spec.rb +++ b/spec/requests/conversations_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Converstions' do diff --git a/spec/requests/forums_spec.rb b/spec/requests/forums_spec.rb index ff7cb283d..2833a2744 100644 --- a/spec/requests/forums_spec.rb +++ b/spec/requests/forums_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Forums" do diff --git a/spec/requests/garden_types_spec.rb b/spec/requests/garden_types_spec.rb index fbacd0491..d415e5bde 100644 --- a/spec/requests/garden_types_spec.rb +++ b/spec/requests/garden_types_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe "GardenTypes", type: :request do diff --git a/spec/requests/gardens_spec.rb b/spec/requests/gardens_spec.rb index 91a8dc8b7..890a6edb7 100644 --- a/spec/requests/gardens_spec.rb +++ b/spec/requests/gardens_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Gardens" do diff --git a/spec/requests/harvests_spec.rb b/spec/requests/harvests_spec.rb index f3774b3c0..c613de081 100644 --- a/spec/requests/harvests_spec.rb +++ b/spec/requests/harvests_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Harvests" do diff --git a/spec/requests/photos_spec.rb b/spec/requests/photos_spec.rb index b937ded3d..6ac4694a0 100644 --- a/spec/requests/photos_spec.rb +++ b/spec/requests/photos_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Photos" do diff --git a/spec/requests/plant_parts_spec.rb b/spec/requests/plant_parts_spec.rb index 1fc2150b2..a96599cbb 100644 --- a/spec/requests/plant_parts_spec.rb +++ b/spec/requests/plant_parts_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "PlantParts" do diff --git a/spec/requests/plantings_spec.rb b/spec/requests/plantings_spec.rb index cb66922e0..90a4b5348 100644 --- a/spec/requests/plantings_spec.rb +++ b/spec/requests/plantings_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Plantings" do diff --git a/spec/requests/post_spec.rb b/spec/requests/post_spec.rb index 3bb479aa8..51ccf416a 100644 --- a/spec/requests/post_spec.rb +++ b/spec/requests/post_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Posts" do diff --git a/spec/requests/scientific_names_spec.rb b/spec/requests/scientific_names_spec.rb index 922f6f270..f2ce118aa 100644 --- a/spec/requests/scientific_names_spec.rb +++ b/spec/requests/scientific_names_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "ScientificNames" do diff --git a/spec/requests/seeds_spec.rb b/spec/requests/seeds_spec.rb index 8bc5aeccf..1440d638c 100644 --- a/spec/requests/seeds_spec.rb +++ b/spec/requests/seeds_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "Seeds" do diff --git a/spec/routing/admin_routing_spec.rb b/spec/routing/admin_routing_spec.rb index 66b17bc16..287bb2976 100644 --- a/spec/routing/admin_routing_spec.rb +++ b/spec/routing/admin_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe AdminController do diff --git a/spec/routing/authentications_routing_spec.rb b/spec/routing/authentications_routing_spec.rb index 0601b9924..877a35395 100644 --- a/spec/routing/authentications_routing_spec.rb +++ b/spec/routing/authentications_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe AuthenticationsController do diff --git a/spec/routing/comments_routing_spec.rb b/spec/routing/comments_routing_spec.rb index 5390ab066..9fbfa436a 100644 --- a/spec/routing/comments_routing_spec.rb +++ b/spec/routing/comments_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe CommentsController do diff --git a/spec/routing/crops_routing_spec.rb b/spec/routing/crops_routing_spec.rb index 30f6004d3..7821db6ff 100644 --- a/spec/routing/crops_routing_spec.rb +++ b/spec/routing/crops_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe CropsController do diff --git a/spec/routing/follows_routing_spec.rb b/spec/routing/follows_routing_spec.rb index ddb01e00c..e79c26610 100644 --- a/spec/routing/follows_routing_spec.rb +++ b/spec/routing/follows_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe FollowsController do diff --git a/spec/routing/forums_routing_spec.rb b/spec/routing/forums_routing_spec.rb index 9ce6f427b..5c3ade545 100644 --- a/spec/routing/forums_routing_spec.rb +++ b/spec/routing/forums_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe ForumsController do diff --git a/spec/routing/garden_types_routing_spec.rb b/spec/routing/garden_types_routing_spec.rb index 986af7b70..805ebdfa3 100644 --- a/spec/routing/garden_types_routing_spec.rb +++ b/spec/routing/garden_types_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe GardenTypesController do diff --git a/spec/routing/gardens_routing_spec.rb b/spec/routing/gardens_routing_spec.rb index 02183eab0..ddd282551 100644 --- a/spec/routing/gardens_routing_spec.rb +++ b/spec/routing/gardens_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe GardensController do diff --git a/spec/routing/harvests_routing_spec.rb b/spec/routing/harvests_routing_spec.rb index af623c3fe..4dc1aaece 100644 --- a/spec/routing/harvests_routing_spec.rb +++ b/spec/routing/harvests_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe HarvestsController do diff --git a/spec/routing/member_routing_spec.rb b/spec/routing/member_routing_spec.rb index f4a32f229..790ff94b1 100644 --- a/spec/routing/member_routing_spec.rb +++ b/spec/routing/member_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe MembersController do diff --git a/spec/routing/photos_routing_spec.rb b/spec/routing/photos_routing_spec.rb index a645d0a60..812acf84a 100644 --- a/spec/routing/photos_routing_spec.rb +++ b/spec/routing/photos_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe PhotosController do diff --git a/spec/routing/plant_parts_routing_spec.rb b/spec/routing/plant_parts_routing_spec.rb index 966047f3f..3e10372d7 100644 --- a/spec/routing/plant_parts_routing_spec.rb +++ b/spec/routing/plant_parts_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe PlantPartsController do diff --git a/spec/routing/plantings_routing_spec.rb b/spec/routing/plantings_routing_spec.rb index d92d3a84f..75c37d655 100644 --- a/spec/routing/plantings_routing_spec.rb +++ b/spec/routing/plantings_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe PlantingsController do diff --git a/spec/routing/roles_routing_spec.rb b/spec/routing/roles_routing_spec.rb index c601e27e3..9b61b982e 100644 --- a/spec/routing/roles_routing_spec.rb +++ b/spec/routing/roles_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe Admin::RolesController do diff --git a/spec/routing/scientific_names_routing_spec.rb b/spec/routing/scientific_names_routing_spec.rb index 7bbbfa764..b52f4b43c 100644 --- a/spec/routing/scientific_names_routing_spec.rb +++ b/spec/routing/scientific_names_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe ScientificNamesController do diff --git a/spec/routing/seeds_routing_spec.rb b/spec/routing/seeds_routing_spec.rb index 9ebfbdb02..0528a5b8d 100644 --- a/spec/routing/seeds_routing_spec.rb +++ b/spec/routing/seeds_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe SeedsController do diff --git a/spec/routing/updates_routing_spec.rb b/spec/routing/updates_routing_spec.rb index 966647515..9c9715526 100644 --- a/spec/routing/updates_routing_spec.rb +++ b/spec/routing/updates_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rails_helper" describe PostsController do diff --git a/spec/services/timeline_service_spec.rb b/spec/services/timeline_service_spec.rb index 4ab41f719..632c8b0ad 100644 --- a/spec/services/timeline_service_spec.rb +++ b/spec/services/timeline_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'timeline' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index df3b6f92b..9b30a0829 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause this diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb index b54cf0282..f2d23aaf4 100644 --- a/spec/support/controller_macros.rb +++ b/spec/support/controller_macros.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Taken unashamedly from https://github.com/plataformatec/devise/wiki/How-To%3a-Controllers-and-Views-tests-with-Rails-3-%28and-rspec%29 module ControllerMacros def login_member(member_factory = :member) diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index 8aa076438..0821d2198 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.configure do |config| # a warning if you turn this off config.before(:suite) do diff --git a/spec/support/devise.rb b/spec/support/devise.rb index 090ffc6a8..c1f9c35fe 100644 --- a/spec/support/devise.rb +++ b/spec/support/devise.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.configure do |config| config.include Devise::Test::ControllerHelpers, type: :controller config.include Devise::Test::ControllerHelpers, type: :view diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index 973718629..91b877e14 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FeatureHelpers def fill_autocomplete(field, options = {}) Crop.reindex diff --git a/spec/support/is_likeable.rb b/spec/support/is_likeable.rb index c402d589c..9fbae5426 100644 --- a/spec/support/is_likeable.rb +++ b/spec/support/is_likeable.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + shared_examples "it is likeable" do before do # Possibly a horrible hack. diff --git a/spec/swagger_helper.rb b/spec/swagger_helper.rb index 327b2c804..67a935fa8 100644 --- a/spec/swagger_helper.rb +++ b/spec/swagger_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.configure do |config| diff --git a/spec/views/admin/index_spec.rb b/spec/views/admin/index_spec.rb index 7379519cc..4e8dbba27 100644 --- a/spec/views/admin/index_spec.rb +++ b/spec/views/admin/index_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'admin/index.html.haml', type: "view" do diff --git a/spec/views/admin/newsletter_spec.rb b/spec/views/admin/newsletter_spec.rb index fbae64def..464f2d6c5 100644 --- a/spec/views/admin/newsletter_spec.rb +++ b/spec/views/admin/newsletter_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'admin/newsletter.html.haml', type: "view" do diff --git a/spec/views/admin/roles/edit.html.haml_spec.rb b/spec/views/admin/roles/edit.html.haml_spec.rb index 859ac2492..d2ffc1146 100644 --- a/spec/views/admin/roles/edit.html.haml_spec.rb +++ b/spec/views/admin/roles/edit.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "admin/roles/edit" do diff --git a/spec/views/admin/roles/index.html.haml_spec.rb b/spec/views/admin/roles/index.html.haml_spec.rb index f852dd0d0..d8d0c7bc6 100644 --- a/spec/views/admin/roles/index.html.haml_spec.rb +++ b/spec/views/admin/roles/index.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "admin/roles/index" do diff --git a/spec/views/admin/roles/new.html.haml_spec.rb b/spec/views/admin/roles/new.html.haml_spec.rb index 3ce6b0c85..b9b3dc7b7 100644 --- a/spec/views/admin/roles/new.html.haml_spec.rb +++ b/spec/views/admin/roles/new.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "admin/roles/new" do diff --git a/spec/views/comments/edit.html.haml_spec.rb b/spec/views/comments/edit.html.haml_spec.rb index b7a547f8c..b95fb9d24 100644 --- a/spec/views/comments/edit.html.haml_spec.rb +++ b/spec/views/comments/edit.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "comments/edit" do diff --git a/spec/views/comments/index.rss.haml_spec.rb b/spec/views/comments/index.rss.haml_spec.rb index d1b376cab..38b5a2386 100644 --- a/spec/views/comments/index.rss.haml_spec.rb +++ b/spec/views/comments/index.rss.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'comments/index.rss.haml' do diff --git a/spec/views/comments/new.html.haml_spec.rb b/spec/views/comments/new.html.haml_spec.rb index c2d7b7e86..5b86a3a29 100644 --- a/spec/views/comments/new.html.haml_spec.rb +++ b/spec/views/comments/new.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "comments/new" do diff --git a/spec/views/crops/_grown_for.html.haml_spec.rb b/spec/views/crops/_grown_for.html.haml_spec.rb index f3beba7a2..3cd68bfd8 100644 --- a/spec/views/crops/_grown_for.html.haml_spec.rb +++ b/spec/views/crops/_grown_for.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "crops/_grown_for" do diff --git a/spec/views/crops/_popover.html.haml_spec.rb b/spec/views/crops/_popover.html.haml_spec.rb index 577667eca..09cd2eda9 100644 --- a/spec/views/crops/_popover.html.haml_spec.rb +++ b/spec/views/crops/_popover.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "crops/_popover" do diff --git a/spec/views/crops/edit.html.haml_spec.rb b/spec/views/crops/edit.html.haml_spec.rb index ba43f645f..6791c3393 100644 --- a/spec/views/crops/edit.html.haml_spec.rb +++ b/spec/views/crops/edit.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "crops/edit" do diff --git a/spec/views/crops/hierarchy.html.haml_spec.rb b/spec/views/crops/hierarchy.html.haml_spec.rb index c1d79f0bb..8232e14f3 100644 --- a/spec/views/crops/hierarchy.html.haml_spec.rb +++ b/spec/views/crops/hierarchy.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "crops/hierarchy" do diff --git a/spec/views/crops/index.html.haml_spec.rb b/spec/views/crops/index.html.haml_spec.rb index 9c1c16805..db69f9132 100644 --- a/spec/views/crops/index.html.haml_spec.rb +++ b/spec/views/crops/index.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "crops/index" do diff --git a/spec/views/crops/index.rss.haml_spec.rb b/spec/views/crops/index.rss.haml_spec.rb index a7afbba7a..5d1bfaef4 100644 --- a/spec/views/crops/index.rss.haml_spec.rb +++ b/spec/views/crops/index.rss.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'crops/index.rss.haml' do diff --git a/spec/views/crops/new.html.haml_spec.rb b/spec/views/crops/new.html.haml_spec.rb index 0dcf43624..95dfc5db0 100644 --- a/spec/views/crops/new.html.haml_spec.rb +++ b/spec/views/crops/new.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "crops/new" do diff --git a/spec/views/crops/wrangle.html.haml_spec.rb b/spec/views/crops/wrangle.html.haml_spec.rb index 1ae400e7e..89c5d0b15 100644 --- a/spec/views/crops/wrangle.html.haml_spec.rb +++ b/spec/views/crops/wrangle.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "crops/wrangle" do diff --git a/spec/views/devise/confirmations/new_spec.rb b/spec/views/devise/confirmations/new_spec.rb index de26a4ad8..ce4290259 100644 --- a/spec/views/devise/confirmations/new_spec.rb +++ b/spec/views/devise/confirmations/new_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe 'devise/confirmations/new.html.haml', type: "view" do before do @view.stub(:resource).and_return(Member.new) diff --git a/spec/views/devise/mailer/confirmation_instructions_spec.rb b/spec/views/devise/mailer/confirmation_instructions_spec.rb index 08e411796..0f4b25f09 100644 --- a/spec/views/devise/mailer/confirmation_instructions_spec.rb +++ b/spec/views/devise/mailer/confirmation_instructions_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'devise/mailer/confirmation_instructions.html.haml', type: "view" do diff --git a/spec/views/devise/mailer/reset_password_instructions_spec.rb b/spec/views/devise/mailer/reset_password_instructions_spec.rb index ef90f7589..7dce3e1f7 100644 --- a/spec/views/devise/mailer/reset_password_instructions_spec.rb +++ b/spec/views/devise/mailer/reset_password_instructions_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'devise/mailer/reset_password_instructions.html.haml', type: "view" do diff --git a/spec/views/devise/mailer/unlock_instructions_spec.rb b/spec/views/devise/mailer/unlock_instructions_spec.rb index d3ac3357d..5db8a66cc 100644 --- a/spec/views/devise/mailer/unlock_instructions_spec.rb +++ b/spec/views/devise/mailer/unlock_instructions_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'devise/mailer/unlock_instructions.html.haml', type: "view" do context "logged in" do diff --git a/spec/views/devise/registrations/edit_spec.rb b/spec/views/devise/registrations/edit_spec.rb index b260d13a8..1ca0ae8ad 100644 --- a/spec/views/devise/registrations/edit_spec.rb +++ b/spec/views/devise/registrations/edit_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'devise/registrations/edit.html.haml', type: "view" do diff --git a/spec/views/devise/registrations/new_spec.rb b/spec/views/devise/registrations/new_spec.rb index 0ee95b5b0..05c690ca9 100644 --- a/spec/views/devise/registrations/new_spec.rb +++ b/spec/views/devise/registrations/new_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'devise/registrations/new.html.haml', type: "view" do diff --git a/spec/views/devise/sessions/new_spec.rb b/spec/views/devise/sessions/new_spec.rb index d8ae1c480..5537f6fd9 100644 --- a/spec/views/devise/sessions/new_spec.rb +++ b/spec/views/devise/sessions/new_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'devise/sessions/new.html.haml', type: "view" do diff --git a/spec/views/devise/shared/_links_spec.rb b/spec/views/devise/shared/_links_spec.rb index c19101593..1a0c55d54 100644 --- a/spec/views/devise/shared/_links_spec.rb +++ b/spec/views/devise/shared/_links_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + describe 'devise/shared/_links.haml', type: "view" do def devise_mapping(register, recover, confirm, lock, oauth) dm = double("mappings") diff --git a/spec/views/devise/unlocks/new_spec.rb b/spec/views/devise/unlocks/new_spec.rb index 68666532f..184b820dd 100644 --- a/spec/views/devise/unlocks/new_spec.rb +++ b/spec/views/devise/unlocks/new_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'devise/unlocks/new.html.haml', type: "view" do diff --git a/spec/views/forums/edit.html.haml_spec.rb b/spec/views/forums/edit.html.haml_spec.rb index 57747391e..08580e4e1 100644 --- a/spec/views/forums/edit.html.haml_spec.rb +++ b/spec/views/forums/edit.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "forums/edit" do diff --git a/spec/views/forums/index.html.haml_spec.rb b/spec/views/forums/index.html.haml_spec.rb index 7307501fe..c5b467dea 100644 --- a/spec/views/forums/index.html.haml_spec.rb +++ b/spec/views/forums/index.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "forums/index" do diff --git a/spec/views/forums/new.html.haml_spec.rb b/spec/views/forums/new.html.haml_spec.rb index 4fec098df..ebb711688 100644 --- a/spec/views/forums/new.html.haml_spec.rb +++ b/spec/views/forums/new.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "forums/new" do diff --git a/spec/views/forums/show.html.haml_spec.rb b/spec/views/forums/show.html.haml_spec.rb index c40a77a81..7fc24c464 100644 --- a/spec/views/forums/show.html.haml_spec.rb +++ b/spec/views/forums/show.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "forums/show" do diff --git a/spec/views/garden_types/edit.html.haml_spec.rb b/spec/views/garden_types/edit.html.haml_spec.rb index b5c69b95f..c328e4275 100644 --- a/spec/views/garden_types/edit.html.haml_spec.rb +++ b/spec/views/garden_types/edit.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "garden_types/edit" do diff --git a/spec/views/garden_types/new.html.haml_spec.rb b/spec/views/garden_types/new.html.haml_spec.rb index 3241666af..e48aff0dd 100644 --- a/spec/views/garden_types/new.html.haml_spec.rb +++ b/spec/views/garden_types/new.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "garden_types/new" do diff --git a/spec/views/garden_types/show.html.haml_spec.rb b/spec/views/garden_types/show.html.haml_spec.rb index 10b4d83a8..33fc283ed 100644 --- a/spec/views/garden_types/show.html.haml_spec.rb +++ b/spec/views/garden_types/show.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "garden_types/show" do diff --git a/spec/views/gardens/edit.html.haml_spec.rb b/spec/views/gardens/edit.html.haml_spec.rb index a0564bf84..fc1ec78ee 100644 --- a/spec/views/gardens/edit.html.haml_spec.rb +++ b/spec/views/gardens/edit.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "gardens/edit" do diff --git a/spec/views/gardens/new.html.haml_spec.rb b/spec/views/gardens/new.html.haml_spec.rb index d76659f73..00bcc91e7 100644 --- a/spec/views/gardens/new.html.haml_spec.rb +++ b/spec/views/gardens/new.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "gardens/new" do diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 7535ce8de..5bb6cf0a9 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "gardens/show" do diff --git a/spec/views/harvests/edit.html.haml_spec.rb b/spec/views/harvests/edit.html.haml_spec.rb index 38307f503..2647f7961 100644 --- a/spec/views/harvests/edit.html.haml_spec.rb +++ b/spec/views/harvests/edit.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "harvests/edit" do diff --git a/spec/views/harvests/index.html.haml_spec.rb b/spec/views/harvests/index.html.haml_spec.rb index 1ce56c492..d018c9558 100644 --- a/spec/views/harvests/index.html.haml_spec.rb +++ b/spec/views/harvests/index.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "harvests/index" do diff --git a/spec/views/harvests/index.rss.haml_spec.rb b/spec/views/harvests/index.rss.haml_spec.rb index e3f1d20b2..47d28a9d6 100644 --- a/spec/views/harvests/index.rss.haml_spec.rb +++ b/spec/views/harvests/index.rss.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'harvests/index.rss.haml' do diff --git a/spec/views/harvests/new.html.haml_spec.rb b/spec/views/harvests/new.html.haml_spec.rb index abe1b547e..6c75a3853 100644 --- a/spec/views/harvests/new.html.haml_spec.rb +++ b/spec/views/harvests/new.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "harvests/new" do diff --git a/spec/views/harvests/show.html.haml_spec.rb b/spec/views/harvests/show.html.haml_spec.rb index 4a8053924..8b270ab56 100644 --- a/spec/views/harvests/show.html.haml_spec.rb +++ b/spec/views/harvests/show.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "harvests/show" do diff --git a/spec/views/home/_blurb.html.haml_spec.rb b/spec/views/home/_blurb.html.haml_spec.rb index 395ce74b0..2fc293133 100644 --- a/spec/views/home/_blurb.html.haml_spec.rb +++ b/spec/views/home/_blurb.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'home/_blurb.html.haml', type: "view" do diff --git a/spec/views/home/_members.html.haml_spec.rb b/spec/views/home/_members.html.haml_spec.rb index 332af1d22..b5be1f2b9 100644 --- a/spec/views/home/_members.html.haml_spec.rb +++ b/spec/views/home/_members.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'home/_members.html.haml', type: "view" do diff --git a/spec/views/home/_seeds.html.haml_spec.rb b/spec/views/home/_seeds.html.haml_spec.rb index e0b2c54be..346a2952d 100644 --- a/spec/views/home/_seeds.html.haml_spec.rb +++ b/spec/views/home/_seeds.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'home/_seeds.html.haml', type: "view" do diff --git a/spec/views/home/_stats.html.haml_spec.rb b/spec/views/home/_stats.html.haml_spec.rb index a9979190c..15d637fd2 100644 --- a/spec/views/home/_stats.html.haml_spec.rb +++ b/spec/views/home/_stats.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'home/_stats.html.haml', type: "view" do diff --git a/spec/views/home/index_spec.rb b/spec/views/home/index_spec.rb index 1289df4eb..83e9308d7 100644 --- a/spec/views/home/index_spec.rb +++ b/spec/views/home/index_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'home/index.html.haml', type: "view" do diff --git a/spec/views/layouts/_head_spec.rb b/spec/views/layouts/_head_spec.rb index c82355100..a516a99c1 100644 --- a/spec/views/layouts/_head_spec.rb +++ b/spec/views/layouts/_head_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'layouts/_head.html.haml', type: "view" do diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb index 4a39e99b3..b87bcb4d6 100644 --- a/spec/views/layouts/_header_spec.rb +++ b/spec/views/layouts/_header_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'layouts/_header.html.haml', type: "view" do diff --git a/spec/views/layouts/application_spec.rb b/spec/views/layouts/application_spec.rb index f2b23d910..4ccb69503 100644 --- a/spec/views/layouts/application_spec.rb +++ b/spec/views/layouts/application_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'layouts/application.html.haml', type: "view" do diff --git a/spec/views/members/_location.html.haml_spec.rb b/spec/views/members/_location.html.haml_spec.rb index db1fae09c..0ab04f478 100644 --- a/spec/views/members/_location.html.haml_spec.rb +++ b/spec/views/members/_location.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "members/_location" do diff --git a/spec/views/members/index.html.haml_spec.rb b/spec/views/members/index.html.haml_spec.rb index 34fda500f..8afbb85a5 100644 --- a/spec/views/members/index.html.haml_spec.rb +++ b/spec/views/members/index.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "members/index" do diff --git a/spec/views/members/show.rss.haml_spec.rb b/spec/views/members/show.rss.haml_spec.rb index ce4dc4c52..873e9ecf2 100644 --- a/spec/views/members/show.rss.haml_spec.rb +++ b/spec/views/members/show.rss.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'members/show.rss.haml', type: "view" do diff --git a/spec/views/photos/edit.html.haml_spec.rb b/spec/views/photos/edit.html.haml_spec.rb index ba481b104..1e94fb7b3 100644 --- a/spec/views/photos/edit.html.haml_spec.rb +++ b/spec/views/photos/edit.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "photos/edit" do diff --git a/spec/views/photos/index.html.haml_spec.rb b/spec/views/photos/index.html.haml_spec.rb index ef058e822..86843ce14 100644 --- a/spec/views/photos/index.html.haml_spec.rb +++ b/spec/views/photos/index.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "photos/index" do diff --git a/spec/views/photos/new.html.haml_spec.rb b/spec/views/photos/new.html.haml_spec.rb index 9f4072ee5..d15e99e22 100644 --- a/spec/views/photos/new.html.haml_spec.rb +++ b/spec/views/photos/new.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "photos/new" do diff --git a/spec/views/photos/show.html.haml_spec.rb b/spec/views/photos/show.html.haml_spec.rb index f0f1235ef..19690e30f 100644 --- a/spec/views/photos/show.html.haml_spec.rb +++ b/spec/views/photos/show.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "photos/show" do diff --git a/spec/views/places/_map_attribution.html.haml_spec.rb b/spec/views/places/_map_attribution.html.haml_spec.rb index afe384dfe..9b869a304 100644 --- a/spec/views/places/_map_attribution.html.haml_spec.rb +++ b/spec/views/places/_map_attribution.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "places/_map_attribution.html.haml", type: :view do diff --git a/spec/views/places/index.html.haml_spec.rb b/spec/views/places/index.html.haml_spec.rb index 072eb4ca3..f49bb9238 100644 --- a/spec/views/places/index.html.haml_spec.rb +++ b/spec/views/places/index.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "places/index" do diff --git a/spec/views/places/show.html.haml_spec.rb b/spec/views/places/show.html.haml_spec.rb index 7f9aa0c9c..2ac779a1f 100644 --- a/spec/views/places/show.html.haml_spec.rb +++ b/spec/views/places/show.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "places/show" do diff --git a/spec/views/plant_parts/edit.html.haml_spec.rb b/spec/views/plant_parts/edit.html.haml_spec.rb index cc6070fb0..c21a92106 100644 --- a/spec/views/plant_parts/edit.html.haml_spec.rb +++ b/spec/views/plant_parts/edit.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "plant_parts/edit" do diff --git a/spec/views/plant_parts/index.html.haml_spec.rb b/spec/views/plant_parts/index.html.haml_spec.rb index b46c4a1a5..828f942e3 100644 --- a/spec/views/plant_parts/index.html.haml_spec.rb +++ b/spec/views/plant_parts/index.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "plant_parts/index" do diff --git a/spec/views/plant_parts/new.html.haml_spec.rb b/spec/views/plant_parts/new.html.haml_spec.rb index b0067273c..203dc128a 100644 --- a/spec/views/plant_parts/new.html.haml_spec.rb +++ b/spec/views/plant_parts/new.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "plant_parts/new" do diff --git a/spec/views/plant_parts/show.html.haml_spec.rb b/spec/views/plant_parts/show.html.haml_spec.rb index 9947cfcce..39dce332a 100644 --- a/spec/views/plant_parts/show.html.haml_spec.rb +++ b/spec/views/plant_parts/show.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "plant_parts/show" do diff --git a/spec/views/plantings/_form.html.haml_spec.rb b/spec/views/plantings/_form.html.haml_spec.rb index 0f4c6f1af..a4f110a2f 100644 --- a/spec/views/plantings/_form.html.haml_spec.rb +++ b/spec/views/plantings/_form.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "plantings/_form" do diff --git a/spec/views/plantings/edit.html.haml_spec.rb b/spec/views/plantings/edit.html.haml_spec.rb index 6baf126f1..3acb14223 100644 --- a/spec/views/plantings/edit.html.haml_spec.rb +++ b/spec/views/plantings/edit.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "plantings/edit" do diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index 4284eada6..c6a0ae446 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "plantings/index" do diff --git a/spec/views/plantings/index.rss.haml_spec.rb b/spec/views/plantings/index.rss.haml_spec.rb index 24faa046c..b0f3be6cc 100644 --- a/spec/views/plantings/index.rss.haml_spec.rb +++ b/spec/views/plantings/index.rss.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'plantings/index.rss.haml' do diff --git a/spec/views/plantings/new.html.haml_spec.rb b/spec/views/plantings/new.html.haml_spec.rb index 3376d5cc0..b0aa596f9 100644 --- a/spec/views/plantings/new.html.haml_spec.rb +++ b/spec/views/plantings/new.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "plantings/new" do diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb index c774c5d48..5d7161e89 100644 --- a/spec/views/plantings/show.html.haml_spec.rb +++ b/spec/views/plantings/show.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "plantings/show" do diff --git a/spec/views/posts/_single.html.haml_spec.rb b/spec/views/posts/_single.html.haml_spec.rb index 90c15af78..403ea1198 100644 --- a/spec/views/posts/_single.html.haml_spec.rb +++ b/spec/views/posts/_single.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "posts/_single" do diff --git a/spec/views/posts/edit.html.haml_spec.rb b/spec/views/posts/edit.html.haml_spec.rb index 2119f80b5..c664f2131 100644 --- a/spec/views/posts/edit.html.haml_spec.rb +++ b/spec/views/posts/edit.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "posts/edit" do diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb index c865b2980..613f8dc59 100644 --- a/spec/views/posts/index.html.haml_spec.rb +++ b/spec/views/posts/index.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "posts/index" do diff --git a/spec/views/posts/index.rss.haml_spec.rb b/spec/views/posts/index.rss.haml_spec.rb index 030e22c05..055de59e2 100644 --- a/spec/views/posts/index.rss.haml_spec.rb +++ b/spec/views/posts/index.rss.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'posts/index.rss.haml', type: "view" do diff --git a/spec/views/posts/new.html.haml_spec.rb b/spec/views/posts/new.html.haml_spec.rb index eaef7f5da..3e5e0efca 100644 --- a/spec/views/posts/new.html.haml_spec.rb +++ b/spec/views/posts/new.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "posts/new" do diff --git a/spec/views/posts/show.html.haml_spec.rb b/spec/views/posts/show.html.haml_spec.rb index bb59f2b47..e40918c19 100644 --- a/spec/views/posts/show.html.haml_spec.rb +++ b/spec/views/posts/show.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "posts/show" do diff --git a/spec/views/posts/show.rss.haml_spec.rb b/spec/views/posts/show.rss.haml_spec.rb index 802bebe93..effd87094 100644 --- a/spec/views/posts/show.rss.haml_spec.rb +++ b/spec/views/posts/show.rss.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'posts/show.rss.haml' do diff --git a/spec/views/scientific_names/edit.html.haml_spec.rb b/spec/views/scientific_names/edit.html.haml_spec.rb index b497b44e7..b6b3cfb79 100644 --- a/spec/views/scientific_names/edit.html.haml_spec.rb +++ b/spec/views/scientific_names/edit.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "scientific_names/edit" do diff --git a/spec/views/scientific_names/index.html.haml_spec.rb b/spec/views/scientific_names/index.html.haml_spec.rb index 9d098e58b..88401808e 100644 --- a/spec/views/scientific_names/index.html.haml_spec.rb +++ b/spec/views/scientific_names/index.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "scientific_names/index" do diff --git a/spec/views/scientific_names/new.html.haml_spec.rb b/spec/views/scientific_names/new.html.haml_spec.rb index 1f6320308..39dbedd88 100644 --- a/spec/views/scientific_names/new.html.haml_spec.rb +++ b/spec/views/scientific_names/new.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "scientific_names/new" do diff --git a/spec/views/scientific_names/show.html.haml_spec.rb b/spec/views/scientific_names/show.html.haml_spec.rb index ed815c55d..1661ae8d2 100644 --- a/spec/views/scientific_names/show.html.haml_spec.rb +++ b/spec/views/scientific_names/show.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "scientific_names/show" do diff --git a/spec/views/seeds/edit.html.haml_spec.rb b/spec/views/seeds/edit.html.haml_spec.rb index 4bc6bf815..d7d5cd873 100644 --- a/spec/views/seeds/edit.html.haml_spec.rb +++ b/spec/views/seeds/edit.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "seeds/edit" do diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb index cfeedd904..8e074a80c 100644 --- a/spec/views/seeds/index.rss.haml_spec.rb +++ b/spec/views/seeds/index.rss.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'seeds/index.rss.haml' do diff --git a/spec/views/seeds/new.html.haml_spec.rb b/spec/views/seeds/new.html.haml_spec.rb index fc40236e5..407e52d72 100644 --- a/spec/views/seeds/new.html.haml_spec.rb +++ b/spec/views/seeds/new.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "seeds/new" do diff --git a/spec/views/seeds/show.html.haml_spec.rb b/spec/views/seeds/show.html.haml_spec.rb index 34525fbb6..2cc9fe146 100644 --- a/spec/views/seeds/show.html.haml_spec.rb +++ b/spec/views/seeds/show.html.haml_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe "seeds/show" do From 9d68ab02281e08f1fea9de5e36d2786600e54e11 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 17:13:54 +1300 Subject: [PATCH 039/188] Rubocop fix of controller --- app/controllers/admin/members_controller.rb | 2 ++ app/controllers/admin/roles_controller.rb | 2 ++ app/controllers/admin_controller.rb | 2 ++ app/controllers/alternate_names_controller.rb | 2 ++ app/controllers/api/v1/base_controller.rb | 2 ++ app/controllers/api/v1/crops_controller.rb | 2 ++ app/controllers/api/v1/gardens_controller.rb | 2 ++ app/controllers/api/v1/harvests_controller.rb | 2 ++ app/controllers/api/v1/members_controller.rb | 2 ++ app/controllers/api/v1/photos_controller.rb | 2 ++ app/controllers/api/v1/plantings_controller.rb | 2 ++ app/controllers/api/v1/seeds_controller.rb | 2 ++ app/controllers/application_controller.rb | 2 ++ app/controllers/authentications_controller.rb | 10 ++++++---- app/controllers/charts/crops_controller.rb | 2 ++ app/controllers/charts/gardens_controller.rb | 2 ++ app/controllers/comments_controller.rb | 2 ++ app/controllers/conversations_controller.rb | 4 +++- app/controllers/crops_controller.rb | 10 ++++++---- app/controllers/follows_controller.rb | 2 ++ app/controllers/forums_controller.rb | 2 ++ app/controllers/garden_types_controller.rb | 2 ++ app/controllers/gardens_controller.rb | 2 ++ app/controllers/home_controller.rb | 2 ++ app/controllers/likes_controller.rb | 14 ++++++++------ app/controllers/members_controller.rb | 4 +++- app/controllers/messages_controller.rb | 2 ++ app/controllers/omniauth_callbacks_controller.rb | 2 ++ app/controllers/pages_controller.rb | 2 ++ app/controllers/passwords_controller.rb | 2 ++ app/controllers/photo_associations_controller.rb | 2 ++ app/controllers/photos_controller.rb | 4 +++- app/controllers/places_controller.rb | 2 ++ app/controllers/plant_parts_controller.rb | 2 ++ app/controllers/plantings_controller.rb | 16 +++++++++------- app/controllers/posts_controller.rb | 2 ++ app/controllers/registrations_controller.rb | 2 ++ app/controllers/robots_controller.rb | 4 +++- app/controllers/scientific_names_controller.rb | 2 ++ app/controllers/seeds_controller.rb | 10 ++++++---- app/controllers/sessions_controller.rb | 2 ++ app/controllers/timeline_controller.rb | 2 ++ 42 files changed, 113 insertions(+), 29 deletions(-) diff --git a/app/controllers/admin/members_controller.rb b/app/controllers/admin/members_controller.rb index 0526a57c0..cf10b5c0d 100644 --- a/app/controllers/admin/members_controller.rb +++ b/app/controllers/admin/members_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class MembersController < ApplicationController before_action :admin! diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb index d08c292dc..3ad46e6ac 100644 --- a/app/controllers/admin/roles_controller.rb +++ b/app/controllers/admin/roles_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Admin class RolesController < ApplicationController before_action :admin! diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 541567430..454faf1c7 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AdminController < ApplicationController respond_to :html def index diff --git a/app/controllers/alternate_names_controller.rb b/app/controllers/alternate_names_controller.rb index 3466f72a9..922c078cf 100644 --- a/app/controllers/alternate_names_controller.rb +++ b/app/controllers/alternate_names_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AlternateNamesController < ApplicationController before_action :authenticate_member!, except: %i(index) load_and_authorize_resource diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb index 4fbc4d806..84eb42dcc 100644 --- a/app/controllers/api/v1/base_controller.rb +++ b/app/controllers/api/v1/base_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class BaseController < JSONAPI::ResourceController diff --git a/app/controllers/api/v1/crops_controller.rb b/app/controllers/api/v1/crops_controller.rb index d67beaa1a..f75516a43 100644 --- a/app/controllers/api/v1/crops_controller.rb +++ b/app/controllers/api/v1/crops_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class CropsController < BaseController diff --git a/app/controllers/api/v1/gardens_controller.rb b/app/controllers/api/v1/gardens_controller.rb index 4343d8014..ff420cf6a 100644 --- a/app/controllers/api/v1/gardens_controller.rb +++ b/app/controllers/api/v1/gardens_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class GardensController < BaseController diff --git a/app/controllers/api/v1/harvests_controller.rb b/app/controllers/api/v1/harvests_controller.rb index bcf735dce..1bef4212d 100644 --- a/app/controllers/api/v1/harvests_controller.rb +++ b/app/controllers/api/v1/harvests_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class HarvestsController < BaseController diff --git a/app/controllers/api/v1/members_controller.rb b/app/controllers/api/v1/members_controller.rb index b9b99956d..7f08067e9 100644 --- a/app/controllers/api/v1/members_controller.rb +++ b/app/controllers/api/v1/members_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class MembersController < BaseController diff --git a/app/controllers/api/v1/photos_controller.rb b/app/controllers/api/v1/photos_controller.rb index a095d24cb..693edd1fa 100644 --- a/app/controllers/api/v1/photos_controller.rb +++ b/app/controllers/api/v1/photos_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class PhotosController < BaseController diff --git a/app/controllers/api/v1/plantings_controller.rb b/app/controllers/api/v1/plantings_controller.rb index d143676ab..dc2bc689f 100644 --- a/app/controllers/api/v1/plantings_controller.rb +++ b/app/controllers/api/v1/plantings_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class PlantingsController < BaseController diff --git a/app/controllers/api/v1/seeds_controller.rb b/app/controllers/api/v1/seeds_controller.rb index 43f5691c6..53722ea6a 100644 --- a/app/controllers/api/v1/seeds_controller.rb +++ b/app/controllers/api/v1/seeds_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Api module V1 class SeedsController < BaseController diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ceafaa6cb..7e01327d6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationController < ActionController::Base protect_from_forgery diff --git a/app/controllers/authentications_controller.rb b/app/controllers/authentications_controller.rb index fc18ff4d7..94f40e25f 100644 --- a/app/controllers/authentications_controller.rb +++ b/app/controllers/authentications_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require './lib/actions/oauth_signup_action' class AuthenticationsController < ApplicationController before_action :authenticate_member! @@ -12,14 +14,14 @@ class AuthenticationsController < ApplicationController @authentication = current_member.authentications .create_with( - name: name, - token: auth['credentials']['token'], + name: name, + token: auth['credentials']['token'], secret: auth['credentials']['secret'] ) .find_or_create_by( provider: auth['provider'], - uid: auth['uid'], - name: name + uid: auth['uid'], + name: name ) flash[:notice] = "Authentication successful." diff --git a/app/controllers/charts/crops_controller.rb b/app/controllers/charts/crops_controller.rb index 9626a76b9..a48ec1ab2 100644 --- a/app/controllers/charts/crops_controller.rb +++ b/app/controllers/charts/crops_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Charts class CropsController < ApplicationController respond_to :json diff --git a/app/controllers/charts/gardens_controller.rb b/app/controllers/charts/gardens_controller.rb index b9d25bb53..a7048c57f 100644 --- a/app/controllers/charts/gardens_controller.rb +++ b/app/controllers/charts/gardens_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Charts class GardensController < ApplicationController respond_to :json diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index d47dae87d..37f2a5b16 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CommentsController < ApplicationController before_action :authenticate_member!, except: %i(index) load_and_authorize_resource diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb index e5da3be93..2f794aaf2 100644 --- a/app/controllers/conversations_controller.rb +++ b/app/controllers/conversations_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ConversationsController < ApplicationController respond_to :html before_action :authenticate_member! @@ -54,7 +56,7 @@ class ConversationsController < ApplicationController def set_box @boxes = { 'inbox' => { 'total' => mailbox.inbox.size, 'unread' => current_member.receipts.where(is_read: false).count }, - 'sent' => { 'total' => mailbox.sentbox.size, 'unread' => 0 }, + 'sent' => { 'total' => mailbox.sentbox.size, 'unread' => 0 }, 'trash' => { 'total' => mailbox.trash.size, 'unread' => 0 } } @box = if params[:box].blank? || !@boxes.keys.include?(params[:box]) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index eecca829c..ce6b7ed01 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'will_paginate/array' class CropsController < ApplicationController @@ -50,8 +52,8 @@ class CropsController < ApplicationController @term = params[:term] @crops = CropSearchService.search( - @term, page: params[:page], - per_page: 36, + @term, page: params[:page], + per_page: 36, current_member: current_member ) respond_with @crops @@ -202,13 +204,13 @@ class CropsController < ApplicationController def crop_json_fields { include: { - plantings: { + plantings: { include: { owner: { only: %i(id login_name location latitude longitude) } } }, scientific_names: { only: [:name] }, - alternate_names: { only: [:name] } + alternate_names: { only: [:name] } } } end diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index 1555a4a7c..2caf0f336 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class FollowsController < ApplicationController before_action :set_member, only: %i(index followers) load_and_authorize_resource diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index df6d1cad2..bc75da5fa 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ForumsController < ApplicationController load_and_authorize_resource respond_to :html, :json diff --git a/app/controllers/garden_types_controller.rb b/app/controllers/garden_types_controller.rb index 5fade528a..567af80ff 100644 --- a/app/controllers/garden_types_controller.rb +++ b/app/controllers/garden_types_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class GardenTypesController < ApplicationController respond_to :html, :json load_and_authorize_resource diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index 3e642837a..568f9b69b 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class GardensController < ApplicationController before_action :authenticate_member!, except: %i(index show) before_action :set_garden, only: %i(edit show update destroy) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 1241c70f5..e5ff4d06b 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class HomeController < ApplicationController skip_authorize_resource respond_to :html diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index 501bc6ee1..c806360c4 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class LikesController < ApplicationController before_action :authenticate_member! respond_to :html, :json @@ -28,11 +30,11 @@ class LikesController < ApplicationController def render_json(like, liked_by_member: true) { - id: like.likeable.id, - like_count: like.likeable.likes.count, + id: like.likeable.id, + like_count: like.likeable.likes.count, liked_by_member: liked_by_member, - description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like"), - url: like_path(like, format: :json) + description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like"), + url: like_path(like, format: :json) } end @@ -40,8 +42,8 @@ class LikesController < ApplicationController respond_to do |format| format.html { redirect_to like.likeable } format.json do - render(json: render_json(like, - liked_by_member: liked_by_member), + render(json: render_json(like, + liked_by_member: liked_by_member), status: status_code) end end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 0d07b303f..9f83044b0 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class MembersController < ApplicationController load_and_authorize_resource except: %i(finish_signup unsubscribe view_follows view_followers show) skip_authorize_resource only: %i(nearby unsubscribe finish_signup) @@ -69,7 +71,7 @@ class MembersController < ApplicationController EMAIL_TYPE_STRING = { send_notification_email: "direct message notifications", - send_planting_reminder: "planting reminders" + send_planting_reminder: "planting reminders" }.freeze def member_params diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 21bb4d0b2..9efc7ae42 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class MessagesController < ApplicationController respond_to :html, :json before_action :authenticate_member! diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 3d642cd3d..c9243c89b 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require './lib/actions/oauth_signup_action' # diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 9ffb98af8..4da0321de 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PagesController < ApplicationController def letsencrypt # use your code here, not mine diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb index fb6852ea9..012cd352b 100644 --- a/app/controllers/passwords_controller.rb +++ b/app/controllers/passwords_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PasswordsController < Devise::PasswordsController protected diff --git a/app/controllers/photo_associations_controller.rb b/app/controllers/photo_associations_controller.rb index 499dbefc0..00655a736 100644 --- a/app/controllers/photo_associations_controller.rb +++ b/app/controllers/photo_associations_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PhotoAssociationsController < ApplicationController before_action :authenticate_member! respond_to :json, :html diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index c6243ad20..7fc12b355 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PhotosController < ApplicationController before_action :authenticate_member!, except: %i(index show) after_action :expire_homepage, only: %i(create destroy) @@ -84,7 +86,7 @@ class PhotosController < ApplicationController def find_or_create_photo_from_flickr_photo photo = Photo.find_or_initialize_by( source_id: photo_params[:source_id], - source: 'flickr' + source: 'flickr' ) photo.update(photo_params) photo.owner_id = current_member.id diff --git a/app/controllers/places_controller.rb b/app/controllers/places_controller.rb index 4586b5d39..a30c1ae98 100644 --- a/app/controllers/places_controller.rb +++ b/app/controllers/places_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PlacesController < ApplicationController skip_authorize_resource respond_to :html, :json diff --git a/app/controllers/plant_parts_controller.rb b/app/controllers/plant_parts_controller.rb index 1e594fd72..8fbd23c59 100644 --- a/app/controllers/plant_parts_controller.rb +++ b/app/controllers/plant_parts_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PlantPartsController < ApplicationController load_and_authorize_resource respond_to :html, :json diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index a47c5a94a..4d654201f 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PlantingsController < ApplicationController before_action :authenticate_member!, except: %i(index show) before_action :set_planting, only: %i(edit show update destroy) @@ -27,11 +29,11 @@ class PlantingsController < ApplicationController end @plantings = Planting.search( - where: @where, - page: params[:page], - limit: 30, + where: @where, + page: params[:page], + limit: 30, boost_by: [:created_at], - load: false + load: false ) @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv" @@ -57,15 +59,15 @@ class PlantingsController < ApplicationController def new @planting = Planting.new( planted_at: Time.zone.today, - owner: current_member, - garden: current_member.gardens.first + owner: current_member, + garden: current_member.gardens.first ) @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new if params[:garden_id] @planting.garden = Garden.find_by( owner: current_member, - id: params[:garden_id] + id: params[:garden_id] ) end diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index d6561ce8e..40a70fade 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PostsController < ApplicationController before_action :authenticate_member!, except: %i(index show) load_and_authorize_resource diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 24a8ee8e8..530321233 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class RegistrationsController < Devise::RegistrationsController respond_to :json diff --git a/app/controllers/robots_controller.rb b/app/controllers/robots_controller.rb index 84f77e906..7a000749a 100644 --- a/app/controllers/robots_controller.rb +++ b/app/controllers/robots_controller.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class RobotsController < ApplicationController - DEFAULT_FILENAME = 'config/robots.txt'.freeze + DEFAULT_FILENAME = 'config/robots.txt' def robots filename = "config/robots.#{subdomain}.txt" if subdomain && subdomain != 'www' diff --git a/app/controllers/scientific_names_controller.rb b/app/controllers/scientific_names_controller.rb index cf58fd4f7..94a18acf9 100644 --- a/app/controllers/scientific_names_controller.rb +++ b/app/controllers/scientific_names_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ScientificNamesController < ApplicationController before_action :authenticate_member!, except: %i(index show) load_and_authorize_resource diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index 1cf465ab2..95c799d5a 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SeedsController < ApplicationController before_action :authenticate_member!, except: %i(index show) before_action :set_seed, only: %i(edit show update destroy) @@ -30,11 +32,11 @@ class SeedsController < ApplicationController @filename = csv_filename @seeds = Seed.search( - where: where, - page: params[:page], - limit: 30, + where: where, + page: params[:page], + limit: 30, boost_by: [:created_at], - load: false + load: false ) respond_with(@seeds) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index b8de4b54e..47063d75d 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SessionsController < Devise::SessionsController respond_to :html, :json diff --git a/app/controllers/timeline_controller.rb b/app/controllers/timeline_controller.rb index da912e69a..662480525 100644 --- a/app/controllers/timeline_controller.rb +++ b/app/controllers/timeline_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class TimelineController < ApplicationController def index if current_member From 9234ca0a6d61d40fb5ad5f95284e09aaf6fc359e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 17:15:41 +1300 Subject: [PATCH 040/188] Index plantings, seeds, and harvests before home page tests --- spec/features/home/home_spec.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb index fea8e27e8..901aa5b60 100644 --- a/spec/features/home/home_spec.rb +++ b/spec/features/home/home_spec.rb @@ -21,15 +21,12 @@ describe "home page" do before do # Add photos, so they can appear on home page planting.photos << photo - planting.reindex - seed.photos << photo - seed.reindex - harvest.photos << photo - harvest.reindex - Crop.reindex + Planting.reindex + Seed.reindex + Harvest.reindex end before { visit root_path } From f8916dfecbd74a8dceb5c439fb42a03bfa05f0de Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Fri, 20 Dec 2019 04:16:33 +0000 Subject: [PATCH 041/188] [CodeFactor] Apply fixes --- app/controllers/authentications_controller.rb | 8 ++++---- app/controllers/conversations_controller.rb | 2 +- app/controllers/crops_controller.rb | 8 ++++---- app/controllers/likes_controller.rb | 12 ++++++------ app/controllers/members_controller.rb | 2 +- app/controllers/photos_controller.rb | 2 +- app/controllers/plantings_controller.rb | 14 +++++++------- app/controllers/seeds_controller.rb | 8 ++++---- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/app/controllers/authentications_controller.rb b/app/controllers/authentications_controller.rb index 94f40e25f..31056c6e1 100644 --- a/app/controllers/authentications_controller.rb +++ b/app/controllers/authentications_controller.rb @@ -14,14 +14,14 @@ class AuthenticationsController < ApplicationController @authentication = current_member.authentications .create_with( - name: name, - token: auth['credentials']['token'], + name: name, + token: auth['credentials']['token'], secret: auth['credentials']['secret'] ) .find_or_create_by( provider: auth['provider'], - uid: auth['uid'], - name: name + uid: auth['uid'], + name: name ) flash[:notice] = "Authentication successful." diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb index 2f794aaf2..14b51e8ff 100644 --- a/app/controllers/conversations_controller.rb +++ b/app/controllers/conversations_controller.rb @@ -56,7 +56,7 @@ class ConversationsController < ApplicationController def set_box @boxes = { 'inbox' => { 'total' => mailbox.inbox.size, 'unread' => current_member.receipts.where(is_read: false).count }, - 'sent' => { 'total' => mailbox.sentbox.size, 'unread' => 0 }, + 'sent' => { 'total' => mailbox.sentbox.size, 'unread' => 0 }, 'trash' => { 'total' => mailbox.trash.size, 'unread' => 0 } } @box = if params[:box].blank? || !@boxes.keys.include?(params[:box]) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index ce6b7ed01..994ffe19b 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -52,8 +52,8 @@ class CropsController < ApplicationController @term = params[:term] @crops = CropSearchService.search( - @term, page: params[:page], - per_page: 36, + @term, page: params[:page], + per_page: 36, current_member: current_member ) respond_with @crops @@ -204,13 +204,13 @@ class CropsController < ApplicationController def crop_json_fields { include: { - plantings: { + plantings: { include: { owner: { only: %i(id login_name location latitude longitude) } } }, scientific_names: { only: [:name] }, - alternate_names: { only: [:name] } + alternate_names: { only: [:name] } } } end diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index c806360c4..37d302fcb 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -30,11 +30,11 @@ class LikesController < ApplicationController def render_json(like, liked_by_member: true) { - id: like.likeable.id, - like_count: like.likeable.likes.count, + id: like.likeable.id, + like_count: like.likeable.likes.count, liked_by_member: liked_by_member, - description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like"), - url: like_path(like, format: :json) + description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like"), + url: like_path(like, format: :json) } end @@ -42,8 +42,8 @@ class LikesController < ApplicationController respond_to do |format| format.html { redirect_to like.likeable } format.json do - render(json: render_json(like, - liked_by_member: liked_by_member), + render(json: render_json(like, + liked_by_member: liked_by_member), status: status_code) end end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 9f83044b0..9b65068d0 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -71,7 +71,7 @@ class MembersController < ApplicationController EMAIL_TYPE_STRING = { send_notification_email: "direct message notifications", - send_planting_reminder: "planting reminders" + send_planting_reminder: "planting reminders" }.freeze def member_params diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 7fc12b355..9b7fb7c1b 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -86,7 +86,7 @@ class PhotosController < ApplicationController def find_or_create_photo_from_flickr_photo photo = Photo.find_or_initialize_by( source_id: photo_params[:source_id], - source: 'flickr' + source: 'flickr' ) photo.update(photo_params) photo.owner_id = current_member.id diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 4d654201f..f4fbd6e80 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -29,11 +29,11 @@ class PlantingsController < ApplicationController end @plantings = Planting.search( - where: @where, - page: params[:page], - limit: 30, + where: @where, + page: params[:page], + limit: 30, boost_by: [:created_at], - load: false + load: false ) @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv" @@ -59,15 +59,15 @@ class PlantingsController < ApplicationController def new @planting = Planting.new( planted_at: Time.zone.today, - owner: current_member, - garden: current_member.gardens.first + owner: current_member, + garden: current_member.gardens.first ) @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new if params[:garden_id] @planting.garden = Garden.find_by( owner: current_member, - id: params[:garden_id] + id: params[:garden_id] ) end diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index 95c799d5a..f53d8c07d 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -32,11 +32,11 @@ class SeedsController < ApplicationController @filename = csv_filename @seeds = Seed.search( - where: where, - page: params[:page], - limit: 30, + where: where, + page: params[:page], + limit: 30, boost_by: [:created_at], - load: false + load: false ) respond_with(@seeds) From fc1c507a964f7abf686eae83b4190ebdd8a3404b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 17:32:48 +1300 Subject: [PATCH 042/188] Load planting rss from elastic too --- app/models/concerns/planting_search.rb | 48 ++++++++++++++------------ app/views/plantings/index.rss.haml | 18 +++++----- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/planting_search.rb index 0b2c1cc5f..cac2cf0ba 100644 --- a/app/models/concerns/planting_search.rb +++ b/app/models/concerns/planting_search.rb @@ -5,11 +5,11 @@ module PlantingSearch included do searchkick merge_mappings: true, - mappings: { + mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, harvests_count: { type: :integer }, - photos_count: { type: :integer }, + photos_count: { type: :integer }, owner_location: { type: :text } } } @@ -18,34 +18,38 @@ module PlantingSearch def search_data { - slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, - crop_id: crop_id, - owner_id: owner_id, - owner_name: owner.login_name, - owner_slug: owner.slug, - planted_from: planted_from, - photos_count: photos.size, - harvests_count: harvests.size, - has_photos: photos.size.positive?, - active: active?, - finished: finished?, - thumbnail_url: default_photo&.thumbnail_url, - owner_location: owner.location, + slug: slug, + active: active?, + crop_id: crop_id, + crop_name: crop.name, + crop_slug: crop.slug, + finished: finished?, + harvests_count: harvests.size, + has_photos: photos.size.positive?, + location: location, + owner_id: owner_id, + owner_location: owner.location, + owner_name: owner.login_name, + owner_slug: owner.slug, percentage_grown: percentage_grown.to_i, - created_at: created_at.to_i + photos_count: photos.size, + planted_at: planted_at, + planted_from: planted_from, + quantity: quantity, + sunniness: sunniness, + thumbnail_url: default_photo&.thumbnail_url, + created_at: created_at.to_i } end def self.homepage_records(limit) search('*', - limit: limit, - where: { + limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end diff --git a/app/views/plantings/index.rss.haml b/app/views/plantings/index.rss.haml index 94eb026da..036e59fd9 100644 --- a/app/views/plantings/index.rss.haml +++ b/app/views/plantings/index.rss.haml @@ -6,15 +6,15 @@ %link= plantings_url - @plantings.each do |planting| %item - %title #{planting.crop} in #{planting.location} - %pubdate= planting.created_at.to_s(:rfc822) + %title #{planting['crop']} in #{planting['location']} + %pubdate= planting['created_at'].to_s(:rfc822) %description :escaped -

Quantity: #{planting.quantity ? planting.quantity : 'unknown' }

-

Planted on: #{planting.planted_at ? planting.planted_at : 'unknown' }

-

Sunniness: #{planting.sunniness ? planting.sunniness : 'unknown' }

-

Planted from: #{planting.planted_from ? planting.planted_from : 'unknown' }

+

Quantity: #{planting['quantity'] ? planting['quantity'] : 'unknown' }

+

Planted on: #{planting['planted_at'] ? planting['planted_at'] : 'unknown' }

+

Sunniness: #{planting['sunniness'] ? planting['sunniness'] : 'unknown' }

+

Planted from: #{planting['planted_from'] ? planting['planted_from'] : 'unknown' }

:escaped_markdown - #{ strip_tags planting.description } - %link= planting_url(planting) - %guid= planting_url(planting) + #{ strip_tags planting['description'] } + %link= planting_url(slug: planting['slug']) + %guid= planting_url(slug: planting['slug']) From 9a0f22a4b9e65e830740bbcb6806aaa195415f3c Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Fri, 20 Dec 2019 04:33:33 +0000 Subject: [PATCH 043/188] [CodeFactor] Apply fixes to commit fc1c507 --- app/models/concerns/planting_search.rb | 52 +++++++++++++------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/planting_search.rb index cac2cf0ba..7e5837195 100644 --- a/app/models/concerns/planting_search.rb +++ b/app/models/concerns/planting_search.rb @@ -5,11 +5,11 @@ module PlantingSearch included do searchkick merge_mappings: true, - mappings: { + mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, harvests_count: { type: :integer }, - photos_count: { type: :integer }, + photos_count: { type: :integer }, owner_location: { type: :text } } } @@ -18,38 +18,38 @@ module PlantingSearch def search_data { - slug: slug, - active: active?, - crop_id: crop_id, - crop_name: crop.name, - crop_slug: crop.slug, - finished: finished?, - harvests_count: harvests.size, - has_photos: photos.size.positive?, - location: location, - owner_id: owner_id, - owner_location: owner.location, - owner_name: owner.login_name, - owner_slug: owner.slug, + slug: slug, + active: active?, + crop_id: crop_id, + crop_name: crop.name, + crop_slug: crop.slug, + finished: finished?, + harvests_count: harvests.size, + has_photos: photos.size.positive?, + location: location, + owner_id: owner_id, + owner_location: owner.location, + owner_name: owner.login_name, + owner_slug: owner.slug, percentage_grown: percentage_grown.to_i, - photos_count: photos.size, - planted_at: planted_at, - planted_from: planted_from, - quantity: quantity, - sunniness: sunniness, - thumbnail_url: default_photo&.thumbnail_url, - created_at: created_at.to_i + photos_count: photos.size, + planted_at: planted_at, + planted_from: planted_from, + quantity: quantity, + sunniness: sunniness, + thumbnail_url: default_photo&.thumbnail_url, + created_at: created_at.to_i } end def self.homepage_records(limit) search('*', - limit: limit, - where: { + limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end From bb0a5e0dd05a1880ed997c8a4004e1b01ace4a7b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 20 Dec 2019 17:34:40 +1300 Subject: [PATCH 044/188] Restore app.json --- app.json | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 app.json diff --git a/app.json b/app.json new file mode 100644 index 000000000..d419d8547 --- /dev/null +++ b/app.json @@ -0,0 +1,51 @@ +{ + "name": "growstuff", + "stack": "heroku-18", + "description": "Open data project for small-scale food growers", + "scripts": { + "postdeploy": "bundle exec rails db:seed" + }, + "env": { + "GROWSTUFF_ELASTICSEARCH": { + "required": true + }, + "GROWSTUFF_FACEBOOK_KEY": { + "required": true + }, + "GROWSTUFF_FACEBOOK_SECRET": { + "required": true + }, + "GROWSTUFF_FLICKR_KEY": { + "required": true + }, + "GROWSTUFF_FLICKR_SECRET": { + "required": true + }, + "GROWSTUFF_SITE_NAME": { + "required": true + }, + "GROWSTUFF_EMAIL": { + "required": true + }, + "MAIL_SENDER_HOST": { + "required": true + } + }, + "formation": { + "web": { + "quantity": 1 + } + }, + "addons": [ + "bonsai", + "heroku-postgresql", + "memcachier", + "newrelic", + "scout", + "sendgrid" + ], + "buildpacks": [ + { "url": "heroku/nodejs" }, + { "url": "heroku/ruby" } + ] +} From c711d7f76341c886f3c15e47c87f18c0a3cf8e6f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 21 Dec 2019 09:31:52 +1300 Subject: [PATCH 045/188] photos don't have a slug --- app/models/concerns/photo_search.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/concerns/photo_search.rb b/app/models/concerns/photo_search.rb index 90647b0b0..0c241f864 100644 --- a/app/models/concerns/photo_search.rb +++ b/app/models/concerns/photo_search.rb @@ -10,7 +10,6 @@ module PhotoSearch def search_data { - slug: slug, crops: crops.map(&:id), owner_id: owner_id, owner_name: owner.login_name, From b4afefcb85cfc07c3827d5bf1dc7c058786bd131 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 21 Dec 2019 09:32:19 +1300 Subject: [PATCH 046/188] Reindex after a photo association save or delete --- app/models/photo_association.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/photo_association.rb b/app/models/photo_association.rb index 36a953230..b09d94ca5 100644 --- a/app/models/photo_association.rb +++ b/app/models/photo_association.rb @@ -10,9 +10,11 @@ class PhotoAssociation < ApplicationRecord ## ## Triggers before_save :set_crop + after_create { |record| record.photographable.reindex } + after_destroy { |record| record.photographable.reindex } def item - find_by!(photographable_id: photographable_id, photographable_type: photographable_type).photographable + photographable end def self.item(item_id, item_type) From cae9fffea6021ba1c664c273a04116a9bbf00c0b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 21 Dec 2019 09:36:52 +1300 Subject: [PATCH 047/188] Index crop as well on photo changes --- app/models/garden.rb | 3 +++ app/models/photo_association.rb | 10 ++++++++-- app/models/post.rb | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/models/garden.rb b/app/models/garden.rb index 95c619dbe..0003b2276 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -77,6 +77,9 @@ class Garden < ApplicationRecord end end + def reindex + end + protected def strip_blanks diff --git a/app/models/photo_association.rb b/app/models/photo_association.rb index b09d94ca5..40004e4b7 100644 --- a/app/models/photo_association.rb +++ b/app/models/photo_association.rb @@ -10,8 +10,8 @@ class PhotoAssociation < ApplicationRecord ## ## Triggers before_save :set_crop - after_create { |record| record.photographable.reindex } - after_destroy { |record| record.photographable.reindex } + after_create :reindex + after_destroy :reindex def item photographable @@ -31,6 +31,12 @@ class PhotoAssociation < ApplicationRecord private + def reindex + photographable.reindex + crop&.reindex + true + end + def photo_and_item_have_same_owner return unless photographable_type != 'Crop' diff --git a/app/models/post.rb b/app/models/post.rb index 659291584..6eff19a35 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -57,6 +57,9 @@ class Post < ApplicationRecord subject end + def reindex + end + private def update_crop_posts_association From 1882c75941e4db7140c46d36a3f6642307cb4868 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Fri, 20 Dec 2019 20:37:33 +0000 Subject: [PATCH 048/188] [CodeFactor] Apply fixes --- app/models/garden.rb | 3 +-- app/models/post.rb | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/models/garden.rb b/app/models/garden.rb index 0003b2276..1a3b4a340 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -77,8 +77,7 @@ class Garden < ApplicationRecord end end - def reindex - end + def reindex; end protected diff --git a/app/models/post.rb b/app/models/post.rb index 6eff19a35..739404228 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -57,8 +57,7 @@ class Post < ApplicationRecord subject end - def reindex - end + def reindex; end private From 3decc69bca86a89246689c73275f7eee64b7c8fe Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 21 Dec 2019 09:40:11 +1300 Subject: [PATCH 049/188] planting routing specs to use slug --- spec/routing/plantings_routing_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/routing/plantings_routing_spec.rb b/spec/routing/plantings_routing_spec.rb index 75c37d655..e3a8b5344 100644 --- a/spec/routing/plantings_routing_spec.rb +++ b/spec/routing/plantings_routing_spec.rb @@ -14,11 +14,11 @@ describe PlantingsController do end it "routes to #show" do - get("/plantings/1").should route_to("plantings#show", id: "1") + get("/plantings/tomato").should route_to("plantings#show", slug: "tomato") end it "routes to #edit" do - get("/plantings/1/edit").should route_to("plantings#edit", id: "1") + get("/plantings/tomato/edit").should route_to("plantings#edit", slug: "tomato") end it "routes to #create" do @@ -26,11 +26,11 @@ describe PlantingsController do end it "routes to #update" do - put("/plantings/1").should route_to("plantings#update", id: "1") + put("/plantings/tomato").should route_to("plantings#update", slug: "tomato") end it "routes to #destroy" do - delete("/plantings/1").should route_to("plantings#destroy", id: "1") + delete("/plantings/tomato").should route_to("plantings#destroy", slug: "tomato") end end end From 306732d27c290fc35b3889de414cccdbfeaac15d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 21 Dec 2019 09:41:21 +1300 Subject: [PATCH 050/188] seed routing spec now using slugs --- spec/routing/seeds_routing_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/routing/seeds_routing_spec.rb b/spec/routing/seeds_routing_spec.rb index 0528a5b8d..65710acb1 100644 --- a/spec/routing/seeds_routing_spec.rb +++ b/spec/routing/seeds_routing_spec.rb @@ -14,11 +14,11 @@ describe SeedsController do end it "routes to #show" do - get("/seeds/1").should route_to("seeds#show", id: "1") + get("/seeds/corn").should route_to("seeds#show", slug: 'corn') end it "routes to #edit" do - get("/seeds/1/edit").should route_to("seeds#edit", id: "1") + get("/seeds/corn/edit").should route_to("seeds#edit", slug: 'corn') end it "routes to #create" do @@ -26,11 +26,11 @@ describe SeedsController do end it "routes to #update" do - put("/seeds/1").should route_to("seeds#update", id: "1") + put("/seeds/corn").should route_to("seeds#update", slug: 'corn') end it "routes to #destroy" do - delete("/seeds/1").should route_to("seeds#destroy", id: "1") + delete("/seeds/corn").should route_to("seeds#destroy", slug: 'corn') end end end From bbaf508da9829e0bbc65b137cde341a8fc999169 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 21 Dec 2019 09:42:21 +1300 Subject: [PATCH 051/188] harvest routing spec now using slugs --- spec/routing/harvests_routing_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/routing/harvests_routing_spec.rb b/spec/routing/harvests_routing_spec.rb index 4dc1aaece..22ee305fc 100644 --- a/spec/routing/harvests_routing_spec.rb +++ b/spec/routing/harvests_routing_spec.rb @@ -14,11 +14,11 @@ describe HarvestsController do end it "routes to #show" do - get("/harvests/1").should route_to("harvests#show", id: "1") + get("/harvests/potato").should route_to("harvests#show", slug: "potato") end it "routes to #edit" do - get("/harvests/1/edit").should route_to("harvests#edit", id: "1") + get("/harvests/potato/edit").should route_to("harvests#edit", slug: "potato") end it "routes to #create" do @@ -26,11 +26,11 @@ describe HarvestsController do end it "routes to #update" do - put("/harvests/1").should route_to("harvests#update", id: "1") + put("/harvests/potato").should route_to("harvests#update", slug: "potato") end it "routes to #destroy" do - delete("/harvests/1").should route_to("harvests#destroy", id: "1") + delete("/harvests/potato").should route_to("harvests#destroy", slug: "potato") end end end From 44d635e9b3bb3e28f94a52ab80abb6d30e47d339 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 21 Dec 2019 16:24:21 +1300 Subject: [PATCH 052/188] Update plantings#index view spec to use hashes like an ES search result --- spec/views/plantings/index.html.haml_spec.rb | 43 +++++++++++--------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index c6a0ae446..b55209e18 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -15,23 +15,28 @@ describe "plantings/index" do total_entries = 3 plantings = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| pager.replace([ - FactoryBot.create(:planting, - garden: garden, - crop: tomato, - owner: member), - FactoryBot.create(:planting, - garden: garden, - crop: maize, - owner: garden.owner, - description: '', - planted_at: Time.zone.local(2013, 1, 13)), - FactoryBot.create(:planting, - garden: garden, - owner: garden.owner, - crop: tomato, - planted_at: Time.zone.local(2013, 1, 13), - finished_at: Time.zone.local(2013, 1, 20), - finished: true) + { + 'crop_name' => tomato.name, + 'slug' => 'tomato-1', + 'owner_name' => member.login_name, + 'owner_slug' => member.slug + }, + { + 'crop_name' => maize.name, + 'slug' => 'maize', + 'owner_name' => garden.owner.login_name, + 'owner_slug' => garden.owner.slug, + 'planted_at' => Time.zone.local(2013, 1, 13) + }, + { + 'crop_name' => tomato.name, + 'slug' => 'tomato-2', + 'owner_name' => garden.owner.login_name, + 'owner_slug' => garden.owner.slug, + 'planted_at' => Time.zone.local(2013, 1, 13), + 'finished_at' => Time.zone.local(2013, 1, 20), + 'finished' => true + } ]) end assign(:plantings, plantings) @@ -39,8 +44,8 @@ describe "plantings/index" do end describe "renders a list of plantings" do - it { expect(rendered).to have_content tomato.name } - it { expect(rendered).to have_content maize.name } + it { expect(rendered).to have_content 'tomato' } + it { expect(rendered).to have_content 'maize' } end it "provides data links" do From cb75e4ff0c662210b95e8c537928dcd2ed429101 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sat, 21 Dec 2019 03:25:07 +0000 Subject: [PATCH 053/188] [CodeFactor] Apply fixes to commit 44d635e --- spec/views/plantings/index.html.haml_spec.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index b55209e18..095520650 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -16,26 +16,26 @@ describe "plantings/index" do plantings = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| pager.replace([ { - 'crop_name' => tomato.name, - 'slug' => 'tomato-1', + 'crop_name' => tomato.name, + 'slug' => 'tomato-1', 'owner_name' => member.login_name, 'owner_slug' => member.slug }, { - 'crop_name' => maize.name, - 'slug' => 'maize', + 'crop_name' => maize.name, + 'slug' => 'maize', 'owner_name' => garden.owner.login_name, 'owner_slug' => garden.owner.slug, 'planted_at' => Time.zone.local(2013, 1, 13) }, { - 'crop_name' => tomato.name, - 'slug' => 'tomato-2', - 'owner_name' => garden.owner.login_name, - 'owner_slug' => garden.owner.slug, - 'planted_at' => Time.zone.local(2013, 1, 13), + 'crop_name' => tomato.name, + 'slug' => 'tomato-2', + 'owner_name' => garden.owner.login_name, + 'owner_slug' => garden.owner.slug, + 'planted_at' => Time.zone.local(2013, 1, 13), 'finished_at' => Time.zone.local(2013, 1, 20), - 'finished' => true + 'finished' => true } ]) end From 786963eb8fe7627739dee30ec66a2d41f169fc48 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 21 Dec 2019 17:33:59 +1300 Subject: [PATCH 054/188] Update seeds rss to expect a hash --- app/models/concerns/seed_search.rb | 15 ++++++++++----- app/views/seeds/index.rss.haml | 25 +++++++++++-------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/app/models/concerns/seed_search.rb b/app/models/concerns/seed_search.rb index 4eb690741..d2389d70d 100644 --- a/app/models/concerns/seed_search.rb +++ b/app/models/concerns/seed_search.rb @@ -18,17 +18,22 @@ module SeedSearch def search_data { slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, crop_id: crop_id, + crop_name: crop.name, + crop_slug: crop.slug, + gmo: gmo, + has_photos: photos.size.positive?, + heirloom: heirloom, + organic: organic, owner_id: owner_id, owner_name: owner.login_name, - tradable_to: tradable_to, - tradeable: tradable?, parent_planting: parent_planting, photos_count: photos.size, - has_photos: photos.size.positive?, + plant_before: plant_before, + quantity: quantity, thumbnail_url: default_photo&.thumbnail_url, + tradable_to: tradable_to, + tradeable: tradable?, finished: finished?, created_at: created_at.to_i } diff --git a/app/views/seeds/index.rss.haml b/app/views/seeds/index.rss.haml index b2044de6e..563ffae17 100644 --- a/app/views/seeds/index.rss.haml +++ b/app/views/seeds/index.rss.haml @@ -6,20 +6,17 @@ %link= seeds_url - @seeds.each do |seed| %item - %title #{seed.owner}'s #{seed.crop} seeds - %pubdate= seed.created_at.to_s(:rfc822) + %title #{seed['owner_name']}'s #{seed['crop_name']} seeds + %pubdate= seed['created_at'].to_s(:rfc822) %description :escaped -

Quantity: #{seed.quantity ? seed.quantity : 'unknown' }

-

Plant before: #{seed.plant_before ? seed.plant_before : 'unknown' }

-

Organic? #{seed.organic}

-

GMO? #{seed.gmo}

-

Heirloom? #{seed.heirloom}

- - if seed.tradable? +

Quantity: #{seed['quantity'] ? seed['quantity'] : 'unknown' }

+

Plant before: #{seed['plant_before'] ? seed['plant_before'] : 'unknown' }

+

Organic? #{seed['organic']}

+

GMO? #{seed['gmo']}

+

Heirloom? #{seed['heirloom']}

+ - if seed['tradable'] %p - Will trade #{seed.tradable_to} from #{seed.owner.location ? seed.owner.location : 'unknown location'} - - :escaped_markdown - #{ strip_tags seed.description } - %link= seed_url(seed) - %guid= seed_url(seed) + Will trade #{seed['tradable_to']} from #{@owner.location ? @owner.location : 'unknown location'} + %link= seed_url(slug: seed['slug']) + %guid= seed_url(slug: seed['slug']) From ce18dc06107451342425919ab87aaf42b8e00a88 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 21 Dec 2019 17:55:14 +1300 Subject: [PATCH 055/188] Display seeds from elastic search --- app/models/seed.rb | 1 + app/views/home/_seeds.html.haml | 4 ++-- app/views/seeds/_search_result.html.haml | 16 ++++++++++++++++ app/views/seeds/index.html.haml | 16 +--------------- 4 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 app/views/seeds/_search_result.html.haml diff --git a/app/models/seed.rb b/app/models/seed.rb index 48e08823d..47571f7f8 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -48,6 +48,7 @@ class Seed < ApplicationRecord # # Delegations delegate :name, to: :crop + delegate :location, :latitude, :longitude, to: :owner # # Scopes diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml index 38ae29fd9..1ce34cb11 100644 --- a/app/views/home/_seeds.html.haml +++ b/app/views/home/_seeds.html.haml @@ -1,5 +1,5 @@ - cache cache_key_for(Seed) do %h2.text-center= t('home.seeds.title') .index-cards - - Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(6).each do |seed| - = render 'seeds/card', seed: seed + - Seed.homepage_records(6).each do |seed| + = render 'seeds/search_result', seed: seed diff --git a/app/views/seeds/_search_result.html.haml b/app/views/seeds/_search_result.html.haml new file mode 100644 index 000000000..058340dcc --- /dev/null +++ b/app/views/seeds/_search_result.html.haml @@ -0,0 +1,16 @@ +.card.seed-card{class: seed['finished'] ? 'card-finished' : ''} + = link_to seed_path(slug: seed['slug']) do + = image_tag(seed['thumbnail_url'] ? seed['thumbnail_url'] : placeholder_image, alt: seed['crop_name'], class: 'img-card') + .text + %span.chip.member-chip= seed['owner_name'] + .card-body + .card-title + = link_to seed['crop_name'], seed_path(seed['slug']) + - if seed['tradeable'] + .text-muted + = icon 'fas', 'map' + Will trade #{seed['tradable_to']} + .card-footer + .badge.badge-pill.badge-location + = icon 'fas', 'map-marker' + = truncate(seed['location'], length: 20, separator: ' ', omission: '... ') \ No newline at end of file diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index 56542618a..f67dca412 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -39,21 +39,7 @@ .index-cards - @seeds.each do |seed| - .card.seed-card{class: seed['finished'] ? 'card-finished' : ''} - = link_to seed_path(slug: seed['slug']) do - = image_tag(seed['thumbnail_url'] ? seed['thumbnail_url'] : placeholder_image, alt: seed['crop_name'], class: 'img-card') - .text - %span.chip.member-chip= seed['owner_name'] - .card-body - .card-title - = link_to seed['crop_name'], seed_path(seed['slug']) - - if seed['tradable'] - .text-muted - = icon 'fas', 'map' - Will trade #{seed['tradable_to']} - .badge.badge-pill.badge-location - = icon 'fas', 'map-marker' - = truncate(seed['owner_location'], length: 20, separator: ' ', omission: '... ') + = render 'seeds/search_result', seed: seed = will_paginate @seeds From 86a8f95e60393c403421bb51a231e16a033163cc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 21 Dec 2019 17:55:34 +1300 Subject: [PATCH 056/188] get photo from crop (saved into ES) --- app/models/concerns/harvest_search.rb | 2 +- app/models/concerns/planting_search.rb | 2 +- app/models/concerns/seed_search.rb | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/concerns/harvest_search.rb b/app/models/concerns/harvest_search.rb index 7850fd8d7..936a7d00d 100644 --- a/app/models/concerns/harvest_search.rb +++ b/app/models/concerns/harvest_search.rb @@ -27,7 +27,7 @@ module HarvestSearch planting_id: planting_id, photos_count: photos.size, has_photos: photos.size.positive?, - thumbnail_url: default_photo&.thumbnail_url, + thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, created_at: created_at.to_i } end diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/planting_search.rb index 7e5837195..38f37261e 100644 --- a/app/models/concerns/planting_search.rb +++ b/app/models/concerns/planting_search.rb @@ -37,7 +37,7 @@ module PlantingSearch planted_from: planted_from, quantity: quantity, sunniness: sunniness, - thumbnail_url: default_photo&.thumbnail_url, + thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, created_at: created_at.to_i } end diff --git a/app/models/concerns/seed_search.rb b/app/models/concerns/seed_search.rb index d2389d70d..833f331f1 100644 --- a/app/models/concerns/seed_search.rb +++ b/app/models/concerns/seed_search.rb @@ -31,10 +31,11 @@ module SeedSearch photos_count: photos.size, plant_before: plant_before, quantity: quantity, - thumbnail_url: default_photo&.thumbnail_url, + thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, tradable_to: tradable_to, tradeable: tradable?, finished: finished?, + location: location, created_at: created_at.to_i } end @@ -43,7 +44,8 @@ module SeedSearch search('*', limit: limit, where: { - photos_count: { gt: 0 } + finished: false, + tradeable: true, }, boost_by: [:created_at], load: false) From d7fc61e0ec1783009e147cca2ae789af0b1743b6 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sat, 21 Dec 2019 04:56:25 +0000 Subject: [PATCH 057/188] [CodeFactor] Apply fixes to commit 86a8f95 --- app/models/concerns/seed_search.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/seed_search.rb b/app/models/concerns/seed_search.rb index 833f331f1..753164064 100644 --- a/app/models/concerns/seed_search.rb +++ b/app/models/concerns/seed_search.rb @@ -45,7 +45,7 @@ module SeedSearch limit: limit, where: { finished: false, - tradeable: true, + tradeable: true }, boost_by: [:created_at], load: false) From 2c8a03568343739a40c378f44f463b535fad6452 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 21 Dec 2019 19:36:59 +1300 Subject: [PATCH 058/188] Update garden routing spec --- spec/routing/gardens_routing_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/routing/gardens_routing_spec.rb b/spec/routing/gardens_routing_spec.rb index ddd282551..7f4e8fb47 100644 --- a/spec/routing/gardens_routing_spec.rb +++ b/spec/routing/gardens_routing_spec.rb @@ -14,11 +14,11 @@ describe GardensController do end it "routes to #show" do - get("/gardens/1").should route_to("gardens#show", id: "1") + get("/gardens/sunny-bed").should route_to("gardens#show", slug: 'sunny-bed') end it "routes to #edit" do - get("/gardens/1/edit").should route_to("gardens#edit", id: "1") + get("/gardens/1/edit").should route_to("gardens#edit", slug: 'sunny-bed') end it "routes to #create" do @@ -26,11 +26,11 @@ describe GardensController do end it "routes to #update" do - put("/gardens/1").should route_to("gardens#update", id: "1") + put("/gardens/sunny-bed").should route_to("gardens#update", slug: 'sunny-bed') end it "routes to #destroy" do - delete("/gardens/1").should route_to("gardens#destroy", id: "1") + delete("/gardens/sunny-bed").should route_to("gardens#destroy", slug: 'sunny-bed') end end end From c79e83c26a99bc51efab2045485a21370850d0a5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 22 Dec 2019 15:43:57 +1300 Subject: [PATCH 059/188] fixed last garden routing spec --- spec/routing/gardens_routing_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/routing/gardens_routing_spec.rb b/spec/routing/gardens_routing_spec.rb index 7f4e8fb47..365fba5e7 100644 --- a/spec/routing/gardens_routing_spec.rb +++ b/spec/routing/gardens_routing_spec.rb @@ -18,7 +18,7 @@ describe GardensController do end it "routes to #edit" do - get("/gardens/1/edit").should route_to("gardens#edit", slug: 'sunny-bed') + get("/gardens/sunny-bed/edit").should route_to("gardens#edit", slug: 'sunny-bed') end it "routes to #create" do From 4b9863a3e658ea0e448c4645a372f977e62bfc95 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 22 Dec 2019 15:46:29 +1300 Subject: [PATCH 060/188] index harvests into ES during harvests#index spec --- spec/features/harvests/browse_harvests_spec.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/features/harvests/browse_harvests_spec.rb b/spec/features/harvests/browse_harvests_spec.rb index 2ce14f4a1..299d68cc8 100644 --- a/spec/features/harvests/browse_harvests_spec.rb +++ b/spec/features/harvests/browse_harvests_spec.rb @@ -9,10 +9,14 @@ describe "browse harvests" do context 'signed in' do include_context 'signed in member' + describe 'blank optional fields' do let!(:harvest) { create :harvest, :no_description } - before { visit harvests_path } + before do + Harvest.reindex + visit harvests_path + end it 'read more' do expect(subject).not_to have_link "Read more" @@ -23,6 +27,7 @@ describe "browse harvests" do let!(:harvest) { create :harvest, :long_description } before do + Harvest.reindex visit harvests_path end From 78fed0e8de0c07cfac91f49246d7f7575ad8f610 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sun, 22 Dec 2019 02:47:35 +0000 Subject: [PATCH 061/188] [CodeFactor] Apply fixes --- spec/features/harvests/browse_harvests_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/harvests/browse_harvests_spec.rb b/spec/features/harvests/browse_harvests_spec.rb index 299d68cc8..55827bcb1 100644 --- a/spec/features/harvests/browse_harvests_spec.rb +++ b/spec/features/harvests/browse_harvests_spec.rb @@ -14,7 +14,7 @@ describe "browse harvests" do let!(:harvest) { create :harvest, :no_description } before do - Harvest.reindex + Harvest.reindex visit harvests_path end @@ -27,7 +27,7 @@ describe "browse harvests" do let!(:harvest) { create :harvest, :long_description } before do - Harvest.reindex + Harvest.reindex visit harvests_path end From c54c417b611ae72b9d52e659c85afa26bb61a14b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 22 Dec 2019 16:04:21 +1300 Subject: [PATCH 062/188] no frozen comment on this spec --- spec/lib/haml/filters/growstuff_markdown_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb index ecaf3356e..5a847759a 100644 --- a/spec/lib/haml/filters/growstuff_markdown_spec.rb +++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb @@ -1,5 +1,4 @@ -# frozen_string_literal: true - +# rubocop:disable Style/FrozenStringLiteralComment require 'rails_helper' require 'haml/filters' require 'haml/filters/growstuff_markdown' From 12e91a74410574ed82978c73e03fc013e4e09558 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 22 Dec 2019 16:04:33 +1300 Subject: [PATCH 063/188] Specify rails 5.2 in rubocop config --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2c360bcb9..7eca13fed 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,7 +4,7 @@ AllCops: Exclude: - 'db/schema.rb' - 'vendor/**/*' - TargetRailsVersion: 5.0 + TargetRailsVersion: 5.2 Rails: Enabled: true From 29b98a5bccd0172ea4101d136d46fdd9dd48b11a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 22 Dec 2019 16:41:26 +1300 Subject: [PATCH 064/188] adding photos (and liking photos) cause `touch` do the cache in invalidated --- app/models/like.rb | 2 +- app/models/photo_association.rb | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/app/models/like.rb b/app/models/like.rb index 5cf7992a0..ed16065de 100644 --- a/app/models/like.rb +++ b/app/models/like.rb @@ -2,7 +2,7 @@ class Like < ApplicationRecord belongs_to :member - belongs_to :likeable, polymorphic: true, counter_cache: true + belongs_to :likeable, polymorphic: true, counter_cache: true, touch: true validates :member, :likeable, presence: true validates :member, uniqueness: { scope: :likeable } end diff --git a/app/models/photo_association.rb b/app/models/photo_association.rb index 40004e4b7..a2904320b 100644 --- a/app/models/photo_association.rb +++ b/app/models/photo_association.rb @@ -2,7 +2,7 @@ class PhotoAssociation < ApplicationRecord belongs_to :photo, inverse_of: :photo_associations - belongs_to :photographable, polymorphic: true + belongs_to :photographable, polymorphic: true, touch: true belongs_to :crop, optional: true, counter_cache: true validate :photo_and_item_have_same_owner @@ -10,8 +10,6 @@ class PhotoAssociation < ApplicationRecord ## ## Triggers before_save :set_crop - after_create :reindex - after_destroy :reindex def item photographable @@ -31,12 +29,6 @@ class PhotoAssociation < ApplicationRecord private - def reindex - photographable.reindex - crop&.reindex - true - end - def photo_and_item_have_same_owner return unless photographable_type != 'Crop' From 5a6ee3872218c0a607c254dee7bf86a2a130fc26 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 22 Dec 2019 16:57:28 +1300 Subject: [PATCH 065/188] update plantings controller spec to look for a hash of searchkick results --- spec/controllers/plantings_controller_spec.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index fb9f51b53..6e5bbd6f2 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -19,25 +19,28 @@ describe PlantingsController do let!(:maize) { FactoryBot.create(:maize) } let!(:planting1) { FactoryBot.create :planting, crop: tomato, owner: member1, created_at: 1.day.ago } let!(:planting2) { FactoryBot.create :planting, crop: maize, owner: member2, created_at: 5.days.ago } - + before { Planting.reindex } describe "assigns all plantings as @plantings" do before { get :index } - it { expect(assigns(:plantings)).to match [planting1, planting2] } + it { expect(assigns(:plantings).size).to eq 2 } + it { expect(assigns(:plantings)[0]['slug']).to eq planting1.slug } + it { expect(assigns(:plantings)[1]['slug']).to eq planting2.slug } end describe "picks up owner from params and shows owner's plantings only" do before { get :index, params: { member_slug: member1.slug } } it { expect(assigns(:owner)).to eq member1 } - it { expect(assigns(:plantings)).to eq [planting1] } + it { expect(assigns(:plantings).size).to eq 1 } + it { expect(assigns(:plantings).first['slug']).to eq planting1.slug } end describe "picks up crop from params and shows the plantings for the crop only" do before { get :index, params: { crop_slug: maize.slug } } it { expect(assigns(:crop)).to eq maize } - it { expect(assigns(:plantings)).to eq [planting2] } + it { expect(assigns(:plantings).first['slug']).to eq planting2.slug } end end From 81051c686522e9c52e3a99b8f55a639614654109 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sun, 22 Dec 2019 03:58:03 +0000 Subject: [PATCH 066/188] [CodeFactor] Apply fixes to commit 5a6ee38 --- spec/controllers/plantings_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index 6e5bbd6f2..033f628e1 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -19,7 +19,7 @@ describe PlantingsController do let!(:maize) { FactoryBot.create(:maize) } let!(:planting1) { FactoryBot.create :planting, crop: tomato, owner: member1, created_at: 1.day.ago } let!(:planting2) { FactoryBot.create :planting, crop: maize, owner: member2, created_at: 5.days.ago } - before { Planting.reindex } + before { Planting.reindex } describe "assigns all plantings as @plantings" do before { get :index } From 929374f77a7686db5477db5ab208820fe4f5e75f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 22 Dec 2019 17:00:30 +1300 Subject: [PATCH 067/188] rubocop renamed : Metrics/LineLength to : Layout/LineLength --- .rubocop.yml | 2 +- app/helpers/crops_helper.rb | 2 +- config/initializers/devise.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7eca13fed..9472c8915 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -52,7 +52,7 @@ Metrics/BlockLength: - '**/*.rake' - 'config/**/*.rb' -Metrics/LineLength: +Layout/LineLength: Max: 140 # Places we use update_all, etc even though it skips validations. diff --git a/app/helpers/crops_helper.rb b/app/helpers/crops_helper.rb index 7d2187e51..ead50b24d 100644 --- a/app/helpers/crops_helper.rb +++ b/app/helpers/crops_helper.rb @@ -15,6 +15,6 @@ module CropsHelper end def crop_ebay_seeds_url(crop) - "https://rover.ebay.com/rover/1/705-53470-19255-0/1?icep_ff3=9&pub=5575213277&toolid=10001&campid=5337940151&customid=&icep_uq=#{CGI.escape crop.name}&icep_sellerId=&icep_ex_kw=&icep_sortBy=12&icep_catId=181003&icep_minPrice=&icep_maxPrice=&ipn=psmain&icep_vectorid=229515&kwid=902099&mtid=824&kw=lg" # rubocop:disable Metrics/LineLength + "https://rover.ebay.com/rover/1/705-53470-19255-0/1?icep_ff3=9&pub=5575213277&toolid=10001&campid=5337940151&customid=&icep_uq=#{CGI.escape crop.name}&icep_sellerId=&icep_ex_kw=&icep_sortBy=12&icep_catId=181003&icep_minPrice=&icep_maxPrice=&ipn=psmain&icep_vectorid=229515&kwid=902099&mtid=824&kw=lg" # rubocop:disable Layout/LineLength end end diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 7692ebbc7..1512d8f09 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# rubocop:disable Metrics/LineLength +# rubocop:disable Layout/LineLength # Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| @@ -238,4 +238,4 @@ Devise.setup do |config| # 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' end -# rubocop:enable Metrics/LineLength +# rubocop:enable Layout/LineLength From 96f6fd3708c539be4d2138155a3156a27b20a7a4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 22 Dec 2019 17:16:13 +1300 Subject: [PATCH 068/188] update to expect syntax --- spec/views/forums/show.html.haml_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/views/forums/show.html.haml_spec.rb b/spec/views/forums/show.html.haml_spec.rb index 7fc24c464..89d2d4432 100644 --- a/spec/views/forums/show.html.haml_spec.rb +++ b/spec/views/forums/show.html.haml_spec.rb @@ -10,8 +10,8 @@ describe "forums/show" do it "renders attributes" do render - rendered.should have_content "Everything about permaculture" - rendered.should have_content @forum.owner.to_s + expect(rendered).to have_content "Everything about permaculture" + expect(rendered).to have_content @forum.owner.to_s end it "parses markdown description into html" do @@ -26,14 +26,14 @@ describe "forums/show" do it 'has no posts' do render - rendered.should have_content "No posts yet." + expect(rendered).to have_content "No posts yet." end it 'shows posts' do @post = FactoryBot.create(:post, forum: @forum) render assert_select "table" - rendered.should have_content @post.subject - rendered.should have_content @post.author.to_s + expect(rendered).to have_content @post.subject + expect(rendered).to have_content @post.author.to_s end end From 4cf5daf3b8a5086ef71f001ed1425a9c17816077 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 23 Dec 2019 09:44:06 +1300 Subject: [PATCH 069/188] gardens charts controller using slug --- app/controllers/charts/gardens_controller.rb | 2 +- spec/controllers/charts/gardens_controller_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/charts/gardens_controller.rb b/app/controllers/charts/gardens_controller.rb index a7048c57f..5ca9a03b9 100644 --- a/app/controllers/charts/gardens_controller.rb +++ b/app/controllers/charts/gardens_controller.rb @@ -5,7 +5,7 @@ module Charts respond_to :json def timeline @data = [] - @garden = Garden.find(params[:garden_id]) + @garden = Garden.find(params[:garden_slug]) @garden.plantings.where.not(planted_at: nil) .order(finished_at: :desc).each do |p| # use finished_at if we have it, otherwise use predictions diff --git a/spec/controllers/charts/gardens_controller_spec.rb b/spec/controllers/charts/gardens_controller_spec.rb index 007e7f58c..b6a2bd1c5 100644 --- a/spec/controllers/charts/gardens_controller_spec.rb +++ b/spec/controllers/charts/gardens_controller_spec.rb @@ -9,7 +9,7 @@ describe Charts::GardensController do context "when not signed in" do describe 'GET timeline' do - before { get :timeline, params: { garden_id: garden.to_param } } + before { get :timeline, params: { garden_slug: garden.to_param } } it { expect(response).to be_successful } end @@ -21,7 +21,7 @@ describe Charts::GardensController do let!(:member) { FactoryBot.create(:member) } describe 'GET timeline' do - before { get :timeline, params: { garden_id: garden.to_param } } + before { get :timeline, params: { garden_slug: garden.to_param } } it { expect(response).to be_successful } end From b730378e1455dc184715387145e03600197cc387 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 23 Dec 2019 09:45:35 +1300 Subject: [PATCH 070/188] tidy up and fix specs for harvest controller --- app/controllers/harvests_controller.rb | 21 +++++++---- spec/controllers/harvests_controller_spec.rb | 38 +++++++++++--------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index b25752ac6..d48c7b228 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -10,14 +10,21 @@ class HarvestsController < ApplicationController responders :flash def index - @owner = Member.find_by(slug: params[:member_slug]) - @crop = Crop.find_by(slug: params[:crop_slug]) - @planting = Planting.find_by(slug: params[:planting_id]) - where = {} - where['owner_id'] = @owner.id if @owner.present? - where['crop_id'] = @crop.id if @crop.present? - where['planting_id'] = @planting.id if @planting.present? + if params[:member_slug] + @owner = Member.find_by(slug: params[:member_slug]) + where['owner_id'] = @owner.id + end + + if params[:crop_slug] + @crop = Crop.find_by(slug: params[:crop_slug]) + where['crop_id'] = @crop.id + end + + if params[:planting_slug] + @planting = Planting.find_by(slug: params[:planting_slug]) + where['planting_id'] = @planting.id + end @harvests = Harvest.search('*', where: where, diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index f4d8871f7..76bb56e69 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -7,10 +7,10 @@ describe HarvestsController do def valid_attributes { - owner_id: subject.current_member.id, - crop_id: FactoryBot.create(:crop).id, + owner_id: subject.current_member.id, + crop_id: FactoryBot.create(:crop).id, plant_part_id: FactoryBot.create(:plant_part).id, - harvested_at: '2017-01-01' + harvested_at: '2017-01-01' } end @@ -22,24 +22,30 @@ describe HarvestsController do let!(:harvest1) { FactoryBot.create(:harvest, owner_id: member1.id, crop_id: tomato.id) } let!(:harvest2) { FactoryBot.create(:harvest, owner_id: member2.id, crop_id: maize.id) } + before { Harvest.reindex } + describe "assigns all harvests as @harvests" do before { get :index, params: {} } - it { expect(assigns(:harvests)).to eq [harvest1, harvest2] } + it { expect(assigns(:harvests).size).to eq 2 } + it { expect(assigns(:harvests)[0]['slug']).to eq harvest1.slug } + it { expect(assigns(:harvests)[1]['slug']).to eq harvest2.slug } end describe "picks up owner from params and shows owner's harvests only" do before { get :index, params: { member_slug: member1.slug } } it { expect(assigns(:owner)).to eq member1 } - it { expect(assigns(:harvests)).to eq [harvest1] } + it { expect(assigns(:harvests).size).to eq 1 } + it { expect(assigns(:harvests)[0]['slug']).to eq harvest1.slug } end describe "picks up crop from params and shows the harvests for the crop only" do before { get :index, params: { crop_slug: maize.name } } it { expect(assigns(:crop)).to eq maize } - it { expect(assigns(:harvests)).to eq [harvest2] } + it { expect(assigns(:harvests).size).to eq 1 } + it { expect(assigns(:harvests)[0]['slug']).to eq harvest2.slug } end describe "generates a csv" do @@ -53,7 +59,7 @@ describe HarvestsController do let(:harvest) { Harvest.create! valid_attributes } describe "assigns the requested harvest as @harvest" do - before { get :show, params: { id: harvest.to_param } } + before { get :show, params: { slug: harvest.to_param } } it { expect(assigns(:harvest)).to eq(harvest) } end @@ -75,7 +81,7 @@ describe HarvestsController do let(:harvest) { Harvest.create! valid_attributes } describe "assigns the requested harvest as @harvest" do - before { get :edit, params: { id: harvest.to_param } } + before { get :edit, params: { slug: harvest.to_param } } it { expect(assigns(:harvest)).to eq(harvest) } end @@ -149,19 +155,19 @@ describe HarvestsController do it "updates the requested harvest" do new_crop = FactoryBot.create :crop expect do - put :update, params: { id: harvest.to_param, harvest: { crop_id: new_crop.id } } + put :update, params: { slug: harvest.to_param, harvest: { crop_id: new_crop.id } } harvest.reload end.to change(harvest, :crop_id).to(new_crop.id) end describe "assigns the requested harvest as @harvest" do - before { put :update, params: { id: harvest.to_param, harvest: valid_attributes } } + before { put :update, params: { slug: harvest.to_param, harvest: valid_attributes } } it { expect(assigns(:harvest)).to eq(harvest) } end describe "redirects to the harvest" do - before { put :update, params: { id: harvest.to_param, harvest: valid_attributes } } + before { put :update, params: { slug: harvest.to_param, harvest: valid_attributes } } it { expect(response).to redirect_to(harvest) } end @@ -172,13 +178,13 @@ describe HarvestsController do harvest = Harvest.create! valid_attributes # Trigger the behavior that occurs when invalid params are submitted Harvest.any_instance.stub(:save).and_return(false) - put :update, params: { id: harvest.to_param, harvest: { "crop_id" => "invalid value" } } + put :update, params: { slug: harvest.to_param, harvest: { "crop_id" => "invalid value" } } expect(assigns(:harvest)).to eq(harvest) end it "re-renders the 'edit' template" do harvest = Harvest.create! valid_attributes - put :update, params: { id: harvest.to_param, harvest: { "crop_id" => "invalid value" } } + put :update, params: { slug: harvest.to_param, harvest: { "crop_id" => "invalid value" } } expect(response).to render_template("edit") end end @@ -189,7 +195,7 @@ describe HarvestsController do describe "does not save planting_id" do before do - put :update, params: { id: harvest.to_param, + put :update, params: { slug: harvest.to_param, harvest: valid_attributes.merge(planting_id: not_my_planting.id) } end @@ -202,13 +208,13 @@ describe HarvestsController do it "destroys the requested harvest" do harvest = Harvest.create! valid_attributes expect do - delete :destroy, params: { id: harvest.to_param } + delete :destroy, params: { slug: harvest.to_param } end.to change(Harvest, :count).by(-1) end it "redirects to the harvests list" do harvest = Harvest.create! valid_attributes - delete :destroy, params: { id: harvest.to_param } + delete :destroy, params: { slug: harvest.to_param } expect(response).to redirect_to(harvests_url) end end From 75c7d63956d4814859dca35afc47e2c4df80f36a Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sun, 22 Dec 2019 20:46:08 +0000 Subject: [PATCH 071/188] [CodeFactor] Apply fixes to commit b730378 --- spec/controllers/harvests_controller_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index 76bb56e69..7e9c01ff9 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -7,10 +7,10 @@ describe HarvestsController do def valid_attributes { - owner_id: subject.current_member.id, - crop_id: FactoryBot.create(:crop).id, + owner_id: subject.current_member.id, + crop_id: FactoryBot.create(:crop).id, plant_part_id: FactoryBot.create(:plant_part).id, - harvested_at: '2017-01-01' + harvested_at: '2017-01-01' } end @@ -195,7 +195,7 @@ describe HarvestsController do describe "does not save planting_id" do before do - put :update, params: { slug: harvest.to_param, + put :update, params: { slug: harvest.to_param, harvest: valid_attributes.merge(planting_id: not_my_planting.id) } end From bbaa0436cb681eb29ee45848224442571deeab95 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 23 Dec 2019 09:46:11 +1300 Subject: [PATCH 072/188] ES query doesn't need to be public on the controller --- app/controllers/plantings_controller.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index f4fbd6e80..2236d8aaa 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -15,25 +15,25 @@ class PlantingsController < ApplicationController def index @show_all = params[:all] == '1' - @where = {} - @where['active'] = true unless @show_all + where = {} + where['active'] = true unless @show_all if params[:member_slug] @owner = Member.find_by(slug: params[:member_slug]) - @where['owner_id'] = @owner.id + where['owner_id'] = @owner.id end if params[:crop_slug] @crop = Crop.find_by(slug: params[:crop_slug]) - @where['crop_id'] = @crop.id + where['crop_id'] = @crop.id end @plantings = Planting.search( - where: @where, - page: params[:page], - limit: 30, + where: where, + page: params[:page], + limit: 30, boost_by: [:created_at], - load: false + load: false ) @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv" @@ -59,15 +59,15 @@ class PlantingsController < ApplicationController def new @planting = Planting.new( planted_at: Time.zone.today, - owner: current_member, - garden: current_member.gardens.first + owner: current_member, + garden: current_member.gardens.first ) @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new if params[:garden_id] @planting.garden = Garden.find_by( owner: current_member, - id: params[:garden_id] + id: params[:garden_id] ) end From 8fe5e4435b53d82ea4cfef202eab287d9d231ded Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sun, 22 Dec 2019 20:46:53 +0000 Subject: [PATCH 073/188] [CodeFactor] Apply fixes --- app/controllers/plantings_controller.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 2236d8aaa..6dafc06ce 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -29,11 +29,11 @@ class PlantingsController < ApplicationController end @plantings = Planting.search( - where: where, - page: params[:page], - limit: 30, + where: where, + page: params[:page], + limit: 30, boost_by: [:created_at], - load: false + load: false ) @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv" @@ -59,15 +59,15 @@ class PlantingsController < ApplicationController def new @planting = Planting.new( planted_at: Time.zone.today, - owner: current_member, - garden: current_member.gardens.first + owner: current_member, + garden: current_member.gardens.first ) @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new if params[:garden_id] @planting.garden = Garden.find_by( owner: current_member, - id: params[:garden_id] + id: params[:garden_id] ) end From 8f25ef5258315e7cf0af4723632c5087d42f2666 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 23 Dec 2019 15:07:24 +1300 Subject: [PATCH 074/188] index seeds in spec --- spec/views/home/_seeds.html.haml_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/views/home/_seeds.html.haml_spec.rb b/spec/views/home/_seeds.html.haml_spec.rb index 346a2952d..0a385e7ac 100644 --- a/spec/views/home/_seeds.html.haml_spec.rb +++ b/spec/views/home/_seeds.html.haml_spec.rb @@ -5,7 +5,10 @@ require 'rails_helper' describe 'home/_seeds.html.haml', type: "view" do let!(:seed) { FactoryBot.create(:tradable_seed, owner: owner) } let(:owner) { FactoryBot.create(:london_member) } - before { render } + before do + Seed.reindex + render + end it 'has a heading' do assert_select 'h2', 'Seeds available to trade' From f8abcd4d1cb6c2f13e2bc082a0c9067ab07a5656 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 23 Dec 2019 15:08:10 +1300 Subject: [PATCH 075/188] gardens controller spec using slug --- spec/controllers/gardens_controller_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb index c4b4de332..319304454 100644 --- a/spec/controllers/gardens_controller_spec.rb +++ b/spec/controllers/gardens_controller_spec.rb @@ -10,7 +10,7 @@ RSpec.describe GardensController, type: :controller do context "when not signed in" do describe 'GET new' do - before { get :new, params: { id: garden.to_param } } + before { get :new, params: { slug: garden.to_param } } it { expect(response).to redirect_to(new_member_session_path) } end @@ -32,19 +32,19 @@ RSpec.describe GardensController, type: :controller do end describe 'GET edit' do - before { get :edit, params: { id: garden.to_param } } + before { get :edit, params: { slug: garden.to_param } } it { expect(response).to redirect_to(new_member_session_path) } end describe 'POST update' do - before { post :update, params: { id: garden.to_param, garden: valid_params } } + before { post :update, params: { slug: garden.to_param, garden: valid_params } } it { expect(response).to redirect_to(new_member_session_path) } end describe 'DELETE' do - before { delete :destroy, params: { id: garden.to_param, params: { garden: valid_params } } } + before { delete :destroy, params: { slug: garden.to_param, params: { garden: valid_params } } } it { expect(response).to redirect_to(new_member_session_path) } end @@ -69,19 +69,19 @@ RSpec.describe GardensController, type: :controller do end describe 'GET edit' do - before { get :edit, params: { id: not_my_garden.to_param } } + before { get :edit, params: { slug: not_my_garden.to_param } } it { expect(response).to redirect_to(root_path) } end describe 'POST update' do - before { post :update, params: { id: not_my_garden.to_param, garden: valid_params } } + before { post :update, params: { slug: not_my_garden.to_param, garden: valid_params } } it { expect(response).to redirect_to(root_path) } end describe 'DELETE' do - before { delete :destroy, params: { id: not_my_garden.to_param, params: { garden: valid_params } } } + before { delete :destroy, params: { slug: not_my_garden.to_param, params: { garden: valid_params } } } it { expect(response).to redirect_to(root_path) } end From 1f17ea1e0368ded4b29d8b3eb1efee4e3b250f34 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 23 Dec 2019 16:52:56 +1300 Subject: [PATCH 076/188] fixes (most of) seed rss specs --- app/models/concerns/seed_search.rb | 2 +- app/views/seeds/index.rss.haml | 4 +--- spec/views/seeds/index.rss.haml_spec.rb | 2 ++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/concerns/seed_search.rb b/app/models/concerns/seed_search.rb index 753164064..97cb3773c 100644 --- a/app/models/concerns/seed_search.rb +++ b/app/models/concerns/seed_search.rb @@ -35,7 +35,7 @@ module SeedSearch tradable_to: tradable_to, tradeable: tradable?, finished: finished?, - location: location, + location: owner.location, created_at: created_at.to_i } end diff --git a/app/views/seeds/index.rss.haml b/app/views/seeds/index.rss.haml index 563ffae17..0c1f5f7a9 100644 --- a/app/views/seeds/index.rss.haml +++ b/app/views/seeds/index.rss.haml @@ -15,8 +15,6 @@

Organic? #{seed['organic']}

GMO? #{seed['gmo']}

Heirloom? #{seed['heirloom']}

- - if seed['tradable'] - %p - Will trade #{seed['tradable_to']} from #{@owner.location ? @owner.location : 'unknown location'} +

Will trade #{seed['tradable_to']} from #{seed['location'] ? seed['location'] : 'unknown location'}

%link= seed_url(slug: seed['slug']) %guid= seed_url(slug: seed['slug']) diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb index 8e074a80c..0f59b247b 100644 --- a/spec/views/seeds/index.rss.haml_spec.rb +++ b/spec/views/seeds/index.rss.haml_spec.rb @@ -12,6 +12,7 @@ describe 'seeds/index.rss.haml' do @seed = FactoryBot.create(:seed) @tradable = FactoryBot.create(:tradable_seed) assign(:seeds, [@seed, @tradable]) + Seed.reindex render end @@ -41,6 +42,7 @@ describe 'seeds/index.rss.haml' do @seed = FactoryBot.create(:seed) assign(:seeds, [@seed]) assign(:owner, @seed.owner) + Seed.reindex render end From d71d8aa603dde3a9d7b9e3ca67e9bef61bd6efce Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 09:24:43 +1300 Subject: [PATCH 077/188] seeds view spec refresehs the ES index --- spec/views/home/_seeds.html.haml_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/views/home/_seeds.html.haml_spec.rb b/spec/views/home/_seeds.html.haml_spec.rb index 0a385e7ac..02dd6e9ff 100644 --- a/spec/views/home/_seeds.html.haml_spec.rb +++ b/spec/views/home/_seeds.html.haml_spec.rb @@ -2,11 +2,11 @@ require 'rails_helper' -describe 'home/_seeds.html.haml', type: "view" do +describe 'home/_seeds.html.haml', type: "view", search: true do let!(:seed) { FactoryBot.create(:tradable_seed, owner: owner) } let(:owner) { FactoryBot.create(:london_member) } before do - Seed.reindex + Seed.searchkick_index.refresh render end From 6622aaf8860fd75d1c6ee5ce4b92075b81c6f5c4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 09:25:15 +1300 Subject: [PATCH 078/188] used expect syntax --- spec/requests/harvests_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/requests/harvests_spec.rb b/spec/requests/harvests_spec.rb index c613de081..839d588f7 100644 --- a/spec/requests/harvests_spec.rb +++ b/spec/requests/harvests_spec.rb @@ -5,9 +5,8 @@ require 'rails_helper' describe "Harvests" do describe "GET /harvests" do it "works! (now write some real specs)" do - # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get harvests_path - response.status.should be(200) + expect(response.status).to be 200 end end end From 99a2dfd46498705751ebd2c399c64eb841269e28 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 09:25:58 +1300 Subject: [PATCH 079/188] index all models in the spec helper --- spec/spec_helper.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9b30a0829..8c30a4826 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -39,6 +39,9 @@ RSpec.configure do |config| config.before(:suite) do # reindex models Crop.reindex + Seed.reindex + Harvest.reindex + Planting.reindex # and disable callbacks Searchkick.disable_callbacks From 44a59a30e1c05ef3fa04c29b72d5821bfb3b9f15 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 09:44:12 +1300 Subject: [PATCH 080/188] seeds#index rss format specs updated to use ES --- app/models/concerns/seed_search.rb | 3 ++- app/views/seeds/index.rss.haml | 1 + spec/views/seeds/index.rss.haml_spec.rb | 18 +++++++++--------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/models/concerns/seed_search.rb b/app/models/concerns/seed_search.rb index 97cb3773c..8c73293dd 100644 --- a/app/models/concerns/seed_search.rb +++ b/app/models/concerns/seed_search.rb @@ -8,6 +8,7 @@ module SeedSearch mappings: { properties: { created_at: { type: :integer }, + plant_before: { type: :text }, photos_count: { type: :integer }, tradable_to: { type: :text } } @@ -29,7 +30,7 @@ module SeedSearch owner_name: owner.login_name, parent_planting: parent_planting, photos_count: photos.size, - plant_before: plant_before, + plant_before: plant_before.to_s(:ymd), quantity: quantity, thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, tradable_to: tradable_to, diff --git a/app/views/seeds/index.rss.haml b/app/views/seeds/index.rss.haml index 0c1f5f7a9..c1c3e7f27 100644 --- a/app/views/seeds/index.rss.haml +++ b/app/views/seeds/index.rss.haml @@ -10,6 +10,7 @@ %pubdate= seed['created_at'].to_s(:rfc822) %description :escaped + SEED: #{seed}

Quantity: #{seed['quantity'] ? seed['quantity'] : 'unknown' }

Plant before: #{seed['plant_before'] ? seed['plant_before'] : 'unknown' }

Organic? #{seed['organic']}

diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb index 0f59b247b..66a87a35f 100644 --- a/spec/views/seeds/index.rss.haml_spec.rb +++ b/spec/views/seeds/index.rss.haml_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe 'seeds/index.rss.haml' do +describe 'seeds/index.rss.haml', search: true do before do controller.stub(:current_user) { nil } end @@ -11,29 +11,29 @@ describe 'seeds/index.rss.haml' do before do @seed = FactoryBot.create(:seed) @tradable = FactoryBot.create(:tradable_seed) - assign(:seeds, [@seed, @tradable]) - Seed.reindex + Seed.searchkick_index.refresh + assign(:seeds, Seed.search('*', load: false)) render end it 'shows RSS feed title' do - rendered.should have_content "Recent seeds from all members" + expect(rendered).to have_content "Recent seeds from all members" end it 'has a useful item title' do - rendered.should have_content "#{@seed.owner}'s #{@seed.crop} seeds" + expect(rendered).to have_content "#{@seed.owner.login_name}'s #{@seed.crop} seeds" end it 'shows the seed count' do - rendered.should have_content "Quantity: #{@seed.quantity}" + expect(rendered).to have_content "Quantity: #{@seed.quantity}" end it 'shows the plant_before date' do - rendered.should have_content "Plant before: #{@seed.plant_before}" + expect(rendered).to have_content "Plant before: #{@seed.plant_before.to_s(:ymd)}" end it 'mentions that one seed is tradable' do - rendered.should have_content "Will trade #{@tradable.tradable_to} from #{@tradable.owner.location}" + expect(rendered).to have_content "Will trade #{@tradable.tradable_to} from #{@tradable.owner.location}" end end @@ -47,7 +47,7 @@ describe 'seeds/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content "Recent seeds from #{@seed.owner}" + expect(rendered).to have_content "Recent seeds from #{@seed.owner}" end end end From 6f950e685b0af7898d996e7c88b33558e6441d4c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 10:45:02 +1300 Subject: [PATCH 081/188] hand loading back to cancancan --- app/controllers/gardens_controller.rb | 4 ++-- app/controllers/harvests_controller.rb | 8 ++------ app/controllers/plantings_controller.rb | 8 ++------ app/controllers/seeds_controller.rb | 6 +----- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index 568f9b69b..5fe86f43b 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -2,9 +2,9 @@ class GardensController < ApplicationController before_action :authenticate_member!, except: %i(index show) - before_action :set_garden, only: %i(edit show update destroy) after_action :expire_homepage, only: %i(create destroy) - load_and_authorize_resource + load_resource find_by: :slug + authorize_resource responders :flash respond_to :html, :json diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index d48c7b228..21b177dac 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -2,9 +2,9 @@ class HarvestsController < ApplicationController before_action :authenticate_member!, except: %i(index show) - before_action :set_harvest, only: %i(edit show update destroy) after_action :update_crop_medians, only: %i(create update destroy) - load_and_authorize_resource + load_resource find_by: :slug + authorize_resource respond_to :html, :json respond_to :csv, :rss, only: :index responders :flash @@ -79,10 +79,6 @@ class HarvestsController < ApplicationController private - def set_harvest - @harvest = Harvest.find(params[:slug]) - end - def harvest_params params.require(:harvest) .permit(:planting_id, :crop_id, :harvested_at, :description, diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 6dafc06ce..9d002bcd9 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -2,11 +2,11 @@ class PlantingsController < ApplicationController before_action :authenticate_member!, except: %i(index show) - before_action :set_planting, only: %i(edit show update destroy) after_action :expire_homepage, only: %i(create update destroy) after_action :update_crop_medians, only: %i(create update destroy) after_action :update_planting_medians, only: :update - load_and_authorize_resource + load_resource find_by: :slug + authorize_resource respond_to :html, :json respond_to :csv, :rss, only: [:index] @@ -101,10 +101,6 @@ class PlantingsController < ApplicationController private - def set_planting - @planting = Planting.find(params[:slug]) - end - def update_crop_medians @planting.crop.update_lifespan_medians if @planting.crop.present? end diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index f53d8c07d..78a9038d0 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -2,7 +2,7 @@ class SeedsController < ApplicationController before_action :authenticate_member!, except: %i(index show) - before_action :set_seed, only: %i(edit show update destroy) + load_resource find_by: :slug authorize_resource responders :flash respond_to :html, :json @@ -84,10 +84,6 @@ class SeedsController < ApplicationController private - def set_seed - @seed = Seed.find(params[:slug]) - end - def seed_params params.require(:seed).permit( :crop_id, :description, :quantity, :plant_before, From de8421471920626e61fe602c2cd639666dc9930c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 10:45:18 +1300 Subject: [PATCH 082/188] fixed trailing whitesapce --- app/views/plantings/_facts.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/plantings/_facts.haml b/app/views/plantings/_facts.haml index b0f2a440b..428c9f6d8 100644 --- a/app/views/plantings/_facts.haml +++ b/app/views/plantings/_facts.haml @@ -16,14 +16,14 @@ unknown - if planting.planted_at.present? %span.planted_at - =planting.planted_at.year + = planting.planted_at.year - if planting.finish_is_predicatable? .card.fact-card %h3 Progress %strong #{planting.age_in_days}/#{planting.expected_lifespan} %span days - + .card.fact-card{class: planting.quantity.present? ? '' : 'text-muted'} %h3 Quantity From 4a2bb2342c373f4c12954eba467c29b778400df3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 11:38:30 +1300 Subject: [PATCH 083/188] Sorting out cancancan, copied to common parent controller --- app/controllers/application_controller.rb | 3 +-- app/controllers/data_controller.rb | 13 +++++++++++++ app/controllers/gardens_controller.rb | 9 +-------- app/controllers/harvests_controller.rb | 8 +------- app/controllers/plantings_controller.rb | 10 +--------- app/controllers/seeds_controller.rb | 10 +--------- config/routes.rb | 6 +++--- spec/controllers/plantings_controller_spec.rb | 17 ++++++++++++++++- 8 files changed, 37 insertions(+), 39 deletions(-) create mode 100644 app/controllers/data_controller.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7e01327d6..219ba4fc2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -7,9 +7,8 @@ class ApplicationController < ActionController::Base after_action :store_location before_action :set_locale - rescue_from ActiveRecord::RecordNotFound, with: :not_found - # CanCan error handling + def store_location unless request.path.in?(["/members/sign_in", "/members/sign_up", diff --git a/app/controllers/data_controller.rb b/app/controllers/data_controller.rb new file mode 100644 index 000000000..fece1f68c --- /dev/null +++ b/app/controllers/data_controller.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class DataController < ApplicationController + abstract + before_action :authenticate_member!, except: %i(index show) + load_and_authorize_resource id_param: :slug + + after_action :expire_homepage, only: %i(create update destroy) + + respond_to :html, :json + respond_to :csv, :rss, only: [:index] + responders :flash +end diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index 5fe86f43b..0af8d3ea3 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -1,13 +1,6 @@ # frozen_string_literal: true -class GardensController < ApplicationController - before_action :authenticate_member!, except: %i(index show) - after_action :expire_homepage, only: %i(create destroy) - load_resource find_by: :slug - authorize_resource - responders :flash - respond_to :html, :json - +class GardensController < DataController def index @owner = Member.find_by(slug: params[:member_slug]) @show_all = params[:all] == '1' diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index 21b177dac..c618b9742 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -1,13 +1,7 @@ # frozen_string_literal: true -class HarvestsController < ApplicationController - before_action :authenticate_member!, except: %i(index show) +class HarvestsController < DataController after_action :update_crop_medians, only: %i(create update destroy) - load_resource find_by: :slug - authorize_resource - respond_to :html, :json - respond_to :csv, :rss, only: :index - responders :flash def index where = {} diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 9d002bcd9..7b6c92734 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -1,16 +1,8 @@ # frozen_string_literal: true -class PlantingsController < ApplicationController - before_action :authenticate_member!, except: %i(index show) - after_action :expire_homepage, only: %i(create update destroy) +class PlantingsController < DataController after_action :update_crop_medians, only: %i(create update destroy) after_action :update_planting_medians, only: :update - load_resource find_by: :slug - authorize_resource - - respond_to :html, :json - respond_to :csv, :rss, only: [:index] - responders :flash def index @show_all = params[:all] == '1' diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index 78a9038d0..eb7f94beb 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -1,14 +1,6 @@ # frozen_string_literal: true -class SeedsController < ApplicationController - before_action :authenticate_member!, except: %i(index show) - load_resource find_by: :slug - authorize_resource - responders :flash - respond_to :html, :json - respond_to :csv, only: :index - respond_to :rss, only: :index - +class SeedsController < DataController def index where = {} diff --git a/config/routes.rb b/config/routes.rb index 0be2fc781..ce6843072 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -33,15 +33,15 @@ Rails.application.routes.draw do end resources :plantings, concerns: :has_photos, param: :slug do - resources :harvests - resources :seeds + get 'harvests' => 'harvests#index' + get 'seeds' => 'seeds#index' collection do get 'crop/:crop' => 'plantings#index', as: 'plantings_by_crop' end end resources :seeds, concerns: :has_photos, param: :slug do - resources :plantings + get 'plantings' => 'plantings#index' get 'crop/:crop' => 'seeds#index', as: 'seeds_by_crop', on: :collection end diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index 033f628e1..0ba923597 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -8,7 +8,7 @@ describe PlantingsController do def valid_attributes { garden_id: FactoryBot.create(:garden, owner: subject.current_member).id, - crop_id: FactoryBot.create(:crop).id + crop_id: FactoryBot.create(:crop).id } end @@ -122,4 +122,19 @@ describe PlantingsController do it { expect(assigns(:planting).owner).to eq subject.current_member } end end + + describe 'GET :edit' do + let(:my_planting) { FactoryBot.create :planting, owner: member } + let(:not_my_planting) { FactoryBot.create :planting } + context 'my planting' do + before { get :edit, params: { slug: my_planting } } + it { expect(assigns(:planting)).to eq my_planting } + end + + context 'not my planting' do + before { get :edit, params: { slug: not_my_planting } } + + it { expect(response).to redirect_to(root_path) } + end + end end From df97d5194069e559706b1b694537a86200ed2581 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Mon, 23 Dec 2019 22:39:08 +0000 Subject: [PATCH 084/188] [CodeFactor] Apply fixes --- app/controllers/application_controller.rb | 2 +- spec/controllers/plantings_controller_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 219ba4fc2..58c3ec353 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base after_action :store_location before_action :set_locale rescue_from ActiveRecord::RecordNotFound, with: :not_found - + def store_location unless request.path.in?(["/members/sign_in", "/members/sign_up", diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index 0ba923597..0025fb163 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -8,7 +8,7 @@ describe PlantingsController do def valid_attributes { garden_id: FactoryBot.create(:garden, owner: subject.current_member).id, - crop_id: FactoryBot.create(:crop).id + crop_id: FactoryBot.create(:crop).id } end From fafe611315c7ebf5e8ef14b9078f8c5a274d5472 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 11:54:16 +1300 Subject: [PATCH 085/188] reinstate planting harvest and planting seeds --- config/routes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index ce6843072..5244ed3bc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -33,8 +33,8 @@ Rails.application.routes.draw do end resources :plantings, concerns: :has_photos, param: :slug do - get 'harvests' => 'harvests#index' - get 'seeds' => 'seeds#index' + resources :harvests + resources :seeds collection do get 'crop/:crop' => 'plantings#index', as: 'plantings_by_crop' end From 68b22d71d0ac5a6e7a005d19e8917b779a399f43 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 12:25:16 +1300 Subject: [PATCH 086/188] fixed indexing of seeds when they have no plant_before --- app/models/concerns/seed_search.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/seed_search.rb b/app/models/concerns/seed_search.rb index 8c73293dd..46805e180 100644 --- a/app/models/concerns/seed_search.rb +++ b/app/models/concerns/seed_search.rb @@ -30,7 +30,7 @@ module SeedSearch owner_name: owner.login_name, parent_planting: parent_planting, photos_count: photos.size, - plant_before: plant_before.to_s(:ymd), + plant_before: plant_before&.to_s(:ymd), quantity: quantity, thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, tradable_to: tradable_to, From e6d9a3c1cfa242b2ffda4073e71355e72ac25d49 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 13:36:15 +1300 Subject: [PATCH 087/188] reindex into ES on homepage --- spec/features/home/home_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb index 901aa5b60..fa6bddaeb 100644 --- a/spec/features/home/home_spec.rb +++ b/spec/features/home/home_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe "home page" do +describe "home page", :search do subject { page } let(:member) { FactoryBot.create :member } @@ -23,10 +23,10 @@ describe "home page" do planting.photos << photo seed.photos << photo harvest.photos << photo - Crop.reindex - Planting.reindex - Seed.reindex - Harvest.reindex + Crop.searchkick_index.refresh + Planting.searchkick_index.refresh + Seed.searchkick_index.refresh + Harvest.searchkick_index.refresh end before { visit root_path } From 56c3fdd4fe964a7023d269ae035e7a566f7a280b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 20:23:27 +1300 Subject: [PATCH 088/188] index records before vie spec --- spec/views/seeds/index.rss.haml_spec.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb index 66a87a35f..0090fc2e9 100644 --- a/spec/views/seeds/index.rss.haml_spec.rb +++ b/spec/views/seeds/index.rss.haml_spec.rb @@ -2,17 +2,17 @@ require 'rails_helper' -describe 'seeds/index.rss.haml', search: true do +describe 'seeds/index.rss.haml', :search do before do controller.stub(:current_user) { nil } end context 'all seeds' do + let(:seed) { FactoryBot.create(:seed) } before do - @seed = FactoryBot.create(:seed) @tradable = FactoryBot.create(:tradable_seed) Seed.searchkick_index.refresh - assign(:seeds, Seed.search('*', load: false)) + assign(:seeds, Seed.homepage_records(10)) render end @@ -21,15 +21,15 @@ describe 'seeds/index.rss.haml', search: true do end it 'has a useful item title' do - expect(rendered).to have_content "#{@seed.owner.login_name}'s #{@seed.crop} seeds" + expect(rendered).to have_content "#{seed.owner.login_name}'s #{seed.crop} seeds" end it 'shows the seed count' do - expect(rendered).to have_content "Quantity: #{@seed.quantity}" + expect(rendered).to have_content "Quantity: #{seed.quantity}" end it 'shows the plant_before date' do - expect(rendered).to have_content "Plant before: #{@seed.plant_before.to_s(:ymd)}" + expect(rendered).to have_content "Plant before: #{seed.plant_before.to_s(:ymd)}" end it 'mentions that one seed is tradable' do @@ -39,15 +39,15 @@ describe 'seeds/index.rss.haml', search: true do context "one member's seeds" do before do - @seed = FactoryBot.create(:seed) - assign(:seeds, [@seed]) - assign(:owner, @seed.owner) + seed = FactoryBot.create(:seed) + assign(:seeds, [seed]) + assign(:owner, seed.owner) Seed.reindex render end it 'shows RSS feed title' do - expect(rendered).to have_content "Recent seeds from #{@seed.owner}" + expect(rendered).to have_content "Recent seeds from #{seed.owner}" end end end From b25a13df898604b71b5717cbbf9b5b28f2967d07 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 21:53:00 +1300 Subject: [PATCH 089/188] fix rss feeds --- app/models/concerns/harvest_search.rb | 15 +++--- app/views/harvests/index.rss.haml | 16 +++--- spec/views/harvests/index.rss.haml_spec.rb | 57 ++++++++++----------- spec/views/plantings/index.rss.haml_spec.rb | 17 +++--- spec/views/seeds/index.rss.haml_spec.rb | 2 +- 5 files changed, 52 insertions(+), 55 deletions(-) diff --git a/app/models/concerns/harvest_search.rb b/app/models/concerns/harvest_search.rb index 936a7d00d..da74bda41 100644 --- a/app/models/concerns/harvest_search.rb +++ b/app/models/concerns/harvest_search.rb @@ -9,7 +9,8 @@ module HarvestSearch properties: { created_at: { type: :integer }, harvests_count: { type: :integer }, - photos_count: { type: :integer } + photos_count: { type: :integer }, + harvested_at: { type: :date } } } @@ -18,16 +19,18 @@ module HarvestSearch def search_data { slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, crop_id: crop_id, - plant_part: plant_part&.name, + crop_name: crop.name, + crop_slug: crop.slug, + has_photos: photos.size.positive?, owner_id: owner_id, owner_name: owner.login_name, - planting_id: planting_id, photos_count: photos.size, - has_photos: photos.size.positive?, + plant_part: plant_part&.name, + planting_id: planting_id, + quantity: quantity, thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, + harvested_at: harvested_at, created_at: created_at.to_i } end diff --git a/app/views/harvests/index.rss.haml b/app/views/harvests/index.rss.haml index f5682edf1..7967b23e5 100644 --- a/app/views/harvests/index.rss.haml +++ b/app/views/harvests/index.rss.haml @@ -6,14 +6,12 @@ %link= harvests_url - @harvests.each do |harvest| %item - %title #{harvest.owner.login_name}'s #{harvest.crop.name} - %pubdate= harvest.harvested_at.to_s(:rfc822) + %title #{harvest['owner_name']}'s #{harvest['crop_name']} + %pubdate= harvest['harvested_at'] %description :escaped -

Crop: #{harvest.crop ? harvest.crop : 'unknown' }

-

Quantity: #{harvest.quantity ? harvest.quantity : 'unknown' }

-

Harvested on: #{harvest.harvested_at ? harvest.harvested_at : 'unknown' }

- :escaped_markdown - #{ strip_tags harvest.description } - %link= harvest_url(harvest) - %guid= harvest_url(harvest) +

Crop: #{harvest['crop_name']}

+

Quantity: #{harvest['quantity'] ? harvest['quantity'] : 'unknown' }

+

Harvested on: #{harvest['harvested_at'] ? harvest['harvested_at'] : 'unknown' }

+ %link= harvest_url(slug: harvest['slug']) + %guid= harvest_url(slug: harvest['slug']) diff --git a/spec/views/harvests/index.rss.haml_spec.rb b/spec/views/harvests/index.rss.haml_spec.rb index 47d28a9d6..e4384c474 100644 --- a/spec/views/harvests/index.rss.haml_spec.rb +++ b/spec/views/harvests/index.rss.haml_spec.rb @@ -2,43 +2,38 @@ require 'rails_helper' -describe 'harvests/index.rss.haml' do +describe 'harvests/index.rss.haml', :search do before do controller.stub(:current_user) { nil } @member = FactoryBot.create(:member) @tomato = FactoryBot.create(:tomato) - @maize = FactoryBot.create(:maize) - @pp = FactoryBot.create(:plant_part) - page = 1 - per_page = 2 - total_entries = 2 - harvests = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| - pager.replace([ - FactoryBot.create(:harvest, - crop: @tomato, - owner: @member), - FactoryBot.create(:harvest, - crop: @maize, - plant_part: @pp, - owner: @member, - quantity: 2) - ]) + + @harvest1 = FactoryBot.create :harvest, crop: @tomato + @harvest2 = FactoryBot.create :harvest, crop: @tomato + @harvest3 = FactoryBot.create :harvest, crop: @tomato + + Harvest.searchkick_index.refresh + assign(:harvests, Harvest.search(load: false)) + end + + context 'all harvests' do + before { render } + it 'shows RSS feed title' do + expect(rendered).to have_content "Recent harvests from all members" + end + + it 'shows formatted content of harvest posts' do + expect(rendered).to have_content "

Quantity: " end - assign(:harvests, harvests) - render end - it 'shows RSS feed title' do - rendered.should have_content "Recent harvests from all members" - end - - it "displays crop's name in title" do - assign(:crop, @tomato) - render - expect(rendered).to have_content @tomato.name - end - - it 'shows formatted content of harvest posts' do - expect(rendered).to have_content "

Quantity: " + context 'for one crop' do + before do + assign(:crop, @tomato) + render + end + it "displays crop's name in title" do + expect(rendered).to have_content @tomato.name + end end end diff --git a/spec/views/plantings/index.rss.haml_spec.rb b/spec/views/plantings/index.rss.haml_spec.rb index b0f3be6cc..6361aaf4b 100644 --- a/spec/views/plantings/index.rss.haml_spec.rb +++ b/spec/views/plantings/index.rss.haml_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe 'plantings/index.rss.haml' do +describe 'plantings/index.rss.haml', :search do before do controller.stub(:current_user) { nil } end @@ -12,28 +12,29 @@ describe 'plantings/index.rss.haml' do @planting = FactoryBot.create(:planting) @sunny = FactoryBot.create(:sunny_planting) @seedling = FactoryBot.create(:seedling_planting) - assign(:plantings, [@planting, @sunny, @seedling]) + Planting.searchkick_index.refresh + assign(:plantings, Planting.search(load: false)) render end it 'shows RSS feed title' do - rendered.should have_content "Recent plantings from all members" + expect(rendered).to have_content "Recent plantings from all members" end it 'item title shows owner and location' do - rendered.should have_content "#{@planting.crop} in #{@planting.location}" + expect(rendered).to have_content "#{@planting.crop} in #{@planting.location}" end it 'shows formatted content of posts' do - rendered.should have_content "This is a really good plant." + expect(rendered).to have_content "This is a really good plant." end it 'shows sunniness' do - rendered.should have_content 'Sunniness: sun' + expect(rendered).to have_content 'Sunniness: sun' end it 'shows propagation method' do - rendered.should have_content 'Planted from: seedling' + expect(rendered).to have_content 'Planted from: seedling' end end @@ -46,7 +47,7 @@ describe 'plantings/index.rss.haml' do end it 'shows title for single member' do - rendered.should have_content "Recent plantings from #{@planting.owner}" + expect(rendered).to have_content "Recent plantings from #{@planting.owner}" end end end diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb index 0090fc2e9..a581282a0 100644 --- a/spec/views/seeds/index.rss.haml_spec.rb +++ b/spec/views/seeds/index.rss.haml_spec.rb @@ -12,7 +12,7 @@ describe 'seeds/index.rss.haml', :search do before do @tradable = FactoryBot.create(:tradable_seed) Seed.searchkick_index.refresh - assign(:seeds, Seed.homepage_records(10)) + assign(:seeds, Seed.search(load: false))) render end From c708d4d22b639e235f790d4192580171e459019c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 22:01:55 +1300 Subject: [PATCH 090/188] Mark spec as needing elastic search --- spec/features/plantings/planting_a_crop_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 7ae4c72ad..a4cbe5ed1 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" require 'custom_matchers' -describe "Planting a crop", :js do +describe "Planting a crop", :js, :search do let!(:maize) { FactoryBot.create :maize } let(:garden) { FactoryBot.create :garden, owner: member, name: 'Orchard' } let!(:planting) do From ee4aa4dec34a42814f76f947fc8bb0d79ee3eaf8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 22:10:49 +1300 Subject: [PATCH 091/188] refresh in dex at start of spec run --- spec/spec_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8c30a4826..d84389efc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -38,10 +38,10 @@ RSpec.configure do |config| config.before(:suite) do # reindex models - Crop.reindex - Seed.reindex - Harvest.reindex - Planting.reindex + Crop.searchkick_index.refresh + Seed.searchkick_index.refresh + Harvest.searchkick_index.refresh + Planting.searchkick_index.refresh # and disable callbacks Searchkick.disable_callbacks From f3ffd6c0866f72581ef614fcab05ed431d871ee3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 22:11:14 +1300 Subject: [PATCH 092/188] remove extra index runs, use search:true from spec helper --- spec/features/harvests/browse_harvests_spec.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/spec/features/harvests/browse_harvests_spec.rb b/spec/features/harvests/browse_harvests_spec.rb index 55827bcb1..a44672629 100644 --- a/spec/features/harvests/browse_harvests_spec.rb +++ b/spec/features/harvests/browse_harvests_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe "browse harvests" do +describe "browse harvests", :search do subject { page } let!(:harvest) { create :harvest, owner: member } @@ -13,10 +13,7 @@ describe "browse harvests" do describe 'blank optional fields' do let!(:harvest) { create :harvest, :no_description } - before do - Harvest.reindex - visit harvests_path - end + before { visit harvests_path } it 'read more' do expect(subject).not_to have_link "Read more" @@ -26,10 +23,7 @@ describe "browse harvests" do describe "filled in optional fields" do let!(:harvest) { create :harvest, :long_description } - before do - Harvest.reindex - visit harvests_path - end + before { visit harvests_path } it 'links to #show' do expect(subject).to have_link harvest.crop.name, href: harvest_path(harvest) From b8c94c13cca8b41805372c0c08054e34822902f6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 22:15:01 +1300 Subject: [PATCH 093/188] refactor to use search:true instead of reindex --- spec/controllers/plantings_controller_spec.rb | 4 ++-- spec/features/crops/browse_crops_spec.rb | 7 ++----- spec/features/harvests/harvesting_a_crop_spec.rb | 2 +- spec/features/seeds/adding_seeds_spec.rb | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index 0025fb163..2a3b4daa0 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -12,14 +12,14 @@ describe PlantingsController do } end - describe "GET index" do + describe "GET index", :search do let!(:member1) { FactoryBot.create(:member) } let!(:member2) { FactoryBot.create(:member) } let!(:tomato) { FactoryBot.create(:tomato) } let!(:maize) { FactoryBot.create(:maize) } let!(:planting1) { FactoryBot.create :planting, crop: tomato, owner: member1, created_at: 1.day.ago } let!(:planting2) { FactoryBot.create :planting, crop: maize, owner: member2, created_at: 5.days.ago } - before { Planting.reindex } + describe "assigns all plantings as @plantings" do before { get :index } diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb index 73aa40574..07a0f5a4a 100644 --- a/spec/features/crops/browse_crops_spec.rb +++ b/spec/features/crops/browse_crops_spec.rb @@ -2,17 +2,14 @@ require 'rails_helper' -describe "browse crops" do +describe "browse crops", :search do let!(:tomato) { FactoryBot.create :tomato } let!(:maize) { FactoryBot.create :maize } let!(:pending_crop) { FactoryBot.create :crop_request } let!(:rejected_crop) { FactoryBot.create :rejected_crop } shared_examples 'shows crops' do - before do - Crop.reindex - visit crops_path - end + before { visit crops_path } it "has a form for sorting by" do expect(page).to have_css "select#sort" diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 0099c11f6..9d4daa5c5 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' require 'custom_matchers' -describe "Harvesting a crop", :js do +describe "Harvesting a crop", :js, :search do context 'signed in' do include_context 'signed in member' let!(:maize) { create :maize } diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb index 622dad584..1b7b3fcca 100644 --- a/spec/features/seeds/adding_seeds_spec.rb +++ b/spec/features/seeds/adding_seeds_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' require 'custom_matchers' -describe "Seeds", :js do +describe "Seeds", :js, :search do context 'signed in' do include_context 'signed in member' let!(:maize) { create :maize } From 2c5d5e09830534cc5ac87ae8e44fc8355d046c04 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 24 Dec 2019 22:18:14 +1300 Subject: [PATCH 094/188] fix ruby syntax in spec --- spec/views/seeds/index.rss.haml_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb index a581282a0..550b84aa6 100644 --- a/spec/views/seeds/index.rss.haml_spec.rb +++ b/spec/views/seeds/index.rss.haml_spec.rb @@ -12,7 +12,7 @@ describe 'seeds/index.rss.haml', :search do before do @tradable = FactoryBot.create(:tradable_seed) Seed.searchkick_index.refresh - assign(:seeds, Seed.search(load: false))) + assign(:seeds, Seed.search(load: false)) render end From 5962081c9e1b07d9492df9635ccfd09e21be7f32 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 25 Dec 2019 11:42:29 +1300 Subject: [PATCH 095/188] fix specs fpr seeds rss feed --- app/views/seeds/index.rss.haml | 5 +-- spec/views/seeds/index.rss.haml_spec.rb | 48 +++++++++++++++---------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/app/views/seeds/index.rss.haml b/app/views/seeds/index.rss.haml index c1c3e7f27..0d128c2fc 100644 --- a/app/views/seeds/index.rss.haml +++ b/app/views/seeds/index.rss.haml @@ -10,12 +10,13 @@ %pubdate= seed['created_at'].to_s(:rfc822) %description :escaped - SEED: #{seed}

Quantity: #{seed['quantity'] ? seed['quantity'] : 'unknown' }

Plant before: #{seed['plant_before'] ? seed['plant_before'] : 'unknown' }

Organic? #{seed['organic']}

GMO? #{seed['gmo']}

Heirloom? #{seed['heirloom']}

-

Will trade #{seed['tradable_to']} from #{seed['location'] ? seed['location'] : 'unknown location'}

+ - if seed['tradeable'] + :escaped +

Will trade #{seed['tradable_to']} from #{seed['location'] ? seed['location'] : 'unknown location'}

%link= seed_url(slug: seed['slug']) %guid= seed_url(slug: seed['slug']) diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb index 550b84aa6..4169880b2 100644 --- a/spec/views/seeds/index.rss.haml_spec.rb +++ b/spec/views/seeds/index.rss.haml_spec.rb @@ -7,21 +7,9 @@ describe 'seeds/index.rss.haml', :search do controller.stub(:current_user) { nil } end - context 'all seeds' do - let(:seed) { FactoryBot.create(:seed) } - before do - @tradable = FactoryBot.create(:tradable_seed) - Seed.searchkick_index.refresh - assign(:seeds, Seed.search(load: false)) - render - end - - it 'shows RSS feed title' do - expect(rendered).to have_content "Recent seeds from all members" - end - + shared_examples 'displays seed in rss feed' do it 'has a useful item title' do - expect(rendered).to have_content "#{seed.owner.login_name}'s #{seed.crop} seeds" + expect(rendered).to have_content "#{seed.owner.login_name}'s #{seed.crop.name} seeds" end it 'shows the seed count' do @@ -31,23 +19,47 @@ describe 'seeds/index.rss.haml', :search do it 'shows the plant_before date' do expect(rendered).to have_content "Plant before: #{seed.plant_before.to_s(:ymd)}" end + end + + context 'all seeds' do + let!(:seed) { FactoryBot.create(:seed) } + let!(:tradable) { FactoryBot.create(:tradable_seed) } + before do + Seed.searchkick_index.refresh + assign(:seeds, Seed.search(load: false)) + render + end + + include_examples 'displays seed in rss feed' + + it 'shows RSS feed title' do + expect(rendered).to have_content "Recent seeds from all members" + end + it 'mentions that one seed is tradable' do - expect(rendered).to have_content "Will trade #{@tradable.tradable_to} from #{@tradable.owner.location}" + expect(rendered).to have_content "Will trade #{tradable.tradable_to} from #{tradable.owner.location}" + end + + it "does not offer untradable seed as tradeable" do + expect(rendered).not_to have_content "Will trade #{seed.tradable_to} from #{seed.owner.location}" end end context "one member's seeds" do + let!(:seed) { FactoryBot.create(:seed) } + before do - seed = FactoryBot.create(:seed) - assign(:seeds, [seed]) assign(:owner, seed.owner) - Seed.reindex + Seed.searchkick_index.refresh + assign(:seeds, Seed.search(load: false)) render end it 'shows RSS feed title' do expect(rendered).to have_content "Recent seeds from #{seed.owner}" end + + include_examples 'displays seed in rss feed' end end From 99d436a91f65d27fdc83c09aef0f42e0dc1e3ac9 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Tue, 24 Dec 2019 22:45:59 +0000 Subject: [PATCH 096/188] [CodeFactor] Apply fixes to commit 5962081 --- spec/views/seeds/index.rss.haml_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb index 4169880b2..7940824fe 100644 --- a/spec/views/seeds/index.rss.haml_spec.rb +++ b/spec/views/seeds/index.rss.haml_spec.rb @@ -36,7 +36,6 @@ describe 'seeds/index.rss.haml', :search do expect(rendered).to have_content "Recent seeds from all members" end - it 'mentions that one seed is tradable' do expect(rendered).to have_content "Will trade #{tradable.tradable_to} from #{tradable.owner.location}" end @@ -59,7 +58,7 @@ describe 'seeds/index.rss.haml', :search do it 'shows RSS feed title' do expect(rendered).to have_content "Recent seeds from #{seed.owner}" end - + include_examples 'displays seed in rss feed' end end From 39d208dec16772a2bb59301241453c4c63b61ca8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 25 Dec 2019 14:26:50 +1300 Subject: [PATCH 097/188] Rename the search concens --- app/models/concerns/photo_search.rb | 21 ------------- .../{crop_search.rb => search_crops.rb} | 2 +- .../{harvest_search.rb => search_harvests.rb} | 2 +- app/models/concerns/search_photos.rb | 30 +++++++++++++++++++ ...planting_search.rb => search_plantings.rb} | 2 +- .../{seed_search.rb => search_seeds.rb} | 2 +- app/models/crop.rb | 2 +- app/models/harvest.rb | 2 +- app/models/photo.rb | 4 ++- app/models/planting.rb | 2 +- app/models/seed.rb | 2 +- 11 files changed, 41 insertions(+), 30 deletions(-) delete mode 100644 app/models/concerns/photo_search.rb rename app/models/concerns/{crop_search.rb => search_crops.rb} (98%) rename app/models/concerns/{harvest_search.rb => search_harvests.rb} (98%) create mode 100644 app/models/concerns/search_photos.rb rename app/models/concerns/{planting_search.rb => search_plantings.rb} (98%) rename app/models/concerns/{seed_search.rb => search_seeds.rb} (98%) diff --git a/app/models/concerns/photo_search.rb b/app/models/concerns/photo_search.rb deleted file mode 100644 index 0c241f864..000000000 --- a/app/models/concerns/photo_search.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -module PhotoSearch - extend ActiveSupport::Concern - - included do - searchkick - - scope :search_import, -> { includes(:owner, :crop, :plantings, :harvests, :seeds, P: posts) } - - def search_data - { - crops: crops.map(&:id), - owner_id: owner_id, - owner_name: owner.login_name, - thumbnail_url: thumbnail_url, - created_at: created_at.to_i - } - end - end -end diff --git a/app/models/concerns/crop_search.rb b/app/models/concerns/search_crops.rb similarity index 98% rename from app/models/concerns/crop_search.rb rename to app/models/concerns/search_crops.rb index 6cb2d7b5e..aaec73136 100644 --- a/app/models/concerns/crop_search.rb +++ b/app/models/concerns/search_crops.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module CropSearch +module SearchCrops extend ActiveSupport::Concern included do diff --git a/app/models/concerns/harvest_search.rb b/app/models/concerns/search_harvests.rb similarity index 98% rename from app/models/concerns/harvest_search.rb rename to app/models/concerns/search_harvests.rb index da74bda41..2f69fd9f1 100644 --- a/app/models/concerns/harvest_search.rb +++ b/app/models/concerns/search_harvests.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module HarvestSearch +module SearchHarvests extend ActiveSupport::Concern included do diff --git a/app/models/concerns/search_photos.rb b/app/models/concerns/search_photos.rb new file mode 100644 index 000000000..10c98adf0 --- /dev/null +++ b/app/models/concerns/search_photos.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module SearchPhotos + extend ActiveSupport::Concern + + included do + searchkick merge_mappings: true, + mappings: { + properties: { + title: { type: :text }, + created_at: { type: :integer }, + } + } + + + # scope :search_import, -> { includes(:owner, :crops, :plantings, :harvests, :seeds, :posts) } + + def search_data + { + title: title, + crops: crops.map(&:id), + owner_id: owner_id, + owner_login_name: owner.login_name, + thumbnail_url: thumbnail_url, + fullsize_url: fullsize_url, + created_at: created_at.to_i + } + end + end +end diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/search_plantings.rb similarity index 98% rename from app/models/concerns/planting_search.rb rename to app/models/concerns/search_plantings.rb index 38f37261e..e96bcd4e5 100644 --- a/app/models/concerns/planting_search.rb +++ b/app/models/concerns/search_plantings.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module PlantingSearch +module SearchPlantings extend ActiveSupport::Concern included do diff --git a/app/models/concerns/seed_search.rb b/app/models/concerns/search_seeds.rb similarity index 98% rename from app/models/concerns/seed_search.rb rename to app/models/concerns/search_seeds.rb index 46805e180..2223efcb0 100644 --- a/app/models/concerns/seed_search.rb +++ b/app/models/concerns/search_seeds.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module SeedSearch +module SearchSeeds extend ActiveSupport::Concern included do diff --git a/app/models/crop.rb b/app/models/crop.rb index 703576e5d..d983dff58 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -4,7 +4,7 @@ class Crop < ApplicationRecord extend FriendlyId include PhotoCapable include OpenFarmData - include CropSearch + include SearchCrops friendly_id :name, use: %i(slugged finders) diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 3c9f490bf..17c2122c7 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -5,7 +5,7 @@ class Harvest < ApplicationRecord extend FriendlyId include PhotoCapable include Ownable - include HarvestSearch + include SearchHarvests friendly_id :harvest_slug, use: %i(slugged finders) diff --git a/app/models/photo.rb b/app/models/photo.rb index 258ad62b8..7518cc80d 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -3,7 +3,7 @@ class Photo < ApplicationRecord include Likeable include Ownable - include PhotoSearch + include SearchPhotos PHOTO_CAPABLE = %w(Garden Planting Harvest Seed Post Crop).freeze @@ -26,6 +26,8 @@ class Photo < ApplicationRecord joins(:photo_associations).where(photo_associations: { photographable_type: model_name.to_s }) } + delegate :login_name, to: :owner, prefix: true + # This is split into a side-effect free method and a side-effecting method # for easier stubbing and testing. def flickr_metadata diff --git a/app/models/planting.rb b/app/models/planting.rb index e73f41849..0705e5d42 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -7,7 +7,7 @@ class Planting < ApplicationRecord include Ownable include PredictPlanting include PredictHarvest - include PlantingSearch + include SearchPlantings friendly_id :planting_slug, use: %i(slugged finders) diff --git a/app/models/seed.rb b/app/models/seed.rb index 47571f7f8..c34c8ee5c 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -5,7 +5,7 @@ class Seed < ApplicationRecord include PhotoCapable include Finishable include Ownable - include SeedSearch + include SearchSeeds friendly_id :seed_slug, use: %i(slugged finders) TRADABLE_TO_VALUES = %w(nowhere locally nationally internationally).freeze From 673f977efcfeb65f69123a5a3035edadee54d985 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 25 Dec 2019 14:27:13 +1300 Subject: [PATCH 098/188] Photos controller using elastic search --- app/controllers/photos_controller.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 9b7fb7c1b..849bdb11d 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -13,18 +13,20 @@ class PhotosController < ApplicationController end def index + where = {} if params[:crop_slug] @crop = Crop.find params[:crop_slug] - @photos = Photo.by_crop(@crop) + where = { crop_id: @crop.id} elsif params[:planting_id] @planting = Planting.find params[:planting_id] - @photos = @planting.photos - else - @photos = Photo.all + where = { planting_id: @planting.id} end - @photos = @photos.order(created_at: :desc) - .includes(:owner) - .paginate(page: params[:page]) + + @photos = Photo.search(load: false, + boost_by: [:created_at], + where: where, + page: params[:page], + limit: 50) respond_with(@photos) end From 950dd7f8100f4ebc3d5dfa41df9b33c784ddc72b Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Wed, 25 Dec 2019 01:27:49 +0000 Subject: [PATCH 099/188] [CodeFactor] Apply fixes --- app/controllers/photos_controller.rb | 12 ++++++------ app/models/concerns/search_photos.rb | 13 ++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 849bdb11d..d168488b1 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -16,17 +16,17 @@ class PhotosController < ApplicationController where = {} if params[:crop_slug] @crop = Crop.find params[:crop_slug] - where = { crop_id: @crop.id} + where = { crop_id: @crop.id } elsif params[:planting_id] @planting = Planting.find params[:planting_id] - where = { planting_id: @planting.id} + where = { planting_id: @planting.id } end @photos = Photo.search(load: false, - boost_by: [:created_at], - where: where, - page: params[:page], - limit: 50) + boost_by: [:created_at], + where: where, + page: params[:page], + limit: 50) respond_with(@photos) end diff --git a/app/models/concerns/search_photos.rb b/app/models/concerns/search_photos.rb index 10c98adf0..1715963a1 100644 --- a/app/models/concerns/search_photos.rb +++ b/app/models/concerns/search_photos.rb @@ -5,13 +5,12 @@ module SearchPhotos included do searchkick merge_mappings: true, - mappings: { - properties: { - title: { type: :text }, - created_at: { type: :integer }, - } - } - + mappings: { + properties: { + title: { type: :text }, + created_at: { type: :integer } + } + } # scope :search_import, -> { includes(:owner, :crops, :plantings, :harvests, :seeds, :posts) } From f42328f85e209ca62f941c4f9eef10dae11172c9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 25 Dec 2019 14:52:15 +1300 Subject: [PATCH 100/188] harvests#index using model-like varaibles --- app/models/concerns/search_harvests.rb | 7 ++-- app/models/harvest.rb | 3 ++ app/views/harvests/_card.html.haml | 11 +++--- app/views/harvests/index.html.haml | 21 ++--------- ...0191209202348_add_harvest_count_to_crop.rb | 37 ++++++++++++++++--- db/schema.rb | 2 + 6 files changed, 50 insertions(+), 31 deletions(-) diff --git a/app/models/concerns/search_harvests.rb b/app/models/concerns/search_harvests.rb index 2f69fd9f1..cd6e481c8 100644 --- a/app/models/concerns/search_harvests.rb +++ b/app/models/concerns/search_harvests.rb @@ -20,12 +20,13 @@ module SearchHarvests { slug: slug, crop_id: crop_id, - crop_name: crop.name, + crop_name: crop_name, crop_slug: crop.slug, has_photos: photos.size.positive?, owner_id: owner_id, - owner_name: owner.login_name, - photos_count: photos.size, + owner_slug: owner_slug, + owner_login_name: owner_login_name, + photos_count: photos_count, plant_part: plant_part&.name, planting_id: planting_id, quantity: quantity, diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 17c2122c7..e0825c0ae 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -50,6 +50,9 @@ class Harvest < ApplicationRecord ON (m.id=h2.owner_id AND harvests.id < h2.id)").where("h2 IS NULL") } + delegate :name, to: :crop, prefix: true + delegate :login_name, :slug, to: :owner, prefix: true + ## ## Validations validates :crop, approved: true diff --git a/app/views/harvests/_card.html.haml b/app/views/harvests/_card.html.haml index 0d06351c9..55811bb24 100644 --- a/app/views/harvests/_card.html.haml +++ b/app/views/harvests/_card.html.haml @@ -1,12 +1,13 @@ - cache harvest do .card = link_to harvest do - = image_tag harvest_image_path(harvest), alt: harvest, class: 'img-card' + = image_tag harvest.thumbnail_url ? harvest.thumbnail_url : placeholder_image, alt: harvest.crop_name, class: 'img-card' .card-body %h5 - = crop_icon(harvest.crop) - %strong - = link_to harvest.crop, harvest + %strong= link_to harvest.crop_name, harvest_path(slug: harvest.slug) %span.badge.badge-pill= harvest.plant_part .card-footer - .float-right=render 'members/tiny', member: harvest.owner \ No newline at end of file + .float-right + %span.chip.member-chip + = link_to member_path(slug: harvest.owner_slug) do + = harvest.owner_login_name \ No newline at end of file diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index 65499b848..71c724c68 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -29,24 +29,9 @@ .badge.badge-success= link_to 'API Methods', '/api-docs' .col-md-10 %section - %h2 - = page_entries_info @harvests + %h2= page_entries_info @harvests = will_paginate @harvests .index-cards - - @harvests.each do |harvest| - - cache harvest do - .card - = link_to harvest_path(slug: harvest['slug']) do - - if harvest['thumbnail_url'].present? - = image_tag harvest['thumbnail_url'], alt: harvest, class: 'img-card' - - else - = image_tag placeholder_image, alt: harvest, class: 'img-card' - .card-body - %h5 - %strong - = link_to harvest_path(slug: harvest['slug']) do - = harvest['crop_name'] - %span.badge.badge-pill= harvest['plant_part'] - .card-footer - .float-right.harvest-owner=render 'members/tiny', member: Member.find(harvest['owner_id']) + - @harvests.each do |h| + = render 'harvests/card', harvest: h = will_paginate @harvests diff --git a/db/migrate/20191209202348_add_harvest_count_to_crop.rb b/db/migrate/20191209202348_add_harvest_count_to_crop.rb index d57ff6848..274721a73 100644 --- a/db/migrate/20191209202348_add_harvest_count_to_crop.rb +++ b/db/migrate/20191209202348_add_harvest_count_to_crop.rb @@ -11,15 +11,15 @@ class AddHarvestCountToCrop < ActiveRecord::Migration[5.2] end change_table :posts do |t| t.integer :comments_count, default: 0 + t.integer :photos_count, default: 0 end + change_table :harvests do |t| + t.integer :photos_count, default: 0 + end + reversible do |dir| dir.up { data } end - - Crop.reindex - Planting.reindex - Seed.reindex - Harvest.reindex end def data @@ -56,5 +56,32 @@ class AddHarvestCountToCrop < ActiveRecord::Migration[5.2] WHERE comments.post_id = posts.id ) SQL + execute <<-SQL.squish + UPDATE harvests + SET photos_count = ( + SELECT count(1) + FROM photo_associations + WHERE photo_associations.photographable_id = harvests.id + ) + SQL + execute <<-SQL.squish + UPDATE posts + SET photos_count = ( + SELECT count(1) + FROM photo_associations + WHERE photo_associations.photographable_id = posts.id + ) + SQL + + say 'indexing crops' + Crop.reindex + say 'indexing plantings' + Planting.reindex + say 'indexing seeds' + Seed.reindex + say 'indexing harvests' + Harvest.reindex + say 'indexing photos' + Photo.reindex end end diff --git a/db/schema.rb b/db/schema.rb index a701305f5..9e14adcd2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -267,6 +267,7 @@ ActiveRecord::Schema.define(version: 2019_12_09_202348) do t.integer "plant_part_id" t.float "si_weight" t.integer "planting_id" + t.integer "photos_count", default: 0 t.index ["planting_id"], name: "index_harvests_on_planting_id" end @@ -495,6 +496,7 @@ ActiveRecord::Schema.define(version: 2019_12_09_202348) do t.integer "forum_id" t.integer "likes_count", default: 0 t.integer "comments_count", default: 0 + t.integer "photos_count", default: 0 t.index ["created_at", "author_id"], name: "index_posts_on_created_at_and_author_id" t.index ["slug"], name: "index_posts_on_slug", unique: true end From 3835a4f936750d52f9114154dc1b9c433b644d02 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 25 Dec 2019 15:52:06 +1300 Subject: [PATCH 101/188] photos from ES --- app/views/photos/_card.html.haml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/photos/_card.html.haml b/app/views/photos/_card.html.haml index f073cbef1..4b606c636 100644 --- a/app/views/photos/_card.html.haml +++ b/app/views/photos/_card.html.haml @@ -1,10 +1,11 @@ .card.photo-card{id: "photo-#{photo.id}"} - = link_to image_tag(photo.source == 'flickr' ? photo.fullsize_url : photo.thumbnail_url, alt: photo.title, class: 'img img-card'), photo + = link_to photo_path(id: photo.id) do + = image_tag(photo.source == 'flickr' ? photo.fullsize_url : photo.thumbnail_url, alt: photo.title, class: 'img img-card') .card-body %h5.ellipsis = photo_icon - = link_to photo.title, photo - %i by #{link_to photo.owner, photo.owner} + = link_to photo.title, photo_path(id: photo.id) + %i by #{link_to photo.owner_login_name, member_path(slug: photo.owner_login_name)} - if photo.date_taken.present? %small.text-muted %time{datetime: photo.date_taken}= I18n.l(photo.date_taken.to_date) From ace0977c75ec90e01e10241d90b6314de2e65a09 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 25 Dec 2019 16:18:34 +1300 Subject: [PATCH 102/188] plantings view using object instead of hash --- app/models/concerns/search_plantings.rb | 7 +++--- app/models/planting.rb | 1 + app/views/plantings/_card.html.haml | 31 +++++++------------------ app/views/plantings/index.html.haml | 15 ++---------- 4 files changed, 16 insertions(+), 38 deletions(-) diff --git a/app/models/concerns/search_plantings.rb b/app/models/concerns/search_plantings.rb index e96bcd4e5..bdf8dc788 100644 --- a/app/models/concerns/search_plantings.rb +++ b/app/models/concerns/search_plantings.rb @@ -7,6 +7,7 @@ module SearchPlantings searchkick merge_mappings: true, mappings: { properties: { + active: { type: :boolean }, created_at: { type: :integer }, harvests_count: { type: :integer }, photos_count: { type: :integer }, @@ -28,9 +29,9 @@ module SearchPlantings has_photos: photos.size.positive?, location: location, owner_id: owner_id, - owner_location: owner.location, - owner_name: owner.login_name, - owner_slug: owner.slug, + owner_location: owner_location, + owner_login_name: owner_login_name, + owner_slug: owner_slug, percentage_grown: percentage_grown.to_i, photos_count: photos.size, planted_at: planted_at, diff --git a/app/models/planting.rb b/app/models/planting.rb index 0705e5d42..9f6b3949e 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -58,6 +58,7 @@ class Planting < ApplicationRecord ## Delegations delegate :name, :slug, :en_wikipedia_url, :default_scientific_name, :plantings_count, to: :crop, prefix: true + delegate :login_name, :slug, :location, to: :owner, prefix: true delegate :annual?, :perennial?, :svg_icon, to: :crop delegate :location, :longitude, :latitude, to: :garden diff --git a/app/views/plantings/_card.html.haml b/app/views/plantings/_card.html.haml index e875b2154..d90908991 100644 --- a/app/views/plantings/_card.html.haml +++ b/app/views/plantings/_card.html.haml @@ -1,27 +1,14 @@ - cache planting do - .card.planting{class: planting.active? ? '' : 'card-finished'} - = link_to planting do - = image_tag planting_image_path(planting), class: 'img-card', alt: planting - - if can? :edit, planting - .planting-quick-actions - .dropdown - %a.planting-menu.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button", href: '#'} - .dropdown-menu{"aria-labelledby" => "planting-menu"} - = planting_edit_button(planting, classes: 'dropdown-item') - = add_photo_button(planting, classes: 'dropdown-item') - - - if planting.active? - = planting_finish_button(planting, classes: 'dropdown-item') - = planting_harvest_button(planting, classes: 'dropdown-item') - = planting_save_seeds_button(planting, classes: 'dropdown-item') - - - if can? :destroy, planting - .dropdown-divider - = delete_button(planting, classes: 'dropdown-item text-danger') - = link_to planting do + .card.planting{class: planting.active ? '' : 'card-finished'} + = link_to planting_path(slug: planting.slug) do + = image_tag planting.thumbnail_url ? planting.thumbnail_url : placeholder_image, class: 'img-card', alt: planting.crop_name + = link_to planting_path(slug: planting.slug) do .card-body.text-center - %h4= planting.crop + %h4= planting.crop_name .text-center= render 'plantings/badges', planting: planting = render 'plantings/progress', planting: planting .card-footer - .float-right=render 'members/tiny', member: planting.owner \ No newline at end of file + .float-right + %span.chip.member-chip + = link_to member_path(slug: planting.owner_slug) do + = planting.owner_login_name \ No newline at end of file diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index 491259221..b7f3a4689 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -39,17 +39,6 @@ %h2= page_entries_info @plantings = will_paginate @plantings .index-cards - - @plantings.each do |planting| - .card.planting{class: planting['active'] ? '' : 'card-finished'} - = link_to planting_path(slug: planting['slug']) do - = image_tag planting['thumbnail_url'] ? planting['thumbnail_url'] : placeholder_image, class: 'img-card', alt: planting - = link_to planting_path(slug: planting['slug']) do - .card-body.text-center - %h4= planting['crop_name'] - / = render 'plantings/progress', planting: planting - .card-footer - .float-right - %span.chip.member-chip - = link_to member_path(slug: planting['owner_slug']) do - = planting['owner_name'] + - @plantings.each do |p| + = render 'plantings/card', planting: p = will_paginate @plantings From aea0d5877d65782d392ad2b7f5fe07a2467cd57d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 25 Dec 2019 16:23:13 +1300 Subject: [PATCH 103/188] use object instead of hash for displaying crops --- app/views/crops/_crop.html.haml | 2 +- app/views/crops/_search_result.haml | 14 -------------- app/views/crops/_thumbnail.html.haml | 9 ++++----- app/views/crops/index.html.haml | 4 ++-- app/views/home/_crops.html.haml | 4 ++-- 5 files changed, 9 insertions(+), 24 deletions(-) delete mode 100644 app/views/crops/_search_result.haml diff --git a/app/views/crops/_crop.html.haml b/app/views/crops/_crop.html.haml index 9c763518d..e32a933a3 100644 --- a/app/views/crops/_crop.html.haml +++ b/app/views/crops/_crop.html.haml @@ -6,7 +6,7 @@ crop .card-body %h3.card-title - %strong= link_to crop, crop + %strong= link_to crop.name, crop_path(slug: crop.slug) = crop.default_scientific_name .d-flex.justify-content-between - if crop.annual? && crop.median_lifespan.present? diff --git a/app/views/crops/_search_result.haml b/app/views/crops/_search_result.haml deleted file mode 100644 index 649b1729f..000000000 --- a/app/views/crops/_search_result.haml +++ /dev/null @@ -1,14 +0,0 @@ -.card.crop-thumbnail - = link_to crop_path(slug: crop['slug']) do - - = image_tag(crop['thumbnail_url'] ? crop['thumbnail_url'] : placeholder_image, - alt: crop['name'], - class: 'img img-card') - - .text - %h3.crop-name - = link_to crop['name'], crop_path(slug: crop['slug']) - %h5.crop-sci-name -   - = crop['scientific_name'] - diff --git a/app/views/crops/_thumbnail.html.haml b/app/views/crops/_thumbnail.html.haml index 948c59bbc..29617b768 100644 --- a/app/views/crops/_thumbnail.html.haml +++ b/app/views/crops/_thumbnail.html.haml @@ -1,12 +1,11 @@ - cache crop do .card.crop-thumbnail - = link_to image_tag(crop_image_path(crop), + = link_to image_tag(crop.thumbnail_url ? crop.thumbnail_url : placeholder_image, alt: crop.name, class: 'img img-card'), - crop + crop_path(slug: crop.slug) .text - %h3.crop-name= link_to crop, crop + %h3.crop-name= link_to crop.name, crop_path(slug: crop.slug) %h5.crop-sci-name -   - = crop.scientific_names.first&.name + = crop.scientific_names.first diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index 9458b31b9..427412019 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -22,8 +22,8 @@ %h2= t('.title') = will_paginate @crops .index-cards - - @crops.each do |crop| - = render 'crops/search_result', crop: crop + - @crops.each do |c| + = render 'crops/thumbnail', crop: c = will_paginate @crops diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index 5744bc22d..17c25cd4d 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -1,4 +1,4 @@ - cache cache_key_for(Crop, 'homepage'), expires_in: 1.day do .index-cards - - CropSearchService.random_with_photos(16).each do |crop| - = render 'crops/search_result', crop: crop \ No newline at end of file + - CropSearchService.random_with_photos(16).each do |c| + = render 'crops/thumbnail', crop: c \ No newline at end of file From e84ab6d2a23eb420b70ec3d6d4c0926120a05650 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 25 Dec 2019 16:37:19 +1300 Subject: [PATCH 104/188] seeds using object instead of hash --- app/models/concerns/search_seeds.rb | 8 +++++--- app/models/seed.rb | 3 ++- app/views/home/_seeds.html.haml | 4 ++-- app/views/seeds/_card.html.haml | 14 +++++++------- app/views/seeds/_search_result.html.haml | 16 ---------------- app/views/seeds/index.html.haml | 6 ++---- 6 files changed, 18 insertions(+), 33 deletions(-) delete mode 100644 app/views/seeds/_search_result.html.haml diff --git a/app/models/concerns/search_seeds.rb b/app/models/concerns/search_seeds.rb index 2223efcb0..f54779362 100644 --- a/app/models/concerns/search_seeds.rb +++ b/app/models/concerns/search_seeds.rb @@ -27,14 +27,16 @@ module SearchSeeds heirloom: heirloom, organic: organic, owner_id: owner_id, - owner_name: owner.login_name, + owner_login_name: owner_login_name, + owner_location: owner_location, + owner_slug: owner_slug, parent_planting: parent_planting, photos_count: photos.size, plant_before: plant_before&.to_s(:ymd), quantity: quantity, thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, tradable_to: tradable_to, - tradeable: tradable?, + tradable: tradable?, finished: finished?, location: owner.location, created_at: created_at.to_i @@ -46,7 +48,7 @@ module SearchSeeds limit: limit, where: { finished: false, - tradeable: true + tradable: true }, boost_by: [:created_at], load: false) diff --git a/app/models/seed.rb b/app/models/seed.rb index c34c8ee5c..9841fa19f 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -47,8 +47,9 @@ class Seed < ApplicationRecord # # Delegations - delegate :name, to: :crop + delegate :name, to: :crop, prefix: true delegate :location, :latitude, :longitude, to: :owner + delegate :login_name, :slug, :location, to: :owner, prefix: true # # Scopes diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml index 1ce34cb11..bfb56295b 100644 --- a/app/views/home/_seeds.html.haml +++ b/app/views/home/_seeds.html.haml @@ -1,5 +1,5 @@ - cache cache_key_for(Seed) do %h2.text-center= t('home.seeds.title') .index-cards - - Seed.homepage_records(6).each do |seed| - = render 'seeds/search_result', seed: seed + - Seed.homepage_records(6).each do |s| + = render 'seeds/card', seed: s diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index db8a72da1..6b4cd8527 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -1,17 +1,17 @@ - cache seed do - .card.seed-card{class: seed.active? ? '' : 'card-finished'} + .card.seed-card{class: seed.finished ? 'card-finished' : ''} = link_to seed do - = image_tag(seed_image_path(seed), alt: seed, class: 'img-card') + = image_tag(seed.thumbnail_url ? seed.thumbnail_url : placeholder_image, alt: seed.name, class: 'img-card') .text - = render 'members/tiny', member: seed.owner + %span.chip.member-chip + = seed.owner_login_name .card-body .card-title - = crop_icon(seed.crop) - = link_to seed.crop, seed - - if seed.tradable? + = link_to seed.crop_name, seed_path(slug: seed.slug) + - if seed.tradable .text-muted = icon 'fas', 'map' Will trade #{seed.tradable_to} .badge.badge-pill.badge-location = icon 'fas', 'map-marker' - = truncate(seed.owner.location, length: 20, separator: ' ', omission: '... ') \ No newline at end of file + = truncate(seed.owner_location, length: 20, separator: ' ', omission: '... ') \ No newline at end of file diff --git a/app/views/seeds/_search_result.html.haml b/app/views/seeds/_search_result.html.haml deleted file mode 100644 index 058340dcc..000000000 --- a/app/views/seeds/_search_result.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -.card.seed-card{class: seed['finished'] ? 'card-finished' : ''} - = link_to seed_path(slug: seed['slug']) do - = image_tag(seed['thumbnail_url'] ? seed['thumbnail_url'] : placeholder_image, alt: seed['crop_name'], class: 'img-card') - .text - %span.chip.member-chip= seed['owner_name'] - .card-body - .card-title - = link_to seed['crop_name'], seed_path(seed['slug']) - - if seed['tradeable'] - .text-muted - = icon 'fas', 'map' - Will trade #{seed['tradable_to']} - .card-footer - .badge.badge-pill.badge-location - = icon 'fas', 'map-marker' - = truncate(seed['location'], length: 20, separator: ' ', omission: '... ') \ No newline at end of file diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index f67dca412..47e349278 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -38,9 +38,7 @@ = will_paginate @seeds .index-cards - - @seeds.each do |seed| - = render 'seeds/search_result', seed: seed + - @seeds.each do |s| + = render 'seeds/card', seed: s = will_paginate @seeds - - From 23138122728ee59e67fd9eedd24ac153e88ad467 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 26 Dec 2019 11:00:21 +1300 Subject: [PATCH 105/188] Removed set_garden --- app/controllers/gardens_controller.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index 0af8d3ea3..ceb53deb2 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -49,9 +49,6 @@ class GardensController < DataController private - def set_garden - @garden = Garden.find(params[:slug]) - end def garden_params params.require(:garden).permit(:name, :slug, :description, :active, From 877baf22db9c6d73caf4f2279c34526cf402f1c9 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Wed, 25 Dec 2019 22:00:43 +0000 Subject: [PATCH 106/188] [CodeFactor] Apply fixes to commit 2313812 --- app/controllers/gardens_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index ceb53deb2..5ef4be121 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -49,7 +49,6 @@ class GardensController < DataController private - def garden_params params.require(:garden).permit(:name, :slug, :description, :active, :location, :latitude, :longitude, :area, :area_unit, :garden_type_id) From eab10eaf7c3c614de1b1157ac6f58790f1680937 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 26 Dec 2019 12:54:36 +1300 Subject: [PATCH 107/188] many to many counter caches weren't working and causing errors. --- app/models/photo_association.rb | 6 +----- ...0191209202348_add_harvest_count_to_crop.rb | 21 ------------------- db/schema.rb | 2 -- 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/app/models/photo_association.rb b/app/models/photo_association.rb index a2904320b..647c1bb78 100644 --- a/app/models/photo_association.rb +++ b/app/models/photo_association.rb @@ -11,10 +11,6 @@ class PhotoAssociation < ApplicationRecord ## Triggers before_save :set_crop - def item - photographable - end - def self.item(item_id, item_type) find_by!(photographable_id: item_id, photographable_type: item_type).photographable end @@ -30,7 +26,7 @@ class PhotoAssociation < ApplicationRecord private def photo_and_item_have_same_owner - return unless photographable_type != 'Crop' + return if photographable_type == 'Crop' errors.add(:photo, "must have same owner as item it links to") unless photographable.owner_id == photo.owner_id end diff --git a/db/migrate/20191209202348_add_harvest_count_to_crop.rb b/db/migrate/20191209202348_add_harvest_count_to_crop.rb index 274721a73..46b5f0737 100644 --- a/db/migrate/20191209202348_add_harvest_count_to_crop.rb +++ b/db/migrate/20191209202348_add_harvest_count_to_crop.rb @@ -11,12 +11,7 @@ class AddHarvestCountToCrop < ActiveRecord::Migration[5.2] end change_table :posts do |t| t.integer :comments_count, default: 0 - t.integer :photos_count, default: 0 end - change_table :harvests do |t| - t.integer :photos_count, default: 0 - end - reversible do |dir| dir.up { data } end @@ -56,22 +51,6 @@ class AddHarvestCountToCrop < ActiveRecord::Migration[5.2] WHERE comments.post_id = posts.id ) SQL - execute <<-SQL.squish - UPDATE harvests - SET photos_count = ( - SELECT count(1) - FROM photo_associations - WHERE photo_associations.photographable_id = harvests.id - ) - SQL - execute <<-SQL.squish - UPDATE posts - SET photos_count = ( - SELECT count(1) - FROM photo_associations - WHERE photo_associations.photographable_id = posts.id - ) - SQL say 'indexing crops' Crop.reindex diff --git a/db/schema.rb b/db/schema.rb index 9e14adcd2..a701305f5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -267,7 +267,6 @@ ActiveRecord::Schema.define(version: 2019_12_09_202348) do t.integer "plant_part_id" t.float "si_weight" t.integer "planting_id" - t.integer "photos_count", default: 0 t.index ["planting_id"], name: "index_harvests_on_planting_id" end @@ -496,7 +495,6 @@ ActiveRecord::Schema.define(version: 2019_12_09_202348) do t.integer "forum_id" t.integer "likes_count", default: 0 t.integer "comments_count", default: 0 - t.integer "photos_count", default: 0 t.index ["created_at", "author_id"], name: "index_posts_on_created_at_and_author_id" t.index ["slug"], name: "index_posts_on_slug", unique: true end From d418f142e7058d33616fa57599ab3c88d180d9aa Mon Sep 17 00:00:00 2001 From: Brenda Date: Thu, 26 Dec 2019 15:02:30 +1300 Subject: [PATCH 108/188] Routes using slugs (instead of ids) this seems to be intended by the models having slugs (added about 7 years ago) but the routes weren't using them --- app/controllers/application_controller.rb | 3 +- app/controllers/charts/gardens_controller.rb | 2 +- app/controllers/data_controller.rb | 13 ++++++ app/controllers/gardens_controller.rb | 8 +--- app/controllers/harvests_controller.rb | 9 ++-- app/controllers/plantings_controller.rb | 11 ++--- app/controllers/seeds_controller.rb | 9 +--- config/routes.rb | 10 ++--- .../charts/gardens_controller_spec.rb | 4 +- spec/controllers/gardens_controller_spec.rb | 14 +++---- spec/controllers/harvests_controller_spec.rb | 20 ++++----- spec/routing/gardens_routing_spec.rb | 8 ++-- spec/routing/harvests_routing_spec.rb | 8 ++-- spec/routing/member_routing_spec.rb | 42 +++++++++++++++++++ spec/routing/plantings_routing_spec.rb | 8 ++-- spec/routing/seeds_routing_spec.rb | 8 ++-- 16 files changed, 107 insertions(+), 70 deletions(-) create mode 100644 app/controllers/data_controller.rb create mode 100644 spec/routing/member_routing_spec.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7e01327d6..58c3ec353 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -7,9 +7,8 @@ class ApplicationController < ActionController::Base after_action :store_location before_action :set_locale - rescue_from ActiveRecord::RecordNotFound, with: :not_found - # CanCan error handling + def store_location unless request.path.in?(["/members/sign_in", "/members/sign_up", diff --git a/app/controllers/charts/gardens_controller.rb b/app/controllers/charts/gardens_controller.rb index a7048c57f..5ca9a03b9 100644 --- a/app/controllers/charts/gardens_controller.rb +++ b/app/controllers/charts/gardens_controller.rb @@ -5,7 +5,7 @@ module Charts respond_to :json def timeline @data = [] - @garden = Garden.find(params[:garden_id]) + @garden = Garden.find(params[:garden_slug]) @garden.plantings.where.not(planted_at: nil) .order(finished_at: :desc).each do |p| # use finished_at if we have it, otherwise use predictions diff --git a/app/controllers/data_controller.rb b/app/controllers/data_controller.rb new file mode 100644 index 000000000..fece1f68c --- /dev/null +++ b/app/controllers/data_controller.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class DataController < ApplicationController + abstract + before_action :authenticate_member!, except: %i(index show) + load_and_authorize_resource id_param: :slug + + after_action :expire_homepage, only: %i(create update destroy) + + respond_to :html, :json + respond_to :csv, :rss, only: [:index] + responders :flash +end diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index 333fa454d..5ef4be121 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -1,10 +1,6 @@ -class GardensController < ApplicationController - before_action :authenticate_member!, except: %i(index show) - after_action :expire_homepage, only: %i(create destroy) - load_and_authorize_resource - responders :flash - respond_to :html, :json +# frozen_string_literal: true +class GardensController < DataController def index @owner = Member.find_by(slug: params[:member_slug]) @show_all = params[:all] == '1' diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index c474e2679..76cb3afe5 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -1,10 +1,7 @@ -class HarvestsController < ApplicationController - before_action :authenticate_member!, except: %i(index show) +# frozen_string_literal: true + +class HarvestsController < DataController after_action :update_crop_medians, only: %i(create update destroy) - load_and_authorize_resource - respond_to :html, :json - respond_to :csv, :rss, only: :index - responders :flash def index @owner = Member.find_by(slug: params[:member_slug]) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index ae01b499c..47919e95e 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -1,13 +1,8 @@ -class PlantingsController < ApplicationController - before_action :authenticate_member!, except: %i(index show) - after_action :expire_homepage, only: %i(create update destroy) +# frozen_string_literal: true + +class PlantingsController < DataController after_action :update_crop_medians, only: %i(create update destroy) after_action :update_planting_medians, only: :update - load_and_authorize_resource - - respond_to :html, :json - respond_to :csv, :rss, only: [:index] - responders :flash def index @owner = Member.find_by(slug: params[:member_slug]) if params[:member_slug] diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index b6457edbf..2294e2840 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -1,11 +1,6 @@ -class SeedsController < ApplicationController - before_action :authenticate_member!, except: %i(index show) - load_and_authorize_resource - responders :flash - respond_to :html, :json - respond_to :csv, only: :index - respond_to :rss, only: :index +# frozen_string_literal: true +class SeedsController < DataController def index @owner = Member.find_by(slug: params[:member_slug]) if params[:member_slug].present? @crop = Crop.find_by(slug: params[:crop_slug]) if params[:crop_slug].present? diff --git a/config/routes.rb b/config/routes.rb index cddfbceb8..5244ed3bc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,11 +28,11 @@ Rails.application.routes.draw do resources :photos, only: :index end - resources :gardens, concerns: :has_photos do + resources :gardens, concerns: :has_photos, param: :slug do get 'timeline' => 'charts/gardens#timeline', constraints: { format: 'json' } end - resources :plantings, concerns: :has_photos do + resources :plantings, concerns: :has_photos, param: :slug do resources :harvests resources :seeds collection do @@ -40,12 +40,12 @@ Rails.application.routes.draw do end end - resources :seeds, concerns: :has_photos do - resources :plantings + resources :seeds, concerns: :has_photos, param: :slug do + get 'plantings' => 'plantings#index' get 'crop/:crop' => 'seeds#index', as: 'seeds_by_crop', on: :collection end - resources :harvests, concerns: :has_photos do + resources :harvests, concerns: :has_photos, param: :slug do get 'crop/:crop' => 'harvests#index', as: 'harvests_by_crop', on: :collection end diff --git a/spec/controllers/charts/gardens_controller_spec.rb b/spec/controllers/charts/gardens_controller_spec.rb index 007e7f58c..b6a2bd1c5 100644 --- a/spec/controllers/charts/gardens_controller_spec.rb +++ b/spec/controllers/charts/gardens_controller_spec.rb @@ -9,7 +9,7 @@ describe Charts::GardensController do context "when not signed in" do describe 'GET timeline' do - before { get :timeline, params: { garden_id: garden.to_param } } + before { get :timeline, params: { garden_slug: garden.to_param } } it { expect(response).to be_successful } end @@ -21,7 +21,7 @@ describe Charts::GardensController do let!(:member) { FactoryBot.create(:member) } describe 'GET timeline' do - before { get :timeline, params: { garden_id: garden.to_param } } + before { get :timeline, params: { garden_slug: garden.to_param } } it { expect(response).to be_successful } end diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb index c4b4de332..319304454 100644 --- a/spec/controllers/gardens_controller_spec.rb +++ b/spec/controllers/gardens_controller_spec.rb @@ -10,7 +10,7 @@ RSpec.describe GardensController, type: :controller do context "when not signed in" do describe 'GET new' do - before { get :new, params: { id: garden.to_param } } + before { get :new, params: { slug: garden.to_param } } it { expect(response).to redirect_to(new_member_session_path) } end @@ -32,19 +32,19 @@ RSpec.describe GardensController, type: :controller do end describe 'GET edit' do - before { get :edit, params: { id: garden.to_param } } + before { get :edit, params: { slug: garden.to_param } } it { expect(response).to redirect_to(new_member_session_path) } end describe 'POST update' do - before { post :update, params: { id: garden.to_param, garden: valid_params } } + before { post :update, params: { slug: garden.to_param, garden: valid_params } } it { expect(response).to redirect_to(new_member_session_path) } end describe 'DELETE' do - before { delete :destroy, params: { id: garden.to_param, params: { garden: valid_params } } } + before { delete :destroy, params: { slug: garden.to_param, params: { garden: valid_params } } } it { expect(response).to redirect_to(new_member_session_path) } end @@ -69,19 +69,19 @@ RSpec.describe GardensController, type: :controller do end describe 'GET edit' do - before { get :edit, params: { id: not_my_garden.to_param } } + before { get :edit, params: { slug: not_my_garden.to_param } } it { expect(response).to redirect_to(root_path) } end describe 'POST update' do - before { post :update, params: { id: not_my_garden.to_param, garden: valid_params } } + before { post :update, params: { slug: not_my_garden.to_param, garden: valid_params } } it { expect(response).to redirect_to(root_path) } end describe 'DELETE' do - before { delete :destroy, params: { id: not_my_garden.to_param, params: { garden: valid_params } } } + before { delete :destroy, params: { slug: not_my_garden.to_param, params: { garden: valid_params } } } it { expect(response).to redirect_to(root_path) } end diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index f4d8871f7..57722269f 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -53,7 +53,7 @@ describe HarvestsController do let(:harvest) { Harvest.create! valid_attributes } describe "assigns the requested harvest as @harvest" do - before { get :show, params: { id: harvest.to_param } } + before { get :show, params: { slug: harvest.to_param } } it { expect(assigns(:harvest)).to eq(harvest) } end @@ -75,7 +75,7 @@ describe HarvestsController do let(:harvest) { Harvest.create! valid_attributes } describe "assigns the requested harvest as @harvest" do - before { get :edit, params: { id: harvest.to_param } } + before { get :edit, params: { slug: harvest.to_param } } it { expect(assigns(:harvest)).to eq(harvest) } end @@ -149,19 +149,19 @@ describe HarvestsController do it "updates the requested harvest" do new_crop = FactoryBot.create :crop expect do - put :update, params: { id: harvest.to_param, harvest: { crop_id: new_crop.id } } + put :update, params: { slug: harvest.to_param, harvest: { crop_id: new_crop.id } } harvest.reload end.to change(harvest, :crop_id).to(new_crop.id) end describe "assigns the requested harvest as @harvest" do - before { put :update, params: { id: harvest.to_param, harvest: valid_attributes } } + before { put :update, params: { slug: harvest.to_param, harvest: valid_attributes } } it { expect(assigns(:harvest)).to eq(harvest) } end describe "redirects to the harvest" do - before { put :update, params: { id: harvest.to_param, harvest: valid_attributes } } + before { put :update, params: { slug: harvest.to_param, harvest: valid_attributes } } it { expect(response).to redirect_to(harvest) } end @@ -172,13 +172,13 @@ describe HarvestsController do harvest = Harvest.create! valid_attributes # Trigger the behavior that occurs when invalid params are submitted Harvest.any_instance.stub(:save).and_return(false) - put :update, params: { id: harvest.to_param, harvest: { "crop_id" => "invalid value" } } + put :update, params: { slug: harvest.to_param, harvest: { "crop_id" => "invalid value" } } expect(assigns(:harvest)).to eq(harvest) end it "re-renders the 'edit' template" do harvest = Harvest.create! valid_attributes - put :update, params: { id: harvest.to_param, harvest: { "crop_id" => "invalid value" } } + put :update, params: { slug: harvest.to_param, harvest: { "crop_id" => "invalid value" } } expect(response).to render_template("edit") end end @@ -189,7 +189,7 @@ describe HarvestsController do describe "does not save planting_id" do before do - put :update, params: { id: harvest.to_param, + put :update, params: { slug: harvest.to_param, harvest: valid_attributes.merge(planting_id: not_my_planting.id) } end @@ -202,13 +202,13 @@ describe HarvestsController do it "destroys the requested harvest" do harvest = Harvest.create! valid_attributes expect do - delete :destroy, params: { id: harvest.to_param } + delete :destroy, params: { slug: harvest.to_param } end.to change(Harvest, :count).by(-1) end it "redirects to the harvests list" do harvest = Harvest.create! valid_attributes - delete :destroy, params: { id: harvest.to_param } + delete :destroy, params: { slug: harvest.to_param } expect(response).to redirect_to(harvests_url) end end diff --git a/spec/routing/gardens_routing_spec.rb b/spec/routing/gardens_routing_spec.rb index ddd282551..365fba5e7 100644 --- a/spec/routing/gardens_routing_spec.rb +++ b/spec/routing/gardens_routing_spec.rb @@ -14,11 +14,11 @@ describe GardensController do end it "routes to #show" do - get("/gardens/1").should route_to("gardens#show", id: "1") + get("/gardens/sunny-bed").should route_to("gardens#show", slug: 'sunny-bed') end it "routes to #edit" do - get("/gardens/1/edit").should route_to("gardens#edit", id: "1") + get("/gardens/sunny-bed/edit").should route_to("gardens#edit", slug: 'sunny-bed') end it "routes to #create" do @@ -26,11 +26,11 @@ describe GardensController do end it "routes to #update" do - put("/gardens/1").should route_to("gardens#update", id: "1") + put("/gardens/sunny-bed").should route_to("gardens#update", slug: 'sunny-bed') end it "routes to #destroy" do - delete("/gardens/1").should route_to("gardens#destroy", id: "1") + delete("/gardens/sunny-bed").should route_to("gardens#destroy", slug: 'sunny-bed') end end end diff --git a/spec/routing/harvests_routing_spec.rb b/spec/routing/harvests_routing_spec.rb index 4dc1aaece..22ee305fc 100644 --- a/spec/routing/harvests_routing_spec.rb +++ b/spec/routing/harvests_routing_spec.rb @@ -14,11 +14,11 @@ describe HarvestsController do end it "routes to #show" do - get("/harvests/1").should route_to("harvests#show", id: "1") + get("/harvests/potato").should route_to("harvests#show", slug: "potato") end it "routes to #edit" do - get("/harvests/1/edit").should route_to("harvests#edit", id: "1") + get("/harvests/potato/edit").should route_to("harvests#edit", slug: "potato") end it "routes to #create" do @@ -26,11 +26,11 @@ describe HarvestsController do end it "routes to #update" do - put("/harvests/1").should route_to("harvests#update", id: "1") + put("/harvests/potato").should route_to("harvests#update", slug: "potato") end it "routes to #destroy" do - delete("/harvests/1").should route_to("harvests#destroy", id: "1") + delete("/harvests/potato").should route_to("harvests#destroy", slug: "potato") end end end diff --git a/spec/routing/member_routing_spec.rb b/spec/routing/member_routing_spec.rb new file mode 100644 index 000000000..790ff94b1 --- /dev/null +++ b/spec/routing/member_routing_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe MembersController do + describe "routing" do + it "routes to #index" do + get("/members").should route_to("members#index") + end + + it "routes to #new" do + get("/members/new").should route_to("members#new") + end + + it "routes to #show" do + get("/members/name").should route_to("members#show", slug: "name") + end + + it "routes to #edit" do + get("/members/name/edit").should route_to("members#edit", slug: "name") + end + + # it "routes to #create" do + # post("/members").should route_to("members#create") + # end + + it "routes to #update" do + put("/members/name").should route_to("members#update", slug: "name") + end + + it "routes to #destroy" do + delete("/members/name").should route_to("members#destroy", slug: "name") + end + + it "routes to harvests#index" do + get("/members/name/harvests").should route_to("harvests#index", member_slug: 'name') + end + it "routes to plantings#index" do + get("/members/name/plantings").should route_to("plantings#index", member_slug: 'name') + end + end +end diff --git a/spec/routing/plantings_routing_spec.rb b/spec/routing/plantings_routing_spec.rb index 75c37d655..e3a8b5344 100644 --- a/spec/routing/plantings_routing_spec.rb +++ b/spec/routing/plantings_routing_spec.rb @@ -14,11 +14,11 @@ describe PlantingsController do end it "routes to #show" do - get("/plantings/1").should route_to("plantings#show", id: "1") + get("/plantings/tomato").should route_to("plantings#show", slug: "tomato") end it "routes to #edit" do - get("/plantings/1/edit").should route_to("plantings#edit", id: "1") + get("/plantings/tomato/edit").should route_to("plantings#edit", slug: "tomato") end it "routes to #create" do @@ -26,11 +26,11 @@ describe PlantingsController do end it "routes to #update" do - put("/plantings/1").should route_to("plantings#update", id: "1") + put("/plantings/tomato").should route_to("plantings#update", slug: "tomato") end it "routes to #destroy" do - delete("/plantings/1").should route_to("plantings#destroy", id: "1") + delete("/plantings/tomato").should route_to("plantings#destroy", slug: "tomato") end end end diff --git a/spec/routing/seeds_routing_spec.rb b/spec/routing/seeds_routing_spec.rb index 0528a5b8d..65710acb1 100644 --- a/spec/routing/seeds_routing_spec.rb +++ b/spec/routing/seeds_routing_spec.rb @@ -14,11 +14,11 @@ describe SeedsController do end it "routes to #show" do - get("/seeds/1").should route_to("seeds#show", id: "1") + get("/seeds/corn").should route_to("seeds#show", slug: 'corn') end it "routes to #edit" do - get("/seeds/1/edit").should route_to("seeds#edit", id: "1") + get("/seeds/corn/edit").should route_to("seeds#edit", slug: 'corn') end it "routes to #create" do @@ -26,11 +26,11 @@ describe SeedsController do end it "routes to #update" do - put("/seeds/1").should route_to("seeds#update", id: "1") + put("/seeds/corn").should route_to("seeds#update", slug: 'corn') end it "routes to #destroy" do - delete("/seeds/1").should route_to("seeds#destroy", id: "1") + delete("/seeds/corn").should route_to("seeds#destroy", slug: 'corn') end end end From 17fa995a17cae78d9ee33c3592d23b0dd86a3fad Mon Sep 17 00:00:00 2001 From: Brenda Date: Thu, 26 Dec 2019 16:04:28 +1300 Subject: [PATCH 109/188] Adding more counter caches --- app/models/comment.rb | 2 +- app/models/harvest.rb | 4 ++-- app/models/like.rb | 2 +- app/models/photo.rb | 2 +- app/models/photo_association.rb | 4 ++-- ...191226024813_crop_harvest_counter_cache.rb | 20 ++++++++++++++++ ...20191226024957_crop_photo_counter_cache.rb | 20 ++++++++++++++++ ...025124_plant_part_harvest_counter_cache.rb | 23 +++++++++++++++++++ ...191226025225_post_comment_counter_cache.rb | 23 +++++++++++++++++++ db/schema.rb | 6 ++++- 10 files changed, 98 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20191226024813_crop_harvest_counter_cache.rb create mode 100644 db/migrate/20191226024957_crop_photo_counter_cache.rb create mode 100644 db/migrate/20191226025124_plant_part_harvest_counter_cache.rb create mode 100644 db/migrate/20191226025225_post_comment_counter_cache.rb diff --git a/app/models/comment.rb b/app/models/comment.rb index 35f0c7009..7b85f4c0d 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -2,7 +2,7 @@ class Comment < ApplicationRecord belongs_to :author, class_name: 'Member', inverse_of: :comments - belongs_to :post + belongs_to :post, counter_cache: true scope :post_order, -> { reorder("created_at ASC") } # for display on post page diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 6777e3c6c..a38241c4e 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -35,8 +35,8 @@ class Harvest < ApplicationRecord ## ## Relationships - belongs_to :crop - belongs_to :plant_part + belongs_to :crop, counter_cache: true + belongs_to :plant_part, counter_cache: true belongs_to :planting, optional: true, counter_cache: true ## diff --git a/app/models/like.rb b/app/models/like.rb index 5cf7992a0..ed16065de 100644 --- a/app/models/like.rb +++ b/app/models/like.rb @@ -2,7 +2,7 @@ class Like < ApplicationRecord belongs_to :member - belongs_to :likeable, polymorphic: true, counter_cache: true + belongs_to :likeable, polymorphic: true, counter_cache: true, touch: true validates :member, :likeable, presence: true validates :member, uniqueness: { scope: :likeable } end diff --git a/app/models/photo.rb b/app/models/photo.rb index 5f9f9169c..38359732c 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -7,7 +7,7 @@ class Photo < ApplicationRecord PHOTO_CAPABLE = %w(Garden Planting Harvest Seed Post Crop).freeze has_many :photo_associations, foreign_key: :photo_id, dependent: :delete_all, inverse_of: :photo - has_many :crops, through: :photo_associations + has_many :crops, through: :photo_associations, counter_cache: true validates :fullsize_url, url: true validates :thumbnail_url, url: true diff --git a/app/models/photo_association.rb b/app/models/photo_association.rb index 425a598c5..1fe576902 100644 --- a/app/models/photo_association.rb +++ b/app/models/photo_association.rb @@ -2,8 +2,8 @@ class PhotoAssociation < ApplicationRecord belongs_to :photo, inverse_of: :photo_associations - belongs_to :photographable, polymorphic: true - belongs_to :crop, optional: true + belongs_to :photographable, polymorphic: true, touch: true + belongs_to :crop, optional: true, counter_cache: true validate :photo_and_item_have_same_owner diff --git a/db/migrate/20191226024813_crop_harvest_counter_cache.rb b/db/migrate/20191226024813_crop_harvest_counter_cache.rb new file mode 100644 index 000000000..d0b9c2082 --- /dev/null +++ b/db/migrate/20191226024813_crop_harvest_counter_cache.rb @@ -0,0 +1,20 @@ +class CropHarvestCounterCache < ActiveRecord::Migration[5.2] + def change + change_table :crops do |t| + t.integer :harvests_count, default: 0 + end + reversible do |dir| + dir.up { set_counter_value } + end + end + def set_counter_value + execute <<-SQL.squish + UPDATE crops + SET harvests_count = ( + SELECT count(1) + FROM harvests + WHERE harvests.crop_id = crops.id + ) + SQL + end +end diff --git a/db/migrate/20191226024957_crop_photo_counter_cache.rb b/db/migrate/20191226024957_crop_photo_counter_cache.rb new file mode 100644 index 000000000..3bb4ebe68 --- /dev/null +++ b/db/migrate/20191226024957_crop_photo_counter_cache.rb @@ -0,0 +1,20 @@ +class CropPhotoCounterCache < ActiveRecord::Migration[5.2] + def change + change_table :crops do |t| + t.integer :photo_associations_count, default: 0 + end + reversible do |dir| + dir.up { set_counter_value } + end + end + def set_counter_value + execute <<-SQL.squish + UPDATE crops + SET photo_associations_count = ( + SELECT count(1) + FROM photo_associations + WHERE photo_associations.crop_id = crops.id + ) + SQL + end +end diff --git a/db/migrate/20191226025124_plant_part_harvest_counter_cache.rb b/db/migrate/20191226025124_plant_part_harvest_counter_cache.rb new file mode 100644 index 000000000..e16deaced --- /dev/null +++ b/db/migrate/20191226025124_plant_part_harvest_counter_cache.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class PlantPartHarvestCounterCache < ActiveRecord::Migration[5.2] + def change + change_table :plant_parts do |t| + t.integer :harvests_count, default: 0 + end + reversible do |dir| + dir.up { set_counter_value } + end + end + + def set_counter_value + execute <<-SQL.squish + UPDATE plant_parts + SET harvests_count = ( + SELECT count(1) + FROM harvests + WHERE harvests.plant_part_id = plant_parts.id + ) + SQL + end +end diff --git a/db/migrate/20191226025225_post_comment_counter_cache.rb b/db/migrate/20191226025225_post_comment_counter_cache.rb new file mode 100644 index 000000000..df930fe0d --- /dev/null +++ b/db/migrate/20191226025225_post_comment_counter_cache.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class PostCommentCounterCache < ActiveRecord::Migration[5.2] + def change + change_table :posts do |t| + t.integer :comments_count, default: 0 + end + reversible do |dir| + dir.up { set_counter_value } + end + end + + def set_counter_value + execute <<-SQL.squish + UPDATE posts + SET comments_count = ( + SELECT count(1) + FROM comments + WHERE comments.post_id = posts.id + ) + SQL + end +end diff --git a/db/schema.rb b/db/schema.rb index 06d7be216..4e6e251cd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_11_19_030244) do +ActiveRecord::Schema.define(version: 2019_12_26_025225) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -196,6 +196,8 @@ ActiveRecord::Schema.define(version: 2019_11_19_030244) do t.integer "median_days_to_first_harvest" t.integer "median_days_to_last_harvest" t.jsonb "openfarm_data" + t.integer "harvests_count", default: 0 + t.integer "photo_associations_count", default: 0 t.index ["name"], name: "index_crops_on_name" t.index ["requester_id"], name: "index_crops_on_requester_id" t.index ["slug"], name: "index_crops_on_slug", unique: true @@ -458,6 +460,7 @@ ActiveRecord::Schema.define(version: 2019_11_19_030244) do t.datetime "created_at" t.datetime "updated_at" t.string "slug" + t.integer "harvests_count", default: 0 end create_table "plantings", id: :serial, force: :cascade do |t| @@ -491,6 +494,7 @@ ActiveRecord::Schema.define(version: 2019_11_19_030244) do t.string "slug" t.integer "forum_id" t.integer "likes_count", default: 0 + t.integer "comments_count", default: 0 t.index ["created_at", "author_id"], name: "index_posts_on_created_at_and_author_id" t.index ["slug"], name: "index_posts_on_slug", unique: true end From a7e915621e69304aa98b438cbbedaa2d85c70ef7 Mon Sep 17 00:00:00 2001 From: Brenda Date: Thu, 26 Dec 2019 18:12:15 +1300 Subject: [PATCH 110/188] Index into elastic during db migration --- ...0191209202348_add_harvest_count_to_crop.rb | 66 ------------------- db/migrate/20191226051019_elastic_indexing.rb | 16 +++++ db/schema.rb | 6 +- 3 files changed, 17 insertions(+), 71 deletions(-) delete mode 100644 db/migrate/20191209202348_add_harvest_count_to_crop.rb create mode 100644 db/migrate/20191226051019_elastic_indexing.rb diff --git a/db/migrate/20191209202348_add_harvest_count_to_crop.rb b/db/migrate/20191209202348_add_harvest_count_to_crop.rb deleted file mode 100644 index 46b5f0737..000000000 --- a/db/migrate/20191209202348_add_harvest_count_to_crop.rb +++ /dev/null @@ -1,66 +0,0 @@ -# frozen_string_literal: true - -class AddHarvestCountToCrop < ActiveRecord::Migration[5.2] - def change - change_table :crops do |t| - t.integer :harvests_count, default: 0 - t.integer :photo_associations_count, default: 0 - end - change_table :plant_parts do |t| - t.integer :harvests_count, default: 0 - end - change_table :posts do |t| - t.integer :comments_count, default: 0 - end - reversible do |dir| - dir.up { data } - end - end - - def data - execute <<-SQL.squish - UPDATE crops - SET harvests_count = ( - SELECT count(1) - FROM harvests - WHERE harvests.crop_id = crops.id - ) - SQL - execute <<-SQL.squish - UPDATE crops - SET photo_associations_count = ( - SELECT count(1) - FROM photo_associations - WHERE photo_associations.crop_id = crops.id - ) - SQL - execute <<-SQL.squish - UPDATE plant_parts - SET harvests_count = ( - SELECT count(1) - FROM harvests - WHERE harvests.plant_part_id = plant_parts.id - ) - SQL - - execute <<-SQL.squish - UPDATE posts - SET comments_count = ( - SELECT count(1) - FROM comments - WHERE comments.post_id = posts.id - ) - SQL - - say 'indexing crops' - Crop.reindex - say 'indexing plantings' - Planting.reindex - say 'indexing seeds' - Seed.reindex - say 'indexing harvests' - Harvest.reindex - say 'indexing photos' - Photo.reindex - end -end diff --git a/db/migrate/20191226051019_elastic_indexing.rb b/db/migrate/20191226051019_elastic_indexing.rb new file mode 100644 index 000000000..b1f357433 --- /dev/null +++ b/db/migrate/20191226051019_elastic_indexing.rb @@ -0,0 +1,16 @@ +class ElasticIndexing < ActiveRecord::Migration[5.2] + def up + say 'indexing crops' + Crop.reindex + say 'indexing plantings' + Planting.reindex + say 'indexing seeds' + Seed.reindex + say 'indexing harvests' + Harvest.reindex + say 'indexing photos' + Photo.reindex + end + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index a701305f5..2b9dceff2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_12_09_202348) do +ActiveRecord::Schema.define(version: 2019_12_26_051019) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -196,8 +196,6 @@ ActiveRecord::Schema.define(version: 2019_12_09_202348) do t.integer "median_days_to_first_harvest" t.integer "median_days_to_last_harvest" t.jsonb "openfarm_data" - t.integer "harvests_count", default: 0 - t.integer "photo_associations_count", default: 0 t.index ["name"], name: "index_crops_on_name" t.index ["requester_id"], name: "index_crops_on_requester_id" t.index ["slug"], name: "index_crops_on_slug", unique: true @@ -460,7 +458,6 @@ ActiveRecord::Schema.define(version: 2019_12_09_202348) do t.datetime "created_at" t.datetime "updated_at" t.string "slug" - t.integer "harvests_count", default: 0 end create_table "plantings", id: :serial, force: :cascade do |t| @@ -494,7 +491,6 @@ ActiveRecord::Schema.define(version: 2019_12_09_202348) do t.string "slug" t.integer "forum_id" t.integer "likes_count", default: 0 - t.integer "comments_count", default: 0 t.index ["created_at", "author_id"], name: "index_posts_on_created_at_and_author_id" t.index ["slug"], name: "index_posts_on_slug", unique: true end From 9a704bacfcf2469cf93c51ddbb9e4249336c6254 Mon Sep 17 00:00:00 2001 From: Brenda Date: Thu, 26 Dec 2019 18:12:37 +1300 Subject: [PATCH 111/188] no counter cache on many to many association harvest->photos --- app/models/concerns/search_harvests.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/search_harvests.rb b/app/models/concerns/search_harvests.rb index cd6e481c8..ea8550a8f 100644 --- a/app/models/concerns/search_harvests.rb +++ b/app/models/concerns/search_harvests.rb @@ -26,7 +26,7 @@ module SearchHarvests owner_id: owner_id, owner_slug: owner_slug, owner_login_name: owner_login_name, - photos_count: photos_count, + photos_count: photos.count, plant_part: plant_part&.name, planting_id: planting_id, quantity: quantity, From 2c2d7875211089d250cb53ef6325fe7c4c9489fd Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 26 Dec 2019 05:13:22 +0000 Subject: [PATCH 112/188] [CodeFactor] Apply fixes --- db/migrate/20191226051019_elastic_indexing.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/migrate/20191226051019_elastic_indexing.rb b/db/migrate/20191226051019_elastic_indexing.rb index b1f357433..a1c37885a 100644 --- a/db/migrate/20191226051019_elastic_indexing.rb +++ b/db/migrate/20191226051019_elastic_indexing.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ElasticIndexing < ActiveRecord::Migration[5.2] def up say 'indexing crops' @@ -11,6 +13,6 @@ class ElasticIndexing < ActiveRecord::Migration[5.2] say 'indexing photos' Photo.reindex end - def down - end + + def down; end end From e3a789c15e436b044da5bedc69473beb14e7ca76 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 26 Dec 2019 23:15:38 +1300 Subject: [PATCH 113/188] indexed items matching database attributes --- app/models/concerns/finishable.rb | 2 +- app/models/concerns/photo_capable.rb | 4 ++++ app/models/concerns/search_crops.rb | 2 +- app/models/concerns/search_plantings.rb | 2 +- app/views/plantings/_progress.html.haml | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/models/concerns/finishable.rb b/app/models/concerns/finishable.rb index 6ff68e9c5..d4a4488dc 100644 --- a/app/models/concerns/finishable.rb +++ b/app/models/concerns/finishable.rb @@ -7,7 +7,7 @@ module Finishable scope :finished, -> { where(finished: true) } scope :current, -> { where.not(finished: true) } - def active? + def active !finished end end diff --git a/app/models/concerns/photo_capable.rb b/app/models/concerns/photo_capable.rb index b585d4b6b..94228047f 100644 --- a/app/models/concerns/photo_capable.rb +++ b/app/models/concerns/photo_capable.rb @@ -15,6 +15,10 @@ module PhotoCapable end end + def thumbnail_url + default_photo ? default_photos.thumbnail_url : nil + end + def most_liked_photo photos.order(likes_count: :desc, created_at: :desc).first end diff --git a/app/models/concerns/search_crops.rb b/app/models/concerns/search_crops.rb index aaec73136..347fd02be 100644 --- a/app/models/concerns/search_crops.rb +++ b/app/models/concerns/search_crops.rb @@ -39,7 +39,7 @@ module SearchCrops # boost this crop for these members planters_ids: plantings.pluck(:owner_id), has_photos: photos.size.positive?, - thumbnail_url: default_photo&.thumbnail_url, + thumbnail_url: thumbnail_url, scientific_name: default_scientific_name&.name, created_at: created_at.to_i } diff --git a/app/models/concerns/search_plantings.rb b/app/models/concerns/search_plantings.rb index bdf8dc788..064c869c1 100644 --- a/app/models/concerns/search_plantings.rb +++ b/app/models/concerns/search_plantings.rb @@ -20,7 +20,7 @@ module SearchPlantings def search_data { slug: slug, - active: active?, + active: active, crop_id: crop_id, crop_name: crop.name, crop_slug: crop.slug, diff --git a/app/views/plantings/_progress.html.haml b/app/views/plantings/_progress.html.haml index a61233f3e..692488457 100644 --- a/app/views/plantings/_progress.html.haml +++ b/app/views/plantings/_progress.html.haml @@ -1,4 +1,4 @@ -- if planting.active? && planting.annual? && planting.percentage_grown.present? +- if planting.active && planting.annual? && planting.percentage_grown.present? .progress .progress-bar.bg-success{"aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => planting.percentage_grown, role: "progressbar", style: "width: #{planting.percentage_grown}%"} From 9e0f35b22be6e1cc26ea5236764e076fb1319295 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 26 Dec 2019 23:22:12 +1300 Subject: [PATCH 114/188] fixing plantings rss feed --- app/views/plantings/index.rss.haml | 2 +- spec/views/plantings/index.rss.haml_spec.rb | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/views/plantings/index.rss.haml b/app/views/plantings/index.rss.haml index 036e59fd9..fd7a467e8 100644 --- a/app/views/plantings/index.rss.haml +++ b/app/views/plantings/index.rss.haml @@ -6,7 +6,7 @@ %link= plantings_url - @plantings.each do |planting| %item - %title #{planting['crop']} in #{planting['location']} + %title #{planting['crop_name']} in #{planting['location']} %pubdate= planting['created_at'].to_s(:rfc822) %description :escaped diff --git a/spec/views/plantings/index.rss.haml_spec.rb b/spec/views/plantings/index.rss.haml_spec.rb index 6361aaf4b..6592f9919 100644 --- a/spec/views/plantings/index.rss.haml_spec.rb +++ b/spec/views/plantings/index.rss.haml_spec.rb @@ -22,11 +22,7 @@ describe 'plantings/index.rss.haml', :search do end it 'item title shows owner and location' do - expect(rendered).to have_content "#{@planting.crop} in #{@planting.location}" - end - - it 'shows formatted content of posts' do - expect(rendered).to have_content "This is a really good plant." + expect(rendered).to have_content "#{@planting.crop.name} in #{@planting.location}" end it 'shows sunniness' do From fc152feebb5190eca583c9bd5a4eef860029bf14 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 26 Dec 2019 23:53:26 +1300 Subject: [PATCH 115/188] Update _quick_actions.haml --- app/views/plantings/_quick_actions.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/plantings/_quick_actions.haml b/app/views/plantings/_quick_actions.haml index 61d173ef2..74ac39314 100644 --- a/app/views/plantings/_quick_actions.haml +++ b/app/views/plantings/_quick_actions.haml @@ -6,7 +6,7 @@ %li= planting_edit_button(planting, classes: 'dropdown-item') %li= add_photo_button(planting, classes: 'dropdown-item') - - if planting.active? + - if planting.active %li= planting_finish_button(planting, classes: 'dropdown-item') %li= planting_harvest_button(planting, classes: 'dropdown-item') %li= planting_save_seeds_button(planting, classes: 'dropdown-item') From f4b87672b13675743f6c3dd58db19e58ae2122db Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 27 Dec 2019 00:11:46 +1300 Subject: [PATCH 116/188] Update _actions.html.haml --- app/views/plantings/_actions.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index e974526af..aa58542e3 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -4,7 +4,7 @@ .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "planting-actions-button"} = planting_edit_button(planting, classes: 'dropdown-item') = add_photo_button(planting, classes: 'dropdown-item') - - if planting.active? + - if planting.active = planting_finish_button(planting, classes: 'dropdown-item') = planting_harvest_button(planting, classes: 'dropdown-item') = planting_save_seeds_button(planting, classes: 'dropdown-item') From 6c7bd777645c51ae2af6a78ec6098c60b33e39b6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 27 Dec 2019 00:14:05 +1300 Subject: [PATCH 117/188] Update photo_capable.rb --- app/models/concerns/photo_capable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/photo_capable.rb b/app/models/concerns/photo_capable.rb index 94228047f..3144ec283 100644 --- a/app/models/concerns/photo_capable.rb +++ b/app/models/concerns/photo_capable.rb @@ -16,7 +16,7 @@ module PhotoCapable end def thumbnail_url - default_photo ? default_photos.thumbnail_url : nil + default_photo ? default_photo.thumbnail_url : nil end def most_liked_photo From 2d7951d85fe0d60743298bf0debd1049ccf7f62e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 27 Dec 2019 00:15:05 +1300 Subject: [PATCH 118/188] Update buttons_helper.rb --- app/helpers/buttons_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index ca5cc5d78..9cc5e11c6 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -89,7 +89,7 @@ module ButtonsHelper end def planting_harvest_button(planting, classes: 'btn btn-default') - return unless planting.active? && can?(:create, Harvest) && can?(:edit, planting) + return unless planting.active && can?(:create, Harvest) && can?(:edit, planting) link_to new_planting_harvest_path(planting), class: classes do harvest_icon + ' ' + t('buttons.record_harvest') From c6d6c3cb5cc14d8d1c641b0067cc0da59580720a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 27 Dec 2019 09:04:51 +1300 Subject: [PATCH 119/188] fixed link in seed card --- app/views/seeds/_card.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index 6b4cd8527..246629450 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -1,6 +1,6 @@ - cache seed do .card.seed-card{class: seed.finished ? 'card-finished' : ''} - = link_to seed do + = link_to seed_path(slug: seed.slug) do = image_tag(seed.thumbnail_url ? seed.thumbnail_url : placeholder_image, alt: seed.name, class: 'img-card') .text %span.chip.member-chip From 23886de24bcddf681ee446795b25bff9a239a328 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 27 Dec 2019 09:07:47 +1300 Subject: [PATCH 120/188] revert plantings#index spec --- spec/views/plantings/index.html.haml_spec.rb | 43 +++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index 095520650..c6a0ae446 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -15,28 +15,23 @@ describe "plantings/index" do total_entries = 3 plantings = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| pager.replace([ - { - 'crop_name' => tomato.name, - 'slug' => 'tomato-1', - 'owner_name' => member.login_name, - 'owner_slug' => member.slug - }, - { - 'crop_name' => maize.name, - 'slug' => 'maize', - 'owner_name' => garden.owner.login_name, - 'owner_slug' => garden.owner.slug, - 'planted_at' => Time.zone.local(2013, 1, 13) - }, - { - 'crop_name' => tomato.name, - 'slug' => 'tomato-2', - 'owner_name' => garden.owner.login_name, - 'owner_slug' => garden.owner.slug, - 'planted_at' => Time.zone.local(2013, 1, 13), - 'finished_at' => Time.zone.local(2013, 1, 20), - 'finished' => true - } + FactoryBot.create(:planting, + garden: garden, + crop: tomato, + owner: member), + FactoryBot.create(:planting, + garden: garden, + crop: maize, + owner: garden.owner, + description: '', + planted_at: Time.zone.local(2013, 1, 13)), + FactoryBot.create(:planting, + garden: garden, + owner: garden.owner, + crop: tomato, + planted_at: Time.zone.local(2013, 1, 13), + finished_at: Time.zone.local(2013, 1, 20), + finished: true) ]) end assign(:plantings, plantings) @@ -44,8 +39,8 @@ describe "plantings/index" do end describe "renders a list of plantings" do - it { expect(rendered).to have_content 'tomato' } - it { expect(rendered).to have_content 'maize' } + it { expect(rendered).to have_content tomato.name } + it { expect(rendered).to have_content maize.name } end it "provides data links" do From 0d08f48b71a053dcad9b49a1719f600250499321 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 27 Dec 2019 09:15:53 +1300 Subject: [PATCH 121/188] turn on ES indexing in some controllers --- dev.diff | 7902 +++++++++++++++++ spec/controllers/harvests_controller_spec.rb | 2 +- spec/controllers/photos_controller_spec.rb | 2 +- spec/controllers/plantings_controller_spec.rb | 2 +- spec/controllers/seeds_controller_spec.rb | 2 +- 5 files changed, 7906 insertions(+), 4 deletions(-) create mode 100644 dev.diff diff --git a/dev.diff b/dev.diff new file mode 100644 index 000000000..8555de953 --- /dev/null +++ b/dev.diff @@ -0,0 +1,7902 @@ +diff --git a/.rubocop.yml b/.rubocop.yml +index 355a14ac..9472c891 100644 +--- a/.rubocop.yml ++++ b/.rubocop.yml +@@ -4,7 +4,7 @@ AllCops: + Exclude: + - 'db/schema.rb' + - 'vendor/**/*' +- TargetRailsVersion: 5.0 ++ TargetRailsVersion: 5.2 + + Rails: + Enabled: true +@@ -15,15 +15,6 @@ Naming/FileName: + - 'Gemfile' + - 'Gemfile.lock' + +-Style/StringLiterals: +- Enabled: false +- +-Style/PercentLiteralDelimiters: +- PreferredDelimiters: +- default: () +- '%i': () +- '%w': () +- + Layout/MultilineMethodCallIndentation: + EnforcedStyle: indented + +@@ -36,11 +27,16 @@ Layout/HashAlignment: + Layout/ParameterAlignment: + EnforcedStyle: with_fixed_indentation + +- +-Style/Documentation: ++Style/StringLiterals: + Enabled: false + +-Style/FrozenStringLiteralComment: ++Style/PercentLiteralDelimiters: ++ PreferredDelimiters: ++ default: () ++ '%i': () ++ '%w': () ++ ++Style/Documentation: + Enabled: false + + # Configuration parameters: Include. +@@ -56,22 +52,9 @@ Metrics/BlockLength: + - '**/*.rake' + - 'config/**/*.rb' + +-Metrics/LineLength: ++Layout/LineLength: + Max: 140 + +-# Remove the following once the code style matches +-Metrics/MethodLength: +- Max: 34 +-Metrics/AbcSize: +- Max: 33 +-# Configuration parameters: CountComments. +-Metrics/ClassLength: +- Max: 171 +-Metrics/CyclomaticComplexity: +- Max: 8 +-Metrics/PerceivedComplexity: +- Max: 9 +- + # Places we use update_all, etc even though it skips validations. + Rails/SkipsModelValidations: + Exclude: +diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml +index 906cc547..91e33b14 100644 +--- a/.rubocop_todo.yml ++++ b/.rubocop_todo.yml +@@ -10,48 +10,6 @@ Lint/AmbiguousOperator: + Exclude: + - 'spec/controllers/crops_controller_spec.rb' + +-# Configuration parameters: AllowComments. +-Lint/SuppressedException: +- Exclude: +- - 'lib/tasks/testing.rake' +- +-Lint/UselessAssignment: +- Exclude: +- - 'config.rb' +- - 'config/compass.rb' +- +-Metrics/AbcSize: +- Max: 125 +- +-# Configuration parameters: CountComments, ExcludedMethods. +-# ExcludedMethods: refine +-Metrics/BlockLength: +- Max: 59 +- +-# Configuration parameters: CountComments. +-Metrics/ClassLength: +- Max: 186 +- +-Metrics/CyclomaticComplexity: +- Max: 29 +- +-# Cop supports --auto-correct. +-# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +-# URISchemes: http, https +-Metrics/LineLength: +- Max: 341 +- +-# Configuration parameters: CountComments, ExcludedMethods. +-Metrics/MethodLength: +- Max: 106 +- +-# Configuration parameters: CountComments. +-Metrics/ModuleLength: +- Max: 107 +- +-Metrics/PerceivedComplexity: +- Max: 29 +- + # Configuration parameters: EnforcedStyle. + # SupportedStyles: lowercase, uppercase + Naming/HeredocDelimiterCase: +diff --git a/app/controllers/admin/members_controller.rb b/app/controllers/admin/members_controller.rb +index 0526a57c..cf10b5c0 100644 +--- a/app/controllers/admin/members_controller.rb ++++ b/app/controllers/admin/members_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Admin + class MembersController < ApplicationController + before_action :admin! +diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb +index d08c292d..3ad46e6a 100644 +--- a/app/controllers/admin/roles_controller.rb ++++ b/app/controllers/admin/roles_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Admin + class RolesController < ApplicationController + before_action :admin! +diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb +index 54156743..454faf1c 100644 +--- a/app/controllers/admin_controller.rb ++++ b/app/controllers/admin_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AdminController < ApplicationController + respond_to :html + def index +diff --git a/app/controllers/alternate_names_controller.rb b/app/controllers/alternate_names_controller.rb +index 3466f72a..922c078c 100644 +--- a/app/controllers/alternate_names_controller.rb ++++ b/app/controllers/alternate_names_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AlternateNamesController < ApplicationController + before_action :authenticate_member!, except: %i(index) + load_and_authorize_resource +diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb +index 4fbc4d80..84eb42dc 100644 +--- a/app/controllers/api/v1/base_controller.rb ++++ b/app/controllers/api/v1/base_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Api + module V1 + class BaseController < JSONAPI::ResourceController +diff --git a/app/controllers/api/v1/crops_controller.rb b/app/controllers/api/v1/crops_controller.rb +index d67beaa1..f75516a4 100644 +--- a/app/controllers/api/v1/crops_controller.rb ++++ b/app/controllers/api/v1/crops_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Api + module V1 + class CropsController < BaseController +diff --git a/app/controllers/api/v1/gardens_controller.rb b/app/controllers/api/v1/gardens_controller.rb +index 4343d801..ff420cf6 100644 +--- a/app/controllers/api/v1/gardens_controller.rb ++++ b/app/controllers/api/v1/gardens_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Api + module V1 + class GardensController < BaseController +diff --git a/app/controllers/api/v1/harvests_controller.rb b/app/controllers/api/v1/harvests_controller.rb +index bcf735dc..1bef4212 100644 +--- a/app/controllers/api/v1/harvests_controller.rb ++++ b/app/controllers/api/v1/harvests_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Api + module V1 + class HarvestsController < BaseController +diff --git a/app/controllers/api/v1/members_controller.rb b/app/controllers/api/v1/members_controller.rb +index b9b99956..7f08067e 100644 +--- a/app/controllers/api/v1/members_controller.rb ++++ b/app/controllers/api/v1/members_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Api + module V1 + class MembersController < BaseController +diff --git a/app/controllers/api/v1/photos_controller.rb b/app/controllers/api/v1/photos_controller.rb +index a095d24c..693edd1f 100644 +--- a/app/controllers/api/v1/photos_controller.rb ++++ b/app/controllers/api/v1/photos_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Api + module V1 + class PhotosController < BaseController +diff --git a/app/controllers/api/v1/plantings_controller.rb b/app/controllers/api/v1/plantings_controller.rb +index d143676a..dc2bc689 100644 +--- a/app/controllers/api/v1/plantings_controller.rb ++++ b/app/controllers/api/v1/plantings_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Api + module V1 + class PlantingsController < BaseController +diff --git a/app/controllers/api/v1/seeds_controller.rb b/app/controllers/api/v1/seeds_controller.rb +index 43f5691c..53722ea6 100644 +--- a/app/controllers/api/v1/seeds_controller.rb ++++ b/app/controllers/api/v1/seeds_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Api + module V1 + class SeedsController < BaseController +diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb +index ceafaa6c..58c3ec35 100644 +--- a/app/controllers/application_controller.rb ++++ b/app/controllers/application_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ApplicationController < ActionController::Base + protect_from_forgery + +@@ -5,9 +7,8 @@ class ApplicationController < ActionController::Base + + after_action :store_location + before_action :set_locale +- + rescue_from ActiveRecord::RecordNotFound, with: :not_found +- # CanCan error handling ++ + def store_location + unless request.path.in?(["/members/sign_in", + "/members/sign_up", +diff --git a/app/controllers/authentications_controller.rb b/app/controllers/authentications_controller.rb +index fc18ff4d..31056c6e 100644 +--- a/app/controllers/authentications_controller.rb ++++ b/app/controllers/authentications_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require './lib/actions/oauth_signup_action' + class AuthenticationsController < ApplicationController + before_action :authenticate_member! +diff --git a/app/controllers/charts/crops_controller.rb b/app/controllers/charts/crops_controller.rb +index 9626a76b..a48ec1ab 100644 +--- a/app/controllers/charts/crops_controller.rb ++++ b/app/controllers/charts/crops_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Charts + class CropsController < ApplicationController + respond_to :json +diff --git a/app/controllers/charts/gardens_controller.rb b/app/controllers/charts/gardens_controller.rb +index b9d25bb5..5ca9a03b 100644 +--- a/app/controllers/charts/gardens_controller.rb ++++ b/app/controllers/charts/gardens_controller.rb +@@ -1,9 +1,11 @@ ++# frozen_string_literal: true ++ + module Charts + class GardensController < ApplicationController + respond_to :json + def timeline + @data = [] +- @garden = Garden.find(params[:garden_id]) ++ @garden = Garden.find(params[:garden_slug]) + @garden.plantings.where.not(planted_at: nil) + .order(finished_at: :desc).each do |p| + # use finished_at if we have it, otherwise use predictions +diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb +index d47dae87..37f2a5b1 100644 +--- a/app/controllers/comments_controller.rb ++++ b/app/controllers/comments_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CommentsController < ApplicationController + before_action :authenticate_member!, except: %i(index) + load_and_authorize_resource +diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb +index e5da3be9..14b51e8f 100644 +--- a/app/controllers/conversations_controller.rb ++++ b/app/controllers/conversations_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ConversationsController < ApplicationController + respond_to :html + before_action :authenticate_member! +diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb +index 99c702e7..994ffe19 100644 +--- a/app/controllers/crops_controller.rb ++++ b/app/controllers/crops_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'will_paginate/array' + + class CropsController < ApplicationController +@@ -9,7 +11,7 @@ class CropsController < ApplicationController + + def index + @sort = params[:sort] +- @crops = crops ++ @crops = Crop.search('*', boost_by: %i(plantings_count harvests_count), limit: 100, page: params[:page], load: false) + @num_requested_crops = requested_crops.size if current_member + @filename = filename + respond_with @crops +@@ -213,13 +215,6 @@ class CropsController < ApplicationController + } + end + +- def crops +- q = Crop.approved.includes(:scientific_names, plantings: :photos) +- q = q.popular unless @sort == 'alpha' +- q.order(Arel.sql("LOWER(crops.name)")) +- .includes(:photos).paginate(page: params[:page]) +- end +- + def requested_crops + current_member.requested_crops.pending_approval + end +diff --git a/app/controllers/data_controller.rb b/app/controllers/data_controller.rb +new file mode 100644 +index 00000000..fece1f68 +--- /dev/null ++++ b/app/controllers/data_controller.rb +@@ -0,0 +1,13 @@ ++# frozen_string_literal: true ++ ++class DataController < ApplicationController ++ abstract ++ before_action :authenticate_member!, except: %i(index show) ++ load_and_authorize_resource id_param: :slug ++ ++ after_action :expire_homepage, only: %i(create update destroy) ++ ++ respond_to :html, :json ++ respond_to :csv, :rss, only: [:index] ++ responders :flash ++end +diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb +index 1555a4a7..2caf0f33 100644 +--- a/app/controllers/follows_controller.rb ++++ b/app/controllers/follows_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class FollowsController < ApplicationController + before_action :set_member, only: %i(index followers) + load_and_authorize_resource +diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb +index df6d1cad..bc75da5f 100644 +--- a/app/controllers/forums_controller.rb ++++ b/app/controllers/forums_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ForumsController < ApplicationController + load_and_authorize_resource + respond_to :html, :json +diff --git a/app/controllers/garden_types_controller.rb b/app/controllers/garden_types_controller.rb +index 5fade528..567af80f 100644 +--- a/app/controllers/garden_types_controller.rb ++++ b/app/controllers/garden_types_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class GardenTypesController < ApplicationController + respond_to :html, :json + load_and_authorize_resource +diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb +index 333fa454..5ef4be12 100644 +--- a/app/controllers/gardens_controller.rb ++++ b/app/controllers/gardens_controller.rb +@@ -1,10 +1,6 @@ +-class GardensController < ApplicationController +- before_action :authenticate_member!, except: %i(index show) +- after_action :expire_homepage, only: %i(create destroy) +- load_and_authorize_resource +- responders :flash +- respond_to :html, :json ++# frozen_string_literal: true + ++class GardensController < DataController + def index + @owner = Member.find_by(slug: params[:member_slug]) + @show_all = params[:all] == '1' +diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb +index c474e267..c618b974 100644 +--- a/app/controllers/harvests_controller.rb ++++ b/app/controllers/harvests_controller.rb +@@ -1,20 +1,31 @@ +-class HarvestsController < ApplicationController +- before_action :authenticate_member!, except: %i(index show) ++# frozen_string_literal: true ++ ++class HarvestsController < DataController + after_action :update_crop_medians, only: %i(create update destroy) +- load_and_authorize_resource +- respond_to :html, :json +- respond_to :csv, :rss, only: :index +- responders :flash + + def index +- @owner = Member.find_by(slug: params[:member_slug]) +- @crop = Crop.find_by(slug: params[:crop_slug]) +- @planting = Planting.find_by(slug: params[:planting_id]) +- +- @harvests = @harvests.where(owner: @owner) if @owner.present? +- @harvests = @harvests.where(crop: @crop) if @crop.present? +- @harvests = @harvests.where(planting: @planting) if @planting.present? +- @harvests = @harvests.order(harvested_at: :desc).joins(:owner, :crop).paginate(page: params[:page]) ++ where = {} ++ if params[:member_slug] ++ @owner = Member.find_by(slug: params[:member_slug]) ++ where['owner_id'] = @owner.id ++ end ++ ++ if params[:crop_slug] ++ @crop = Crop.find_by(slug: params[:crop_slug]) ++ where['crop_id'] = @crop.id ++ end ++ ++ if params[:planting_slug] ++ @planting = Planting.find_by(slug: params[:planting_slug]) ++ where['planting_id'] = @planting.id ++ end ++ ++ @harvests = Harvest.search('*', ++ where: where, ++ limit: 100, ++ page: params[:page], ++ load: false, ++ boost_by: [:created_at]) + + @filename = csv_filename + +diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb +index 1241c70f..e5ff4d06 100644 +--- a/app/controllers/home_controller.rb ++++ b/app/controllers/home_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class HomeController < ApplicationController + skip_authorize_resource + respond_to :html +diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb +index 501bc6ee..37d302fc 100644 +--- a/app/controllers/likes_controller.rb ++++ b/app/controllers/likes_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class LikesController < ApplicationController + before_action :authenticate_member! + respond_to :html, :json +diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb +index 0d07b303..9b65068d 100644 +--- a/app/controllers/members_controller.rb ++++ b/app/controllers/members_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class MembersController < ApplicationController + load_and_authorize_resource except: %i(finish_signup unsubscribe view_follows view_followers show) + skip_authorize_resource only: %i(nearby unsubscribe finish_signup) +diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb +index 21bb4d0b..9efc7ae4 100644 +--- a/app/controllers/messages_controller.rb ++++ b/app/controllers/messages_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class MessagesController < ApplicationController + respond_to :html, :json + before_action :authenticate_member! +diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb +index 3d642cd3..c9243c89 100644 +--- a/app/controllers/omniauth_callbacks_controller.rb ++++ b/app/controllers/omniauth_callbacks_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require './lib/actions/oauth_signup_action' + + # +diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb +index 9ffb98af..4da0321d 100644 +--- a/app/controllers/pages_controller.rb ++++ b/app/controllers/pages_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class PagesController < ApplicationController + def letsencrypt + # use your code here, not mine +diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb +index fb6852ea..012cd352 100644 +--- a/app/controllers/passwords_controller.rb ++++ b/app/controllers/passwords_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class PasswordsController < Devise::PasswordsController + protected + +diff --git a/app/controllers/photo_associations_controller.rb b/app/controllers/photo_associations_controller.rb +index 499dbefc..00655a73 100644 +--- a/app/controllers/photo_associations_controller.rb ++++ b/app/controllers/photo_associations_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class PhotoAssociationsController < ApplicationController + before_action :authenticate_member! + respond_to :json, :html +diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb +index c6243ad2..d168488b 100644 +--- a/app/controllers/photos_controller.rb ++++ b/app/controllers/photos_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class PhotosController < ApplicationController + before_action :authenticate_member!, except: %i(index show) + after_action :expire_homepage, only: %i(create destroy) +@@ -11,18 +13,20 @@ class PhotosController < ApplicationController + end + + def index ++ where = {} + if params[:crop_slug] + @crop = Crop.find params[:crop_slug] +- @photos = Photo.by_crop(@crop) ++ where = { crop_id: @crop.id } + elsif params[:planting_id] + @planting = Planting.find params[:planting_id] +- @photos = @planting.photos +- else +- @photos = Photo.all ++ where = { planting_id: @planting.id } + end +- @photos = @photos.order(created_at: :desc) +- .includes(:owner) +- .paginate(page: params[:page]) ++ ++ @photos = Photo.search(load: false, ++ boost_by: [:created_at], ++ where: where, ++ page: params[:page], ++ limit: 50) + respond_with(@photos) + end + +diff --git a/app/controllers/places_controller.rb b/app/controllers/places_controller.rb +index 4586b5d3..a30c1ae9 100644 +--- a/app/controllers/places_controller.rb ++++ b/app/controllers/places_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class PlacesController < ApplicationController + skip_authorize_resource + respond_to :html, :json +diff --git a/app/controllers/plant_parts_controller.rb b/app/controllers/plant_parts_controller.rb +index 1e594fd7..8fbd23c5 100644 +--- a/app/controllers/plant_parts_controller.rb ++++ b/app/controllers/plant_parts_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class PlantPartsController < ApplicationController + load_and_authorize_resource + respond_to :html, :json +diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb +index ae01b499..7b6c9273 100644 +--- a/app/controllers/plantings_controller.rb ++++ b/app/controllers/plantings_controller.rb +@@ -1,29 +1,32 @@ +-class PlantingsController < ApplicationController +- before_action :authenticate_member!, except: %i(index show) +- after_action :expire_homepage, only: %i(create update destroy) ++# frozen_string_literal: true ++ ++class PlantingsController < DataController + after_action :update_crop_medians, only: %i(create update destroy) + after_action :update_planting_medians, only: :update +- load_and_authorize_resource +- +- respond_to :html, :json +- respond_to :csv, :rss, only: [:index] +- responders :flash + + def index +- @owner = Member.find_by(slug: params[:member_slug]) if params[:member_slug] +- @crop = Crop.find_by(slug: params[:crop_slug]) if params[:crop_slug] +- + @show_all = params[:all] == '1' + +- @plantings = @plantings.where(owner: @owner) if @owner.present? +- @plantings = @plantings.where(crop: @crop) if @crop.present? ++ where = {} ++ where['active'] = true unless @show_all + +- @plantings = @plantings.active unless params[:all] == '1' ++ if params[:member_slug] ++ @owner = Member.find_by(slug: params[:member_slug]) ++ where['owner_id'] = @owner.id ++ end + +- @plantings = @plantings.joins(:owner, :crop, :garden) +- .order(created_at: :desc) +- .includes(:owner, :garden, crop: :parent) +- .paginate(page: params[:page]) ++ if params[:crop_slug] ++ @crop = Crop.find_by(slug: params[:crop_slug]) ++ where['crop_id'] = @crop.id ++ end ++ ++ @plantings = Planting.search( ++ where: where, ++ page: params[:page], ++ limit: 30, ++ boost_by: [:created_at], ++ load: false ++ ) + + @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv" + +@@ -31,10 +34,16 @@ class PlantingsController < ApplicationController + end + + def show ++ @planting = Planting.includes(:owner, :crop, :garden) ++ .find(params[:slug]) + @photos = @planting.photos.includes(:owner).order(date_taken: :desc) ++ @harvests = Harvest.search(where: { planting_id: @planting.id }) + @matching_seeds = matching_seeds ++ ++ # TODO: use elastic search long/lat + @neighbours = @planting.nearby_same_crop + .where.not(id: @planting.id) ++ .includes(:owner, :crop, :garden) + .limit(6) + respond_with @planting + end +diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb +index d6561ce8..40a70fad 100644 +--- a/app/controllers/posts_controller.rb ++++ b/app/controllers/posts_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class PostsController < ApplicationController + before_action :authenticate_member!, except: %i(index show) + load_and_authorize_resource +diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb +index 24a8ee8e..53032123 100644 +--- a/app/controllers/registrations_controller.rb ++++ b/app/controllers/registrations_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class RegistrationsController < Devise::RegistrationsController + respond_to :json + +diff --git a/app/controllers/robots_controller.rb b/app/controllers/robots_controller.rb +index 84f77e90..7a000749 100644 +--- a/app/controllers/robots_controller.rb ++++ b/app/controllers/robots_controller.rb +@@ -1,5 +1,7 @@ ++# frozen_string_literal: true ++ + class RobotsController < ApplicationController +- DEFAULT_FILENAME = 'config/robots.txt'.freeze ++ DEFAULT_FILENAME = 'config/robots.txt' + + def robots + filename = "config/robots.#{subdomain}.txt" if subdomain && subdomain != 'www' +diff --git a/app/controllers/scientific_names_controller.rb b/app/controllers/scientific_names_controller.rb +index cf58fd4f..94a18acf 100644 +--- a/app/controllers/scientific_names_controller.rb ++++ b/app/controllers/scientific_names_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ScientificNamesController < ApplicationController + before_action :authenticate_member!, except: %i(index show) + load_and_authorize_resource +diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb +index b6457edb..eb7f94be 100644 +--- a/app/controllers/seeds_controller.rb ++++ b/app/controllers/seeds_controller.rb +@@ -1,20 +1,35 @@ +-class SeedsController < ApplicationController +- before_action :authenticate_member!, except: %i(index show) +- load_and_authorize_resource +- responders :flash +- respond_to :html, :json +- respond_to :csv, only: :index +- respond_to :rss, only: :index ++# frozen_string_literal: true + ++class SeedsController < DataController + def index +- @owner = Member.find_by(slug: params[:member_slug]) if params[:member_slug].present? +- @crop = Crop.find_by(slug: params[:crop_slug]) if params[:crop_slug].present? +- @planting = Planting.find_by(slug: params[:planting_id]) if params[:planting_id].present? ++ where = {} ++ ++ if params[:member_slug].present? ++ @owner = Member.find_by(slug: params[:member_slug]) ++ where['owner_id'] = @owner.id ++ end ++ ++ if params[:crop_slug].present? ++ @crop = Crop.find_by(slug: params[:crop_slug]) ++ where['crop_id'] = @crop.id ++ end ++ ++ if params[:planting_id].present? ++ @planting = Planting.find_by(slug: params[:planting_id]) ++ where['parent_planting'] = @planting.id ++ end + + @show_all = (params[:all] == '1') ++ where['finished'] = false unless @show_all + + @filename = csv_filename +- @seeds = seeds.order(created_at: :desc).includes(:owner, :crop).paginate(page: params[:page]) ++ @seeds = Seed.search( ++ where: where, ++ page: params[:page], ++ limit: 30, ++ boost_by: [:created_at], ++ load: false ++ ) + + respond_with(@seeds) + end +@@ -61,15 +76,6 @@ class SeedsController < ApplicationController + + private + +- def seeds +- records = Seed.all +- records = records.where(owner: @owner) if @owner.present? +- records = records.where(crop: @crop) if @crop.present? +- records = records.where(parent_planting: @planting) if @planting.present? +- records = records.active unless @show_all +- records +- end +- + def seed_params + params.require(:seed).permit( + :crop_id, :description, :quantity, :plant_before, +diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb +index b8de4b54..47063d75 100644 +--- a/app/controllers/sessions_controller.rb ++++ b/app/controllers/sessions_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class SessionsController < Devise::SessionsController + respond_to :html, :json + +diff --git a/app/controllers/timeline_controller.rb b/app/controllers/timeline_controller.rb +index da912e69..66248052 100644 +--- a/app/controllers/timeline_controller.rb ++++ b/app/controllers/timeline_controller.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class TimelineController < ApplicationController + def index + if current_member +diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb +index 4cdda2b9..0e3a9d86 100644 +--- a/app/helpers/application_helper.rb ++++ b/app/helpers/application_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module ApplicationHelper + def parse_date(str) + str ||= '' # Date.parse barfs on nil +diff --git a/app/helpers/auto_suggest_helper.rb b/app/helpers/auto_suggest_helper.rb +index 85a3f0cb..1b8521c8 100644 +--- a/app/helpers/auto_suggest_helper.rb ++++ b/app/helpers/auto_suggest_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module AutoSuggestHelper + def auto_suggest(resource, source, options = {}) + if options[:default] && !options[:default].new_record? +diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb +index 1c4eb530..ca5cc5d7 100644 +--- a/app/helpers/buttons_helper.rb ++++ b/app/helpers/buttons_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module ButtonsHelper + include IconsHelper + def garden_plant_something_button(garden, classes: "btn btn-default") +diff --git a/app/helpers/crops_helper.rb b/app/helpers/crops_helper.rb +index f307dc79..ead50b24 100644 +--- a/app/helpers/crops_helper.rb ++++ b/app/helpers/crops_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module CropsHelper + def display_seed_availability(member, crop) + seeds = member.seeds.where(crop: crop) +@@ -13,6 +15,6 @@ module CropsHelper + end + + def crop_ebay_seeds_url(crop) +- "https://rover.ebay.com/rover/1/705-53470-19255-0/1?icep_ff3=9&pub=5575213277&toolid=10001&campid=5337940151&customid=&icep_uq=#{CGI.escape crop.name}&icep_sellerId=&icep_ex_kw=&icep_sortBy=12&icep_catId=181003&icep_minPrice=&icep_maxPrice=&ipn=psmain&icep_vectorid=229515&kwid=902099&mtid=824&kw=lg" # rubocop:disable Metrics/LineLength ++ "https://rover.ebay.com/rover/1/705-53470-19255-0/1?icep_ff3=9&pub=5575213277&toolid=10001&campid=5337940151&customid=&icep_uq=#{CGI.escape crop.name}&icep_sellerId=&icep_ex_kw=&icep_sortBy=12&icep_catId=181003&icep_minPrice=&icep_maxPrice=&ipn=psmain&icep_vectorid=229515&kwid=902099&mtid=824&kw=lg" # rubocop:disable Layout/LineLength + end + end +diff --git a/app/helpers/editable_form_helper.rb b/app/helpers/editable_form_helper.rb +index 007eeb62..527baf5b 100644 +--- a/app/helpers/editable_form_helper.rb ++++ b/app/helpers/editable_form_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module EditableFormHelper + def editable(field_type, model, field, display_field:, collection: []) + render 'shared/editable/form', field_type: field_type, +diff --git a/app/helpers/event_helper.rb b/app/helpers/event_helper.rb +index f2ff4a5f..4bc8033b 100644 +--- a/app/helpers/event_helper.rb ++++ b/app/helpers/event_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module EventHelper + def in_weeks(days) + (days / 7.0).round +diff --git a/app/helpers/gardens_helper.rb b/app/helpers/gardens_helper.rb +index 1f50d18f..0ae6d180 100644 +--- a/app/helpers/gardens_helper.rb ++++ b/app/helpers/gardens_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module GardensHelper + def display_garden_description(garden) + if garden.description.nil? +diff --git a/app/helpers/harvests_helper.rb b/app/helpers/harvests_helper.rb +index ff1838ce..cce5a10f 100644 +--- a/app/helpers/harvests_helper.rb ++++ b/app/helpers/harvests_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module HarvestsHelper + def display_quantity(harvest) + human_quantity = display_human_quantity(harvest) +diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb +index 00eb9fc3..53ceb403 100644 +--- a/app/helpers/icons_helper.rb ++++ b/app/helpers/icons_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module IconsHelper + include FontAwesome::Sass::Rails::ViewHelpers + +diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb +index c1316806..9ae42c28 100644 +--- a/app/helpers/photos_helper.rb ++++ b/app/helpers/photos_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module PhotosHelper + def crop_image_path(crop) + thumbnail_url(crop.default_photo) +diff --git a/app/helpers/plantings_helper.rb b/app/helpers/plantings_helper.rb +index 4de9102e..3b977f65 100644 +--- a/app/helpers/plantings_helper.rb ++++ b/app/helpers/plantings_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module PlantingsHelper + def display_finished(planting) + if planting.finished_at.present? +diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb +index fd676e8d..ad4afd4b 100644 +--- a/app/helpers/posts_helper.rb ++++ b/app/helpers/posts_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module PostsHelper + def display_post_truncated(post) + length = 300 +diff --git a/app/helpers/seeds_helper.rb b/app/helpers/seeds_helper.rb +index ab9e28e7..e585a234 100644 +--- a/app/helpers/seeds_helper.rb ++++ b/app/helpers/seeds_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module SeedsHelper + def display_seed_quantity(seed) + if seed.quantity.nil? +diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb +index a009ace5..d92ffddc 100644 +--- a/app/jobs/application_job.rb ++++ b/app/jobs/application_job.rb +@@ -1,2 +1,4 @@ ++# frozen_string_literal: true ++ + class ApplicationJob < ActiveJob::Base + end +diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb +index 286b2239..d84cb6e7 100644 +--- a/app/mailers/application_mailer.rb ++++ b/app/mailers/application_mailer.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb +index d3ab4b2c..c9727be3 100644 +--- a/app/mailers/notifier.rb ++++ b/app/mailers/notifier.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class Notifier < ApplicationMailer + # include NotificationsHelper + default from: "Growstuff <#{ENV['GROWSTUFF_EMAIL']}>" +diff --git a/app/models/ability.rb b/app/models/ability.rb +index b2231e64..422c5454 100644 +--- a/app/models/ability.rb ++++ b/app/models/ability.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class Ability + include CanCan::Ability + +diff --git a/app/models/alternate_name.rb b/app/models/alternate_name.rb +index f40665b1..c9360213 100644 +--- a/app/models/alternate_name.rb ++++ b/app/models/alternate_name.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AlternateName < ApplicationRecord + belongs_to :crop + belongs_to :creator, class_name: 'Member', inverse_of: :created_alternate_names +diff --git a/app/models/application_record.rb b/app/models/application_record.rb +index e14f64e6..5d2c9a2e 100644 +--- a/app/models/application_record.rb ++++ b/app/models/application_record.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true + self.per_page = 36 +diff --git a/app/models/authentication.rb b/app/models/authentication.rb +index 91ecc8de..98a65a63 100644 +--- a/app/models/authentication.rb ++++ b/app/models/authentication.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class Authentication < ApplicationRecord + belongs_to :member + end +diff --git a/app/models/comment.rb b/app/models/comment.rb +index 62ebdde7..7b85f4c0 100644 +--- a/app/models/comment.rb ++++ b/app/models/comment.rb +@@ -1,6 +1,8 @@ ++# frozen_string_literal: true ++ + class Comment < ApplicationRecord + belongs_to :author, class_name: 'Member', inverse_of: :comments +- belongs_to :post ++ belongs_to :post, counter_cache: true + + scope :post_order, -> { reorder("created_at ASC") } # for display on post page + +diff --git a/app/models/concerns/finishable.rb b/app/models/concerns/finishable.rb +index 42fa4e73..6ff68e9c 100644 +--- a/app/models/concerns/finishable.rb ++++ b/app/models/concerns/finishable.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Finishable + extend ActiveSupport::Concern + +diff --git a/app/models/concerns/likeable.rb b/app/models/concerns/likeable.rb +index 9db3da6e..911317a6 100644 +--- a/app/models/concerns/likeable.rb ++++ b/app/models/concerns/likeable.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Likeable + extend ActiveSupport::Concern + +diff --git a/app/models/concerns/member_flickr.rb b/app/models/concerns/member_flickr.rb +index d5d591dc..363f74d9 100644 +--- a/app/models/concerns/member_flickr.rb ++++ b/app/models/concerns/member_flickr.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module MemberFlickr + extend ActiveSupport::Concern + +diff --git a/app/models/concerns/member_newsletter.rb b/app/models/concerns/member_newsletter.rb +index 882bac7c..8f92340c 100644 +--- a/app/models/concerns/member_newsletter.rb ++++ b/app/models/concerns/member_newsletter.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module MemberNewsletter + extend ActiveSupport::Concern + +diff --git a/app/models/concerns/open_farm_data.rb b/app/models/concerns/open_farm_data.rb +index e7d2306e..f051d43c 100644 +--- a/app/models/concerns/open_farm_data.rb ++++ b/app/models/concerns/open_farm_data.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module OpenFarmData + extend ActiveSupport::Concern + +diff --git a/app/models/concerns/ownable.rb b/app/models/concerns/ownable.rb +index 6cd40a2e..8dac572a 100644 +--- a/app/models/concerns/ownable.rb ++++ b/app/models/concerns/ownable.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Ownable + extend ActiveSupport::Concern + +diff --git a/app/models/concerns/photo_capable.rb b/app/models/concerns/photo_capable.rb +index f96258f8..b585d4b6 100644 +--- a/app/models/concerns/photo_capable.rb ++++ b/app/models/concerns/photo_capable.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module PhotoCapable + extend ActiveSupport::Concern + +diff --git a/app/models/concerns/predict_harvest.rb b/app/models/concerns/predict_harvest.rb +index 4ea24153..bd11fc11 100644 +--- a/app/models/concerns/predict_harvest.rb ++++ b/app/models/concerns/predict_harvest.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module PredictHarvest + extend ActiveSupport::Concern + +diff --git a/app/models/concerns/predict_planting.rb b/app/models/concerns/predict_planting.rb +index a38b3582..9f1aee58 100644 +--- a/app/models/concerns/predict_planting.rb ++++ b/app/models/concerns/predict_planting.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module PredictPlanting + extend ActiveSupport::Concern + +diff --git a/app/models/concerns/crop_search.rb b/app/models/concerns/search_crops.rb +similarity index 67% +rename from app/models/concerns/crop_search.rb +rename to app/models/concerns/search_crops.rb +index edeffe36..aaec7313 100644 +--- a/app/models/concerns/crop_search.rb ++++ b/app/models/concerns/search_crops.rb +@@ -1,15 +1,20 @@ +-module CropSearch ++# frozen_string_literal: true ++ ++module SearchCrops + extend ActiveSupport::Concern + + included do + #################################### + # Elastic search configuration +- searchkick word_start: %i(name alternate_names scientific_names), ++ searchkick word_start: %i(name description alternate_names scientific_names), + case_sensitive: false, + merge_mappings: true, + mappings: { + properties: { +- created_at: { type: :integer } ++ created_at: { type: :integer }, ++ plantings_count: { type: :integer }, ++ harvests_count: { type: :integer }, ++ photos_count: { type: :integer } + } + } + +@@ -23,17 +28,19 @@ module CropSearch + def search_data + { + name: name, ++ description: description, + slug: 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, + # boost this crop for these members + planters_ids: plantings.pluck(:owner_id), + has_photos: photos.size.positive?, +- photo: default_photo&.thumbnail_url, ++ thumbnail_url: default_photo&.thumbnail_url, + scientific_name: default_scientific_name&.name, +- description: description, + created_at: created_at.to_i + } + end +diff --git a/app/models/concerns/search_harvests.rb b/app/models/concerns/search_harvests.rb +new file mode 100644 +index 00000000..cd6e481c +--- /dev/null ++++ b/app/models/concerns/search_harvests.rb +@@ -0,0 +1,49 @@ ++# frozen_string_literal: true ++ ++module SearchHarvests ++ extend ActiveSupport::Concern ++ ++ included do ++ searchkick merge_mappings: true, ++ mappings: { ++ properties: { ++ created_at: { type: :integer }, ++ harvests_count: { type: :integer }, ++ photos_count: { type: :integer }, ++ harvested_at: { type: :date } ++ } ++ } ++ ++ scope :search_import, -> { includes(:owner, :crop, :plant_part) } ++ ++ def search_data ++ { ++ slug: slug, ++ crop_id: crop_id, ++ crop_name: crop_name, ++ crop_slug: crop.slug, ++ has_photos: photos.size.positive?, ++ owner_id: owner_id, ++ owner_slug: owner_slug, ++ owner_login_name: owner_login_name, ++ photos_count: photos_count, ++ plant_part: plant_part&.name, ++ planting_id: planting_id, ++ quantity: quantity, ++ thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, ++ harvested_at: harvested_at, ++ created_at: created_at.to_i ++ } ++ end ++ ++ def self.homepage_records(limit) ++ search('*', ++ limit: limit, ++ where: { ++ photos_count: { gt: 0 } ++ }, ++ boost_by: [:created_at], ++ load: false) ++ end ++ end ++end +diff --git a/app/models/concerns/search_photos.rb b/app/models/concerns/search_photos.rb +new file mode 100644 +index 00000000..1715963a +--- /dev/null ++++ b/app/models/concerns/search_photos.rb +@@ -0,0 +1,29 @@ ++# frozen_string_literal: true ++ ++module SearchPhotos ++ extend ActiveSupport::Concern ++ ++ included do ++ searchkick merge_mappings: true, ++ mappings: { ++ properties: { ++ title: { type: :text }, ++ created_at: { type: :integer } ++ } ++ } ++ ++ # scope :search_import, -> { includes(:owner, :crops, :plantings, :harvests, :seeds, :posts) } ++ ++ def search_data ++ { ++ title: title, ++ crops: crops.map(&:id), ++ owner_id: owner_id, ++ owner_login_name: owner.login_name, ++ thumbnail_url: thumbnail_url, ++ fullsize_url: fullsize_url, ++ created_at: created_at.to_i ++ } ++ end ++ end ++end +diff --git a/app/models/concerns/search_plantings.rb b/app/models/concerns/search_plantings.rb +new file mode 100644 +index 00000000..bdf8dc78 +--- /dev/null ++++ b/app/models/concerns/search_plantings.rb +@@ -0,0 +1,56 @@ ++# frozen_string_literal: true ++ ++module SearchPlantings ++ extend ActiveSupport::Concern ++ ++ included do ++ searchkick merge_mappings: true, ++ mappings: { ++ properties: { ++ active: { type: :boolean }, ++ created_at: { type: :integer }, ++ harvests_count: { type: :integer }, ++ photos_count: { type: :integer }, ++ owner_location: { type: :text } ++ } ++ } ++ ++ scope :search_import, -> { includes(:owner, :crop) } ++ ++ def search_data ++ { ++ slug: slug, ++ active: active?, ++ crop_id: crop_id, ++ crop_name: crop.name, ++ crop_slug: crop.slug, ++ finished: finished?, ++ harvests_count: harvests.size, ++ has_photos: photos.size.positive?, ++ location: location, ++ owner_id: owner_id, ++ owner_location: owner_location, ++ owner_login_name: owner_login_name, ++ owner_slug: owner_slug, ++ percentage_grown: percentage_grown.to_i, ++ photos_count: photos.size, ++ planted_at: planted_at, ++ planted_from: planted_from, ++ quantity: quantity, ++ sunniness: sunniness, ++ thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, ++ created_at: created_at.to_i ++ } ++ end ++ ++ def self.homepage_records(limit) ++ search('*', ++ limit: limit, ++ where: { ++ photos_count: { gt: 0 } ++ }, ++ boost_by: [:created_at], ++ load: false) ++ end ++ end ++end +diff --git a/app/models/concerns/search_seeds.rb b/app/models/concerns/search_seeds.rb +new file mode 100644 +index 00000000..f5477936 +--- /dev/null ++++ b/app/models/concerns/search_seeds.rb +@@ -0,0 +1,57 @@ ++# frozen_string_literal: true ++ ++module SearchSeeds ++ extend ActiveSupport::Concern ++ ++ included do ++ searchkick merge_mappings: true, ++ mappings: { ++ properties: { ++ created_at: { type: :integer }, ++ plant_before: { type: :text }, ++ photos_count: { type: :integer }, ++ tradable_to: { type: :text } ++ } ++ } ++ ++ scope :search_import, -> { includes(:owner, :crop, :parent_planting) } ++ ++ def search_data ++ { ++ slug: slug, ++ crop_id: crop_id, ++ crop_name: crop.name, ++ crop_slug: crop.slug, ++ gmo: gmo, ++ has_photos: photos.size.positive?, ++ heirloom: heirloom, ++ organic: organic, ++ owner_id: owner_id, ++ owner_login_name: owner_login_name, ++ owner_location: owner_location, ++ owner_slug: owner_slug, ++ parent_planting: parent_planting, ++ photos_count: photos.size, ++ plant_before: plant_before&.to_s(:ymd), ++ quantity: quantity, ++ thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, ++ tradable_to: tradable_to, ++ tradable: tradable?, ++ finished: finished?, ++ location: owner.location, ++ created_at: created_at.to_i ++ } ++ end ++ ++ def self.homepage_records(limit) ++ search('*', ++ limit: limit, ++ where: { ++ finished: false, ++ tradable: true ++ }, ++ boost_by: [:created_at], ++ load: false) ++ end ++ end ++end +diff --git a/app/models/crop.rb b/app/models/crop.rb +index 78da0337..d983dff5 100644 +--- a/app/models/crop.rb ++++ b/app/models/crop.rb +@@ -1,8 +1,10 @@ ++# frozen_string_literal: true ++ + class Crop < ApplicationRecord + extend FriendlyId + include PhotoCapable + include OpenFarmData +- include CropSearch ++ include SearchCrops + + friendly_id :name, use: %i(slugged finders) + +diff --git a/app/models/crop_companion.rb b/app/models/crop_companion.rb +index 55d7c27a..3d09b194 100644 +--- a/app/models/crop_companion.rb ++++ b/app/models/crop_companion.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CropCompanion < ApplicationRecord + belongs_to :crop_a, class_name: :Crop + belongs_to :crop_b, class_name: :Crop +diff --git a/app/models/crop_post.rb b/app/models/crop_post.rb +index 5c520e3b..04c8e71e 100644 +--- a/app/models/crop_post.rb ++++ b/app/models/crop_post.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CropPost < ApplicationRecord + belongs_to :crop + belongs_to :post +diff --git a/app/models/csv_importer.rb b/app/models/csv_importer.rb +index d3b992ab..41ab325c 100644 +--- a/app/models/csv_importer.rb ++++ b/app/models/csv_importer.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CsvImporter + # used by db/seeds.rb and rake growstuff:import_crops + # CSV fields: +diff --git a/app/models/follow.rb b/app/models/follow.rb +index a70fd15f..1ee678ef 100644 +--- a/app/models/follow.rb ++++ b/app/models/follow.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class Follow < ApplicationRecord + belongs_to :follower, class_name: "Member", inverse_of: :follows + belongs_to :followed, class_name: "Member", inverse_of: :inverse_follows +diff --git a/app/models/forum.rb b/app/models/forum.rb +index 664af4f3..2ecae932 100644 +--- a/app/models/forum.rb ++++ b/app/models/forum.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class Forum < ApplicationRecord + extend FriendlyId + include Ownable +diff --git a/app/models/garden.rb b/app/models/garden.rb +index 865c11d6..1a3b4a34 100644 +--- a/app/models/garden.rb ++++ b/app/models/garden.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class Garden < ApplicationRecord + extend FriendlyId + include Geocodable +@@ -75,6 +77,8 @@ class Garden < ApplicationRecord + end + end + ++ def reindex; end ++ + protected + + def strip_blanks +diff --git a/app/models/garden_type.rb b/app/models/garden_type.rb +index b81789b6..bed371e2 100644 +--- a/app/models/garden_type.rb ++++ b/app/models/garden_type.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class GardenType < ApplicationRecord + extend FriendlyId + friendly_id :name, use: %i(slugged finders) +diff --git a/app/models/harvest.rb b/app/models/harvest.rb +index 4b40e56c..e0825c0a 100644 +--- a/app/models/harvest.rb ++++ b/app/models/harvest.rb +@@ -1,8 +1,11 @@ ++# frozen_string_literal: true ++ + class Harvest < ApplicationRecord + include ActionView::Helpers::NumberHelper + extend FriendlyId + include PhotoCapable + include Ownable ++ include SearchHarvests + + friendly_id :harvest_slug, use: %i(slugged finders) + +@@ -33,8 +36,8 @@ class Harvest < ApplicationRecord + + ## + ## Relationships +- belongs_to :crop +- belongs_to :plant_part ++ belongs_to :crop, counter_cache: true ++ belongs_to :plant_part, counter_cache: true + belongs_to :planting, optional: true, counter_cache: true + + ## +@@ -47,6 +50,9 @@ class Harvest < ApplicationRecord + ON (m.id=h2.owner_id AND harvests.id < h2.id)").where("h2 IS NULL") + } + ++ delegate :name, to: :crop, prefix: true ++ delegate :login_name, :slug, to: :owner, prefix: true ++ + ## + ## Validations + validates :crop, approved: true +diff --git a/app/models/like.rb b/app/models/like.rb +index f7490373..ed16065d 100644 +--- a/app/models/like.rb ++++ b/app/models/like.rb +@@ -1,6 +1,8 @@ ++# frozen_string_literal: true ++ + class Like < ApplicationRecord + belongs_to :member +- belongs_to :likeable, polymorphic: true, counter_cache: true ++ belongs_to :likeable, polymorphic: true, counter_cache: true, touch: true + validates :member, :likeable, presence: true + validates :member, uniqueness: { scope: :likeable } + end +diff --git a/app/models/member.rb b/app/models/member.rb +index 2762a602..5d373000 100644 +--- a/app/models/member.rb ++++ b/app/models/member.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class Member < ApplicationRecord + include Discard::Model + acts_as_messageable # messages can be sent to this model +diff --git a/app/models/notification.rb b/app/models/notification.rb +index 466fe73b..55e270d3 100644 +--- a/app/models/notification.rb ++++ b/app/models/notification.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class Notification < ApplicationRecord + belongs_to :sender, class_name: 'Member', inverse_of: :sent_notifications + belongs_to :recipient, class_name: 'Member', inverse_of: :notifications +diff --git a/app/models/photo.rb b/app/models/photo.rb +index 3bdbe255..7518cc80 100644 +--- a/app/models/photo.rb ++++ b/app/models/photo.rb +@@ -1,11 +1,14 @@ ++# frozen_string_literal: true ++ + class Photo < ApplicationRecord + include Likeable + include Ownable ++ include SearchPhotos + + PHOTO_CAPABLE = %w(Garden Planting Harvest Seed Post Crop).freeze + + has_many :photo_associations, foreign_key: :photo_id, dependent: :delete_all, inverse_of: :photo +- has_many :crops, through: :photo_associations ++ has_many :crops, through: :photo_associations, counter_cache: true + + validates :fullsize_url, url: true + validates :thumbnail_url, url: true +@@ -23,6 +26,8 @@ class Photo < ApplicationRecord + joins(:photo_associations).where(photo_associations: { photographable_type: model_name.to_s }) + } + ++ delegate :login_name, to: :owner, prefix: true ++ + # This is split into a side-effect free method and a side-effecting method + # for easier stubbing and testing. + def flickr_metadata +diff --git a/app/models/photo_association.rb b/app/models/photo_association.rb +index 89e495b0..647c1bb7 100644 +--- a/app/models/photo_association.rb ++++ b/app/models/photo_association.rb +@@ -1,7 +1,9 @@ ++# frozen_string_literal: true ++ + class PhotoAssociation < ApplicationRecord + belongs_to :photo, inverse_of: :photo_associations +- belongs_to :photographable, polymorphic: true +- belongs_to :crop, optional: true ++ belongs_to :photographable, polymorphic: true, touch: true ++ belongs_to :crop, optional: true, counter_cache: true + + validate :photo_and_item_have_same_owner + +@@ -9,10 +11,6 @@ class PhotoAssociation < ApplicationRecord + ## Triggers + before_save :set_crop + +- def item +- find_by!(photographable_id: photographable_id, photographable_type: photographable_type).photographable +- end +- + def self.item(item_id, item_type) + find_by!(photographable_id: item_id, photographable_type: item_type).photographable + end +@@ -28,7 +26,7 @@ class PhotoAssociation < ApplicationRecord + private + + def photo_and_item_have_same_owner +- return unless photographable_type != 'Crop' ++ return if photographable_type == 'Crop' + + errors.add(:photo, "must have same owner as item it links to") unless photographable.owner_id == photo.owner_id + end +diff --git a/app/models/plant_part.rb b/app/models/plant_part.rb +index 6fd57bff..e7e80830 100644 +--- a/app/models/plant_part.rb ++++ b/app/models/plant_part.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class PlantPart < ApplicationRecord + extend FriendlyId + friendly_id :name, use: %i(slugged finders) +diff --git a/app/models/planting.rb b/app/models/planting.rb +index 71646834..9f6b3949 100644 +--- a/app/models/planting.rb ++++ b/app/models/planting.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class Planting < ApplicationRecord + extend FriendlyId + include PhotoCapable +@@ -5,6 +7,8 @@ class Planting < ApplicationRecord + include Ownable + include PredictPlanting + include PredictHarvest ++ include SearchPlantings ++ + friendly_id :planting_slug, use: %i(slugged finders) + + # Constants +@@ -54,6 +58,7 @@ class Planting < ApplicationRecord + ## Delegations + delegate :name, :slug, :en_wikipedia_url, :default_scientific_name, :plantings_count, + to: :crop, prefix: true ++ delegate :login_name, :slug, :location, to: :owner, prefix: true + + delegate :annual?, :perennial?, :svg_icon, to: :crop + delegate :location, :longitude, :latitude, to: :garden +diff --git a/app/models/post.rb b/app/models/post.rb +index fd5abb13..73940422 100644 +--- a/app/models/post.rb ++++ b/app/models/post.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class Post < ApplicationRecord + extend FriendlyId + include Likeable +@@ -55,6 +57,8 @@ class Post < ApplicationRecord + subject + end + ++ def reindex; end ++ + private + + def update_crop_posts_association +diff --git a/app/models/role.rb b/app/models/role.rb +index cd985d11..b89db328 100644 +--- a/app/models/role.rb ++++ b/app/models/role.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class Role < ApplicationRecord + extend FriendlyId + friendly_id :name, use: %i(slugged finders) +diff --git a/app/models/scientific_name.rb b/app/models/scientific_name.rb +index b2da3320..94ab605b 100644 +--- a/app/models/scientific_name.rb ++++ b/app/models/scientific_name.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ScientificName < ApplicationRecord + belongs_to :crop + belongs_to :creator, class_name: 'Member', inverse_of: :created_scientific_names +diff --git a/app/models/seed.rb b/app/models/seed.rb +index cc1cecaa..9841fa19 100644 +--- a/app/models/seed.rb ++++ b/app/models/seed.rb +@@ -1,8 +1,11 @@ ++# frozen_string_literal: true ++ + class Seed < ApplicationRecord + extend FriendlyId + include PhotoCapable + include Finishable + include Ownable ++ include SearchSeeds + friendly_id :seed_slug, use: %i(slugged finders) + + TRADABLE_TO_VALUES = %w(nowhere locally nationally internationally).freeze +@@ -44,7 +47,9 @@ class Seed < ApplicationRecord + + # + # Delegations +- delegate :name, to: :crop ++ delegate :name, to: :crop, prefix: true ++ delegate :location, :latitude, :longitude, to: :owner ++ delegate :login_name, :slug, :location, to: :owner, prefix: true + + # + # Scopes +diff --git a/app/resources/api/v1/crop_resource.rb b/app/resources/api/v1/crop_resource.rb +index 8eac3209..abbf2258 100644 +--- a/app/resources/api/v1/crop_resource.rb ++++ b/app/resources/api/v1/crop_resource.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Api + module V1 + class CropResource < BaseResource +diff --git a/app/resources/api/v1/garden_resource.rb b/app/resources/api/v1/garden_resource.rb +index cffcb27f..4b4a32bb 100644 +--- a/app/resources/api/v1/garden_resource.rb ++++ b/app/resources/api/v1/garden_resource.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Api + module V1 + class GardenResource < BaseResource +diff --git a/app/resources/api/v1/harvest_resource.rb b/app/resources/api/v1/harvest_resource.rb +index c1ce0ae0..502bee5b 100644 +--- a/app/resources/api/v1/harvest_resource.rb ++++ b/app/resources/api/v1/harvest_resource.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Api + module V1 + class HarvestResource < BaseResource +diff --git a/app/resources/api/v1/member_resource.rb b/app/resources/api/v1/member_resource.rb +index 4013aeea..9a2731f2 100644 +--- a/app/resources/api/v1/member_resource.rb ++++ b/app/resources/api/v1/member_resource.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Api + module V1 + class MemberResource < BaseResource +diff --git a/app/resources/api/v1/photo_resource.rb b/app/resources/api/v1/photo_resource.rb +index 84c7eab1..6da294cd 100644 +--- a/app/resources/api/v1/photo_resource.rb ++++ b/app/resources/api/v1/photo_resource.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Api + module V1 + class PhotoResource < BaseResource +diff --git a/app/resources/api/v1/planting_resource.rb b/app/resources/api/v1/planting_resource.rb +index 1e41078f..0db7e40b 100644 +--- a/app/resources/api/v1/planting_resource.rb ++++ b/app/resources/api/v1/planting_resource.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Api + module V1 + class PlantingResource < BaseResource +diff --git a/app/resources/api/v1/seed_resource.rb b/app/resources/api/v1/seed_resource.rb +index e994ce1a..82dd53ee 100644 +--- a/app/resources/api/v1/seed_resource.rb ++++ b/app/resources/api/v1/seed_resource.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Api + module V1 + class SeedResource < BaseResource +diff --git a/app/resources/base_resource.rb b/app/resources/base_resource.rb +index 2d54fdf0..46de0ce5 100644 +--- a/app/resources/base_resource.rb ++++ b/app/resources/base_resource.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class BaseResource < JSONAPI::Resource + immutable + abstract +diff --git a/app/services/crop_search_service.rb b/app/services/crop_search_service.rb +index 645505e0..274d5a3c 100644 +--- a/app/services/crop_search_service.rb ++++ b/app/services/crop_search_service.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CropSearchService + # Crop.search(string) + def self.search(query, page: 1, per_page: 12, current_member: nil) +diff --git a/app/services/timeline_service.rb b/app/services/timeline_service.rb +index 8ed76508..328eb17d 100644 +--- a/app/services/timeline_service.rb ++++ b/app/services/timeline_service.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class TimelineService + def self.member_query(member) + query.where(owner_id: member.id) +diff --git a/app/validators/approved_validator.rb b/app/validators/approved_validator.rb +index 8a77fa2d..179bfef1 100644 +--- a/app/validators/approved_validator.rb ++++ b/app/validators/approved_validator.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ApprovedValidator < ActiveModel::EachValidator + def validate_each(record, attribute, _value) + record.errors[attribute] << (options[:message] || 'must be approved') unless record.crop.try(:approved?) +diff --git a/app/views/crops/_crop.html.haml b/app/views/crops/_crop.html.haml +index 9c763518..e32a933a 100644 +--- a/app/views/crops/_crop.html.haml ++++ b/app/views/crops/_crop.html.haml +@@ -6,7 +6,7 @@ + crop + .card-body + %h3.card-title +- %strong= link_to crop, crop ++ %strong= link_to crop.name, crop_path(slug: crop.slug) + = crop.default_scientific_name + .d-flex.justify-content-between + - if crop.annual? && crop.median_lifespan.present? +diff --git a/app/views/crops/_thumbnail.html.haml b/app/views/crops/_thumbnail.html.haml +index 948c59bb..29617b76 100644 +--- a/app/views/crops/_thumbnail.html.haml ++++ b/app/views/crops/_thumbnail.html.haml +@@ -1,12 +1,11 @@ + - cache crop do + .card.crop-thumbnail +- = link_to image_tag(crop_image_path(crop), ++ = link_to image_tag(crop.thumbnail_url ? crop.thumbnail_url : placeholder_image, + alt: crop.name, + class: 'img img-card'), +- crop ++ crop_path(slug: crop.slug) + + .text +- %h3.crop-name= link_to crop, crop ++ %h3.crop-name= link_to crop.name, crop_path(slug: crop.slug) + %h5.crop-sci-name +-   +- = crop.scientific_names.first&.name ++ = crop.scientific_names.first +diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml +index 7fc08875..42741201 100644 +--- a/app/views/crops/index.html.haml ++++ b/app/views/crops/index.html.haml +@@ -22,8 +22,8 @@ + %h2= t('.title') + = will_paginate @crops + .index-cards +- - @crops.each do |crop| +- = render 'crops/thumbnail', crop: crop ++ - @crops.each do |c| ++ = render 'crops/thumbnail', crop: c + + = will_paginate @crops + +diff --git a/app/views/harvests/_card.html.haml b/app/views/harvests/_card.html.haml +index 0d51fbb4..55811bb2 100644 +--- a/app/views/harvests/_card.html.haml ++++ b/app/views/harvests/_card.html.haml +@@ -1,11 +1,13 @@ +-.card +- = link_to harvest do +- = image_tag harvest_image_path(harvest), alt: harvest, class: 'img-card' +- .card-body +- %h5 +- = crop_icon(harvest.crop) +- %strong +- = link_to harvest.crop, harvest +- %span.badge.badge-pill= harvest.plant_part +- .card-footer +- .float-right=render 'members/tiny', member: harvest.owner +\ No newline at end of file ++- cache harvest do ++ .card ++ = link_to harvest do ++ = image_tag harvest.thumbnail_url ? harvest.thumbnail_url : placeholder_image, alt: harvest.crop_name, class: 'img-card' ++ .card-body ++ %h5 ++ %strong= link_to harvest.crop_name, harvest_path(slug: harvest.slug) ++ %span.badge.badge-pill= harvest.plant_part ++ .card-footer ++ .float-right ++ %span.chip.member-chip ++ = link_to member_path(slug: harvest.owner_slug) do ++ = harvest.owner_login_name +\ No newline at end of file +diff --git a/app/views/harvests/_harvest.haml b/app/views/harvests/_harvest.haml +index 7341875c..f6772516 100644 +--- a/app/views/harvests/_harvest.haml ++++ b/app/views/harvests/_harvest.haml +@@ -1,6 +1,4 @@ + - if local_assigns[:full] +- - cache harvest do +- = render 'harvests/card', harvest: harvest ++ = render 'harvests/card', harvest: harvest + - else +- - cache harvest do +- = render 'harvests/thumbnail', harvest: harvest +\ No newline at end of file ++ = render 'harvests/thumbnail', harvest: harvest +\ No newline at end of file +diff --git a/app/views/harvests/_thumbnail.html.haml b/app/views/harvests/_thumbnail.html.haml +index 8539d72d..5dfe125c 100644 +--- a/app/views/harvests/_thumbnail.html.haml ++++ b/app/views/harvests/_thumbnail.html.haml +@@ -1,9 +1,10 @@ +-.card.harvest-thumbnail +- = link_to image_tag(harvest_image_path(harvest), +- alt: harvest, +- class: 'img img-card'), +- harvest ++- cache harvest do ++ .card.harvest-thumbnail ++ = link_to image_tag(harvest_image_path(harvest), ++ alt: harvest, ++ class: 'img img-card'), ++ harvest + +- .text +- %h3.harvest-plant-part= link_to harvest.plant_part, harvest +- %h5.harvest-crop= harvest.crop ++ .text ++ %h3.harvest-plant-part= link_to harvest.plant_part, harvest ++ %h5.harvest-crop= harvest.crop +diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml +index f2a5cb04..71c724c6 100644 +--- a/app/views/harvests/index.html.haml ++++ b/app/views/harvests/index.html.haml +@@ -29,8 +29,9 @@ + .badge.badge-success= link_to 'API Methods', '/api-docs' + .col-md-10 + %section +- %h2 +- = page_entries_info @harvests ++ %h2= page_entries_info @harvests + = will_paginate @harvests +- .index-cards=render @harvests, full: true ++ .index-cards ++ - @harvests.each do |h| ++ = render 'harvests/card', harvest: h + = will_paginate @harvests +diff --git a/app/views/harvests/index.rss.haml b/app/views/harvests/index.rss.haml +index f5682edf..7967b23e 100644 +--- a/app/views/harvests/index.rss.haml ++++ b/app/views/harvests/index.rss.haml +@@ -6,14 +6,12 @@ + %link= harvests_url + - @harvests.each do |harvest| + %item +- %title #{harvest.owner.login_name}'s #{harvest.crop.name} +- %pubdate= harvest.harvested_at.to_s(:rfc822) ++ %title #{harvest['owner_name']}'s #{harvest['crop_name']} ++ %pubdate= harvest['harvested_at'] + %description + :escaped +-

Crop: #{harvest.crop ? harvest.crop : 'unknown' }

+-

Quantity: #{harvest.quantity ? harvest.quantity : 'unknown' }

+-

Harvested on: #{harvest.harvested_at ? harvest.harvested_at : 'unknown' }

+- :escaped_markdown +- #{ strip_tags harvest.description } +- %link= harvest_url(harvest) +- %guid= harvest_url(harvest) ++

Crop: #{harvest['crop_name']}

++

Quantity: #{harvest['quantity'] ? harvest['quantity'] : 'unknown' }

++

Harvested on: #{harvest['harvested_at'] ? harvest['harvested_at'] : 'unknown' }

++ %link= harvest_url(slug: harvest['slug']) ++ %guid= harvest_url(slug: harvest['slug']) +diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml +index fe4b1492..17c25cd4 100644 +--- a/app/views/home/_crops.html.haml ++++ b/app/views/home/_crops.html.haml +@@ -1,16 +1,4 @@ + - cache cache_key_for(Crop, 'homepage'), expires_in: 1.day do + .index-cards +- - CropSearchService.random_with_photos(16).each do |crop| +- .card.crop-thumbnail +- = link_to crop_path(slug: crop['slug']) do +- = image_tag(crop['photo'], +- alt: crop['name'], +- class: 'img img-card') +- +- .text +- %h3.crop-name +- = link_to crop['name'], crop_path(slug: crop['slug']) +- %h5.crop-sci-name +-   +- = crop['scientific_name'] +- ++ - CropSearchService.random_with_photos(16).each do |c| ++ = render 'crops/thumbnail', crop: c +\ No newline at end of file +diff --git a/app/views/home/_discuss.html.haml b/app/views/home/_discuss.html.haml +index 7954b536..96983207 100644 +--- a/app/views/home/_discuss.html.haml ++++ b/app/views/home/_discuss.html.haml +@@ -12,7 +12,7 @@ + %p.mb-2 + = truncate(strip_tags(post.body), length: 200) + %small +- = post.comments.size ++ = post.comments_count + comments + %p.text-right + = link_to "#{t('.view_all')} ยป", posts_path, class: 'btn btn-block' +diff --git a/app/views/home/_harvests.html.haml b/app/views/home/_harvests.html.haml +index cdf7aa58..7dadbbfb 100644 +--- a/app/views/home/_harvests.html.haml ++++ b/app/views/home/_harvests.html.haml +@@ -1,11 +1,12 @@ + %h2= t('.recently_harvested') +-- Harvest.has_photos.recent.includes(:crop, :owner, :photos, :plant_part).limit(6).each do |harvest| ++- Harvest.homepage_records(6).each do |harvest| + - cache harvest do +- = link_to harvest, class: 'list-group-item list-group-item-action flex-column align-items-start' do ++ = link_to harvest_path(slug: harvest['slug']), class: 'list-group-item list-group-item-action flex-column align-items-start' do + .d-flex.w-100.justify-content-between.homepage--list-item + %div +- %h5= harvest.crop.name +- %span.badge.badge-success=harvest.plant_part ++ %h5= harvest['crop_name'] ++ %span.badge.badge-success=harvest['plant_part'] + %small.text-muted +- harvested by #{harvest.owner} +- %p.mb-2= image_tag harvest_image_path(harvest), width: 75, class: 'rounded shadow' +\ No newline at end of file ++ harvested by #{harvest['owner_name']} ++ %p.mb-2 ++ = image_tag harvest['thumbnail_url'], width: 75, class: 'rounded shadow' +\ No newline at end of file +diff --git a/app/views/home/_plantings.html.haml b/app/views/home/_plantings.html.haml +index 8d26fe45..a3bb79f7 100644 +--- a/app/views/home/_plantings.html.haml ++++ b/app/views/home/_plantings.html.haml +@@ -1,12 +1,11 @@ + %h2= t('.recently_planted') +-- Planting.has_photos.recent.includes(:owner, :crop).limit(6).each do |planting| +- - cache planting do +- = link_to planting, class: 'list-group-item list-group-item-action flex-column align-items-start' do +- .d-flex.w-100.justify-content-between.homepage--list-item +- %p.mb-2 +- = image_tag planting_image_path(planting), width: 75, class: 'rounded shadow' +- .text-right +- %h5= planting.crop.name +- - if planting.planted_from.present? +- %span.badge.badge-success= planting.planted_from.pluralize +- %small.text-muted planted by #{planting.owner} ++- Planting.homepage_records(6).each do |planting| ++ = link_to planting_path(slug: planting['slug']), class: 'list-group-item list-group-item-action flex-column align-items-start' do ++ .d-flex.w-100.justify-content-between.homepage--list-item ++ %p.mb-2 ++ = image_tag planting['thumbnail_url'], width: 75, class: 'rounded shadow' ++ .text-right ++ %h5= planting['crop_name'] ++ - if planting['planted_from'].present? ++ %span.badge.badge-success= planting['planted_from'].pluralize ++ %small.text-muted planted by #{planting['owner_name']} +diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml +index 38ae29fd..bfb56295 100644 +--- a/app/views/home/_seeds.html.haml ++++ b/app/views/home/_seeds.html.haml +@@ -1,5 +1,5 @@ + - cache cache_key_for(Seed) do + %h2.text-center= t('home.seeds.title') + .index-cards +- - Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(6).each do |seed| +- = render 'seeds/card', seed: seed ++ - Seed.homepage_records(6).each do |s| ++ = render 'seeds/card', seed: s +diff --git a/app/views/layouts/_menu.haml b/app/views/layouts/_menu.haml +index eea460e0..3703f969 100644 +--- a/app/views/layouts/_menu.haml ++++ b/app/views/layouts/_menu.haml +@@ -5,7 +5,7 @@ + = link_to timeline_index_path, method: :get, class: 'nav-link text-white' do + = image_tag 'icons/notification.svg', class: 'img img-icon' + %li.nav-item +- = link_to member_gardens_path(member_slug: current_member.slug), class: 'nav-link text-white' do ++ = link_to member_gardens_path(current_member), class: 'nav-link text-white' do + = image_icon 'gardens' + %li.nav-item.dropdown + %a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#", role: "button"} +diff --git a/app/views/photos/_card.html.haml b/app/views/photos/_card.html.haml +index f073cbef..4b606c63 100644 +--- a/app/views/photos/_card.html.haml ++++ b/app/views/photos/_card.html.haml +@@ -1,10 +1,11 @@ + .card.photo-card{id: "photo-#{photo.id}"} +- = link_to image_tag(photo.source == 'flickr' ? photo.fullsize_url : photo.thumbnail_url, alt: photo.title, class: 'img img-card'), photo ++ = link_to photo_path(id: photo.id) do ++ = image_tag(photo.source == 'flickr' ? photo.fullsize_url : photo.thumbnail_url, alt: photo.title, class: 'img img-card') + .card-body + %h5.ellipsis + = photo_icon +- = link_to photo.title, photo +- %i by #{link_to photo.owner, photo.owner} ++ = link_to photo.title, photo_path(id: photo.id) ++ %i by #{link_to photo.owner_login_name, member_path(slug: photo.owner_login_name)} + - if photo.date_taken.present? + %small.text-muted + %time{datetime: photo.date_taken}= I18n.l(photo.date_taken.to_date) +diff --git a/app/views/plantings/_card.html.haml b/app/views/plantings/_card.html.haml +index e875b215..d9090899 100644 +--- a/app/views/plantings/_card.html.haml ++++ b/app/views/plantings/_card.html.haml +@@ -1,27 +1,14 @@ + - cache planting do +- .card.planting{class: planting.active? ? '' : 'card-finished'} +- = link_to planting do +- = image_tag planting_image_path(planting), class: 'img-card', alt: planting +- - if can? :edit, planting +- .planting-quick-actions +- .dropdown +- %a.planting-menu.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button", href: '#'} +- .dropdown-menu{"aria-labelledby" => "planting-menu"} +- = planting_edit_button(planting, classes: 'dropdown-item') +- = add_photo_button(planting, classes: 'dropdown-item') +- +- - if planting.active? +- = planting_finish_button(planting, classes: 'dropdown-item') +- = planting_harvest_button(planting, classes: 'dropdown-item') +- = planting_save_seeds_button(planting, classes: 'dropdown-item') +- +- - if can? :destroy, planting +- .dropdown-divider +- = delete_button(planting, classes: 'dropdown-item text-danger') +- = link_to planting do ++ .card.planting{class: planting.active ? '' : 'card-finished'} ++ = link_to planting_path(slug: planting.slug) do ++ = image_tag planting.thumbnail_url ? planting.thumbnail_url : placeholder_image, class: 'img-card', alt: planting.crop_name ++ = link_to planting_path(slug: planting.slug) do + .card-body.text-center +- %h4= planting.crop ++ %h4= planting.crop_name + .text-center= render 'plantings/badges', planting: planting + = render 'plantings/progress', planting: planting + .card-footer +- .float-right=render 'members/tiny', member: planting.owner +\ No newline at end of file ++ .float-right ++ %span.chip.member-chip ++ = link_to member_path(slug: planting.owner_slug) do ++ = planting.owner_login_name +\ No newline at end of file +diff --git a/app/views/plantings/_facts.haml b/app/views/plantings/_facts.haml +index b0f2a440..428c9f6d 100644 +--- a/app/views/plantings/_facts.haml ++++ b/app/views/plantings/_facts.haml +@@ -16,14 +16,14 @@ + unknown + - if planting.planted_at.present? + %span.planted_at +- =planting.planted_at.year ++ = planting.planted_at.year + + - if planting.finish_is_predicatable? + .card.fact-card + %h3 Progress + %strong #{planting.age_in_days}/#{planting.expected_lifespan} + %span days +- ++ + .card.fact-card{class: planting.quantity.present? ? '' : 'text-muted'} + %h3 + Quantity +diff --git a/app/views/plantings/_harvests.html.haml b/app/views/plantings/_harvests.html.haml +index aa3a0fd4..4f9aa933 100644 +--- a/app/views/plantings/_harvests.html.haml ++++ b/app/views/plantings/_harvests.html.haml +@@ -10,11 +10,11 @@ + = link_to harvests_path(return: 'planting', harvest: {crop_id: @planting.crop_id, planting_id: @planting.id, plant_part_id: plant_part.id}), method: :post, class: 'dropdown-item' do + = plant_part.name + +-- if planting.harvests.empty? ++- if @planting.harvests.empty? + %p No harvests recorded + - if !planting.finished? && can?(:edit, planting) && can?(:create, Harvest) + %p Record your harvests here to improve crop predictions, and you'll be able to compare with your garden next season. + - else + .index-cards +- - planting.harvests.order(created_at: :desc).includes(:crop).each do |harvest| ++ - @planting.harvests.each do |harvest| + = render 'harvests/thumbnail', harvest: harvest +diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml +index c1f21c44..b7f3a468 100644 +--- a/app/views/plantings/index.html.haml ++++ b/app/views/plantings/index.html.haml +@@ -10,7 +10,6 @@ + %h1.display-2.text-center + = planting_icon + = title('plantings', @owner, @crop, @planting) +- + .row + .col-md-2 + = render 'layouts/nav', model: Planting +@@ -20,9 +19,9 @@ + include finished plantings + %hr + - if @owner.present? +- = render @owner ++ = render @owner, cached: true + - if @crop.present? +- = render @crop ++ = render @crop, cached: true + + %section.open-data + %h2 Open Data +@@ -40,7 +39,6 @@ + %h2= page_entries_info @plantings + = will_paginate @plantings + .index-cards +- - @plantings.each do |planting| +- = render planting, full: true +- ++ - @plantings.each do |p| ++ = render 'plantings/card', planting: p + = will_paginate @plantings +diff --git a/app/views/plantings/index.rss.haml b/app/views/plantings/index.rss.haml +index 94eb026d..036e59fd 100644 +--- a/app/views/plantings/index.rss.haml ++++ b/app/views/plantings/index.rss.haml +@@ -6,15 +6,15 @@ + %link= plantings_url + - @plantings.each do |planting| + %item +- %title #{planting.crop} in #{planting.location} +- %pubdate= planting.created_at.to_s(:rfc822) ++ %title #{planting['crop']} in #{planting['location']} ++ %pubdate= planting['created_at'].to_s(:rfc822) + %description + :escaped +-

Quantity: #{planting.quantity ? planting.quantity : 'unknown' }

+-

Planted on: #{planting.planted_at ? planting.planted_at : 'unknown' }

+-

Sunniness: #{planting.sunniness ? planting.sunniness : 'unknown' }

+-

Planted from: #{planting.planted_from ? planting.planted_from : 'unknown' }

++

Quantity: #{planting['quantity'] ? planting['quantity'] : 'unknown' }

++

Planted on: #{planting['planted_at'] ? planting['planted_at'] : 'unknown' }

++

Sunniness: #{planting['sunniness'] ? planting['sunniness'] : 'unknown' }

++

Planted from: #{planting['planted_from'] ? planting['planted_from'] : 'unknown' }

+ :escaped_markdown +- #{ strip_tags planting.description } +- %link= planting_url(planting) +- %guid= planting_url(planting) ++ #{ strip_tags planting['description'] } ++ %link= planting_url(slug: planting['slug']) ++ %guid= planting_url(slug: planting['slug']) +diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml +index db8a72da..6b4cd852 100644 +--- a/app/views/seeds/_card.html.haml ++++ b/app/views/seeds/_card.html.haml +@@ -1,17 +1,17 @@ + - cache seed do +- .card.seed-card{class: seed.active? ? '' : 'card-finished'} ++ .card.seed-card{class: seed.finished ? 'card-finished' : ''} + = link_to seed do +- = image_tag(seed_image_path(seed), alt: seed, class: 'img-card') ++ = image_tag(seed.thumbnail_url ? seed.thumbnail_url : placeholder_image, alt: seed.name, class: 'img-card') + .text +- = render 'members/tiny', member: seed.owner ++ %span.chip.member-chip ++ = seed.owner_login_name + .card-body + .card-title +- = crop_icon(seed.crop) +- = link_to seed.crop, seed +- - if seed.tradable? ++ = link_to seed.crop_name, seed_path(slug: seed.slug) ++ - if seed.tradable + .text-muted + = icon 'fas', 'map' + Will trade #{seed.tradable_to} + .badge.badge-pill.badge-location + = icon 'fas', 'map-marker' +- = truncate(seed.owner.location, length: 20, separator: ' ', omission: '... ') +\ No newline at end of file ++ = truncate(seed.owner_location, length: 20, separator: ' ', omission: '... ') +\ No newline at end of file +diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml +index e0d17efe..47e34927 100644 +--- a/app/views/seeds/index.html.haml ++++ b/app/views/seeds/index.html.haml +@@ -38,9 +38,7 @@ + = will_paginate @seeds + + .index-cards +- - @seeds.each do |seed| +- = render 'seeds/card', seed: seed ++ - @seeds.each do |s| ++ = render 'seeds/card', seed: s + + = will_paginate @seeds +- +- +diff --git a/app/views/seeds/index.rss.haml b/app/views/seeds/index.rss.haml +index b2044de6..0d128c2f 100644 +--- a/app/views/seeds/index.rss.haml ++++ b/app/views/seeds/index.rss.haml +@@ -6,20 +6,17 @@ + %link= seeds_url + - @seeds.each do |seed| + %item +- %title #{seed.owner}'s #{seed.crop} seeds +- %pubdate= seed.created_at.to_s(:rfc822) ++ %title #{seed['owner_name']}'s #{seed['crop_name']} seeds ++ %pubdate= seed['created_at'].to_s(:rfc822) + %description + :escaped +-

Quantity: #{seed.quantity ? seed.quantity : 'unknown' }

+-

Plant before: #{seed.plant_before ? seed.plant_before : 'unknown' }

+-

Organic? #{seed.organic}

+-

GMO? #{seed.gmo}

+-

Heirloom? #{seed.heirloom}

+- - if seed.tradable? +- %p +- Will trade #{seed.tradable_to} from #{seed.owner.location ? seed.owner.location : 'unknown location'} +- +- :escaped_markdown +- #{ strip_tags seed.description } +- %link= seed_url(seed) +- %guid= seed_url(seed) ++

Quantity: #{seed['quantity'] ? seed['quantity'] : 'unknown' }

++

Plant before: #{seed['plant_before'] ? seed['plant_before'] : 'unknown' }

++

Organic? #{seed['organic']}

++

GMO? #{seed['gmo']}

++

Heirloom? #{seed['heirloom']}

++ - if seed['tradeable'] ++ :escaped ++

Will trade #{seed['tradable_to']} from #{seed['location'] ? seed['location'] : 'unknown location'}

++ %link= seed_url(slug: seed['slug']) ++ %guid= seed_url(slug: seed['slug']) +diff --git a/config.rb b/config.rb +index 214d25ef..328f8a9d 100644 +--- a/config.rb ++++ b/config.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Require any additional compass plugins here. + # Set this to the root of your project when deployed: + http_path = "/" +diff --git a/config/application.rb b/config/application.rb +index a42ae3ba..b34bc36f 100644 +--- a/config/application.rb ++++ b/config/application.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require_relative 'boot' + + require 'rails/all' +diff --git a/config/boot.rb b/config/boot.rb +index 4423c97f..73bf2c9b 100644 +--- a/config/boot.rb ++++ b/config/boot.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + + require 'bundler/setup' # Set up gems listed in the Gemfile. +diff --git a/config/compass.rb b/config/compass.rb +index 2b22d5d7..81dc9bdc 100644 +--- a/config/compass.rb ++++ b/config/compass.rb +@@ -1,2 +1,4 @@ ++# frozen_string_literal: true ++ + # Require any additional compass plugins here. + project_type = :rails +diff --git a/config/environment.rb b/config/environment.rb +index 426333bb..d5abe558 100644 +--- a/config/environment.rb ++++ b/config/environment.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Load the Rails application. + require_relative 'application' + +diff --git a/config/environments/development.rb b/config/environments/development.rb +index 46106e08..caaf7fcd 100644 +--- a/config/environments/development.rb ++++ b/config/environments/development.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + +diff --git a/config/environments/production.rb b/config/environments/production.rb +index 6ffdc773..882d7a46 100644 +--- a/config/environments/production.rb ++++ b/config/environments/production.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + +diff --git a/config/environments/test.rb b/config/environments/test.rb +index 2a0efb6b..8c31b699 100644 +--- a/config/environments/test.rb ++++ b/config/environments/test.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + +diff --git a/config/factory_bot.rb b/config/factory_bot.rb +index 43d50d52..e4925f2a 100644 +--- a/config/factory_bot.rb ++++ b/config/factory_bot.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + ActionDispatch::Callbacks.after do + # Reload the factories + return unless Rails.env.development? || Rails.env.test? +diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb +index 89d2efab..f4556db3 100644 +--- a/config/initializers/application_controller_renderer.rb ++++ b/config/initializers/application_controller_renderer.rb +@@ -1,3 +1,4 @@ ++# frozen_string_literal: true + # Be sure to restart your server when you modify this file. + + # ActiveSupport::Reloader.to_prepare do +diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb +index 60484d4a..c3da5a1a 100644 +--- a/config/initializers/assets.rb ++++ b/config/initializers/assets.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Be sure to restart your server when you modify this file. + + # Version of your assets, change this if you want to expire all your assets. +diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb +index 59385cdf..d0f0d3b5 100644 +--- a/config/initializers/backtrace_silencers.rb ++++ b/config/initializers/backtrace_silencers.rb +@@ -1,3 +1,4 @@ ++# frozen_string_literal: true + # Be sure to restart your server when you modify this file. + + # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +diff --git a/config/initializers/comfortable_mexican_sofa.rb b/config/initializers/comfortable_mexican_sofa.rb +index dc8148fd..80dce601 100644 +--- a/config/initializers/comfortable_mexican_sofa.rb ++++ b/config/initializers/comfortable_mexican_sofa.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + ComfortableMexicanSofa.configure do |config| + # Title of the admin area + # config.cms_title = 'ComfortableMexicanSofa CMS Engine' +diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb +index d3bcaa5e..497f5667 100644 +--- a/config/initializers/content_security_policy.rb ++++ b/config/initializers/content_security_policy.rb +@@ -1,3 +1,4 @@ ++# frozen_string_literal: true + # Be sure to restart your server when you modify this file. + + # Define an application-wide content security policy +diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb +index 5a6a32d3..ee8dff9c 100644 +--- a/config/initializers/cookies_serializer.rb ++++ b/config/initializers/cookies_serializer.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Be sure to restart your server when you modify this file. + + # Specify a serializer for the signed and encrypted cookie jars. +diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb +index 974551c9..1512d8f0 100644 +--- a/config/initializers/devise.rb ++++ b/config/initializers/devise.rb +@@ -1,4 +1,6 @@ +-# rubocop:disable Metrics/LineLength ++# frozen_string_literal: true ++ ++# rubocop:disable Layout/LineLength + # Use this hook to configure devise mailer, warden hooks and so forth. + # Many of these configuration options can be set straight in your model. + Devise.setup do |config| +@@ -236,4 +238,4 @@ Devise.setup do |config| + # 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' + end +-# rubocop:enable Metrics/LineLength ++# rubocop:enable Layout/LineLength +diff --git a/config/initializers/escaped_markdown.rb b/config/initializers/escaped_markdown.rb +index 87837b0c..6cad3bdf 100644 +--- a/config/initializers/escaped_markdown.rb ++++ b/config/initializers/escaped_markdown.rb +@@ -1 +1,3 @@ ++# frozen_string_literal: true ++ + require 'haml/filters/escaped_markdown' +diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb +index 4a994e1e..7a4f47b4 100644 +--- a/config/initializers/filter_parameter_logging.rb ++++ b/config/initializers/filter_parameter_logging.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Be sure to restart your server when you modify this file. + + # Configure sensitive parameters which will be filtered from the log file. +diff --git a/config/initializers/friendly_id.rb b/config/initializers/friendly_id.rb +index 3a88f87b..90586aa8 100644 +--- a/config/initializers/friendly_id.rb ++++ b/config/initializers/friendly_id.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # FriendlyId Global Configuration + # + # Use this to set up shared configuration options for your entire application. +diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb +index 1a2f76e5..ef916e73 100644 +--- a/config/initializers/geocoder.rb ++++ b/config/initializers/geocoder.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'geocodable' + + Geocoder.configure( +diff --git a/config/initializers/growstuff_markdown.rb b/config/initializers/growstuff_markdown.rb +index a7f6781b..901237fb 100644 +--- a/config/initializers/growstuff_markdown.rb ++++ b/config/initializers/growstuff_markdown.rb +@@ -1 +1,3 @@ ++# frozen_string_literal: true ++ + require 'haml/filters/growstuff_markdown' +diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb +index 03943153..39ff77ae 100644 +--- a/config/initializers/inflections.rb ++++ b/config/initializers/inflections.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Be sure to restart your server when you modify this file. + + # Add new inflection rules using the following format. Inflections +diff --git a/config/initializers/jsonapi_resources.rb b/config/initializers/jsonapi_resources.rb +index 1a17dfc0..d4ddadb4 100644 +--- a/config/initializers/jsonapi_resources.rb ++++ b/config/initializers/jsonapi_resources.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + JSONAPI.configure do |config| + # built in paginators are :none, :offset, :paged + config.default_paginator = :offset +diff --git a/config/initializers/leaflet.rb b/config/initializers/leaflet.rb +index 510a9707..3a8c09b6 100644 +--- a/config/initializers/leaflet.rb ++++ b/config/initializers/leaflet.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + Leaflet.tile_layer = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' + Leaflet.attribution = '© OpenStreetMap contributors, CC-BY-SA' + Leaflet.max_zoom = 18 +diff --git a/config/initializers/mailboxer.rb b/config/initializers/mailboxer.rb +index 6f1b0fa7..b43a6151 100644 +--- a/config/initializers/mailboxer.rb ++++ b/config/initializers/mailboxer.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + Mailboxer.setup do |config| + # Configures if your application uses or not email sending for Notifications and Messages + config.uses_emails = true +diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb +index dc189968..6e1d16f0 100644 +--- a/config/initializers/mime_types.rb ++++ b/config/initializers/mime_types.rb +@@ -1,3 +1,4 @@ ++# frozen_string_literal: true + # Be sure to restart your server when you modify this file. + + # Add new mime types for use in respond_to blocks: +diff --git a/config/initializers/new_framework_defaults_5_1.rb b/config/initializers/new_framework_defaults_5_1.rb +index 9010abd5..b33ee806 100644 +--- a/config/initializers/new_framework_defaults_5_1.rb ++++ b/config/initializers/new_framework_defaults_5_1.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Be sure to restart your server when you modify this file. + # + # This file contains migration options to ease your Rails 5.1 upgrade. +diff --git a/config/initializers/new_framework_defaults_5_2.rb b/config/initializers/new_framework_defaults_5_2.rb +index c383d072..7df9ce8f 100644 +--- a/config/initializers/new_framework_defaults_5_2.rb ++++ b/config/initializers/new_framework_defaults_5_2.rb +@@ -1,3 +1,4 @@ ++# frozen_string_literal: true + # Be sure to restart your server when you modify this file. + # + # This file contains migration options to ease your Rails 5.2 upgrade. +diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb +index 160efb10..940d84a4 100644 +--- a/config/initializers/omniauth.rb ++++ b/config/initializers/omniauth.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + Rails.application.config.middleware.use OmniAuth::Builder do + provider :twitter, ENV['GROWSTUFF_TWITTER_KEY'], ENV['GROWSTUFF_TWITTER_SECRET'] + provider :flickr, ENV['GROWSTUFF_FLICKR_KEY'], ENV['GROWSTUFF_FLICKR_SECRET'] +diff --git a/config/initializers/rswag_api.rb b/config/initializers/rswag_api.rb +index 3c027ffd..307807a9 100644 +--- a/config/initializers/rswag_api.rb ++++ b/config/initializers/rswag_api.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + Rswag::Api.configure do |c| + # Specify a root folder where Swagger JSON files are located + # This is used by the Swagger middleware to serve requests for API descriptions +diff --git a/config/initializers/rswag_ui.rb b/config/initializers/rswag_ui.rb +index 4d7adbaa..8b632a43 100644 +--- a/config/initializers/rswag_ui.rb ++++ b/config/initializers/rswag_ui.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + Rswag::Ui.configure do |c| + # List the Swagger endpoints that you want to be documented through the swagger-ui + # The first parameter is the path (absolute or relative to the UI host) to the corresponding +diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb +index 9fc73901..26a833e0 100644 +--- a/config/initializers/session_store.rb ++++ b/config/initializers/session_store.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Be sure to restart your server when you modify this file. + + Rails.application.config.session_store :cookie_store, key: '_growstuff_session' +diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb +index 4dab98d1..15990b73 100644 +--- a/config/initializers/sidekiq.rb ++++ b/config/initializers/sidekiq.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # config/initializers/sidekiq.rb + + Sidekiq.configure_server do |config| +diff --git a/config/initializers/swagger.rb b/config/initializers/swagger.rb +index 0bdadefc..830a9a36 100644 +--- a/config/initializers/swagger.rb ++++ b/config/initializers/swagger.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + Jsonapi::Swagger.config do |config| + config.use_rswag = false + config.version = '2.0' +diff --git a/config/initializers/time_formats.rb b/config/initializers/time_formats.rb +index 3f3adf45..c56b40be 100644 +--- a/config/initializers/time_formats.rb ++++ b/config/initializers/time_formats.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + Time::DATE_FORMATS[:default] = '%B %d, %Y at %H:%M' + Date::DATE_FORMATS[:default] = "%B %d, %Y" + +diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb +index bffab6c8..3d5ac255 100644 +--- a/config/initializers/wrap_parameters.rb ++++ b/config/initializers/wrap_parameters.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Be sure to restart your server when you modify this file. + + # This file contains settings for ActionController::ParamsWrapper which +diff --git a/config/locales/en.yml b/config/locales/en.yml +index adc90fd0..fccdaf45 100644 +--- a/config/locales/en.yml ++++ b/config/locales/en.yml +@@ -125,7 +125,7 @@ en: + title: + crop_harvests: Everyone's %{crop} harvests + default: Everyone's harvests +- owner_harvests: "%{owner} harvests" ++ owner_harvests: "%{owner}'s harvests" + planting_harvests: Harvests from %{planting} + updated: Harvest was successfully updated. + home: +diff --git a/config/routes.rb b/config/routes.rb +index 7efb4d79..5244ed3b 100644 +--- a/config/routes.rb ++++ b/config/routes.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + Rails.application.routes.draw do + mount Rswag::Ui::Engine => '/api-docs' + mount Rswag::Api::Engine => '/api-docs' +@@ -26,11 +28,11 @@ Rails.application.routes.draw do + resources :photos, only: :index + end + +- resources :gardens, concerns: :has_photos do ++ resources :gardens, concerns: :has_photos, param: :slug do + get 'timeline' => 'charts/gardens#timeline', constraints: { format: 'json' } + end + +- resources :plantings, concerns: :has_photos do ++ resources :plantings, concerns: :has_photos, param: :slug do + resources :harvests + resources :seeds + collection do +@@ -38,12 +40,12 @@ Rails.application.routes.draw do + end + end + +- resources :seeds, concerns: :has_photos do +- resources :plantings ++ resources :seeds, concerns: :has_photos, param: :slug do ++ get 'plantings' => 'plantings#index' + get 'crop/:crop' => 'seeds#index', as: 'seeds_by_crop', on: :collection + end + +- resources :harvests, concerns: :has_photos do ++ resources :harvests, concerns: :has_photos, param: :slug do + get 'crop/:crop' => 'harvests#index', as: 'harvests_by_crop', on: :collection + end + +diff --git a/config/setup_load_paths.rb b/config/setup_load_paths.rb +index b78f9aff..36e63028 100644 +--- a/config/setup_load_paths.rb ++++ b/config/setup_load_paths.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + if ENV['MY_RUBY_HOME']&.include?('rvm') + begin + require 'rvm' +diff --git a/config/spring.rb b/config/spring.rb +index c9119b40..ff5ba06b 100644 +--- a/config/spring.rb ++++ b/config/spring.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + %w( + .ruby-version + .rbenv-vars +diff --git a/config/unicorn.rb b/config/unicorn.rb +index fa76bae3..c4218569 100644 +--- a/config/unicorn.rb ++++ b/config/unicorn.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # from https://blog.heroku.com/archives/2013/2/27/unicorn_rails + worker_processes 3 + timeout 30 +diff --git a/db/migrate/20120903092956_devise_create_users.rb b/db/migrate/20120903092956_devise_create_users.rb +index 62d84f3d..08d044fd 100644 +--- a/db/migrate/20120903092956_devise_create_users.rb ++++ b/db/migrate/20120903092956_devise_create_users.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class DeviseCreateUsers < ActiveRecord::Migration[4.2] + def change + create_table(:users) do |t| +diff --git a/db/migrate/20120903112806_add_username_to_users.rb b/db/migrate/20120903112806_add_username_to_users.rb +index 2df3aa56..f27c39cd 100644 +--- a/db/migrate/20120903112806_add_username_to_users.rb ++++ b/db/migrate/20120903112806_add_username_to_users.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddUsernameToUsers < ActiveRecord::Migration[4.2] + def change + add_column :users, :username, :string +diff --git a/db/migrate/20121001212604_create_crops.rb b/db/migrate/20121001212604_create_crops.rb +index 6e6fbcc2..4c2832f3 100644 +--- a/db/migrate/20121001212604_create_crops.rb ++++ b/db/migrate/20121001212604_create_crops.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateCrops < ActiveRecord::Migration[4.2] + def change + create_table :crops do |t| +diff --git a/db/migrate/20121003190731_require_system_name_for_crops.rb b/db/migrate/20121003190731_require_system_name_for_crops.rb +index 7989fcec..1731554c 100644 +--- a/db/migrate/20121003190731_require_system_name_for_crops.rb ++++ b/db/migrate/20121003190731_require_system_name_for_crops.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class RequireSystemNameForCrops < ActiveRecord::Migration[4.2] + def up + change_table :crops do |t| +diff --git a/db/migrate/20121027035231_add_slug_to_crops.rb b/db/migrate/20121027035231_add_slug_to_crops.rb +index d360b4a4..fb31e562 100644 +--- a/db/migrate/20121027035231_add_slug_to_crops.rb ++++ b/db/migrate/20121027035231_add_slug_to_crops.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddSlugToCrops < ActiveRecord::Migration[4.2] + def change + add_column :crops, :slug, :string +diff --git a/db/migrate/20121105032913_create_gardens.rb b/db/migrate/20121105032913_create_gardens.rb +index e6c7834e..41cee244 100644 +--- a/db/migrate/20121105032913_create_gardens.rb ++++ b/db/migrate/20121105032913_create_gardens.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateGardens < ActiveRecord::Migration[4.2] + def change + create_table :gardens do |t| +diff --git a/db/migrate/20121106101718_add_slug_to_users.rb b/db/migrate/20121106101718_add_slug_to_users.rb +index 5840e09d..599eb29c 100644 +--- a/db/migrate/20121106101718_add_slug_to_users.rb ++++ b/db/migrate/20121106101718_add_slug_to_users.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddSlugToUsers < ActiveRecord::Migration[4.2] + def change + add_column :users, :slug, :string +diff --git a/db/migrate/20121107012827_create_scientific_names.rb b/db/migrate/20121107012827_create_scientific_names.rb +index 0e6b179f..bbef3d1b 100644 +--- a/db/migrate/20121107012827_create_scientific_names.rb ++++ b/db/migrate/20121107012827_create_scientific_names.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateScientificNames < ActiveRecord::Migration[4.2] + def change + create_table :scientific_names do |t| +diff --git a/db/migrate/20121108105440_create_updates.rb b/db/migrate/20121108105440_create_updates.rb +index 3caacb74..35ded8d6 100644 +--- a/db/migrate/20121108105440_create_updates.rb ++++ b/db/migrate/20121108105440_create_updates.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateUpdates < ActiveRecord::Migration[4.2] + def change + create_table :updates do |t| +diff --git a/db/migrate/20121109130033_add_creation_index_to_updates.rb b/db/migrate/20121109130033_add_creation_index_to_updates.rb +index 57c24d55..30652d54 100644 +--- a/db/migrate/20121109130033_add_creation_index_to_updates.rb ++++ b/db/migrate/20121109130033_add_creation_index_to_updates.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddCreationIndexToUpdates < ActiveRecord::Migration[4.2] + def change + add_index :updates, %i(created_at user_id) +diff --git a/db/migrate/20121203034745_add_tos_agreement_to_users.rb b/db/migrate/20121203034745_add_tos_agreement_to_users.rb +index 31354ea5..466d8c45 100644 +--- a/db/migrate/20121203034745_add_tos_agreement_to_users.rb ++++ b/db/migrate/20121203034745_add_tos_agreement_to_users.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddTosAgreementToUsers < ActiveRecord::Migration[4.2] + def change + add_column :users, :tos_agreement, :boolean +diff --git a/db/migrate/20121214224227_add_slug_to_updates.rb b/db/migrate/20121214224227_add_slug_to_updates.rb +index 78d25ef2..e0038dba 100644 +--- a/db/migrate/20121214224227_add_slug_to_updates.rb ++++ b/db/migrate/20121214224227_add_slug_to_updates.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddSlugToUpdates < ActiveRecord::Migration[4.2] + def change + add_column :updates, :slug, :string +diff --git a/db/migrate/20121219022554_create_plantings.rb b/db/migrate/20121219022554_create_plantings.rb +index d586e242..f618875d 100644 +--- a/db/migrate/20121219022554_create_plantings.rb ++++ b/db/migrate/20121219022554_create_plantings.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreatePlantings < ActiveRecord::Migration[4.2] + def change + create_table :plantings do |t| +diff --git a/db/migrate/20130113045802_rename_updates_to_posts.rb b/db/migrate/20130113045802_rename_updates_to_posts.rb +index 6329df2b..fecca7c3 100644 +--- a/db/migrate/20130113045802_rename_updates_to_posts.rb ++++ b/db/migrate/20130113045802_rename_updates_to_posts.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class RenameUpdatesToPosts < ActiveRecord::Migration[4.2] + def change + rename_table :updates, :posts +diff --git a/db/migrate/20130113060852_rename_users_to_members.rb b/db/migrate/20130113060852_rename_users_to_members.rb +index bb248186..a278a306 100644 +--- a/db/migrate/20130113060852_rename_users_to_members.rb ++++ b/db/migrate/20130113060852_rename_users_to_members.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class RenameUsersToMembers < ActiveRecord::Migration[4.2] + def change + rename_table :users, :members +diff --git a/db/migrate/20130113081521_rename_post_member_to_author.rb b/db/migrate/20130113081521_rename_post_member_to_author.rb +index a1658925..6cb4ae04 100644 +--- a/db/migrate/20130113081521_rename_post_member_to_author.rb ++++ b/db/migrate/20130113081521_rename_post_member_to_author.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class RenamePostMemberToAuthor < ActiveRecord::Migration[4.2] + def change + rename_column :posts, :member_id, :author_id +diff --git a/db/migrate/20130113095802_rename_garden_member_to_owner.rb b/db/migrate/20130113095802_rename_garden_member_to_owner.rb +index ea6bd4c7..4ebd10d0 100644 +--- a/db/migrate/20130113095802_rename_garden_member_to_owner.rb ++++ b/db/migrate/20130113095802_rename_garden_member_to_owner.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class RenameGardenMemberToOwner < ActiveRecord::Migration[4.2] + def change + rename_column :gardens, :member_id, :owner_id +diff --git a/db/migrate/20130118031942_add_description_to_gardens.rb b/db/migrate/20130118031942_add_description_to_gardens.rb +index f8eb0a44..e846901e 100644 +--- a/db/migrate/20130118031942_add_description_to_gardens.rb ++++ b/db/migrate/20130118031942_add_description_to_gardens.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddDescriptionToGardens < ActiveRecord::Migration[4.2] + def change + add_column :gardens, :description, :text +diff --git a/db/migrate/20130118043431_add_slug_to_plantings.rb b/db/migrate/20130118043431_add_slug_to_plantings.rb +index c4e5d434..5f451a83 100644 +--- a/db/migrate/20130118043431_add_slug_to_plantings.rb ++++ b/db/migrate/20130118043431_add_slug_to_plantings.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddSlugToPlantings < ActiveRecord::Migration[4.2] + def change + add_column :plantings, :slug, :string +diff --git a/db/migrate/20130206033956_create_comments.rb b/db/migrate/20130206033956_create_comments.rb +index 0c4663ec..894da776 100644 +--- a/db/migrate/20130206033956_create_comments.rb ++++ b/db/migrate/20130206033956_create_comments.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateComments < ActiveRecord::Migration[4.2] + def change + create_table :comments do |t| +diff --git a/db/migrate/20130206051328_add_show_email_to_member.rb b/db/migrate/20130206051328_add_show_email_to_member.rb +index 3185b137..de734d58 100644 +--- a/db/migrate/20130206051328_add_show_email_to_member.rb ++++ b/db/migrate/20130206051328_add_show_email_to_member.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddShowEmailToMember < ActiveRecord::Migration[4.2] + def change + add_column :members, :show_email, :boolean +diff --git a/db/migrate/20130208034248_require_fields_for_comments.rb b/db/migrate/20130208034248_require_fields_for_comments.rb +index da847671..eb4ca646 100644 +--- a/db/migrate/20130208034248_require_fields_for_comments.rb ++++ b/db/migrate/20130208034248_require_fields_for_comments.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class RequireFieldsForComments < ActiveRecord::Migration[4.2] + def up + change_table :comments do |t| +diff --git a/db/migrate/20130212001748_add_geo_to_members.rb b/db/migrate/20130212001748_add_geo_to_members.rb +index e60f355f..01406871 100644 +--- a/db/migrate/20130212001748_add_geo_to_members.rb ++++ b/db/migrate/20130212001748_add_geo_to_members.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddGeoToMembers < ActiveRecord::Migration[4.2] + def change + add_column :members, :location, :string +diff --git a/db/migrate/20130212123628_create_notifications.rb b/db/migrate/20130212123628_create_notifications.rb +index b89b1365..978f3054 100644 +--- a/db/migrate/20130212123628_create_notifications.rb ++++ b/db/migrate/20130212123628_create_notifications.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateNotifications < ActiveRecord::Migration[4.2] + def change + create_table :notifications do |t| +diff --git a/db/migrate/20130213014511_create_forums.rb b/db/migrate/20130213014511_create_forums.rb +index 0df3f00a..69a4a30e 100644 +--- a/db/migrate/20130213014511_create_forums.rb ++++ b/db/migrate/20130213014511_create_forums.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateForums < ActiveRecord::Migration[4.2] + def change + create_table :forums do |t| +diff --git a/db/migrate/20130213015708_add_forum_to_posts.rb b/db/migrate/20130213015708_add_forum_to_posts.rb +index 315ae0be..e6225db2 100644 +--- a/db/migrate/20130213015708_add_forum_to_posts.rb ++++ b/db/migrate/20130213015708_add_forum_to_posts.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddForumToPosts < ActiveRecord::Migration[4.2] + def change + add_column :posts, :forum_id, :integer +diff --git a/db/migrate/20130214024117_create_roles.rb b/db/migrate/20130214024117_create_roles.rb +index e39c7565..b0799ecb 100644 +--- a/db/migrate/20130214024117_create_roles.rb ++++ b/db/migrate/20130214024117_create_roles.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateRoles < ActiveRecord::Migration[4.2] + def change + create_table :roles do |t| +diff --git a/db/migrate/20130214034838_add_members_roles_table.rb b/db/migrate/20130214034838_add_members_roles_table.rb +index 502266a8..32c0b191 100644 +--- a/db/migrate/20130214034838_add_members_roles_table.rb ++++ b/db/migrate/20130214034838_add_members_roles_table.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddMembersRolesTable < ActiveRecord::Migration[4.2] + def change + create_table :members_roles, id: false do |t| +diff --git a/db/migrate/20130215131921_rename_notification_fields.rb b/db/migrate/20130215131921_rename_notification_fields.rb +index c2294d2f..7fcdd337 100644 +--- a/db/migrate/20130215131921_rename_notification_fields.rb ++++ b/db/migrate/20130215131921_rename_notification_fields.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class RenameNotificationFields < ActiveRecord::Migration[4.2] + def change + change_table :notifications do |t| +diff --git a/db/migrate/20130220044605_add_slug_to_forums.rb b/db/migrate/20130220044605_add_slug_to_forums.rb +index 57fbdc14..179f883a 100644 +--- a/db/migrate/20130220044605_add_slug_to_forums.rb ++++ b/db/migrate/20130220044605_add_slug_to_forums.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddSlugToForums < ActiveRecord::Migration[4.2] + def change + add_column :forums, :slug, :string +diff --git a/db/migrate/20130220044642_add_slug_to_roles.rb b/db/migrate/20130220044642_add_slug_to_roles.rb +index a3812d77..e867ce13 100644 +--- a/db/migrate/20130220044642_add_slug_to_roles.rb ++++ b/db/migrate/20130220044642_add_slug_to_roles.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddSlugToRoles < ActiveRecord::Migration[4.2] + def change + add_column :roles, :slug, :string +diff --git a/db/migrate/20130222060730_default_read_to_false.rb b/db/migrate/20130222060730_default_read_to_false.rb +index 81a10aa4..40dea83a 100644 +--- a/db/migrate/20130222060730_default_read_to_false.rb ++++ b/db/migrate/20130222060730_default_read_to_false.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class DefaultReadToFalse < ActiveRecord::Migration[4.2] + def up + change_table :notifications do |t| +diff --git a/db/migrate/20130326092227_change_planted_at_to_date.rb b/db/migrate/20130326092227_change_planted_at_to_date.rb +index 089c77ef..b2bd78ae 100644 +--- a/db/migrate/20130326092227_change_planted_at_to_date.rb ++++ b/db/migrate/20130326092227_change_planted_at_to_date.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ChangePlantedAtToDate < ActiveRecord::Migration[4.2] + def change + change_column :plantings, :planted_at, :date +diff --git a/db/migrate/20130327120024_add_send_email_to_member.rb b/db/migrate/20130327120024_add_send_email_to_member.rb +index 5421bb0d..89ff6126 100644 +--- a/db/migrate/20130327120024_add_send_email_to_member.rb ++++ b/db/migrate/20130327120024_add_send_email_to_member.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddSendEmailToMember < ActiveRecord::Migration[4.2] + def change + add_column :members, :send_notification_email, :boolean, default: true +diff --git a/db/migrate/20130329045744_add_sunniness_to_planting.rb b/db/migrate/20130329045744_add_sunniness_to_planting.rb +index 74fe7a65..ec79264c 100644 +--- a/db/migrate/20130329045744_add_sunniness_to_planting.rb ++++ b/db/migrate/20130329045744_add_sunniness_to_planting.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddSunninessToPlanting < ActiveRecord::Migration[4.2] + def change + add_column :plantings, :sunniness, :string +diff --git a/db/migrate/20130404174459_create_authentications.rb b/db/migrate/20130404174459_create_authentications.rb +index 226f1c34..809ad60b 100644 +--- a/db/migrate/20130404174459_create_authentications.rb ++++ b/db/migrate/20130404174459_create_authentications.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateAuthentications < ActiveRecord::Migration[4.2] + def change + create_table :authentications do |t| +diff --git a/db/migrate/20130409103549_make_post_subject_non_null.rb b/db/migrate/20130409103549_make_post_subject_non_null.rb +index ac05aca2..f11815a6 100644 +--- a/db/migrate/20130409103549_make_post_subject_non_null.rb ++++ b/db/migrate/20130409103549_make_post_subject_non_null.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class MakePostSubjectNonNull < ActiveRecord::Migration[4.2] + change_column :posts, :subject, :string, null: false + end +diff --git a/db/migrate/20130409162140_add_name_to_authentications.rb b/db/migrate/20130409162140_add_name_to_authentications.rb +index dabcb623..a0e53008 100644 +--- a/db/migrate/20130409162140_add_name_to_authentications.rb ++++ b/db/migrate/20130409162140_add_name_to_authentications.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddNameToAuthentications < ActiveRecord::Migration[4.2] + def change + add_column :authentications, :name, :string +diff --git a/db/migrate/20130507105357_create_products.rb b/db/migrate/20130507105357_create_products.rb +index 5a1ddd99..ac2ef8b6 100644 +--- a/db/migrate/20130507105357_create_products.rb ++++ b/db/migrate/20130507105357_create_products.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateProducts < ActiveRecord::Migration[4.2] + def change + create_table :products do |t| +diff --git a/db/migrate/20130507110411_create_orders.rb b/db/migrate/20130507110411_create_orders.rb +index 7974f10e..1c4c00c3 100644 +--- a/db/migrate/20130507110411_create_orders.rb ++++ b/db/migrate/20130507110411_create_orders.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateOrders < ActiveRecord::Migration[4.2] + def change + create_table :orders do |t| +diff --git a/db/migrate/20130507113915_add_orders_products_table.rb b/db/migrate/20130507113915_add_orders_products_table.rb +index 3d584508..33e34e6a 100644 +--- a/db/migrate/20130507113915_add_orders_products_table.rb ++++ b/db/migrate/20130507113915_add_orders_products_table.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddOrdersProductsTable < ActiveRecord::Migration[4.2] + def change + create_table :orders_products, id: false do |t| +diff --git a/db/migrate/20130508050711_add_completed_to_order.rb b/db/migrate/20130508050711_add_completed_to_order.rb +index e7c9f422..6640113e 100644 +--- a/db/migrate/20130508050711_add_completed_to_order.rb ++++ b/db/migrate/20130508050711_add_completed_to_order.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddCompletedToOrder < ActiveRecord::Migration[4.2] + def change + add_column :orders, :completed_at, :datetime +diff --git a/db/migrate/20130508104506_create_photos.rb b/db/migrate/20130508104506_create_photos.rb +index b6fb3d19..cb4a55e8 100644 +--- a/db/migrate/20130508104506_create_photos.rb ++++ b/db/migrate/20130508104506_create_photos.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreatePhotos < ActiveRecord::Migration[4.2] + def change + create_table :photos do |t| +diff --git a/db/migrate/20130509123711_add_metadata_to_photos.rb b/db/migrate/20130509123711_add_metadata_to_photos.rb +index e05c260c..5b62473f 100644 +--- a/db/migrate/20130509123711_add_metadata_to_photos.rb ++++ b/db/migrate/20130509123711_add_metadata_to_photos.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddMetadataToPhotos < ActiveRecord::Migration[4.2] + def up + change_table :photos do |t| +diff --git a/db/migrate/20130514124515_add_parent_to_crop.rb b/db/migrate/20130514124515_add_parent_to_crop.rb +index 65427c1c..9557db8e 100644 +--- a/db/migrate/20130514124515_add_parent_to_crop.rb ++++ b/db/migrate/20130514124515_add_parent_to_crop.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddParentToCrop < ActiveRecord::Migration[4.2] + def change + add_column :crops, :parent_id, :integer +diff --git a/db/migrate/20130515033842_create_order_items.rb b/db/migrate/20130515033842_create_order_items.rb +index ed7966f4..6305b381 100644 +--- a/db/migrate/20130515033842_create_order_items.rb ++++ b/db/migrate/20130515033842_create_order_items.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateOrderItems < ActiveRecord::Migration[4.2] + def change + create_table :order_items do |t| +diff --git a/db/migrate/20130515054017_change_order_member_id_to_integer.rb b/db/migrate/20130515054017_change_order_member_id_to_integer.rb +index 508fb13e..4a010dcc 100644 +--- a/db/migrate/20130515054017_change_order_member_id_to_integer.rb ++++ b/db/migrate/20130515054017_change_order_member_id_to_integer.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ChangeOrderMemberIdToInteger < ActiveRecord::Migration[4.2] + def up + remove_column :orders, :member_id +diff --git a/db/migrate/20130515122301_change_prices_to_integers.rb b/db/migrate/20130515122301_change_prices_to_integers.rb +index ef84683b..6a232fe2 100644 +--- a/db/migrate/20130515122301_change_prices_to_integers.rb ++++ b/db/migrate/20130515122301_change_prices_to_integers.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ChangePricesToIntegers < ActiveRecord::Migration[4.2] + def up + change_column :order_items, :price, :integer +diff --git a/db/migrate/20130517015920_create_account_details.rb b/db/migrate/20130517015920_create_account_details.rb +index c949798d..66a04ace 100644 +--- a/db/migrate/20130517015920_create_account_details.rb ++++ b/db/migrate/20130517015920_create_account_details.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateAccountDetails < ActiveRecord::Migration[4.2] + def change + create_table :account_details do |t| +diff --git a/db/migrate/20130517051922_create_account_types.rb b/db/migrate/20130517051922_create_account_types.rb +index 25bef37b..410b0701 100644 +--- a/db/migrate/20130517051922_create_account_types.rb ++++ b/db/migrate/20130517051922_create_account_types.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateAccountTypes < ActiveRecord::Migration[4.2] + def change + create_table :account_types do |t| +diff --git a/db/migrate/20130517234458_require_account_type_name.rb b/db/migrate/20130517234458_require_account_type_name.rb +index 2b118492..d638ad3c 100644 +--- a/db/migrate/20130517234458_require_account_type_name.rb ++++ b/db/migrate/20130517234458_require_account_type_name.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class RequireAccountTypeName < ActiveRecord::Migration[4.2] + def up + change_column :account_types, :name, :string, null: false +diff --git a/db/migrate/20130518000339_add_columns_to_product.rb b/db/migrate/20130518000339_add_columns_to_product.rb +index b3bba302..d6f80fae 100644 +--- a/db/migrate/20130518000339_add_columns_to_product.rb ++++ b/db/migrate/20130518000339_add_columns_to_product.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddColumnsToProduct < ActiveRecord::Migration[4.2] + def change + add_column :products, :account_type_id, :integer +diff --git a/db/migrate/20130518002942_rename_account_detail_to_account.rb b/db/migrate/20130518002942_rename_account_detail_to_account.rb +index a806c63a..cb369ce9 100644 +--- a/db/migrate/20130518002942_rename_account_detail_to_account.rb ++++ b/db/migrate/20130518002942_rename_account_detail_to_account.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class RenameAccountDetailToAccount < ActiveRecord::Migration[4.2] + def change + rename_table :account_details, :accounts +diff --git a/db/migrate/20130529032813_add_express_token_to_orders.rb b/db/migrate/20130529032813_add_express_token_to_orders.rb +index e7d40f41..53de7e9a 100644 +--- a/db/migrate/20130529032813_add_express_token_to_orders.rb ++++ b/db/migrate/20130529032813_add_express_token_to_orders.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddExpressTokenToOrders < ActiveRecord::Migration[4.2] + def change + add_column :orders, :paypal_express_token, :string +diff --git a/db/migrate/20130531110729_add_photos_plantings_table.rb b/db/migrate/20130531110729_add_photos_plantings_table.rb +index f4a3bb7b..cb9c4c52 100644 +--- a/db/migrate/20130531110729_add_photos_plantings_table.rb ++++ b/db/migrate/20130531110729_add_photos_plantings_table.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddPhotosPlantingsTable < ActiveRecord::Migration[4.2] + def change + create_table :photos_plantings, id: false do |t| +diff --git a/db/migrate/20130601011725_change_flickr_photo_id_to_string.rb b/db/migrate/20130601011725_change_flickr_photo_id_to_string.rb +index 92cfa168..b46e4ca2 100644 +--- a/db/migrate/20130601011725_change_flickr_photo_id_to_string.rb ++++ b/db/migrate/20130601011725_change_flickr_photo_id_to_string.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ChangeFlickrPhotoIdToString < ActiveRecord::Migration[4.2] + def up + remove_column :photos, :flickr_photo_id +diff --git a/db/migrate/20130606230333_change_product_description_to_text.rb b/db/migrate/20130606230333_change_product_description_to_text.rb +index 3393a8ae..7bae1e6a 100644 +--- a/db/migrate/20130606230333_change_product_description_to_text.rb ++++ b/db/migrate/20130606230333_change_product_description_to_text.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ChangeProductDescriptionToText < ActiveRecord::Migration[4.2] + def up + change_column :products, :description, :text +diff --git a/db/migrate/20130606233733_add_recommended_price_to_product.rb b/db/migrate/20130606233733_add_recommended_price_to_product.rb +index d424618f..076e20f3 100644 +--- a/db/migrate/20130606233733_add_recommended_price_to_product.rb ++++ b/db/migrate/20130606233733_add_recommended_price_to_product.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddRecommendedPriceToProduct < ActiveRecord::Migration[4.2] + def change + add_column :products, :recommended_price, :integer +diff --git a/db/migrate/20130705104238_add_planted_from_to_planting.rb b/db/migrate/20130705104238_add_planted_from_to_planting.rb +index 1dd4e070..d36ec235 100644 +--- a/db/migrate/20130705104238_add_planted_from_to_planting.rb ++++ b/db/migrate/20130705104238_add_planted_from_to_planting.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddPlantedFromToPlanting < ActiveRecord::Migration[4.2] + def change + add_column :plantings, :planted_from, :string +diff --git a/db/migrate/20130715110134_create_seeds.rb b/db/migrate/20130715110134_create_seeds.rb +index da895571..8065f9ac 100644 +--- a/db/migrate/20130715110134_create_seeds.rb ++++ b/db/migrate/20130715110134_create_seeds.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateSeeds < ActiveRecord::Migration[4.2] + def change + create_table :seeds do |t| +diff --git a/db/migrate/20130718005600_change_use_by_to_plant_before_on_seed.rb b/db/migrate/20130718005600_change_use_by_to_plant_before_on_seed.rb +index b440c270..c33a7398 100644 +--- a/db/migrate/20130718005600_change_use_by_to_plant_before_on_seed.rb ++++ b/db/migrate/20130718005600_change_use_by_to_plant_before_on_seed.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ChangeUseByToPlantBeforeOnSeed < ActiveRecord::Migration[4.2] + def change + rename_column :seeds, :use_by, :plant_before +diff --git a/db/migrate/20130718011247_add_trading_to_seeds.rb b/db/migrate/20130718011247_add_trading_to_seeds.rb +index 52add7f5..0ca32df9 100644 +--- a/db/migrate/20130718011247_add_trading_to_seeds.rb ++++ b/db/migrate/20130718011247_add_trading_to_seeds.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddTradingToSeeds < ActiveRecord::Migration[4.2] + def change + add_column :seeds, :tradable, :boolean +diff --git a/db/migrate/20130722050836_remove_tradable_from_seeds.rb b/db/migrate/20130722050836_remove_tradable_from_seeds.rb +index 9bea0bd1..d668990e 100644 +--- a/db/migrate/20130722050836_remove_tradable_from_seeds.rb ++++ b/db/migrate/20130722050836_remove_tradable_from_seeds.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class RemoveTradableFromSeeds < ActiveRecord::Migration[4.2] + def up + remove_column :seeds, :tradable +diff --git a/db/migrate/20130723103128_set_default_tradable_to_on_seed.rb b/db/migrate/20130723103128_set_default_tradable_to_on_seed.rb +index 56b88aad..5cecac55 100644 +--- a/db/migrate/20130723103128_set_default_tradable_to_on_seed.rb ++++ b/db/migrate/20130723103128_set_default_tradable_to_on_seed.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class SetDefaultTradableToOnSeed < ActiveRecord::Migration[4.2] + def up + change_column_default(:seeds, :tradable_to, 'nowhere') +diff --git a/db/migrate/20130723110702_add_slug_to_seed.rb b/db/migrate/20130723110702_add_slug_to_seed.rb +index ec52bdad..cb4fb704 100644 +--- a/db/migrate/20130723110702_add_slug_to_seed.rb ++++ b/db/migrate/20130723110702_add_slug_to_seed.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddSlugToSeed < ActiveRecord::Migration[4.2] + def change + add_column :seeds, :slug, :string +diff --git a/db/migrate/20130809012511_add_bio_to_members.rb b/db/migrate/20130809012511_add_bio_to_members.rb +index b63d11bb..affc7182 100644 +--- a/db/migrate/20130809012511_add_bio_to_members.rb ++++ b/db/migrate/20130809012511_add_bio_to_members.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddBioToMembers < ActiveRecord::Migration[4.2] + def change + add_column :members, :bio, :text +diff --git a/db/migrate/20130819004549_add_planting_count_to_crop.rb b/db/migrate/20130819004549_add_planting_count_to_crop.rb +index b25fc4a6..21864853 100644 +--- a/db/migrate/20130819004549_add_planting_count_to_crop.rb ++++ b/db/migrate/20130819004549_add_planting_count_to_crop.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddPlantingCountToCrop < ActiveRecord::Migration[4.2] + def change + add_column :crops, :plantings_count, :integer +diff --git a/db/migrate/20130821011352_add_creator_to_crops.rb b/db/migrate/20130821011352_add_creator_to_crops.rb +index 24aab3f7..9847c51a 100644 +--- a/db/migrate/20130821011352_add_creator_to_crops.rb ++++ b/db/migrate/20130821011352_add_creator_to_crops.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddCreatorToCrops < ActiveRecord::Migration[4.2] + def change + add_column :crops, :creator_id, :integer +diff --git a/db/migrate/20130821073736_add_creator_to_scientific_name.rb b/db/migrate/20130821073736_add_creator_to_scientific_name.rb +index e2904811..eb657737 100644 +--- a/db/migrate/20130821073736_add_creator_to_scientific_name.rb ++++ b/db/migrate/20130821073736_add_creator_to_scientific_name.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddCreatorToScientificName < ActiveRecord::Migration[4.2] + def change + add_column :scientific_names, :creator_id, :integer +diff --git a/db/migrate/20130826012139_add_owner_to_planting.rb b/db/migrate/20130826012139_add_owner_to_planting.rb +index 3399870d..9fb48320 100644 +--- a/db/migrate/20130826012139_add_owner_to_planting.rb ++++ b/db/migrate/20130826012139_add_owner_to_planting.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddOwnerToPlanting < ActiveRecord::Migration[4.2] + def change + add_column :plantings, :owner_id, :integer +diff --git a/db/migrate/20130826023159_add_plantings_count_to_member.rb b/db/migrate/20130826023159_add_plantings_count_to_member.rb +index 97347998..c4ad4729 100644 +--- a/db/migrate/20130826023159_add_plantings_count_to_member.rb ++++ b/db/migrate/20130826023159_add_plantings_count_to_member.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddPlantingsCountToMember < ActiveRecord::Migration[4.2] + def change + add_column :members, :plantings_count, :integer +diff --git a/db/migrate/20130827105823_add_newsletter_to_member.rb b/db/migrate/20130827105823_add_newsletter_to_member.rb +index 25f16a69..806f6ed9 100644 +--- a/db/migrate/20130827105823_add_newsletter_to_member.rb ++++ b/db/migrate/20130827105823_add_newsletter_to_member.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddNewsletterToMember < ActiveRecord::Migration[4.2] + def change + add_column :members, :newsletter, :boolean +diff --git a/db/migrate/20130913015118_add_referral_code_to_order.rb b/db/migrate/20130913015118_add_referral_code_to_order.rb +index ff9e5a6f..f4cd52ea 100644 +--- a/db/migrate/20130913015118_add_referral_code_to_order.rb ++++ b/db/migrate/20130913015118_add_referral_code_to_order.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddReferralCodeToOrder < ActiveRecord::Migration[4.2] + def change + add_column :orders, :referral_code, :string +diff --git a/db/migrate/20130917053547_create_harvests.rb b/db/migrate/20130917053547_create_harvests.rb +index f7e529a3..031aeb66 100644 +--- a/db/migrate/20130917053547_create_harvests.rb ++++ b/db/migrate/20130917053547_create_harvests.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateHarvests < ActiveRecord::Migration[4.2] + def change + create_table :harvests do |t| +diff --git a/db/migrate/20130917060257_change_harvest_notes_to_description.rb b/db/migrate/20130917060257_change_harvest_notes_to_description.rb +index 8359c0b9..2c09044d 100644 +--- a/db/migrate/20130917060257_change_harvest_notes_to_description.rb ++++ b/db/migrate/20130917060257_change_harvest_notes_to_description.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ChangeHarvestNotesToDescription < ActiveRecord::Migration[4.2] + def change + rename_column :harvests, :notes, :description +diff --git a/db/migrate/20130917071545_change_harvest_units_to_unit.rb b/db/migrate/20130917071545_change_harvest_units_to_unit.rb +index 7f859f47..21f96af1 100644 +--- a/db/migrate/20130917071545_change_harvest_units_to_unit.rb ++++ b/db/migrate/20130917071545_change_harvest_units_to_unit.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ChangeHarvestUnitsToUnit < ActiveRecord::Migration[4.2] + def change + rename_column :harvests, :units, :unit +diff --git a/db/migrate/20130917075803_add_slug_to_harvests.rb b/db/migrate/20130917075803_add_slug_to_harvests.rb +index b9bc376e..2cad48d7 100644 +--- a/db/migrate/20130917075803_add_slug_to_harvests.rb ++++ b/db/migrate/20130917075803_add_slug_to_harvests.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddSlugToHarvests < ActiveRecord::Migration[4.2] + def change + add_column :harvests, :slug, :string +diff --git a/db/migrate/20130925050304_add_weight_to_harvests.rb b/db/migrate/20130925050304_add_weight_to_harvests.rb +index 1aa43df6..a567938f 100644 +--- a/db/migrate/20130925050304_add_weight_to_harvests.rb ++++ b/db/migrate/20130925050304_add_weight_to_harvests.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddWeightToHarvests < ActiveRecord::Migration[4.2] + def change + add_column :harvests, :weight_quantity, :decimal +diff --git a/db/migrate/20131018101204_rename_system_name_to_name.rb b/db/migrate/20131018101204_rename_system_name_to_name.rb +index 6124d174..d3d3696a 100644 +--- a/db/migrate/20131018101204_rename_system_name_to_name.rb ++++ b/db/migrate/20131018101204_rename_system_name_to_name.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class RenameSystemNameToName < ActiveRecord::Migration[4.2] + def up + # Rails is smart enough to alter the column being indexed, but not the name +diff --git a/db/migrate/20131025104228_add_fields_to_gardens.rb b/db/migrate/20131025104228_add_fields_to_gardens.rb +index e77a9c6c..385493b1 100644 +--- a/db/migrate/20131025104228_add_fields_to_gardens.rb ++++ b/db/migrate/20131025104228_add_fields_to_gardens.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddFieldsToGardens < ActiveRecord::Migration[4.2] + def change + add_column :gardens, :active, :boolean, default: true +diff --git a/db/migrate/20131029053113_add_plant_part_to_harvests.rb b/db/migrate/20131029053113_add_plant_part_to_harvests.rb +index fad21613..a3e32b44 100644 +--- a/db/migrate/20131029053113_add_plant_part_to_harvests.rb ++++ b/db/migrate/20131029053113_add_plant_part_to_harvests.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddPlantPartToHarvests < ActiveRecord::Migration[4.2] + def change + add_column :harvests, :plant_part, :string +diff --git a/db/migrate/20131030230908_create_plant_parts.rb b/db/migrate/20131030230908_create_plant_parts.rb +index f3454f97..6c0ac467 100644 +--- a/db/migrate/20131030230908_create_plant_parts.rb ++++ b/db/migrate/20131030230908_create_plant_parts.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreatePlantParts < ActiveRecord::Migration[4.2] + def change + create_table :plant_parts do |t| +diff --git a/db/migrate/20131030231202_change_plant_part_to_plant_part_id.rb b/db/migrate/20131030231202_change_plant_part_to_plant_part_id.rb +index 134eeca9..ae9ce783 100644 +--- a/db/migrate/20131030231202_change_plant_part_to_plant_part_id.rb ++++ b/db/migrate/20131030231202_change_plant_part_to_plant_part_id.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ChangePlantPartToPlantPartId < ActiveRecord::Migration[4.2] + def up + remove_column :harvests, :plant_part +diff --git a/db/migrate/20131031000655_add_slug_to_plant_part.rb b/db/migrate/20131031000655_add_slug_to_plant_part.rb +index 242c3077..1078fd4c 100644 +--- a/db/migrate/20131031000655_add_slug_to_plant_part.rb ++++ b/db/migrate/20131031000655_add_slug_to_plant_part.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddSlugToPlantPart < ActiveRecord::Migration[4.2] + def change + add_column :plant_parts, :slug, :string +diff --git a/db/migrate/20140718075753_default_plantings_count_to_zero.rb b/db/migrate/20140718075753_default_plantings_count_to_zero.rb +index 15ee6df8..472e1740 100644 +--- a/db/migrate/20140718075753_default_plantings_count_to_zero.rb ++++ b/db/migrate/20140718075753_default_plantings_count_to_zero.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class DefaultPlantingsCountToZero < ActiveRecord::Migration[4.2] + def up + change_column :crops, :plantings_count, :integer, default: 0 +diff --git a/db/migrate/20140829230600_add_finished_to_planting.rb b/db/migrate/20140829230600_add_finished_to_planting.rb +index 868298f6..461f49c2 100644 +--- a/db/migrate/20140829230600_add_finished_to_planting.rb ++++ b/db/migrate/20140829230600_add_finished_to_planting.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddFinishedToPlanting < ActiveRecord::Migration[4.2] + def change + add_column :plantings, :finished, :boolean, default: false +diff --git a/db/migrate/20140905001730_add_harvests_photos_table.rb b/db/migrate/20140905001730_add_harvests_photos_table.rb +index f05ae013..d83c91f8 100644 +--- a/db/migrate/20140905001730_add_harvests_photos_table.rb ++++ b/db/migrate/20140905001730_add_harvests_photos_table.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddHarvestsPhotosTable < ActiveRecord::Migration[4.2] + def change + create_table :harvests_photos, id: false do |t| +diff --git a/db/migrate/20140928044231_add_crops_posts_table.rb b/db/migrate/20140928044231_add_crops_posts_table.rb +index a9e8761f..529530fe 100644 +--- a/db/migrate/20140928044231_add_crops_posts_table.rb ++++ b/db/migrate/20140928044231_add_crops_posts_table.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddCropsPostsTable < ActiveRecord::Migration[4.2] + def change + create_table :crops_posts, id: false do |t| +diff --git a/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb b/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb +index cd464eee..d2f5316d 100644 +--- a/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb ++++ b/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddSendPlantingReminderToMember < ActiveRecord::Migration[4.2] + def change + add_column :members, :send_planting_reminder, :boolean, default: true +diff --git a/db/migrate/20141002022459_create_index_harvest_photos.rb b/db/migrate/20141002022459_create_index_harvest_photos.rb +index f9c8ee91..26e9f8e7 100644 +--- a/db/migrate/20141002022459_create_index_harvest_photos.rb ++++ b/db/migrate/20141002022459_create_index_harvest_photos.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateIndexHarvestPhotos < ActiveRecord::Migration[4.2] + def change + add_index(:harvests_photos, %i(harvest_id photo_id)) +diff --git a/db/migrate/20141018111015_create_alternate_names.rb b/db/migrate/20141018111015_create_alternate_names.rb +index 65400cc2..bd1cd496 100644 +--- a/db/migrate/20141018111015_create_alternate_names.rb ++++ b/db/migrate/20141018111015_create_alternate_names.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateAlternateNames < ActiveRecord::Migration[4.2] + def change + create_table :alternate_names do |t| +diff --git a/db/migrate/20141111130849_create_follows.rb b/db/migrate/20141111130849_create_follows.rb +index 5ca3f9b1..02f585a6 100644 +--- a/db/migrate/20141111130849_create_follows.rb ++++ b/db/migrate/20141111130849_create_follows.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateFollows < ActiveRecord::Migration[4.2] + def change + create_table :follows do |t| +diff --git a/db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb b/db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb +index a777fc79..4d980c52 100644 +--- a/db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb ++++ b/db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ChangeFollowsMemberIdToFollowerId < ActiveRecord::Migration[4.2] + def change + rename_column :follows, :member_id, :follower_id +diff --git a/db/migrate/20150124110540_add_properties_to_seeds.rb b/db/migrate/20150124110540_add_properties_to_seeds.rb +index 0adb9660..48e4f2c3 100644 +--- a/db/migrate/20150124110540_add_properties_to_seeds.rb ++++ b/db/migrate/20150124110540_add_properties_to_seeds.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddPropertiesToSeeds < ActiveRecord::Migration[4.2] + def change + add_column :seeds, :days_until_maturity_min, :integer +diff --git a/db/migrate/20150127043022_add_gardens_photos_table.rb b/db/migrate/20150127043022_add_gardens_photos_table.rb +index 45917424..a2a7a990 100644 +--- a/db/migrate/20150127043022_add_gardens_photos_table.rb ++++ b/db/migrate/20150127043022_add_gardens_photos_table.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddGardensPhotosTable < ActiveRecord::Migration[4.2] + def change + create_table :gardens_photos, id: false do |t| +diff --git a/db/migrate/20150129034206_add_si_weight_to_harvest.rb b/db/migrate/20150129034206_add_si_weight_to_harvest.rb +index 881d4ad0..6429ad57 100644 +--- a/db/migrate/20150129034206_add_si_weight_to_harvest.rb ++++ b/db/migrate/20150129034206_add_si_weight_to_harvest.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddSiWeightToHarvest < ActiveRecord::Migration[4.2] + def change + add_column :harvests, :si_weight, :float +diff --git a/db/migrate/20150130224814_add_requester_to_crops.rb b/db/migrate/20150130224814_add_requester_to_crops.rb +index 0d9f7094..9d223a5e 100644 +--- a/db/migrate/20150130224814_add_requester_to_crops.rb ++++ b/db/migrate/20150130224814_add_requester_to_crops.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddRequesterToCrops < ActiveRecord::Migration[4.2] + def change + add_column :crops, :requester_id, :integer +diff --git a/db/migrate/20150201052245_create_cms.rb b/db/migrate/20150201052245_create_cms.rb +index 4dc1a5d2..9a193751 100644 +--- a/db/migrate/20150201052245_create_cms.rb ++++ b/db/migrate/20150201052245_create_cms.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateCms < ActiveRecord::Migration[4.2] + def self.up # rubocop:disable Metrics/MethodLength, Metrics/AbcSize + text_limit = case ActiveRecord::Base.connection.adapter_name +diff --git a/db/migrate/20150201053200_add_approval_status_to_crops.rb b/db/migrate/20150201053200_add_approval_status_to_crops.rb +index ff6b12cb..48101c5d 100644 +--- a/db/migrate/20150201053200_add_approval_status_to_crops.rb ++++ b/db/migrate/20150201053200_add_approval_status_to_crops.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddApprovalStatusToCrops < ActiveRecord::Migration[4.2] + def change + add_column :crops, :approval_status, :string, default: "approved" +diff --git a/db/migrate/20150201062506_add_reason_for_rejection_to_crops.rb b/db/migrate/20150201062506_add_reason_for_rejection_to_crops.rb +index 001cd795..37703676 100644 +--- a/db/migrate/20150201062506_add_reason_for_rejection_to_crops.rb ++++ b/db/migrate/20150201062506_add_reason_for_rejection_to_crops.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddReasonForRejectionToCrops < ActiveRecord::Migration[4.2] + def change + add_column :crops, :reason_for_rejection, :text +diff --git a/db/migrate/20150201064502_add_request_notes_to_crops.rb b/db/migrate/20150201064502_add_request_notes_to_crops.rb +index 433c5ad3..b2c21a82 100644 +--- a/db/migrate/20150201064502_add_request_notes_to_crops.rb ++++ b/db/migrate/20150201064502_add_request_notes_to_crops.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddRequestNotesToCrops < ActiveRecord::Migration[4.2] + def change + add_column :crops, :request_notes, :text +diff --git a/db/migrate/20150203080226_create_likes.rb b/db/migrate/20150203080226_create_likes.rb +index b5f7d427..e49ce9b5 100644 +--- a/db/migrate/20150203080226_create_likes.rb ++++ b/db/migrate/20150203080226_create_likes.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateLikes < ActiveRecord::Migration[4.2] + def change + create_table :likes do |t| +diff --git a/db/migrate/20150209105410_add_rejection_notes_to_crops.rb b/db/migrate/20150209105410_add_rejection_notes_to_crops.rb +index 44fc9fb7..3ee48d7c 100644 +--- a/db/migrate/20150209105410_add_rejection_notes_to_crops.rb ++++ b/db/migrate/20150209105410_add_rejection_notes_to_crops.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddRejectionNotesToCrops < ActiveRecord::Migration[4.2] + def change + add_column :crops, :rejection_notes, :text +diff --git a/db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb b/db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb +index c60e6f6a..39630353 100644 +--- a/db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb ++++ b/db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddDaysBeforeMaturityToPlantings < ActiveRecord::Migration[4.2] + def change + add_column :plantings, :days_before_maturity, :integer +diff --git a/db/migrate/20150824145414_add_member_preferred_image.rb b/db/migrate/20150824145414_add_member_preferred_image.rb +index c3c56337..9243318d 100644 +--- a/db/migrate/20150824145414_add_member_preferred_image.rb ++++ b/db/migrate/20150824145414_add_member_preferred_image.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddMemberPreferredImage < ActiveRecord::Migration[4.2] + def change + add_column :members, :preferred_avatar_uri, :string +diff --git a/db/migrate/20161129021533_rename_scientific_name.rb b/db/migrate/20161129021533_rename_scientific_name.rb +index 3aac2e5d..f5a76c5a 100644 +--- a/db/migrate/20161129021533_rename_scientific_name.rb ++++ b/db/migrate/20161129021533_rename_scientific_name.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class RenameScientificName < ActiveRecord::Migration[4.2] + def self.up + rename_column :scientific_names, :scientific_name, :name +diff --git a/db/migrate/20161201154922_add_photos_seeds_table.rb b/db/migrate/20161201154922_add_photos_seeds_table.rb +index bbe7478c..8031d2ca 100644 +--- a/db/migrate/20161201154922_add_photos_seeds_table.rb ++++ b/db/migrate/20161201154922_add_photos_seeds_table.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddPhotosSeedsTable < ActiveRecord::Migration[4.2] + def change + create_table :photos_seeds, id: false do |t| +diff --git a/db/migrate/20170104035248_add_planting_ref_to_harvests.rb b/db/migrate/20170104035248_add_planting_ref_to_harvests.rb +index 515ffaa8..3c197dcd 100644 +--- a/db/migrate/20170104035248_add_planting_ref_to_harvests.rb ++++ b/db/migrate/20170104035248_add_planting_ref_to_harvests.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddPlantingRefToHarvests < ActiveRecord::Migration[4.2] + def change + add_reference :harvests, :planting, index: true, foreign_key: true +diff --git a/db/migrate/20170413221549_counter_caches.rb b/db/migrate/20170413221549_counter_caches.rb +index 27f4f1f6..76e3b72c 100644 +--- a/db/migrate/20170413221549_counter_caches.rb ++++ b/db/migrate/20170413221549_counter_caches.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CounterCaches < ActiveRecord::Migration[4.2] + def change + add_column :members, :gardens_count, :integer +diff --git a/db/migrate/20170520060252_add_deleted_to_members.rb b/db/migrate/20170520060252_add_deleted_to_members.rb +index 3e7059ae..4e370ff3 100644 +--- a/db/migrate/20170520060252_add_deleted_to_members.rb ++++ b/db/migrate/20170520060252_add_deleted_to_members.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddDeletedToMembers < ActiveRecord::Migration[4.2] + def change + add_column :members, :deleted_at, :datetime +diff --git a/db/migrate/20171022032108_all_the_predictions.rb b/db/migrate/20171022032108_all_the_predictions.rb +index aa0f1bfd..80f18df2 100644 +--- a/db/migrate/20171022032108_all_the_predictions.rb ++++ b/db/migrate/20171022032108_all_the_predictions.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AllThePredictions < ActiveRecord::Migration[4.2] + def change + add_column :crops, :perennial, :boolean, default: false +diff --git a/db/migrate/20171028230429_create_median_function.rb b/db/migrate/20171028230429_create_median_function.rb +index 5e57c01d..1b1e44e5 100644 +--- a/db/migrate/20171028230429_create_median_function.rb ++++ b/db/migrate/20171028230429_create_median_function.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateMedianFunction < ActiveRecord::Migration[4.2] + def up + ActiveMedian.create_function +diff --git a/db/migrate/20171105011017_set_prediction_data.rb b/db/migrate/20171105011017_set_prediction_data.rb +index 8dfd91b4..795e6c15 100644 +--- a/db/migrate/20171105011017_set_prediction_data.rb ++++ b/db/migrate/20171105011017_set_prediction_data.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class SetPredictionData < ActiveRecord::Migration[4.2] + def up + say "Updating all plantings time to first harvest" +diff --git a/db/migrate/20171129041341_create_photographings.rb b/db/migrate/20171129041341_create_photographings.rb +index a80245b5..2ae1168d 100644 +--- a/db/migrate/20171129041341_create_photographings.rb ++++ b/db/migrate/20171129041341_create_photographings.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreatePhotographings < ActiveRecord::Migration[4.2] + def change + create_table :photographings do |t| +diff --git a/db/migrate/20180118112809_add_datetaken_to_photos.rb b/db/migrate/20180118112809_add_datetaken_to_photos.rb +index 03fae107..59030559 100644 +--- a/db/migrate/20180118112809_add_datetaken_to_photos.rb ++++ b/db/migrate/20180118112809_add_datetaken_to_photos.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddDatetakenToPhotos < ActiveRecord::Migration[4.2] + def change + add_column :photos, :date_taken, :datetime +diff --git a/db/migrate/20180205000612_remove_shop.rb b/db/migrate/20180205000612_remove_shop.rb +index 6977f127..17248e3d 100644 +--- a/db/migrate/20180205000612_remove_shop.rb ++++ b/db/migrate/20180205000612_remove_shop.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class RemoveShop < ActiveRecord::Migration[4.2] + def up + drop_table :order_items +diff --git a/db/migrate/20180213005731_seed_usage.rb b/db/migrate/20180213005731_seed_usage.rb +index 8f7112e4..ddb2c237 100644 +--- a/db/migrate/20180213005731_seed_usage.rb ++++ b/db/migrate/20180213005731_seed_usage.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class SeedUsage < ActiveRecord::Migration[4.2] + def change + # # seed can be all sown, meaning there is none left +diff --git a/db/migrate/20180401220637_add_member_count_caches.rb b/db/migrate/20180401220637_add_member_count_caches.rb +index 912db008..8f10b0c6 100644 +--- a/db/migrate/20180401220637_add_member_count_caches.rb ++++ b/db/migrate/20180401220637_add_member_count_caches.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddMemberCountCaches < ActiveRecord::Migration[4.2] + def change + add_column :members, :photos_count, :integer +diff --git a/db/migrate/20190130090437_add_crop_to_photographings.rb b/db/migrate/20190130090437_add_crop_to_photographings.rb +index 3b4ad878..e74f57b6 100644 +--- a/db/migrate/20190130090437_add_crop_to_photographings.rb ++++ b/db/migrate/20190130090437_add_crop_to_photographings.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddCropToPhotographings < ActiveRecord::Migration[5.2] + def change + add_column(:photographings, :crop_id, :integer) +diff --git a/db/migrate/20190317023129_finished_boolean.rb b/db/migrate/20190317023129_finished_boolean.rb +index ac652431..8ba8c73e 100644 +--- a/db/migrate/20190317023129_finished_boolean.rb ++++ b/db/migrate/20190317023129_finished_boolean.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class FinishedBoolean < ActiveRecord::Migration[5.2] + def change + Planting.unscoped.where('finished_at < now()').update_all(finished: true) +diff --git a/db/migrate/20190326063855_create_garden_types.rb b/db/migrate/20190326063855_create_garden_types.rb +index 0d7ca230..d844eb78 100644 +--- a/db/migrate/20190326063855_create_garden_types.rb ++++ b/db/migrate/20190326063855_create_garden_types.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateGardenTypes < ActiveRecord::Migration[5.2] + def change + create_table :garden_types do |t| +diff --git a/db/migrate/20190326224347_add_harvests_count.rb b/db/migrate/20190326224347_add_harvests_count.rb +index 9557ffda..fc5b6bdc 100644 +--- a/db/migrate/20190326224347_add_harvests_count.rb ++++ b/db/migrate/20190326224347_add_harvests_count.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddHarvestsCount < ActiveRecord::Migration[5.2] + def change + add_column :plantings, :harvests_count, :integer, default: 0 +diff --git a/db/migrate/20190712003735_add_like_counter_caches.rb b/db/migrate/20190712003735_add_like_counter_caches.rb +index 92c29249..c956d6f8 100644 +--- a/db/migrate/20190712003735_add_like_counter_caches.rb ++++ b/db/migrate/20190712003735_add_like_counter_caches.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddLikeCounterCaches < ActiveRecord::Migration[5.2] + def change + change_table :photos do |t| +diff --git a/db/migrate/20190712234859_rename_photographings.rb b/db/migrate/20190712234859_rename_photographings.rb +index 7f9a5127..09ea403e 100644 +--- a/db/migrate/20190712234859_rename_photographings.rb ++++ b/db/migrate/20190712234859_rename_photographings.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class RenamePhotographings < ActiveRecord::Migration[5.2] + def change + rename_table :photographings, :photo_associations +diff --git a/db/migrate/20190720000555_create_mailboxer.mailboxer_engine.rb b/db/migrate/20190720000555_create_mailboxer.mailboxer_engine.rb +index 943d04e8..04ab2fd9 100644 +--- a/db/migrate/20190720000555_create_mailboxer.mailboxer_engine.rb ++++ b/db/migrate/20190720000555_create_mailboxer.mailboxer_engine.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # This migration comes from mailboxer_engine (originally 20110511145103) + class CreateMailboxer < ActiveRecord::Migration[4.2] + def self.up +diff --git a/db/migrate/20190720000556_add_conversation_optout.mailboxer_engine.rb b/db/migrate/20190720000556_add_conversation_optout.mailboxer_engine.rb +index 50eeeed0..fa062c83 100644 +--- a/db/migrate/20190720000556_add_conversation_optout.mailboxer_engine.rb ++++ b/db/migrate/20190720000556_add_conversation_optout.mailboxer_engine.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # This migration comes from mailboxer_engine (originally 20131206080416) + class AddConversationOptout < ActiveRecord::Migration[4.2] + def self.up +diff --git a/db/migrate/20190720000557_add_missing_indices.mailboxer_engine.rb b/db/migrate/20190720000557_add_missing_indices.mailboxer_engine.rb +index 87c15483..b6e79300 100644 +--- a/db/migrate/20190720000557_add_missing_indices.mailboxer_engine.rb ++++ b/db/migrate/20190720000557_add_missing_indices.mailboxer_engine.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # This migration comes from mailboxer_engine (originally 20131206080417) + class AddMissingIndices < ActiveRecord::Migration[4.2] + def change +diff --git a/db/migrate/20190720000558_add_delivery_tracking_info_to_mailboxer_receipts.mailboxer_engine.rb b/db/migrate/20190720000558_add_delivery_tracking_info_to_mailboxer_receipts.mailboxer_engine.rb +index 498d152d..547e3e44 100644 +--- a/db/migrate/20190720000558_add_delivery_tracking_info_to_mailboxer_receipts.mailboxer_engine.rb ++++ b/db/migrate/20190720000558_add_delivery_tracking_info_to_mailboxer_receipts.mailboxer_engine.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # This migration comes from mailboxer_engine (originally 20151103080417) + class AddDeliveryTrackingInfoToMailboxerReceipts < ActiveRecord::Migration[4.2] + def change +diff --git a/db/migrate/20190720000625_notifications_to_mailboxer.rb b/db/migrate/20190720000625_notifications_to_mailboxer.rb +index 1dabd892..fb488cff 100644 +--- a/db/migrate/20190720000625_notifications_to_mailboxer.rb ++++ b/db/migrate/20190720000625_notifications_to_mailboxer.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class NotificationsToMailboxer < ActiveRecord::Migration[5.2] + def up + Mailboxer.setup do |config| +diff --git a/db/migrate/20190721042146_paranoia_to_discard.rb b/db/migrate/20190721042146_paranoia_to_discard.rb +index 4b880336..bdebe321 100644 +--- a/db/migrate/20190721042146_paranoia_to_discard.rb ++++ b/db/migrate/20190721042146_paranoia_to_discard.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class ParanoiaToDiscard < ActiveRecord::Migration[5.2] + def change + rename_column :members, :deleted_at, :discarded_at +diff --git a/db/migrate/20190902004225_add_openfarm_data_to_crops.rb b/db/migrate/20190902004225_add_openfarm_data_to_crops.rb +index f8cc4d43..61b3e1ee 100644 +--- a/db/migrate/20190902004225_add_openfarm_data_to_crops.rb ++++ b/db/migrate/20190902004225_add_openfarm_data_to_crops.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddOpenfarmDataToCrops < ActiveRecord::Migration[5.2] + def change + add_column :crops, :openfarm_data, :jsonb +diff --git a/db/migrate/20190910022329_add_photo_source.rb b/db/migrate/20190910022329_add_photo_source.rb +index 44e9a9d7..302cf68c 100644 +--- a/db/migrate/20190910022329_add_photo_source.rb ++++ b/db/migrate/20190910022329_add_photo_source.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddPhotoSource < ActiveRecord::Migration[5.2] + def change + add_column :photos, :source, :string +diff --git a/db/migrate/20190915065209_create_crop_companions.rb b/db/migrate/20190915065209_create_crop_companions.rb +index 1b9d1b97..b50fba28 100644 +--- a/db/migrate/20190915065209_create_crop_companions.rb ++++ b/db/migrate/20190915065209_create_crop_companions.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CreateCropCompanions < ActiveRecord::Migration[5.2] + def change + create_table :crop_companions do |t| +diff --git a/db/migrate/20190918033319_unique_urls.rb b/db/migrate/20190918033319_unique_urls.rb +index 99b9caf4..ed1da03d 100644 +--- a/db/migrate/20190918033319_unique_urls.rb ++++ b/db/migrate/20190918033319_unique_urls.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class UniqueUrls < ActiveRecord::Migration[5.2] + def change + add_index :photos, :fullsize_url, unique: true +diff --git a/db/migrate/20190921211652_crop_posts.rb b/db/migrate/20190921211652_crop_posts.rb +index c7f2950c..de8b5d39 100644 +--- a/db/migrate/20190921211652_crop_posts.rb ++++ b/db/migrate/20190921211652_crop_posts.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CropPosts < ActiveRecord::Migration[5.2] + def change + rename_table :crops_posts, :crop_posts +diff --git a/db/migrate/20191029024101_add_saved_at_to_seeds.rb b/db/migrate/20191029024101_add_saved_at_to_seeds.rb +index 745bdf5e..ccbf598e 100644 +--- a/db/migrate/20191029024101_add_saved_at_to_seeds.rb ++++ b/db/migrate/20191029024101_add_saved_at_to_seeds.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class AddSavedAtToSeeds < ActiveRecord::Migration[5.2] + def change + add_column :seeds, :saved_at, :date +diff --git a/db/migrate/20191119020643_upgrade_cms.rb b/db/migrate/20191119020643_upgrade_cms.rb +index 8b2b34f5..8256e910 100644 +--- a/db/migrate/20191119020643_upgrade_cms.rb ++++ b/db/migrate/20191119020643_upgrade_cms.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class UpgradeCms < ActiveRecord::Migration[5.2] + def change + rename_table :comfy_cms_blocks, :comfy_cms_fragments +diff --git a/db/migrate/20191119030244_cms_tags.rb b/db/migrate/20191119030244_cms_tags.rb +index fa3ef0d4..918f6a32 100644 +--- a/db/migrate/20191119030244_cms_tags.rb ++++ b/db/migrate/20191119030244_cms_tags.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class CmsTags < ActiveRecord::Migration[5.2] + def up + Comfy::Cms::Layout.all.each do |layout| +diff --git a/db/migrate/20191209202348_add_harvest_count_to_crop.rb b/db/migrate/20191209202348_add_harvest_count_to_crop.rb +new file mode 100644 +index 00000000..46b5f073 +--- /dev/null ++++ b/db/migrate/20191209202348_add_harvest_count_to_crop.rb +@@ -0,0 +1,66 @@ ++# frozen_string_literal: true ++ ++class AddHarvestCountToCrop < ActiveRecord::Migration[5.2] ++ def change ++ change_table :crops do |t| ++ t.integer :harvests_count, default: 0 ++ t.integer :photo_associations_count, default: 0 ++ end ++ change_table :plant_parts do |t| ++ t.integer :harvests_count, default: 0 ++ end ++ change_table :posts do |t| ++ t.integer :comments_count, default: 0 ++ end ++ reversible do |dir| ++ dir.up { data } ++ end ++ end ++ ++ def data ++ execute <<-SQL.squish ++ UPDATE crops ++ SET harvests_count = ( ++ SELECT count(1) ++ FROM harvests ++ WHERE harvests.crop_id = crops.id ++ ) ++ SQL ++ execute <<-SQL.squish ++ UPDATE crops ++ SET photo_associations_count = ( ++ SELECT count(1) ++ FROM photo_associations ++ WHERE photo_associations.crop_id = crops.id ++ ) ++ SQL ++ execute <<-SQL.squish ++ UPDATE plant_parts ++ SET harvests_count = ( ++ SELECT count(1) ++ FROM harvests ++ WHERE harvests.plant_part_id = plant_parts.id ++ ) ++ SQL ++ ++ execute <<-SQL.squish ++ UPDATE posts ++ SET comments_count = ( ++ SELECT count(1) ++ FROM comments ++ WHERE comments.post_id = posts.id ++ ) ++ SQL ++ ++ say 'indexing crops' ++ Crop.reindex ++ say 'indexing plantings' ++ Planting.reindex ++ say 'indexing seeds' ++ Seed.reindex ++ say 'indexing harvests' ++ Harvest.reindex ++ say 'indexing photos' ++ Photo.reindex ++ end ++end +diff --git a/db/schema.rb b/db/schema.rb +index 06d7be21..a701305f 100644 +--- a/db/schema.rb ++++ b/db/schema.rb +@@ -10,7 +10,7 @@ + # + # It's strongly recommended that you check this file into your version control system. + +-ActiveRecord::Schema.define(version: 2019_11_19_030244) do ++ActiveRecord::Schema.define(version: 2019_12_09_202348) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" +@@ -196,6 +196,8 @@ ActiveRecord::Schema.define(version: 2019_11_19_030244) do + t.integer "median_days_to_first_harvest" + t.integer "median_days_to_last_harvest" + t.jsonb "openfarm_data" ++ t.integer "harvests_count", default: 0 ++ t.integer "photo_associations_count", default: 0 + t.index ["name"], name: "index_crops_on_name" + t.index ["requester_id"], name: "index_crops_on_requester_id" + t.index ["slug"], name: "index_crops_on_slug", unique: true +@@ -458,6 +460,7 @@ ActiveRecord::Schema.define(version: 2019_11_19_030244) do + t.datetime "created_at" + t.datetime "updated_at" + t.string "slug" ++ t.integer "harvests_count", default: 0 + end + + create_table "plantings", id: :serial, force: :cascade do |t| +@@ -491,6 +494,7 @@ ActiveRecord::Schema.define(version: 2019_11_19_030244) do + t.string "slug" + t.integer "forum_id" + t.integer "likes_count", default: 0 ++ t.integer "comments_count", default: 0 + t.index ["created_at", "author_id"], name: "index_posts_on_created_at_and_author_id" + t.index ["slug"], name: "index_posts_on_slug", unique: true + end +diff --git a/db/seeds.rb b/db/seeds.rb +index ed57b6b7..d3ac333b 100644 +--- a/db/seeds.rb ++++ b/db/seeds.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # This file should contain all the record creation needed to seed the database with its default values. + # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). + +diff --git a/lib/actions/oauth_signup_action.rb b/lib/actions/oauth_signup_action.rb +index de274dc3..cd1f7d76 100644 +--- a/lib/actions/oauth_signup_action.rb ++++ b/lib/actions/oauth_signup_action.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + class Growstuff::OauthSignupAction + # + # Inspects the omniauth information +diff --git a/lib/geocodable.rb b/lib/geocodable.rb +index f1bb243f..7d3b3c8e 100644 +--- a/lib/geocodable.rb ++++ b/lib/geocodable.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module Geocodable + def self.included(base) + base.extend(self) +diff --git a/lib/haml/filters/escaped_markdown.rb b/lib/haml/filters/escaped_markdown.rb +index 86345b5a..d68f0661 100644 +--- a/lib/haml/filters/escaped_markdown.rb ++++ b/lib/haml/filters/escaped_markdown.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'bluecloth' + require 'haml/filters/growstuff_markdown' + +diff --git a/lib/haml/filters/growstuff_markdown.rb b/lib/haml/filters/growstuff_markdown.rb +index 52dff709..d5869e7f 100644 +--- a/lib/haml/filters/growstuff_markdown.rb ++++ b/lib/haml/filters/growstuff_markdown.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'bluecloth' + + module Haml::Filters +diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake +index 6c185c7b..137243f0 100644 +--- a/lib/tasks/growstuff.rake ++++ b/lib/tasks/growstuff.rake +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + namespace :growstuff do + desc "Add an admin user, by name" + # usage: rake growstuff:admin_user name=skud +diff --git a/lib/tasks/hooks.rake b/lib/tasks/hooks.rake +index 67cc41cb..051902ed 100644 +--- a/lib/tasks/hooks.rake ++++ b/lib/tasks/hooks.rake +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + desc "Install git hooks" + task :hooks do + FileUtils.symlink '../../script/pre-commit.sh', '.git/hooks/pre-commit', +diff --git a/lib/tasks/i18n.rake b/lib/tasks/i18n.rake +index 04fa8001..8a0f9d8c 100644 +--- a/lib/tasks/i18n.rake ++++ b/lib/tasks/i18n.rake +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + namespace :i18n do + desc "sort all i18n locale keys" + task :normalize do +diff --git a/lib/tasks/openfarm.rake b/lib/tasks/openfarm.rake +index b6b6ce90..92ca9cc3 100644 +--- a/lib/tasks/openfarm.rake ++++ b/lib/tasks/openfarm.rake +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + namespace :openfarm do + desc "Retrieve crop info from open farm" + # usage: rake growstuff:admin_user name=skud +diff --git a/lib/tasks/search.rake b/lib/tasks/search.rake +index 71f9da6b..d93fd601 100644 +--- a/lib/tasks/search.rake ++++ b/lib/tasks/search.rake +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + namespace :search do + desc 'reindex' + task reindex: :environment do +diff --git a/lib/tasks/testing.rake b/lib/tasks/testing.rake +index 1120f6ca..d6a5fd5c 100644 +--- a/lib/tasks/testing.rake ++++ b/lib/tasks/testing.rake +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rake' + begin + require 'rspec/core/rake_task' +diff --git a/script/check_contributors_md.rb b/script/check_contributors_md.rb +index 9aa3fa29..d0013e78 100755 +--- a/script/check_contributors_md.rb ++++ b/script/check_contributors_md.rb +@@ -1,4 +1,6 @@ + #!/usr/bin/env ruby ++# frozen_string_literal: true ++ + require "English" + + puts "Checking to see if you're in CONTRIBUTORS.md..." +diff --git a/script/check_static.rb b/script/check_static.rb +index e747599f..f82932a9 100755 +--- a/script/check_static.rb ++++ b/script/check_static.rb +@@ -1,4 +1,5 @@ + #!/usr/bin/env ruby ++# frozen_string_literal: true + + checks = [ + # 'overcommit -r', +diff --git a/script/heroku_maintenance.rb b/script/heroku_maintenance.rb +index d2a20d67..1c285a28 100755 +--- a/script/heroku_maintenance.rb ++++ b/script/heroku_maintenance.rb +@@ -1,4 +1,5 @@ + #!/usr/bin/env ruby ++# frozen_string_literal: true + + require 'platform-api' + require 'yaml' +diff --git a/spec/controllers/admin/roles_controller_spec.rb b/spec/controllers/admin/roles_controller_spec.rb +index 86694a74..cb2a193e 100644 +--- a/spec/controllers/admin/roles_controller_spec.rb ++++ b/spec/controllers/admin/roles_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe Admin::RolesController do +diff --git a/spec/controllers/admin_controller_spec.rb b/spec/controllers/admin_controller_spec.rb +index 7f0e5620..b1b22289 100644 +--- a/spec/controllers/admin_controller_spec.rb ++++ b/spec/controllers/admin_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe AdminController do +diff --git a/spec/controllers/authentications_controller_spec.rb b/spec/controllers/authentications_controller_spec.rb +index 372d44c4..d4bc8ad5 100644 +--- a/spec/controllers/authentications_controller_spec.rb ++++ b/spec/controllers/authentications_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe AuthenticationsController do +diff --git a/spec/controllers/charts/crops_controller_spec.rb b/spec/controllers/charts/crops_controller_spec.rb +index 3a6a40bb..dd08302b 100644 +--- a/spec/controllers/charts/crops_controller_spec.rb ++++ b/spec/controllers/charts/crops_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe Charts::CropsController do +diff --git a/spec/controllers/charts/gardens_controller_spec.rb b/spec/controllers/charts/gardens_controller_spec.rb +index d264388f..b6a2bd1c 100644 +--- a/spec/controllers/charts/gardens_controller_spec.rb ++++ b/spec/controllers/charts/gardens_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe Charts::GardensController do +@@ -7,7 +9,7 @@ describe Charts::GardensController do + + context "when not signed in" do + describe 'GET timeline' do +- before { get :timeline, params: { garden_id: garden.to_param } } ++ before { get :timeline, params: { garden_slug: garden.to_param } } + + it { expect(response).to be_successful } + end +@@ -19,7 +21,7 @@ describe Charts::GardensController do + let!(:member) { FactoryBot.create(:member) } + + describe 'GET timeline' do +- before { get :timeline, params: { garden_id: garden.to_param } } ++ before { get :timeline, params: { garden_slug: garden.to_param } } + + it { expect(response).to be_successful } + end +diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb +index 741b19ff..4e8b64ce 100644 +--- a/spec/controllers/comments_controller_spec.rb ++++ b/spec/controllers/comments_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe CommentsController do +diff --git a/spec/controllers/crops_controller_spec.rb b/spec/controllers/crops_controller_spec.rb +index 1bb737c9..8681b479 100644 +--- a/spec/controllers/crops_controller_spec.rb ++++ b/spec/controllers/crops_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe CropsController do +diff --git a/spec/controllers/forums_controller_spec.rb b/spec/controllers/forums_controller_spec.rb +index 5c59473c..065ff32d 100644 +--- a/spec/controllers/forums_controller_spec.rb ++++ b/spec/controllers/forums_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe ForumsController do +diff --git a/spec/controllers/garden_types_controller_spec.rb b/spec/controllers/garden_types_controller_spec.rb +index 53bc9cae..e3c46675 100644 +--- a/spec/controllers/garden_types_controller_spec.rb ++++ b/spec/controllers/garden_types_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + RSpec.describe GardenTypesController, type: :controller do +diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb +index 3222829f..31930445 100644 +--- a/spec/controllers/gardens_controller_spec.rb ++++ b/spec/controllers/gardens_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + RSpec.describe GardensController, type: :controller do +@@ -8,7 +10,7 @@ RSpec.describe GardensController, type: :controller do + + context "when not signed in" do + describe 'GET new' do +- before { get :new, params: { id: garden.to_param } } ++ before { get :new, params: { slug: garden.to_param } } + + it { expect(response).to redirect_to(new_member_session_path) } + end +@@ -30,19 +32,19 @@ RSpec.describe GardensController, type: :controller do + end + + describe 'GET edit' do +- before { get :edit, params: { id: garden.to_param } } ++ before { get :edit, params: { slug: garden.to_param } } + + it { expect(response).to redirect_to(new_member_session_path) } + end + + describe 'POST update' do +- before { post :update, params: { id: garden.to_param, garden: valid_params } } ++ before { post :update, params: { slug: garden.to_param, garden: valid_params } } + + it { expect(response).to redirect_to(new_member_session_path) } + end + + describe 'DELETE' do +- before { delete :destroy, params: { id: garden.to_param, params: { garden: valid_params } } } ++ before { delete :destroy, params: { slug: garden.to_param, params: { garden: valid_params } } } + + it { expect(response).to redirect_to(new_member_session_path) } + end +@@ -67,19 +69,19 @@ RSpec.describe GardensController, type: :controller do + end + + describe 'GET edit' do +- before { get :edit, params: { id: not_my_garden.to_param } } ++ before { get :edit, params: { slug: not_my_garden.to_param } } + + it { expect(response).to redirect_to(root_path) } + end + + describe 'POST update' do +- before { post :update, params: { id: not_my_garden.to_param, garden: valid_params } } ++ before { post :update, params: { slug: not_my_garden.to_param, garden: valid_params } } + + it { expect(response).to redirect_to(root_path) } + end + + describe 'DELETE' do +- before { delete :destroy, params: { id: not_my_garden.to_param, params: { garden: valid_params } } } ++ before { delete :destroy, params: { slug: not_my_garden.to_param, params: { garden: valid_params } } } + + it { expect(response).to redirect_to(root_path) } + end +diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb +index b77eb9b5..7e9c01ff 100644 +--- a/spec/controllers/harvests_controller_spec.rb ++++ b/spec/controllers/harvests_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe HarvestsController do +@@ -20,24 +22,30 @@ describe HarvestsController do + let!(:harvest1) { FactoryBot.create(:harvest, owner_id: member1.id, crop_id: tomato.id) } + let!(:harvest2) { FactoryBot.create(:harvest, owner_id: member2.id, crop_id: maize.id) } + ++ before { Harvest.reindex } ++ + describe "assigns all harvests as @harvests" do + before { get :index, params: {} } + +- it { expect(assigns(:harvests)).to eq [harvest1, harvest2] } ++ it { expect(assigns(:harvests).size).to eq 2 } ++ it { expect(assigns(:harvests)[0]['slug']).to eq harvest1.slug } ++ it { expect(assigns(:harvests)[1]['slug']).to eq harvest2.slug } + end + + describe "picks up owner from params and shows owner's harvests only" do + before { get :index, params: { member_slug: member1.slug } } + + it { expect(assigns(:owner)).to eq member1 } +- it { expect(assigns(:harvests)).to eq [harvest1] } ++ it { expect(assigns(:harvests).size).to eq 1 } ++ it { expect(assigns(:harvests)[0]['slug']).to eq harvest1.slug } + end + + describe "picks up crop from params and shows the harvests for the crop only" do + before { get :index, params: { crop_slug: maize.name } } + + it { expect(assigns(:crop)).to eq maize } +- it { expect(assigns(:harvests)).to eq [harvest2] } ++ it { expect(assigns(:harvests).size).to eq 1 } ++ it { expect(assigns(:harvests)[0]['slug']).to eq harvest2.slug } + end + + describe "generates a csv" do +@@ -51,7 +59,7 @@ describe HarvestsController do + let(:harvest) { Harvest.create! valid_attributes } + + describe "assigns the requested harvest as @harvest" do +- before { get :show, params: { id: harvest.to_param } } ++ before { get :show, params: { slug: harvest.to_param } } + + it { expect(assigns(:harvest)).to eq(harvest) } + end +@@ -73,7 +81,7 @@ describe HarvestsController do + let(:harvest) { Harvest.create! valid_attributes } + + describe "assigns the requested harvest as @harvest" do +- before { get :edit, params: { id: harvest.to_param } } ++ before { get :edit, params: { slug: harvest.to_param } } + + it { expect(assigns(:harvest)).to eq(harvest) } + end +@@ -147,19 +155,19 @@ describe HarvestsController do + it "updates the requested harvest" do + new_crop = FactoryBot.create :crop + expect do +- put :update, params: { id: harvest.to_param, harvest: { crop_id: new_crop.id } } ++ put :update, params: { slug: harvest.to_param, harvest: { crop_id: new_crop.id } } + harvest.reload + end.to change(harvest, :crop_id).to(new_crop.id) + end + + describe "assigns the requested harvest as @harvest" do +- before { put :update, params: { id: harvest.to_param, harvest: valid_attributes } } ++ before { put :update, params: { slug: harvest.to_param, harvest: valid_attributes } } + + it { expect(assigns(:harvest)).to eq(harvest) } + end + + describe "redirects to the harvest" do +- before { put :update, params: { id: harvest.to_param, harvest: valid_attributes } } ++ before { put :update, params: { slug: harvest.to_param, harvest: valid_attributes } } + + it { expect(response).to redirect_to(harvest) } + end +@@ -170,13 +178,13 @@ describe HarvestsController do + harvest = Harvest.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Harvest.any_instance.stub(:save).and_return(false) +- put :update, params: { id: harvest.to_param, harvest: { "crop_id" => "invalid value" } } ++ put :update, params: { slug: harvest.to_param, harvest: { "crop_id" => "invalid value" } } + expect(assigns(:harvest)).to eq(harvest) + end + + it "re-renders the 'edit' template" do + harvest = Harvest.create! valid_attributes +- put :update, params: { id: harvest.to_param, harvest: { "crop_id" => "invalid value" } } ++ put :update, params: { slug: harvest.to_param, harvest: { "crop_id" => "invalid value" } } + expect(response).to render_template("edit") + end + end +@@ -187,7 +195,7 @@ describe HarvestsController do + + describe "does not save planting_id" do + before do +- put :update, params: { id: harvest.to_param, ++ put :update, params: { slug: harvest.to_param, + harvest: valid_attributes.merge(planting_id: not_my_planting.id) } + end + +@@ -200,13 +208,13 @@ describe HarvestsController do + it "destroys the requested harvest" do + harvest = Harvest.create! valid_attributes + expect do +- delete :destroy, params: { id: harvest.to_param } ++ delete :destroy, params: { slug: harvest.to_param } + end.to change(Harvest, :count).by(-1) + end + + it "redirects to the harvests list" do + harvest = Harvest.create! valid_attributes +- delete :destroy, params: { id: harvest.to_param } ++ delete :destroy, params: { slug: harvest.to_param } + expect(response).to redirect_to(harvests_url) + end + end +diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb +index cb12b2bb..608addc3 100644 +--- a/spec/controllers/home_controller_spec.rb ++++ b/spec/controllers/home_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe HomeController do +diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb +index 6730b0a8..98567827 100644 +--- a/spec/controllers/likes_controller_spec.rb ++++ b/spec/controllers/likes_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe LikesController do +diff --git a/spec/controllers/member_controller_spec.rb b/spec/controllers/member_controller_spec.rb +index 5ec80e34..6e6997e9 100644 +--- a/spec/controllers/member_controller_spec.rb ++++ b/spec/controllers/member_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe MembersController do +diff --git a/spec/controllers/photo_associations_controller_spec.rb b/spec/controllers/photo_associations_controller_spec.rb +index 21ed0aa2..65d89e9f 100644 +--- a/spec/controllers/photo_associations_controller_spec.rb ++++ b/spec/controllers/photo_associations_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe PhotoAssociationsController do +diff --git a/spec/controllers/places_controller_spec.rb b/spec/controllers/places_controller_spec.rb +index a32d27c2..640adfcb 100644 +--- a/spec/controllers/places_controller_spec.rb ++++ b/spec/controllers/places_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe PlacesController do +diff --git a/spec/controllers/plant_parts_controller_spec.rb b/spec/controllers/plant_parts_controller_spec.rb +index c6e11f31..94e1e4c8 100644 +--- a/spec/controllers/plant_parts_controller_spec.rb ++++ b/spec/controllers/plant_parts_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe PlantPartsController do +diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb +index c055d776..2a3b4daa 100644 +--- a/spec/controllers/plantings_controller_spec.rb ++++ b/spec/controllers/plantings_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe PlantingsController do +@@ -10,7 +12,7 @@ describe PlantingsController do + } + end + +- describe "GET index" do ++ describe "GET index", :search do + let!(:member1) { FactoryBot.create(:member) } + let!(:member2) { FactoryBot.create(:member) } + let!(:tomato) { FactoryBot.create(:tomato) } +@@ -21,21 +23,24 @@ describe PlantingsController do + describe "assigns all plantings as @plantings" do + before { get :index } + +- it { expect(assigns(:plantings)).to match [planting1, planting2] } ++ it { expect(assigns(:plantings).size).to eq 2 } ++ it { expect(assigns(:plantings)[0]['slug']).to eq planting1.slug } ++ it { expect(assigns(:plantings)[1]['slug']).to eq planting2.slug } + end + + describe "picks up owner from params and shows owner's plantings only" do + before { get :index, params: { member_slug: member1.slug } } + + it { expect(assigns(:owner)).to eq member1 } +- it { expect(assigns(:plantings)).to eq [planting1] } ++ it { expect(assigns(:plantings).size).to eq 1 } ++ it { expect(assigns(:plantings).first['slug']).to eq planting1.slug } + end + + describe "picks up crop from params and shows the plantings for the crop only" do + before { get :index, params: { crop_slug: maize.slug } } + + it { expect(assigns(:crop)).to eq maize } +- it { expect(assigns(:plantings)).to eq [planting2] } ++ it { expect(assigns(:plantings).first['slug']).to eq planting2.slug } + end + end + +@@ -117,4 +122,19 @@ describe PlantingsController do + it { expect(assigns(:planting).owner).to eq subject.current_member } + end + end ++ ++ describe 'GET :edit' do ++ let(:my_planting) { FactoryBot.create :planting, owner: member } ++ let(:not_my_planting) { FactoryBot.create :planting } ++ context 'my planting' do ++ before { get :edit, params: { slug: my_planting } } ++ it { expect(assigns(:planting)).to eq my_planting } ++ end ++ ++ context 'not my planting' do ++ before { get :edit, params: { slug: not_my_planting } } ++ ++ it { expect(response).to redirect_to(root_path) } ++ end ++ end + end +diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb +index 0842e4a5..1bae41f1 100644 +--- a/spec/controllers/posts_controller_spec.rb ++++ b/spec/controllers/posts_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe PostsController do +diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb +index 82b52652..71b62810 100644 +--- a/spec/controllers/registrations_controller_spec.rb ++++ b/spec/controllers/registrations_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe RegistrationsController do +diff --git a/spec/controllers/robots_controller_spec.rb b/spec/controllers/robots_controller_spec.rb +index b45a8b23..5c94c1ff 100644 +--- a/spec/controllers/robots_controller_spec.rb ++++ b/spec/controllers/robots_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe RobotsController do +diff --git a/spec/controllers/scientific_names_controller_spec.rb b/spec/controllers/scientific_names_controller_spec.rb +index a5673545..d7b1612a 100644 +--- a/spec/controllers/scientific_names_controller_spec.rb ++++ b/spec/controllers/scientific_names_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe ScientificNamesController do +diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb +index 1c6e89bb..c8fdf27c 100644 +--- a/spec/controllers/seeds_controller_spec.rb ++++ b/spec/controllers/seeds_controller_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe SeedsController do +diff --git a/spec/custom_matchers.rb b/spec/custom_matchers.rb +index 1cb9d61a..972c939e 100644 +--- a/spec/custom_matchers.rb ++++ b/spec/custom_matchers.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rspec/expectations' + + RSpec::Matchers.define :have_optional do |expected| +diff --git a/spec/factories/alternate_names.rb b/spec/factories/alternate_names.rb +index 44cee8a2..df991c2b 100644 +--- a/spec/factories/alternate_names.rb ++++ b/spec/factories/alternate_names.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Read about factories at https://github.com/thoughtbot/factory_bot + + FactoryBot.define do +diff --git a/spec/factories/authentications.rb b/spec/factories/authentications.rb +index 97a34f6c..d93c37bb 100644 +--- a/spec/factories/authentications.rb ++++ b/spec/factories/authentications.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Read about factories at https://github.com/thoughtbot/factory_bot + + FactoryBot.define do +diff --git a/spec/factories/comments.rb b/spec/factories/comments.rb +index 5b726bd4..e030d34d 100644 +--- a/spec/factories/comments.rb ++++ b/spec/factories/comments.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + FactoryBot.define do + factory :comment do + post +diff --git a/spec/factories/crop.rb b/spec/factories/crop.rb +index b1c23a95..72e5d1e7 100644 +--- a/spec/factories/crop.rb ++++ b/spec/factories/crop.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + FactoryBot.define do + factory :crop do + name { "magic bean" } +@@ -51,6 +53,11 @@ FactoryBot.define do + name { "eggplant" } + end + ++ factory :crop_with_photo do ++ name { 'marshmallow' } ++ photos { FactoryBot.create_list :photo, 1 } ++ end ++ + # This should have a name that is alphabetically earlier than :uppercase + # crop to ensure that the ordering tests work. + factory :lowercasecrop do +diff --git a/spec/factories/crop_companions.rb b/spec/factories/crop_companions.rb +index 6db4f0eb..ea58b9e0 100644 +--- a/spec/factories/crop_companions.rb ++++ b/spec/factories/crop_companions.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + FactoryBot.define do + factory :crop_companion do + end +diff --git a/spec/factories/follows.rb b/spec/factories/follows.rb +index a6c609e4..4f608067 100644 +--- a/spec/factories/follows.rb ++++ b/spec/factories/follows.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + FactoryBot.define do + factory :follow do + follower +diff --git a/spec/factories/forums.rb b/spec/factories/forums.rb +index ba1e6cf8..79591579 100644 +--- a/spec/factories/forums.rb ++++ b/spec/factories/forums.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Read about factories at https://github.com/thoughtbot/factory_bot + + FactoryBot.define do +diff --git a/spec/factories/garden.rb b/spec/factories/garden.rb +index d11dcd0d..b7a5edde 100644 +--- a/spec/factories/garden.rb ++++ b/spec/factories/garden.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + FactoryBot.define do + factory :garden do + name { Faker::Vehicle.vin } +diff --git a/spec/factories/garden_types.rb b/spec/factories/garden_types.rb +index 942fd793..02d5ec75 100644 +--- a/spec/factories/garden_types.rb ++++ b/spec/factories/garden_types.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + FactoryBot.define do + factory :garden_type do + name { "homemade swamp" } +diff --git a/spec/factories/harvests.rb b/spec/factories/harvests.rb +index 426c3d24..d4bd0f18 100644 +--- a/spec/factories/harvests.rb ++++ b/spec/factories/harvests.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Read about factories at https://github.com/thoughtbot/factory_bot + + FactoryBot.define do +diff --git a/spec/factories/like.rb b/spec/factories/like.rb +index bf19554b..ffb41c8d 100644 +--- a/spec/factories/like.rb ++++ b/spec/factories/like.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + FactoryBot.define do + factory :like do + member +diff --git a/spec/factories/member.rb b/spec/factories/member.rb +index 87b5326f..3a02e2c3 100644 +--- a/spec/factories/member.rb ++++ b/spec/factories/member.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + FactoryBot.define do + factory :member, aliases: %i(author owner sender recipient creator) do + login_name { (0...8).map { rand(65..90).chr }.join } +diff --git a/spec/factories/notifications.rb b/spec/factories/notifications.rb +index 4d2cee82..a143c777 100644 +--- a/spec/factories/notifications.rb ++++ b/spec/factories/notifications.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Read about factories at https://github.com/thoughtbot/factory_bot + + FactoryBot.define do +diff --git a/spec/factories/photos.rb b/spec/factories/photos.rb +index 41e581d2..405edfd7 100644 +--- a/spec/factories/photos.rb ++++ b/spec/factories/photos.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Read about factories at https://github.com/thoughtbot/factory_bot + + FactoryBot.define do +diff --git a/spec/factories/plant_parts.rb b/spec/factories/plant_parts.rb +index 42a30afd..7fecd326 100644 +--- a/spec/factories/plant_parts.rb ++++ b/spec/factories/plant_parts.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Read about factories at https://github.com/thoughtbot/factory_bot + + FactoryBot.define do +diff --git a/spec/factories/planting.rb b/spec/factories/planting.rb +index 8fb709d1..cfdcd2b1 100644 +--- a/spec/factories/planting.rb ++++ b/spec/factories/planting.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + FactoryBot.define do + factory :planting do + owner +diff --git a/spec/factories/post.rb b/spec/factories/post.rb +index f3471042..c035fdbe 100644 +--- a/spec/factories/post.rb ++++ b/spec/factories/post.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + FactoryBot.define do + factory :post do + subject { Faker::Book.title } +diff --git a/spec/factories/roles.rb b/spec/factories/roles.rb +index 3e33d972..c7c57f7e 100644 +--- a/spec/factories/roles.rb ++++ b/spec/factories/roles.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Read about factories at https://github.com/thoughtbot/factory_bot + + FactoryBot.define do +diff --git a/spec/factories/scientific_name.rb b/spec/factories/scientific_name.rb +index 7e0e0446..ec43799c 100644 +--- a/spec/factories/scientific_name.rb ++++ b/spec/factories/scientific_name.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + FactoryBot.define do + factory :scientific_name do + association :crop, factory: :crop +diff --git a/spec/factories/seeds.rb b/spec/factories/seeds.rb +index 2f523859..deafb530 100644 +--- a/spec/factories/seeds.rb ++++ b/spec/factories/seeds.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Read about factories at https://github.com/thoughtbot/factory_bot + + FactoryBot.define do +diff --git a/spec/features/admin/admin_spec.rb b/spec/features/admin/admin_spec.rb +index cbd83bf5..f5b384d5 100644 +--- a/spec/features/admin/admin_spec.rb ++++ b/spec/features/admin/admin_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "forums", js: true do +diff --git a/spec/features/admin/forums_spec.rb b/spec/features/admin/forums_spec.rb +index 7a41266c..ab44e2ae 100644 +--- a/spec/features/admin/forums_spec.rb ++++ b/spec/features/admin/forums_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "forums", js: true do +diff --git a/spec/features/cms_spec.rb b/spec/features/cms_spec.rb +index d13fc1b4..253750cf 100644 +--- a/spec/features/cms_spec.rb ++++ b/spec/features/cms_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "cms admin" do +diff --git a/spec/features/comments/commenting_a_comment_spec.rb b/spec/features/comments/commenting_a_comment_spec.rb +index 6debc9d1..ded09272 100644 +--- a/spec/features/comments/commenting_a_comment_spec.rb ++++ b/spec/features/comments/commenting_a_comment_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'Commenting on a post' do +diff --git a/spec/features/conversations/index_spec.rb b/spec/features/conversations/index_spec.rb +index 969fc447..9df3b584 100644 +--- a/spec/features/conversations/index_spec.rb ++++ b/spec/features/conversations/index_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Conversations", :js do +diff --git a/spec/features/conversations/show_spec.rb b/spec/features/conversations/show_spec.rb +index ccf92fb8..1bcfb887 100644 +--- a/spec/features/conversations/show_spec.rb ++++ b/spec/features/conversations/show_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Conversations", :js do +diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb +index adfc3b4e..bb4843e0 100644 +--- a/spec/features/crops/alternate_name_spec.rb ++++ b/spec/features/crops/alternate_name_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Alternate names", js: true do +diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb +index d60727bb..07a0f5a4 100644 +--- a/spec/features/crops/browse_crops_spec.rb ++++ b/spec/features/crops/browse_crops_spec.rb +@@ -1,6 +1,8 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + +-describe "browse crops" do ++describe "browse crops", :search do + let!(:tomato) { FactoryBot.create :tomato } + let!(:maize) { FactoryBot.create :maize } + let!(:pending_crop) { FactoryBot.create :crop_request } +@@ -8,6 +10,7 @@ describe "browse crops" do + + shared_examples 'shows crops' do + before { visit crops_path } ++ + it "has a form for sorting by" do + expect(page).to have_css "select#sort" + end +diff --git a/spec/features/crops/creating_a_crop_spec.rb b/spec/features/crops/creating_a_crop_spec.rb +index 6240db8d..c4782975 100644 +--- a/spec/features/crops/creating_a_crop_spec.rb ++++ b/spec/features/crops/creating_a_crop_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Crop", js: true do +diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb +index cec0579a..ec1ff63c 100644 +--- a/spec/features/crops/crop_detail_page_spec.rb ++++ b/spec/features/crops/crop_detail_page_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "crop detail page", js: true do +diff --git a/spec/features/crops/crop_photos_spec.rb b/spec/features/crops/crop_photos_spec.rb +index 13ecc14a..1fc44772 100644 +--- a/spec/features/crops/crop_photos_spec.rb ++++ b/spec/features/crops/crop_photos_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "crop detail page", js: true do +diff --git a/spec/features/crops/crop_search_spec.rb b/spec/features/crops/crop_search_spec.rb +index b87655a0..af39c174 100644 +--- a/spec/features/crops/crop_search_spec.rb ++++ b/spec/features/crops/crop_search_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "crop search" do +diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb +index 5dd8af71..328e560c 100644 +--- a/spec/features/crops/crop_wranglers_spec.rb ++++ b/spec/features/crops/crop_wranglers_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "crop wranglers", js: true do +diff --git a/spec/features/crops/crop_wrangling_button_spec.rb b/spec/features/crops/crop_wrangling_button_spec.rb +index 3545db9f..a081aff7 100644 +--- a/spec/features/crops/crop_wrangling_button_spec.rb ++++ b/spec/features/crops/crop_wrangling_button_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "crop wrangling button" do +diff --git a/spec/features/crops/delete_crop_spec.rb b/spec/features/crops/delete_crop_spec.rb +index 41092c89..941496e1 100644 +--- a/spec/features/crops/delete_crop_spec.rb ++++ b/spec/features/crops/delete_crop_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Delete crop spec" do +diff --git a/spec/features/crops/inflections_spec.rb b/spec/features/crops/inflections_spec.rb +index c7ca5ce3..9df14594 100644 +--- a/spec/features/crops/inflections_spec.rb ++++ b/spec/features/crops/inflections_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "irregular crop inflections" do +diff --git a/spec/features/crops/request_new_crop_spec.rb b/spec/features/crops/request_new_crop_spec.rb +index da38b1ec..3964ad6b 100644 +--- a/spec/features/crops/request_new_crop_spec.rb ++++ b/spec/features/crops/request_new_crop_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Requesting a new crop" do +diff --git a/spec/features/crops/requested_crops_spec.rb b/spec/features/crops/requested_crops_spec.rb +index e73292c1..0556fb2a 100644 +--- a/spec/features/crops/requested_crops_spec.rb ++++ b/spec/features/crops/requested_crops_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Requesting Crops" do +diff --git a/spec/features/crops/scientific_name_spec.rb b/spec/features/crops/scientific_name_spec.rb +index 63fad9ee..a8a523cb 100644 +--- a/spec/features/crops/scientific_name_spec.rb ++++ b/spec/features/crops/scientific_name_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Scientific names", js: true do +diff --git a/spec/features/crops/show_spec.rb b/spec/features/crops/show_spec.rb +index 48d08325..a219f774 100644 +--- a/spec/features/crops/show_spec.rb ++++ b/spec/features/crops/show_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "browse crops" do +diff --git a/spec/features/footer_spec.rb b/spec/features/footer_spec.rb +index 8d6225ec..6e5713f6 100644 +--- a/spec/features/footer_spec.rb ++++ b/spec/features/footer_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "footer", js: true do +diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb +index 74fc1080..6c1fc8b4 100644 +--- a/spec/features/gardens/actions_spec.rb ++++ b/spec/features/gardens/actions_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + require 'custom_matchers' + +diff --git a/spec/features/gardens/adding_gardens_spec.rb b/spec/features/gardens/adding_gardens_spec.rb +index 7320a124..d281e965 100644 +--- a/spec/features/gardens/adding_gardens_spec.rb ++++ b/spec/features/gardens/adding_gardens_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + require 'custom_matchers' + +diff --git a/spec/features/gardens/gardens_spec.rb b/spec/features/gardens/gardens_spec.rb +index 6b845bc5..71465795 100644 +--- a/spec/features/gardens/gardens_spec.rb ++++ b/spec/features/gardens/gardens_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Planting a crop", js: true do +diff --git a/spec/features/gardens/index_spec.rb b/spec/features/gardens/index_spec.rb +index b5eb5d3d..00cfad3a 100644 +--- a/spec/features/gardens/index_spec.rb ++++ b/spec/features/gardens/index_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + require 'custom_matchers' + +diff --git a/spec/features/harvests/browse_harvests_spec.rb b/spec/features/harvests/browse_harvests_spec.rb +index 6ead7e23..a4467262 100644 +--- a/spec/features/harvests/browse_harvests_spec.rb ++++ b/spec/features/harvests/browse_harvests_spec.rb +@@ -1,12 +1,15 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + +-describe "browse harvests" do ++describe "browse harvests", :search do + subject { page } + + let!(:harvest) { create :harvest, owner: member } + + context 'signed in' do + include_context 'signed in member' ++ + describe 'blank optional fields' do + let!(:harvest) { create :harvest, :no_description } + +@@ -20,9 +23,7 @@ describe "browse harvests" do + describe "filled in optional fields" do + let!(:harvest) { create :harvest, :long_description } + +- before do +- visit harvests_path +- end ++ before { visit harvests_path } + + it 'links to #show' do + expect(subject).to have_link harvest.crop.name, href: harvest_path(harvest) +diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb +index a551d4df..9d4daa5c 100644 +--- a/spec/features/harvests/harvesting_a_crop_spec.rb ++++ b/spec/features/harvests/harvesting_a_crop_spec.rb +@@ -1,7 +1,9 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + require 'custom_matchers' + +-describe "Harvesting a crop", :js do ++describe "Harvesting a crop", :js, :search do + context 'signed in' do + include_context 'signed in member' + let!(:maize) { create :maize } +@@ -38,12 +40,15 @@ describe "Harvesting a crop", :js do + expect(page).to have_content "harvest was successfully created." + end + +- it "Clicking link to owner's profile" do +- visit member_harvests_path(member) +- within '.login-name' do +- click_link member.login_name ++ describe 'member harvests' do ++ before { visit member_harvests_path(member) } ++ it { expect(page).to have_text "#{member.login_name}'s harvests" } ++ it "Clicking link to owner's profile" do ++ within '.login-name' do ++ click_link member.login_name ++ end ++ expect(current_path).to eq member_path(member) + end +- expect(current_path).to eq member_path member + end + + describe "Harvesting from crop page" do +diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb +index cbd14b4d..fa6bddae 100644 +--- a/spec/features/home/home_spec.rb ++++ b/spec/features/home/home_spec.rb +@@ -1,6 +1,8 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + +-describe "home page" do ++describe "home page", :search do + subject { page } + + let(:member) { FactoryBot.create :member } +@@ -21,7 +23,10 @@ describe "home page" do + planting.photos << photo + seed.photos << photo + harvest.photos << photo +- Crop.reindex ++ Crop.searchkick_index.refresh ++ Planting.searchkick_index.refresh ++ Seed.searchkick_index.refresh ++ Harvest.searchkick_index.refresh + end + + before { visit root_path } +diff --git a/spec/features/likeable_spec.rb b/spec/features/likeable_spec.rb +index 95503efa..0b44d374 100644 +--- a/spec/features/likeable_spec.rb ++++ b/spec/features/likeable_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'Likeable', js: true do +diff --git a/spec/features/locale_spec.rb b/spec/features/locale_spec.rb +index 2dce809a..ac4ba081 100644 +--- a/spec/features/locale_spec.rb ++++ b/spec/features/locale_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Changing locales", js: true do +diff --git a/spec/features/members/ban_spec.rb b/spec/features/members/ban_spec.rb +index f6f99e69..3395637c 100644 +--- a/spec/features/members/ban_spec.rb ++++ b/spec/features/members/ban_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "members list" do +diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb +index ce3ff776..a8ca9fb8 100644 +--- a/spec/features/members/deletion_spec.rb ++++ b/spec/features/members/deletion_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "member deletion" do +diff --git a/spec/features/members/following_spec.rb b/spec/features/members/following_spec.rb +index 42a20df3..a48bed81 100644 +--- a/spec/features/members/following_spec.rb ++++ b/spec/features/members/following_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "follows", :js do +diff --git a/spec/features/members/list_spec.rb b/spec/features/members/list_spec.rb +index f00b1daa..b26ead43 100644 +--- a/spec/features/members/list_spec.rb ++++ b/spec/features/members/list_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "members list" do +diff --git a/spec/features/members/profile_spec.rb b/spec/features/members/profile_spec.rb +index 4b51b586..08438efd 100644 +--- a/spec/features/members/profile_spec.rb ++++ b/spec/features/members/profile_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "member profile", js: true do +diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb +index 05efb57f..530a6b54 100644 +--- a/spec/features/percy/percy_spec.rb ++++ b/spec/features/percy/percy_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'Test with visual testing', type: :feature, js: true do +diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb +index d52a1ef4..b500a89d 100644 +--- a/spec/features/photos/new_photo_spec.rb ++++ b/spec/features/photos/new_photo_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "new photo page" do +diff --git a/spec/features/photos/show_photo_spec.rb b/spec/features/photos/show_photo_spec.rb +index 68bf8ea8..a2a517c1 100644 +--- a/spec/features/photos/show_photo_spec.rb ++++ b/spec/features/photos/show_photo_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "show photo page" do +diff --git a/spec/features/places/searching_a_place_spec.rb b/spec/features/places/searching_a_place_spec.rb +index 5b698532..d31eee6b 100644 +--- a/spec/features/places/searching_a_place_spec.rb ++++ b/spec/features/places/searching_a_place_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe "User searches" do +diff --git a/spec/features/planting_reminder_spec.rb b/spec/features/planting_reminder_spec.rb +index 5caecbc5..8ac7703a 100644 +--- a/spec/features/planting_reminder_spec.rb ++++ b/spec/features/planting_reminder_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + require 'capybara/email/rspec' + +diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb +index 2ca3439d..a4cbe5ed 100644 +--- a/spec/features/plantings/planting_a_crop_spec.rb ++++ b/spec/features/plantings/planting_a_crop_spec.rb +@@ -1,7 +1,9 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + require 'custom_matchers' + +-describe "Planting a crop", :js do ++describe "Planting a crop", :js, :search do + let!(:maize) { FactoryBot.create :maize } + let(:garden) { FactoryBot.create :garden, owner: member, name: 'Orchard' } + let!(:planting) do +diff --git a/spec/features/plantings/prediction_spec.rb b/spec/features/plantings/prediction_spec.rb +index 1efa4ac5..c22734a7 100644 +--- a/spec/features/plantings/prediction_spec.rb ++++ b/spec/features/plantings/prediction_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + require 'custom_matchers' + describe "Display a planting", :js do +diff --git a/spec/features/plantings/show_spec.rb b/spec/features/plantings/show_spec.rb +index 7207b479..3ffcb45b 100644 +--- a/spec/features/plantings/show_spec.rb ++++ b/spec/features/plantings/show_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + require 'custom_matchers' + +diff --git a/spec/features/posts/posting_a_post_spec.rb b/spec/features/posts/posting_a_post_spec.rb +index f1b61bc8..cd1a4b0a 100644 +--- a/spec/features/posts/posting_a_post_spec.rb ++++ b/spec/features/posts/posting_a_post_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'Post a post' do +diff --git a/spec/features/rss/comments_spec.rb b/spec/features/rss/comments_spec.rb +index 1b0263d6..5b678330 100644 +--- a/spec/features/rss/comments_spec.rb ++++ b/spec/features/rss/comments_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'Comments RSS feed' do +diff --git a/spec/features/rss/crops_spec.rb b/spec/features/rss/crops_spec.rb +index 704dd60b..7e26d30e 100644 +--- a/spec/features/rss/crops_spec.rb ++++ b/spec/features/rss/crops_spec.rb +@@ -1,12 +1,16 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'Crops RSS feed' do + it 'The index feed exists' do ++ Crop.reindex + visit crops_path(format: 'rss') + # expect(page.status_code).to equal 200 + end + + it 'The index title is what we expect' do ++ Crop.reindex + visit crops_path(format: 'rss') + expect(page).to have_content "Recently added crops (#{ENV['GROWSTUFF_SITE_NAME']})" + end +diff --git a/spec/features/rss/members_spec.rb b/spec/features/rss/members_spec.rb +index 1daefcd5..ba63a1a2 100644 +--- a/spec/features/rss/members_spec.rb ++++ b/spec/features/rss/members_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'Members RSS feed' do +diff --git a/spec/features/rss/plantings_spec.rb b/spec/features/rss/plantings_spec.rb +index 7a6e31b9..30ffba94 100644 +--- a/spec/features/rss/plantings_spec.rb ++++ b/spec/features/rss/plantings_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'Plantings RSS feed' do +@@ -7,6 +9,7 @@ describe 'Plantings RSS feed' do + end + + it 'The index title is what we expect' do ++ Planting.reindex + visit plantings_path(format: 'rss') + expect(page).to have_content "Recent plantings from "\ + "#{@owner || 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" +diff --git a/spec/features/rss/posts_spec.rb b/spec/features/rss/posts_spec.rb +index 0b85590c..b07ca28c 100644 +--- a/spec/features/rss/posts_spec.rb ++++ b/spec/features/rss/posts_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'Posts RSS feed' do +diff --git a/spec/features/rss/seeds_spec.rb b/spec/features/rss/seeds_spec.rb +index 5a50e881..c0a2e141 100644 +--- a/spec/features/rss/seeds_spec.rb ++++ b/spec/features/rss/seeds_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'Seeds RSS feed' do +diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb +index 9ab32788..1b7b3fcc 100644 +--- a/spec/features/seeds/adding_seeds_spec.rb ++++ b/spec/features/seeds/adding_seeds_spec.rb +@@ -1,7 +1,9 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + require 'custom_matchers' + +-describe "Seeds", :js do ++describe "Seeds", :js, :search do + context 'signed in' do + include_context 'signed in member' + let!(:maize) { create :maize } +diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb +index 0aa54f12..8de59ab4 100644 +--- a/spec/features/seeds/misc_seeds_spec.rb ++++ b/spec/features/seeds/misc_seeds_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "seeds", js: true do +diff --git a/spec/features/seeds/seed_photos.rb b/spec/features/seeds/seed_photos.rb +index 6f4d9828..37640f12 100644 +--- a/spec/features/seeds/seed_photos.rb ++++ b/spec/features/seeds/seed_photos.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + require 'custom_matchers' + +diff --git a/spec/features/shared_examples/append_date.rb b/spec/features/shared_examples/append_date.rb +index 2680dac3..3b8b6ec6 100644 +--- a/spec/features/shared_examples/append_date.rb ++++ b/spec/features/shared_examples/append_date.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + shared_examples "append date" do + let(:this_month) { Time.zone.today.strftime("%b") } + let(:this_year) { Time.zone.today.year } +diff --git a/spec/features/shared_examples/crop_suggest.rb b/spec/features/shared_examples/crop_suggest.rb +index b7e49dbd..33775c74 100644 +--- a/spec/features/shared_examples/crop_suggest.rb ++++ b/spec/features/shared_examples/crop_suggest.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + shared_examples "crop suggest" do |resource| +diff --git a/spec/features/signin_spec.rb b/spec/features/signin_spec.rb +index 5d20b461..25cf7112 100644 +--- a/spec/features/signin_spec.rb ++++ b/spec/features/signin_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "signin", js: true do +diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb +index 4a2013e5..ca9d6455 100644 +--- a/spec/features/signout_spec.rb ++++ b/spec/features/signout_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "signout" do +diff --git a/spec/features/signup_spec.rb b/spec/features/signup_spec.rb +index 331dedaa..c7a13619 100644 +--- a/spec/features/signup_spec.rb ++++ b/spec/features/signup_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "signup", js: true do +diff --git a/spec/features/timeline/index_spec.rb b/spec/features/timeline/index_spec.rb +index bf0022df..134c4a06 100644 +--- a/spec/features/timeline/index_spec.rb ++++ b/spec/features/timeline/index_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "timeline", js: true do +diff --git a/spec/features/unsubscribing_spec.rb b/spec/features/unsubscribing_spec.rb +index 039b536b..9fff6084 100644 +--- a/spec/features/unsubscribing_spec.rb ++++ b/spec/features/unsubscribing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + require 'capybara/email/rspec' + +diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb +index ae7230a0..c285f9c5 100644 +--- a/spec/helpers/application_helper_spec.rb ++++ b/spec/helpers/application_helper_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe ApplicationHelper do +diff --git a/spec/helpers/buttons_helper_spec.rb b/spec/helpers/buttons_helper_spec.rb +index b9bdc41a..b55a4668 100644 +--- a/spec/helpers/buttons_helper_spec.rb ++++ b/spec/helpers/buttons_helper_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + # Specs in this file have access to a helper object that includes +diff --git a/spec/helpers/crops_helper_spec.rb b/spec/helpers/crops_helper_spec.rb +index 532019e4..07d8bc3f 100644 +--- a/spec/helpers/crops_helper_spec.rb ++++ b/spec/helpers/crops_helper_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe CropsHelper do +diff --git a/spec/helpers/event_helper_spec.rb b/spec/helpers/event_helper_spec.rb +index f90a04c1..634953c5 100644 +--- a/spec/helpers/event_helper_spec.rb ++++ b/spec/helpers/event_helper_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + RSpec.describe EventHelper, type: :helper do +diff --git a/spec/helpers/gardens_helper_spec.rb b/spec/helpers/gardens_helper_spec.rb +index 57db618b..3b8094ea 100644 +--- a/spec/helpers/gardens_helper_spec.rb ++++ b/spec/helpers/gardens_helper_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe GardensHelper do +diff --git a/spec/helpers/harvests_helper_spec.rb b/spec/helpers/harvests_helper_spec.rb +index 4286c326..25be2d24 100644 +--- a/spec/helpers/harvests_helper_spec.rb ++++ b/spec/helpers/harvests_helper_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe HarvestsHelper do +diff --git a/spec/helpers/photos_helper_spec.rb b/spec/helpers/photos_helper_spec.rb +index b24a254c..bbd6a32b 100644 +--- a/spec/helpers/photos_helper_spec.rb ++++ b/spec/helpers/photos_helper_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe PhotosHelper do +diff --git a/spec/helpers/plantings_helper_spec.rb b/spec/helpers/plantings_helper_spec.rb +index d28ed90d..14192bb1 100644 +--- a/spec/helpers/plantings_helper_spec.rb ++++ b/spec/helpers/plantings_helper_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe PlantingsHelper do +diff --git a/spec/helpers/seeds_helper_spec.rb b/spec/helpers/seeds_helper_spec.rb +index 7fa75132..593527fa 100644 +--- a/spec/helpers/seeds_helper_spec.rb ++++ b/spec/helpers/seeds_helper_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe SeedsHelper do +diff --git a/spec/lib/actions/oauth_signup_action_spec.rb b/spec/lib/actions/oauth_signup_action_spec.rb +index dd8310d0..621b29af 100644 +--- a/spec/lib/actions/oauth_signup_action_spec.rb ++++ b/spec/lib/actions/oauth_signup_action_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + require './lib/actions/oauth_signup_action' + +diff --git a/spec/lib/haml/filters/escaped_markdown_spec.rb b/spec/lib/haml/filters/escaped_markdown_spec.rb +index 41575129..fd9b4e0b 100644 +--- a/spec/lib/haml/filters/escaped_markdown_spec.rb ++++ b/spec/lib/haml/filters/escaped_markdown_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + require 'haml/filters' + require 'haml/filters/escaped_markdown' +diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb +index cc27bd56..5a847759 100644 +--- a/spec/lib/haml/filters/growstuff_markdown_spec.rb ++++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb +@@ -1,3 +1,4 @@ ++# rubocop:disable Style/FrozenStringLiteralComment + require 'rails_helper' + require 'haml/filters' + require 'haml/filters/growstuff_markdown' +diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb +index 389ae993..c2c206a6 100644 +--- a/spec/models/ability_spec.rb ++++ b/spec/models/ability_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + require 'cancan/matchers' + +diff --git a/spec/models/alternate_name_spec.rb b/spec/models/alternate_name_spec.rb +index 5881121c..515fdaa7 100644 +--- a/spec/models/alternate_name_spec.rb ++++ b/spec/models/alternate_name_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe AlternateName do +diff --git a/spec/models/authentication_spec.rb b/spec/models/authentication_spec.rb +index 7e02a57f..2c91dfac 100644 +--- a/spec/models/authentication_spec.rb ++++ b/spec/models/authentication_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe Authentication do +diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb +index 75166df9..f684697f 100644 +--- a/spec/models/comment_spec.rb ++++ b/spec/models/comment_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe Comment do +diff --git a/spec/models/crop_companion_spec.rb b/spec/models/crop_companion_spec.rb +index 7b6223db..e1cedbfd 100644 +--- a/spec/models/crop_companion_spec.rb ++++ b/spec/models/crop_companion_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + RSpec.describe CropCompanion, type: :model do +diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb +index 98ba5136..bb3c07b0 100644 +--- a/spec/models/crop_spec.rb ++++ b/spec/models/crop_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe Crop do +diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb +index 63e397d9..4a11208b 100644 +--- a/spec/models/follow_spec.rb ++++ b/spec/models/follow_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'spec_helper' + + describe Follow do +diff --git a/spec/models/forum_spec.rb b/spec/models/forum_spec.rb +index 310c3684..cc5b34a0 100644 +--- a/spec/models/forum_spec.rb ++++ b/spec/models/forum_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe Forum do +diff --git a/spec/models/garden_spec.rb b/spec/models/garden_spec.rb +index c62fd0f1..f154eca9 100644 +--- a/spec/models/garden_spec.rb ++++ b/spec/models/garden_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe Garden do +diff --git a/spec/models/garden_type.rb b/spec/models/garden_type.rb +index cd5862c9..9ea7ac16 100644 +--- a/spec/models/garden_type.rb ++++ b/spec/models/garden_type.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe GardenType do +diff --git a/spec/models/harvest_spec.rb b/spec/models/harvest_spec.rb +index f4b11084..5465b43e 100644 +--- a/spec/models/harvest_spec.rb ++++ b/spec/models/harvest_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe Harvest do +diff --git a/spec/models/like_spec.rb b/spec/models/like_spec.rb +index 56f35bf1..aeb5797e 100644 +--- a/spec/models/like_spec.rb ++++ b/spec/models/like_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'like' do +diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb +index 10ca3f5e..f591bd3d 100644 +--- a/spec/models/member_spec.rb ++++ b/spec/models/member_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'member' do +diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb +index 2a4c7e86..2f504f86 100644 +--- a/spec/models/notification_spec.rb ++++ b/spec/models/notification_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe Notification do +diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb +index 1102253f..b7ca5189 100644 +--- a/spec/models/photo_spec.rb ++++ b/spec/models/photo_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe Photo do +diff --git a/spec/models/plant_part_spec.rb b/spec/models/plant_part_spec.rb +index ba1e5624..7747ec4e 100644 +--- a/spec/models/plant_part_spec.rb ++++ b/spec/models/plant_part_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe PlantPart do +diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb +index fe2b5299..34d5696a 100644 +--- a/spec/models/planting_spec.rb ++++ b/spec/models/planting_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe Planting do +diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb +index e8bf3cf5..5fd8c8f6 100644 +--- a/spec/models/post_spec.rb ++++ b/spec/models/post_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe Post do +diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb +index 0fc5f92b..5893a9dc 100644 +--- a/spec/models/role_spec.rb ++++ b/spec/models/role_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe Role do +diff --git a/spec/models/scientific_name_spec.rb b/spec/models/scientific_name_spec.rb +index 0b170812..7433182e 100644 +--- a/spec/models/scientific_name_spec.rb ++++ b/spec/models/scientific_name_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe ScientificName do +diff --git a/spec/models/seed_spec.rb b/spec/models/seed_spec.rb +index a2dae315..1729f5da 100644 +--- a/spec/models/seed_spec.rb ++++ b/spec/models/seed_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe Seed do +diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb +index d780aedb..5082ce6a 100644 +--- a/spec/rails_helper.rb ++++ b/spec/rails_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # This file is copied to spec/ when you run 'rails generate rspec:install' + ENV["RAILS_ENV"] ||= 'test' + require 'simplecov' +diff --git a/spec/requests/api/v1/crop_request_spec.rb b/spec/requests/api/v1/crop_request_spec.rb +index 9eaab019..06dd0311 100644 +--- a/spec/requests/api/v1/crop_request_spec.rb ++++ b/spec/requests/api/v1/crop_request_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + RSpec.describe 'Crops', type: :request do +diff --git a/spec/requests/api/v1/gardens_request_spec.rb b/spec/requests/api/v1/gardens_request_spec.rb +index 12a729a3..3116aa20 100644 +--- a/spec/requests/api/v1/gardens_request_spec.rb ++++ b/spec/requests/api/v1/gardens_request_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + RSpec.describe 'Gardens', type: :request do +diff --git a/spec/requests/api/v1/harvest_request_spec.rb b/spec/requests/api/v1/harvest_request_spec.rb +index b958f793..eb6a6e48 100644 +--- a/spec/requests/api/v1/harvest_request_spec.rb ++++ b/spec/requests/api/v1/harvest_request_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + RSpec.describe 'Harvests', type: :request do +diff --git a/spec/requests/api/v1/member_request_spec.rb b/spec/requests/api/v1/member_request_spec.rb +index 0f1d7812..38021af3 100644 +--- a/spec/requests/api/v1/member_request_spec.rb ++++ b/spec/requests/api/v1/member_request_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + RSpec.describe 'Members', type: :request do +diff --git a/spec/requests/api/v1/photos_request_spec.rb b/spec/requests/api/v1/photos_request_spec.rb +index d194e237..1db6cede 100644 +--- a/spec/requests/api/v1/photos_request_spec.rb ++++ b/spec/requests/api/v1/photos_request_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + RSpec.describe 'Photos', type: :request do +diff --git a/spec/requests/api/v1/plantings_request_spec.rb b/spec/requests/api/v1/plantings_request_spec.rb +index 8c811f51..26781cc2 100644 +--- a/spec/requests/api/v1/plantings_request_spec.rb ++++ b/spec/requests/api/v1/plantings_request_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + RSpec.describe 'Plantings', type: :request do +diff --git a/spec/requests/api/v1/seeds_request_spec.rb b/spec/requests/api/v1/seeds_request_spec.rb +index a65243c5..b0157fbf 100644 +--- a/spec/requests/api/v1/seeds_request_spec.rb ++++ b/spec/requests/api/v1/seeds_request_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + RSpec.describe 'Photos', type: :request do +diff --git a/spec/requests/authentications_spec.rb b/spec/requests/authentications_spec.rb +index 6cc612f4..6ed6f4ea 100644 +--- a/spec/requests/authentications_spec.rb ++++ b/spec/requests/authentications_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Authentications" do +diff --git a/spec/requests/conversations_spec.rb b/spec/requests/conversations_spec.rb +index 1ed99668..745a0dbd 100644 +--- a/spec/requests/conversations_spec.rb ++++ b/spec/requests/conversations_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'Converstions' do +diff --git a/spec/requests/forums_spec.rb b/spec/requests/forums_spec.rb +index ff7cb283..2833a274 100644 +--- a/spec/requests/forums_spec.rb ++++ b/spec/requests/forums_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Forums" do +diff --git a/spec/requests/garden_types_spec.rb b/spec/requests/garden_types_spec.rb +index fbacd049..d415e5bd 100644 +--- a/spec/requests/garden_types_spec.rb ++++ b/spec/requests/garden_types_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + RSpec.describe "GardenTypes", type: :request do +diff --git a/spec/requests/gardens_spec.rb b/spec/requests/gardens_spec.rb +index 91a8dc8b..890a6edb 100644 +--- a/spec/requests/gardens_spec.rb ++++ b/spec/requests/gardens_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Gardens" do +diff --git a/spec/requests/harvests_spec.rb b/spec/requests/harvests_spec.rb +index f3774b3c..839d588f 100644 +--- a/spec/requests/harvests_spec.rb ++++ b/spec/requests/harvests_spec.rb +@@ -1,11 +1,12 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Harvests" do + describe "GET /harvests" do + it "works! (now write some real specs)" do +- # Run the generator again with the --webrat flag if you want to use webrat methods/matchers + get harvests_path +- response.status.should be(200) ++ expect(response.status).to be 200 + end + end + end +diff --git a/spec/requests/photos_spec.rb b/spec/requests/photos_spec.rb +index b937ded3..6ac4694a 100644 +--- a/spec/requests/photos_spec.rb ++++ b/spec/requests/photos_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Photos" do +diff --git a/spec/requests/plant_parts_spec.rb b/spec/requests/plant_parts_spec.rb +index 1fc2150b..a96599cb 100644 +--- a/spec/requests/plant_parts_spec.rb ++++ b/spec/requests/plant_parts_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "PlantParts" do +diff --git a/spec/requests/plantings_spec.rb b/spec/requests/plantings_spec.rb +index cb66922e..90a4b534 100644 +--- a/spec/requests/plantings_spec.rb ++++ b/spec/requests/plantings_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Plantings" do +diff --git a/spec/requests/post_spec.rb b/spec/requests/post_spec.rb +index 3bb479aa..51ccf416 100644 +--- a/spec/requests/post_spec.rb ++++ b/spec/requests/post_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Posts" do +diff --git a/spec/requests/scientific_names_spec.rb b/spec/requests/scientific_names_spec.rb +index 922f6f27..f2ce118a 100644 +--- a/spec/requests/scientific_names_spec.rb ++++ b/spec/requests/scientific_names_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "ScientificNames" do +diff --git a/spec/requests/seeds_spec.rb b/spec/requests/seeds_spec.rb +index 8bc5aecc..1440d638 100644 +--- a/spec/requests/seeds_spec.rb ++++ b/spec/requests/seeds_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "Seeds" do +diff --git a/spec/routing/admin_routing_spec.rb b/spec/routing/admin_routing_spec.rb +index 66b17bc1..287bb297 100644 +--- a/spec/routing/admin_routing_spec.rb ++++ b/spec/routing/admin_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe AdminController do +diff --git a/spec/routing/authentications_routing_spec.rb b/spec/routing/authentications_routing_spec.rb +index 0601b992..877a3539 100644 +--- a/spec/routing/authentications_routing_spec.rb ++++ b/spec/routing/authentications_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe AuthenticationsController do +diff --git a/spec/routing/comments_routing_spec.rb b/spec/routing/comments_routing_spec.rb +index 5390ab06..9fbfa436 100644 +--- a/spec/routing/comments_routing_spec.rb ++++ b/spec/routing/comments_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe CommentsController do +diff --git a/spec/routing/crops_routing_spec.rb b/spec/routing/crops_routing_spec.rb +index 30f6004d..7821db6f 100644 +--- a/spec/routing/crops_routing_spec.rb ++++ b/spec/routing/crops_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe CropsController do +diff --git a/spec/routing/follows_routing_spec.rb b/spec/routing/follows_routing_spec.rb +index ddb01e00..e79c2661 100644 +--- a/spec/routing/follows_routing_spec.rb ++++ b/spec/routing/follows_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "spec_helper" + + describe FollowsController do +diff --git a/spec/routing/forums_routing_spec.rb b/spec/routing/forums_routing_spec.rb +index 9ce6f427..5c3ade54 100644 +--- a/spec/routing/forums_routing_spec.rb ++++ b/spec/routing/forums_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe ForumsController do +diff --git a/spec/routing/garden_types_routing_spec.rb b/spec/routing/garden_types_routing_spec.rb +index 986af7b7..805ebdfa 100644 +--- a/spec/routing/garden_types_routing_spec.rb ++++ b/spec/routing/garden_types_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe GardenTypesController do +diff --git a/spec/routing/gardens_routing_spec.rb b/spec/routing/gardens_routing_spec.rb +index 02183eab..365fba5e 100644 +--- a/spec/routing/gardens_routing_spec.rb ++++ b/spec/routing/gardens_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe GardensController do +@@ -12,11 +14,11 @@ describe GardensController do + end + + it "routes to #show" do +- get("/gardens/1").should route_to("gardens#show", id: "1") ++ get("/gardens/sunny-bed").should route_to("gardens#show", slug: 'sunny-bed') + end + + it "routes to #edit" do +- get("/gardens/1/edit").should route_to("gardens#edit", id: "1") ++ get("/gardens/sunny-bed/edit").should route_to("gardens#edit", slug: 'sunny-bed') + end + + it "routes to #create" do +@@ -24,11 +26,11 @@ describe GardensController do + end + + it "routes to #update" do +- put("/gardens/1").should route_to("gardens#update", id: "1") ++ put("/gardens/sunny-bed").should route_to("gardens#update", slug: 'sunny-bed') + end + + it "routes to #destroy" do +- delete("/gardens/1").should route_to("gardens#destroy", id: "1") ++ delete("/gardens/sunny-bed").should route_to("gardens#destroy", slug: 'sunny-bed') + end + end + end +diff --git a/spec/routing/harvests_routing_spec.rb b/spec/routing/harvests_routing_spec.rb +index af623c3f..22ee305f 100644 +--- a/spec/routing/harvests_routing_spec.rb ++++ b/spec/routing/harvests_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe HarvestsController do +@@ -12,11 +14,11 @@ describe HarvestsController do + end + + it "routes to #show" do +- get("/harvests/1").should route_to("harvests#show", id: "1") ++ get("/harvests/potato").should route_to("harvests#show", slug: "potato") + end + + it "routes to #edit" do +- get("/harvests/1/edit").should route_to("harvests#edit", id: "1") ++ get("/harvests/potato/edit").should route_to("harvests#edit", slug: "potato") + end + + it "routes to #create" do +@@ -24,11 +26,11 @@ describe HarvestsController do + end + + it "routes to #update" do +- put("/harvests/1").should route_to("harvests#update", id: "1") ++ put("/harvests/potato").should route_to("harvests#update", slug: "potato") + end + + it "routes to #destroy" do +- delete("/harvests/1").should route_to("harvests#destroy", id: "1") ++ delete("/harvests/potato").should route_to("harvests#destroy", slug: "potato") + end + end + end +diff --git a/spec/routing/member_routing_spec.rb b/spec/routing/member_routing_spec.rb +new file mode 100644 +index 00000000..790ff94b +--- /dev/null ++++ b/spec/routing/member_routing_spec.rb +@@ -0,0 +1,42 @@ ++# frozen_string_literal: true ++ ++require "rails_helper" ++ ++describe MembersController do ++ describe "routing" do ++ it "routes to #index" do ++ get("/members").should route_to("members#index") ++ end ++ ++ it "routes to #new" do ++ get("/members/new").should route_to("members#new") ++ end ++ ++ it "routes to #show" do ++ get("/members/name").should route_to("members#show", slug: "name") ++ end ++ ++ it "routes to #edit" do ++ get("/members/name/edit").should route_to("members#edit", slug: "name") ++ end ++ ++ # it "routes to #create" do ++ # post("/members").should route_to("members#create") ++ # end ++ ++ it "routes to #update" do ++ put("/members/name").should route_to("members#update", slug: "name") ++ end ++ ++ it "routes to #destroy" do ++ delete("/members/name").should route_to("members#destroy", slug: "name") ++ end ++ ++ it "routes to harvests#index" do ++ get("/members/name/harvests").should route_to("harvests#index", member_slug: 'name') ++ end ++ it "routes to plantings#index" do ++ get("/members/name/plantings").should route_to("plantings#index", member_slug: 'name') ++ end ++ end ++end +diff --git a/spec/routing/photos_routing_spec.rb b/spec/routing/photos_routing_spec.rb +index a645d0a6..812acf84 100644 +--- a/spec/routing/photos_routing_spec.rb ++++ b/spec/routing/photos_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe PhotosController do +diff --git a/spec/routing/plant_parts_routing_spec.rb b/spec/routing/plant_parts_routing_spec.rb +index 966047f3..3e10372d 100644 +--- a/spec/routing/plant_parts_routing_spec.rb ++++ b/spec/routing/plant_parts_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe PlantPartsController do +diff --git a/spec/routing/plantings_routing_spec.rb b/spec/routing/plantings_routing_spec.rb +index d92d3a84..e3a8b534 100644 +--- a/spec/routing/plantings_routing_spec.rb ++++ b/spec/routing/plantings_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe PlantingsController do +@@ -12,11 +14,11 @@ describe PlantingsController do + end + + it "routes to #show" do +- get("/plantings/1").should route_to("plantings#show", id: "1") ++ get("/plantings/tomato").should route_to("plantings#show", slug: "tomato") + end + + it "routes to #edit" do +- get("/plantings/1/edit").should route_to("plantings#edit", id: "1") ++ get("/plantings/tomato/edit").should route_to("plantings#edit", slug: "tomato") + end + + it "routes to #create" do +@@ -24,11 +26,11 @@ describe PlantingsController do + end + + it "routes to #update" do +- put("/plantings/1").should route_to("plantings#update", id: "1") ++ put("/plantings/tomato").should route_to("plantings#update", slug: "tomato") + end + + it "routes to #destroy" do +- delete("/plantings/1").should route_to("plantings#destroy", id: "1") ++ delete("/plantings/tomato").should route_to("plantings#destroy", slug: "tomato") + end + end + end +diff --git a/spec/routing/roles_routing_spec.rb b/spec/routing/roles_routing_spec.rb +index c601e27e..9b61b982 100644 +--- a/spec/routing/roles_routing_spec.rb ++++ b/spec/routing/roles_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe Admin::RolesController do +diff --git a/spec/routing/scientific_names_routing_spec.rb b/spec/routing/scientific_names_routing_spec.rb +index 7bbbfa76..b52f4b43 100644 +--- a/spec/routing/scientific_names_routing_spec.rb ++++ b/spec/routing/scientific_names_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe ScientificNamesController do +diff --git a/spec/routing/seeds_routing_spec.rb b/spec/routing/seeds_routing_spec.rb +index 9ebfbdb0..65710acb 100644 +--- a/spec/routing/seeds_routing_spec.rb ++++ b/spec/routing/seeds_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe SeedsController do +@@ -12,11 +14,11 @@ describe SeedsController do + end + + it "routes to #show" do +- get("/seeds/1").should route_to("seeds#show", id: "1") ++ get("/seeds/corn").should route_to("seeds#show", slug: 'corn') + end + + it "routes to #edit" do +- get("/seeds/1/edit").should route_to("seeds#edit", id: "1") ++ get("/seeds/corn/edit").should route_to("seeds#edit", slug: 'corn') + end + + it "routes to #create" do +@@ -24,11 +26,11 @@ describe SeedsController do + end + + it "routes to #update" do +- put("/seeds/1").should route_to("seeds#update", id: "1") ++ put("/seeds/corn").should route_to("seeds#update", slug: 'corn') + end + + it "routes to #destroy" do +- delete("/seeds/1").should route_to("seeds#destroy", id: "1") ++ delete("/seeds/corn").should route_to("seeds#destroy", slug: 'corn') + end + end + end +diff --git a/spec/routing/updates_routing_spec.rb b/spec/routing/updates_routing_spec.rb +index 96664751..9c971552 100644 +--- a/spec/routing/updates_routing_spec.rb ++++ b/spec/routing/updates_routing_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require "rails_helper" + + describe PostsController do +diff --git a/spec/services/timeline_service_spec.rb b/spec/services/timeline_service_spec.rb +index 4ab41f71..632c8b0a 100644 +--- a/spec/services/timeline_service_spec.rb ++++ b/spec/services/timeline_service_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'timeline' do +diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb +index df3b6f92..d84389ef 100644 +--- a/spec/spec_helper.rb ++++ b/spec/spec_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # This file was generated by the `rails generate rspec:install` command. Conventionally, all + # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. + # The generated `.rspec` file contains `--require spec_helper` which will cause this +@@ -36,7 +38,10 @@ RSpec.configure do |config| + + config.before(:suite) do + # reindex models +- Crop.reindex ++ Crop.searchkick_index.refresh ++ Seed.searchkick_index.refresh ++ Harvest.searchkick_index.refresh ++ Planting.searchkick_index.refresh + + # and disable callbacks + Searchkick.disable_callbacks +diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb +index b54cf028..f2d23aaf 100644 +--- a/spec/support/controller_macros.rb ++++ b/spec/support/controller_macros.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + # Taken unashamedly from https://github.com/plataformatec/devise/wiki/How-To%3a-Controllers-and-Views-tests-with-Rails-3-%28and-rspec%29 + module ControllerMacros + def login_member(member_factory = :member) +diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb +index 8aa07643..0821d219 100644 +--- a/spec/support/database_cleaner.rb ++++ b/spec/support/database_cleaner.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + RSpec.configure do |config| + # a warning if you turn this off + config.before(:suite) do +diff --git a/spec/support/devise.rb b/spec/support/devise.rb +index 090ffc6a..c1f9c35f 100644 +--- a/spec/support/devise.rb ++++ b/spec/support/devise.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + RSpec.configure do |config| + config.include Devise::Test::ControllerHelpers, type: :controller + config.include Devise::Test::ControllerHelpers, type: :view +diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb +index 97371862..91b877e1 100644 +--- a/spec/support/feature_helpers.rb ++++ b/spec/support/feature_helpers.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + module FeatureHelpers + def fill_autocomplete(field, options = {}) + Crop.reindex +diff --git a/spec/support/is_likeable.rb b/spec/support/is_likeable.rb +index c402d589..9fbae542 100644 +--- a/spec/support/is_likeable.rb ++++ b/spec/support/is_likeable.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + shared_examples "it is likeable" do + before do + # Possibly a horrible hack. +diff --git a/spec/swagger_helper.rb b/spec/swagger_helper.rb +index 327b2c80..67a935fa 100644 +--- a/spec/swagger_helper.rb ++++ b/spec/swagger_helper.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + RSpec.configure do |config| +diff --git a/spec/views/admin/index_spec.rb b/spec/views/admin/index_spec.rb +index 7379519c..4e8dbba2 100644 +--- a/spec/views/admin/index_spec.rb ++++ b/spec/views/admin/index_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'admin/index.html.haml', type: "view" do +diff --git a/spec/views/admin/newsletter_spec.rb b/spec/views/admin/newsletter_spec.rb +index fbae64de..464f2d6c 100644 +--- a/spec/views/admin/newsletter_spec.rb ++++ b/spec/views/admin/newsletter_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'admin/newsletter.html.haml', type: "view" do +diff --git a/spec/views/admin/roles/edit.html.haml_spec.rb b/spec/views/admin/roles/edit.html.haml_spec.rb +index 859ac249..d2ffc114 100644 +--- a/spec/views/admin/roles/edit.html.haml_spec.rb ++++ b/spec/views/admin/roles/edit.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "admin/roles/edit" do +diff --git a/spec/views/admin/roles/index.html.haml_spec.rb b/spec/views/admin/roles/index.html.haml_spec.rb +index f852dd0d..d8d0c7bc 100644 +--- a/spec/views/admin/roles/index.html.haml_spec.rb ++++ b/spec/views/admin/roles/index.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "admin/roles/index" do +diff --git a/spec/views/admin/roles/new.html.haml_spec.rb b/spec/views/admin/roles/new.html.haml_spec.rb +index 3ce6b0c8..b9b3dc7b 100644 +--- a/spec/views/admin/roles/new.html.haml_spec.rb ++++ b/spec/views/admin/roles/new.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "admin/roles/new" do +diff --git a/spec/views/comments/edit.html.haml_spec.rb b/spec/views/comments/edit.html.haml_spec.rb +index b7a547f8..b95fb9d2 100644 +--- a/spec/views/comments/edit.html.haml_spec.rb ++++ b/spec/views/comments/edit.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "comments/edit" do +diff --git a/spec/views/comments/index.rss.haml_spec.rb b/spec/views/comments/index.rss.haml_spec.rb +index d1b376ca..38b5a238 100644 +--- a/spec/views/comments/index.rss.haml_spec.rb ++++ b/spec/views/comments/index.rss.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'comments/index.rss.haml' do +diff --git a/spec/views/comments/new.html.haml_spec.rb b/spec/views/comments/new.html.haml_spec.rb +index c2d7b7e8..5b86a3a2 100644 +--- a/spec/views/comments/new.html.haml_spec.rb ++++ b/spec/views/comments/new.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "comments/new" do +diff --git a/spec/views/crops/_grown_for.html.haml_spec.rb b/spec/views/crops/_grown_for.html.haml_spec.rb +index f3beba7a..3cd68bfd 100644 +--- a/spec/views/crops/_grown_for.html.haml_spec.rb ++++ b/spec/views/crops/_grown_for.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "crops/_grown_for" do +diff --git a/spec/views/crops/_popover.html.haml_spec.rb b/spec/views/crops/_popover.html.haml_spec.rb +index 577667ec..09cd2eda 100644 +--- a/spec/views/crops/_popover.html.haml_spec.rb ++++ b/spec/views/crops/_popover.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "crops/_popover" do +diff --git a/spec/views/crops/edit.html.haml_spec.rb b/spec/views/crops/edit.html.haml_spec.rb +index ba43f645..6791c339 100644 +--- a/spec/views/crops/edit.html.haml_spec.rb ++++ b/spec/views/crops/edit.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "crops/edit" do +diff --git a/spec/views/crops/hierarchy.html.haml_spec.rb b/spec/views/crops/hierarchy.html.haml_spec.rb +index c1d79f0b..8232e14f 100644 +--- a/spec/views/crops/hierarchy.html.haml_spec.rb ++++ b/spec/views/crops/hierarchy.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "crops/hierarchy" do +diff --git a/spec/views/crops/index.html.haml_spec.rb b/spec/views/crops/index.html.haml_spec.rb +index 9c1c1680..db69f913 100644 +--- a/spec/views/crops/index.html.haml_spec.rb ++++ b/spec/views/crops/index.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "crops/index" do +diff --git a/spec/views/crops/index.rss.haml_spec.rb b/spec/views/crops/index.rss.haml_spec.rb +index a7afbba7..5d1bfaef 100644 +--- a/spec/views/crops/index.rss.haml_spec.rb ++++ b/spec/views/crops/index.rss.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'crops/index.rss.haml' do +diff --git a/spec/views/crops/new.html.haml_spec.rb b/spec/views/crops/new.html.haml_spec.rb +index 0dcf4362..95dfc5db 100644 +--- a/spec/views/crops/new.html.haml_spec.rb ++++ b/spec/views/crops/new.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "crops/new" do +diff --git a/spec/views/crops/wrangle.html.haml_spec.rb b/spec/views/crops/wrangle.html.haml_spec.rb +index 1ae400e7..89c5d0b1 100644 +--- a/spec/views/crops/wrangle.html.haml_spec.rb ++++ b/spec/views/crops/wrangle.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "crops/wrangle" do +diff --git a/spec/views/devise/confirmations/new_spec.rb b/spec/views/devise/confirmations/new_spec.rb +index de26a4ad..ce429025 100644 +--- a/spec/views/devise/confirmations/new_spec.rb ++++ b/spec/views/devise/confirmations/new_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + describe 'devise/confirmations/new.html.haml', type: "view" do + before do + @view.stub(:resource).and_return(Member.new) +diff --git a/spec/views/devise/mailer/confirmation_instructions_spec.rb b/spec/views/devise/mailer/confirmation_instructions_spec.rb +index 08e41179..0f4b25f0 100644 +--- a/spec/views/devise/mailer/confirmation_instructions_spec.rb ++++ b/spec/views/devise/mailer/confirmation_instructions_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'devise/mailer/confirmation_instructions.html.haml', type: "view" do +diff --git a/spec/views/devise/mailer/reset_password_instructions_spec.rb b/spec/views/devise/mailer/reset_password_instructions_spec.rb +index ef90f758..7dce3e1f 100644 +--- a/spec/views/devise/mailer/reset_password_instructions_spec.rb ++++ b/spec/views/devise/mailer/reset_password_instructions_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'devise/mailer/reset_password_instructions.html.haml', type: "view" do +diff --git a/spec/views/devise/mailer/unlock_instructions_spec.rb b/spec/views/devise/mailer/unlock_instructions_spec.rb +index d3ac3357..5db8a66c 100644 +--- a/spec/views/devise/mailer/unlock_instructions_spec.rb ++++ b/spec/views/devise/mailer/unlock_instructions_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + describe 'devise/mailer/unlock_instructions.html.haml', type: "view" do + context "logged in" do +diff --git a/spec/views/devise/registrations/edit_spec.rb b/spec/views/devise/registrations/edit_spec.rb +index b260d13a..1ca0ae8a 100644 +--- a/spec/views/devise/registrations/edit_spec.rb ++++ b/spec/views/devise/registrations/edit_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'devise/registrations/edit.html.haml', type: "view" do +diff --git a/spec/views/devise/registrations/new_spec.rb b/spec/views/devise/registrations/new_spec.rb +index 0ee95b5b..05c690ca 100644 +--- a/spec/views/devise/registrations/new_spec.rb ++++ b/spec/views/devise/registrations/new_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'devise/registrations/new.html.haml', type: "view" do +diff --git a/spec/views/devise/sessions/new_spec.rb b/spec/views/devise/sessions/new_spec.rb +index d8ae1c48..5537f6fd 100644 +--- a/spec/views/devise/sessions/new_spec.rb ++++ b/spec/views/devise/sessions/new_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'devise/sessions/new.html.haml', type: "view" do +diff --git a/spec/views/devise/shared/_links_spec.rb b/spec/views/devise/shared/_links_spec.rb +index c1910159..1a0c55d5 100644 +--- a/spec/views/devise/shared/_links_spec.rb ++++ b/spec/views/devise/shared/_links_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + describe 'devise/shared/_links.haml', type: "view" do + def devise_mapping(register, recover, confirm, lock, oauth) + dm = double("mappings") +diff --git a/spec/views/devise/unlocks/new_spec.rb b/spec/views/devise/unlocks/new_spec.rb +index 68666532..184b820d 100644 +--- a/spec/views/devise/unlocks/new_spec.rb ++++ b/spec/views/devise/unlocks/new_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'devise/unlocks/new.html.haml', type: "view" do +diff --git a/spec/views/forums/edit.html.haml_spec.rb b/spec/views/forums/edit.html.haml_spec.rb +index 57747391..08580e4e 100644 +--- a/spec/views/forums/edit.html.haml_spec.rb ++++ b/spec/views/forums/edit.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "forums/edit" do +diff --git a/spec/views/forums/index.html.haml_spec.rb b/spec/views/forums/index.html.haml_spec.rb +index 9bfef29e..74a0684a 100644 +--- a/spec/views/forums/index.html.haml_spec.rb ++++ b/spec/views/forums/index.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "forums/index" do +diff --git a/spec/views/forums/new.html.haml_spec.rb b/spec/views/forums/new.html.haml_spec.rb +index 4fec098d..ebb71168 100644 +--- a/spec/views/forums/new.html.haml_spec.rb ++++ b/spec/views/forums/new.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "forums/new" do +diff --git a/spec/views/forums/show.html.haml_spec.rb b/spec/views/forums/show.html.haml_spec.rb +index c40a77a8..89d2d443 100644 +--- a/spec/views/forums/show.html.haml_spec.rb ++++ b/spec/views/forums/show.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "forums/show" do +@@ -8,8 +10,8 @@ describe "forums/show" do + + it "renders attributes" do + render +- rendered.should have_content "Everything about permaculture" +- rendered.should have_content @forum.owner.to_s ++ expect(rendered).to have_content "Everything about permaculture" ++ expect(rendered).to have_content @forum.owner.to_s + end + + it "parses markdown description into html" do +@@ -24,14 +26,14 @@ describe "forums/show" do + + it 'has no posts' do + render +- rendered.should have_content "No posts yet." ++ expect(rendered).to have_content "No posts yet." + end + + it 'shows posts' do + @post = FactoryBot.create(:post, forum: @forum) + render + assert_select "table" +- rendered.should have_content @post.subject +- rendered.should have_content @post.author.to_s ++ expect(rendered).to have_content @post.subject ++ expect(rendered).to have_content @post.author.to_s + end + end +diff --git a/spec/views/garden_types/edit.html.haml_spec.rb b/spec/views/garden_types/edit.html.haml_spec.rb +index b5c69b95..c328e427 100644 +--- a/spec/views/garden_types/edit.html.haml_spec.rb ++++ b/spec/views/garden_types/edit.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "garden_types/edit" do +diff --git a/spec/views/garden_types/new.html.haml_spec.rb b/spec/views/garden_types/new.html.haml_spec.rb +index 3241666a..e48aff0d 100644 +--- a/spec/views/garden_types/new.html.haml_spec.rb ++++ b/spec/views/garden_types/new.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "garden_types/new" do +diff --git a/spec/views/garden_types/show.html.haml_spec.rb b/spec/views/garden_types/show.html.haml_spec.rb +index 10b4d83a..33fc283e 100644 +--- a/spec/views/garden_types/show.html.haml_spec.rb ++++ b/spec/views/garden_types/show.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "garden_types/show" do +diff --git a/spec/views/gardens/edit.html.haml_spec.rb b/spec/views/gardens/edit.html.haml_spec.rb +index a0564bf8..fc1ec78e 100644 +--- a/spec/views/gardens/edit.html.haml_spec.rb ++++ b/spec/views/gardens/edit.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "gardens/edit" do +diff --git a/spec/views/gardens/new.html.haml_spec.rb b/spec/views/gardens/new.html.haml_spec.rb +index d76659f7..00bcc91e 100644 +--- a/spec/views/gardens/new.html.haml_spec.rb ++++ b/spec/views/gardens/new.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "gardens/new" do +diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb +index 7535ce8d..5bb6cf0a 100644 +--- a/spec/views/gardens/show.html.haml_spec.rb ++++ b/spec/views/gardens/show.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "gardens/show" do +diff --git a/spec/views/harvests/edit.html.haml_spec.rb b/spec/views/harvests/edit.html.haml_spec.rb +index 38307f50..2647f796 100644 +--- a/spec/views/harvests/edit.html.haml_spec.rb ++++ b/spec/views/harvests/edit.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "harvests/edit" do +diff --git a/spec/views/harvests/index.html.haml_spec.rb b/spec/views/harvests/index.html.haml_spec.rb +index 1ce56c49..d018c955 100644 +--- a/spec/views/harvests/index.html.haml_spec.rb ++++ b/spec/views/harvests/index.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "harvests/index" do +diff --git a/spec/views/harvests/index.rss.haml_spec.rb b/spec/views/harvests/index.rss.haml_spec.rb +index e3f1d20b..e4384c47 100644 +--- a/spec/views/harvests/index.rss.haml_spec.rb ++++ b/spec/views/harvests/index.rss.haml_spec.rb +@@ -1,42 +1,39 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + +-describe 'harvests/index.rss.haml' do ++describe 'harvests/index.rss.haml', :search do + before do + controller.stub(:current_user) { nil } + @member = FactoryBot.create(:member) + @tomato = FactoryBot.create(:tomato) +- @maize = FactoryBot.create(:maize) +- @pp = FactoryBot.create(:plant_part) +- page = 1 +- per_page = 2 +- total_entries = 2 +- harvests = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| +- pager.replace([ +- FactoryBot.create(:harvest, +- crop: @tomato, +- owner: @member), +- FactoryBot.create(:harvest, +- crop: @maize, +- plant_part: @pp, +- owner: @member, +- quantity: 2) +- ]) +- end +- assign(:harvests, harvests) +- render +- end + +- it 'shows RSS feed title' do +- rendered.should have_content "Recent harvests from all members" ++ @harvest1 = FactoryBot.create :harvest, crop: @tomato ++ @harvest2 = FactoryBot.create :harvest, crop: @tomato ++ @harvest3 = FactoryBot.create :harvest, crop: @tomato ++ ++ Harvest.searchkick_index.refresh ++ assign(:harvests, Harvest.search(load: false)) + end + +- it "displays crop's name in title" do +- assign(:crop, @tomato) +- render +- expect(rendered).to have_content @tomato.name ++ context 'all harvests' do ++ before { render } ++ it 'shows RSS feed title' do ++ expect(rendered).to have_content "Recent harvests from all members" ++ end ++ ++ it 'shows formatted content of harvest posts' do ++ expect(rendered).to have_content "

Quantity: " ++ end + end + +- it 'shows formatted content of harvest posts' do +- expect(rendered).to have_content "

Quantity: " ++ context 'for one crop' do ++ before do ++ assign(:crop, @tomato) ++ render ++ end ++ it "displays crop's name in title" do ++ expect(rendered).to have_content @tomato.name ++ end + end + end +diff --git a/spec/views/harvests/new.html.haml_spec.rb b/spec/views/harvests/new.html.haml_spec.rb +index abe1b547..6c75a385 100644 +--- a/spec/views/harvests/new.html.haml_spec.rb ++++ b/spec/views/harvests/new.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "harvests/new" do +diff --git a/spec/views/harvests/show.html.haml_spec.rb b/spec/views/harvests/show.html.haml_spec.rb +index 4a805392..8b270ab5 100644 +--- a/spec/views/harvests/show.html.haml_spec.rb ++++ b/spec/views/harvests/show.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "harvests/show" do +diff --git a/spec/views/home/_blurb.html.haml_spec.rb b/spec/views/home/_blurb.html.haml_spec.rb +index 395ce74b..2fc29313 100644 +--- a/spec/views/home/_blurb.html.haml_spec.rb ++++ b/spec/views/home/_blurb.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'home/_blurb.html.haml', type: "view" do +diff --git a/spec/views/home/_members.html.haml_spec.rb b/spec/views/home/_members.html.haml_spec.rb +index 332af1d2..b5be1f2b 100644 +--- a/spec/views/home/_members.html.haml_spec.rb ++++ b/spec/views/home/_members.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'home/_members.html.haml', type: "view" do +diff --git a/spec/views/home/_seeds.html.haml_spec.rb b/spec/views/home/_seeds.html.haml_spec.rb +index e0b2c54b..02dd6e9f 100644 +--- a/spec/views/home/_seeds.html.haml_spec.rb ++++ b/spec/views/home/_seeds.html.haml_spec.rb +@@ -1,9 +1,14 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + +-describe 'home/_seeds.html.haml', type: "view" do ++describe 'home/_seeds.html.haml', type: "view", search: true do + let!(:seed) { FactoryBot.create(:tradable_seed, owner: owner) } + let(:owner) { FactoryBot.create(:london_member) } +- before { render } ++ before do ++ Seed.searchkick_index.refresh ++ render ++ end + + it 'has a heading' do + assert_select 'h2', 'Seeds available to trade' +diff --git a/spec/views/home/_stats.html.haml_spec.rb b/spec/views/home/_stats.html.haml_spec.rb +index a9979190..15d637fd 100644 +--- a/spec/views/home/_stats.html.haml_spec.rb ++++ b/spec/views/home/_stats.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'home/_stats.html.haml', type: "view" do +diff --git a/spec/views/home/index_spec.rb b/spec/views/home/index_spec.rb +index 1289df4e..83e9308d 100644 +--- a/spec/views/home/index_spec.rb ++++ b/spec/views/home/index_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'home/index.html.haml', type: "view" do +diff --git a/spec/views/layouts/_head_spec.rb b/spec/views/layouts/_head_spec.rb +index c8235510..a516a99c 100644 +--- a/spec/views/layouts/_head_spec.rb ++++ b/spec/views/layouts/_head_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'layouts/_head.html.haml', type: "view" do +diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb +index 4a39e99b..b87bcb4d 100644 +--- a/spec/views/layouts/_header_spec.rb ++++ b/spec/views/layouts/_header_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'layouts/_header.html.haml', type: "view" do +diff --git a/spec/views/layouts/application_spec.rb b/spec/views/layouts/application_spec.rb +index f2b23d91..4ccb6950 100644 +--- a/spec/views/layouts/application_spec.rb ++++ b/spec/views/layouts/application_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'layouts/application.html.haml', type: "view" do +diff --git a/spec/views/members/_location.html.haml_spec.rb b/spec/views/members/_location.html.haml_spec.rb +index db1fae09..0ab04f47 100644 +--- a/spec/views/members/_location.html.haml_spec.rb ++++ b/spec/views/members/_location.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "members/_location" do +diff --git a/spec/views/members/index.html.haml_spec.rb b/spec/views/members/index.html.haml_spec.rb +index 34fda500..8afbb85a 100644 +--- a/spec/views/members/index.html.haml_spec.rb ++++ b/spec/views/members/index.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "members/index" do +diff --git a/spec/views/members/show.rss.haml_spec.rb b/spec/views/members/show.rss.haml_spec.rb +index ce4dc4c5..873e9ecf 100644 +--- a/spec/views/members/show.rss.haml_spec.rb ++++ b/spec/views/members/show.rss.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'members/show.rss.haml', type: "view" do +diff --git a/spec/views/photos/edit.html.haml_spec.rb b/spec/views/photos/edit.html.haml_spec.rb +index ba481b10..1e94fb7b 100644 +--- a/spec/views/photos/edit.html.haml_spec.rb ++++ b/spec/views/photos/edit.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "photos/edit" do +diff --git a/spec/views/photos/index.html.haml_spec.rb b/spec/views/photos/index.html.haml_spec.rb +index ef058e82..86843ce1 100644 +--- a/spec/views/photos/index.html.haml_spec.rb ++++ b/spec/views/photos/index.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "photos/index" do +diff --git a/spec/views/photos/new.html.haml_spec.rb b/spec/views/photos/new.html.haml_spec.rb +index 9f4072ee..d15e99e2 100644 +--- a/spec/views/photos/new.html.haml_spec.rb ++++ b/spec/views/photos/new.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "photos/new" do +diff --git a/spec/views/photos/show.html.haml_spec.rb b/spec/views/photos/show.html.haml_spec.rb +index f0f1235e..19690e30 100644 +--- a/spec/views/photos/show.html.haml_spec.rb ++++ b/spec/views/photos/show.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "photos/show" do +diff --git a/spec/views/places/_map_attribution.html.haml_spec.rb b/spec/views/places/_map_attribution.html.haml_spec.rb +index afe384df..9b869a30 100644 +--- a/spec/views/places/_map_attribution.html.haml_spec.rb ++++ b/spec/views/places/_map_attribution.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "places/_map_attribution.html.haml", type: :view do +diff --git a/spec/views/places/index.html.haml_spec.rb b/spec/views/places/index.html.haml_spec.rb +index 072eb4ca..f49bb923 100644 +--- a/spec/views/places/index.html.haml_spec.rb ++++ b/spec/views/places/index.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "places/index" do +diff --git a/spec/views/places/show.html.haml_spec.rb b/spec/views/places/show.html.haml_spec.rb +index 7f9aa0c9..2ac779a1 100644 +--- a/spec/views/places/show.html.haml_spec.rb ++++ b/spec/views/places/show.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "places/show" do +diff --git a/spec/views/plant_parts/edit.html.haml_spec.rb b/spec/views/plant_parts/edit.html.haml_spec.rb +index cc6070fb..c21a9210 100644 +--- a/spec/views/plant_parts/edit.html.haml_spec.rb ++++ b/spec/views/plant_parts/edit.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "plant_parts/edit" do +diff --git a/spec/views/plant_parts/index.html.haml_spec.rb b/spec/views/plant_parts/index.html.haml_spec.rb +index b46c4a1a..828f942e 100644 +--- a/spec/views/plant_parts/index.html.haml_spec.rb ++++ b/spec/views/plant_parts/index.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "plant_parts/index" do +diff --git a/spec/views/plant_parts/new.html.haml_spec.rb b/spec/views/plant_parts/new.html.haml_spec.rb +index b0067273..203dc128 100644 +--- a/spec/views/plant_parts/new.html.haml_spec.rb ++++ b/spec/views/plant_parts/new.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "plant_parts/new" do +diff --git a/spec/views/plant_parts/show.html.haml_spec.rb b/spec/views/plant_parts/show.html.haml_spec.rb +index 9947cfcc..39dce332 100644 +--- a/spec/views/plant_parts/show.html.haml_spec.rb ++++ b/spec/views/plant_parts/show.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "plant_parts/show" do +diff --git a/spec/views/plantings/_form.html.haml_spec.rb b/spec/views/plantings/_form.html.haml_spec.rb +index 0f4c6f1a..a4f110a2 100644 +--- a/spec/views/plantings/_form.html.haml_spec.rb ++++ b/spec/views/plantings/_form.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "plantings/_form" do +diff --git a/spec/views/plantings/edit.html.haml_spec.rb b/spec/views/plantings/edit.html.haml_spec.rb +index 6baf126f..3acb1422 100644 +--- a/spec/views/plantings/edit.html.haml_spec.rb ++++ b/spec/views/plantings/edit.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "plantings/edit" do +diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb +index 4284eada..09552065 100644 +--- a/spec/views/plantings/index.html.haml_spec.rb ++++ b/spec/views/plantings/index.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "plantings/index" do +@@ -13,23 +15,28 @@ describe "plantings/index" do + total_entries = 3 + plantings = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| + pager.replace([ +- FactoryBot.create(:planting, +- garden: garden, +- crop: tomato, +- owner: member), +- FactoryBot.create(:planting, +- garden: garden, +- crop: maize, +- owner: garden.owner, +- description: '', +- planted_at: Time.zone.local(2013, 1, 13)), +- FactoryBot.create(:planting, +- garden: garden, +- owner: garden.owner, +- crop: tomato, +- planted_at: Time.zone.local(2013, 1, 13), +- finished_at: Time.zone.local(2013, 1, 20), +- finished: true) ++ { ++ 'crop_name' => tomato.name, ++ 'slug' => 'tomato-1', ++ 'owner_name' => member.login_name, ++ 'owner_slug' => member.slug ++ }, ++ { ++ 'crop_name' => maize.name, ++ 'slug' => 'maize', ++ 'owner_name' => garden.owner.login_name, ++ 'owner_slug' => garden.owner.slug, ++ 'planted_at' => Time.zone.local(2013, 1, 13) ++ }, ++ { ++ 'crop_name' => tomato.name, ++ 'slug' => 'tomato-2', ++ 'owner_name' => garden.owner.login_name, ++ 'owner_slug' => garden.owner.slug, ++ 'planted_at' => Time.zone.local(2013, 1, 13), ++ 'finished_at' => Time.zone.local(2013, 1, 20), ++ 'finished' => true ++ } + ]) + end + assign(:plantings, plantings) +@@ -37,8 +44,8 @@ describe "plantings/index" do + end + + describe "renders a list of plantings" do +- it { expect(rendered).to have_content tomato.name } +- it { expect(rendered).to have_content maize.name } ++ it { expect(rendered).to have_content 'tomato' } ++ it { expect(rendered).to have_content 'maize' } + end + + it "provides data links" do +diff --git a/spec/views/plantings/index.rss.haml_spec.rb b/spec/views/plantings/index.rss.haml_spec.rb +index 24faa046..6361aaf4 100644 +--- a/spec/views/plantings/index.rss.haml_spec.rb ++++ b/spec/views/plantings/index.rss.haml_spec.rb +@@ -1,6 +1,8 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + +-describe 'plantings/index.rss.haml' do ++describe 'plantings/index.rss.haml', :search do + before do + controller.stub(:current_user) { nil } + end +@@ -10,28 +12,29 @@ describe 'plantings/index.rss.haml' do + @planting = FactoryBot.create(:planting) + @sunny = FactoryBot.create(:sunny_planting) + @seedling = FactoryBot.create(:seedling_planting) +- assign(:plantings, [@planting, @sunny, @seedling]) ++ Planting.searchkick_index.refresh ++ assign(:plantings, Planting.search(load: false)) + render + end + + it 'shows RSS feed title' do +- rendered.should have_content "Recent plantings from all members" ++ expect(rendered).to have_content "Recent plantings from all members" + end + + it 'item title shows owner and location' do +- rendered.should have_content "#{@planting.crop} in #{@planting.location}" ++ expect(rendered).to have_content "#{@planting.crop} in #{@planting.location}" + end + + it 'shows formatted content of posts' do +- rendered.should have_content "This is a really good plant." ++ expect(rendered).to have_content "This is a really good plant." + end + + it 'shows sunniness' do +- rendered.should have_content 'Sunniness: sun' ++ expect(rendered).to have_content 'Sunniness: sun' + end + + it 'shows propagation method' do +- rendered.should have_content 'Planted from: seedling' ++ expect(rendered).to have_content 'Planted from: seedling' + end + end + +@@ -44,7 +47,7 @@ describe 'plantings/index.rss.haml' do + end + + it 'shows title for single member' do +- rendered.should have_content "Recent plantings from #{@planting.owner}" ++ expect(rendered).to have_content "Recent plantings from #{@planting.owner}" + end + end + end +diff --git a/spec/views/plantings/new.html.haml_spec.rb b/spec/views/plantings/new.html.haml_spec.rb +index 3376d5cc..b0aa596f 100644 +--- a/spec/views/plantings/new.html.haml_spec.rb ++++ b/spec/views/plantings/new.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "plantings/new" do +diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb +index c774c5d4..5d7161e8 100644 +--- a/spec/views/plantings/show.html.haml_spec.rb ++++ b/spec/views/plantings/show.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "plantings/show" do +diff --git a/spec/views/posts/_single.html.haml_spec.rb b/spec/views/posts/_single.html.haml_spec.rb +index 90c15af7..403ea119 100644 +--- a/spec/views/posts/_single.html.haml_spec.rb ++++ b/spec/views/posts/_single.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "posts/_single" do +diff --git a/spec/views/posts/edit.html.haml_spec.rb b/spec/views/posts/edit.html.haml_spec.rb +index 2119f80b..c664f213 100644 +--- a/spec/views/posts/edit.html.haml_spec.rb ++++ b/spec/views/posts/edit.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "posts/edit" do +diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb +index c865b298..613f8dc5 100644 +--- a/spec/views/posts/index.html.haml_spec.rb ++++ b/spec/views/posts/index.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "posts/index" do +diff --git a/spec/views/posts/index.rss.haml_spec.rb b/spec/views/posts/index.rss.haml_spec.rb +index 030e22c0..055de59e 100644 +--- a/spec/views/posts/index.rss.haml_spec.rb ++++ b/spec/views/posts/index.rss.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'posts/index.rss.haml', type: "view" do +diff --git a/spec/views/posts/new.html.haml_spec.rb b/spec/views/posts/new.html.haml_spec.rb +index eaef7f5d..3e5e0efc 100644 +--- a/spec/views/posts/new.html.haml_spec.rb ++++ b/spec/views/posts/new.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "posts/new" do +diff --git a/spec/views/posts/show.html.haml_spec.rb b/spec/views/posts/show.html.haml_spec.rb +index bb59f2b4..e40918c1 100644 +--- a/spec/views/posts/show.html.haml_spec.rb ++++ b/spec/views/posts/show.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "posts/show" do +diff --git a/spec/views/posts/show.rss.haml_spec.rb b/spec/views/posts/show.rss.haml_spec.rb +index 802bebe9..effd8709 100644 +--- a/spec/views/posts/show.rss.haml_spec.rb ++++ b/spec/views/posts/show.rss.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe 'posts/show.rss.haml' do +diff --git a/spec/views/scientific_names/edit.html.haml_spec.rb b/spec/views/scientific_names/edit.html.haml_spec.rb +index b497b44e..b6b3cfb7 100644 +--- a/spec/views/scientific_names/edit.html.haml_spec.rb ++++ b/spec/views/scientific_names/edit.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "scientific_names/edit" do +diff --git a/spec/views/scientific_names/index.html.haml_spec.rb b/spec/views/scientific_names/index.html.haml_spec.rb +index 9d098e58..88401808 100644 +--- a/spec/views/scientific_names/index.html.haml_spec.rb ++++ b/spec/views/scientific_names/index.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "scientific_names/index" do +diff --git a/spec/views/scientific_names/new.html.haml_spec.rb b/spec/views/scientific_names/new.html.haml_spec.rb +index 1f632030..39dbedd8 100644 +--- a/spec/views/scientific_names/new.html.haml_spec.rb ++++ b/spec/views/scientific_names/new.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "scientific_names/new" do +diff --git a/spec/views/scientific_names/show.html.haml_spec.rb b/spec/views/scientific_names/show.html.haml_spec.rb +index ed815c55..1661ae8d 100644 +--- a/spec/views/scientific_names/show.html.haml_spec.rb ++++ b/spec/views/scientific_names/show.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "scientific_names/show" do +diff --git a/spec/views/seeds/edit.html.haml_spec.rb b/spec/views/seeds/edit.html.haml_spec.rb +index 4bc6bf81..d7d5cd87 100644 +--- a/spec/views/seeds/edit.html.haml_spec.rb ++++ b/spec/views/seeds/edit.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "seeds/edit" do +diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb +index cfeedd90..7940824f 100644 +--- a/spec/views/seeds/index.rss.haml_spec.rb ++++ b/spec/views/seeds/index.rss.haml_spec.rb +@@ -1,49 +1,64 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + +-describe 'seeds/index.rss.haml' do ++describe 'seeds/index.rss.haml', :search do + before do + controller.stub(:current_user) { nil } + end + +- context 'all seeds' do +- before do +- @seed = FactoryBot.create(:seed) +- @tradable = FactoryBot.create(:tradable_seed) +- assign(:seeds, [@seed, @tradable]) +- render ++ shared_examples 'displays seed in rss feed' do ++ it 'has a useful item title' do ++ expect(rendered).to have_content "#{seed.owner.login_name}'s #{seed.crop.name} seeds" + end + +- it 'shows RSS feed title' do +- rendered.should have_content "Recent seeds from all members" ++ it 'shows the seed count' do ++ expect(rendered).to have_content "Quantity: #{seed.quantity}" + end + +- it 'has a useful item title' do +- rendered.should have_content "#{@seed.owner}'s #{@seed.crop} seeds" ++ it 'shows the plant_before date' do ++ expect(rendered).to have_content "Plant before: #{seed.plant_before.to_s(:ymd)}" + end ++ end + +- it 'shows the seed count' do +- rendered.should have_content "Quantity: #{@seed.quantity}" ++ context 'all seeds' do ++ let!(:seed) { FactoryBot.create(:seed) } ++ let!(:tradable) { FactoryBot.create(:tradable_seed) } ++ before do ++ Seed.searchkick_index.refresh ++ assign(:seeds, Seed.search(load: false)) ++ render + end + +- it 'shows the plant_before date' do +- rendered.should have_content "Plant before: #{@seed.plant_before}" ++ include_examples 'displays seed in rss feed' ++ ++ it 'shows RSS feed title' do ++ expect(rendered).to have_content "Recent seeds from all members" + end + + it 'mentions that one seed is tradable' do +- rendered.should have_content "Will trade #{@tradable.tradable_to} from #{@tradable.owner.location}" ++ expect(rendered).to have_content "Will trade #{tradable.tradable_to} from #{tradable.owner.location}" ++ end ++ ++ it "does not offer untradable seed as tradeable" do ++ expect(rendered).not_to have_content "Will trade #{seed.tradable_to} from #{seed.owner.location}" + end + end + + context "one member's seeds" do ++ let!(:seed) { FactoryBot.create(:seed) } ++ + before do +- @seed = FactoryBot.create(:seed) +- assign(:seeds, [@seed]) +- assign(:owner, @seed.owner) ++ assign(:owner, seed.owner) ++ Seed.searchkick_index.refresh ++ assign(:seeds, Seed.search(load: false)) + render + end + + it 'shows RSS feed title' do +- rendered.should have_content "Recent seeds from #{@seed.owner}" ++ expect(rendered).to have_content "Recent seeds from #{seed.owner}" + end ++ ++ include_examples 'displays seed in rss feed' + end + end +diff --git a/spec/views/seeds/new.html.haml_spec.rb b/spec/views/seeds/new.html.haml_spec.rb +index fc40236e..407e52d7 100644 +--- a/spec/views/seeds/new.html.haml_spec.rb ++++ b/spec/views/seeds/new.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "seeds/new" do +diff --git a/spec/views/seeds/show.html.haml_spec.rb b/spec/views/seeds/show.html.haml_spec.rb +index 34525fbb..2cc9fe14 100644 +--- a/spec/views/seeds/show.html.haml_spec.rb ++++ b/spec/views/seeds/show.html.haml_spec.rb +@@ -1,3 +1,5 @@ ++# frozen_string_literal: true ++ + require 'rails_helper' + + describe "seeds/show" do diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index 7e9c01ff9..29bfc95b6 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe HarvestsController do +describe HarvestsController, :search do login_member def valid_attributes diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 4cf8140bd..55f6628fd 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe PhotosController do +describe PhotosController, :search do login_member describe 'GET index' do diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index 2a3b4daa0..0baac6d46 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe PlantingsController do +describe PlantingsController, :search do login_member def valid_attributes diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb index c8fdf27c8..4ed7bf27d 100644 --- a/spec/controllers/seeds_controller_spec.rb +++ b/spec/controllers/seeds_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe SeedsController do +describe SeedsController, :search do let(:owner) { FactoryBot.create(:member) } describe "GET index" do From 1c7816c951b400c7f4a5067ebebd81b7225b9b7f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 27 Dec 2019 16:57:00 +1300 Subject: [PATCH 122/188] fixing photos by crop query in photos controller --- app/controllers/photos_controller.rb | 2 +- app/models/concerns/search_photos.rb | 5 ++-- spec/controllers/photos_controller_spec.rb | 34 +++++++++++++++++----- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index d168488b1..ad64d58f5 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -16,7 +16,7 @@ class PhotosController < ApplicationController where = {} if params[:crop_slug] @crop = Crop.find params[:crop_slug] - where = { crop_id: @crop.id } + where = { crops: [@crop.id] } elsif params[:planting_id] @planting = Planting.find params[:planting_id] where = { planting_id: @planting.id } diff --git a/app/models/concerns/search_photos.rb b/app/models/concerns/search_photos.rb index 1715963a1..2ab03d896 100644 --- a/app/models/concerns/search_photos.rb +++ b/app/models/concerns/search_photos.rb @@ -12,12 +12,13 @@ module SearchPhotos } } - # scope :search_import, -> { includes(:owner, :crops, :plantings, :harvests, :seeds, :posts) } + scope :search_import, -> { includes(:owner, :crops, :plantings, :harvests, :seeds, :posts) } def search_data { + id: id, title: title, - crops: crops.map(&:id), + crops: photo_associations.map(&:crop_id), owner_id: owner_id, owner_login_name: owner.login_name, thumbnail_url: thumbnail_url, diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 55f6628fd..c7f27e8df 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -9,29 +9,49 @@ describe PhotosController, :search do describe 'all photos' do let!(:photo) { FactoryBot.create :photo } - before { get :index } + before do + Photo.searchkick_index.refresh + photo.reindex + sleep 1 + get :index + end - it { expect(assigns(:photos)).to eq [photo] } + it "finds photos" do + expect(assigns(:photos).size).to eq 1 + expect(assigns(:photos).first.id).to eq photo.id + end end describe 'crop photos' do - let!(:photo) { FactoryBot.create :photo, owner: member } - let!(:crop_photo) { FactoryBot.create :photo, owner: member } + let!(:photo) { FactoryBot.create :photo, owner: member, title: 'no assocations photo' } + let!(:crop_photo) { FactoryBot.create :photo, owner: member, title: 'photos of planting' } let!(:planting) { FactoryBot.create :planting, crop: crop, owner: member } let!(:crop) { FactoryBot.create :crop } before do planting.photos << crop_photo + Photo.searchkick_index.refresh + crop_photo.reload + crop_photo.reindex + # This is terrible, but this is needed for ES to fully index this + sleep 1 + + # all these tests are inline, so we only sleep once get :index, params: { crop_slug: crop.to_param } end - it { expect(assigns(:crop)).to eq crop } - it { expect(assigns(:photos)).to eq [crop_photo] } + it "find photos by crop" do + expect(Photo.search).to include crop_photo + expect(assigns(:crop)).to eq crop + expect(assigns(:photos).size).to eq 1 + expect(assigns(:photos).first.crops).to include crop.id + expect(assigns(:photos).first.id).to eq crop_photo.id + end end end describe "GET new" do - let(:tomato) { FactoryBot.create(:tomato) } + let(:tomato) { FactoryBot.create(:tomato) } let(:planting) { FactoryBot.create(:planting, crop: tomato, owner: member) } let(:garden) { FactoryBot.create(:garden, owner: member) } let(:harvest) { FactoryBot.create(:harvest, owner: member) } From 2685cc70a7cf796539f5bf25c24fb6c1cf70e2e6 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Fri, 27 Dec 2019 04:21:06 +0000 Subject: [PATCH 123/188] [CodeFactor] Apply fixes to commit 1c7816c --- spec/controllers/photos_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index c7f27e8df..a6680d308 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -18,7 +18,7 @@ describe PhotosController, :search do it "finds photos" do expect(assigns(:photos).size).to eq 1 - expect(assigns(:photos).first.id).to eq photo.id + expect(assigns(:photos).first.id).to eq photo.id end end From a015110b05772485cdde37544d43c4721c9399e2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 27 Dec 2019 19:50:46 +1300 Subject: [PATCH 124/188] Reindex before running plantings controller specs --- spec/controllers/plantings_controller_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index 0baac6d46..f7d9a0a21 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -8,7 +8,7 @@ describe PlantingsController, :search do def valid_attributes { garden_id: FactoryBot.create(:garden, owner: subject.current_member).id, - crop_id: FactoryBot.create(:crop).id + crop_id: FactoryBot.create(:crop).id } end @@ -19,6 +19,9 @@ describe PlantingsController, :search do let!(:maize) { FactoryBot.create(:maize) } let!(:planting1) { FactoryBot.create :planting, crop: tomato, owner: member1, created_at: 1.day.ago } let!(:planting2) { FactoryBot.create :planting, crop: maize, owner: member2, created_at: 5.days.ago } + before do + Planting.reindex + end describe "assigns all plantings as @plantings" do before { get :index } From 1bb8770a6e3b4866f79d72c1162d66d8e4ddf1f8 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Fri, 27 Dec 2019 06:51:32 +0000 Subject: [PATCH 125/188] [CodeFactor] Apply fixes --- spec/controllers/plantings_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index f7d9a0a21..4b5f2a651 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -8,7 +8,7 @@ describe PlantingsController, :search do def valid_attributes { garden_id: FactoryBot.create(:garden, owner: subject.current_member).id, - crop_id: FactoryBot.create(:crop).id + crop_id: FactoryBot.create(:crop).id } end From 2185892cf5036cc489ee6573bb4365eb7f40efa8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 27 Dec 2019 19:52:43 +1300 Subject: [PATCH 126/188] Trying a different way to ES reindex in spec helper --- spec/spec_helper.rb | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d84389efc..393572a45 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -36,23 +36,36 @@ RSpec.configure do |config| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end - config.before(:suite) do - # reindex models - Crop.searchkick_index.refresh - Seed.searchkick_index.refresh - Harvest.searchkick_index.refresh - Planting.searchkick_index.refresh + # config.before(:suite) do + # # reindex models + # Crop.searchkick_index.refresh + # Seed.searchkick_index.refresh + # Harvest.searchkick_index.refresh + # Planting.searchkick_index.refresh - # and disable callbacks - Searchkick.disable_callbacks - end + # # and disable callbacks + # Searchkick.disable_callbacks + # end - config.around(:each, search: true) do |example| - Searchkick.callbacks(true) do - example.run + # config.around(:each, search: true) do |example| + # Searchkick.callbacks(true) do + # example.run + # end + # end + config.before(:each) do |example| + # Elasticsearch / Searchkick + if example.metadata[:search] + Searchkick.enable_callbacks + Crop.reindex + Photo.reindex + Harvest.reindex + Seed.reindex + Planting.reindex + else + Searchkick.disable_callbacks end end - + # rspec-mocks config goes here. You can use an alternate test double # library (such as bogus or mocha) by changing the `mock_with` option here. config.mock_with :rspec do |mocks| From 5eea6d65d065fc3e22f80e6af0b874f648ddee61 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Fri, 27 Dec 2019 19:34:42 +0000 Subject: [PATCH 127/188] [CodeFactor] Apply fixes --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 393572a45..8c64b75b7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -65,7 +65,7 @@ RSpec.configure do |config| Searchkick.disable_callbacks end end - + # rspec-mocks config goes here. You can use an alternate test double # library (such as bogus or mocha) by changing the `mock_with` option here. config.mock_with :rspec do |mocks| From 59130d5603ebec726b11142a5dc0d24d3a2102e7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 28 Dec 2019 08:41:47 +1300 Subject: [PATCH 128/188] display rss feed from harvests objects (instead of hashes) --- app/views/harvests/index.rss.haml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/harvests/index.rss.haml b/app/views/harvests/index.rss.haml index 7967b23e5..6d4fd0fcb 100644 --- a/app/views/harvests/index.rss.haml +++ b/app/views/harvests/index.rss.haml @@ -6,12 +6,12 @@ %link= harvests_url - @harvests.each do |harvest| %item - %title #{harvest['owner_name']}'s #{harvest['crop_name']} - %pubdate= harvest['harvested_at'] + %title #{harvest.owner_name}'s #{harvest.crop_name} + %pubdate= harvest.harvested_at %description :escaped -

Crop: #{harvest['crop_name']}

-

Quantity: #{harvest['quantity'] ? harvest['quantity'] : 'unknown' }

-

Harvested on: #{harvest['harvested_at'] ? harvest['harvested_at'] : 'unknown' }

- %link= harvest_url(slug: harvest['slug']) - %guid= harvest_url(slug: harvest['slug']) +

Crop: #{harvest.crop_name}

+

Quantity: #{harvest.quantity ? harvest.quantity : 'unknown' }

+

Harvested on: #{harvest.harvested_at ? harvest.harvested_at : 'unknown' }

+ %link= harvest_url(slug: harvest.slug) + %guid= harvest_url(slug: harvest.slug) From 06241842700817b491d1a18a57cf7b9baf2b1ed2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 28 Dec 2019 09:06:13 +1300 Subject: [PATCH 129/188] tidying up matching attributes for seeds rss feed --- app/models/concerns/search_seeds.rb | 74 ++++++++++++++--------------- app/views/seeds/index.rss.haml | 24 +++++----- 2 files changed, 48 insertions(+), 50 deletions(-) diff --git a/app/models/concerns/search_seeds.rb b/app/models/concerns/search_seeds.rb index f54779362..4ba34b1ea 100644 --- a/app/models/concerns/search_seeds.rb +++ b/app/models/concerns/search_seeds.rb @@ -4,54 +4,52 @@ module SearchSeeds extend ActiveSupport::Concern included do - searchkick merge_mappings: true, - mappings: { - properties: { - created_at: { type: :integer }, - plant_before: { type: :text }, - photos_count: { type: :integer }, - tradable_to: { type: :text } - } - } + searchkick merge_mappings: true, mappings: { + properties: { + created_at: { type: :integer }, + plant_before: { type: :text }, + photos_count: { type: :integer }, + tradable_to: { type: :text } + } + } scope :search_import, -> { includes(:owner, :crop, :parent_planting) } def search_data { - slug: slug, - crop_id: crop_id, - crop_name: crop.name, - crop_slug: crop.slug, - gmo: gmo, - has_photos: photos.size.positive?, - heirloom: heirloom, - organic: organic, - owner_id: owner_id, + slug: slug, + crop_id: crop_id, + crop_name: crop.name, + crop_slug: crop.slug, + finished: finished?, + gmo: gmo, + has_photos: photos.size.positive?, + heirloom: heirloom, + location: owner.location, + organic: organic, + owner_id: owner_id, + owner_location: owner_location, owner_login_name: owner_login_name, - owner_location: owner_location, - owner_slug: owner_slug, - parent_planting: parent_planting, - photos_count: photos.size, - plant_before: plant_before&.to_s(:ymd), - quantity: quantity, - thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, - tradable_to: tradable_to, - tradable: tradable?, - finished: finished?, - location: owner.location, - created_at: created_at.to_i + owner_slug: owner_slug, + parent_planting: parent_planting, + photos_count: photos.size, + plant_before: plant_before&.to_s(:ymd), + quantity: quantity, + thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, + tradable_to: tradable_to, + tradable: tradable?, + created_at: created_at.to_i } end def self.homepage_records(limit) - search('*', - limit: limit, - where: { - finished: false, - tradable: true - }, - boost_by: [:created_at], - load: false) + search('*', limit: limit, + where: { + finished: false, + tradable: true + }, + boost_by: [:created_at], + load: false) end end end diff --git a/app/views/seeds/index.rss.haml b/app/views/seeds/index.rss.haml index 0d128c2fc..24bec8c06 100644 --- a/app/views/seeds/index.rss.haml +++ b/app/views/seeds/index.rss.haml @@ -2,21 +2,21 @@ %rss{ version: 2.0 } %channel %title - Recent seeds from #{@owner ? @owner : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']}) + Recent seeds from #{@owner ||= 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']}) %link= seeds_url - @seeds.each do |seed| %item - %title #{seed['owner_name']}'s #{seed['crop_name']} seeds - %pubdate= seed['created_at'].to_s(:rfc822) + %title #{seed.owner_login_name}'s #{seed.crop_name} seeds + %pubdate= seed.created_at.to_s(:rfc822) %description :escaped -

Quantity: #{seed['quantity'] ? seed['quantity'] : 'unknown' }

-

Plant before: #{seed['plant_before'] ? seed['plant_before'] : 'unknown' }

-

Organic? #{seed['organic']}

-

GMO? #{seed['gmo']}

-

Heirloom? #{seed['heirloom']}

- - if seed['tradeable'] +

Quantity: #{seed.quantity ||= 'unknown' }

+

Plant before: #{seed.plant_before ||= 'unknown' }

+

Organic? #{seed.organic}

+

GMO? #{seed.gmo}

+

Heirloom? #{seed.heirloom}

+ - if seed.tradable :escaped -

Will trade #{seed['tradable_to']} from #{seed['location'] ? seed['location'] : 'unknown location'}

- %link= seed_url(slug: seed['slug']) - %guid= seed_url(slug: seed['slug']) +

Will trade #{seed.tradable_to} from #{seed.location ||= 'unknown location'}

+ %link= seed_url(slug: seed.slug) + %guid= seed_url(slug: seed.slug) From 979d172bd7600e306a9d558c83d14cc52e4c4769 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 28 Dec 2019 09:06:23 +1300 Subject: [PATCH 130/188] rubocop tidy on harvests rss feed --- app/views/harvests/index.rss.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/harvests/index.rss.haml b/app/views/harvests/index.rss.haml index 6d4fd0fcb..f2ee766a6 100644 --- a/app/views/harvests/index.rss.haml +++ b/app/views/harvests/index.rss.haml @@ -2,16 +2,16 @@ %rss{ version: 2.0 } %channel %title - Recent harvests from #{@owner ? @owner : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']}) + Recent harvests from #{@owner ||= 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']}) %link= harvests_url - @harvests.each do |harvest| %item - %title #{harvest.owner_name}'s #{harvest.crop_name} + %title #{harvest.owner_login_name}'s #{harvest.crop_name} %pubdate= harvest.harvested_at %description :escaped

Crop: #{harvest.crop_name}

-

Quantity: #{harvest.quantity ? harvest.quantity : 'unknown' }

-

Harvested on: #{harvest.harvested_at ? harvest.harvested_at : 'unknown' }

+

Quantity: #{harvest.quantity ||= 'unknown' }

+

Harvested on: #{harvest.harvested_at ||= 'unknown' }

%link= harvest_url(slug: harvest.slug) %guid= harvest_url(slug: harvest.slug) From ce909332b7098d26bebad2076b66d40045d5deea Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 28 Dec 2019 09:15:52 +1300 Subject: [PATCH 131/188] plantings controller update --- app/controllers/plantings_controller.rb | 16 +++++++--------- spec/controllers/plantings_controller_spec.rb | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 7b6c92734..983fb13ff 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -21,11 +21,11 @@ class PlantingsController < DataController end @plantings = Planting.search( - where: where, - page: params[:page], - limit: 30, + where: where, + page: params[:page], + limit: 30, boost_by: [:created_at], - load: false + load: false ) @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv" @@ -34,8 +34,6 @@ class PlantingsController < DataController end def show - @planting = Planting.includes(:owner, :crop, :garden) - .find(params[:slug]) @photos = @planting.photos.includes(:owner).order(date_taken: :desc) @harvests = Harvest.search(where: { planting_id: @planting.id }) @matching_seeds = matching_seeds @@ -51,15 +49,15 @@ class PlantingsController < DataController def new @planting = Planting.new( planted_at: Time.zone.today, - owner: current_member, - garden: current_member.gardens.first + owner: current_member, + garden: current_member.gardens.first ) @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new if params[:garden_id] @planting.garden = Garden.find_by( owner: current_member, - id: params[:garden_id] + id: params[:garden_id] ) end diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index 4b5f2a651..f7d9a0a21 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -8,7 +8,7 @@ describe PlantingsController, :search do def valid_attributes { garden_id: FactoryBot.create(:garden, owner: subject.current_member).id, - crop_id: FactoryBot.create(:crop).id + crop_id: FactoryBot.create(:crop).id } end From 8ee332edd8888646eb57a08f1b2fa3e0f526ad69 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 28 Dec 2019 09:20:18 +1300 Subject: [PATCH 132/188] update harvests controller --- app/controllers/harvests_controller.rb | 11 +++++------ spec/controllers/harvests_controller_spec.rb | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index c618b9742..67dbe5528 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -20,12 +20,11 @@ class HarvestsController < DataController where['planting_id'] = @planting.id end - @harvests = Harvest.search('*', - where: where, - limit: 100, - page: params[:page], - load: false, - boost_by: [:created_at]) + @harvests = Harvest.search('*', where: where, + limit: 100, + page: params[:page], + load: false, + boost_by: [:created_at]) @filename = csv_filename diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index 29bfc95b6..6233a28dc 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -7,10 +7,10 @@ describe HarvestsController, :search do def valid_attributes { - owner_id: subject.current_member.id, - crop_id: FactoryBot.create(:crop).id, + owner_id: subject.current_member.id, + crop_id: FactoryBot.create(:crop).id, plant_part_id: FactoryBot.create(:plant_part).id, - harvested_at: '2017-01-01' + harvested_at: '2017-01-01' } end @@ -28,8 +28,8 @@ describe HarvestsController, :search do before { get :index, params: {} } it { expect(assigns(:harvests).size).to eq 2 } - it { expect(assigns(:harvests)[0]['slug']).to eq harvest1.slug } - it { expect(assigns(:harvests)[1]['slug']).to eq harvest2.slug } + it { expect(assigns(:harvests)[0].slug).to eq harvest1.slug } + it { expect(assigns(:harvests)[1].slug).to eq harvest2.slug } end describe "picks up owner from params and shows owner's harvests only" do @@ -37,7 +37,7 @@ describe HarvestsController, :search do it { expect(assigns(:owner)).to eq member1 } it { expect(assigns(:harvests).size).to eq 1 } - it { expect(assigns(:harvests)[0]['slug']).to eq harvest1.slug } + it { expect(assigns(:harvests)[0].slug).to eq harvest1.slug } end describe "picks up crop from params and shows the harvests for the crop only" do @@ -45,7 +45,7 @@ describe HarvestsController, :search do it { expect(assigns(:crop)).to eq maize } it { expect(assigns(:harvests).size).to eq 1 } - it { expect(assigns(:harvests)[0]['slug']).to eq harvest2.slug } + it { expect(assigns(:harvests)[0].slug).to eq harvest2.slug } end describe "generates a csv" do @@ -195,8 +195,10 @@ describe HarvestsController, :search do describe "does not save planting_id" do before do - put :update, params: { slug: harvest.to_param, - harvest: valid_attributes.merge(planting_id: not_my_planting.id) } + put :update, params: { + slug: harvest.to_param, + harvest: valid_attributes.merge(planting_id: not_my_planting.id) + } end it { expect(harvest.planting_id).to eq(nil) } From b9e9ce1439dd2859a08b5b6a4e2746a1c1400a5a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 28 Dec 2019 09:33:36 +1300 Subject: [PATCH 133/188] index seed.active into ES --- app/helpers/buttons_helper.rb | 2 +- app/models/concerns/search_seeds.rb | 1 + app/views/seeds/_actions.html.haml | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 9cc5e11c6..fb1ac0458 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -81,7 +81,7 @@ module ButtonsHelper end def seed_finish_button(seed, classes: 'btn btn-default') - return unless can?(:create, Planting) && seed.active? + return unless can?(:create, Planting) && seed.active link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: "#{classes} append-date" do finished_icon + ' ' + t('buttons.mark_as_finished') diff --git a/app/models/concerns/search_seeds.rb b/app/models/concerns/search_seeds.rb index 4ba34b1ea..326ce2b35 100644 --- a/app/models/concerns/search_seeds.rb +++ b/app/models/concerns/search_seeds.rb @@ -24,6 +24,7 @@ module SearchSeeds finished: finished?, gmo: gmo, has_photos: photos.size.positive?, + active: active, heirloom: heirloom, location: owner.location, organic: organic, diff --git a/app/views/seeds/_actions.html.haml b/app/views/seeds/_actions.html.haml index 5cc91951a..1d337eea4 100644 --- a/app/views/seeds/_actions.html.haml +++ b/app/views/seeds/_actions.html.haml @@ -3,13 +3,13 @@ %a#seed-actions-button.btn.btn-info.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button", href: '#'} Actions .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "seed-actions-button"} - - if can?(:create, Planting) && can?(:update, seed) && seed.active? + - if can?(:create, Planting) && can?(:update, seed) && seed.active = link_to new_planting_path(seed_id: seed), class: 'dropdown-item success-color' do = seed_icon Plant seeds = seed_edit_button(seed, classes: 'dropdown-item') = add_photo_button(seed, classes: 'dropdown-item') - - if seed.active? + - if seed.active = seed_finish_button(seed, classes: 'dropdown-item') .dropdown-divider = delete_button(seed, classes: 'dropdown-item text-danger') From 233c5666ad0b32705ff3bbff20a004d1bf204929 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 28 Dec 2019 09:33:53 +1300 Subject: [PATCH 134/188] treat harvests as object(not hash) in harvsets rss feed --- app/views/home/_harvests.html.haml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/home/_harvests.html.haml b/app/views/home/_harvests.html.haml index 7dadbbfbd..b8d23f9be 100644 --- a/app/views/home/_harvests.html.haml +++ b/app/views/home/_harvests.html.haml @@ -1,12 +1,12 @@ %h2= t('.recently_harvested') - Harvest.homepage_records(6).each do |harvest| - cache harvest do - = link_to harvest_path(slug: harvest['slug']), class: 'list-group-item list-group-item-action flex-column align-items-start' do + = link_to harvest_path(slug: harvest.slug), class: 'list-group-item list-group-item-action flex-column align-items-start' do .d-flex.w-100.justify-content-between.homepage--list-item %div - %h5= harvest['crop_name'] - %span.badge.badge-success=harvest['plant_part'] + %h5= harvest.crop_name + %span.badge.badge-success=harvest.plant_part %small.text-muted - harvested by #{harvest['owner_name']} + harvested by #{harvest.owner_name} %p.mb-2 - = image_tag harvest['thumbnail_url'], width: 75, class: 'rounded shadow' \ No newline at end of file + = image_tag harvest.thumbnail_url, width: 75, class: 'rounded shadow' \ No newline at end of file From c2b4c67077ea7f2005d9df590f6827170e35efb5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 28 Dec 2019 09:34:04 +1300 Subject: [PATCH 135/188] crop compantion tests --- spec/models/crop_companion_spec.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spec/models/crop_companion_spec.rb b/spec/models/crop_companion_spec.rb index e1cedbfd0..52be791e2 100644 --- a/spec/models/crop_companion_spec.rb +++ b/spec/models/crop_companion_spec.rb @@ -3,5 +3,12 @@ require 'rails_helper' RSpec.describe CropCompanion, type: :model do - pending "add some examples to (or delete) #{__FILE__}" + it 'has a crop' do + cc = CropCompanion.new + cc.crop_a = FactoryBot.create :tomato + cc.crop_b = FactoryBot.create :maize + cc.save! + + expect(cc.crop_a.name).to eq 'tomato' + end end From 97cacdae0e72fce3fc2e8d1009804612e4d2532f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 28 Dec 2019 09:50:08 +1300 Subject: [PATCH 136/188] --- app/models/concerns/search_harvests.rb | 51 +++++++++++++------------- app/models/harvest.rb | 21 ++++++----- app/views/harvests/_card.html.haml | 2 +- app/views/harvests/index.rss.haml | 1 + 4 files changed, 38 insertions(+), 37 deletions(-) diff --git a/app/models/concerns/search_harvests.rb b/app/models/concerns/search_harvests.rb index ea8550a8f..dc8a07b7e 100644 --- a/app/models/concerns/search_harvests.rb +++ b/app/models/concerns/search_harvests.rb @@ -4,46 +4,45 @@ module SearchHarvests extend ActiveSupport::Concern included do - searchkick merge_mappings: true, - mappings: { - properties: { - created_at: { type: :integer }, - harvests_count: { type: :integer }, - photos_count: { type: :integer }, - harvested_at: { type: :date } - } - } + searchkick merge_mappings: true, mappings: { + properties: { + created_at: { type: :integer }, + harvests_count: { type: :integer }, + photos_count: { type: :integer }, + harvested_at: { type: :date } + } + } scope :search_import, -> { includes(:owner, :crop, :plant_part) } def search_data { - slug: slug, - crop_id: crop_id, - crop_name: crop_name, - crop_slug: crop.slug, - has_photos: photos.size.positive?, - owner_id: owner_id, - owner_slug: owner_slug, + slug: slug, + crop_id: crop_id, + crop_name: crop_name, + crop_slug: crop.slug, + has_photos: photos.size.positive?, + owner_id: owner_id, owner_login_name: owner_login_name, - photos_count: photos.count, - plant_part: plant_part&.name, - planting_id: planting_id, - quantity: quantity, - thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, - harvested_at: harvested_at, - created_at: created_at.to_i + owner_slug: owner_slug, + photos_count: photos.count, + plant_part_name: plant_part_name, + planting_id: planting_id, + quantity: quantity, + thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, + harvested_at: harvested_at, + created_at: created_at.to_i } end def self.homepage_records(limit) search('*', - limit: limit, - where: { + limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end diff --git a/app/models/harvest.rb b/app/models/harvest.rb index e0825c0ae..5e7bdcbc1 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -12,15 +12,15 @@ class Harvest < ApplicationRecord # Constants UNITS_VALUES = { "individual" => "individual", - "bunches" => "bunch", - "sprigs" => "sprig", - "handfuls" => "handful", - "litres" => "litre", - "pints" => "pint", - "quarts" => "quart", - "buckets" => "bucket", - "baskets" => "basket", - "bushels" => "bushel" + "bunches" => "bunch", + "sprigs" => "sprig", + "handfuls" => "handful", + "litres" => "litre", + "pints" => "pint", + "quarts" => "quart", + "buckets" => "bucket", + "baskets" => "basket", + "bushels" => "bushel" }.freeze WEIGHT_UNITS_VALUES = { @@ -50,8 +50,9 @@ class Harvest < ApplicationRecord ON (m.id=h2.owner_id AND harvests.id < h2.id)").where("h2 IS NULL") } - delegate :name, to: :crop, prefix: true + delegate :name, :slug, to: :crop, prefix: true delegate :login_name, :slug, to: :owner, prefix: true + delegate :name, to: :plant_part, prefix: true ## ## Validations diff --git a/app/views/harvests/_card.html.haml b/app/views/harvests/_card.html.haml index 55811bb24..7cfedccc8 100644 --- a/app/views/harvests/_card.html.haml +++ b/app/views/harvests/_card.html.haml @@ -5,7 +5,7 @@ .card-body %h5 %strong= link_to harvest.crop_name, harvest_path(slug: harvest.slug) - %span.badge.badge-pill= harvest.plant_part + %span.badge.badge-pill= harvest.plant_part_name .card-footer .float-right %span.chip.member-chip diff --git a/app/views/harvests/index.rss.haml b/app/views/harvests/index.rss.haml index f2ee766a6..10f226d47 100644 --- a/app/views/harvests/index.rss.haml +++ b/app/views/harvests/index.rss.haml @@ -11,6 +11,7 @@ %description :escaped

Crop: #{harvest.crop_name}

+

Plant path: #{harvest.plant_part_name}

Quantity: #{harvest.quantity ||= 'unknown' }

Harvested on: #{harvest.harvested_at ||= 'unknown' }

%link= harvest_url(slug: harvest.slug) From a89534da5358d3edb99f7541d888a010dc47c779 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 28 Dec 2019 10:06:10 +1300 Subject: [PATCH 137/188] harvest tidy up --- app/models/concerns/search_harvests.rb | 13 ++-- app/models/concerns/search_plantings.rb | 70 ++++++++++---------- app/models/harvest.rb | 4 +- spec/views/plantings/index.html.haml_spec.rb | 22 +++--- 4 files changed, 53 insertions(+), 56 deletions(-) diff --git a/app/models/concerns/search_harvests.rb b/app/models/concerns/search_harvests.rb index dc8a07b7e..9be5e48c6 100644 --- a/app/models/concerns/search_harvests.rb +++ b/app/models/concerns/search_harvests.rb @@ -36,13 +36,12 @@ module SearchHarvests end def self.homepage_records(limit) - search('*', - limit: limit, - where: { - photos_count: { gt: 0 } - }, - boost_by: [:created_at], - load: false) + search('*', limit: limit, + where: { + photos_count: { gt: 0 } + }, + boost_by: [:created_at], + load: false) end end end diff --git a/app/models/concerns/search_plantings.rb b/app/models/concerns/search_plantings.rb index 064c869c1..cc2e039a6 100644 --- a/app/models/concerns/search_plantings.rb +++ b/app/models/concerns/search_plantings.rb @@ -4,53 +4,51 @@ module SearchPlantings extend ActiveSupport::Concern included do - searchkick merge_mappings: true, - mappings: { - properties: { - active: { type: :boolean }, - created_at: { type: :integer }, - harvests_count: { type: :integer }, - photos_count: { type: :integer }, - owner_location: { type: :text } - } - } + searchkick merge_mappings: true, mappings: { + properties: { + active: { type: :boolean }, + created_at: { type: :integer }, + harvests_count: { type: :integer }, + photos_count: { type: :integer }, + owner_location: { type: :text } + } + } scope :search_import, -> { includes(:owner, :crop) } def search_data { - slug: slug, - active: active, - crop_id: crop_id, - crop_name: crop.name, - crop_slug: crop.slug, - finished: finished?, - harvests_count: harvests.size, - has_photos: photos.size.positive?, - location: location, - owner_id: owner_id, - owner_location: owner_location, + slug: slug, + active: active, + crop_id: crop_id, + crop_name: crop.name, + crop_slug: crop.slug, + finished: finished?, + harvests_count: harvests_count, + has_photos: photos.size.positive?, + location: location, + owner_id: owner_id, + owner_location: owner_location, owner_login_name: owner_login_name, - owner_slug: owner_slug, + owner_slug: owner_slug, percentage_grown: percentage_grown.to_i, - photos_count: photos.size, - planted_at: planted_at, - planted_from: planted_from, - quantity: quantity, - sunniness: sunniness, - thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, - created_at: created_at.to_i + photos_count: photos.size, + planted_at: planted_at, + planted_from: planted_from, + quantity: quantity, + sunniness: sunniness, + thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, + created_at: created_at.to_i } end def self.homepage_records(limit) - search('*', - limit: limit, - where: { - photos_count: { gt: 0 } - }, - boost_by: [:created_at], - load: false) + search('*', limit: limit, + where: { + photos_count: { gt: 0 } + }, + boost_by: [:created_at], + load: false) end end end diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 5e7bdcbc1..399194610 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -46,8 +46,8 @@ class Harvest < ApplicationRecord scope :recent, -> { order(created_at: :desc) } scope :one_per_owner, lambda { joins("JOIN members m ON (m.id=harvests.owner_id) - LEFT OUTER JOIN harvests h2 - ON (m.id=h2.owner_id AND harvests.id < h2.id)").where("h2 IS NULL") + LEFT OUTER JOIN harvests h2 + ON (m.id=h2.owner_id AND harvests.id < h2.id)").where("h2 IS NULL") } delegate :name, :slug, to: :crop, prefix: true diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index c6a0ae446..f2f29f556 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -17,21 +17,21 @@ describe "plantings/index" do pager.replace([ FactoryBot.create(:planting, garden: garden, - crop: tomato, - owner: member), + crop: tomato, + owner: member), FactoryBot.create(:planting, - garden: garden, - crop: maize, - owner: garden.owner, + garden: garden, + crop: maize, + owner: garden.owner, description: '', - planted_at: Time.zone.local(2013, 1, 13)), + planted_at: Time.zone.local(2013, 1, 13)), FactoryBot.create(:planting, - garden: garden, - owner: garden.owner, - crop: tomato, - planted_at: Time.zone.local(2013, 1, 13), + garden: garden, + owner: garden.owner, + crop: tomato, + planted_at: Time.zone.local(2013, 1, 13), finished_at: Time.zone.local(2013, 1, 20), - finished: true) + finished: true) ]) end assign(:plantings, plantings) From 4940b79043469c791b88ce19eb9d6b10232f260c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 28 Dec 2019 10:08:50 +1300 Subject: [PATCH 138/188] more tidy, crops controller --- app/controllers/crops_controller.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index 994ffe19b..5d520b3e1 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -11,7 +11,10 @@ class CropsController < ApplicationController def index @sort = params[:sort] - @crops = Crop.search('*', boost_by: %i(plantings_count harvests_count), limit: 100, page: params[:page], load: false) + @crops = Crop.search('*', boost_by: %i(plantings_count harvests_count), + limit: 100, + page: params[:page], + load: false) @num_requested_crops = requested_crops.size if current_member @filename = filename respond_with @crops @@ -52,8 +55,8 @@ class CropsController < ApplicationController @term = params[:term] @crops = CropSearchService.search( - @term, page: params[:page], - per_page: 36, + @term, page: params[:page], + per_page: 36, current_member: current_member ) respond_with @crops @@ -204,13 +207,13 @@ class CropsController < ApplicationController def crop_json_fields { include: { - plantings: { + plantings: { include: { owner: { only: %i(id login_name location latitude longitude) } } }, scientific_names: { only: [:name] }, - alternate_names: { only: [:name] } + alternate_names: { only: [:name] } } } end From 38c7bdd7c21dd02590e3ae3aee814605f7a36fb8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 30 Dec 2019 09:38:39 +1300 Subject: [PATCH 139/188] likes count and sorted es search data config --- app/models/concerns/search_harvests.rb | 22 +++++++++++++++---- app/models/concerns/search_photos.rb | 28 ++++++++++++------------- app/models/concerns/search_plantings.rb | 27 ++++++++++++++++-------- app/models/concerns/search_seeds.rb | 27 +++++++++++++++++------- app/models/planting.rb | 1 + db/schema.rb | 2 -- 6 files changed, 70 insertions(+), 37 deletions(-) diff --git a/app/models/concerns/search_harvests.rb b/app/models/concerns/search_harvests.rb index 9be5e48c6..a6d4c4d70 100644 --- a/app/models/concerns/search_harvests.rb +++ b/app/models/concerns/search_harvests.rb @@ -6,9 +6,9 @@ module SearchHarvests included do searchkick merge_mappings: true, mappings: { properties: { - created_at: { type: :integer }, harvests_count: { type: :integer }, photos_count: { type: :integer }, + created_at: { type: :integer }, harvested_at: { type: :date } } } @@ -18,18 +18,32 @@ module SearchHarvests def search_data { slug: slug, + quantity: quantity, + + # crop crop_id: crop_id, crop_name: crop_name, crop_slug: crop.slug, - has_photos: photos.size.positive?, + + # owner owner_id: owner_id, owner_login_name: owner_login_name, owner_slug: owner_slug, - photos_count: photos.count, plant_part_name: plant_part_name, + + #planting planting_id: planting_id, - quantity: quantity, + planting_slug: planting_slug, + + #photo + has_photos: photos.size.positive?, thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, + + # counts + harvests_count: harvests_count, + photos_count: photos.count, + + # timestamps harvested_at: harvested_at, created_at: created_at.to_i } diff --git a/app/models/concerns/search_photos.rb b/app/models/concerns/search_photos.rb index 2ab03d896..04f4b0d2b 100644 --- a/app/models/concerns/search_photos.rb +++ b/app/models/concerns/search_photos.rb @@ -4,26 +4,26 @@ module SearchPhotos extend ActiveSupport::Concern included do - searchkick merge_mappings: true, - mappings: { - properties: { - title: { type: :text }, - created_at: { type: :integer } - } - } + searchkick merge_mappings: true, mappings: { + properties: { + title: { type: :text }, + created_at: { type: :integer } + } + } scope :search_import, -> { includes(:owner, :crops, :plantings, :harvests, :seeds, :posts) } def search_data { - id: id, - title: title, - crops: photo_associations.map(&:crop_id), - owner_id: owner_id, + id: id, + title: title, + crops: photo_associations.map(&:crop_id), + owner_id: owner_id, owner_login_name: owner.login_name, - thumbnail_url: thumbnail_url, - fullsize_url: fullsize_url, - created_at: created_at.to_i + likes_count: likes_count, + thumbnail_url: thumbnail_url, + fullsize_url: fullsize_url, + created_at: created_at.to_i } end end diff --git a/app/models/concerns/search_plantings.rb b/app/models/concerns/search_plantings.rb index cc2e039a6..bb29e07f9 100644 --- a/app/models/concerns/search_plantings.rb +++ b/app/models/concerns/search_plantings.rb @@ -20,24 +20,33 @@ module SearchPlantings { slug: slug, active: active, - crop_id: crop_id, - crop_name: crop.name, - crop_slug: crop.slug, finished: finished?, - harvests_count: harvests_count, has_photos: photos.size.positive?, location: location, - owner_id: owner_id, - owner_location: owner_location, - owner_login_name: owner_login_name, - owner_slug: owner_slug, percentage_grown: percentage_grown.to_i, - photos_count: photos.size, planted_at: planted_at, planted_from: planted_from, quantity: quantity, sunniness: sunniness, + + # crops + 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, + + # photos thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, + # counts + photos_count: photos.size, + harvests_count: harvests_count, + + # timestamps created_at: created_at.to_i } end diff --git a/app/models/concerns/search_seeds.rb b/app/models/concerns/search_seeds.rb index 326ce2b35..23f55e140 100644 --- a/app/models/concerns/search_seeds.rb +++ b/app/models/concerns/search_seeds.rb @@ -18,27 +18,38 @@ module SearchSeeds def search_data { slug: slug, - crop_id: crop_id, - crop_name: crop.name, - crop_slug: crop.slug, finished: finished?, gmo: gmo, - has_photos: photos.size.positive?, active: active, heirloom: heirloom, location: owner.location, organic: organic, + quantity: quantity, + plant_before: plant_before&.to_s(:ymd), + tradable_to: tradable_to, + tradable: tradable?, + + # crop + 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, + + # planting parent_planting: parent_planting, + + # counts photos_count: photos.size, - plant_before: plant_before&.to_s(:ymd), - quantity: quantity, + + # photo + has_photos: photos.size.positive?, thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, - tradable_to: tradable_to, - tradable: tradable?, + created_at: created_at.to_i } end diff --git a/app/models/planting.rb b/app/models/planting.rb index 9f6b3949e..9dcad1fca 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -59,6 +59,7 @@ class Planting < ApplicationRecord delegate :name, :slug, :en_wikipedia_url, :default_scientific_name, :plantings_count, to: :crop, prefix: true delegate :login_name, :slug, :location, to: :owner, prefix: true + delegate :slug, to: :planting, prefix: true delegate :annual?, :perennial?, :svg_icon, to: :crop delegate :location, :longitude, :latitude, to: :garden diff --git a/db/schema.rb b/db/schema.rb index 068d4ff5b..ed75b6452 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,10 +10,8 @@ # # It's strongly recommended that you check this file into your version control system. - ActiveRecord::Schema.define(version: 2019_12_26_051019) do - # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From a3215d25554c785c9df3b6686d798a69a2aa0cdd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 31 Dec 2019 14:47:15 +1300 Subject: [PATCH 140/188] Rubocop fixes --- db/migrate/20180213005731_seed_usage.rb | 12 +++--- db/migrate/20191119030244_cms_tags.rb | 4 +- ...191226024813_crop_harvest_counter_cache.rb | 3 -- spec/factories/crop.rb | 6 +++ spec/factories/harvests.rb | 6 +++ spec/factories/photos.rb | 6 +++ spec/factories/planting.rb | 6 +++ spec/factories/seeds.rb | 6 +++ spec/models/photo_spec.rb | 14 +++++++ spec/spec_helper.rb | 37 ++++++------------- 10 files changed, 65 insertions(+), 35 deletions(-) diff --git a/db/migrate/20180213005731_seed_usage.rb b/db/migrate/20180213005731_seed_usage.rb index ddb2c2378..03240e098 100644 --- a/db/migrate/20180213005731_seed_usage.rb +++ b/db/migrate/20180213005731_seed_usage.rb @@ -9,16 +9,16 @@ class SeedUsage < ActiveRecord::Migration[4.2] # plantings can be grown from a seed add_column(:plantings, :parent_seed_id, :integer) add_foreign_key(:plantings, :seeds, - column: :parent_seed_id, + column: :parent_seed_id, primary_key: :id, - name: :parent_seed, - on_delete: :nullify) + name: :parent_seed, + on_delete: :nullify) # seeds can be harvest from planting add_column(:seeds, :parent_planting_id, :integer) add_foreign_key(:seeds, :plantings, - column: :parent_planting_id, + column: :parent_planting_id, primary_key: :id, - name: :parent_planting, - on_delete: :nullify) + name: :parent_planting, + on_delete: :nullify) end end diff --git a/db/migrate/20191119030244_cms_tags.rb b/db/migrate/20191119030244_cms_tags.rb index 918f6a325..acaba82c8 100644 --- a/db/migrate/20191119030244_cms_tags.rb +++ b/db/migrate/20191119030244_cms_tags.rb @@ -30,7 +30,9 @@ class CmsTags < ActiveRecord::Migration[5.2] layout.content = layout.content.gsub(/\{\{ ?cms:(\w+):([\w]+):([^:]*) ?\}\}/, '{{ cms:\1 \2, "\3" }}') if layout.content.is_a? String layout.content = layout.content.gsub(/cms:rich_text/, 'cms:wysiwyg') if layout.content.is_a? String layout.content = layout.content.gsub(/cms:integer/, 'cms:number') if layout.content.is_a? String - layout.content = layout.content.gsub(/cms: string/, 'cms:text') if layout.content.is_a? String # probably a result of goofing one of the more general regexps + if layout.content.is_a? String + layout.content = layout.content.gsub(/cms: string/, 'cms:text') + end # probably a result of goofing one of the more general regexps if layout.content.is_a? String layout.content = layout.content.gsub(%r{\{\{ ?cms:page_file ([\w/]+) ?\}\}}, '{{ cms:file \1, render: false }}') end diff --git a/db/migrate/20191226024813_crop_harvest_counter_cache.rb b/db/migrate/20191226024813_crop_harvest_counter_cache.rb index 6441ed469..b942bfde3 100644 --- a/db/migrate/20191226024813_crop_harvest_counter_cache.rb +++ b/db/migrate/20191226024813_crop_harvest_counter_cache.rb @@ -1,8 +1,5 @@ - - # frozen_string_literal: true - class CropHarvestCounterCache < ActiveRecord::Migration[5.2] def change change_table :crops do |t| diff --git a/spec/factories/crop.rb b/spec/factories/crop.rb index 72e5d1e72..c8a8d5f9d 100644 --- a/spec/factories/crop.rb +++ b/spec/factories/crop.rb @@ -86,5 +86,11 @@ FactoryBot.define do approval_status { "rejected" } reason_for_rejection { "Totally fake" } end + + trait :reindex do + after(:create) do |crop, _evaluator| + crop.reindex(refresh: true) + end + end end end diff --git a/spec/factories/harvests.rb b/spec/factories/harvests.rb index d4bd0f18d..cc116b627 100644 --- a/spec/factories/harvests.rb +++ b/spec/factories/harvests.rb @@ -27,4 +27,10 @@ FactoryBot.define do trait :no_description do description { "" } end + + trait :reindex do + after(:create) do |harvest, _evaluator| + harvest.reindex(refresh: true) + end + end end diff --git a/spec/factories/photos.rb b/spec/factories/photos.rb index 405edfd7c..f1dc8839a 100644 --- a/spec/factories/photos.rb +++ b/spec/factories/photos.rb @@ -18,5 +18,11 @@ FactoryBot.define do license_name { "All rights reserved" } license_url { nil } end + + trait :reindex do + after(:create) do |photo, _evaluator| + photo.reindex(refresh: true) + end + end end end diff --git a/spec/factories/planting.rb b/spec/factories/planting.rb index cfdcd2b1c..d45afdef6 100644 --- a/spec/factories/planting.rb +++ b/spec/factories/planting.rb @@ -61,5 +61,11 @@ FactoryBot.define do crop end end + + trait :reindex do + after(:create) do |planting, _evaluator| + planting.reindex(refresh: true) + end + end end end diff --git a/spec/factories/seeds.rb b/spec/factories/seeds.rb index deafb5302..b71aeaa4b 100644 --- a/spec/factories/seeds.rb +++ b/spec/factories/seeds.rb @@ -31,5 +31,11 @@ FactoryBot.define do factory :untradable_seed do tradable_to { "nowhere" } end + + trait :reindex do + after(:create) do |seed, _evaluator| + seed.reindex(refresh: true) + end + end end end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index b7ca51898..85986c01c 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -190,4 +190,18 @@ describe Photo do it { expect(Photo.by_crop(planting_crop)).to eq([planting_photo]) } it { expect(Photo.by_crop(seed_crop)).to eq([seed_photo]) } end + + describe 'Elastic search indexing', search: true do + describe "finds new photos in search index" do + let!(:photo) { FactoryBot.create :photo, :reindex } + before { Photo.searchkick_index.refresh } + + it "finds just one" do + expect(Photo.search.size).to eq 1 + end + it "finds the matching photo" do + expect(Photo.search.first.id).to eq photo.id + end + end + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8c64b75b7..88eccdc20 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -36,33 +36,20 @@ RSpec.configure do |config| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end - # config.before(:suite) do - # # reindex models - # Crop.searchkick_index.refresh - # Seed.searchkick_index.refresh - # Harvest.searchkick_index.refresh - # Planting.searchkick_index.refresh + config.before(:suite) do + # reindex models + Photo.reindex + Crop.reindex + Harvest.reindex + Planting.reindex - # # and disable callbacks - # Searchkick.disable_callbacks - # end + # and disable callbacks + Searchkick.disable_callbacks + end - # config.around(:each, search: true) do |example| - # Searchkick.callbacks(true) do - # example.run - # end - # end - config.before(:each) do |example| - # Elasticsearch / Searchkick - if example.metadata[:search] - Searchkick.enable_callbacks - Crop.reindex - Photo.reindex - Harvest.reindex - Seed.reindex - Planting.reindex - else - Searchkick.disable_callbacks + config.around(:each, search: true) do |example| + Searchkick.callbacks(true) do + example.run end end From 95654017d17dd72761a661acd856465b2aa76aad Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 31 Dec 2019 14:50:31 +1300 Subject: [PATCH 141/188] added frozen literals --- Guardfile | 2 ++ Rakefile | 2 ++ config.ru | 2 ++ spec/rails_helper.rb | 4 ++-- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Guardfile b/Guardfile index e4197ab07..8e9e7cc88 100644 --- a/Guardfile +++ b/Guardfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + guard :rspec, cmd: 'bundle exec rspec --format documentation', failed_mode: :keep do diff --git a/Rakefile b/Rakefile index 15ae3eb68..88a812821 100755 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,6 @@ #!/usr/bin/env rake +# frozen_string_literal: true + # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. diff --git a/config.ru b/config.ru index bd83b2541..61c04e13f 100644 --- a/config.ru +++ b/config.ru @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 5082ce6ab..24d044f26 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -59,8 +59,8 @@ include Warden::Test::Helpers # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. # -Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } -Dir[Rails.root.join("spec/features/shared_examples/**/*.rb")].each { |f| require f } +Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |f| require f } +Dir[Rails.root.join("spec/features/shared_examples/**/*.rb")].sort.each { |f| require f } # Checks for pending migrations before tests are run. # If you are not using ActiveRecord, you can remove this line. From 676345815c64a5f6497c482b44e7dfd92a4caadc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 31 Dec 2019 21:01:57 +1300 Subject: [PATCH 142/188] tests for photos searching --- app/models/concerns/search_photos.rb | 26 ++--- app/models/crop.rb | 6 +- app/models/photo.rb | 24 +++-- app/models/photo_association.rb | 17 +++- spec/models/photo_spec.rb | 137 +++++++++++++++++++-------- 5 files changed, 143 insertions(+), 67 deletions(-) diff --git a/app/models/concerns/search_photos.rb b/app/models/concerns/search_photos.rb index 04f4b0d2b..5bf48ec67 100644 --- a/app/models/concerns/search_photos.rb +++ b/app/models/concerns/search_photos.rb @@ -11,19 +11,23 @@ module SearchPhotos } } - scope :search_import, -> { includes(:owner, :crops, :plantings, :harvests, :seeds, :posts) } - def search_data { - id: id, - title: title, - crops: photo_associations.map(&:crop_id), - owner_id: owner_id, - owner_login_name: owner.login_name, - likes_count: likes_count, - thumbnail_url: thumbnail_url, - fullsize_url: fullsize_url, - created_at: created_at.to_i + id: id, + title: title, + thumbnail_url: thumbnail_url, + fullsize_url: fullsize_url, + # crops + crops: crops.pluck(:id), + # likes + liked_by_members_names: liked_by_members_names, + # owner + owner_id: owner_id, + owner_login_name: owner.login_name, + # counts + likes_count: likes_count, + + created_at: created_at.to_i } end end diff --git a/app/models/crop.rb b/app/models/crop.rb index d983dff58..c5de8aa2c 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -18,7 +18,7 @@ class Crop < ApplicationRecord has_many :plantings, dependent: :destroy has_many :seeds, dependent: :destroy has_many :harvests, dependent: :destroy - has_many :photo_associations, dependent: :delete_all + has_many :photo_associations, dependent: :delete_all, inverse_of: :crop has_many :photos, through: :photo_associations has_many :plant_parts, -> { joins_members.distinct.order("plant_parts.name") }, through: :harvests has_many :varieties, class_name: 'Crop', foreign_key: 'parent_id', dependent: :nullify, inverse_of: :parent @@ -50,10 +50,10 @@ class Crop < ApplicationRecord ## Wikipedia urls are only necessary when approving a crop validates :en_wikipedia_url, format: { - with: %r{\Ahttps?:\/\/en\.wikipedia\.org\/wiki\/[[:alnum:]%_\.()-]+\z}, + with: %r{\Ahttps?:\/\/en\.wikipedia\.org\/wiki\/[[:alnum:]%_\.()-]+\z}, message: 'is not a valid English Wikipedia URL' }, - if: :approved? + if: :approved? def to_s name diff --git a/app/models/photo.rb b/app/models/photo.rb index 7518cc80d..0c407bc1e 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -8,7 +8,13 @@ class Photo < ApplicationRecord PHOTO_CAPABLE = %w(Garden Planting Harvest Seed Post Crop).freeze has_many :photo_associations, foreign_key: :photo_id, dependent: :delete_all, inverse_of: :photo - has_many :crops, through: :photo_associations, counter_cache: true + + # This doesn't work, ActiveRecord tries to use the polymoriphinc photographable + # relationship instead. + # has_many :crops, through: :photo_associations + def crops + Crop.distinct.joins(:photo_associations).where(photo_associations: { photo: self }) + end validates :fullsize_url, url: true validates :thumbnail_url, url: true @@ -16,8 +22,8 @@ class Photo < ApplicationRecord # creates a relationship for each assignee type PHOTO_CAPABLE.each do |type| has_many type.downcase.pluralize.to_s.to_sym, - through: :photo_associations, - source: :photographable, + through: :photo_associations, + source: :photographable, source_type: type end @@ -36,13 +42,13 @@ class Photo < ApplicationRecord licenses = flickr.photos.licenses.getInfo license = licenses.find { |l| l.id == info.license } { - title: calculate_title(info), - license_name: license.name, - license_url: license.url, + title: calculate_title(info), + license_name: license.name, + license_url: license.url, thumbnail_url: FlickRaw.url_q(info), - fullsize_url: FlickRaw.url_z(info), - link_url: FlickRaw.url_photopage(info), - date_taken: info.dates.taken + fullsize_url: FlickRaw.url_z(info), + link_url: FlickRaw.url_photopage(info), + date_taken: info.dates.taken } end diff --git a/app/models/photo_association.rb b/app/models/photo_association.rb index 647c1bb78..9f92160fb 100644 --- a/app/models/photo_association.rb +++ b/app/models/photo_association.rb @@ -1,20 +1,23 @@ # frozen_string_literal: true class PhotoAssociation < ApplicationRecord - belongs_to :photo, inverse_of: :photo_associations + belongs_to :photo, touch: true + belongs_to :crop, optional: true, touch: true #, counter_cache: true belongs_to :photographable, polymorphic: true, touch: true - belongs_to :crop, optional: true, counter_cache: true validate :photo_and_item_have_same_owner + validate :crop_present ## ## Triggers - before_save :set_crop + before_validation :set_crop def self.item(item_id, item_type) find_by!(photographable_id: item_id, photographable_type: item_type).photographable end + private + def set_crop if %w(Planting Seed Harvest).include?(photographable_type) self.crop_id = photographable.crop_id @@ -23,11 +26,15 @@ class PhotoAssociation < ApplicationRecord end end - private - def photo_and_item_have_same_owner return if photographable_type == 'Crop' errors.add(:photo, "must have same owner as item it links to") unless photographable.owner_id == photo.owner_id end + + def crop_present + if %w(Planting Seed Harvest).include?(photographable_type) + errors.add(:crop_id, "failed to calculate crop") unless crop_id.present? + end + end end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 85986c01c..7eb917f35 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -3,8 +3,7 @@ require 'rails_helper' describe Photo do - let(:photo) { FactoryBot.create(:photo, owner: member) } - let(:old_photo) { FactoryBot.create(:photo, owner: member, created_at: 1.year.ago, date_taken: 2.years.ago) } + let(:photo) { FactoryBot.create(:photo, :reindex, owner: member) } let(:member) { FactoryBot.create(:member) } it_behaves_like "it is likeable" @@ -20,13 +19,14 @@ describe Photo do describe 'to a planting' do before { planting.photos << photo } - it { expect(planting.photos.size).to eq 1 } + it { expect(planting.photos.count).to eq 1 } it { expect(planting.photos.first).to eq photo } # there's only one photo, so that's the default it { expect(planting.default_photo).to eq photo } it { expect(planting.crop.default_photo).to eq photo } describe 'with a second older photo' do + let(:old_photo) { FactoryBot.create(:photo, owner: member, created_at: 1.year.ago, date_taken: 2.years.ago) } # Add an old photo before { planting.photos << old_photo } it { expect(planting.default_photo).to eq photo } @@ -40,28 +40,45 @@ describe Photo do end end - it 'to a harvest' do - harvest.photos << photo - expect(harvest.photos.size).to eq 1 - expect(harvest.photos.first).to eq photo + describe 'to a harvest' do + let(:crop){ harvest.crop } + before { harvest.photos << photo } + + it { expect(harvest.photos).to eq [photo] } + it { expect(harvest.photo_associations.count).to eq 1 } + + # Check the relationship from crop + it { expect(crop.photo_associations.count).to eq 1 } + it { expect(crop.photos.count).to eq 1 } + it { expect(crop.photos).to eq [photo] } + + # Check the relationship from the photo + it { expect(photo.photo_associations.count).to eq 1 } + it { expect(photo.photo_associations.map(&:crop)).to eq [ crop ]} + it { expect(photo.crops.count).to eq 1 } + it { expect(photo.crops).to eq [crop] } end it 'to a seed' do seed.photos << photo - expect(seed.photos.size).to eq 1 - expect(seed.photos.first).to eq photo + expect(seed.photos).to eq [photo] + expect(photo.crops).to eq [seed.crop] + end + + it 'to a planting' do + planting.photos << photo + expect(planting.photos).to eq [photo] + expect(photo.crops).to eq [planting.crop] end it 'to a garden' do garden.photos << photo - expect(garden.photos.size).to eq 1 - expect(garden.photos.first).to eq photo + expect(garden.photos).to eq [photo] end it 'to a post' do post.photos << photo - expect(post.photos.size).to eq 1 - expect(post.photos.first).to eq photo + expect(post.photos).to eq [photo] end end @@ -69,19 +86,19 @@ describe Photo do it 'from a planting' do planting.photos << photo photo.destroy - expect(planting.photos.size).to eq 0 + expect(planting.photos.count).to eq 0 end it 'from a harvest' do harvest.photos << photo photo.destroy - expect(harvest.photos.size).to eq 0 + expect(harvest.photos.count).to eq 0 end it 'from a garden' do garden.photos << photo photo.destroy - expect(garden.photos.size).to eq 0 + expect(garden.photos.count).to eq 0 end it "automatically if unused" do @@ -117,23 +134,23 @@ describe Photo do planting.photos << photo harvest.photos << photo garden.photos << photo - expect(photo.plantings.size).to eq 1 - expect(photo.harvests.size).to eq 1 - expect(photo.gardens.size).to eq 1 + expect(photo.plantings.count).to eq 1 + expect(photo.harvests.count).to eq 1 + expect(photo.gardens.count).to eq 1 planting.destroy # photo is still used by harvest and garden photo.reload - expect(photo.plantings.size).to eq 0 - expect(photo.harvests.size).to eq 1 + expect(photo.plantings.count).to eq 0 + expect(photo.harvests.count).to eq 1 harvest.destroy garden.destroy # photo is now no longer used by anything photo.reload - expect(photo.plantings.size).to eq 0 - expect(photo.harvests.size).to eq 0 - expect(photo.gardens.size).to eq 0 + expect(photo.plantings.count).to eq 0 + expect(photo.harvests.count).to eq 0 + expect(photo.gardens.count).to eq 0 photo.destroy_if_unused expect(-> { photo.reload }).to raise_error ActiveRecord::RecordNotFound end @@ -163,16 +180,16 @@ describe Photo do expect(Photo.joins(:owner).all).not_to include(photo) end - describe 'scopes' do - let(:harvest_crop) { FactoryBot.create :crop } + describe 'assocations' do + let(:harvest_crop) { FactoryBot.create :crop, name: 'harvest_crop' } let!(:harvest) { FactoryBot.create :harvest, owner: member, crop: harvest_crop } let!(:harvest_photo) { FactoryBot.create :photo, owner: member } - let(:planting_crop) { FactoryBot.create :crop } + let(:planting_crop) { FactoryBot.create :crop, name: 'planting_crop' } let!(:planting) { FactoryBot.create :planting, owner: member, crop: planting_crop } let!(:planting_photo) { FactoryBot.create :photo, owner: member } - let(:seed_crop) { FactoryBot.create :crop } + let(:seed_crop) { FactoryBot.create :crop, name: 'seed_crop' } let!(:seed) { FactoryBot.create :seed, owner: member, crop: seed_crop } let!(:seed_photo) { FactoryBot.create :photo, owner: member } @@ -180,28 +197,70 @@ describe Photo do harvest.photos << harvest_photo planting.photos << planting_photo seed.photos << seed_photo + + # harvest_photo.reload + # harvest.reload + # # harvest.reindex + + # planting_photo.reload + # planting.reload + # # planting.reindex + + # seed_photo.reload + # seed.reload + # seed.reindex end - it { expect(Photo.by_model(Harvest)).to eq([harvest_photo]) } - it { expect(Photo.by_model(Planting)).to eq([planting_photo]) } - it { expect(Photo.by_model(Seed)).to eq([seed_photo]) } + describe 'relationships' do + it { expect(seed_photo.crops).to eq [seed_crop] } + it { expect(seed_crop.photos).to eq [seed_photo] } - it { expect(Photo.by_crop(harvest_crop)).to eq([harvest_photo]) } - it { expect(Photo.by_crop(planting_crop)).to eq([planting_photo]) } - it { expect(Photo.by_crop(seed_crop)).to eq([seed_photo]) } + it { expect(harvest_photo.crops).to eq [harvest_crop] } + it { expect(harvest_crop.photos).to eq [harvest_photo] } + + it { expect(planting_photo.crops).to eq [planting_crop] } + it { expect(planting_crop.photos).to eq [planting_photo] } + end + + describe 'scopes' do + it { expect(Photo.by_model(Harvest)).to eq([harvest_photo]) } + it { expect(Photo.by_model(Planting)).to eq([planting_photo]) } + it { expect(Photo.by_model(Seed)).to eq([seed_photo]) } + + it { expect(Photo.by_crop(harvest_crop)).to eq([harvest_photo]) } + it { expect(Photo.by_crop(planting_crop)).to eq([planting_photo]) } + it { expect(Photo.by_crop(seed_crop)).to eq([seed_photo]) } + end end describe 'Elastic search indexing', search: true do - describe "finds new photos in search index" do - let!(:photo) { FactoryBot.create :photo, :reindex } - before { Photo.searchkick_index.refresh } + let!(:planting) { FactoryBot.create(:planting, :reindex, owner: photo.owner) } + let!(:crop) { FactoryBot.create :crop, :reindex } + before do + planting.photos << photo + Photo.reindex + Photo.searchkick_index.refresh + end + + describe "finds all photos in search index" do it "finds just one" do - expect(Photo.search.size).to eq 1 + expect(Photo.search.count).to eq 1 end it "finds the matching photo" do - expect(Photo.search.first.id).to eq photo.id + expect(Photo.search).to include photo end + + it "retrieves crops from ES" do + expect(Photo.search(load: false).first.crops).to eq [planting.crop.id] + end + end + + it "finds photos by owner in search index" do + expect(Photo.search(where: { owner_id: planting.owner_id })).to include photo + end + it "finds photos by crop in search index" do + expect(Photo.search(where: { crops: planting.crop.id })).to include photo end end end From 6bc0aa7194b8e586b59244b0f7e2d24c34f43cc3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 31 Dec 2019 21:03:34 +1300 Subject: [PATCH 143/188] Adding missing frozen literals --- bin/bundle | 2 ++ bin/rails | 2 ++ bin/rake | 2 ++ bin/setup | 2 ++ bin/update | 2 ++ bin/yarn | 2 ++ 6 files changed, 12 insertions(+) diff --git a/bin/bundle b/bin/bundle index f19acf5b5..2dbb71769 100755 --- a/bin/bundle +++ b/bin/bundle @@ -1,3 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails index 073966023..a31728ab9 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index 17240489f..c19995500 100755 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + require_relative '../config/boot' require 'rake' Rake.application.run diff --git a/bin/setup b/bin/setup index 94fd4d797..c2e43ceb2 100755 --- a/bin/setup +++ b/bin/setup @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + require 'fileutils' include FileUtils diff --git a/bin/update b/bin/update index 58bfaed51..313c74b38 100755 --- a/bin/update +++ b/bin/update @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + require 'fileutils' include FileUtils diff --git a/bin/yarn b/bin/yarn index b24854dce..268a9398f 100755 --- a/bin/yarn +++ b/bin/yarn @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + APP_ROOT = File.expand_path('..', __dir__) Dir.chdir(APP_ROOT) do exec "yarnpkg", *ARGV From f76266a71634ff8a2c3e3244869b7d76e2c812eb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 31 Dec 2019 21:46:42 +1300 Subject: [PATCH 144/188] photos controller working with ES --- app/controllers/photos_controller.rb | 16 +++---- spec/controllers/photos_controller_spec.rb | 49 ++++++++++------------ 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index ad64d58f5..322c5a66e 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -16,17 +16,19 @@ class PhotosController < ApplicationController where = {} if params[:crop_slug] @crop = Crop.find params[:crop_slug] - where = { crops: [@crop.id] } + where = { crops: @crop.id } elsif params[:planting_id] @planting = Planting.find params[:planting_id] where = { planting_id: @planting.id } end - @photos = Photo.search(load: false, - boost_by: [:created_at], - where: where, - page: params[:page], - limit: 50) + @photos = Photo.search( + load: false, + boost_by: [:created_at], + where: where, + page: params[:page], + limit: Photo.per_page + ) respond_with(@photos) end @@ -88,7 +90,7 @@ class PhotosController < ApplicationController def find_or_create_photo_from_flickr_photo photo = Photo.find_or_initialize_by( source_id: photo_params[:source_id], - source: 'flickr' + source: 'flickr' ) photo.update(photo_params) photo.owner_id = current_member.id diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index a6680d308..7d318e5f5 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -7,45 +7,42 @@ describe PhotosController, :search do describe 'GET index' do describe 'all photos' do - let!(:photo) { FactoryBot.create :photo } + let!(:photo) { FactoryBot.create :photo, :reindex } before do Photo.searchkick_index.refresh - photo.reindex - sleep 1 get :index end it "finds photos" do - expect(assigns(:photos).size).to eq 1 + expect(assigns(:photos).count).to eq 1 expect(assigns(:photos).first.id).to eq photo.id end end - describe 'crop photos' do - let!(:photo) { FactoryBot.create :photo, owner: member, title: 'no assocations photo' } - let!(:crop_photo) { FactoryBot.create :photo, owner: member, title: 'photos of planting' } - let!(:planting) { FactoryBot.create :planting, crop: crop, owner: member } - let!(:crop) { FactoryBot.create :crop } + 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 } before do planting.photos << crop_photo Photo.searchkick_index.refresh - crop_photo.reload - crop_photo.reindex - # This is terrible, but this is needed for ES to fully index this - sleep 1 - - # all these tests are inline, so we only sleep once get :index, params: { crop_slug: crop.to_param } end - it "find photos by crop" do - expect(Photo.search).to include crop_photo - expect(assigns(:crop)).to eq crop - expect(assigns(:photos).size).to eq 1 - expect(assigns(:photos).first.crops).to include crop.id - expect(assigns(:photos).first.id).to eq crop_photo.id + describe "find photos by crop" do + it "has indexed the photos of this crop" do + expect(Photo.search).to include crop_photo + end + it "assigns crop" do + expect(assigns(:crop)).to eq crop + end + + it { expect(assigns(:photos).size).to eq 1 } + it { expect(assigns(:photos).first.crops).to include crop.id } + it { expect(assigns(:photos).first.id).to eq crop_photo.id } end end end @@ -91,12 +88,12 @@ describe PhotosController, :search do describe "POST create" do before do - Photo.any_instance.stub(:flickr_metadata).and_return(title: "A Heartbreaking work of staggering genius", - license_name: "CC-BY", - license_url: "http://example.com/aybpl", + Photo.any_instance.stub(:flickr_metadata).and_return(title: "A Heartbreaking work of staggering genius", + license_name: "CC-BY", + license_url: "http://example.com/aybpl", thumbnail_url: "http://example.com/thumb.jpg", - fullsize_url: "http://example.com/full.jpg", - link_url: "http://example.com") + fullsize_url: "http://example.com/full.jpg", + link_url: "http://example.com") end let(:member) { FactoryBot.create(:member) } From 54778d988440efd12e54cb94b645a5ce663893d7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 08:38:27 +1300 Subject: [PATCH 145/188] Likes popuplating from elastic, no more extra look ups --- app/assets/javascripts/likes.js | 4 ++-- app/views/photos/_likes.html.haml | 16 +++++++--------- app/views/posts/_likes.html.haml | 12 +++++------- config/routes.rb | 5 ++++- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/likes.js b/app/assets/javascripts/likes.js index 60b3e57e7..801617ff9 100644 --- a/app/assets/javascripts/likes.js +++ b/app/assets/javascripts/likes.js @@ -14,7 +14,7 @@ $(document).ready(function() { } else { likeBadge.removeClass('liked'); likeButton.data('method', 'post'); - likeButton.attr('href', '/likes.json?post_id=' + data.id); + likeButton.attr('href', '/likes.json?type=Post&id=' + data.id); likeButton.text('Like'); } }); @@ -34,7 +34,7 @@ $(document).ready(function() { likeBadge.removeClass('liked'); // Turn the button into an *like* button likeButton.data('method', 'post'); - likeButton.attr('href', '/likes.json?photo_id=' + data.id); + likeButton.attr('href', '/likes.json?type=Photo&id=' + data.id); } }); }); diff --git a/app/views/photos/_likes.html.haml b/app/views/photos/_likes.html.haml index fb0b0e918..d7d2aaf48 100644 --- a/app/views/photos/_likes.html.haml +++ b/app/views/photos/_likes.html.haml @@ -1,14 +1,12 @@ %span.likes - - if member_signed_in? - - if can?(:new, Like) && !photo.liked_by?(current_member) - = link_to likes_path(photo_id: photo.id, format: :json), + - if member_signed_in? && can?(:new, Like) + - if !photo.liked_by_members_names.include?(current_member.login_name) + = link_to likes_path(type: 'Photo', id: photo.id, format: :json), method: :post, remote: true, class: 'photo-like like-btn' do = render 'likes/count', likeable: photo - else - - like = photo.likes.find_by(member: current_member) - - if like && can?(:destroy, like) - = link_to like_path(id: like.id, format: :json), - method: :delete, remote: true, class: 'photo-like like-btn' do - = render 'likes/count', likeable: photo + = link_to likes_path(type: 'Photo', id: photo.id, format: :json), + method: :delete, remote: true, class: 'photo-like like-btn' do + = render 'likes/count', likeable: photo - else - = render 'likes/count', likeable: photo \ No newline at end of file + = render 'likes/count', likeable: photo diff --git a/app/views/posts/_likes.html.haml b/app/views/posts/_likes.html.haml index 18112c308..95c2a8cd1 100644 --- a/app/views/posts/_likes.html.haml +++ b/app/views/posts/_likes.html.haml @@ -1,12 +1,10 @@ -- if member_signed_in? - - if can?(:new, Like) && !post.liked_by?(current_member) - = link_to 'Like', likes_path(post_id: post.id, format: :json), +- if member_signed_in? && can?(:new, Like) + - if !post.liked_by?(current_member) + = link_to 'Like', likes_path(type: 'Post', id: post.id, format: :json), method: :post, remote: true, class: 'post-like btn like-btn' - else - - like = post.likes.find_by(member: current_member) - - if like && can?(:destroy, like) - = link_to 'Unlike', like_path(id: like.id, format: :json), - method: :delete, remote: true, class: 'post-like btn like-btn' + = link_to 'Unlike', likes_path(type: 'Post', id: post.id, format: :json), + method: :delete, remote: true, class: 'post-like btn like-btn' = render 'likes/count', likeable: post diff --git a/config/routes.rb b/config/routes.rb index 5244ed3bc..118bf59ae 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -86,7 +86,10 @@ Rails.application.routes.draw do resources :forums resources :follows, only: %i(create destroy) - resources :likes, only: %i(create destroy) + + post 'likes' => 'likes#create' + delete 'likes' => 'likes#destroy' + resources :timeline resources :members, param: :slug do From e9ff6a438898a0ddeadf902c76ce5b4396c7c948 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 08:39:08 +1300 Subject: [PATCH 146/188] likes in the elastic search index during spec run --- spec/features/likeable_spec.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/spec/features/likeable_spec.rb b/spec/features/likeable_spec.rb index 0b44d3741..bb79fa129 100644 --- a/spec/features/likeable_spec.rb +++ b/spec/features/likeable_spec.rb @@ -2,14 +2,17 @@ require 'rails_helper' -describe 'Likeable', js: true do +describe 'Likeable', :js, search: true do let(:another_member) { FactoryBot.create(:london_member) } - let!(:post) { FactoryBot.create(:post, author: member) } - let!(:photo) { FactoryBot.create(:photo, owner: member) } + let!(:post) { FactoryBot.create(:post, :reindex, author: member) } + let!(:photo) { FactoryBot.create(:photo, :reindex, owner: member) } include_context 'signed in member' + describe 'photos' do - let(:like_count_class) { "#photo-#{photo.id} .like-count" } + def like_count_class + "#photo-#{photo.id} .like-count" + end shared_examples 'photo can be liked' do it 'can be liked' do From de3c4d0f62c3bbae18fe684a19b025134f5508ef Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 08:39:27 +1300 Subject: [PATCH 147/188] likes found in controller by id and type of likeable --- app/controllers/likes_controller.rb | 35 +++++++++++++++-------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index 37d302fcb..6d3293006 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -5,14 +5,23 @@ class LikesController < ApplicationController respond_to :html, :json def create - @like = Like.new(member: current_member, likeable: find_likeable) + @like = Like.new( + member: current_member, + likeable_type: params[:type], + likeable_id: params[:id] + ) return failed(@like, message: 'Unable to like') unless @like.likeable && @like.save success(@like, liked_by_member: true, status_code: :created) end def destroy - @like = Like.find_by(id: params[:id], member: current_member) + @like = Like.find_by( + likeable_type: params[:type], + likeable_id: params[:id], + member: current_member + ) + return failed(@like, message: 'Unable to unlike') unless @like&.destroy success(@like, liked_by_member: false, status_code: :ok) @@ -20,21 +29,12 @@ class LikesController < ApplicationController private - def find_likeable - if params[:post_id] - Post.find(params[:post_id]) - elsif params[:photo_id] - Photo.find(params[:photo_id]) - end - end - def render_json(like, liked_by_member: true) { - id: like.likeable.id, - like_count: like.likeable.likes.count, + id: like.likeable.id, + like_count: like.likeable.likes.count, liked_by_member: liked_by_member, - description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like"), - url: like_path(like, format: :json) + description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like") } end @@ -42,9 +42,10 @@ class LikesController < ApplicationController respond_to do |format| format.html { redirect_to like.likeable } format.json do - render(json: render_json(like, - liked_by_member: liked_by_member), - status: status_code) + render(json: render_json( + like, + liked_by_member: liked_by_member + ), status: status_code) end end end From 63ea6752fa12e1c2fc8ee961743d085a1d84c260 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 08:40:04 +1300 Subject: [PATCH 148/188] likes reading from hash from elastic --- app/models/concerns/likeable.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/likeable.rb b/app/models/concerns/likeable.rb index 911317a6e..c1927a126 100644 --- a/app/models/concerns/likeable.rb +++ b/app/models/concerns/likeable.rb @@ -9,6 +9,10 @@ module Likeable end def liked_by?(member) - member && members.include?(member) + liked_by_members_names.include?(member.login_name) + end + + def liked_by_members_names + Member.where(id: likes.pluck(:member_id)).pluck(:login_name) end end From 80038c7f42caae10034e28b2b46eca5beea23f53 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 08:40:43 +1300 Subject: [PATCH 149/188] set which parts of crop are searchable --- app/models/concerns/search_crops.rb | 35 +++++++++++++++-------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/app/models/concerns/search_crops.rb b/app/models/concerns/search_crops.rb index 347fd02be..f388ae814 100644 --- a/app/models/concerns/search_crops.rb +++ b/app/models/concerns/search_crops.rb @@ -6,15 +6,16 @@ module SearchCrops included do #################################### # Elastic search configuration - searchkick word_start: %i(name description alternate_names scientific_names), + searchkick word_start: %i(name description alternate_names scientific_names), case_sensitive: false, + searchable: [:name, :descriptions, :alternate_names, :scientific_names], merge_mappings: true, - mappings: { + mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, plantings_count: { type: :integer }, - harvests_count: { type: :integer }, - photos_count: { type: :integer } + harvests_count: { type: :integer }, + photos_count: { type: :integer } } } @@ -27,21 +28,21 @@ module SearchCrops def search_data { - name: name, - description: description, - slug: slug, - alternate_names: alternate_names.pluck(:name), + name: name, + description: description, + slug: slug, + alternate_names: alternate_names.pluck(:name), scientific_names: scientific_names.pluck(:name), - photos_count: photo_associations_count, + photos_count: photo_associations_count, # boost the crops that are planted the most - plantings_count: plantings_count, - harvests_count: harvests_count, + plantings_count: plantings_count, + harvests_count: harvests_count, # boost this crop for these members - planters_ids: plantings.pluck(:owner_id), - has_photos: photos.size.positive?, - thumbnail_url: thumbnail_url, - scientific_name: default_scientific_name&.name, - created_at: created_at.to_i + planters_ids: plantings.pluck(:owner_id), + has_photos: photos.size.positive?, + thumbnail_url: thumbnail_url, + scientific_name: default_scientific_name&.name, + created_at: created_at.to_i } end end From 36875b620c2da8fd0454af78079b641dcbe12639 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 08:41:00 +1300 Subject: [PATCH 150/188] harvest search, fixed error when some data not set on model --- app/models/concerns/search_harvests.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/concerns/search_harvests.rb b/app/models/concerns/search_harvests.rb index a6d4c4d70..9c4e8892a 100644 --- a/app/models/concerns/search_harvests.rb +++ b/app/models/concerns/search_harvests.rb @@ -29,18 +29,18 @@ module SearchHarvests owner_id: owner_id, owner_login_name: owner_login_name, owner_slug: owner_slug, - plant_part_name: plant_part_name, + plant_part_name: plant_part&.name, - #planting + # planting planting_id: planting_id, - planting_slug: planting_slug, + planting_slug: planting&.slug, - #photo + # photo has_photos: photos.size.positive?, thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, # counts - harvests_count: harvests_count, + # harvests_count: harvests_count, photos_count: photos.count, # timestamps From e24ef32fe6a37c61c3269f8d60f3bd82be5827ad Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 08:41:34 +1300 Subject: [PATCH 151/188] like spec, don't make so many photso --- spec/models/like_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/models/like_spec.rb b/spec/models/like_spec.rb index aeb5797e3..bd012ae42 100644 --- a/spec/models/like_spec.rb +++ b/spec/models/like_spec.rb @@ -5,6 +5,7 @@ require 'rails_helper' describe 'like' do let(:member) { FactoryBot.create(:member) } let(:post) { FactoryBot.create(:post) } + let(:photo) { FactoryBot.create :photo } context 'existing like' do before do @@ -61,4 +62,14 @@ describe 'like' do 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) + 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) + expect(photo.liked_by_members_names).to eq [member.login_name] + end end From b2738afdc2d130661fb1ceb132d3df100bdccee6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 08:42:18 +1300 Subject: [PATCH 152/188] fake reindexer on posts, so it doesn't throw errors --- app/models/post.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 739404228..e5a84c82e 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -57,7 +57,7 @@ class Post < ApplicationRecord subject end - def reindex; end + def reindex(refresh: false); end private @@ -91,9 +91,9 @@ class Post < ApplicationRecord Notification.create( recipient_id: recipient_id, - sender_id: sender, - subject: "#{author} mentioned you in their post #{subject}", - body: body + sender_id: sender, + subject: "#{author} mentioned you in their post #{subject}", + body: body ) end end From c4d02edbd1845b5a684d2e13b7012ca8fb04ffe7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 09:24:24 +1300 Subject: [PATCH 153/188] force reindex after a like --- app/controllers/likes_controller.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index 6d3293006..953baac35 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -10,9 +10,12 @@ class LikesController < ApplicationController likeable_type: params[:type], likeable_id: params[:id] ) - return failed(@like, message: 'Unable to like') unless @like.likeable && @like.save - - success(@like, liked_by_member: true, status_code: :created) + if @like.likeable && @like.save + @like.likeable.reindex(refresh: true) + success(@like, liked_by_member: true, status_code: :created) + else + failed(@like, message: 'Unable to like') + end end def destroy @@ -22,9 +25,12 @@ class LikesController < ApplicationController member: current_member ) - return failed(@like, message: 'Unable to unlike') unless @like&.destroy - - success(@like, liked_by_member: false, status_code: :ok) + if @like&.destroy + @like.likeable.reindex(refresh: true) + success(@like, liked_by_member: false, status_code: :ok) + else + failed(@like, message: 'Unable to unlike') + end end private From 6e81f2966de8b63fc57dbd173e7f4356b7a09d97 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 09:24:47 +1300 Subject: [PATCH 154/188] fixed colouring of likes button --- app/views/likes/_count.haml | 2 +- app/views/photos/_likes.html.haml | 6 +++--- app/views/posts/_likes.html.haml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/likes/_count.haml b/app/views/likes/_count.haml index 79fece151..61920e259 100644 --- a/app/views/likes/_count.haml +++ b/app/views/likes/_count.haml @@ -1,4 +1,4 @@ -%span.badge.like-badge{class: (likeable.liked_by?(current_member)) ? 'liked' : ''} +%span.badge.like-badge{class: liked ? 'liked' : ''} = like_icon   %span.like-count= likeable.likes_count diff --git a/app/views/photos/_likes.html.haml b/app/views/photos/_likes.html.haml index d7d2aaf48..93aaede82 100644 --- a/app/views/photos/_likes.html.haml +++ b/app/views/photos/_likes.html.haml @@ -2,11 +2,11 @@ - if member_signed_in? && can?(:new, Like) - if !photo.liked_by_members_names.include?(current_member.login_name) = link_to likes_path(type: 'Photo', id: photo.id, format: :json), - method: :post, remote: true, class: 'photo-like like-btn' do - = render 'likes/count', likeable: photo + method: :post, remote: true, class: 'photo-like like-btn ' do + = render 'likes/count', likeable: photo, liked: false - else = link_to likes_path(type: 'Photo', id: photo.id, format: :json), method: :delete, remote: true, class: 'photo-like like-btn' do - = render 'likes/count', likeable: photo + = render 'likes/count', likeable: photo, liked: true - else = render 'likes/count', likeable: photo diff --git a/app/views/posts/_likes.html.haml b/app/views/posts/_likes.html.haml index 95c2a8cd1..fe0d0c790 100644 --- a/app/views/posts/_likes.html.haml +++ b/app/views/posts/_likes.html.haml @@ -7,4 +7,4 @@ = link_to 'Unlike', likes_path(type: 'Post', id: post.id, format: :json), method: :delete, remote: true, class: 'post-like btn like-btn' -= render 'likes/count', likeable: post += render 'likes/count', likeable: post, liked: post.liked_by?(current_member) From d541a4ea0a6faaf2dee5433c4195cfac85a195de Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 09:24:59 +1300 Subject: [PATCH 155/188] another frozen literal --- script/rails | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script/rails b/script/rails index 754b05caa..bb6f9c879 100755 --- a/script/rails +++ b/script/rails @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + # This command will automatically be run when you run "rails" # with Rails 3 gems installed from the root of your application. From 76e649a0a8feae85ddd7f929cd67221f1d350114 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 09:26:54 +1300 Subject: [PATCH 156/188] update likes controller spec for new params --- spec/controllers/likes_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb index 985678278..cc1bf9ba5 100644 --- a/spec/controllers/likes_controller_spec.rb +++ b/spec/controllers/likes_controller_spec.rb @@ -10,7 +10,7 @@ describe LikesController do before { sign_in member } describe "POST create" do - before { post :create, params: { post_id: blogpost.id, format: :json } } + before { post :create, params: { type: 'Post', id: blogpost.id, format: :json } } it { expect(response.content_type).to eq "application/json" } @@ -27,7 +27,7 @@ describe LikesController do end describe "DELETE destroy" do - before { delete :destroy, params: { id: like.id, format: :json } } + before { delete :destroy, params: { type: like.likeable_type, id: like.likeable_id, format: :json } } it { expect(response.content_type).to eq "application/json" } From 41c90acbbcba7391c23b2f6715d65331c4a79e62 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 11:43:59 +1300 Subject: [PATCH 157/188] added missing `liked` flag to photos/card --- app/views/photos/_likes.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/photos/_likes.html.haml b/app/views/photos/_likes.html.haml index 93aaede82..4268e05cf 100644 --- a/app/views/photos/_likes.html.haml +++ b/app/views/photos/_likes.html.haml @@ -9,4 +9,5 @@ method: :delete, remote: true, class: 'photo-like like-btn' do = render 'likes/count', likeable: photo, liked: true - else - = render 'likes/count', likeable: photo + = render 'likes/count', likeable: photo, liked: member_signed_in? && photo.liked_by_members_names.include?(current_member.login_name) + From d46883f39b4228ff9ddd4e4d4c1c9fabbf9c622c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 12:32:23 +1300 Subject: [PATCH 158/188] don't query for photos that we never read --- app/controllers/crops_controller.rb | 16 ++++++++-------- app/services/crop_search_service.rb | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index 5d520b3e1..baf56aa1a 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -4,7 +4,7 @@ require 'will_paginate/array' class CropsController < ApplicationController before_action :authenticate_member!, except: %i(index hierarchy search show) - load_and_authorize_resource + load_and_authorize_resource id_param: :slug skip_authorize_resource only: %i(hierarchy search) respond_to :html, :json, :rss, :csv, :svg responders :flash @@ -54,19 +54,19 @@ class CropsController < ApplicationController def search @term = params[:term] - @crops = CropSearchService.search( - @term, page: params[:page], - per_page: 36, - current_member: current_member - ) + @crops = CropSearchService.search(@term, + page: params[:page], + per_page: Crop.per_page, + current_member: current_member) respond_with @crops end def show - @crop = Crop.includes(:scientific_names, :alternate_names, :parent, :varieties).find_by!(slug: params[:slug]) + @crop = Crop.includes( + :scientific_names, :alternate_names, :parent, :varieties + ).find_by!(slug: params[:slug]) respond_to do |format| format.html do - @photos = Photo.by_crop(@crop) @posts = @crop.posts.order(created_at: :desc).paginate(page: params[:page]) @companions = @crop.companions.approved end diff --git a/app/services/crop_search_service.rb b/app/services/crop_search_service.rb index 274d5a3c0..420dede00 100644 --- a/app/services/crop_search_service.rb +++ b/app/services/crop_search_service.rb @@ -4,40 +4,40 @@ class CropSearchService # Crop.search(string) def self.search(query, page: 1, per_page: 12, current_member: nil) search_params = { - page: page, - per_page: per_page, - fields: %i(name^5 alternate_names scientific_names), - match: :word_start, - boost_by: [:plantings_count], - includes: %i(scientific_names alternate_names), + page: page, + per_page: per_page, + fields: %i(name^5 alternate_names scientific_names), + match: :word_start, + boost_by: [:plantings_count], + includes: %i(scientific_names alternate_names), misspellings: { edit_distance: 2 } } # prioritise crops the member has planted search_params[:boost_where] = { planters_ids: current_member.id } if current_member - Crop.search(query, search_params) + Crop.search(query, search_params, load: false) end def self.random_with_photos(limit) body = { "query": { "function_score": { - "query": { "query_string": { "query": 'has_photos:true' } }, + "query": { "query_string": { "query": 'has_photos:true' } }, "random_score": { "seed": DateTime.now.to_i } } } } Crop.search( limit: limit, - load: false, - body: body + load: false, + body: body ) end def self.recent(limit) Crop.search( - limit: limit, - load: false, + limit: limit, + load: false, boost_by: { created_at: { factor: 100 } } # default factor is 1 ) end From 8a1b8be0efb289f98e16050aeea7835c000df757 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 13:47:25 +1300 Subject: [PATCH 159/188] Load crops from search, without hitting the database --- app/services/crop_search_service.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/services/crop_search_service.rb b/app/services/crop_search_service.rb index 420dede00..85ced41d5 100644 --- a/app/services/crop_search_service.rb +++ b/app/services/crop_search_service.rb @@ -10,12 +10,13 @@ class CropSearchService match: :word_start, boost_by: [:plantings_count], includes: %i(scientific_names alternate_names), - misspellings: { edit_distance: 2 } + misspellings: { edit_distance: 2 }, + load: false } # prioritise crops the member has planted search_params[:boost_where] = { planters_ids: current_member.id } if current_member - Crop.search(query, search_params, load: false) + Crop.search(query, search_params) end def self.random_with_photos(limit) From 139574c9c000a4d84376333511cc965ebb50b8f1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 14:14:56 +1300 Subject: [PATCH 160/188] displays photos without hitting the database --- app/models/crop.rb | 6 +++++- app/views/crops/_photos.html.haml | 2 +- app/views/crops/show.html.haml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/crop.rb b/app/models/crop.rb index c5de8aa2c..2a2b1fe95 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -18,7 +18,7 @@ class Crop < ApplicationRecord has_many :plantings, dependent: :destroy has_many :seeds, dependent: :destroy has_many :harvests, dependent: :destroy - has_many :photo_associations, dependent: :delete_all, inverse_of: :crop + has_many :photo_associations, dependent: :delete_all, inverse_of: :crop, counter_cache: true has_many :photos, through: :photo_associations has_many :plant_parts, -> { joins_members.distinct.order("plant_parts.name") }, through: :harvests has_many :varieties, class_name: 'Crop', foreign_key: 'parent_id', dependent: :nullify, inverse_of: :parent @@ -63,6 +63,10 @@ class Crop < ApplicationRecord slug end + def photos_count + photo_associations_count + end + def default_scientific_name scientific_names.first end diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index ba27113f6..471b9a01f 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -1,4 +1,4 @@ -- if photos.size.positive? +- if crop.photos_count.positive? %h2 #{photo_icon} Photos - [Crop, Planting, Harvest, Seed].each do |model_name| - if photos.by_model(model_name).size.positive? diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 7acefc6bb..f4dd34744 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -32,7 +32,7 @@ %section.photos = cute_icon - = render 'crops/photos', photos: @photos, crop: @crop + = render 'crops/photos', crop: @crop - if @crop.plantings.any? %section.charts From 6017c04b5f422b65252ca0e8088d3b239bb3c2a8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 1 Jan 2020 15:54:52 +1300 Subject: [PATCH 161/188] don't check if post is liked by member, unless the member is signed in --- app/views/posts/_likes.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/posts/_likes.html.haml b/app/views/posts/_likes.html.haml index fe0d0c790..7c00d1bfd 100644 --- a/app/views/posts/_likes.html.haml +++ b/app/views/posts/_likes.html.haml @@ -7,4 +7,4 @@ = link_to 'Unlike', likes_path(type: 'Post', id: post.id, format: :json), method: :delete, remote: true, class: 'post-like btn like-btn' -= render 'likes/count', likeable: post, liked: post.liked_by?(current_member) += render 'likes/count', likeable: post, liked: member_signed_in? && post.liked_by?(current_member) From ff883db27921606f27a5655955d8829784d5a132 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 2 Jan 2020 20:23:13 +1300 Subject: [PATCH 162/188] Revert "displays photos without hitting the database" This reverts commit 139574c9c000a4d84376333511cc965ebb50b8f1. --- app/models/crop.rb | 6 +----- app/views/crops/_photos.html.haml | 2 +- app/views/crops/show.html.haml | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/models/crop.rb b/app/models/crop.rb index 2a2b1fe95..c5de8aa2c 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -18,7 +18,7 @@ class Crop < ApplicationRecord has_many :plantings, dependent: :destroy has_many :seeds, dependent: :destroy has_many :harvests, dependent: :destroy - has_many :photo_associations, dependent: :delete_all, inverse_of: :crop, counter_cache: true + has_many :photo_associations, dependent: :delete_all, inverse_of: :crop has_many :photos, through: :photo_associations has_many :plant_parts, -> { joins_members.distinct.order("plant_parts.name") }, through: :harvests has_many :varieties, class_name: 'Crop', foreign_key: 'parent_id', dependent: :nullify, inverse_of: :parent @@ -63,10 +63,6 @@ class Crop < ApplicationRecord slug end - def photos_count - photo_associations_count - end - def default_scientific_name scientific_names.first end diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index 471b9a01f..ba27113f6 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -1,4 +1,4 @@ -- if crop.photos_count.positive? +- if photos.size.positive? %h2 #{photo_icon} Photos - [Crop, Planting, Harvest, Seed].each do |model_name| - if photos.by_model(model_name).size.positive? diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index f4dd34744..7acefc6bb 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -32,7 +32,7 @@ %section.photos = cute_icon - = render 'crops/photos', crop: @crop + = render 'crops/photos', photos: @photos, crop: @crop - if @crop.plantings.any? %section.charts From f27ac12563c50ffcb5a69a2e77a7c853fd7e68e6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 2 Jan 2020 20:29:41 +1300 Subject: [PATCH 163/188] don't pass photos to crops/_photos --- app/views/crops/_photos.html.haml | 6 +++--- app/views/crops/show.html.haml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index ba27113f6..207974b0a 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -1,7 +1,7 @@ -- if photos.size.positive? +- if crop.photo_associations_count.positive? %h2 #{photo_icon} Photos - [Crop, Planting, Harvest, Seed].each do |model_name| - - if photos.by_model(model_name).size.positive? + - if crop.photos.by_model(model_name).size.positive? %h3 #{@crop.name.capitalize} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} - = render 'photos/gallery', photos: photos.by_model(model_name).includes(:owner).order(likes_count: :desc).limit(5) + = render 'photos/gallery', photos: crop.photos.by_model(model_name).includes(:owner).order(likes_count: :desc).limit(5) = link_to 'more photos ยป', crop_photos_path(@crop), class: 'btn' diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 7acefc6bb..f4dd34744 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -32,7 +32,7 @@ %section.photos = cute_icon - = render 'crops/photos', photos: @photos, crop: @crop + = render 'crops/photos', crop: @crop - if @crop.plantings.any? %section.charts From d757ec4fae558b2e1f143f5b25581b5c2ebab29a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 2 Jan 2020 21:06:27 +1300 Subject: [PATCH 164/188] Reindex crops, in crop browse feature spec --- spec/features/crops/browse_crops_spec.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb index 07a0f5a4a..d44b42820 100644 --- a/spec/features/crops/browse_crops_spec.rb +++ b/spec/features/crops/browse_crops_spec.rb @@ -3,13 +3,16 @@ require 'rails_helper' describe "browse crops", :search do - let!(:tomato) { FactoryBot.create :tomato } - let!(:maize) { FactoryBot.create :maize } - let!(:pending_crop) { FactoryBot.create :crop_request } - let!(:rejected_crop) { FactoryBot.create :rejected_crop } + let!(:tomato) { FactoryBot.create :tomato, :reindex } + let!(:maize) { FactoryBot.create :maize, :reindex } + let!(:pending_crop) { FactoryBot.create :crop_request, :reindex } + let!(:rejected_crop) { FactoryBot.create :rejected_crop, :reindex } shared_examples 'shows crops' do - before { visit crops_path } + before do + Crop.reindex + visit crops_path + end it "has a form for sorting by" do expect(page).to have_css "select#sort" From 2e8625d6ff8378fff76ad634f728051f1c1dfe48 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 2 Jan 2020 21:10:35 +1300 Subject: [PATCH 165/188] Reindex harvests before harvest feature spec --- spec/features/harvests/browse_harvests_spec.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spec/features/harvests/browse_harvests_spec.rb b/spec/features/harvests/browse_harvests_spec.rb index a44672629..16b967f50 100644 --- a/spec/features/harvests/browse_harvests_spec.rb +++ b/spec/features/harvests/browse_harvests_spec.rb @@ -11,9 +11,12 @@ describe "browse harvests", :search do include_context 'signed in member' describe 'blank optional fields' do - let!(:harvest) { create :harvest, :no_description } + let!(:harvest) { create :harvest, :no_description, :reindex } - before { visit harvests_path } + before do + Harvest.reindex + visit harvests_path + end it 'read more' do expect(subject).not_to have_link "Read more" @@ -21,9 +24,12 @@ describe "browse harvests", :search do end describe "filled in optional fields" do - let!(:harvest) { create :harvest, :long_description } + let!(:harvest) { create :harvest, :long_description, :reindex } - before { visit harvests_path } + before do + Harvest.reindex + visit harvests_path + end it 'links to #show' do expect(subject).to have_link harvest.crop.name, href: harvest_path(harvest) From 7e30b6b6e041bac78950f5703cbff7debe3cc8f0 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Fri, 3 Jan 2020 11:28:51 +0000 Subject: [PATCH 166/188] [CodeFactor] Apply fixes --- app/controllers/crops_controller.rb | 14 ++--- app/controllers/harvests_controller.rb | 8 +-- app/controllers/likes_controller.rb | 14 ++--- app/controllers/photos_controller.rb | 10 ++-- app/controllers/plantings_controller.rb | 14 ++--- app/models/concerns/search_crops.rb | 36 ++++++------- app/models/concerns/search_harvests.rb | 42 +++++++-------- app/models/concerns/search_photos.rb | 20 +++---- app/models/concerns/search_plantings.rb | 50 ++++++++--------- app/models/concerns/search_seeds.rb | 54 +++++++++---------- app/models/crop.rb | 4 +- app/models/harvest.rb | 18 +++---- app/models/photo.rb | 16 +++--- app/models/photo_association.rb | 4 +- app/models/post.rb | 6 +-- app/services/crop_search_service.rb | 22 ++++---- db/migrate/20180213005731_seed_usage.rb | 12 ++--- spec/controllers/harvests_controller_spec.rb | 8 +-- spec/controllers/photos_controller_spec.rb | 10 ++-- spec/controllers/plantings_controller_spec.rb | 2 +- spec/features/crops/browse_crops_spec.rb | 2 +- spec/models/photo_spec.rb | 4 +- spec/views/plantings/index.html.haml_spec.rb | 22 ++++---- 23 files changed, 196 insertions(+), 196 deletions(-) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index baf56aa1a..d915de921 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -12,9 +12,9 @@ class CropsController < ApplicationController def index @sort = params[:sort] @crops = Crop.search('*', boost_by: %i(plantings_count harvests_count), - limit: 100, - page: params[:page], - load: false) + limit: 100, + page: params[:page], + load: false) @num_requested_crops = requested_crops.size if current_member @filename = filename respond_with @crops @@ -55,8 +55,8 @@ class CropsController < ApplicationController @term = params[:term] @crops = CropSearchService.search(@term, - page: params[:page], - per_page: Crop.per_page, + page: params[:page], + per_page: Crop.per_page, current_member: current_member) respond_with @crops end @@ -207,13 +207,13 @@ class CropsController < ApplicationController def crop_json_fields { include: { - plantings: { + plantings: { include: { owner: { only: %i(id login_name location latitude longitude) } } }, scientific_names: { only: [:name] }, - alternate_names: { only: [:name] } + alternate_names: { only: [:name] } } } end diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index 67dbe5528..f6dabd566 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -20,10 +20,10 @@ class HarvestsController < DataController where['planting_id'] = @planting.id end - @harvests = Harvest.search('*', where: where, - limit: 100, - page: params[:page], - load: false, + @harvests = Harvest.search('*', where: where, + limit: 100, + page: params[:page], + load: false, boost_by: [:created_at]) @filename = csv_filename diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index 953baac35..ffb0604f6 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -6,9 +6,9 @@ class LikesController < ApplicationController def create @like = Like.new( - member: current_member, + member: current_member, likeable_type: params[:type], - likeable_id: params[:id] + likeable_id: params[:id] ) if @like.likeable && @like.save @like.likeable.reindex(refresh: true) @@ -21,8 +21,8 @@ class LikesController < ApplicationController def destroy @like = Like.find_by( likeable_type: params[:type], - likeable_id: params[:id], - member: current_member + likeable_id: params[:id], + member: current_member ) if @like&.destroy @@ -37,10 +37,10 @@ class LikesController < ApplicationController def render_json(like, liked_by_member: true) { - id: like.likeable.id, - like_count: like.likeable.likes.count, + id: like.likeable.id, + like_count: like.likeable.likes.count, liked_by_member: liked_by_member, - description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like") + description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like") } end diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 322c5a66e..e117bebf0 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -23,11 +23,11 @@ class PhotosController < ApplicationController end @photos = Photo.search( - load: false, + load: false, boost_by: [:created_at], - where: where, - page: params[:page], - limit: Photo.per_page + where: where, + page: params[:page], + limit: Photo.per_page ) respond_with(@photos) end @@ -90,7 +90,7 @@ class PhotosController < ApplicationController def find_or_create_photo_from_flickr_photo photo = Photo.find_or_initialize_by( source_id: photo_params[:source_id], - source: 'flickr' + source: 'flickr' ) photo.update(photo_params) photo.owner_id = current_member.id diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 983fb13ff..c1183e790 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -21,11 +21,11 @@ class PlantingsController < DataController end @plantings = Planting.search( - where: where, - page: params[:page], - limit: 30, + where: where, + page: params[:page], + limit: 30, boost_by: [:created_at], - load: false + load: false ) @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv" @@ -49,15 +49,15 @@ class PlantingsController < DataController def new @planting = Planting.new( planted_at: Time.zone.today, - owner: current_member, - garden: current_member.gardens.first + owner: current_member, + garden: current_member.gardens.first ) @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new if params[:garden_id] @planting.garden = Garden.find_by( owner: current_member, - id: params[:garden_id] + id: params[:garden_id] ) end diff --git a/app/models/concerns/search_crops.rb b/app/models/concerns/search_crops.rb index f388ae814..b37fbfcc1 100644 --- a/app/models/concerns/search_crops.rb +++ b/app/models/concerns/search_crops.rb @@ -6,16 +6,16 @@ module SearchCrops included do #################################### # Elastic search configuration - searchkick word_start: %i(name description alternate_names scientific_names), + searchkick word_start: %i(name description alternate_names scientific_names), case_sensitive: false, - searchable: [:name, :descriptions, :alternate_names, :scientific_names], + searchable: %i(name descriptions alternate_names scientific_names), merge_mappings: true, - mappings: { + mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, plantings_count: { type: :integer }, - harvests_count: { type: :integer }, - photos_count: { type: :integer } + harvests_count: { type: :integer }, + photos_count: { type: :integer } } } @@ -28,21 +28,21 @@ module SearchCrops def search_data { - name: name, - description: description, - slug: slug, - alternate_names: alternate_names.pluck(:name), + name: name, + description: description, + slug: slug, + alternate_names: alternate_names.pluck(:name), scientific_names: scientific_names.pluck(:name), - photos_count: photo_associations_count, + photos_count: photo_associations_count, # boost the crops that are planted the most - plantings_count: plantings_count, - harvests_count: harvests_count, + plantings_count: plantings_count, + harvests_count: harvests_count, # boost this crop for these members - planters_ids: plantings.pluck(:owner_id), - has_photos: photos.size.positive?, - thumbnail_url: thumbnail_url, - scientific_name: default_scientific_name&.name, - created_at: created_at.to_i + planters_ids: plantings.pluck(:owner_id), + has_photos: photos.size.positive?, + thumbnail_url: thumbnail_url, + scientific_name: default_scientific_name&.name, + created_at: created_at.to_i } end end diff --git a/app/models/concerns/search_harvests.rb b/app/models/concerns/search_harvests.rb index 9c4e8892a..c33682776 100644 --- a/app/models/concerns/search_harvests.rb +++ b/app/models/concerns/search_harvests.rb @@ -7,9 +7,9 @@ module SearchHarvests searchkick merge_mappings: true, mappings: { properties: { harvests_count: { type: :integer }, - photos_count: { type: :integer }, - created_at: { type: :integer }, - harvested_at: { type: :date } + photos_count: { type: :integer }, + created_at: { type: :integer }, + harvested_at: { type: :date } } } @@ -17,45 +17,45 @@ module SearchHarvests def search_data { - slug: slug, - quantity: quantity, + slug: slug, + quantity: quantity, # crop - crop_id: crop_id, - crop_name: crop_name, - crop_slug: crop.slug, + crop_id: crop_id, + crop_name: crop_name, + crop_slug: crop.slug, # owner - owner_id: owner_id, + owner_id: owner_id, owner_login_name: owner_login_name, - owner_slug: owner_slug, - plant_part_name: plant_part&.name, + owner_slug: owner_slug, + plant_part_name: plant_part&.name, # planting - planting_id: planting_id, - planting_slug: planting&.slug, + planting_id: planting_id, + planting_slug: planting&.slug, # photo - has_photos: photos.size.positive?, - thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, + has_photos: photos.size.positive?, + thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, # counts # harvests_count: harvests_count, - photos_count: photos.count, + photos_count: photos.count, # timestamps - harvested_at: harvested_at, - created_at: created_at.to_i + harvested_at: harvested_at, + created_at: created_at.to_i } end def self.homepage_records(limit) - search('*', limit: limit, - where: { + search('*', limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end diff --git a/app/models/concerns/search_photos.rb b/app/models/concerns/search_photos.rb index 5bf48ec67..952dd5d63 100644 --- a/app/models/concerns/search_photos.rb +++ b/app/models/concerns/search_photos.rb @@ -6,28 +6,28 @@ module SearchPhotos included do searchkick merge_mappings: true, mappings: { properties: { - title: { type: :text }, + title: { type: :text }, created_at: { type: :integer } } } def search_data { - id: id, - title: title, - thumbnail_url: thumbnail_url, - fullsize_url: fullsize_url, + id: id, + title: title, + thumbnail_url: thumbnail_url, + fullsize_url: fullsize_url, # crops - crops: crops.pluck(:id), + crops: crops.pluck(:id), # likes liked_by_members_names: liked_by_members_names, # owner - owner_id: owner_id, - owner_login_name: owner.login_name, + owner_id: owner_id, + owner_login_name: owner.login_name, # counts - likes_count: likes_count, + likes_count: likes_count, - created_at: created_at.to_i + created_at: created_at.to_i } end end diff --git a/app/models/concerns/search_plantings.rb b/app/models/concerns/search_plantings.rb index bb29e07f9..5307464d2 100644 --- a/app/models/concerns/search_plantings.rb +++ b/app/models/concerns/search_plantings.rb @@ -6,10 +6,10 @@ module SearchPlantings included do searchkick merge_mappings: true, mappings: { properties: { - active: { type: :boolean }, - created_at: { type: :integer }, + active: { type: :boolean }, + created_at: { type: :integer }, harvests_count: { type: :integer }, - photos_count: { type: :integer }, + photos_count: { type: :integer }, owner_location: { type: :text } } } @@ -18,46 +18,46 @@ module SearchPlantings def search_data { - slug: slug, - active: active, - finished: finished?, - has_photos: photos.size.positive?, - location: location, + slug: slug, + active: active, + finished: finished?, + has_photos: photos.size.positive?, + location: location, percentage_grown: percentage_grown.to_i, - planted_at: planted_at, - planted_from: planted_from, - quantity: quantity, - sunniness: sunniness, + planted_at: planted_at, + planted_from: planted_from, + quantity: quantity, + sunniness: sunniness, # crops - crop_id: crop_id, - crop_name: crop.name, - crop_slug: crop.slug, + crop_id: crop_id, + crop_name: crop.name, + crop_slug: crop.slug, # owner - owner_id: owner_id, - owner_location: owner_location, + owner_id: owner_id, + owner_location: owner_location, owner_login_name: owner_login_name, - owner_slug: owner_slug, + owner_slug: owner_slug, # photos - thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, + thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, # counts - photos_count: photos.size, - harvests_count: harvests_count, + photos_count: photos.size, + harvests_count: harvests_count, # timestamps - created_at: created_at.to_i + created_at: created_at.to_i } end def self.homepage_records(limit) - search('*', limit: limit, - where: { + search('*', limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end diff --git a/app/models/concerns/search_seeds.rb b/app/models/concerns/search_seeds.rb index 23f55e140..1792173e7 100644 --- a/app/models/concerns/search_seeds.rb +++ b/app/models/concerns/search_seeds.rb @@ -6,10 +6,10 @@ module SearchSeeds included do searchkick merge_mappings: true, mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, plant_before: { type: :text }, photos_count: { type: :integer }, - tradable_to: { type: :text } + tradable_to: { type: :text } } } @@ -17,51 +17,51 @@ module SearchSeeds def search_data { - slug: slug, - finished: finished?, - gmo: gmo, - active: active, - heirloom: heirloom, - location: owner.location, - organic: organic, - quantity: quantity, - plant_before: plant_before&.to_s(:ymd), - tradable_to: tradable_to, - tradable: tradable?, + slug: slug, + finished: finished?, + gmo: gmo, + active: active, + heirloom: heirloom, + location: owner.location, + organic: organic, + quantity: quantity, + plant_before: plant_before&.to_s(:ymd), + tradable_to: tradable_to, + tradable: tradable?, # crop - crop_id: crop_id, - crop_name: crop.name, - crop_slug: crop.slug, + crop_id: crop_id, + crop_name: crop.name, + crop_slug: crop.slug, # owner - owner_id: owner_id, - owner_location: owner_location, + owner_id: owner_id, + owner_location: owner_location, owner_login_name: owner_login_name, - owner_slug: owner_slug, + owner_slug: owner_slug, # planting - parent_planting: parent_planting, + parent_planting: parent_planting, # counts - photos_count: photos.size, + photos_count: photos.size, # photo - has_photos: photos.size.positive?, - thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, + has_photos: photos.size.positive?, + thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, - created_at: created_at.to_i + created_at: created_at.to_i } end def self.homepage_records(limit) - search('*', limit: limit, - where: { + search('*', limit: limit, + where: { finished: false, tradable: true }, boost_by: [:created_at], - load: false) + load: false) end end end diff --git a/app/models/crop.rb b/app/models/crop.rb index c5de8aa2c..0df63cf85 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -50,10 +50,10 @@ class Crop < ApplicationRecord ## Wikipedia urls are only necessary when approving a crop validates :en_wikipedia_url, format: { - with: %r{\Ahttps?:\/\/en\.wikipedia\.org\/wiki\/[[:alnum:]%_\.()-]+\z}, + with: %r{\Ahttps?:\/\/en\.wikipedia\.org\/wiki\/[[:alnum:]%_\.()-]+\z}, message: 'is not a valid English Wikipedia URL' }, - if: :approved? + if: :approved? def to_s name diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 399194610..338984dd2 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -12,15 +12,15 @@ class Harvest < ApplicationRecord # Constants UNITS_VALUES = { "individual" => "individual", - "bunches" => "bunch", - "sprigs" => "sprig", - "handfuls" => "handful", - "litres" => "litre", - "pints" => "pint", - "quarts" => "quart", - "buckets" => "bucket", - "baskets" => "basket", - "bushels" => "bushel" + "bunches" => "bunch", + "sprigs" => "sprig", + "handfuls" => "handful", + "litres" => "litre", + "pints" => "pint", + "quarts" => "quart", + "buckets" => "bucket", + "baskets" => "basket", + "bushels" => "bushel" }.freeze WEIGHT_UNITS_VALUES = { diff --git a/app/models/photo.rb b/app/models/photo.rb index 0c407bc1e..3e0254800 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -22,8 +22,8 @@ class Photo < ApplicationRecord # creates a relationship for each assignee type PHOTO_CAPABLE.each do |type| has_many type.downcase.pluralize.to_s.to_sym, - through: :photo_associations, - source: :photographable, + through: :photo_associations, + source: :photographable, source_type: type end @@ -42,13 +42,13 @@ class Photo < ApplicationRecord licenses = flickr.photos.licenses.getInfo license = licenses.find { |l| l.id == info.license } { - title: calculate_title(info), - license_name: license.name, - license_url: license.url, + title: calculate_title(info), + license_name: license.name, + license_url: license.url, thumbnail_url: FlickRaw.url_q(info), - fullsize_url: FlickRaw.url_z(info), - link_url: FlickRaw.url_photopage(info), - date_taken: info.dates.taken + fullsize_url: FlickRaw.url_z(info), + link_url: FlickRaw.url_photopage(info), + date_taken: info.dates.taken } end diff --git a/app/models/photo_association.rb b/app/models/photo_association.rb index 9f92160fb..e253a3a50 100644 --- a/app/models/photo_association.rb +++ b/app/models/photo_association.rb @@ -2,7 +2,7 @@ class PhotoAssociation < ApplicationRecord belongs_to :photo, touch: true - belongs_to :crop, optional: true, touch: true #, counter_cache: true + belongs_to :crop, optional: true, touch: true # , counter_cache: true belongs_to :photographable, polymorphic: true, touch: true validate :photo_and_item_have_same_owner @@ -34,7 +34,7 @@ class PhotoAssociation < ApplicationRecord def crop_present if %w(Planting Seed Harvest).include?(photographable_type) - errors.add(:crop_id, "failed to calculate crop") unless crop_id.present? + errors.add(:crop_id, "failed to calculate crop") if crop_id.blank? end end end diff --git a/app/models/post.rb b/app/models/post.rb index e5a84c82e..0fbdf3533 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -91,9 +91,9 @@ class Post < ApplicationRecord Notification.create( recipient_id: recipient_id, - sender_id: sender, - subject: "#{author} mentioned you in their post #{subject}", - body: body + sender_id: sender, + subject: "#{author} mentioned you in their post #{subject}", + body: body ) end end diff --git a/app/services/crop_search_service.rb b/app/services/crop_search_service.rb index 85ced41d5..46989b7cc 100644 --- a/app/services/crop_search_service.rb +++ b/app/services/crop_search_service.rb @@ -4,12 +4,12 @@ class CropSearchService # Crop.search(string) def self.search(query, page: 1, per_page: 12, current_member: nil) search_params = { - page: page, - per_page: per_page, - fields: %i(name^5 alternate_names scientific_names), - match: :word_start, - boost_by: [:plantings_count], - includes: %i(scientific_names alternate_names), + page: page, + per_page: per_page, + fields: %i(name^5 alternate_names scientific_names), + match: :word_start, + boost_by: [:plantings_count], + includes: %i(scientific_names alternate_names), misspellings: { edit_distance: 2 }, load: false } @@ -23,22 +23,22 @@ class CropSearchService body = { "query": { "function_score": { - "query": { "query_string": { "query": 'has_photos:true' } }, + "query": { "query_string": { "query": 'has_photos:true' } }, "random_score": { "seed": DateTime.now.to_i } } } } Crop.search( limit: limit, - load: false, - body: body + load: false, + body: body ) end def self.recent(limit) Crop.search( - limit: limit, - load: false, + limit: limit, + load: false, boost_by: { created_at: { factor: 100 } } # default factor is 1 ) end diff --git a/db/migrate/20180213005731_seed_usage.rb b/db/migrate/20180213005731_seed_usage.rb index 03240e098..ddb2c2378 100644 --- a/db/migrate/20180213005731_seed_usage.rb +++ b/db/migrate/20180213005731_seed_usage.rb @@ -9,16 +9,16 @@ class SeedUsage < ActiveRecord::Migration[4.2] # plantings can be grown from a seed add_column(:plantings, :parent_seed_id, :integer) add_foreign_key(:plantings, :seeds, - column: :parent_seed_id, + column: :parent_seed_id, primary_key: :id, - name: :parent_seed, - on_delete: :nullify) + name: :parent_seed, + on_delete: :nullify) # seeds can be harvest from planting add_column(:seeds, :parent_planting_id, :integer) add_foreign_key(:seeds, :plantings, - column: :parent_planting_id, + column: :parent_planting_id, primary_key: :id, - name: :parent_planting, - on_delete: :nullify) + name: :parent_planting, + on_delete: :nullify) end end diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index 6233a28dc..50d45ba6e 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -7,10 +7,10 @@ describe HarvestsController, :search do def valid_attributes { - owner_id: subject.current_member.id, - crop_id: FactoryBot.create(:crop).id, + owner_id: subject.current_member.id, + crop_id: FactoryBot.create(:crop).id, plant_part_id: FactoryBot.create(:plant_part).id, - harvested_at: '2017-01-01' + harvested_at: '2017-01-01' } end @@ -196,7 +196,7 @@ describe HarvestsController, :search do describe "does not save planting_id" do before do put :update, params: { - slug: harvest.to_param, + slug: harvest.to_param, harvest: valid_attributes.merge(planting_id: not_my_planting.id) } end diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 4e89ffbca..a13a7ccc9 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -88,12 +88,12 @@ describe PhotosController, :search do describe "POST create" do before do - Photo.any_instance.stub(:flickr_metadata).and_return(title: "A Heartbreaking work of staggering genius", - license_name: "CC-BY", - license_url: "http://example.com/aybpl", + Photo.any_instance.stub(:flickr_metadata).and_return(title: "A Heartbreaking work of staggering genius", + license_name: "CC-BY", + license_url: "http://example.com/aybpl", thumbnail_url: "http://example.com/thumb.jpg", - fullsize_url: "http://example.com/full.jpg", - link_url: "http://example.com") + fullsize_url: "http://example.com/full.jpg", + link_url: "http://example.com") end let(:member) { FactoryBot.create(:member) } diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index f7d9a0a21..4b5f2a651 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -8,7 +8,7 @@ describe PlantingsController, :search do def valid_attributes { garden_id: FactoryBot.create(:garden, owner: subject.current_member).id, - crop_id: FactoryBot.create(:crop).id + crop_id: FactoryBot.create(:crop).id } end diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb index d44b42820..a3f5b3670 100644 --- a/spec/features/crops/browse_crops_spec.rb +++ b/spec/features/crops/browse_crops_spec.rb @@ -12,7 +12,7 @@ describe "browse crops", :search do before do Crop.reindex visit crops_path - end + end it "has a form for sorting by" do expect(page).to have_css "select#sort" diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 7eb917f35..16219c588 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -41,7 +41,7 @@ describe Photo do end describe 'to a harvest' do - let(:crop){ harvest.crop } + let(:crop) { harvest.crop } before { harvest.photos << photo } it { expect(harvest.photos).to eq [photo] } @@ -54,7 +54,7 @@ describe Photo do # Check the relationship from the photo it { expect(photo.photo_associations.count).to eq 1 } - it { expect(photo.photo_associations.map(&:crop)).to eq [ crop ]} + it { expect(photo.photo_associations.map(&:crop)).to eq [ crop ] } it { expect(photo.crops.count).to eq 1 } it { expect(photo.crops).to eq [crop] } end diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index f2f29f556..c6a0ae446 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -17,21 +17,21 @@ describe "plantings/index" do pager.replace([ FactoryBot.create(:planting, garden: garden, - crop: tomato, - owner: member), + crop: tomato, + owner: member), FactoryBot.create(:planting, - garden: garden, - crop: maize, - owner: garden.owner, + garden: garden, + crop: maize, + owner: garden.owner, description: '', - planted_at: Time.zone.local(2013, 1, 13)), + planted_at: Time.zone.local(2013, 1, 13)), FactoryBot.create(:planting, - garden: garden, - owner: garden.owner, - crop: tomato, - planted_at: Time.zone.local(2013, 1, 13), + garden: garden, + owner: garden.owner, + crop: tomato, + planted_at: Time.zone.local(2013, 1, 13), finished_at: Time.zone.local(2013, 1, 20), - finished: true) + finished: true) ]) end assign(:plantings, plantings) From b7e53daebaf7a936b8aaa9ea6c394298afa486ec Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 5 Jan 2020 16:57:14 +1300 Subject: [PATCH 167/188] fixes to crop photos --- app/models/concerns/photo_capable.rb | 6 +++++- app/views/crops/_photos.html.haml | 2 +- spec/features/crops/crop_photos_spec.rb | 12 +++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/models/concerns/photo_capable.rb b/app/models/concerns/photo_capable.rb index 3144ec283..c1433a7fc 100644 --- a/app/models/concerns/photo_capable.rb +++ b/app/models/concerns/photo_capable.rb @@ -16,7 +16,11 @@ module PhotoCapable end def thumbnail_url - default_photo ? default_photo.thumbnail_url : nil + df = default_photo + + return unless df + + df.source == 'flickr' ? df.fullsize_url : df.thumbnail_url end def most_liked_photo diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index 207974b0a..42ee6eef7 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -1,4 +1,4 @@ -- if crop.photo_associations_count.positive? +- if crop.photos.count.positive? %h2 #{photo_icon} Photos - [Crop, Planting, Harvest, Seed].each do |model_name| - if crop.photos.by_model(model_name).size.positive? diff --git a/spec/features/crops/crop_photos_spec.rb b/spec/features/crops/crop_photos_spec.rb index 1fc44772a..edeac6fcd 100644 --- a/spec/features/crops/crop_photos_spec.rb +++ b/spec/features/crops/crop_photos_spec.rb @@ -2,15 +2,17 @@ require 'rails_helper' -describe "crop detail page", js: true do +describe "crop detail page", :js, :search do subject { page } let!(:owner_member) { FactoryBot.create :member } - let!(:crop) { FactoryBot.create :crop } + let!(:crop) { FactoryBot.create :crop, :reindex } + 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!(:harvest) { FactoryBot.create :harvest, crop: crop, owner: owner_member } let!(:seed) { FactoryBot.create :seed, crop: crop, owner: owner_member } let!(:photo1) { FactoryBot.create(:photo, owner: owner_member) } @@ -27,7 +29,11 @@ describe "crop detail page", js: true do harvest.photos << photo4 seed.photos << photo5 seed.photos << photo6 + Crop.reindex visit crop_path(crop) + expect(crop.photos.count).to eq 6 + expect(crop.photos.by_model(Planting).count).to eq 2 + expect(page).to have_content 'Photos' end shared_examples "shows photos" do From e6e020dbc94bcd5f0e8f07a487a9ee6e41ba602d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 5 Jan 2020 20:55:51 +1300 Subject: [PATCH 168/188] oops --- dev.diff | 7902 ------------------------------------------------------ 1 file changed, 7902 deletions(-) delete mode 100644 dev.diff diff --git a/dev.diff b/dev.diff deleted file mode 100644 index 8555de953..000000000 --- a/dev.diff +++ /dev/null @@ -1,7902 +0,0 @@ -diff --git a/.rubocop.yml b/.rubocop.yml -index 355a14ac..9472c891 100644 ---- a/.rubocop.yml -+++ b/.rubocop.yml -@@ -4,7 +4,7 @@ AllCops: - Exclude: - - 'db/schema.rb' - - 'vendor/**/*' -- TargetRailsVersion: 5.0 -+ TargetRailsVersion: 5.2 - - Rails: - Enabled: true -@@ -15,15 +15,6 @@ Naming/FileName: - - 'Gemfile' - - 'Gemfile.lock' - --Style/StringLiterals: -- Enabled: false -- --Style/PercentLiteralDelimiters: -- PreferredDelimiters: -- default: () -- '%i': () -- '%w': () -- - Layout/MultilineMethodCallIndentation: - EnforcedStyle: indented - -@@ -36,11 +27,16 @@ Layout/HashAlignment: - Layout/ParameterAlignment: - EnforcedStyle: with_fixed_indentation - -- --Style/Documentation: -+Style/StringLiterals: - Enabled: false - --Style/FrozenStringLiteralComment: -+Style/PercentLiteralDelimiters: -+ PreferredDelimiters: -+ default: () -+ '%i': () -+ '%w': () -+ -+Style/Documentation: - Enabled: false - - # Configuration parameters: Include. -@@ -56,22 +52,9 @@ Metrics/BlockLength: - - '**/*.rake' - - 'config/**/*.rb' - --Metrics/LineLength: -+Layout/LineLength: - Max: 140 - --# Remove the following once the code style matches --Metrics/MethodLength: -- Max: 34 --Metrics/AbcSize: -- Max: 33 --# Configuration parameters: CountComments. --Metrics/ClassLength: -- Max: 171 --Metrics/CyclomaticComplexity: -- Max: 8 --Metrics/PerceivedComplexity: -- Max: 9 -- - # Places we use update_all, etc even though it skips validations. - Rails/SkipsModelValidations: - Exclude: -diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml -index 906cc547..91e33b14 100644 ---- a/.rubocop_todo.yml -+++ b/.rubocop_todo.yml -@@ -10,48 +10,6 @@ Lint/AmbiguousOperator: - Exclude: - - 'spec/controllers/crops_controller_spec.rb' - --# Configuration parameters: AllowComments. --Lint/SuppressedException: -- Exclude: -- - 'lib/tasks/testing.rake' -- --Lint/UselessAssignment: -- Exclude: -- - 'config.rb' -- - 'config/compass.rb' -- --Metrics/AbcSize: -- Max: 125 -- --# Configuration parameters: CountComments, ExcludedMethods. --# ExcludedMethods: refine --Metrics/BlockLength: -- Max: 59 -- --# Configuration parameters: CountComments. --Metrics/ClassLength: -- Max: 186 -- --Metrics/CyclomaticComplexity: -- Max: 29 -- --# Cop supports --auto-correct. --# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. --# URISchemes: http, https --Metrics/LineLength: -- Max: 341 -- --# Configuration parameters: CountComments, ExcludedMethods. --Metrics/MethodLength: -- Max: 106 -- --# Configuration parameters: CountComments. --Metrics/ModuleLength: -- Max: 107 -- --Metrics/PerceivedComplexity: -- Max: 29 -- - # Configuration parameters: EnforcedStyle. - # SupportedStyles: lowercase, uppercase - Naming/HeredocDelimiterCase: -diff --git a/app/controllers/admin/members_controller.rb b/app/controllers/admin/members_controller.rb -index 0526a57c..cf10b5c0 100644 ---- a/app/controllers/admin/members_controller.rb -+++ b/app/controllers/admin/members_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Admin - class MembersController < ApplicationController - before_action :admin! -diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb -index d08c292d..3ad46e6a 100644 ---- a/app/controllers/admin/roles_controller.rb -+++ b/app/controllers/admin/roles_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Admin - class RolesController < ApplicationController - before_action :admin! -diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb -index 54156743..454faf1c 100644 ---- a/app/controllers/admin_controller.rb -+++ b/app/controllers/admin_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AdminController < ApplicationController - respond_to :html - def index -diff --git a/app/controllers/alternate_names_controller.rb b/app/controllers/alternate_names_controller.rb -index 3466f72a..922c078c 100644 ---- a/app/controllers/alternate_names_controller.rb -+++ b/app/controllers/alternate_names_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AlternateNamesController < ApplicationController - before_action :authenticate_member!, except: %i(index) - load_and_authorize_resource -diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb -index 4fbc4d80..84eb42dc 100644 ---- a/app/controllers/api/v1/base_controller.rb -+++ b/app/controllers/api/v1/base_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Api - module V1 - class BaseController < JSONAPI::ResourceController -diff --git a/app/controllers/api/v1/crops_controller.rb b/app/controllers/api/v1/crops_controller.rb -index d67beaa1..f75516a4 100644 ---- a/app/controllers/api/v1/crops_controller.rb -+++ b/app/controllers/api/v1/crops_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Api - module V1 - class CropsController < BaseController -diff --git a/app/controllers/api/v1/gardens_controller.rb b/app/controllers/api/v1/gardens_controller.rb -index 4343d801..ff420cf6 100644 ---- a/app/controllers/api/v1/gardens_controller.rb -+++ b/app/controllers/api/v1/gardens_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Api - module V1 - class GardensController < BaseController -diff --git a/app/controllers/api/v1/harvests_controller.rb b/app/controllers/api/v1/harvests_controller.rb -index bcf735dc..1bef4212 100644 ---- a/app/controllers/api/v1/harvests_controller.rb -+++ b/app/controllers/api/v1/harvests_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Api - module V1 - class HarvestsController < BaseController -diff --git a/app/controllers/api/v1/members_controller.rb b/app/controllers/api/v1/members_controller.rb -index b9b99956..7f08067e 100644 ---- a/app/controllers/api/v1/members_controller.rb -+++ b/app/controllers/api/v1/members_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Api - module V1 - class MembersController < BaseController -diff --git a/app/controllers/api/v1/photos_controller.rb b/app/controllers/api/v1/photos_controller.rb -index a095d24c..693edd1f 100644 ---- a/app/controllers/api/v1/photos_controller.rb -+++ b/app/controllers/api/v1/photos_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Api - module V1 - class PhotosController < BaseController -diff --git a/app/controllers/api/v1/plantings_controller.rb b/app/controllers/api/v1/plantings_controller.rb -index d143676a..dc2bc689 100644 ---- a/app/controllers/api/v1/plantings_controller.rb -+++ b/app/controllers/api/v1/plantings_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Api - module V1 - class PlantingsController < BaseController -diff --git a/app/controllers/api/v1/seeds_controller.rb b/app/controllers/api/v1/seeds_controller.rb -index 43f5691c..53722ea6 100644 ---- a/app/controllers/api/v1/seeds_controller.rb -+++ b/app/controllers/api/v1/seeds_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Api - module V1 - class SeedsController < BaseController -diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb -index ceafaa6c..58c3ec35 100644 ---- a/app/controllers/application_controller.rb -+++ b/app/controllers/application_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ApplicationController < ActionController::Base - protect_from_forgery - -@@ -5,9 +7,8 @@ class ApplicationController < ActionController::Base - - after_action :store_location - before_action :set_locale -- - rescue_from ActiveRecord::RecordNotFound, with: :not_found -- # CanCan error handling -+ - def store_location - unless request.path.in?(["/members/sign_in", - "/members/sign_up", -diff --git a/app/controllers/authentications_controller.rb b/app/controllers/authentications_controller.rb -index fc18ff4d..31056c6e 100644 ---- a/app/controllers/authentications_controller.rb -+++ b/app/controllers/authentications_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require './lib/actions/oauth_signup_action' - class AuthenticationsController < ApplicationController - before_action :authenticate_member! -diff --git a/app/controllers/charts/crops_controller.rb b/app/controllers/charts/crops_controller.rb -index 9626a76b..a48ec1ab 100644 ---- a/app/controllers/charts/crops_controller.rb -+++ b/app/controllers/charts/crops_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Charts - class CropsController < ApplicationController - respond_to :json -diff --git a/app/controllers/charts/gardens_controller.rb b/app/controllers/charts/gardens_controller.rb -index b9d25bb5..5ca9a03b 100644 ---- a/app/controllers/charts/gardens_controller.rb -+++ b/app/controllers/charts/gardens_controller.rb -@@ -1,9 +1,11 @@ -+# frozen_string_literal: true -+ - module Charts - class GardensController < ApplicationController - respond_to :json - def timeline - @data = [] -- @garden = Garden.find(params[:garden_id]) -+ @garden = Garden.find(params[:garden_slug]) - @garden.plantings.where.not(planted_at: nil) - .order(finished_at: :desc).each do |p| - # use finished_at if we have it, otherwise use predictions -diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb -index d47dae87..37f2a5b1 100644 ---- a/app/controllers/comments_controller.rb -+++ b/app/controllers/comments_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CommentsController < ApplicationController - before_action :authenticate_member!, except: %i(index) - load_and_authorize_resource -diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb -index e5da3be9..14b51e8f 100644 ---- a/app/controllers/conversations_controller.rb -+++ b/app/controllers/conversations_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ConversationsController < ApplicationController - respond_to :html - before_action :authenticate_member! -diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb -index 99c702e7..994ffe19 100644 ---- a/app/controllers/crops_controller.rb -+++ b/app/controllers/crops_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'will_paginate/array' - - class CropsController < ApplicationController -@@ -9,7 +11,7 @@ class CropsController < ApplicationController - - def index - @sort = params[:sort] -- @crops = crops -+ @crops = Crop.search('*', boost_by: %i(plantings_count harvests_count), limit: 100, page: params[:page], load: false) - @num_requested_crops = requested_crops.size if current_member - @filename = filename - respond_with @crops -@@ -213,13 +215,6 @@ class CropsController < ApplicationController - } - end - -- def crops -- q = Crop.approved.includes(:scientific_names, plantings: :photos) -- q = q.popular unless @sort == 'alpha' -- q.order(Arel.sql("LOWER(crops.name)")) -- .includes(:photos).paginate(page: params[:page]) -- end -- - def requested_crops - current_member.requested_crops.pending_approval - end -diff --git a/app/controllers/data_controller.rb b/app/controllers/data_controller.rb -new file mode 100644 -index 00000000..fece1f68 ---- /dev/null -+++ b/app/controllers/data_controller.rb -@@ -0,0 +1,13 @@ -+# frozen_string_literal: true -+ -+class DataController < ApplicationController -+ abstract -+ before_action :authenticate_member!, except: %i(index show) -+ load_and_authorize_resource id_param: :slug -+ -+ after_action :expire_homepage, only: %i(create update destroy) -+ -+ respond_to :html, :json -+ respond_to :csv, :rss, only: [:index] -+ responders :flash -+end -diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb -index 1555a4a7..2caf0f33 100644 ---- a/app/controllers/follows_controller.rb -+++ b/app/controllers/follows_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class FollowsController < ApplicationController - before_action :set_member, only: %i(index followers) - load_and_authorize_resource -diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb -index df6d1cad..bc75da5f 100644 ---- a/app/controllers/forums_controller.rb -+++ b/app/controllers/forums_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ForumsController < ApplicationController - load_and_authorize_resource - respond_to :html, :json -diff --git a/app/controllers/garden_types_controller.rb b/app/controllers/garden_types_controller.rb -index 5fade528..567af80f 100644 ---- a/app/controllers/garden_types_controller.rb -+++ b/app/controllers/garden_types_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class GardenTypesController < ApplicationController - respond_to :html, :json - load_and_authorize_resource -diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb -index 333fa454..5ef4be12 100644 ---- a/app/controllers/gardens_controller.rb -+++ b/app/controllers/gardens_controller.rb -@@ -1,10 +1,6 @@ --class GardensController < ApplicationController -- before_action :authenticate_member!, except: %i(index show) -- after_action :expire_homepage, only: %i(create destroy) -- load_and_authorize_resource -- responders :flash -- respond_to :html, :json -+# frozen_string_literal: true - -+class GardensController < DataController - def index - @owner = Member.find_by(slug: params[:member_slug]) - @show_all = params[:all] == '1' -diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb -index c474e267..c618b974 100644 ---- a/app/controllers/harvests_controller.rb -+++ b/app/controllers/harvests_controller.rb -@@ -1,20 +1,31 @@ --class HarvestsController < ApplicationController -- before_action :authenticate_member!, except: %i(index show) -+# frozen_string_literal: true -+ -+class HarvestsController < DataController - after_action :update_crop_medians, only: %i(create update destroy) -- load_and_authorize_resource -- respond_to :html, :json -- respond_to :csv, :rss, only: :index -- responders :flash - - def index -- @owner = Member.find_by(slug: params[:member_slug]) -- @crop = Crop.find_by(slug: params[:crop_slug]) -- @planting = Planting.find_by(slug: params[:planting_id]) -- -- @harvests = @harvests.where(owner: @owner) if @owner.present? -- @harvests = @harvests.where(crop: @crop) if @crop.present? -- @harvests = @harvests.where(planting: @planting) if @planting.present? -- @harvests = @harvests.order(harvested_at: :desc).joins(:owner, :crop).paginate(page: params[:page]) -+ where = {} -+ if params[:member_slug] -+ @owner = Member.find_by(slug: params[:member_slug]) -+ where['owner_id'] = @owner.id -+ end -+ -+ if params[:crop_slug] -+ @crop = Crop.find_by(slug: params[:crop_slug]) -+ where['crop_id'] = @crop.id -+ end -+ -+ if params[:planting_slug] -+ @planting = Planting.find_by(slug: params[:planting_slug]) -+ where['planting_id'] = @planting.id -+ end -+ -+ @harvests = Harvest.search('*', -+ where: where, -+ limit: 100, -+ page: params[:page], -+ load: false, -+ boost_by: [:created_at]) - - @filename = csv_filename - -diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb -index 1241c70f..e5ff4d06 100644 ---- a/app/controllers/home_controller.rb -+++ b/app/controllers/home_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class HomeController < ApplicationController - skip_authorize_resource - respond_to :html -diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb -index 501bc6ee..37d302fc 100644 ---- a/app/controllers/likes_controller.rb -+++ b/app/controllers/likes_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class LikesController < ApplicationController - before_action :authenticate_member! - respond_to :html, :json -diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb -index 0d07b303..9b65068d 100644 ---- a/app/controllers/members_controller.rb -+++ b/app/controllers/members_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class MembersController < ApplicationController - load_and_authorize_resource except: %i(finish_signup unsubscribe view_follows view_followers show) - skip_authorize_resource only: %i(nearby unsubscribe finish_signup) -diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb -index 21bb4d0b..9efc7ae4 100644 ---- a/app/controllers/messages_controller.rb -+++ b/app/controllers/messages_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class MessagesController < ApplicationController - respond_to :html, :json - before_action :authenticate_member! -diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb -index 3d642cd3..c9243c89 100644 ---- a/app/controllers/omniauth_callbacks_controller.rb -+++ b/app/controllers/omniauth_callbacks_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require './lib/actions/oauth_signup_action' - - # -diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb -index 9ffb98af..4da0321d 100644 ---- a/app/controllers/pages_controller.rb -+++ b/app/controllers/pages_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class PagesController < ApplicationController - def letsencrypt - # use your code here, not mine -diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb -index fb6852ea..012cd352 100644 ---- a/app/controllers/passwords_controller.rb -+++ b/app/controllers/passwords_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class PasswordsController < Devise::PasswordsController - protected - -diff --git a/app/controllers/photo_associations_controller.rb b/app/controllers/photo_associations_controller.rb -index 499dbefc..00655a73 100644 ---- a/app/controllers/photo_associations_controller.rb -+++ b/app/controllers/photo_associations_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class PhotoAssociationsController < ApplicationController - before_action :authenticate_member! - respond_to :json, :html -diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb -index c6243ad2..d168488b 100644 ---- a/app/controllers/photos_controller.rb -+++ b/app/controllers/photos_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class PhotosController < ApplicationController - before_action :authenticate_member!, except: %i(index show) - after_action :expire_homepage, only: %i(create destroy) -@@ -11,18 +13,20 @@ class PhotosController < ApplicationController - end - - def index -+ where = {} - if params[:crop_slug] - @crop = Crop.find params[:crop_slug] -- @photos = Photo.by_crop(@crop) -+ where = { crop_id: @crop.id } - elsif params[:planting_id] - @planting = Planting.find params[:planting_id] -- @photos = @planting.photos -- else -- @photos = Photo.all -+ where = { planting_id: @planting.id } - end -- @photos = @photos.order(created_at: :desc) -- .includes(:owner) -- .paginate(page: params[:page]) -+ -+ @photos = Photo.search(load: false, -+ boost_by: [:created_at], -+ where: where, -+ page: params[:page], -+ limit: 50) - respond_with(@photos) - end - -diff --git a/app/controllers/places_controller.rb b/app/controllers/places_controller.rb -index 4586b5d3..a30c1ae9 100644 ---- a/app/controllers/places_controller.rb -+++ b/app/controllers/places_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class PlacesController < ApplicationController - skip_authorize_resource - respond_to :html, :json -diff --git a/app/controllers/plant_parts_controller.rb b/app/controllers/plant_parts_controller.rb -index 1e594fd7..8fbd23c5 100644 ---- a/app/controllers/plant_parts_controller.rb -+++ b/app/controllers/plant_parts_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class PlantPartsController < ApplicationController - load_and_authorize_resource - respond_to :html, :json -diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb -index ae01b499..7b6c9273 100644 ---- a/app/controllers/plantings_controller.rb -+++ b/app/controllers/plantings_controller.rb -@@ -1,29 +1,32 @@ --class PlantingsController < ApplicationController -- before_action :authenticate_member!, except: %i(index show) -- after_action :expire_homepage, only: %i(create update destroy) -+# frozen_string_literal: true -+ -+class PlantingsController < DataController - after_action :update_crop_medians, only: %i(create update destroy) - after_action :update_planting_medians, only: :update -- load_and_authorize_resource -- -- respond_to :html, :json -- respond_to :csv, :rss, only: [:index] -- responders :flash - - def index -- @owner = Member.find_by(slug: params[:member_slug]) if params[:member_slug] -- @crop = Crop.find_by(slug: params[:crop_slug]) if params[:crop_slug] -- - @show_all = params[:all] == '1' - -- @plantings = @plantings.where(owner: @owner) if @owner.present? -- @plantings = @plantings.where(crop: @crop) if @crop.present? -+ where = {} -+ where['active'] = true unless @show_all - -- @plantings = @plantings.active unless params[:all] == '1' -+ if params[:member_slug] -+ @owner = Member.find_by(slug: params[:member_slug]) -+ where['owner_id'] = @owner.id -+ end - -- @plantings = @plantings.joins(:owner, :crop, :garden) -- .order(created_at: :desc) -- .includes(:owner, :garden, crop: :parent) -- .paginate(page: params[:page]) -+ if params[:crop_slug] -+ @crop = Crop.find_by(slug: params[:crop_slug]) -+ where['crop_id'] = @crop.id -+ end -+ -+ @plantings = Planting.search( -+ where: where, -+ page: params[:page], -+ limit: 30, -+ boost_by: [:created_at], -+ load: false -+ ) - - @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv" - -@@ -31,10 +34,16 @@ class PlantingsController < ApplicationController - end - - def show -+ @planting = Planting.includes(:owner, :crop, :garden) -+ .find(params[:slug]) - @photos = @planting.photos.includes(:owner).order(date_taken: :desc) -+ @harvests = Harvest.search(where: { planting_id: @planting.id }) - @matching_seeds = matching_seeds -+ -+ # TODO: use elastic search long/lat - @neighbours = @planting.nearby_same_crop - .where.not(id: @planting.id) -+ .includes(:owner, :crop, :garden) - .limit(6) - respond_with @planting - end -diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb -index d6561ce8..40a70fad 100644 ---- a/app/controllers/posts_controller.rb -+++ b/app/controllers/posts_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class PostsController < ApplicationController - before_action :authenticate_member!, except: %i(index show) - load_and_authorize_resource -diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb -index 24a8ee8e..53032123 100644 ---- a/app/controllers/registrations_controller.rb -+++ b/app/controllers/registrations_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class RegistrationsController < Devise::RegistrationsController - respond_to :json - -diff --git a/app/controllers/robots_controller.rb b/app/controllers/robots_controller.rb -index 84f77e90..7a000749 100644 ---- a/app/controllers/robots_controller.rb -+++ b/app/controllers/robots_controller.rb -@@ -1,5 +1,7 @@ -+# frozen_string_literal: true -+ - class RobotsController < ApplicationController -- DEFAULT_FILENAME = 'config/robots.txt'.freeze -+ DEFAULT_FILENAME = 'config/robots.txt' - - def robots - filename = "config/robots.#{subdomain}.txt" if subdomain && subdomain != 'www' -diff --git a/app/controllers/scientific_names_controller.rb b/app/controllers/scientific_names_controller.rb -index cf58fd4f..94a18acf 100644 ---- a/app/controllers/scientific_names_controller.rb -+++ b/app/controllers/scientific_names_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ScientificNamesController < ApplicationController - before_action :authenticate_member!, except: %i(index show) - load_and_authorize_resource -diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb -index b6457edb..eb7f94be 100644 ---- a/app/controllers/seeds_controller.rb -+++ b/app/controllers/seeds_controller.rb -@@ -1,20 +1,35 @@ --class SeedsController < ApplicationController -- before_action :authenticate_member!, except: %i(index show) -- load_and_authorize_resource -- responders :flash -- respond_to :html, :json -- respond_to :csv, only: :index -- respond_to :rss, only: :index -+# frozen_string_literal: true - -+class SeedsController < DataController - def index -- @owner = Member.find_by(slug: params[:member_slug]) if params[:member_slug].present? -- @crop = Crop.find_by(slug: params[:crop_slug]) if params[:crop_slug].present? -- @planting = Planting.find_by(slug: params[:planting_id]) if params[:planting_id].present? -+ where = {} -+ -+ if params[:member_slug].present? -+ @owner = Member.find_by(slug: params[:member_slug]) -+ where['owner_id'] = @owner.id -+ end -+ -+ if params[:crop_slug].present? -+ @crop = Crop.find_by(slug: params[:crop_slug]) -+ where['crop_id'] = @crop.id -+ end -+ -+ if params[:planting_id].present? -+ @planting = Planting.find_by(slug: params[:planting_id]) -+ where['parent_planting'] = @planting.id -+ end - - @show_all = (params[:all] == '1') -+ where['finished'] = false unless @show_all - - @filename = csv_filename -- @seeds = seeds.order(created_at: :desc).includes(:owner, :crop).paginate(page: params[:page]) -+ @seeds = Seed.search( -+ where: where, -+ page: params[:page], -+ limit: 30, -+ boost_by: [:created_at], -+ load: false -+ ) - - respond_with(@seeds) - end -@@ -61,15 +76,6 @@ class SeedsController < ApplicationController - - private - -- def seeds -- records = Seed.all -- records = records.where(owner: @owner) if @owner.present? -- records = records.where(crop: @crop) if @crop.present? -- records = records.where(parent_planting: @planting) if @planting.present? -- records = records.active unless @show_all -- records -- end -- - def seed_params - params.require(:seed).permit( - :crop_id, :description, :quantity, :plant_before, -diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb -index b8de4b54..47063d75 100644 ---- a/app/controllers/sessions_controller.rb -+++ b/app/controllers/sessions_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class SessionsController < Devise::SessionsController - respond_to :html, :json - -diff --git a/app/controllers/timeline_controller.rb b/app/controllers/timeline_controller.rb -index da912e69..66248052 100644 ---- a/app/controllers/timeline_controller.rb -+++ b/app/controllers/timeline_controller.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class TimelineController < ApplicationController - def index - if current_member -diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb -index 4cdda2b9..0e3a9d86 100644 ---- a/app/helpers/application_helper.rb -+++ b/app/helpers/application_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module ApplicationHelper - def parse_date(str) - str ||= '' # Date.parse barfs on nil -diff --git a/app/helpers/auto_suggest_helper.rb b/app/helpers/auto_suggest_helper.rb -index 85a3f0cb..1b8521c8 100644 ---- a/app/helpers/auto_suggest_helper.rb -+++ b/app/helpers/auto_suggest_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module AutoSuggestHelper - def auto_suggest(resource, source, options = {}) - if options[:default] && !options[:default].new_record? -diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb -index 1c4eb530..ca5cc5d7 100644 ---- a/app/helpers/buttons_helper.rb -+++ b/app/helpers/buttons_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module ButtonsHelper - include IconsHelper - def garden_plant_something_button(garden, classes: "btn btn-default") -diff --git a/app/helpers/crops_helper.rb b/app/helpers/crops_helper.rb -index f307dc79..ead50b24 100644 ---- a/app/helpers/crops_helper.rb -+++ b/app/helpers/crops_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module CropsHelper - def display_seed_availability(member, crop) - seeds = member.seeds.where(crop: crop) -@@ -13,6 +15,6 @@ module CropsHelper - end - - def crop_ebay_seeds_url(crop) -- "https://rover.ebay.com/rover/1/705-53470-19255-0/1?icep_ff3=9&pub=5575213277&toolid=10001&campid=5337940151&customid=&icep_uq=#{CGI.escape crop.name}&icep_sellerId=&icep_ex_kw=&icep_sortBy=12&icep_catId=181003&icep_minPrice=&icep_maxPrice=&ipn=psmain&icep_vectorid=229515&kwid=902099&mtid=824&kw=lg" # rubocop:disable Metrics/LineLength -+ "https://rover.ebay.com/rover/1/705-53470-19255-0/1?icep_ff3=9&pub=5575213277&toolid=10001&campid=5337940151&customid=&icep_uq=#{CGI.escape crop.name}&icep_sellerId=&icep_ex_kw=&icep_sortBy=12&icep_catId=181003&icep_minPrice=&icep_maxPrice=&ipn=psmain&icep_vectorid=229515&kwid=902099&mtid=824&kw=lg" # rubocop:disable Layout/LineLength - end - end -diff --git a/app/helpers/editable_form_helper.rb b/app/helpers/editable_form_helper.rb -index 007eeb62..527baf5b 100644 ---- a/app/helpers/editable_form_helper.rb -+++ b/app/helpers/editable_form_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module EditableFormHelper - def editable(field_type, model, field, display_field:, collection: []) - render 'shared/editable/form', field_type: field_type, -diff --git a/app/helpers/event_helper.rb b/app/helpers/event_helper.rb -index f2ff4a5f..4bc8033b 100644 ---- a/app/helpers/event_helper.rb -+++ b/app/helpers/event_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module EventHelper - def in_weeks(days) - (days / 7.0).round -diff --git a/app/helpers/gardens_helper.rb b/app/helpers/gardens_helper.rb -index 1f50d18f..0ae6d180 100644 ---- a/app/helpers/gardens_helper.rb -+++ b/app/helpers/gardens_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module GardensHelper - def display_garden_description(garden) - if garden.description.nil? -diff --git a/app/helpers/harvests_helper.rb b/app/helpers/harvests_helper.rb -index ff1838ce..cce5a10f 100644 ---- a/app/helpers/harvests_helper.rb -+++ b/app/helpers/harvests_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module HarvestsHelper - def display_quantity(harvest) - human_quantity = display_human_quantity(harvest) -diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb -index 00eb9fc3..53ceb403 100644 ---- a/app/helpers/icons_helper.rb -+++ b/app/helpers/icons_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module IconsHelper - include FontAwesome::Sass::Rails::ViewHelpers - -diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb -index c1316806..9ae42c28 100644 ---- a/app/helpers/photos_helper.rb -+++ b/app/helpers/photos_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module PhotosHelper - def crop_image_path(crop) - thumbnail_url(crop.default_photo) -diff --git a/app/helpers/plantings_helper.rb b/app/helpers/plantings_helper.rb -index 4de9102e..3b977f65 100644 ---- a/app/helpers/plantings_helper.rb -+++ b/app/helpers/plantings_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module PlantingsHelper - def display_finished(planting) - if planting.finished_at.present? -diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb -index fd676e8d..ad4afd4b 100644 ---- a/app/helpers/posts_helper.rb -+++ b/app/helpers/posts_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module PostsHelper - def display_post_truncated(post) - length = 300 -diff --git a/app/helpers/seeds_helper.rb b/app/helpers/seeds_helper.rb -index ab9e28e7..e585a234 100644 ---- a/app/helpers/seeds_helper.rb -+++ b/app/helpers/seeds_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module SeedsHelper - def display_seed_quantity(seed) - if seed.quantity.nil? -diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb -index a009ace5..d92ffddc 100644 ---- a/app/jobs/application_job.rb -+++ b/app/jobs/application_job.rb -@@ -1,2 +1,4 @@ -+# frozen_string_literal: true -+ - class ApplicationJob < ActiveJob::Base - end -diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb -index 286b2239..d84cb6e7 100644 ---- a/app/mailers/application_mailer.rb -+++ b/app/mailers/application_mailer.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' - layout 'mailer' -diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb -index d3ab4b2c..c9727be3 100644 ---- a/app/mailers/notifier.rb -+++ b/app/mailers/notifier.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class Notifier < ApplicationMailer - # include NotificationsHelper - default from: "Growstuff <#{ENV['GROWSTUFF_EMAIL']}>" -diff --git a/app/models/ability.rb b/app/models/ability.rb -index b2231e64..422c5454 100644 ---- a/app/models/ability.rb -+++ b/app/models/ability.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class Ability - include CanCan::Ability - -diff --git a/app/models/alternate_name.rb b/app/models/alternate_name.rb -index f40665b1..c9360213 100644 ---- a/app/models/alternate_name.rb -+++ b/app/models/alternate_name.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AlternateName < ApplicationRecord - belongs_to :crop - belongs_to :creator, class_name: 'Member', inverse_of: :created_alternate_names -diff --git a/app/models/application_record.rb b/app/models/application_record.rb -index e14f64e6..5d2c9a2e 100644 ---- a/app/models/application_record.rb -+++ b/app/models/application_record.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ApplicationRecord < ActiveRecord::Base - self.abstract_class = true - self.per_page = 36 -diff --git a/app/models/authentication.rb b/app/models/authentication.rb -index 91ecc8de..98a65a63 100644 ---- a/app/models/authentication.rb -+++ b/app/models/authentication.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class Authentication < ApplicationRecord - belongs_to :member - end -diff --git a/app/models/comment.rb b/app/models/comment.rb -index 62ebdde7..7b85f4c0 100644 ---- a/app/models/comment.rb -+++ b/app/models/comment.rb -@@ -1,6 +1,8 @@ -+# frozen_string_literal: true -+ - class Comment < ApplicationRecord - belongs_to :author, class_name: 'Member', inverse_of: :comments -- belongs_to :post -+ belongs_to :post, counter_cache: true - - scope :post_order, -> { reorder("created_at ASC") } # for display on post page - -diff --git a/app/models/concerns/finishable.rb b/app/models/concerns/finishable.rb -index 42fa4e73..6ff68e9c 100644 ---- a/app/models/concerns/finishable.rb -+++ b/app/models/concerns/finishable.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Finishable - extend ActiveSupport::Concern - -diff --git a/app/models/concerns/likeable.rb b/app/models/concerns/likeable.rb -index 9db3da6e..911317a6 100644 ---- a/app/models/concerns/likeable.rb -+++ b/app/models/concerns/likeable.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Likeable - extend ActiveSupport::Concern - -diff --git a/app/models/concerns/member_flickr.rb b/app/models/concerns/member_flickr.rb -index d5d591dc..363f74d9 100644 ---- a/app/models/concerns/member_flickr.rb -+++ b/app/models/concerns/member_flickr.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module MemberFlickr - extend ActiveSupport::Concern - -diff --git a/app/models/concerns/member_newsletter.rb b/app/models/concerns/member_newsletter.rb -index 882bac7c..8f92340c 100644 ---- a/app/models/concerns/member_newsletter.rb -+++ b/app/models/concerns/member_newsletter.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module MemberNewsletter - extend ActiveSupport::Concern - -diff --git a/app/models/concerns/open_farm_data.rb b/app/models/concerns/open_farm_data.rb -index e7d2306e..f051d43c 100644 ---- a/app/models/concerns/open_farm_data.rb -+++ b/app/models/concerns/open_farm_data.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module OpenFarmData - extend ActiveSupport::Concern - -diff --git a/app/models/concerns/ownable.rb b/app/models/concerns/ownable.rb -index 6cd40a2e..8dac572a 100644 ---- a/app/models/concerns/ownable.rb -+++ b/app/models/concerns/ownable.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Ownable - extend ActiveSupport::Concern - -diff --git a/app/models/concerns/photo_capable.rb b/app/models/concerns/photo_capable.rb -index f96258f8..b585d4b6 100644 ---- a/app/models/concerns/photo_capable.rb -+++ b/app/models/concerns/photo_capable.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module PhotoCapable - extend ActiveSupport::Concern - -diff --git a/app/models/concerns/predict_harvest.rb b/app/models/concerns/predict_harvest.rb -index 4ea24153..bd11fc11 100644 ---- a/app/models/concerns/predict_harvest.rb -+++ b/app/models/concerns/predict_harvest.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module PredictHarvest - extend ActiveSupport::Concern - -diff --git a/app/models/concerns/predict_planting.rb b/app/models/concerns/predict_planting.rb -index a38b3582..9f1aee58 100644 ---- a/app/models/concerns/predict_planting.rb -+++ b/app/models/concerns/predict_planting.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module PredictPlanting - extend ActiveSupport::Concern - -diff --git a/app/models/concerns/crop_search.rb b/app/models/concerns/search_crops.rb -similarity index 67% -rename from app/models/concerns/crop_search.rb -rename to app/models/concerns/search_crops.rb -index edeffe36..aaec7313 100644 ---- a/app/models/concerns/crop_search.rb -+++ b/app/models/concerns/search_crops.rb -@@ -1,15 +1,20 @@ --module CropSearch -+# frozen_string_literal: true -+ -+module SearchCrops - extend ActiveSupport::Concern - - included do - #################################### - # Elastic search configuration -- searchkick word_start: %i(name alternate_names scientific_names), -+ searchkick word_start: %i(name description alternate_names scientific_names), - case_sensitive: false, - merge_mappings: true, - mappings: { - properties: { -- created_at: { type: :integer } -+ created_at: { type: :integer }, -+ plantings_count: { type: :integer }, -+ harvests_count: { type: :integer }, -+ photos_count: { type: :integer } - } - } - -@@ -23,17 +28,19 @@ module CropSearch - def search_data - { - name: name, -+ description: description, - slug: 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, - # boost this crop for these members - planters_ids: plantings.pluck(:owner_id), - has_photos: photos.size.positive?, -- photo: default_photo&.thumbnail_url, -+ thumbnail_url: default_photo&.thumbnail_url, - scientific_name: default_scientific_name&.name, -- description: description, - created_at: created_at.to_i - } - end -diff --git a/app/models/concerns/search_harvests.rb b/app/models/concerns/search_harvests.rb -new file mode 100644 -index 00000000..cd6e481c ---- /dev/null -+++ b/app/models/concerns/search_harvests.rb -@@ -0,0 +1,49 @@ -+# frozen_string_literal: true -+ -+module SearchHarvests -+ extend ActiveSupport::Concern -+ -+ included do -+ searchkick merge_mappings: true, -+ mappings: { -+ properties: { -+ created_at: { type: :integer }, -+ harvests_count: { type: :integer }, -+ photos_count: { type: :integer }, -+ harvested_at: { type: :date } -+ } -+ } -+ -+ scope :search_import, -> { includes(:owner, :crop, :plant_part) } -+ -+ def search_data -+ { -+ slug: slug, -+ crop_id: crop_id, -+ crop_name: crop_name, -+ crop_slug: crop.slug, -+ has_photos: photos.size.positive?, -+ owner_id: owner_id, -+ owner_slug: owner_slug, -+ owner_login_name: owner_login_name, -+ photos_count: photos_count, -+ plant_part: plant_part&.name, -+ planting_id: planting_id, -+ quantity: quantity, -+ thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, -+ harvested_at: harvested_at, -+ created_at: created_at.to_i -+ } -+ end -+ -+ def self.homepage_records(limit) -+ search('*', -+ limit: limit, -+ where: { -+ photos_count: { gt: 0 } -+ }, -+ boost_by: [:created_at], -+ load: false) -+ end -+ end -+end -diff --git a/app/models/concerns/search_photos.rb b/app/models/concerns/search_photos.rb -new file mode 100644 -index 00000000..1715963a ---- /dev/null -+++ b/app/models/concerns/search_photos.rb -@@ -0,0 +1,29 @@ -+# frozen_string_literal: true -+ -+module SearchPhotos -+ extend ActiveSupport::Concern -+ -+ included do -+ searchkick merge_mappings: true, -+ mappings: { -+ properties: { -+ title: { type: :text }, -+ created_at: { type: :integer } -+ } -+ } -+ -+ # scope :search_import, -> { includes(:owner, :crops, :plantings, :harvests, :seeds, :posts) } -+ -+ def search_data -+ { -+ title: title, -+ crops: crops.map(&:id), -+ owner_id: owner_id, -+ owner_login_name: owner.login_name, -+ thumbnail_url: thumbnail_url, -+ fullsize_url: fullsize_url, -+ created_at: created_at.to_i -+ } -+ end -+ end -+end -diff --git a/app/models/concerns/search_plantings.rb b/app/models/concerns/search_plantings.rb -new file mode 100644 -index 00000000..bdf8dc78 ---- /dev/null -+++ b/app/models/concerns/search_plantings.rb -@@ -0,0 +1,56 @@ -+# frozen_string_literal: true -+ -+module SearchPlantings -+ extend ActiveSupport::Concern -+ -+ included do -+ searchkick merge_mappings: true, -+ mappings: { -+ properties: { -+ active: { type: :boolean }, -+ created_at: { type: :integer }, -+ harvests_count: { type: :integer }, -+ photos_count: { type: :integer }, -+ owner_location: { type: :text } -+ } -+ } -+ -+ scope :search_import, -> { includes(:owner, :crop) } -+ -+ def search_data -+ { -+ slug: slug, -+ active: active?, -+ crop_id: crop_id, -+ crop_name: crop.name, -+ crop_slug: crop.slug, -+ finished: finished?, -+ harvests_count: harvests.size, -+ has_photos: photos.size.positive?, -+ location: location, -+ owner_id: owner_id, -+ owner_location: owner_location, -+ owner_login_name: owner_login_name, -+ owner_slug: owner_slug, -+ percentage_grown: percentage_grown.to_i, -+ photos_count: photos.size, -+ planted_at: planted_at, -+ planted_from: planted_from, -+ quantity: quantity, -+ sunniness: sunniness, -+ thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, -+ created_at: created_at.to_i -+ } -+ end -+ -+ def self.homepage_records(limit) -+ search('*', -+ limit: limit, -+ where: { -+ photos_count: { gt: 0 } -+ }, -+ boost_by: [:created_at], -+ load: false) -+ end -+ end -+end -diff --git a/app/models/concerns/search_seeds.rb b/app/models/concerns/search_seeds.rb -new file mode 100644 -index 00000000..f5477936 ---- /dev/null -+++ b/app/models/concerns/search_seeds.rb -@@ -0,0 +1,57 @@ -+# frozen_string_literal: true -+ -+module SearchSeeds -+ extend ActiveSupport::Concern -+ -+ included do -+ searchkick merge_mappings: true, -+ mappings: { -+ properties: { -+ created_at: { type: :integer }, -+ plant_before: { type: :text }, -+ photos_count: { type: :integer }, -+ tradable_to: { type: :text } -+ } -+ } -+ -+ scope :search_import, -> { includes(:owner, :crop, :parent_planting) } -+ -+ def search_data -+ { -+ slug: slug, -+ crop_id: crop_id, -+ crop_name: crop.name, -+ crop_slug: crop.slug, -+ gmo: gmo, -+ has_photos: photos.size.positive?, -+ heirloom: heirloom, -+ organic: organic, -+ owner_id: owner_id, -+ owner_login_name: owner_login_name, -+ owner_location: owner_location, -+ owner_slug: owner_slug, -+ parent_planting: parent_planting, -+ photos_count: photos.size, -+ plant_before: plant_before&.to_s(:ymd), -+ quantity: quantity, -+ thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, -+ tradable_to: tradable_to, -+ tradable: tradable?, -+ finished: finished?, -+ location: owner.location, -+ created_at: created_at.to_i -+ } -+ end -+ -+ def self.homepage_records(limit) -+ search('*', -+ limit: limit, -+ where: { -+ finished: false, -+ tradable: true -+ }, -+ boost_by: [:created_at], -+ load: false) -+ end -+ end -+end -diff --git a/app/models/crop.rb b/app/models/crop.rb -index 78da0337..d983dff5 100644 ---- a/app/models/crop.rb -+++ b/app/models/crop.rb -@@ -1,8 +1,10 @@ -+# frozen_string_literal: true -+ - class Crop < ApplicationRecord - extend FriendlyId - include PhotoCapable - include OpenFarmData -- include CropSearch -+ include SearchCrops - - friendly_id :name, use: %i(slugged finders) - -diff --git a/app/models/crop_companion.rb b/app/models/crop_companion.rb -index 55d7c27a..3d09b194 100644 ---- a/app/models/crop_companion.rb -+++ b/app/models/crop_companion.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CropCompanion < ApplicationRecord - belongs_to :crop_a, class_name: :Crop - belongs_to :crop_b, class_name: :Crop -diff --git a/app/models/crop_post.rb b/app/models/crop_post.rb -index 5c520e3b..04c8e71e 100644 ---- a/app/models/crop_post.rb -+++ b/app/models/crop_post.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CropPost < ApplicationRecord - belongs_to :crop - belongs_to :post -diff --git a/app/models/csv_importer.rb b/app/models/csv_importer.rb -index d3b992ab..41ab325c 100644 ---- a/app/models/csv_importer.rb -+++ b/app/models/csv_importer.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CsvImporter - # used by db/seeds.rb and rake growstuff:import_crops - # CSV fields: -diff --git a/app/models/follow.rb b/app/models/follow.rb -index a70fd15f..1ee678ef 100644 ---- a/app/models/follow.rb -+++ b/app/models/follow.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class Follow < ApplicationRecord - belongs_to :follower, class_name: "Member", inverse_of: :follows - belongs_to :followed, class_name: "Member", inverse_of: :inverse_follows -diff --git a/app/models/forum.rb b/app/models/forum.rb -index 664af4f3..2ecae932 100644 ---- a/app/models/forum.rb -+++ b/app/models/forum.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class Forum < ApplicationRecord - extend FriendlyId - include Ownable -diff --git a/app/models/garden.rb b/app/models/garden.rb -index 865c11d6..1a3b4a34 100644 ---- a/app/models/garden.rb -+++ b/app/models/garden.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class Garden < ApplicationRecord - extend FriendlyId - include Geocodable -@@ -75,6 +77,8 @@ class Garden < ApplicationRecord - end - end - -+ def reindex; end -+ - protected - - def strip_blanks -diff --git a/app/models/garden_type.rb b/app/models/garden_type.rb -index b81789b6..bed371e2 100644 ---- a/app/models/garden_type.rb -+++ b/app/models/garden_type.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class GardenType < ApplicationRecord - extend FriendlyId - friendly_id :name, use: %i(slugged finders) -diff --git a/app/models/harvest.rb b/app/models/harvest.rb -index 4b40e56c..e0825c0a 100644 ---- a/app/models/harvest.rb -+++ b/app/models/harvest.rb -@@ -1,8 +1,11 @@ -+# frozen_string_literal: true -+ - class Harvest < ApplicationRecord - include ActionView::Helpers::NumberHelper - extend FriendlyId - include PhotoCapable - include Ownable -+ include SearchHarvests - - friendly_id :harvest_slug, use: %i(slugged finders) - -@@ -33,8 +36,8 @@ class Harvest < ApplicationRecord - - ## - ## Relationships -- belongs_to :crop -- belongs_to :plant_part -+ belongs_to :crop, counter_cache: true -+ belongs_to :plant_part, counter_cache: true - belongs_to :planting, optional: true, counter_cache: true - - ## -@@ -47,6 +50,9 @@ class Harvest < ApplicationRecord - ON (m.id=h2.owner_id AND harvests.id < h2.id)").where("h2 IS NULL") - } - -+ delegate :name, to: :crop, prefix: true -+ delegate :login_name, :slug, to: :owner, prefix: true -+ - ## - ## Validations - validates :crop, approved: true -diff --git a/app/models/like.rb b/app/models/like.rb -index f7490373..ed16065d 100644 ---- a/app/models/like.rb -+++ b/app/models/like.rb -@@ -1,6 +1,8 @@ -+# frozen_string_literal: true -+ - class Like < ApplicationRecord - belongs_to :member -- belongs_to :likeable, polymorphic: true, counter_cache: true -+ belongs_to :likeable, polymorphic: true, counter_cache: true, touch: true - validates :member, :likeable, presence: true - validates :member, uniqueness: { scope: :likeable } - end -diff --git a/app/models/member.rb b/app/models/member.rb -index 2762a602..5d373000 100644 ---- a/app/models/member.rb -+++ b/app/models/member.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class Member < ApplicationRecord - include Discard::Model - acts_as_messageable # messages can be sent to this model -diff --git a/app/models/notification.rb b/app/models/notification.rb -index 466fe73b..55e270d3 100644 ---- a/app/models/notification.rb -+++ b/app/models/notification.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class Notification < ApplicationRecord - belongs_to :sender, class_name: 'Member', inverse_of: :sent_notifications - belongs_to :recipient, class_name: 'Member', inverse_of: :notifications -diff --git a/app/models/photo.rb b/app/models/photo.rb -index 3bdbe255..7518cc80 100644 ---- a/app/models/photo.rb -+++ b/app/models/photo.rb -@@ -1,11 +1,14 @@ -+# frozen_string_literal: true -+ - class Photo < ApplicationRecord - include Likeable - include Ownable -+ include SearchPhotos - - PHOTO_CAPABLE = %w(Garden Planting Harvest Seed Post Crop).freeze - - has_many :photo_associations, foreign_key: :photo_id, dependent: :delete_all, inverse_of: :photo -- has_many :crops, through: :photo_associations -+ has_many :crops, through: :photo_associations, counter_cache: true - - validates :fullsize_url, url: true - validates :thumbnail_url, url: true -@@ -23,6 +26,8 @@ class Photo < ApplicationRecord - joins(:photo_associations).where(photo_associations: { photographable_type: model_name.to_s }) - } - -+ delegate :login_name, to: :owner, prefix: true -+ - # This is split into a side-effect free method and a side-effecting method - # for easier stubbing and testing. - def flickr_metadata -diff --git a/app/models/photo_association.rb b/app/models/photo_association.rb -index 89e495b0..647c1bb7 100644 ---- a/app/models/photo_association.rb -+++ b/app/models/photo_association.rb -@@ -1,7 +1,9 @@ -+# frozen_string_literal: true -+ - class PhotoAssociation < ApplicationRecord - belongs_to :photo, inverse_of: :photo_associations -- belongs_to :photographable, polymorphic: true -- belongs_to :crop, optional: true -+ belongs_to :photographable, polymorphic: true, touch: true -+ belongs_to :crop, optional: true, counter_cache: true - - validate :photo_and_item_have_same_owner - -@@ -9,10 +11,6 @@ class PhotoAssociation < ApplicationRecord - ## Triggers - before_save :set_crop - -- def item -- find_by!(photographable_id: photographable_id, photographable_type: photographable_type).photographable -- end -- - def self.item(item_id, item_type) - find_by!(photographable_id: item_id, photographable_type: item_type).photographable - end -@@ -28,7 +26,7 @@ class PhotoAssociation < ApplicationRecord - private - - def photo_and_item_have_same_owner -- return unless photographable_type != 'Crop' -+ return if photographable_type == 'Crop' - - errors.add(:photo, "must have same owner as item it links to") unless photographable.owner_id == photo.owner_id - end -diff --git a/app/models/plant_part.rb b/app/models/plant_part.rb -index 6fd57bff..e7e80830 100644 ---- a/app/models/plant_part.rb -+++ b/app/models/plant_part.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class PlantPart < ApplicationRecord - extend FriendlyId - friendly_id :name, use: %i(slugged finders) -diff --git a/app/models/planting.rb b/app/models/planting.rb -index 71646834..9f6b3949 100644 ---- a/app/models/planting.rb -+++ b/app/models/planting.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class Planting < ApplicationRecord - extend FriendlyId - include PhotoCapable -@@ -5,6 +7,8 @@ class Planting < ApplicationRecord - include Ownable - include PredictPlanting - include PredictHarvest -+ include SearchPlantings -+ - friendly_id :planting_slug, use: %i(slugged finders) - - # Constants -@@ -54,6 +58,7 @@ class Planting < ApplicationRecord - ## Delegations - delegate :name, :slug, :en_wikipedia_url, :default_scientific_name, :plantings_count, - to: :crop, prefix: true -+ delegate :login_name, :slug, :location, to: :owner, prefix: true - - delegate :annual?, :perennial?, :svg_icon, to: :crop - delegate :location, :longitude, :latitude, to: :garden -diff --git a/app/models/post.rb b/app/models/post.rb -index fd5abb13..73940422 100644 ---- a/app/models/post.rb -+++ b/app/models/post.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class Post < ApplicationRecord - extend FriendlyId - include Likeable -@@ -55,6 +57,8 @@ class Post < ApplicationRecord - subject - end - -+ def reindex; end -+ - private - - def update_crop_posts_association -diff --git a/app/models/role.rb b/app/models/role.rb -index cd985d11..b89db328 100644 ---- a/app/models/role.rb -+++ b/app/models/role.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class Role < ApplicationRecord - extend FriendlyId - friendly_id :name, use: %i(slugged finders) -diff --git a/app/models/scientific_name.rb b/app/models/scientific_name.rb -index b2da3320..94ab605b 100644 ---- a/app/models/scientific_name.rb -+++ b/app/models/scientific_name.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ScientificName < ApplicationRecord - belongs_to :crop - belongs_to :creator, class_name: 'Member', inverse_of: :created_scientific_names -diff --git a/app/models/seed.rb b/app/models/seed.rb -index cc1cecaa..9841fa19 100644 ---- a/app/models/seed.rb -+++ b/app/models/seed.rb -@@ -1,8 +1,11 @@ -+# frozen_string_literal: true -+ - class Seed < ApplicationRecord - extend FriendlyId - include PhotoCapable - include Finishable - include Ownable -+ include SearchSeeds - friendly_id :seed_slug, use: %i(slugged finders) - - TRADABLE_TO_VALUES = %w(nowhere locally nationally internationally).freeze -@@ -44,7 +47,9 @@ class Seed < ApplicationRecord - - # - # Delegations -- delegate :name, to: :crop -+ delegate :name, to: :crop, prefix: true -+ delegate :location, :latitude, :longitude, to: :owner -+ delegate :login_name, :slug, :location, to: :owner, prefix: true - - # - # Scopes -diff --git a/app/resources/api/v1/crop_resource.rb b/app/resources/api/v1/crop_resource.rb -index 8eac3209..abbf2258 100644 ---- a/app/resources/api/v1/crop_resource.rb -+++ b/app/resources/api/v1/crop_resource.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Api - module V1 - class CropResource < BaseResource -diff --git a/app/resources/api/v1/garden_resource.rb b/app/resources/api/v1/garden_resource.rb -index cffcb27f..4b4a32bb 100644 ---- a/app/resources/api/v1/garden_resource.rb -+++ b/app/resources/api/v1/garden_resource.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Api - module V1 - class GardenResource < BaseResource -diff --git a/app/resources/api/v1/harvest_resource.rb b/app/resources/api/v1/harvest_resource.rb -index c1ce0ae0..502bee5b 100644 ---- a/app/resources/api/v1/harvest_resource.rb -+++ b/app/resources/api/v1/harvest_resource.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Api - module V1 - class HarvestResource < BaseResource -diff --git a/app/resources/api/v1/member_resource.rb b/app/resources/api/v1/member_resource.rb -index 4013aeea..9a2731f2 100644 ---- a/app/resources/api/v1/member_resource.rb -+++ b/app/resources/api/v1/member_resource.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Api - module V1 - class MemberResource < BaseResource -diff --git a/app/resources/api/v1/photo_resource.rb b/app/resources/api/v1/photo_resource.rb -index 84c7eab1..6da294cd 100644 ---- a/app/resources/api/v1/photo_resource.rb -+++ b/app/resources/api/v1/photo_resource.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Api - module V1 - class PhotoResource < BaseResource -diff --git a/app/resources/api/v1/planting_resource.rb b/app/resources/api/v1/planting_resource.rb -index 1e41078f..0db7e40b 100644 ---- a/app/resources/api/v1/planting_resource.rb -+++ b/app/resources/api/v1/planting_resource.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Api - module V1 - class PlantingResource < BaseResource -diff --git a/app/resources/api/v1/seed_resource.rb b/app/resources/api/v1/seed_resource.rb -index e994ce1a..82dd53ee 100644 ---- a/app/resources/api/v1/seed_resource.rb -+++ b/app/resources/api/v1/seed_resource.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Api - module V1 - class SeedResource < BaseResource -diff --git a/app/resources/base_resource.rb b/app/resources/base_resource.rb -index 2d54fdf0..46de0ce5 100644 ---- a/app/resources/base_resource.rb -+++ b/app/resources/base_resource.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class BaseResource < JSONAPI::Resource - immutable - abstract -diff --git a/app/services/crop_search_service.rb b/app/services/crop_search_service.rb -index 645505e0..274d5a3c 100644 ---- a/app/services/crop_search_service.rb -+++ b/app/services/crop_search_service.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CropSearchService - # Crop.search(string) - def self.search(query, page: 1, per_page: 12, current_member: nil) -diff --git a/app/services/timeline_service.rb b/app/services/timeline_service.rb -index 8ed76508..328eb17d 100644 ---- a/app/services/timeline_service.rb -+++ b/app/services/timeline_service.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class TimelineService - def self.member_query(member) - query.where(owner_id: member.id) -diff --git a/app/validators/approved_validator.rb b/app/validators/approved_validator.rb -index 8a77fa2d..179bfef1 100644 ---- a/app/validators/approved_validator.rb -+++ b/app/validators/approved_validator.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ApprovedValidator < ActiveModel::EachValidator - def validate_each(record, attribute, _value) - record.errors[attribute] << (options[:message] || 'must be approved') unless record.crop.try(:approved?) -diff --git a/app/views/crops/_crop.html.haml b/app/views/crops/_crop.html.haml -index 9c763518..e32a933a 100644 ---- a/app/views/crops/_crop.html.haml -+++ b/app/views/crops/_crop.html.haml -@@ -6,7 +6,7 @@ - crop - .card-body - %h3.card-title -- %strong= link_to crop, crop -+ %strong= link_to crop.name, crop_path(slug: crop.slug) - = crop.default_scientific_name - .d-flex.justify-content-between - - if crop.annual? && crop.median_lifespan.present? -diff --git a/app/views/crops/_thumbnail.html.haml b/app/views/crops/_thumbnail.html.haml -index 948c59bb..29617b76 100644 ---- a/app/views/crops/_thumbnail.html.haml -+++ b/app/views/crops/_thumbnail.html.haml -@@ -1,12 +1,11 @@ - - cache crop do - .card.crop-thumbnail -- = link_to image_tag(crop_image_path(crop), -+ = link_to image_tag(crop.thumbnail_url ? crop.thumbnail_url : placeholder_image, - alt: crop.name, - class: 'img img-card'), -- crop -+ crop_path(slug: crop.slug) - - .text -- %h3.crop-name= link_to crop, crop -+ %h3.crop-name= link_to crop.name, crop_path(slug: crop.slug) - %h5.crop-sci-name --   -- = crop.scientific_names.first&.name -+ = crop.scientific_names.first -diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml -index 7fc08875..42741201 100644 ---- a/app/views/crops/index.html.haml -+++ b/app/views/crops/index.html.haml -@@ -22,8 +22,8 @@ - %h2= t('.title') - = will_paginate @crops - .index-cards -- - @crops.each do |crop| -- = render 'crops/thumbnail', crop: crop -+ - @crops.each do |c| -+ = render 'crops/thumbnail', crop: c - - = will_paginate @crops - -diff --git a/app/views/harvests/_card.html.haml b/app/views/harvests/_card.html.haml -index 0d51fbb4..55811bb2 100644 ---- a/app/views/harvests/_card.html.haml -+++ b/app/views/harvests/_card.html.haml -@@ -1,11 +1,13 @@ --.card -- = link_to harvest do -- = image_tag harvest_image_path(harvest), alt: harvest, class: 'img-card' -- .card-body -- %h5 -- = crop_icon(harvest.crop) -- %strong -- = link_to harvest.crop, harvest -- %span.badge.badge-pill= harvest.plant_part -- .card-footer -- .float-right=render 'members/tiny', member: harvest.owner -\ No newline at end of file -+- cache harvest do -+ .card -+ = link_to harvest do -+ = image_tag harvest.thumbnail_url ? harvest.thumbnail_url : placeholder_image, alt: harvest.crop_name, class: 'img-card' -+ .card-body -+ %h5 -+ %strong= link_to harvest.crop_name, harvest_path(slug: harvest.slug) -+ %span.badge.badge-pill= harvest.plant_part -+ .card-footer -+ .float-right -+ %span.chip.member-chip -+ = link_to member_path(slug: harvest.owner_slug) do -+ = harvest.owner_login_name -\ No newline at end of file -diff --git a/app/views/harvests/_harvest.haml b/app/views/harvests/_harvest.haml -index 7341875c..f6772516 100644 ---- a/app/views/harvests/_harvest.haml -+++ b/app/views/harvests/_harvest.haml -@@ -1,6 +1,4 @@ - - if local_assigns[:full] -- - cache harvest do -- = render 'harvests/card', harvest: harvest -+ = render 'harvests/card', harvest: harvest - - else -- - cache harvest do -- = render 'harvests/thumbnail', harvest: harvest -\ No newline at end of file -+ = render 'harvests/thumbnail', harvest: harvest -\ No newline at end of file -diff --git a/app/views/harvests/_thumbnail.html.haml b/app/views/harvests/_thumbnail.html.haml -index 8539d72d..5dfe125c 100644 ---- a/app/views/harvests/_thumbnail.html.haml -+++ b/app/views/harvests/_thumbnail.html.haml -@@ -1,9 +1,10 @@ --.card.harvest-thumbnail -- = link_to image_tag(harvest_image_path(harvest), -- alt: harvest, -- class: 'img img-card'), -- harvest -+- cache harvest do -+ .card.harvest-thumbnail -+ = link_to image_tag(harvest_image_path(harvest), -+ alt: harvest, -+ class: 'img img-card'), -+ harvest - -- .text -- %h3.harvest-plant-part= link_to harvest.plant_part, harvest -- %h5.harvest-crop= harvest.crop -+ .text -+ %h3.harvest-plant-part= link_to harvest.plant_part, harvest -+ %h5.harvest-crop= harvest.crop -diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml -index f2a5cb04..71c724c6 100644 ---- a/app/views/harvests/index.html.haml -+++ b/app/views/harvests/index.html.haml -@@ -29,8 +29,9 @@ - .badge.badge-success= link_to 'API Methods', '/api-docs' - .col-md-10 - %section -- %h2 -- = page_entries_info @harvests -+ %h2= page_entries_info @harvests - = will_paginate @harvests -- .index-cards=render @harvests, full: true -+ .index-cards -+ - @harvests.each do |h| -+ = render 'harvests/card', harvest: h - = will_paginate @harvests -diff --git a/app/views/harvests/index.rss.haml b/app/views/harvests/index.rss.haml -index f5682edf..7967b23e 100644 ---- a/app/views/harvests/index.rss.haml -+++ b/app/views/harvests/index.rss.haml -@@ -6,14 +6,12 @@ - %link= harvests_url - - @harvests.each do |harvest| - %item -- %title #{harvest.owner.login_name}'s #{harvest.crop.name} -- %pubdate= harvest.harvested_at.to_s(:rfc822) -+ %title #{harvest['owner_name']}'s #{harvest['crop_name']} -+ %pubdate= harvest['harvested_at'] - %description - :escaped --

Crop: #{harvest.crop ? harvest.crop : 'unknown' }

--

Quantity: #{harvest.quantity ? harvest.quantity : 'unknown' }

--

Harvested on: #{harvest.harvested_at ? harvest.harvested_at : 'unknown' }

-- :escaped_markdown -- #{ strip_tags harvest.description } -- %link= harvest_url(harvest) -- %guid= harvest_url(harvest) -+

Crop: #{harvest['crop_name']}

-+

Quantity: #{harvest['quantity'] ? harvest['quantity'] : 'unknown' }

-+

Harvested on: #{harvest['harvested_at'] ? harvest['harvested_at'] : 'unknown' }

-+ %link= harvest_url(slug: harvest['slug']) -+ %guid= harvest_url(slug: harvest['slug']) -diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml -index fe4b1492..17c25cd4 100644 ---- a/app/views/home/_crops.html.haml -+++ b/app/views/home/_crops.html.haml -@@ -1,16 +1,4 @@ - - cache cache_key_for(Crop, 'homepage'), expires_in: 1.day do - .index-cards -- - CropSearchService.random_with_photos(16).each do |crop| -- .card.crop-thumbnail -- = link_to crop_path(slug: crop['slug']) do -- = image_tag(crop['photo'], -- alt: crop['name'], -- class: 'img img-card') -- -- .text -- %h3.crop-name -- = link_to crop['name'], crop_path(slug: crop['slug']) -- %h5.crop-sci-name --   -- = crop['scientific_name'] -- -+ - CropSearchService.random_with_photos(16).each do |c| -+ = render 'crops/thumbnail', crop: c -\ No newline at end of file -diff --git a/app/views/home/_discuss.html.haml b/app/views/home/_discuss.html.haml -index 7954b536..96983207 100644 ---- a/app/views/home/_discuss.html.haml -+++ b/app/views/home/_discuss.html.haml -@@ -12,7 +12,7 @@ - %p.mb-2 - = truncate(strip_tags(post.body), length: 200) - %small -- = post.comments.size -+ = post.comments_count - comments - %p.text-right - = link_to "#{t('.view_all')} ยป", posts_path, class: 'btn btn-block' -diff --git a/app/views/home/_harvests.html.haml b/app/views/home/_harvests.html.haml -index cdf7aa58..7dadbbfb 100644 ---- a/app/views/home/_harvests.html.haml -+++ b/app/views/home/_harvests.html.haml -@@ -1,11 +1,12 @@ - %h2= t('.recently_harvested') --- Harvest.has_photos.recent.includes(:crop, :owner, :photos, :plant_part).limit(6).each do |harvest| -+- Harvest.homepage_records(6).each do |harvest| - - cache harvest do -- = link_to harvest, class: 'list-group-item list-group-item-action flex-column align-items-start' do -+ = link_to harvest_path(slug: harvest['slug']), class: 'list-group-item list-group-item-action flex-column align-items-start' do - .d-flex.w-100.justify-content-between.homepage--list-item - %div -- %h5= harvest.crop.name -- %span.badge.badge-success=harvest.plant_part -+ %h5= harvest['crop_name'] -+ %span.badge.badge-success=harvest['plant_part'] - %small.text-muted -- harvested by #{harvest.owner} -- %p.mb-2= image_tag harvest_image_path(harvest), width: 75, class: 'rounded shadow' -\ No newline at end of file -+ harvested by #{harvest['owner_name']} -+ %p.mb-2 -+ = image_tag harvest['thumbnail_url'], width: 75, class: 'rounded shadow' -\ No newline at end of file -diff --git a/app/views/home/_plantings.html.haml b/app/views/home/_plantings.html.haml -index 8d26fe45..a3bb79f7 100644 ---- a/app/views/home/_plantings.html.haml -+++ b/app/views/home/_plantings.html.haml -@@ -1,12 +1,11 @@ - %h2= t('.recently_planted') --- Planting.has_photos.recent.includes(:owner, :crop).limit(6).each do |planting| -- - cache planting do -- = link_to planting, class: 'list-group-item list-group-item-action flex-column align-items-start' do -- .d-flex.w-100.justify-content-between.homepage--list-item -- %p.mb-2 -- = image_tag planting_image_path(planting), width: 75, class: 'rounded shadow' -- .text-right -- %h5= planting.crop.name -- - if planting.planted_from.present? -- %span.badge.badge-success= planting.planted_from.pluralize -- %small.text-muted planted by #{planting.owner} -+- Planting.homepage_records(6).each do |planting| -+ = link_to planting_path(slug: planting['slug']), class: 'list-group-item list-group-item-action flex-column align-items-start' do -+ .d-flex.w-100.justify-content-between.homepage--list-item -+ %p.mb-2 -+ = image_tag planting['thumbnail_url'], width: 75, class: 'rounded shadow' -+ .text-right -+ %h5= planting['crop_name'] -+ - if planting['planted_from'].present? -+ %span.badge.badge-success= planting['planted_from'].pluralize -+ %small.text-muted planted by #{planting['owner_name']} -diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml -index 38ae29fd..bfb56295 100644 ---- a/app/views/home/_seeds.html.haml -+++ b/app/views/home/_seeds.html.haml -@@ -1,5 +1,5 @@ - - cache cache_key_for(Seed) do - %h2.text-center= t('home.seeds.title') - .index-cards -- - Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(6).each do |seed| -- = render 'seeds/card', seed: seed -+ - Seed.homepage_records(6).each do |s| -+ = render 'seeds/card', seed: s -diff --git a/app/views/layouts/_menu.haml b/app/views/layouts/_menu.haml -index eea460e0..3703f969 100644 ---- a/app/views/layouts/_menu.haml -+++ b/app/views/layouts/_menu.haml -@@ -5,7 +5,7 @@ - = link_to timeline_index_path, method: :get, class: 'nav-link text-white' do - = image_tag 'icons/notification.svg', class: 'img img-icon' - %li.nav-item -- = link_to member_gardens_path(member_slug: current_member.slug), class: 'nav-link text-white' do -+ = link_to member_gardens_path(current_member), class: 'nav-link text-white' do - = image_icon 'gardens' - %li.nav-item.dropdown - %a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#", role: "button"} -diff --git a/app/views/photos/_card.html.haml b/app/views/photos/_card.html.haml -index f073cbef..4b606c63 100644 ---- a/app/views/photos/_card.html.haml -+++ b/app/views/photos/_card.html.haml -@@ -1,10 +1,11 @@ - .card.photo-card{id: "photo-#{photo.id}"} -- = link_to image_tag(photo.source == 'flickr' ? photo.fullsize_url : photo.thumbnail_url, alt: photo.title, class: 'img img-card'), photo -+ = link_to photo_path(id: photo.id) do -+ = image_tag(photo.source == 'flickr' ? photo.fullsize_url : photo.thumbnail_url, alt: photo.title, class: 'img img-card') - .card-body - %h5.ellipsis - = photo_icon -- = link_to photo.title, photo -- %i by #{link_to photo.owner, photo.owner} -+ = link_to photo.title, photo_path(id: photo.id) -+ %i by #{link_to photo.owner_login_name, member_path(slug: photo.owner_login_name)} - - if photo.date_taken.present? - %small.text-muted - %time{datetime: photo.date_taken}= I18n.l(photo.date_taken.to_date) -diff --git a/app/views/plantings/_card.html.haml b/app/views/plantings/_card.html.haml -index e875b215..d9090899 100644 ---- a/app/views/plantings/_card.html.haml -+++ b/app/views/plantings/_card.html.haml -@@ -1,27 +1,14 @@ - - cache planting do -- .card.planting{class: planting.active? ? '' : 'card-finished'} -- = link_to planting do -- = image_tag planting_image_path(planting), class: 'img-card', alt: planting -- - if can? :edit, planting -- .planting-quick-actions -- .dropdown -- %a.planting-menu.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button", href: '#'} -- .dropdown-menu{"aria-labelledby" => "planting-menu"} -- = planting_edit_button(planting, classes: 'dropdown-item') -- = add_photo_button(planting, classes: 'dropdown-item') -- -- - if planting.active? -- = planting_finish_button(planting, classes: 'dropdown-item') -- = planting_harvest_button(planting, classes: 'dropdown-item') -- = planting_save_seeds_button(planting, classes: 'dropdown-item') -- -- - if can? :destroy, planting -- .dropdown-divider -- = delete_button(planting, classes: 'dropdown-item text-danger') -- = link_to planting do -+ .card.planting{class: planting.active ? '' : 'card-finished'} -+ = link_to planting_path(slug: planting.slug) do -+ = image_tag planting.thumbnail_url ? planting.thumbnail_url : placeholder_image, class: 'img-card', alt: planting.crop_name -+ = link_to planting_path(slug: planting.slug) do - .card-body.text-center -- %h4= planting.crop -+ %h4= planting.crop_name - .text-center= render 'plantings/badges', planting: planting - = render 'plantings/progress', planting: planting - .card-footer -- .float-right=render 'members/tiny', member: planting.owner -\ No newline at end of file -+ .float-right -+ %span.chip.member-chip -+ = link_to member_path(slug: planting.owner_slug) do -+ = planting.owner_login_name -\ No newline at end of file -diff --git a/app/views/plantings/_facts.haml b/app/views/plantings/_facts.haml -index b0f2a440..428c9f6d 100644 ---- a/app/views/plantings/_facts.haml -+++ b/app/views/plantings/_facts.haml -@@ -16,14 +16,14 @@ - unknown - - if planting.planted_at.present? - %span.planted_at -- =planting.planted_at.year -+ = planting.planted_at.year - - - if planting.finish_is_predicatable? - .card.fact-card - %h3 Progress - %strong #{planting.age_in_days}/#{planting.expected_lifespan} - %span days -- -+ - .card.fact-card{class: planting.quantity.present? ? '' : 'text-muted'} - %h3 - Quantity -diff --git a/app/views/plantings/_harvests.html.haml b/app/views/plantings/_harvests.html.haml -index aa3a0fd4..4f9aa933 100644 ---- a/app/views/plantings/_harvests.html.haml -+++ b/app/views/plantings/_harvests.html.haml -@@ -10,11 +10,11 @@ - = link_to harvests_path(return: 'planting', harvest: {crop_id: @planting.crop_id, planting_id: @planting.id, plant_part_id: plant_part.id}), method: :post, class: 'dropdown-item' do - = plant_part.name - --- if planting.harvests.empty? -+- if @planting.harvests.empty? - %p No harvests recorded - - if !planting.finished? && can?(:edit, planting) && can?(:create, Harvest) - %p Record your harvests here to improve crop predictions, and you'll be able to compare with your garden next season. - - else - .index-cards -- - planting.harvests.order(created_at: :desc).includes(:crop).each do |harvest| -+ - @planting.harvests.each do |harvest| - = render 'harvests/thumbnail', harvest: harvest -diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml -index c1f21c44..b7f3a468 100644 ---- a/app/views/plantings/index.html.haml -+++ b/app/views/plantings/index.html.haml -@@ -10,7 +10,6 @@ - %h1.display-2.text-center - = planting_icon - = title('plantings', @owner, @crop, @planting) -- - .row - .col-md-2 - = render 'layouts/nav', model: Planting -@@ -20,9 +19,9 @@ - include finished plantings - %hr - - if @owner.present? -- = render @owner -+ = render @owner, cached: true - - if @crop.present? -- = render @crop -+ = render @crop, cached: true - - %section.open-data - %h2 Open Data -@@ -40,7 +39,6 @@ - %h2= page_entries_info @plantings - = will_paginate @plantings - .index-cards -- - @plantings.each do |planting| -- = render planting, full: true -- -+ - @plantings.each do |p| -+ = render 'plantings/card', planting: p - = will_paginate @plantings -diff --git a/app/views/plantings/index.rss.haml b/app/views/plantings/index.rss.haml -index 94eb026d..036e59fd 100644 ---- a/app/views/plantings/index.rss.haml -+++ b/app/views/plantings/index.rss.haml -@@ -6,15 +6,15 @@ - %link= plantings_url - - @plantings.each do |planting| - %item -- %title #{planting.crop} in #{planting.location} -- %pubdate= planting.created_at.to_s(:rfc822) -+ %title #{planting['crop']} in #{planting['location']} -+ %pubdate= planting['created_at'].to_s(:rfc822) - %description - :escaped --

Quantity: #{planting.quantity ? planting.quantity : 'unknown' }

--

Planted on: #{planting.planted_at ? planting.planted_at : 'unknown' }

--

Sunniness: #{planting.sunniness ? planting.sunniness : 'unknown' }

--

Planted from: #{planting.planted_from ? planting.planted_from : 'unknown' }

-+

Quantity: #{planting['quantity'] ? planting['quantity'] : 'unknown' }

-+

Planted on: #{planting['planted_at'] ? planting['planted_at'] : 'unknown' }

-+

Sunniness: #{planting['sunniness'] ? planting['sunniness'] : 'unknown' }

-+

Planted from: #{planting['planted_from'] ? planting['planted_from'] : 'unknown' }

- :escaped_markdown -- #{ strip_tags planting.description } -- %link= planting_url(planting) -- %guid= planting_url(planting) -+ #{ strip_tags planting['description'] } -+ %link= planting_url(slug: planting['slug']) -+ %guid= planting_url(slug: planting['slug']) -diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml -index db8a72da..6b4cd852 100644 ---- a/app/views/seeds/_card.html.haml -+++ b/app/views/seeds/_card.html.haml -@@ -1,17 +1,17 @@ - - cache seed do -- .card.seed-card{class: seed.active? ? '' : 'card-finished'} -+ .card.seed-card{class: seed.finished ? 'card-finished' : ''} - = link_to seed do -- = image_tag(seed_image_path(seed), alt: seed, class: 'img-card') -+ = image_tag(seed.thumbnail_url ? seed.thumbnail_url : placeholder_image, alt: seed.name, class: 'img-card') - .text -- = render 'members/tiny', member: seed.owner -+ %span.chip.member-chip -+ = seed.owner_login_name - .card-body - .card-title -- = crop_icon(seed.crop) -- = link_to seed.crop, seed -- - if seed.tradable? -+ = link_to seed.crop_name, seed_path(slug: seed.slug) -+ - if seed.tradable - .text-muted - = icon 'fas', 'map' - Will trade #{seed.tradable_to} - .badge.badge-pill.badge-location - = icon 'fas', 'map-marker' -- = truncate(seed.owner.location, length: 20, separator: ' ', omission: '... ') -\ No newline at end of file -+ = truncate(seed.owner_location, length: 20, separator: ' ', omission: '... ') -\ No newline at end of file -diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml -index e0d17efe..47e34927 100644 ---- a/app/views/seeds/index.html.haml -+++ b/app/views/seeds/index.html.haml -@@ -38,9 +38,7 @@ - = will_paginate @seeds - - .index-cards -- - @seeds.each do |seed| -- = render 'seeds/card', seed: seed -+ - @seeds.each do |s| -+ = render 'seeds/card', seed: s - - = will_paginate @seeds -- -- -diff --git a/app/views/seeds/index.rss.haml b/app/views/seeds/index.rss.haml -index b2044de6..0d128c2f 100644 ---- a/app/views/seeds/index.rss.haml -+++ b/app/views/seeds/index.rss.haml -@@ -6,20 +6,17 @@ - %link= seeds_url - - @seeds.each do |seed| - %item -- %title #{seed.owner}'s #{seed.crop} seeds -- %pubdate= seed.created_at.to_s(:rfc822) -+ %title #{seed['owner_name']}'s #{seed['crop_name']} seeds -+ %pubdate= seed['created_at'].to_s(:rfc822) - %description - :escaped --

Quantity: #{seed.quantity ? seed.quantity : 'unknown' }

--

Plant before: #{seed.plant_before ? seed.plant_before : 'unknown' }

--

Organic? #{seed.organic}

--

GMO? #{seed.gmo}

--

Heirloom? #{seed.heirloom}

-- - if seed.tradable? -- %p -- Will trade #{seed.tradable_to} from #{seed.owner.location ? seed.owner.location : 'unknown location'} -- -- :escaped_markdown -- #{ strip_tags seed.description } -- %link= seed_url(seed) -- %guid= seed_url(seed) -+

Quantity: #{seed['quantity'] ? seed['quantity'] : 'unknown' }

-+

Plant before: #{seed['plant_before'] ? seed['plant_before'] : 'unknown' }

-+

Organic? #{seed['organic']}

-+

GMO? #{seed['gmo']}

-+

Heirloom? #{seed['heirloom']}

-+ - if seed['tradeable'] -+ :escaped -+

Will trade #{seed['tradable_to']} from #{seed['location'] ? seed['location'] : 'unknown location'}

-+ %link= seed_url(slug: seed['slug']) -+ %guid= seed_url(slug: seed['slug']) -diff --git a/config.rb b/config.rb -index 214d25ef..328f8a9d 100644 ---- a/config.rb -+++ b/config.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Require any additional compass plugins here. - # Set this to the root of your project when deployed: - http_path = "/" -diff --git a/config/application.rb b/config/application.rb -index a42ae3ba..b34bc36f 100644 ---- a/config/application.rb -+++ b/config/application.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require_relative 'boot' - - require 'rails/all' -diff --git a/config/boot.rb b/config/boot.rb -index 4423c97f..73bf2c9b 100644 ---- a/config/boot.rb -+++ b/config/boot.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) - - require 'bundler/setup' # Set up gems listed in the Gemfile. -diff --git a/config/compass.rb b/config/compass.rb -index 2b22d5d7..81dc9bdc 100644 ---- a/config/compass.rb -+++ b/config/compass.rb -@@ -1,2 +1,4 @@ -+# frozen_string_literal: true -+ - # Require any additional compass plugins here. - project_type = :rails -diff --git a/config/environment.rb b/config/environment.rb -index 426333bb..d5abe558 100644 ---- a/config/environment.rb -+++ b/config/environment.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Load the Rails application. - require_relative 'application' - -diff --git a/config/environments/development.rb b/config/environments/development.rb -index 46106e08..caaf7fcd 100644 ---- a/config/environments/development.rb -+++ b/config/environments/development.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - -diff --git a/config/environments/production.rb b/config/environments/production.rb -index 6ffdc773..882d7a46 100644 ---- a/config/environments/production.rb -+++ b/config/environments/production.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - -diff --git a/config/environments/test.rb b/config/environments/test.rb -index 2a0efb6b..8c31b699 100644 ---- a/config/environments/test.rb -+++ b/config/environments/test.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - -diff --git a/config/factory_bot.rb b/config/factory_bot.rb -index 43d50d52..e4925f2a 100644 ---- a/config/factory_bot.rb -+++ b/config/factory_bot.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - ActionDispatch::Callbacks.after do - # Reload the factories - return unless Rails.env.development? || Rails.env.test? -diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb -index 89d2efab..f4556db3 100644 ---- a/config/initializers/application_controller_renderer.rb -+++ b/config/initializers/application_controller_renderer.rb -@@ -1,3 +1,4 @@ -+# frozen_string_literal: true - # Be sure to restart your server when you modify this file. - - # ActiveSupport::Reloader.to_prepare do -diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb -index 60484d4a..c3da5a1a 100644 ---- a/config/initializers/assets.rb -+++ b/config/initializers/assets.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Be sure to restart your server when you modify this file. - - # Version of your assets, change this if you want to expire all your assets. -diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb -index 59385cdf..d0f0d3b5 100644 ---- a/config/initializers/backtrace_silencers.rb -+++ b/config/initializers/backtrace_silencers.rb -@@ -1,3 +1,4 @@ -+# frozen_string_literal: true - # Be sure to restart your server when you modify this file. - - # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. -diff --git a/config/initializers/comfortable_mexican_sofa.rb b/config/initializers/comfortable_mexican_sofa.rb -index dc8148fd..80dce601 100644 ---- a/config/initializers/comfortable_mexican_sofa.rb -+++ b/config/initializers/comfortable_mexican_sofa.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - ComfortableMexicanSofa.configure do |config| - # Title of the admin area - # config.cms_title = 'ComfortableMexicanSofa CMS Engine' -diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb -index d3bcaa5e..497f5667 100644 ---- a/config/initializers/content_security_policy.rb -+++ b/config/initializers/content_security_policy.rb -@@ -1,3 +1,4 @@ -+# frozen_string_literal: true - # Be sure to restart your server when you modify this file. - - # Define an application-wide content security policy -diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb -index 5a6a32d3..ee8dff9c 100644 ---- a/config/initializers/cookies_serializer.rb -+++ b/config/initializers/cookies_serializer.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Be sure to restart your server when you modify this file. - - # Specify a serializer for the signed and encrypted cookie jars. -diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb -index 974551c9..1512d8f0 100644 ---- a/config/initializers/devise.rb -+++ b/config/initializers/devise.rb -@@ -1,4 +1,6 @@ --# rubocop:disable Metrics/LineLength -+# frozen_string_literal: true -+ -+# rubocop:disable Layout/LineLength - # Use this hook to configure devise mailer, warden hooks and so forth. - # Many of these configuration options can be set straight in your model. - Devise.setup do |config| -@@ -236,4 +238,4 @@ Devise.setup do |config| - # 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' - end --# rubocop:enable Metrics/LineLength -+# rubocop:enable Layout/LineLength -diff --git a/config/initializers/escaped_markdown.rb b/config/initializers/escaped_markdown.rb -index 87837b0c..6cad3bdf 100644 ---- a/config/initializers/escaped_markdown.rb -+++ b/config/initializers/escaped_markdown.rb -@@ -1 +1,3 @@ -+# frozen_string_literal: true -+ - require 'haml/filters/escaped_markdown' -diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb -index 4a994e1e..7a4f47b4 100644 ---- a/config/initializers/filter_parameter_logging.rb -+++ b/config/initializers/filter_parameter_logging.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Be sure to restart your server when you modify this file. - - # Configure sensitive parameters which will be filtered from the log file. -diff --git a/config/initializers/friendly_id.rb b/config/initializers/friendly_id.rb -index 3a88f87b..90586aa8 100644 ---- a/config/initializers/friendly_id.rb -+++ b/config/initializers/friendly_id.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # FriendlyId Global Configuration - # - # Use this to set up shared configuration options for your entire application. -diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb -index 1a2f76e5..ef916e73 100644 ---- a/config/initializers/geocoder.rb -+++ b/config/initializers/geocoder.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'geocodable' - - Geocoder.configure( -diff --git a/config/initializers/growstuff_markdown.rb b/config/initializers/growstuff_markdown.rb -index a7f6781b..901237fb 100644 ---- a/config/initializers/growstuff_markdown.rb -+++ b/config/initializers/growstuff_markdown.rb -@@ -1 +1,3 @@ -+# frozen_string_literal: true -+ - require 'haml/filters/growstuff_markdown' -diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb -index 03943153..39ff77ae 100644 ---- a/config/initializers/inflections.rb -+++ b/config/initializers/inflections.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Be sure to restart your server when you modify this file. - - # Add new inflection rules using the following format. Inflections -diff --git a/config/initializers/jsonapi_resources.rb b/config/initializers/jsonapi_resources.rb -index 1a17dfc0..d4ddadb4 100644 ---- a/config/initializers/jsonapi_resources.rb -+++ b/config/initializers/jsonapi_resources.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - JSONAPI.configure do |config| - # built in paginators are :none, :offset, :paged - config.default_paginator = :offset -diff --git a/config/initializers/leaflet.rb b/config/initializers/leaflet.rb -index 510a9707..3a8c09b6 100644 ---- a/config/initializers/leaflet.rb -+++ b/config/initializers/leaflet.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - Leaflet.tile_layer = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' - Leaflet.attribution = '© OpenStreetMap contributors, CC-BY-SA' - Leaflet.max_zoom = 18 -diff --git a/config/initializers/mailboxer.rb b/config/initializers/mailboxer.rb -index 6f1b0fa7..b43a6151 100644 ---- a/config/initializers/mailboxer.rb -+++ b/config/initializers/mailboxer.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - Mailboxer.setup do |config| - # Configures if your application uses or not email sending for Notifications and Messages - config.uses_emails = true -diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb -index dc189968..6e1d16f0 100644 ---- a/config/initializers/mime_types.rb -+++ b/config/initializers/mime_types.rb -@@ -1,3 +1,4 @@ -+# frozen_string_literal: true - # Be sure to restart your server when you modify this file. - - # Add new mime types for use in respond_to blocks: -diff --git a/config/initializers/new_framework_defaults_5_1.rb b/config/initializers/new_framework_defaults_5_1.rb -index 9010abd5..b33ee806 100644 ---- a/config/initializers/new_framework_defaults_5_1.rb -+++ b/config/initializers/new_framework_defaults_5_1.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Be sure to restart your server when you modify this file. - # - # This file contains migration options to ease your Rails 5.1 upgrade. -diff --git a/config/initializers/new_framework_defaults_5_2.rb b/config/initializers/new_framework_defaults_5_2.rb -index c383d072..7df9ce8f 100644 ---- a/config/initializers/new_framework_defaults_5_2.rb -+++ b/config/initializers/new_framework_defaults_5_2.rb -@@ -1,3 +1,4 @@ -+# frozen_string_literal: true - # Be sure to restart your server when you modify this file. - # - # This file contains migration options to ease your Rails 5.2 upgrade. -diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb -index 160efb10..940d84a4 100644 ---- a/config/initializers/omniauth.rb -+++ b/config/initializers/omniauth.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - Rails.application.config.middleware.use OmniAuth::Builder do - provider :twitter, ENV['GROWSTUFF_TWITTER_KEY'], ENV['GROWSTUFF_TWITTER_SECRET'] - provider :flickr, ENV['GROWSTUFF_FLICKR_KEY'], ENV['GROWSTUFF_FLICKR_SECRET'] -diff --git a/config/initializers/rswag_api.rb b/config/initializers/rswag_api.rb -index 3c027ffd..307807a9 100644 ---- a/config/initializers/rswag_api.rb -+++ b/config/initializers/rswag_api.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - Rswag::Api.configure do |c| - # Specify a root folder where Swagger JSON files are located - # This is used by the Swagger middleware to serve requests for API descriptions -diff --git a/config/initializers/rswag_ui.rb b/config/initializers/rswag_ui.rb -index 4d7adbaa..8b632a43 100644 ---- a/config/initializers/rswag_ui.rb -+++ b/config/initializers/rswag_ui.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - Rswag::Ui.configure do |c| - # List the Swagger endpoints that you want to be documented through the swagger-ui - # The first parameter is the path (absolute or relative to the UI host) to the corresponding -diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb -index 9fc73901..26a833e0 100644 ---- a/config/initializers/session_store.rb -+++ b/config/initializers/session_store.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Be sure to restart your server when you modify this file. - - Rails.application.config.session_store :cookie_store, key: '_growstuff_session' -diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb -index 4dab98d1..15990b73 100644 ---- a/config/initializers/sidekiq.rb -+++ b/config/initializers/sidekiq.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # config/initializers/sidekiq.rb - - Sidekiq.configure_server do |config| -diff --git a/config/initializers/swagger.rb b/config/initializers/swagger.rb -index 0bdadefc..830a9a36 100644 ---- a/config/initializers/swagger.rb -+++ b/config/initializers/swagger.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - Jsonapi::Swagger.config do |config| - config.use_rswag = false - config.version = '2.0' -diff --git a/config/initializers/time_formats.rb b/config/initializers/time_formats.rb -index 3f3adf45..c56b40be 100644 ---- a/config/initializers/time_formats.rb -+++ b/config/initializers/time_formats.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - Time::DATE_FORMATS[:default] = '%B %d, %Y at %H:%M' - Date::DATE_FORMATS[:default] = "%B %d, %Y" - -diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb -index bffab6c8..3d5ac255 100644 ---- a/config/initializers/wrap_parameters.rb -+++ b/config/initializers/wrap_parameters.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Be sure to restart your server when you modify this file. - - # This file contains settings for ActionController::ParamsWrapper which -diff --git a/config/locales/en.yml b/config/locales/en.yml -index adc90fd0..fccdaf45 100644 ---- a/config/locales/en.yml -+++ b/config/locales/en.yml -@@ -125,7 +125,7 @@ en: - title: - crop_harvests: Everyone's %{crop} harvests - default: Everyone's harvests -- owner_harvests: "%{owner} harvests" -+ owner_harvests: "%{owner}'s harvests" - planting_harvests: Harvests from %{planting} - updated: Harvest was successfully updated. - home: -diff --git a/config/routes.rb b/config/routes.rb -index 7efb4d79..5244ed3b 100644 ---- a/config/routes.rb -+++ b/config/routes.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - Rails.application.routes.draw do - mount Rswag::Ui::Engine => '/api-docs' - mount Rswag::Api::Engine => '/api-docs' -@@ -26,11 +28,11 @@ Rails.application.routes.draw do - resources :photos, only: :index - end - -- resources :gardens, concerns: :has_photos do -+ resources :gardens, concerns: :has_photos, param: :slug do - get 'timeline' => 'charts/gardens#timeline', constraints: { format: 'json' } - end - -- resources :plantings, concerns: :has_photos do -+ resources :plantings, concerns: :has_photos, param: :slug do - resources :harvests - resources :seeds - collection do -@@ -38,12 +40,12 @@ Rails.application.routes.draw do - end - end - -- resources :seeds, concerns: :has_photos do -- resources :plantings -+ resources :seeds, concerns: :has_photos, param: :slug do -+ get 'plantings' => 'plantings#index' - get 'crop/:crop' => 'seeds#index', as: 'seeds_by_crop', on: :collection - end - -- resources :harvests, concerns: :has_photos do -+ resources :harvests, concerns: :has_photos, param: :slug do - get 'crop/:crop' => 'harvests#index', as: 'harvests_by_crop', on: :collection - end - -diff --git a/config/setup_load_paths.rb b/config/setup_load_paths.rb -index b78f9aff..36e63028 100644 ---- a/config/setup_load_paths.rb -+++ b/config/setup_load_paths.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - if ENV['MY_RUBY_HOME']&.include?('rvm') - begin - require 'rvm' -diff --git a/config/spring.rb b/config/spring.rb -index c9119b40..ff5ba06b 100644 ---- a/config/spring.rb -+++ b/config/spring.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - %w( - .ruby-version - .rbenv-vars -diff --git a/config/unicorn.rb b/config/unicorn.rb -index fa76bae3..c4218569 100644 ---- a/config/unicorn.rb -+++ b/config/unicorn.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # from https://blog.heroku.com/archives/2013/2/27/unicorn_rails - worker_processes 3 - timeout 30 -diff --git a/db/migrate/20120903092956_devise_create_users.rb b/db/migrate/20120903092956_devise_create_users.rb -index 62d84f3d..08d044fd 100644 ---- a/db/migrate/20120903092956_devise_create_users.rb -+++ b/db/migrate/20120903092956_devise_create_users.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class DeviseCreateUsers < ActiveRecord::Migration[4.2] - def change - create_table(:users) do |t| -diff --git a/db/migrate/20120903112806_add_username_to_users.rb b/db/migrate/20120903112806_add_username_to_users.rb -index 2df3aa56..f27c39cd 100644 ---- a/db/migrate/20120903112806_add_username_to_users.rb -+++ b/db/migrate/20120903112806_add_username_to_users.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddUsernameToUsers < ActiveRecord::Migration[4.2] - def change - add_column :users, :username, :string -diff --git a/db/migrate/20121001212604_create_crops.rb b/db/migrate/20121001212604_create_crops.rb -index 6e6fbcc2..4c2832f3 100644 ---- a/db/migrate/20121001212604_create_crops.rb -+++ b/db/migrate/20121001212604_create_crops.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateCrops < ActiveRecord::Migration[4.2] - def change - create_table :crops do |t| -diff --git a/db/migrate/20121003190731_require_system_name_for_crops.rb b/db/migrate/20121003190731_require_system_name_for_crops.rb -index 7989fcec..1731554c 100644 ---- a/db/migrate/20121003190731_require_system_name_for_crops.rb -+++ b/db/migrate/20121003190731_require_system_name_for_crops.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class RequireSystemNameForCrops < ActiveRecord::Migration[4.2] - def up - change_table :crops do |t| -diff --git a/db/migrate/20121027035231_add_slug_to_crops.rb b/db/migrate/20121027035231_add_slug_to_crops.rb -index d360b4a4..fb31e562 100644 ---- a/db/migrate/20121027035231_add_slug_to_crops.rb -+++ b/db/migrate/20121027035231_add_slug_to_crops.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddSlugToCrops < ActiveRecord::Migration[4.2] - def change - add_column :crops, :slug, :string -diff --git a/db/migrate/20121105032913_create_gardens.rb b/db/migrate/20121105032913_create_gardens.rb -index e6c7834e..41cee244 100644 ---- a/db/migrate/20121105032913_create_gardens.rb -+++ b/db/migrate/20121105032913_create_gardens.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateGardens < ActiveRecord::Migration[4.2] - def change - create_table :gardens do |t| -diff --git a/db/migrate/20121106101718_add_slug_to_users.rb b/db/migrate/20121106101718_add_slug_to_users.rb -index 5840e09d..599eb29c 100644 ---- a/db/migrate/20121106101718_add_slug_to_users.rb -+++ b/db/migrate/20121106101718_add_slug_to_users.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddSlugToUsers < ActiveRecord::Migration[4.2] - def change - add_column :users, :slug, :string -diff --git a/db/migrate/20121107012827_create_scientific_names.rb b/db/migrate/20121107012827_create_scientific_names.rb -index 0e6b179f..bbef3d1b 100644 ---- a/db/migrate/20121107012827_create_scientific_names.rb -+++ b/db/migrate/20121107012827_create_scientific_names.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateScientificNames < ActiveRecord::Migration[4.2] - def change - create_table :scientific_names do |t| -diff --git a/db/migrate/20121108105440_create_updates.rb b/db/migrate/20121108105440_create_updates.rb -index 3caacb74..35ded8d6 100644 ---- a/db/migrate/20121108105440_create_updates.rb -+++ b/db/migrate/20121108105440_create_updates.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateUpdates < ActiveRecord::Migration[4.2] - def change - create_table :updates do |t| -diff --git a/db/migrate/20121109130033_add_creation_index_to_updates.rb b/db/migrate/20121109130033_add_creation_index_to_updates.rb -index 57c24d55..30652d54 100644 ---- a/db/migrate/20121109130033_add_creation_index_to_updates.rb -+++ b/db/migrate/20121109130033_add_creation_index_to_updates.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddCreationIndexToUpdates < ActiveRecord::Migration[4.2] - def change - add_index :updates, %i(created_at user_id) -diff --git a/db/migrate/20121203034745_add_tos_agreement_to_users.rb b/db/migrate/20121203034745_add_tos_agreement_to_users.rb -index 31354ea5..466d8c45 100644 ---- a/db/migrate/20121203034745_add_tos_agreement_to_users.rb -+++ b/db/migrate/20121203034745_add_tos_agreement_to_users.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddTosAgreementToUsers < ActiveRecord::Migration[4.2] - def change - add_column :users, :tos_agreement, :boolean -diff --git a/db/migrate/20121214224227_add_slug_to_updates.rb b/db/migrate/20121214224227_add_slug_to_updates.rb -index 78d25ef2..e0038dba 100644 ---- a/db/migrate/20121214224227_add_slug_to_updates.rb -+++ b/db/migrate/20121214224227_add_slug_to_updates.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddSlugToUpdates < ActiveRecord::Migration[4.2] - def change - add_column :updates, :slug, :string -diff --git a/db/migrate/20121219022554_create_plantings.rb b/db/migrate/20121219022554_create_plantings.rb -index d586e242..f618875d 100644 ---- a/db/migrate/20121219022554_create_plantings.rb -+++ b/db/migrate/20121219022554_create_plantings.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreatePlantings < ActiveRecord::Migration[4.2] - def change - create_table :plantings do |t| -diff --git a/db/migrate/20130113045802_rename_updates_to_posts.rb b/db/migrate/20130113045802_rename_updates_to_posts.rb -index 6329df2b..fecca7c3 100644 ---- a/db/migrate/20130113045802_rename_updates_to_posts.rb -+++ b/db/migrate/20130113045802_rename_updates_to_posts.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class RenameUpdatesToPosts < ActiveRecord::Migration[4.2] - def change - rename_table :updates, :posts -diff --git a/db/migrate/20130113060852_rename_users_to_members.rb b/db/migrate/20130113060852_rename_users_to_members.rb -index bb248186..a278a306 100644 ---- a/db/migrate/20130113060852_rename_users_to_members.rb -+++ b/db/migrate/20130113060852_rename_users_to_members.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class RenameUsersToMembers < ActiveRecord::Migration[4.2] - def change - rename_table :users, :members -diff --git a/db/migrate/20130113081521_rename_post_member_to_author.rb b/db/migrate/20130113081521_rename_post_member_to_author.rb -index a1658925..6cb4ae04 100644 ---- a/db/migrate/20130113081521_rename_post_member_to_author.rb -+++ b/db/migrate/20130113081521_rename_post_member_to_author.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class RenamePostMemberToAuthor < ActiveRecord::Migration[4.2] - def change - rename_column :posts, :member_id, :author_id -diff --git a/db/migrate/20130113095802_rename_garden_member_to_owner.rb b/db/migrate/20130113095802_rename_garden_member_to_owner.rb -index ea6bd4c7..4ebd10d0 100644 ---- a/db/migrate/20130113095802_rename_garden_member_to_owner.rb -+++ b/db/migrate/20130113095802_rename_garden_member_to_owner.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class RenameGardenMemberToOwner < ActiveRecord::Migration[4.2] - def change - rename_column :gardens, :member_id, :owner_id -diff --git a/db/migrate/20130118031942_add_description_to_gardens.rb b/db/migrate/20130118031942_add_description_to_gardens.rb -index f8eb0a44..e846901e 100644 ---- a/db/migrate/20130118031942_add_description_to_gardens.rb -+++ b/db/migrate/20130118031942_add_description_to_gardens.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddDescriptionToGardens < ActiveRecord::Migration[4.2] - def change - add_column :gardens, :description, :text -diff --git a/db/migrate/20130118043431_add_slug_to_plantings.rb b/db/migrate/20130118043431_add_slug_to_plantings.rb -index c4e5d434..5f451a83 100644 ---- a/db/migrate/20130118043431_add_slug_to_plantings.rb -+++ b/db/migrate/20130118043431_add_slug_to_plantings.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddSlugToPlantings < ActiveRecord::Migration[4.2] - def change - add_column :plantings, :slug, :string -diff --git a/db/migrate/20130206033956_create_comments.rb b/db/migrate/20130206033956_create_comments.rb -index 0c4663ec..894da776 100644 ---- a/db/migrate/20130206033956_create_comments.rb -+++ b/db/migrate/20130206033956_create_comments.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateComments < ActiveRecord::Migration[4.2] - def change - create_table :comments do |t| -diff --git a/db/migrate/20130206051328_add_show_email_to_member.rb b/db/migrate/20130206051328_add_show_email_to_member.rb -index 3185b137..de734d58 100644 ---- a/db/migrate/20130206051328_add_show_email_to_member.rb -+++ b/db/migrate/20130206051328_add_show_email_to_member.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddShowEmailToMember < ActiveRecord::Migration[4.2] - def change - add_column :members, :show_email, :boolean -diff --git a/db/migrate/20130208034248_require_fields_for_comments.rb b/db/migrate/20130208034248_require_fields_for_comments.rb -index da847671..eb4ca646 100644 ---- a/db/migrate/20130208034248_require_fields_for_comments.rb -+++ b/db/migrate/20130208034248_require_fields_for_comments.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class RequireFieldsForComments < ActiveRecord::Migration[4.2] - def up - change_table :comments do |t| -diff --git a/db/migrate/20130212001748_add_geo_to_members.rb b/db/migrate/20130212001748_add_geo_to_members.rb -index e60f355f..01406871 100644 ---- a/db/migrate/20130212001748_add_geo_to_members.rb -+++ b/db/migrate/20130212001748_add_geo_to_members.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddGeoToMembers < ActiveRecord::Migration[4.2] - def change - add_column :members, :location, :string -diff --git a/db/migrate/20130212123628_create_notifications.rb b/db/migrate/20130212123628_create_notifications.rb -index b89b1365..978f3054 100644 ---- a/db/migrate/20130212123628_create_notifications.rb -+++ b/db/migrate/20130212123628_create_notifications.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateNotifications < ActiveRecord::Migration[4.2] - def change - create_table :notifications do |t| -diff --git a/db/migrate/20130213014511_create_forums.rb b/db/migrate/20130213014511_create_forums.rb -index 0df3f00a..69a4a30e 100644 ---- a/db/migrate/20130213014511_create_forums.rb -+++ b/db/migrate/20130213014511_create_forums.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateForums < ActiveRecord::Migration[4.2] - def change - create_table :forums do |t| -diff --git a/db/migrate/20130213015708_add_forum_to_posts.rb b/db/migrate/20130213015708_add_forum_to_posts.rb -index 315ae0be..e6225db2 100644 ---- a/db/migrate/20130213015708_add_forum_to_posts.rb -+++ b/db/migrate/20130213015708_add_forum_to_posts.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddForumToPosts < ActiveRecord::Migration[4.2] - def change - add_column :posts, :forum_id, :integer -diff --git a/db/migrate/20130214024117_create_roles.rb b/db/migrate/20130214024117_create_roles.rb -index e39c7565..b0799ecb 100644 ---- a/db/migrate/20130214024117_create_roles.rb -+++ b/db/migrate/20130214024117_create_roles.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateRoles < ActiveRecord::Migration[4.2] - def change - create_table :roles do |t| -diff --git a/db/migrate/20130214034838_add_members_roles_table.rb b/db/migrate/20130214034838_add_members_roles_table.rb -index 502266a8..32c0b191 100644 ---- a/db/migrate/20130214034838_add_members_roles_table.rb -+++ b/db/migrate/20130214034838_add_members_roles_table.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddMembersRolesTable < ActiveRecord::Migration[4.2] - def change - create_table :members_roles, id: false do |t| -diff --git a/db/migrate/20130215131921_rename_notification_fields.rb b/db/migrate/20130215131921_rename_notification_fields.rb -index c2294d2f..7fcdd337 100644 ---- a/db/migrate/20130215131921_rename_notification_fields.rb -+++ b/db/migrate/20130215131921_rename_notification_fields.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class RenameNotificationFields < ActiveRecord::Migration[4.2] - def change - change_table :notifications do |t| -diff --git a/db/migrate/20130220044605_add_slug_to_forums.rb b/db/migrate/20130220044605_add_slug_to_forums.rb -index 57fbdc14..179f883a 100644 ---- a/db/migrate/20130220044605_add_slug_to_forums.rb -+++ b/db/migrate/20130220044605_add_slug_to_forums.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddSlugToForums < ActiveRecord::Migration[4.2] - def change - add_column :forums, :slug, :string -diff --git a/db/migrate/20130220044642_add_slug_to_roles.rb b/db/migrate/20130220044642_add_slug_to_roles.rb -index a3812d77..e867ce13 100644 ---- a/db/migrate/20130220044642_add_slug_to_roles.rb -+++ b/db/migrate/20130220044642_add_slug_to_roles.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddSlugToRoles < ActiveRecord::Migration[4.2] - def change - add_column :roles, :slug, :string -diff --git a/db/migrate/20130222060730_default_read_to_false.rb b/db/migrate/20130222060730_default_read_to_false.rb -index 81a10aa4..40dea83a 100644 ---- a/db/migrate/20130222060730_default_read_to_false.rb -+++ b/db/migrate/20130222060730_default_read_to_false.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class DefaultReadToFalse < ActiveRecord::Migration[4.2] - def up - change_table :notifications do |t| -diff --git a/db/migrate/20130326092227_change_planted_at_to_date.rb b/db/migrate/20130326092227_change_planted_at_to_date.rb -index 089c77ef..b2bd78ae 100644 ---- a/db/migrate/20130326092227_change_planted_at_to_date.rb -+++ b/db/migrate/20130326092227_change_planted_at_to_date.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ChangePlantedAtToDate < ActiveRecord::Migration[4.2] - def change - change_column :plantings, :planted_at, :date -diff --git a/db/migrate/20130327120024_add_send_email_to_member.rb b/db/migrate/20130327120024_add_send_email_to_member.rb -index 5421bb0d..89ff6126 100644 ---- a/db/migrate/20130327120024_add_send_email_to_member.rb -+++ b/db/migrate/20130327120024_add_send_email_to_member.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddSendEmailToMember < ActiveRecord::Migration[4.2] - def change - add_column :members, :send_notification_email, :boolean, default: true -diff --git a/db/migrate/20130329045744_add_sunniness_to_planting.rb b/db/migrate/20130329045744_add_sunniness_to_planting.rb -index 74fe7a65..ec79264c 100644 ---- a/db/migrate/20130329045744_add_sunniness_to_planting.rb -+++ b/db/migrate/20130329045744_add_sunniness_to_planting.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddSunninessToPlanting < ActiveRecord::Migration[4.2] - def change - add_column :plantings, :sunniness, :string -diff --git a/db/migrate/20130404174459_create_authentications.rb b/db/migrate/20130404174459_create_authentications.rb -index 226f1c34..809ad60b 100644 ---- a/db/migrate/20130404174459_create_authentications.rb -+++ b/db/migrate/20130404174459_create_authentications.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateAuthentications < ActiveRecord::Migration[4.2] - def change - create_table :authentications do |t| -diff --git a/db/migrate/20130409103549_make_post_subject_non_null.rb b/db/migrate/20130409103549_make_post_subject_non_null.rb -index ac05aca2..f11815a6 100644 ---- a/db/migrate/20130409103549_make_post_subject_non_null.rb -+++ b/db/migrate/20130409103549_make_post_subject_non_null.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class MakePostSubjectNonNull < ActiveRecord::Migration[4.2] - change_column :posts, :subject, :string, null: false - end -diff --git a/db/migrate/20130409162140_add_name_to_authentications.rb b/db/migrate/20130409162140_add_name_to_authentications.rb -index dabcb623..a0e53008 100644 ---- a/db/migrate/20130409162140_add_name_to_authentications.rb -+++ b/db/migrate/20130409162140_add_name_to_authentications.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddNameToAuthentications < ActiveRecord::Migration[4.2] - def change - add_column :authentications, :name, :string -diff --git a/db/migrate/20130507105357_create_products.rb b/db/migrate/20130507105357_create_products.rb -index 5a1ddd99..ac2ef8b6 100644 ---- a/db/migrate/20130507105357_create_products.rb -+++ b/db/migrate/20130507105357_create_products.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateProducts < ActiveRecord::Migration[4.2] - def change - create_table :products do |t| -diff --git a/db/migrate/20130507110411_create_orders.rb b/db/migrate/20130507110411_create_orders.rb -index 7974f10e..1c4c00c3 100644 ---- a/db/migrate/20130507110411_create_orders.rb -+++ b/db/migrate/20130507110411_create_orders.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateOrders < ActiveRecord::Migration[4.2] - def change - create_table :orders do |t| -diff --git a/db/migrate/20130507113915_add_orders_products_table.rb b/db/migrate/20130507113915_add_orders_products_table.rb -index 3d584508..33e34e6a 100644 ---- a/db/migrate/20130507113915_add_orders_products_table.rb -+++ b/db/migrate/20130507113915_add_orders_products_table.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddOrdersProductsTable < ActiveRecord::Migration[4.2] - def change - create_table :orders_products, id: false do |t| -diff --git a/db/migrate/20130508050711_add_completed_to_order.rb b/db/migrate/20130508050711_add_completed_to_order.rb -index e7c9f422..6640113e 100644 ---- a/db/migrate/20130508050711_add_completed_to_order.rb -+++ b/db/migrate/20130508050711_add_completed_to_order.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddCompletedToOrder < ActiveRecord::Migration[4.2] - def change - add_column :orders, :completed_at, :datetime -diff --git a/db/migrate/20130508104506_create_photos.rb b/db/migrate/20130508104506_create_photos.rb -index b6fb3d19..cb4a55e8 100644 ---- a/db/migrate/20130508104506_create_photos.rb -+++ b/db/migrate/20130508104506_create_photos.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreatePhotos < ActiveRecord::Migration[4.2] - def change - create_table :photos do |t| -diff --git a/db/migrate/20130509123711_add_metadata_to_photos.rb b/db/migrate/20130509123711_add_metadata_to_photos.rb -index e05c260c..5b62473f 100644 ---- a/db/migrate/20130509123711_add_metadata_to_photos.rb -+++ b/db/migrate/20130509123711_add_metadata_to_photos.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddMetadataToPhotos < ActiveRecord::Migration[4.2] - def up - change_table :photos do |t| -diff --git a/db/migrate/20130514124515_add_parent_to_crop.rb b/db/migrate/20130514124515_add_parent_to_crop.rb -index 65427c1c..9557db8e 100644 ---- a/db/migrate/20130514124515_add_parent_to_crop.rb -+++ b/db/migrate/20130514124515_add_parent_to_crop.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddParentToCrop < ActiveRecord::Migration[4.2] - def change - add_column :crops, :parent_id, :integer -diff --git a/db/migrate/20130515033842_create_order_items.rb b/db/migrate/20130515033842_create_order_items.rb -index ed7966f4..6305b381 100644 ---- a/db/migrate/20130515033842_create_order_items.rb -+++ b/db/migrate/20130515033842_create_order_items.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateOrderItems < ActiveRecord::Migration[4.2] - def change - create_table :order_items do |t| -diff --git a/db/migrate/20130515054017_change_order_member_id_to_integer.rb b/db/migrate/20130515054017_change_order_member_id_to_integer.rb -index 508fb13e..4a010dcc 100644 ---- a/db/migrate/20130515054017_change_order_member_id_to_integer.rb -+++ b/db/migrate/20130515054017_change_order_member_id_to_integer.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ChangeOrderMemberIdToInteger < ActiveRecord::Migration[4.2] - def up - remove_column :orders, :member_id -diff --git a/db/migrate/20130515122301_change_prices_to_integers.rb b/db/migrate/20130515122301_change_prices_to_integers.rb -index ef84683b..6a232fe2 100644 ---- a/db/migrate/20130515122301_change_prices_to_integers.rb -+++ b/db/migrate/20130515122301_change_prices_to_integers.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ChangePricesToIntegers < ActiveRecord::Migration[4.2] - def up - change_column :order_items, :price, :integer -diff --git a/db/migrate/20130517015920_create_account_details.rb b/db/migrate/20130517015920_create_account_details.rb -index c949798d..66a04ace 100644 ---- a/db/migrate/20130517015920_create_account_details.rb -+++ b/db/migrate/20130517015920_create_account_details.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateAccountDetails < ActiveRecord::Migration[4.2] - def change - create_table :account_details do |t| -diff --git a/db/migrate/20130517051922_create_account_types.rb b/db/migrate/20130517051922_create_account_types.rb -index 25bef37b..410b0701 100644 ---- a/db/migrate/20130517051922_create_account_types.rb -+++ b/db/migrate/20130517051922_create_account_types.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateAccountTypes < ActiveRecord::Migration[4.2] - def change - create_table :account_types do |t| -diff --git a/db/migrate/20130517234458_require_account_type_name.rb b/db/migrate/20130517234458_require_account_type_name.rb -index 2b118492..d638ad3c 100644 ---- a/db/migrate/20130517234458_require_account_type_name.rb -+++ b/db/migrate/20130517234458_require_account_type_name.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class RequireAccountTypeName < ActiveRecord::Migration[4.2] - def up - change_column :account_types, :name, :string, null: false -diff --git a/db/migrate/20130518000339_add_columns_to_product.rb b/db/migrate/20130518000339_add_columns_to_product.rb -index b3bba302..d6f80fae 100644 ---- a/db/migrate/20130518000339_add_columns_to_product.rb -+++ b/db/migrate/20130518000339_add_columns_to_product.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddColumnsToProduct < ActiveRecord::Migration[4.2] - def change - add_column :products, :account_type_id, :integer -diff --git a/db/migrate/20130518002942_rename_account_detail_to_account.rb b/db/migrate/20130518002942_rename_account_detail_to_account.rb -index a806c63a..cb369ce9 100644 ---- a/db/migrate/20130518002942_rename_account_detail_to_account.rb -+++ b/db/migrate/20130518002942_rename_account_detail_to_account.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class RenameAccountDetailToAccount < ActiveRecord::Migration[4.2] - def change - rename_table :account_details, :accounts -diff --git a/db/migrate/20130529032813_add_express_token_to_orders.rb b/db/migrate/20130529032813_add_express_token_to_orders.rb -index e7d40f41..53de7e9a 100644 ---- a/db/migrate/20130529032813_add_express_token_to_orders.rb -+++ b/db/migrate/20130529032813_add_express_token_to_orders.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddExpressTokenToOrders < ActiveRecord::Migration[4.2] - def change - add_column :orders, :paypal_express_token, :string -diff --git a/db/migrate/20130531110729_add_photos_plantings_table.rb b/db/migrate/20130531110729_add_photos_plantings_table.rb -index f4a3bb7b..cb9c4c52 100644 ---- a/db/migrate/20130531110729_add_photos_plantings_table.rb -+++ b/db/migrate/20130531110729_add_photos_plantings_table.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddPhotosPlantingsTable < ActiveRecord::Migration[4.2] - def change - create_table :photos_plantings, id: false do |t| -diff --git a/db/migrate/20130601011725_change_flickr_photo_id_to_string.rb b/db/migrate/20130601011725_change_flickr_photo_id_to_string.rb -index 92cfa168..b46e4ca2 100644 ---- a/db/migrate/20130601011725_change_flickr_photo_id_to_string.rb -+++ b/db/migrate/20130601011725_change_flickr_photo_id_to_string.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ChangeFlickrPhotoIdToString < ActiveRecord::Migration[4.2] - def up - remove_column :photos, :flickr_photo_id -diff --git a/db/migrate/20130606230333_change_product_description_to_text.rb b/db/migrate/20130606230333_change_product_description_to_text.rb -index 3393a8ae..7bae1e6a 100644 ---- a/db/migrate/20130606230333_change_product_description_to_text.rb -+++ b/db/migrate/20130606230333_change_product_description_to_text.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ChangeProductDescriptionToText < ActiveRecord::Migration[4.2] - def up - change_column :products, :description, :text -diff --git a/db/migrate/20130606233733_add_recommended_price_to_product.rb b/db/migrate/20130606233733_add_recommended_price_to_product.rb -index d424618f..076e20f3 100644 ---- a/db/migrate/20130606233733_add_recommended_price_to_product.rb -+++ b/db/migrate/20130606233733_add_recommended_price_to_product.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddRecommendedPriceToProduct < ActiveRecord::Migration[4.2] - def change - add_column :products, :recommended_price, :integer -diff --git a/db/migrate/20130705104238_add_planted_from_to_planting.rb b/db/migrate/20130705104238_add_planted_from_to_planting.rb -index 1dd4e070..d36ec235 100644 ---- a/db/migrate/20130705104238_add_planted_from_to_planting.rb -+++ b/db/migrate/20130705104238_add_planted_from_to_planting.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddPlantedFromToPlanting < ActiveRecord::Migration[4.2] - def change - add_column :plantings, :planted_from, :string -diff --git a/db/migrate/20130715110134_create_seeds.rb b/db/migrate/20130715110134_create_seeds.rb -index da895571..8065f9ac 100644 ---- a/db/migrate/20130715110134_create_seeds.rb -+++ b/db/migrate/20130715110134_create_seeds.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateSeeds < ActiveRecord::Migration[4.2] - def change - create_table :seeds do |t| -diff --git a/db/migrate/20130718005600_change_use_by_to_plant_before_on_seed.rb b/db/migrate/20130718005600_change_use_by_to_plant_before_on_seed.rb -index b440c270..c33a7398 100644 ---- a/db/migrate/20130718005600_change_use_by_to_plant_before_on_seed.rb -+++ b/db/migrate/20130718005600_change_use_by_to_plant_before_on_seed.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ChangeUseByToPlantBeforeOnSeed < ActiveRecord::Migration[4.2] - def change - rename_column :seeds, :use_by, :plant_before -diff --git a/db/migrate/20130718011247_add_trading_to_seeds.rb b/db/migrate/20130718011247_add_trading_to_seeds.rb -index 52add7f5..0ca32df9 100644 ---- a/db/migrate/20130718011247_add_trading_to_seeds.rb -+++ b/db/migrate/20130718011247_add_trading_to_seeds.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddTradingToSeeds < ActiveRecord::Migration[4.2] - def change - add_column :seeds, :tradable, :boolean -diff --git a/db/migrate/20130722050836_remove_tradable_from_seeds.rb b/db/migrate/20130722050836_remove_tradable_from_seeds.rb -index 9bea0bd1..d668990e 100644 ---- a/db/migrate/20130722050836_remove_tradable_from_seeds.rb -+++ b/db/migrate/20130722050836_remove_tradable_from_seeds.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class RemoveTradableFromSeeds < ActiveRecord::Migration[4.2] - def up - remove_column :seeds, :tradable -diff --git a/db/migrate/20130723103128_set_default_tradable_to_on_seed.rb b/db/migrate/20130723103128_set_default_tradable_to_on_seed.rb -index 56b88aad..5cecac55 100644 ---- a/db/migrate/20130723103128_set_default_tradable_to_on_seed.rb -+++ b/db/migrate/20130723103128_set_default_tradable_to_on_seed.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class SetDefaultTradableToOnSeed < ActiveRecord::Migration[4.2] - def up - change_column_default(:seeds, :tradable_to, 'nowhere') -diff --git a/db/migrate/20130723110702_add_slug_to_seed.rb b/db/migrate/20130723110702_add_slug_to_seed.rb -index ec52bdad..cb4fb704 100644 ---- a/db/migrate/20130723110702_add_slug_to_seed.rb -+++ b/db/migrate/20130723110702_add_slug_to_seed.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddSlugToSeed < ActiveRecord::Migration[4.2] - def change - add_column :seeds, :slug, :string -diff --git a/db/migrate/20130809012511_add_bio_to_members.rb b/db/migrate/20130809012511_add_bio_to_members.rb -index b63d11bb..affc7182 100644 ---- a/db/migrate/20130809012511_add_bio_to_members.rb -+++ b/db/migrate/20130809012511_add_bio_to_members.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddBioToMembers < ActiveRecord::Migration[4.2] - def change - add_column :members, :bio, :text -diff --git a/db/migrate/20130819004549_add_planting_count_to_crop.rb b/db/migrate/20130819004549_add_planting_count_to_crop.rb -index b25fc4a6..21864853 100644 ---- a/db/migrate/20130819004549_add_planting_count_to_crop.rb -+++ b/db/migrate/20130819004549_add_planting_count_to_crop.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddPlantingCountToCrop < ActiveRecord::Migration[4.2] - def change - add_column :crops, :plantings_count, :integer -diff --git a/db/migrate/20130821011352_add_creator_to_crops.rb b/db/migrate/20130821011352_add_creator_to_crops.rb -index 24aab3f7..9847c51a 100644 ---- a/db/migrate/20130821011352_add_creator_to_crops.rb -+++ b/db/migrate/20130821011352_add_creator_to_crops.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddCreatorToCrops < ActiveRecord::Migration[4.2] - def change - add_column :crops, :creator_id, :integer -diff --git a/db/migrate/20130821073736_add_creator_to_scientific_name.rb b/db/migrate/20130821073736_add_creator_to_scientific_name.rb -index e2904811..eb657737 100644 ---- a/db/migrate/20130821073736_add_creator_to_scientific_name.rb -+++ b/db/migrate/20130821073736_add_creator_to_scientific_name.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddCreatorToScientificName < ActiveRecord::Migration[4.2] - def change - add_column :scientific_names, :creator_id, :integer -diff --git a/db/migrate/20130826012139_add_owner_to_planting.rb b/db/migrate/20130826012139_add_owner_to_planting.rb -index 3399870d..9fb48320 100644 ---- a/db/migrate/20130826012139_add_owner_to_planting.rb -+++ b/db/migrate/20130826012139_add_owner_to_planting.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddOwnerToPlanting < ActiveRecord::Migration[4.2] - def change - add_column :plantings, :owner_id, :integer -diff --git a/db/migrate/20130826023159_add_plantings_count_to_member.rb b/db/migrate/20130826023159_add_plantings_count_to_member.rb -index 97347998..c4ad4729 100644 ---- a/db/migrate/20130826023159_add_plantings_count_to_member.rb -+++ b/db/migrate/20130826023159_add_plantings_count_to_member.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddPlantingsCountToMember < ActiveRecord::Migration[4.2] - def change - add_column :members, :plantings_count, :integer -diff --git a/db/migrate/20130827105823_add_newsletter_to_member.rb b/db/migrate/20130827105823_add_newsletter_to_member.rb -index 25f16a69..806f6ed9 100644 ---- a/db/migrate/20130827105823_add_newsletter_to_member.rb -+++ b/db/migrate/20130827105823_add_newsletter_to_member.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddNewsletterToMember < ActiveRecord::Migration[4.2] - def change - add_column :members, :newsletter, :boolean -diff --git a/db/migrate/20130913015118_add_referral_code_to_order.rb b/db/migrate/20130913015118_add_referral_code_to_order.rb -index ff9e5a6f..f4cd52ea 100644 ---- a/db/migrate/20130913015118_add_referral_code_to_order.rb -+++ b/db/migrate/20130913015118_add_referral_code_to_order.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddReferralCodeToOrder < ActiveRecord::Migration[4.2] - def change - add_column :orders, :referral_code, :string -diff --git a/db/migrate/20130917053547_create_harvests.rb b/db/migrate/20130917053547_create_harvests.rb -index f7e529a3..031aeb66 100644 ---- a/db/migrate/20130917053547_create_harvests.rb -+++ b/db/migrate/20130917053547_create_harvests.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateHarvests < ActiveRecord::Migration[4.2] - def change - create_table :harvests do |t| -diff --git a/db/migrate/20130917060257_change_harvest_notes_to_description.rb b/db/migrate/20130917060257_change_harvest_notes_to_description.rb -index 8359c0b9..2c09044d 100644 ---- a/db/migrate/20130917060257_change_harvest_notes_to_description.rb -+++ b/db/migrate/20130917060257_change_harvest_notes_to_description.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ChangeHarvestNotesToDescription < ActiveRecord::Migration[4.2] - def change - rename_column :harvests, :notes, :description -diff --git a/db/migrate/20130917071545_change_harvest_units_to_unit.rb b/db/migrate/20130917071545_change_harvest_units_to_unit.rb -index 7f859f47..21f96af1 100644 ---- a/db/migrate/20130917071545_change_harvest_units_to_unit.rb -+++ b/db/migrate/20130917071545_change_harvest_units_to_unit.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ChangeHarvestUnitsToUnit < ActiveRecord::Migration[4.2] - def change - rename_column :harvests, :units, :unit -diff --git a/db/migrate/20130917075803_add_slug_to_harvests.rb b/db/migrate/20130917075803_add_slug_to_harvests.rb -index b9bc376e..2cad48d7 100644 ---- a/db/migrate/20130917075803_add_slug_to_harvests.rb -+++ b/db/migrate/20130917075803_add_slug_to_harvests.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddSlugToHarvests < ActiveRecord::Migration[4.2] - def change - add_column :harvests, :slug, :string -diff --git a/db/migrate/20130925050304_add_weight_to_harvests.rb b/db/migrate/20130925050304_add_weight_to_harvests.rb -index 1aa43df6..a567938f 100644 ---- a/db/migrate/20130925050304_add_weight_to_harvests.rb -+++ b/db/migrate/20130925050304_add_weight_to_harvests.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddWeightToHarvests < ActiveRecord::Migration[4.2] - def change - add_column :harvests, :weight_quantity, :decimal -diff --git a/db/migrate/20131018101204_rename_system_name_to_name.rb b/db/migrate/20131018101204_rename_system_name_to_name.rb -index 6124d174..d3d3696a 100644 ---- a/db/migrate/20131018101204_rename_system_name_to_name.rb -+++ b/db/migrate/20131018101204_rename_system_name_to_name.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class RenameSystemNameToName < ActiveRecord::Migration[4.2] - def up - # Rails is smart enough to alter the column being indexed, but not the name -diff --git a/db/migrate/20131025104228_add_fields_to_gardens.rb b/db/migrate/20131025104228_add_fields_to_gardens.rb -index e77a9c6c..385493b1 100644 ---- a/db/migrate/20131025104228_add_fields_to_gardens.rb -+++ b/db/migrate/20131025104228_add_fields_to_gardens.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddFieldsToGardens < ActiveRecord::Migration[4.2] - def change - add_column :gardens, :active, :boolean, default: true -diff --git a/db/migrate/20131029053113_add_plant_part_to_harvests.rb b/db/migrate/20131029053113_add_plant_part_to_harvests.rb -index fad21613..a3e32b44 100644 ---- a/db/migrate/20131029053113_add_plant_part_to_harvests.rb -+++ b/db/migrate/20131029053113_add_plant_part_to_harvests.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddPlantPartToHarvests < ActiveRecord::Migration[4.2] - def change - add_column :harvests, :plant_part, :string -diff --git a/db/migrate/20131030230908_create_plant_parts.rb b/db/migrate/20131030230908_create_plant_parts.rb -index f3454f97..6c0ac467 100644 ---- a/db/migrate/20131030230908_create_plant_parts.rb -+++ b/db/migrate/20131030230908_create_plant_parts.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreatePlantParts < ActiveRecord::Migration[4.2] - def change - create_table :plant_parts do |t| -diff --git a/db/migrate/20131030231202_change_plant_part_to_plant_part_id.rb b/db/migrate/20131030231202_change_plant_part_to_plant_part_id.rb -index 134eeca9..ae9ce783 100644 ---- a/db/migrate/20131030231202_change_plant_part_to_plant_part_id.rb -+++ b/db/migrate/20131030231202_change_plant_part_to_plant_part_id.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ChangePlantPartToPlantPartId < ActiveRecord::Migration[4.2] - def up - remove_column :harvests, :plant_part -diff --git a/db/migrate/20131031000655_add_slug_to_plant_part.rb b/db/migrate/20131031000655_add_slug_to_plant_part.rb -index 242c3077..1078fd4c 100644 ---- a/db/migrate/20131031000655_add_slug_to_plant_part.rb -+++ b/db/migrate/20131031000655_add_slug_to_plant_part.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddSlugToPlantPart < ActiveRecord::Migration[4.2] - def change - add_column :plant_parts, :slug, :string -diff --git a/db/migrate/20140718075753_default_plantings_count_to_zero.rb b/db/migrate/20140718075753_default_plantings_count_to_zero.rb -index 15ee6df8..472e1740 100644 ---- a/db/migrate/20140718075753_default_plantings_count_to_zero.rb -+++ b/db/migrate/20140718075753_default_plantings_count_to_zero.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class DefaultPlantingsCountToZero < ActiveRecord::Migration[4.2] - def up - change_column :crops, :plantings_count, :integer, default: 0 -diff --git a/db/migrate/20140829230600_add_finished_to_planting.rb b/db/migrate/20140829230600_add_finished_to_planting.rb -index 868298f6..461f49c2 100644 ---- a/db/migrate/20140829230600_add_finished_to_planting.rb -+++ b/db/migrate/20140829230600_add_finished_to_planting.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddFinishedToPlanting < ActiveRecord::Migration[4.2] - def change - add_column :plantings, :finished, :boolean, default: false -diff --git a/db/migrate/20140905001730_add_harvests_photos_table.rb b/db/migrate/20140905001730_add_harvests_photos_table.rb -index f05ae013..d83c91f8 100644 ---- a/db/migrate/20140905001730_add_harvests_photos_table.rb -+++ b/db/migrate/20140905001730_add_harvests_photos_table.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddHarvestsPhotosTable < ActiveRecord::Migration[4.2] - def change - create_table :harvests_photos, id: false do |t| -diff --git a/db/migrate/20140928044231_add_crops_posts_table.rb b/db/migrate/20140928044231_add_crops_posts_table.rb -index a9e8761f..529530fe 100644 ---- a/db/migrate/20140928044231_add_crops_posts_table.rb -+++ b/db/migrate/20140928044231_add_crops_posts_table.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddCropsPostsTable < ActiveRecord::Migration[4.2] - def change - create_table :crops_posts, id: false do |t| -diff --git a/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb b/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb -index cd464eee..d2f5316d 100644 ---- a/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb -+++ b/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddSendPlantingReminderToMember < ActiveRecord::Migration[4.2] - def change - add_column :members, :send_planting_reminder, :boolean, default: true -diff --git a/db/migrate/20141002022459_create_index_harvest_photos.rb b/db/migrate/20141002022459_create_index_harvest_photos.rb -index f9c8ee91..26e9f8e7 100644 ---- a/db/migrate/20141002022459_create_index_harvest_photos.rb -+++ b/db/migrate/20141002022459_create_index_harvest_photos.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateIndexHarvestPhotos < ActiveRecord::Migration[4.2] - def change - add_index(:harvests_photos, %i(harvest_id photo_id)) -diff --git a/db/migrate/20141018111015_create_alternate_names.rb b/db/migrate/20141018111015_create_alternate_names.rb -index 65400cc2..bd1cd496 100644 ---- a/db/migrate/20141018111015_create_alternate_names.rb -+++ b/db/migrate/20141018111015_create_alternate_names.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateAlternateNames < ActiveRecord::Migration[4.2] - def change - create_table :alternate_names do |t| -diff --git a/db/migrate/20141111130849_create_follows.rb b/db/migrate/20141111130849_create_follows.rb -index 5ca3f9b1..02f585a6 100644 ---- a/db/migrate/20141111130849_create_follows.rb -+++ b/db/migrate/20141111130849_create_follows.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateFollows < ActiveRecord::Migration[4.2] - def change - create_table :follows do |t| -diff --git a/db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb b/db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb -index a777fc79..4d980c52 100644 ---- a/db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb -+++ b/db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ChangeFollowsMemberIdToFollowerId < ActiveRecord::Migration[4.2] - def change - rename_column :follows, :member_id, :follower_id -diff --git a/db/migrate/20150124110540_add_properties_to_seeds.rb b/db/migrate/20150124110540_add_properties_to_seeds.rb -index 0adb9660..48e4f2c3 100644 ---- a/db/migrate/20150124110540_add_properties_to_seeds.rb -+++ b/db/migrate/20150124110540_add_properties_to_seeds.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddPropertiesToSeeds < ActiveRecord::Migration[4.2] - def change - add_column :seeds, :days_until_maturity_min, :integer -diff --git a/db/migrate/20150127043022_add_gardens_photos_table.rb b/db/migrate/20150127043022_add_gardens_photos_table.rb -index 45917424..a2a7a990 100644 ---- a/db/migrate/20150127043022_add_gardens_photos_table.rb -+++ b/db/migrate/20150127043022_add_gardens_photos_table.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddGardensPhotosTable < ActiveRecord::Migration[4.2] - def change - create_table :gardens_photos, id: false do |t| -diff --git a/db/migrate/20150129034206_add_si_weight_to_harvest.rb b/db/migrate/20150129034206_add_si_weight_to_harvest.rb -index 881d4ad0..6429ad57 100644 ---- a/db/migrate/20150129034206_add_si_weight_to_harvest.rb -+++ b/db/migrate/20150129034206_add_si_weight_to_harvest.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddSiWeightToHarvest < ActiveRecord::Migration[4.2] - def change - add_column :harvests, :si_weight, :float -diff --git a/db/migrate/20150130224814_add_requester_to_crops.rb b/db/migrate/20150130224814_add_requester_to_crops.rb -index 0d9f7094..9d223a5e 100644 ---- a/db/migrate/20150130224814_add_requester_to_crops.rb -+++ b/db/migrate/20150130224814_add_requester_to_crops.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddRequesterToCrops < ActiveRecord::Migration[4.2] - def change - add_column :crops, :requester_id, :integer -diff --git a/db/migrate/20150201052245_create_cms.rb b/db/migrate/20150201052245_create_cms.rb -index 4dc1a5d2..9a193751 100644 ---- a/db/migrate/20150201052245_create_cms.rb -+++ b/db/migrate/20150201052245_create_cms.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateCms < ActiveRecord::Migration[4.2] - def self.up # rubocop:disable Metrics/MethodLength, Metrics/AbcSize - text_limit = case ActiveRecord::Base.connection.adapter_name -diff --git a/db/migrate/20150201053200_add_approval_status_to_crops.rb b/db/migrate/20150201053200_add_approval_status_to_crops.rb -index ff6b12cb..48101c5d 100644 ---- a/db/migrate/20150201053200_add_approval_status_to_crops.rb -+++ b/db/migrate/20150201053200_add_approval_status_to_crops.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddApprovalStatusToCrops < ActiveRecord::Migration[4.2] - def change - add_column :crops, :approval_status, :string, default: "approved" -diff --git a/db/migrate/20150201062506_add_reason_for_rejection_to_crops.rb b/db/migrate/20150201062506_add_reason_for_rejection_to_crops.rb -index 001cd795..37703676 100644 ---- a/db/migrate/20150201062506_add_reason_for_rejection_to_crops.rb -+++ b/db/migrate/20150201062506_add_reason_for_rejection_to_crops.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddReasonForRejectionToCrops < ActiveRecord::Migration[4.2] - def change - add_column :crops, :reason_for_rejection, :text -diff --git a/db/migrate/20150201064502_add_request_notes_to_crops.rb b/db/migrate/20150201064502_add_request_notes_to_crops.rb -index 433c5ad3..b2c21a82 100644 ---- a/db/migrate/20150201064502_add_request_notes_to_crops.rb -+++ b/db/migrate/20150201064502_add_request_notes_to_crops.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddRequestNotesToCrops < ActiveRecord::Migration[4.2] - def change - add_column :crops, :request_notes, :text -diff --git a/db/migrate/20150203080226_create_likes.rb b/db/migrate/20150203080226_create_likes.rb -index b5f7d427..e49ce9b5 100644 ---- a/db/migrate/20150203080226_create_likes.rb -+++ b/db/migrate/20150203080226_create_likes.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateLikes < ActiveRecord::Migration[4.2] - def change - create_table :likes do |t| -diff --git a/db/migrate/20150209105410_add_rejection_notes_to_crops.rb b/db/migrate/20150209105410_add_rejection_notes_to_crops.rb -index 44fc9fb7..3ee48d7c 100644 ---- a/db/migrate/20150209105410_add_rejection_notes_to_crops.rb -+++ b/db/migrate/20150209105410_add_rejection_notes_to_crops.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddRejectionNotesToCrops < ActiveRecord::Migration[4.2] - def change - add_column :crops, :rejection_notes, :text -diff --git a/db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb b/db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb -index c60e6f6a..39630353 100644 ---- a/db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb -+++ b/db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddDaysBeforeMaturityToPlantings < ActiveRecord::Migration[4.2] - def change - add_column :plantings, :days_before_maturity, :integer -diff --git a/db/migrate/20150824145414_add_member_preferred_image.rb b/db/migrate/20150824145414_add_member_preferred_image.rb -index c3c56337..9243318d 100644 ---- a/db/migrate/20150824145414_add_member_preferred_image.rb -+++ b/db/migrate/20150824145414_add_member_preferred_image.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddMemberPreferredImage < ActiveRecord::Migration[4.2] - def change - add_column :members, :preferred_avatar_uri, :string -diff --git a/db/migrate/20161129021533_rename_scientific_name.rb b/db/migrate/20161129021533_rename_scientific_name.rb -index 3aac2e5d..f5a76c5a 100644 ---- a/db/migrate/20161129021533_rename_scientific_name.rb -+++ b/db/migrate/20161129021533_rename_scientific_name.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class RenameScientificName < ActiveRecord::Migration[4.2] - def self.up - rename_column :scientific_names, :scientific_name, :name -diff --git a/db/migrate/20161201154922_add_photos_seeds_table.rb b/db/migrate/20161201154922_add_photos_seeds_table.rb -index bbe7478c..8031d2ca 100644 ---- a/db/migrate/20161201154922_add_photos_seeds_table.rb -+++ b/db/migrate/20161201154922_add_photos_seeds_table.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddPhotosSeedsTable < ActiveRecord::Migration[4.2] - def change - create_table :photos_seeds, id: false do |t| -diff --git a/db/migrate/20170104035248_add_planting_ref_to_harvests.rb b/db/migrate/20170104035248_add_planting_ref_to_harvests.rb -index 515ffaa8..3c197dcd 100644 ---- a/db/migrate/20170104035248_add_planting_ref_to_harvests.rb -+++ b/db/migrate/20170104035248_add_planting_ref_to_harvests.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddPlantingRefToHarvests < ActiveRecord::Migration[4.2] - def change - add_reference :harvests, :planting, index: true, foreign_key: true -diff --git a/db/migrate/20170413221549_counter_caches.rb b/db/migrate/20170413221549_counter_caches.rb -index 27f4f1f6..76e3b72c 100644 ---- a/db/migrate/20170413221549_counter_caches.rb -+++ b/db/migrate/20170413221549_counter_caches.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CounterCaches < ActiveRecord::Migration[4.2] - def change - add_column :members, :gardens_count, :integer -diff --git a/db/migrate/20170520060252_add_deleted_to_members.rb b/db/migrate/20170520060252_add_deleted_to_members.rb -index 3e7059ae..4e370ff3 100644 ---- a/db/migrate/20170520060252_add_deleted_to_members.rb -+++ b/db/migrate/20170520060252_add_deleted_to_members.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddDeletedToMembers < ActiveRecord::Migration[4.2] - def change - add_column :members, :deleted_at, :datetime -diff --git a/db/migrate/20171022032108_all_the_predictions.rb b/db/migrate/20171022032108_all_the_predictions.rb -index aa0f1bfd..80f18df2 100644 ---- a/db/migrate/20171022032108_all_the_predictions.rb -+++ b/db/migrate/20171022032108_all_the_predictions.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AllThePredictions < ActiveRecord::Migration[4.2] - def change - add_column :crops, :perennial, :boolean, default: false -diff --git a/db/migrate/20171028230429_create_median_function.rb b/db/migrate/20171028230429_create_median_function.rb -index 5e57c01d..1b1e44e5 100644 ---- a/db/migrate/20171028230429_create_median_function.rb -+++ b/db/migrate/20171028230429_create_median_function.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateMedianFunction < ActiveRecord::Migration[4.2] - def up - ActiveMedian.create_function -diff --git a/db/migrate/20171105011017_set_prediction_data.rb b/db/migrate/20171105011017_set_prediction_data.rb -index 8dfd91b4..795e6c15 100644 ---- a/db/migrate/20171105011017_set_prediction_data.rb -+++ b/db/migrate/20171105011017_set_prediction_data.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class SetPredictionData < ActiveRecord::Migration[4.2] - def up - say "Updating all plantings time to first harvest" -diff --git a/db/migrate/20171129041341_create_photographings.rb b/db/migrate/20171129041341_create_photographings.rb -index a80245b5..2ae1168d 100644 ---- a/db/migrate/20171129041341_create_photographings.rb -+++ b/db/migrate/20171129041341_create_photographings.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreatePhotographings < ActiveRecord::Migration[4.2] - def change - create_table :photographings do |t| -diff --git a/db/migrate/20180118112809_add_datetaken_to_photos.rb b/db/migrate/20180118112809_add_datetaken_to_photos.rb -index 03fae107..59030559 100644 ---- a/db/migrate/20180118112809_add_datetaken_to_photos.rb -+++ b/db/migrate/20180118112809_add_datetaken_to_photos.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddDatetakenToPhotos < ActiveRecord::Migration[4.2] - def change - add_column :photos, :date_taken, :datetime -diff --git a/db/migrate/20180205000612_remove_shop.rb b/db/migrate/20180205000612_remove_shop.rb -index 6977f127..17248e3d 100644 ---- a/db/migrate/20180205000612_remove_shop.rb -+++ b/db/migrate/20180205000612_remove_shop.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class RemoveShop < ActiveRecord::Migration[4.2] - def up - drop_table :order_items -diff --git a/db/migrate/20180213005731_seed_usage.rb b/db/migrate/20180213005731_seed_usage.rb -index 8f7112e4..ddb2c237 100644 ---- a/db/migrate/20180213005731_seed_usage.rb -+++ b/db/migrate/20180213005731_seed_usage.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class SeedUsage < ActiveRecord::Migration[4.2] - def change - # # seed can be all sown, meaning there is none left -diff --git a/db/migrate/20180401220637_add_member_count_caches.rb b/db/migrate/20180401220637_add_member_count_caches.rb -index 912db008..8f10b0c6 100644 ---- a/db/migrate/20180401220637_add_member_count_caches.rb -+++ b/db/migrate/20180401220637_add_member_count_caches.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddMemberCountCaches < ActiveRecord::Migration[4.2] - def change - add_column :members, :photos_count, :integer -diff --git a/db/migrate/20190130090437_add_crop_to_photographings.rb b/db/migrate/20190130090437_add_crop_to_photographings.rb -index 3b4ad878..e74f57b6 100644 ---- a/db/migrate/20190130090437_add_crop_to_photographings.rb -+++ b/db/migrate/20190130090437_add_crop_to_photographings.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddCropToPhotographings < ActiveRecord::Migration[5.2] - def change - add_column(:photographings, :crop_id, :integer) -diff --git a/db/migrate/20190317023129_finished_boolean.rb b/db/migrate/20190317023129_finished_boolean.rb -index ac652431..8ba8c73e 100644 ---- a/db/migrate/20190317023129_finished_boolean.rb -+++ b/db/migrate/20190317023129_finished_boolean.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class FinishedBoolean < ActiveRecord::Migration[5.2] - def change - Planting.unscoped.where('finished_at < now()').update_all(finished: true) -diff --git a/db/migrate/20190326063855_create_garden_types.rb b/db/migrate/20190326063855_create_garden_types.rb -index 0d7ca230..d844eb78 100644 ---- a/db/migrate/20190326063855_create_garden_types.rb -+++ b/db/migrate/20190326063855_create_garden_types.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateGardenTypes < ActiveRecord::Migration[5.2] - def change - create_table :garden_types do |t| -diff --git a/db/migrate/20190326224347_add_harvests_count.rb b/db/migrate/20190326224347_add_harvests_count.rb -index 9557ffda..fc5b6bdc 100644 ---- a/db/migrate/20190326224347_add_harvests_count.rb -+++ b/db/migrate/20190326224347_add_harvests_count.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddHarvestsCount < ActiveRecord::Migration[5.2] - def change - add_column :plantings, :harvests_count, :integer, default: 0 -diff --git a/db/migrate/20190712003735_add_like_counter_caches.rb b/db/migrate/20190712003735_add_like_counter_caches.rb -index 92c29249..c956d6f8 100644 ---- a/db/migrate/20190712003735_add_like_counter_caches.rb -+++ b/db/migrate/20190712003735_add_like_counter_caches.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddLikeCounterCaches < ActiveRecord::Migration[5.2] - def change - change_table :photos do |t| -diff --git a/db/migrate/20190712234859_rename_photographings.rb b/db/migrate/20190712234859_rename_photographings.rb -index 7f9a5127..09ea403e 100644 ---- a/db/migrate/20190712234859_rename_photographings.rb -+++ b/db/migrate/20190712234859_rename_photographings.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class RenamePhotographings < ActiveRecord::Migration[5.2] - def change - rename_table :photographings, :photo_associations -diff --git a/db/migrate/20190720000555_create_mailboxer.mailboxer_engine.rb b/db/migrate/20190720000555_create_mailboxer.mailboxer_engine.rb -index 943d04e8..04ab2fd9 100644 ---- a/db/migrate/20190720000555_create_mailboxer.mailboxer_engine.rb -+++ b/db/migrate/20190720000555_create_mailboxer.mailboxer_engine.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # This migration comes from mailboxer_engine (originally 20110511145103) - class CreateMailboxer < ActiveRecord::Migration[4.2] - def self.up -diff --git a/db/migrate/20190720000556_add_conversation_optout.mailboxer_engine.rb b/db/migrate/20190720000556_add_conversation_optout.mailboxer_engine.rb -index 50eeeed0..fa062c83 100644 ---- a/db/migrate/20190720000556_add_conversation_optout.mailboxer_engine.rb -+++ b/db/migrate/20190720000556_add_conversation_optout.mailboxer_engine.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # This migration comes from mailboxer_engine (originally 20131206080416) - class AddConversationOptout < ActiveRecord::Migration[4.2] - def self.up -diff --git a/db/migrate/20190720000557_add_missing_indices.mailboxer_engine.rb b/db/migrate/20190720000557_add_missing_indices.mailboxer_engine.rb -index 87c15483..b6e79300 100644 ---- a/db/migrate/20190720000557_add_missing_indices.mailboxer_engine.rb -+++ b/db/migrate/20190720000557_add_missing_indices.mailboxer_engine.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # This migration comes from mailboxer_engine (originally 20131206080417) - class AddMissingIndices < ActiveRecord::Migration[4.2] - def change -diff --git a/db/migrate/20190720000558_add_delivery_tracking_info_to_mailboxer_receipts.mailboxer_engine.rb b/db/migrate/20190720000558_add_delivery_tracking_info_to_mailboxer_receipts.mailboxer_engine.rb -index 498d152d..547e3e44 100644 ---- a/db/migrate/20190720000558_add_delivery_tracking_info_to_mailboxer_receipts.mailboxer_engine.rb -+++ b/db/migrate/20190720000558_add_delivery_tracking_info_to_mailboxer_receipts.mailboxer_engine.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # This migration comes from mailboxer_engine (originally 20151103080417) - class AddDeliveryTrackingInfoToMailboxerReceipts < ActiveRecord::Migration[4.2] - def change -diff --git a/db/migrate/20190720000625_notifications_to_mailboxer.rb b/db/migrate/20190720000625_notifications_to_mailboxer.rb -index 1dabd892..fb488cff 100644 ---- a/db/migrate/20190720000625_notifications_to_mailboxer.rb -+++ b/db/migrate/20190720000625_notifications_to_mailboxer.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class NotificationsToMailboxer < ActiveRecord::Migration[5.2] - def up - Mailboxer.setup do |config| -diff --git a/db/migrate/20190721042146_paranoia_to_discard.rb b/db/migrate/20190721042146_paranoia_to_discard.rb -index 4b880336..bdebe321 100644 ---- a/db/migrate/20190721042146_paranoia_to_discard.rb -+++ b/db/migrate/20190721042146_paranoia_to_discard.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class ParanoiaToDiscard < ActiveRecord::Migration[5.2] - def change - rename_column :members, :deleted_at, :discarded_at -diff --git a/db/migrate/20190902004225_add_openfarm_data_to_crops.rb b/db/migrate/20190902004225_add_openfarm_data_to_crops.rb -index f8cc4d43..61b3e1ee 100644 ---- a/db/migrate/20190902004225_add_openfarm_data_to_crops.rb -+++ b/db/migrate/20190902004225_add_openfarm_data_to_crops.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddOpenfarmDataToCrops < ActiveRecord::Migration[5.2] - def change - add_column :crops, :openfarm_data, :jsonb -diff --git a/db/migrate/20190910022329_add_photo_source.rb b/db/migrate/20190910022329_add_photo_source.rb -index 44e9a9d7..302cf68c 100644 ---- a/db/migrate/20190910022329_add_photo_source.rb -+++ b/db/migrate/20190910022329_add_photo_source.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddPhotoSource < ActiveRecord::Migration[5.2] - def change - add_column :photos, :source, :string -diff --git a/db/migrate/20190915065209_create_crop_companions.rb b/db/migrate/20190915065209_create_crop_companions.rb -index 1b9d1b97..b50fba28 100644 ---- a/db/migrate/20190915065209_create_crop_companions.rb -+++ b/db/migrate/20190915065209_create_crop_companions.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CreateCropCompanions < ActiveRecord::Migration[5.2] - def change - create_table :crop_companions do |t| -diff --git a/db/migrate/20190918033319_unique_urls.rb b/db/migrate/20190918033319_unique_urls.rb -index 99b9caf4..ed1da03d 100644 ---- a/db/migrate/20190918033319_unique_urls.rb -+++ b/db/migrate/20190918033319_unique_urls.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class UniqueUrls < ActiveRecord::Migration[5.2] - def change - add_index :photos, :fullsize_url, unique: true -diff --git a/db/migrate/20190921211652_crop_posts.rb b/db/migrate/20190921211652_crop_posts.rb -index c7f2950c..de8b5d39 100644 ---- a/db/migrate/20190921211652_crop_posts.rb -+++ b/db/migrate/20190921211652_crop_posts.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CropPosts < ActiveRecord::Migration[5.2] - def change - rename_table :crops_posts, :crop_posts -diff --git a/db/migrate/20191029024101_add_saved_at_to_seeds.rb b/db/migrate/20191029024101_add_saved_at_to_seeds.rb -index 745bdf5e..ccbf598e 100644 ---- a/db/migrate/20191029024101_add_saved_at_to_seeds.rb -+++ b/db/migrate/20191029024101_add_saved_at_to_seeds.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class AddSavedAtToSeeds < ActiveRecord::Migration[5.2] - def change - add_column :seeds, :saved_at, :date -diff --git a/db/migrate/20191119020643_upgrade_cms.rb b/db/migrate/20191119020643_upgrade_cms.rb -index 8b2b34f5..8256e910 100644 ---- a/db/migrate/20191119020643_upgrade_cms.rb -+++ b/db/migrate/20191119020643_upgrade_cms.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class UpgradeCms < ActiveRecord::Migration[5.2] - def change - rename_table :comfy_cms_blocks, :comfy_cms_fragments -diff --git a/db/migrate/20191119030244_cms_tags.rb b/db/migrate/20191119030244_cms_tags.rb -index fa3ef0d4..918f6a32 100644 ---- a/db/migrate/20191119030244_cms_tags.rb -+++ b/db/migrate/20191119030244_cms_tags.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class CmsTags < ActiveRecord::Migration[5.2] - def up - Comfy::Cms::Layout.all.each do |layout| -diff --git a/db/migrate/20191209202348_add_harvest_count_to_crop.rb b/db/migrate/20191209202348_add_harvest_count_to_crop.rb -new file mode 100644 -index 00000000..46b5f073 ---- /dev/null -+++ b/db/migrate/20191209202348_add_harvest_count_to_crop.rb -@@ -0,0 +1,66 @@ -+# frozen_string_literal: true -+ -+class AddHarvestCountToCrop < ActiveRecord::Migration[5.2] -+ def change -+ change_table :crops do |t| -+ t.integer :harvests_count, default: 0 -+ t.integer :photo_associations_count, default: 0 -+ end -+ change_table :plant_parts do |t| -+ t.integer :harvests_count, default: 0 -+ end -+ change_table :posts do |t| -+ t.integer :comments_count, default: 0 -+ end -+ reversible do |dir| -+ dir.up { data } -+ end -+ end -+ -+ def data -+ execute <<-SQL.squish -+ UPDATE crops -+ SET harvests_count = ( -+ SELECT count(1) -+ FROM harvests -+ WHERE harvests.crop_id = crops.id -+ ) -+ SQL -+ execute <<-SQL.squish -+ UPDATE crops -+ SET photo_associations_count = ( -+ SELECT count(1) -+ FROM photo_associations -+ WHERE photo_associations.crop_id = crops.id -+ ) -+ SQL -+ execute <<-SQL.squish -+ UPDATE plant_parts -+ SET harvests_count = ( -+ SELECT count(1) -+ FROM harvests -+ WHERE harvests.plant_part_id = plant_parts.id -+ ) -+ SQL -+ -+ execute <<-SQL.squish -+ UPDATE posts -+ SET comments_count = ( -+ SELECT count(1) -+ FROM comments -+ WHERE comments.post_id = posts.id -+ ) -+ SQL -+ -+ say 'indexing crops' -+ Crop.reindex -+ say 'indexing plantings' -+ Planting.reindex -+ say 'indexing seeds' -+ Seed.reindex -+ say 'indexing harvests' -+ Harvest.reindex -+ say 'indexing photos' -+ Photo.reindex -+ end -+end -diff --git a/db/schema.rb b/db/schema.rb -index 06d7be21..a701305f 100644 ---- a/db/schema.rb -+++ b/db/schema.rb -@@ -10,7 +10,7 @@ - # - # It's strongly recommended that you check this file into your version control system. - --ActiveRecord::Schema.define(version: 2019_11_19_030244) do -+ActiveRecord::Schema.define(version: 2019_12_09_202348) do - - # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" -@@ -196,6 +196,8 @@ ActiveRecord::Schema.define(version: 2019_11_19_030244) do - t.integer "median_days_to_first_harvest" - t.integer "median_days_to_last_harvest" - t.jsonb "openfarm_data" -+ t.integer "harvests_count", default: 0 -+ t.integer "photo_associations_count", default: 0 - t.index ["name"], name: "index_crops_on_name" - t.index ["requester_id"], name: "index_crops_on_requester_id" - t.index ["slug"], name: "index_crops_on_slug", unique: true -@@ -458,6 +460,7 @@ ActiveRecord::Schema.define(version: 2019_11_19_030244) do - t.datetime "created_at" - t.datetime "updated_at" - t.string "slug" -+ t.integer "harvests_count", default: 0 - end - - create_table "plantings", id: :serial, force: :cascade do |t| -@@ -491,6 +494,7 @@ ActiveRecord::Schema.define(version: 2019_11_19_030244) do - t.string "slug" - t.integer "forum_id" - t.integer "likes_count", default: 0 -+ t.integer "comments_count", default: 0 - t.index ["created_at", "author_id"], name: "index_posts_on_created_at_and_author_id" - t.index ["slug"], name: "index_posts_on_slug", unique: true - end -diff --git a/db/seeds.rb b/db/seeds.rb -index ed57b6b7..d3ac333b 100644 ---- a/db/seeds.rb -+++ b/db/seeds.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # This file should contain all the record creation needed to seed the database with its default values. - # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). - -diff --git a/lib/actions/oauth_signup_action.rb b/lib/actions/oauth_signup_action.rb -index de274dc3..cd1f7d76 100644 ---- a/lib/actions/oauth_signup_action.rb -+++ b/lib/actions/oauth_signup_action.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - class Growstuff::OauthSignupAction - # - # Inspects the omniauth information -diff --git a/lib/geocodable.rb b/lib/geocodable.rb -index f1bb243f..7d3b3c8e 100644 ---- a/lib/geocodable.rb -+++ b/lib/geocodable.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module Geocodable - def self.included(base) - base.extend(self) -diff --git a/lib/haml/filters/escaped_markdown.rb b/lib/haml/filters/escaped_markdown.rb -index 86345b5a..d68f0661 100644 ---- a/lib/haml/filters/escaped_markdown.rb -+++ b/lib/haml/filters/escaped_markdown.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'bluecloth' - require 'haml/filters/growstuff_markdown' - -diff --git a/lib/haml/filters/growstuff_markdown.rb b/lib/haml/filters/growstuff_markdown.rb -index 52dff709..d5869e7f 100644 ---- a/lib/haml/filters/growstuff_markdown.rb -+++ b/lib/haml/filters/growstuff_markdown.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'bluecloth' - - module Haml::Filters -diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake -index 6c185c7b..137243f0 100644 ---- a/lib/tasks/growstuff.rake -+++ b/lib/tasks/growstuff.rake -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - namespace :growstuff do - desc "Add an admin user, by name" - # usage: rake growstuff:admin_user name=skud -diff --git a/lib/tasks/hooks.rake b/lib/tasks/hooks.rake -index 67cc41cb..051902ed 100644 ---- a/lib/tasks/hooks.rake -+++ b/lib/tasks/hooks.rake -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - desc "Install git hooks" - task :hooks do - FileUtils.symlink '../../script/pre-commit.sh', '.git/hooks/pre-commit', -diff --git a/lib/tasks/i18n.rake b/lib/tasks/i18n.rake -index 04fa8001..8a0f9d8c 100644 ---- a/lib/tasks/i18n.rake -+++ b/lib/tasks/i18n.rake -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - namespace :i18n do - desc "sort all i18n locale keys" - task :normalize do -diff --git a/lib/tasks/openfarm.rake b/lib/tasks/openfarm.rake -index b6b6ce90..92ca9cc3 100644 ---- a/lib/tasks/openfarm.rake -+++ b/lib/tasks/openfarm.rake -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - namespace :openfarm do - desc "Retrieve crop info from open farm" - # usage: rake growstuff:admin_user name=skud -diff --git a/lib/tasks/search.rake b/lib/tasks/search.rake -index 71f9da6b..d93fd601 100644 ---- a/lib/tasks/search.rake -+++ b/lib/tasks/search.rake -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - namespace :search do - desc 'reindex' - task reindex: :environment do -diff --git a/lib/tasks/testing.rake b/lib/tasks/testing.rake -index 1120f6ca..d6a5fd5c 100644 ---- a/lib/tasks/testing.rake -+++ b/lib/tasks/testing.rake -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rake' - begin - require 'rspec/core/rake_task' -diff --git a/script/check_contributors_md.rb b/script/check_contributors_md.rb -index 9aa3fa29..d0013e78 100755 ---- a/script/check_contributors_md.rb -+++ b/script/check_contributors_md.rb -@@ -1,4 +1,6 @@ - #!/usr/bin/env ruby -+# frozen_string_literal: true -+ - require "English" - - puts "Checking to see if you're in CONTRIBUTORS.md..." -diff --git a/script/check_static.rb b/script/check_static.rb -index e747599f..f82932a9 100755 ---- a/script/check_static.rb -+++ b/script/check_static.rb -@@ -1,4 +1,5 @@ - #!/usr/bin/env ruby -+# frozen_string_literal: true - - checks = [ - # 'overcommit -r', -diff --git a/script/heroku_maintenance.rb b/script/heroku_maintenance.rb -index d2a20d67..1c285a28 100755 ---- a/script/heroku_maintenance.rb -+++ b/script/heroku_maintenance.rb -@@ -1,4 +1,5 @@ - #!/usr/bin/env ruby -+# frozen_string_literal: true - - require 'platform-api' - require 'yaml' -diff --git a/spec/controllers/admin/roles_controller_spec.rb b/spec/controllers/admin/roles_controller_spec.rb -index 86694a74..cb2a193e 100644 ---- a/spec/controllers/admin/roles_controller_spec.rb -+++ b/spec/controllers/admin/roles_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe Admin::RolesController do -diff --git a/spec/controllers/admin_controller_spec.rb b/spec/controllers/admin_controller_spec.rb -index 7f0e5620..b1b22289 100644 ---- a/spec/controllers/admin_controller_spec.rb -+++ b/spec/controllers/admin_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe AdminController do -diff --git a/spec/controllers/authentications_controller_spec.rb b/spec/controllers/authentications_controller_spec.rb -index 372d44c4..d4bc8ad5 100644 ---- a/spec/controllers/authentications_controller_spec.rb -+++ b/spec/controllers/authentications_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe AuthenticationsController do -diff --git a/spec/controllers/charts/crops_controller_spec.rb b/spec/controllers/charts/crops_controller_spec.rb -index 3a6a40bb..dd08302b 100644 ---- a/spec/controllers/charts/crops_controller_spec.rb -+++ b/spec/controllers/charts/crops_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe Charts::CropsController do -diff --git a/spec/controllers/charts/gardens_controller_spec.rb b/spec/controllers/charts/gardens_controller_spec.rb -index d264388f..b6a2bd1c 100644 ---- a/spec/controllers/charts/gardens_controller_spec.rb -+++ b/spec/controllers/charts/gardens_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe Charts::GardensController do -@@ -7,7 +9,7 @@ describe Charts::GardensController do - - context "when not signed in" do - describe 'GET timeline' do -- before { get :timeline, params: { garden_id: garden.to_param } } -+ before { get :timeline, params: { garden_slug: garden.to_param } } - - it { expect(response).to be_successful } - end -@@ -19,7 +21,7 @@ describe Charts::GardensController do - let!(:member) { FactoryBot.create(:member) } - - describe 'GET timeline' do -- before { get :timeline, params: { garden_id: garden.to_param } } -+ before { get :timeline, params: { garden_slug: garden.to_param } } - - it { expect(response).to be_successful } - end -diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb -index 741b19ff..4e8b64ce 100644 ---- a/spec/controllers/comments_controller_spec.rb -+++ b/spec/controllers/comments_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe CommentsController do -diff --git a/spec/controllers/crops_controller_spec.rb b/spec/controllers/crops_controller_spec.rb -index 1bb737c9..8681b479 100644 ---- a/spec/controllers/crops_controller_spec.rb -+++ b/spec/controllers/crops_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe CropsController do -diff --git a/spec/controllers/forums_controller_spec.rb b/spec/controllers/forums_controller_spec.rb -index 5c59473c..065ff32d 100644 ---- a/spec/controllers/forums_controller_spec.rb -+++ b/spec/controllers/forums_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe ForumsController do -diff --git a/spec/controllers/garden_types_controller_spec.rb b/spec/controllers/garden_types_controller_spec.rb -index 53bc9cae..e3c46675 100644 ---- a/spec/controllers/garden_types_controller_spec.rb -+++ b/spec/controllers/garden_types_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - RSpec.describe GardenTypesController, type: :controller do -diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb -index 3222829f..31930445 100644 ---- a/spec/controllers/gardens_controller_spec.rb -+++ b/spec/controllers/gardens_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - RSpec.describe GardensController, type: :controller do -@@ -8,7 +10,7 @@ RSpec.describe GardensController, type: :controller do - - context "when not signed in" do - describe 'GET new' do -- before { get :new, params: { id: garden.to_param } } -+ before { get :new, params: { slug: garden.to_param } } - - it { expect(response).to redirect_to(new_member_session_path) } - end -@@ -30,19 +32,19 @@ RSpec.describe GardensController, type: :controller do - end - - describe 'GET edit' do -- before { get :edit, params: { id: garden.to_param } } -+ before { get :edit, params: { slug: garden.to_param } } - - it { expect(response).to redirect_to(new_member_session_path) } - end - - describe 'POST update' do -- before { post :update, params: { id: garden.to_param, garden: valid_params } } -+ before { post :update, params: { slug: garden.to_param, garden: valid_params } } - - it { expect(response).to redirect_to(new_member_session_path) } - end - - describe 'DELETE' do -- before { delete :destroy, params: { id: garden.to_param, params: { garden: valid_params } } } -+ before { delete :destroy, params: { slug: garden.to_param, params: { garden: valid_params } } } - - it { expect(response).to redirect_to(new_member_session_path) } - end -@@ -67,19 +69,19 @@ RSpec.describe GardensController, type: :controller do - end - - describe 'GET edit' do -- before { get :edit, params: { id: not_my_garden.to_param } } -+ before { get :edit, params: { slug: not_my_garden.to_param } } - - it { expect(response).to redirect_to(root_path) } - end - - describe 'POST update' do -- before { post :update, params: { id: not_my_garden.to_param, garden: valid_params } } -+ before { post :update, params: { slug: not_my_garden.to_param, garden: valid_params } } - - it { expect(response).to redirect_to(root_path) } - end - - describe 'DELETE' do -- before { delete :destroy, params: { id: not_my_garden.to_param, params: { garden: valid_params } } } -+ before { delete :destroy, params: { slug: not_my_garden.to_param, params: { garden: valid_params } } } - - it { expect(response).to redirect_to(root_path) } - end -diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb -index b77eb9b5..7e9c01ff 100644 ---- a/spec/controllers/harvests_controller_spec.rb -+++ b/spec/controllers/harvests_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe HarvestsController do -@@ -20,24 +22,30 @@ describe HarvestsController do - let!(:harvest1) { FactoryBot.create(:harvest, owner_id: member1.id, crop_id: tomato.id) } - let!(:harvest2) { FactoryBot.create(:harvest, owner_id: member2.id, crop_id: maize.id) } - -+ before { Harvest.reindex } -+ - describe "assigns all harvests as @harvests" do - before { get :index, params: {} } - -- it { expect(assigns(:harvests)).to eq [harvest1, harvest2] } -+ it { expect(assigns(:harvests).size).to eq 2 } -+ it { expect(assigns(:harvests)[0]['slug']).to eq harvest1.slug } -+ it { expect(assigns(:harvests)[1]['slug']).to eq harvest2.slug } - end - - describe "picks up owner from params and shows owner's harvests only" do - before { get :index, params: { member_slug: member1.slug } } - - it { expect(assigns(:owner)).to eq member1 } -- it { expect(assigns(:harvests)).to eq [harvest1] } -+ it { expect(assigns(:harvests).size).to eq 1 } -+ it { expect(assigns(:harvests)[0]['slug']).to eq harvest1.slug } - end - - describe "picks up crop from params and shows the harvests for the crop only" do - before { get :index, params: { crop_slug: maize.name } } - - it { expect(assigns(:crop)).to eq maize } -- it { expect(assigns(:harvests)).to eq [harvest2] } -+ it { expect(assigns(:harvests).size).to eq 1 } -+ it { expect(assigns(:harvests)[0]['slug']).to eq harvest2.slug } - end - - describe "generates a csv" do -@@ -51,7 +59,7 @@ describe HarvestsController do - let(:harvest) { Harvest.create! valid_attributes } - - describe "assigns the requested harvest as @harvest" do -- before { get :show, params: { id: harvest.to_param } } -+ before { get :show, params: { slug: harvest.to_param } } - - it { expect(assigns(:harvest)).to eq(harvest) } - end -@@ -73,7 +81,7 @@ describe HarvestsController do - let(:harvest) { Harvest.create! valid_attributes } - - describe "assigns the requested harvest as @harvest" do -- before { get :edit, params: { id: harvest.to_param } } -+ before { get :edit, params: { slug: harvest.to_param } } - - it { expect(assigns(:harvest)).to eq(harvest) } - end -@@ -147,19 +155,19 @@ describe HarvestsController do - it "updates the requested harvest" do - new_crop = FactoryBot.create :crop - expect do -- put :update, params: { id: harvest.to_param, harvest: { crop_id: new_crop.id } } -+ put :update, params: { slug: harvest.to_param, harvest: { crop_id: new_crop.id } } - harvest.reload - end.to change(harvest, :crop_id).to(new_crop.id) - end - - describe "assigns the requested harvest as @harvest" do -- before { put :update, params: { id: harvest.to_param, harvest: valid_attributes } } -+ before { put :update, params: { slug: harvest.to_param, harvest: valid_attributes } } - - it { expect(assigns(:harvest)).to eq(harvest) } - end - - describe "redirects to the harvest" do -- before { put :update, params: { id: harvest.to_param, harvest: valid_attributes } } -+ before { put :update, params: { slug: harvest.to_param, harvest: valid_attributes } } - - it { expect(response).to redirect_to(harvest) } - end -@@ -170,13 +178,13 @@ describe HarvestsController do - harvest = Harvest.create! valid_attributes - # Trigger the behavior that occurs when invalid params are submitted - Harvest.any_instance.stub(:save).and_return(false) -- put :update, params: { id: harvest.to_param, harvest: { "crop_id" => "invalid value" } } -+ put :update, params: { slug: harvest.to_param, harvest: { "crop_id" => "invalid value" } } - expect(assigns(:harvest)).to eq(harvest) - end - - it "re-renders the 'edit' template" do - harvest = Harvest.create! valid_attributes -- put :update, params: { id: harvest.to_param, harvest: { "crop_id" => "invalid value" } } -+ put :update, params: { slug: harvest.to_param, harvest: { "crop_id" => "invalid value" } } - expect(response).to render_template("edit") - end - end -@@ -187,7 +195,7 @@ describe HarvestsController do - - describe "does not save planting_id" do - before do -- put :update, params: { id: harvest.to_param, -+ put :update, params: { slug: harvest.to_param, - harvest: valid_attributes.merge(planting_id: not_my_planting.id) } - end - -@@ -200,13 +208,13 @@ describe HarvestsController do - it "destroys the requested harvest" do - harvest = Harvest.create! valid_attributes - expect do -- delete :destroy, params: { id: harvest.to_param } -+ delete :destroy, params: { slug: harvest.to_param } - end.to change(Harvest, :count).by(-1) - end - - it "redirects to the harvests list" do - harvest = Harvest.create! valid_attributes -- delete :destroy, params: { id: harvest.to_param } -+ delete :destroy, params: { slug: harvest.to_param } - expect(response).to redirect_to(harvests_url) - end - end -diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb -index cb12b2bb..608addc3 100644 ---- a/spec/controllers/home_controller_spec.rb -+++ b/spec/controllers/home_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe HomeController do -diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb -index 6730b0a8..98567827 100644 ---- a/spec/controllers/likes_controller_spec.rb -+++ b/spec/controllers/likes_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe LikesController do -diff --git a/spec/controllers/member_controller_spec.rb b/spec/controllers/member_controller_spec.rb -index 5ec80e34..6e6997e9 100644 ---- a/spec/controllers/member_controller_spec.rb -+++ b/spec/controllers/member_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe MembersController do -diff --git a/spec/controllers/photo_associations_controller_spec.rb b/spec/controllers/photo_associations_controller_spec.rb -index 21ed0aa2..65d89e9f 100644 ---- a/spec/controllers/photo_associations_controller_spec.rb -+++ b/spec/controllers/photo_associations_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe PhotoAssociationsController do -diff --git a/spec/controllers/places_controller_spec.rb b/spec/controllers/places_controller_spec.rb -index a32d27c2..640adfcb 100644 ---- a/spec/controllers/places_controller_spec.rb -+++ b/spec/controllers/places_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe PlacesController do -diff --git a/spec/controllers/plant_parts_controller_spec.rb b/spec/controllers/plant_parts_controller_spec.rb -index c6e11f31..94e1e4c8 100644 ---- a/spec/controllers/plant_parts_controller_spec.rb -+++ b/spec/controllers/plant_parts_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe PlantPartsController do -diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb -index c055d776..2a3b4daa 100644 ---- a/spec/controllers/plantings_controller_spec.rb -+++ b/spec/controllers/plantings_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe PlantingsController do -@@ -10,7 +12,7 @@ describe PlantingsController do - } - end - -- describe "GET index" do -+ describe "GET index", :search do - let!(:member1) { FactoryBot.create(:member) } - let!(:member2) { FactoryBot.create(:member) } - let!(:tomato) { FactoryBot.create(:tomato) } -@@ -21,21 +23,24 @@ describe PlantingsController do - describe "assigns all plantings as @plantings" do - before { get :index } - -- it { expect(assigns(:plantings)).to match [planting1, planting2] } -+ it { expect(assigns(:plantings).size).to eq 2 } -+ it { expect(assigns(:plantings)[0]['slug']).to eq planting1.slug } -+ it { expect(assigns(:plantings)[1]['slug']).to eq planting2.slug } - end - - describe "picks up owner from params and shows owner's plantings only" do - before { get :index, params: { member_slug: member1.slug } } - - it { expect(assigns(:owner)).to eq member1 } -- it { expect(assigns(:plantings)).to eq [planting1] } -+ it { expect(assigns(:plantings).size).to eq 1 } -+ it { expect(assigns(:plantings).first['slug']).to eq planting1.slug } - end - - describe "picks up crop from params and shows the plantings for the crop only" do - before { get :index, params: { crop_slug: maize.slug } } - - it { expect(assigns(:crop)).to eq maize } -- it { expect(assigns(:plantings)).to eq [planting2] } -+ it { expect(assigns(:plantings).first['slug']).to eq planting2.slug } - end - end - -@@ -117,4 +122,19 @@ describe PlantingsController do - it { expect(assigns(:planting).owner).to eq subject.current_member } - end - end -+ -+ describe 'GET :edit' do -+ let(:my_planting) { FactoryBot.create :planting, owner: member } -+ let(:not_my_planting) { FactoryBot.create :planting } -+ context 'my planting' do -+ before { get :edit, params: { slug: my_planting } } -+ it { expect(assigns(:planting)).to eq my_planting } -+ end -+ -+ context 'not my planting' do -+ before { get :edit, params: { slug: not_my_planting } } -+ -+ it { expect(response).to redirect_to(root_path) } -+ end -+ end - end -diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb -index 0842e4a5..1bae41f1 100644 ---- a/spec/controllers/posts_controller_spec.rb -+++ b/spec/controllers/posts_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe PostsController do -diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb -index 82b52652..71b62810 100644 ---- a/spec/controllers/registrations_controller_spec.rb -+++ b/spec/controllers/registrations_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe RegistrationsController do -diff --git a/spec/controllers/robots_controller_spec.rb b/spec/controllers/robots_controller_spec.rb -index b45a8b23..5c94c1ff 100644 ---- a/spec/controllers/robots_controller_spec.rb -+++ b/spec/controllers/robots_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe RobotsController do -diff --git a/spec/controllers/scientific_names_controller_spec.rb b/spec/controllers/scientific_names_controller_spec.rb -index a5673545..d7b1612a 100644 ---- a/spec/controllers/scientific_names_controller_spec.rb -+++ b/spec/controllers/scientific_names_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe ScientificNamesController do -diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb -index 1c6e89bb..c8fdf27c 100644 ---- a/spec/controllers/seeds_controller_spec.rb -+++ b/spec/controllers/seeds_controller_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe SeedsController do -diff --git a/spec/custom_matchers.rb b/spec/custom_matchers.rb -index 1cb9d61a..972c939e 100644 ---- a/spec/custom_matchers.rb -+++ b/spec/custom_matchers.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rspec/expectations' - - RSpec::Matchers.define :have_optional do |expected| -diff --git a/spec/factories/alternate_names.rb b/spec/factories/alternate_names.rb -index 44cee8a2..df991c2b 100644 ---- a/spec/factories/alternate_names.rb -+++ b/spec/factories/alternate_names.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Read about factories at https://github.com/thoughtbot/factory_bot - - FactoryBot.define do -diff --git a/spec/factories/authentications.rb b/spec/factories/authentications.rb -index 97a34f6c..d93c37bb 100644 ---- a/spec/factories/authentications.rb -+++ b/spec/factories/authentications.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Read about factories at https://github.com/thoughtbot/factory_bot - - FactoryBot.define do -diff --git a/spec/factories/comments.rb b/spec/factories/comments.rb -index 5b726bd4..e030d34d 100644 ---- a/spec/factories/comments.rb -+++ b/spec/factories/comments.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - FactoryBot.define do - factory :comment do - post -diff --git a/spec/factories/crop.rb b/spec/factories/crop.rb -index b1c23a95..72e5d1e7 100644 ---- a/spec/factories/crop.rb -+++ b/spec/factories/crop.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - FactoryBot.define do - factory :crop do - name { "magic bean" } -@@ -51,6 +53,11 @@ FactoryBot.define do - name { "eggplant" } - end - -+ factory :crop_with_photo do -+ name { 'marshmallow' } -+ photos { FactoryBot.create_list :photo, 1 } -+ end -+ - # This should have a name that is alphabetically earlier than :uppercase - # crop to ensure that the ordering tests work. - factory :lowercasecrop do -diff --git a/spec/factories/crop_companions.rb b/spec/factories/crop_companions.rb -index 6db4f0eb..ea58b9e0 100644 ---- a/spec/factories/crop_companions.rb -+++ b/spec/factories/crop_companions.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - FactoryBot.define do - factory :crop_companion do - end -diff --git a/spec/factories/follows.rb b/spec/factories/follows.rb -index a6c609e4..4f608067 100644 ---- a/spec/factories/follows.rb -+++ b/spec/factories/follows.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - FactoryBot.define do - factory :follow do - follower -diff --git a/spec/factories/forums.rb b/spec/factories/forums.rb -index ba1e6cf8..79591579 100644 ---- a/spec/factories/forums.rb -+++ b/spec/factories/forums.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Read about factories at https://github.com/thoughtbot/factory_bot - - FactoryBot.define do -diff --git a/spec/factories/garden.rb b/spec/factories/garden.rb -index d11dcd0d..b7a5edde 100644 ---- a/spec/factories/garden.rb -+++ b/spec/factories/garden.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - FactoryBot.define do - factory :garden do - name { Faker::Vehicle.vin } -diff --git a/spec/factories/garden_types.rb b/spec/factories/garden_types.rb -index 942fd793..02d5ec75 100644 ---- a/spec/factories/garden_types.rb -+++ b/spec/factories/garden_types.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - FactoryBot.define do - factory :garden_type do - name { "homemade swamp" } -diff --git a/spec/factories/harvests.rb b/spec/factories/harvests.rb -index 426c3d24..d4bd0f18 100644 ---- a/spec/factories/harvests.rb -+++ b/spec/factories/harvests.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Read about factories at https://github.com/thoughtbot/factory_bot - - FactoryBot.define do -diff --git a/spec/factories/like.rb b/spec/factories/like.rb -index bf19554b..ffb41c8d 100644 ---- a/spec/factories/like.rb -+++ b/spec/factories/like.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - FactoryBot.define do - factory :like do - member -diff --git a/spec/factories/member.rb b/spec/factories/member.rb -index 87b5326f..3a02e2c3 100644 ---- a/spec/factories/member.rb -+++ b/spec/factories/member.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - FactoryBot.define do - factory :member, aliases: %i(author owner sender recipient creator) do - login_name { (0...8).map { rand(65..90).chr }.join } -diff --git a/spec/factories/notifications.rb b/spec/factories/notifications.rb -index 4d2cee82..a143c777 100644 ---- a/spec/factories/notifications.rb -+++ b/spec/factories/notifications.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Read about factories at https://github.com/thoughtbot/factory_bot - - FactoryBot.define do -diff --git a/spec/factories/photos.rb b/spec/factories/photos.rb -index 41e581d2..405edfd7 100644 ---- a/spec/factories/photos.rb -+++ b/spec/factories/photos.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Read about factories at https://github.com/thoughtbot/factory_bot - - FactoryBot.define do -diff --git a/spec/factories/plant_parts.rb b/spec/factories/plant_parts.rb -index 42a30afd..7fecd326 100644 ---- a/spec/factories/plant_parts.rb -+++ b/spec/factories/plant_parts.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Read about factories at https://github.com/thoughtbot/factory_bot - - FactoryBot.define do -diff --git a/spec/factories/planting.rb b/spec/factories/planting.rb -index 8fb709d1..cfdcd2b1 100644 ---- a/spec/factories/planting.rb -+++ b/spec/factories/planting.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - FactoryBot.define do - factory :planting do - owner -diff --git a/spec/factories/post.rb b/spec/factories/post.rb -index f3471042..c035fdbe 100644 ---- a/spec/factories/post.rb -+++ b/spec/factories/post.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - FactoryBot.define do - factory :post do - subject { Faker::Book.title } -diff --git a/spec/factories/roles.rb b/spec/factories/roles.rb -index 3e33d972..c7c57f7e 100644 ---- a/spec/factories/roles.rb -+++ b/spec/factories/roles.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Read about factories at https://github.com/thoughtbot/factory_bot - - FactoryBot.define do -diff --git a/spec/factories/scientific_name.rb b/spec/factories/scientific_name.rb -index 7e0e0446..ec43799c 100644 ---- a/spec/factories/scientific_name.rb -+++ b/spec/factories/scientific_name.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - FactoryBot.define do - factory :scientific_name do - association :crop, factory: :crop -diff --git a/spec/factories/seeds.rb b/spec/factories/seeds.rb -index 2f523859..deafb530 100644 ---- a/spec/factories/seeds.rb -+++ b/spec/factories/seeds.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Read about factories at https://github.com/thoughtbot/factory_bot - - FactoryBot.define do -diff --git a/spec/features/admin/admin_spec.rb b/spec/features/admin/admin_spec.rb -index cbd83bf5..f5b384d5 100644 ---- a/spec/features/admin/admin_spec.rb -+++ b/spec/features/admin/admin_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "forums", js: true do -diff --git a/spec/features/admin/forums_spec.rb b/spec/features/admin/forums_spec.rb -index 7a41266c..ab44e2ae 100644 ---- a/spec/features/admin/forums_spec.rb -+++ b/spec/features/admin/forums_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "forums", js: true do -diff --git a/spec/features/cms_spec.rb b/spec/features/cms_spec.rb -index d13fc1b4..253750cf 100644 ---- a/spec/features/cms_spec.rb -+++ b/spec/features/cms_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "cms admin" do -diff --git a/spec/features/comments/commenting_a_comment_spec.rb b/spec/features/comments/commenting_a_comment_spec.rb -index 6debc9d1..ded09272 100644 ---- a/spec/features/comments/commenting_a_comment_spec.rb -+++ b/spec/features/comments/commenting_a_comment_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'Commenting on a post' do -diff --git a/spec/features/conversations/index_spec.rb b/spec/features/conversations/index_spec.rb -index 969fc447..9df3b584 100644 ---- a/spec/features/conversations/index_spec.rb -+++ b/spec/features/conversations/index_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Conversations", :js do -diff --git a/spec/features/conversations/show_spec.rb b/spec/features/conversations/show_spec.rb -index ccf92fb8..1bcfb887 100644 ---- a/spec/features/conversations/show_spec.rb -+++ b/spec/features/conversations/show_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Conversations", :js do -diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb -index adfc3b4e..bb4843e0 100644 ---- a/spec/features/crops/alternate_name_spec.rb -+++ b/spec/features/crops/alternate_name_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Alternate names", js: true do -diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb -index d60727bb..07a0f5a4 100644 ---- a/spec/features/crops/browse_crops_spec.rb -+++ b/spec/features/crops/browse_crops_spec.rb -@@ -1,6 +1,8 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - --describe "browse crops" do -+describe "browse crops", :search do - let!(:tomato) { FactoryBot.create :tomato } - let!(:maize) { FactoryBot.create :maize } - let!(:pending_crop) { FactoryBot.create :crop_request } -@@ -8,6 +10,7 @@ describe "browse crops" do - - shared_examples 'shows crops' do - before { visit crops_path } -+ - it "has a form for sorting by" do - expect(page).to have_css "select#sort" - end -diff --git a/spec/features/crops/creating_a_crop_spec.rb b/spec/features/crops/creating_a_crop_spec.rb -index 6240db8d..c4782975 100644 ---- a/spec/features/crops/creating_a_crop_spec.rb -+++ b/spec/features/crops/creating_a_crop_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Crop", js: true do -diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb -index cec0579a..ec1ff63c 100644 ---- a/spec/features/crops/crop_detail_page_spec.rb -+++ b/spec/features/crops/crop_detail_page_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "crop detail page", js: true do -diff --git a/spec/features/crops/crop_photos_spec.rb b/spec/features/crops/crop_photos_spec.rb -index 13ecc14a..1fc44772 100644 ---- a/spec/features/crops/crop_photos_spec.rb -+++ b/spec/features/crops/crop_photos_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "crop detail page", js: true do -diff --git a/spec/features/crops/crop_search_spec.rb b/spec/features/crops/crop_search_spec.rb -index b87655a0..af39c174 100644 ---- a/spec/features/crops/crop_search_spec.rb -+++ b/spec/features/crops/crop_search_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "crop search" do -diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb -index 5dd8af71..328e560c 100644 ---- a/spec/features/crops/crop_wranglers_spec.rb -+++ b/spec/features/crops/crop_wranglers_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "crop wranglers", js: true do -diff --git a/spec/features/crops/crop_wrangling_button_spec.rb b/spec/features/crops/crop_wrangling_button_spec.rb -index 3545db9f..a081aff7 100644 ---- a/spec/features/crops/crop_wrangling_button_spec.rb -+++ b/spec/features/crops/crop_wrangling_button_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "crop wrangling button" do -diff --git a/spec/features/crops/delete_crop_spec.rb b/spec/features/crops/delete_crop_spec.rb -index 41092c89..941496e1 100644 ---- a/spec/features/crops/delete_crop_spec.rb -+++ b/spec/features/crops/delete_crop_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Delete crop spec" do -diff --git a/spec/features/crops/inflections_spec.rb b/spec/features/crops/inflections_spec.rb -index c7ca5ce3..9df14594 100644 ---- a/spec/features/crops/inflections_spec.rb -+++ b/spec/features/crops/inflections_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "irregular crop inflections" do -diff --git a/spec/features/crops/request_new_crop_spec.rb b/spec/features/crops/request_new_crop_spec.rb -index da38b1ec..3964ad6b 100644 ---- a/spec/features/crops/request_new_crop_spec.rb -+++ b/spec/features/crops/request_new_crop_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Requesting a new crop" do -diff --git a/spec/features/crops/requested_crops_spec.rb b/spec/features/crops/requested_crops_spec.rb -index e73292c1..0556fb2a 100644 ---- a/spec/features/crops/requested_crops_spec.rb -+++ b/spec/features/crops/requested_crops_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Requesting Crops" do -diff --git a/spec/features/crops/scientific_name_spec.rb b/spec/features/crops/scientific_name_spec.rb -index 63fad9ee..a8a523cb 100644 ---- a/spec/features/crops/scientific_name_spec.rb -+++ b/spec/features/crops/scientific_name_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Scientific names", js: true do -diff --git a/spec/features/crops/show_spec.rb b/spec/features/crops/show_spec.rb -index 48d08325..a219f774 100644 ---- a/spec/features/crops/show_spec.rb -+++ b/spec/features/crops/show_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "browse crops" do -diff --git a/spec/features/footer_spec.rb b/spec/features/footer_spec.rb -index 8d6225ec..6e5713f6 100644 ---- a/spec/features/footer_spec.rb -+++ b/spec/features/footer_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "footer", js: true do -diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb -index 74fc1080..6c1fc8b4 100644 ---- a/spec/features/gardens/actions_spec.rb -+++ b/spec/features/gardens/actions_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - require 'custom_matchers' - -diff --git a/spec/features/gardens/adding_gardens_spec.rb b/spec/features/gardens/adding_gardens_spec.rb -index 7320a124..d281e965 100644 ---- a/spec/features/gardens/adding_gardens_spec.rb -+++ b/spec/features/gardens/adding_gardens_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - require 'custom_matchers' - -diff --git a/spec/features/gardens/gardens_spec.rb b/spec/features/gardens/gardens_spec.rb -index 6b845bc5..71465795 100644 ---- a/spec/features/gardens/gardens_spec.rb -+++ b/spec/features/gardens/gardens_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Planting a crop", js: true do -diff --git a/spec/features/gardens/index_spec.rb b/spec/features/gardens/index_spec.rb -index b5eb5d3d..00cfad3a 100644 ---- a/spec/features/gardens/index_spec.rb -+++ b/spec/features/gardens/index_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - require 'custom_matchers' - -diff --git a/spec/features/harvests/browse_harvests_spec.rb b/spec/features/harvests/browse_harvests_spec.rb -index 6ead7e23..a4467262 100644 ---- a/spec/features/harvests/browse_harvests_spec.rb -+++ b/spec/features/harvests/browse_harvests_spec.rb -@@ -1,12 +1,15 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - --describe "browse harvests" do -+describe "browse harvests", :search do - subject { page } - - let!(:harvest) { create :harvest, owner: member } - - context 'signed in' do - include_context 'signed in member' -+ - describe 'blank optional fields' do - let!(:harvest) { create :harvest, :no_description } - -@@ -20,9 +23,7 @@ describe "browse harvests" do - describe "filled in optional fields" do - let!(:harvest) { create :harvest, :long_description } - -- before do -- visit harvests_path -- end -+ before { visit harvests_path } - - it 'links to #show' do - expect(subject).to have_link harvest.crop.name, href: harvest_path(harvest) -diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb -index a551d4df..9d4daa5c 100644 ---- a/spec/features/harvests/harvesting_a_crop_spec.rb -+++ b/spec/features/harvests/harvesting_a_crop_spec.rb -@@ -1,7 +1,9 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - require 'custom_matchers' - --describe "Harvesting a crop", :js do -+describe "Harvesting a crop", :js, :search do - context 'signed in' do - include_context 'signed in member' - let!(:maize) { create :maize } -@@ -38,12 +40,15 @@ describe "Harvesting a crop", :js do - expect(page).to have_content "harvest was successfully created." - end - -- it "Clicking link to owner's profile" do -- visit member_harvests_path(member) -- within '.login-name' do -- click_link member.login_name -+ describe 'member harvests' do -+ before { visit member_harvests_path(member) } -+ it { expect(page).to have_text "#{member.login_name}'s harvests" } -+ it "Clicking link to owner's profile" do -+ within '.login-name' do -+ click_link member.login_name -+ end -+ expect(current_path).to eq member_path(member) - end -- expect(current_path).to eq member_path member - end - - describe "Harvesting from crop page" do -diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb -index cbd14b4d..fa6bddae 100644 ---- a/spec/features/home/home_spec.rb -+++ b/spec/features/home/home_spec.rb -@@ -1,6 +1,8 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - --describe "home page" do -+describe "home page", :search do - subject { page } - - let(:member) { FactoryBot.create :member } -@@ -21,7 +23,10 @@ describe "home page" do - planting.photos << photo - seed.photos << photo - harvest.photos << photo -- Crop.reindex -+ Crop.searchkick_index.refresh -+ Planting.searchkick_index.refresh -+ Seed.searchkick_index.refresh -+ Harvest.searchkick_index.refresh - end - - before { visit root_path } -diff --git a/spec/features/likeable_spec.rb b/spec/features/likeable_spec.rb -index 95503efa..0b44d374 100644 ---- a/spec/features/likeable_spec.rb -+++ b/spec/features/likeable_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'Likeable', js: true do -diff --git a/spec/features/locale_spec.rb b/spec/features/locale_spec.rb -index 2dce809a..ac4ba081 100644 ---- a/spec/features/locale_spec.rb -+++ b/spec/features/locale_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Changing locales", js: true do -diff --git a/spec/features/members/ban_spec.rb b/spec/features/members/ban_spec.rb -index f6f99e69..3395637c 100644 ---- a/spec/features/members/ban_spec.rb -+++ b/spec/features/members/ban_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "members list" do -diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb -index ce3ff776..a8ca9fb8 100644 ---- a/spec/features/members/deletion_spec.rb -+++ b/spec/features/members/deletion_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "member deletion" do -diff --git a/spec/features/members/following_spec.rb b/spec/features/members/following_spec.rb -index 42a20df3..a48bed81 100644 ---- a/spec/features/members/following_spec.rb -+++ b/spec/features/members/following_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "follows", :js do -diff --git a/spec/features/members/list_spec.rb b/spec/features/members/list_spec.rb -index f00b1daa..b26ead43 100644 ---- a/spec/features/members/list_spec.rb -+++ b/spec/features/members/list_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "members list" do -diff --git a/spec/features/members/profile_spec.rb b/spec/features/members/profile_spec.rb -index 4b51b586..08438efd 100644 ---- a/spec/features/members/profile_spec.rb -+++ b/spec/features/members/profile_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "member profile", js: true do -diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb -index 05efb57f..530a6b54 100644 ---- a/spec/features/percy/percy_spec.rb -+++ b/spec/features/percy/percy_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'Test with visual testing', type: :feature, js: true do -diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb -index d52a1ef4..b500a89d 100644 ---- a/spec/features/photos/new_photo_spec.rb -+++ b/spec/features/photos/new_photo_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "new photo page" do -diff --git a/spec/features/photos/show_photo_spec.rb b/spec/features/photos/show_photo_spec.rb -index 68bf8ea8..a2a517c1 100644 ---- a/spec/features/photos/show_photo_spec.rb -+++ b/spec/features/photos/show_photo_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "show photo page" do -diff --git a/spec/features/places/searching_a_place_spec.rb b/spec/features/places/searching_a_place_spec.rb -index 5b698532..d31eee6b 100644 ---- a/spec/features/places/searching_a_place_spec.rb -+++ b/spec/features/places/searching_a_place_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe "User searches" do -diff --git a/spec/features/planting_reminder_spec.rb b/spec/features/planting_reminder_spec.rb -index 5caecbc5..8ac7703a 100644 ---- a/spec/features/planting_reminder_spec.rb -+++ b/spec/features/planting_reminder_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - require 'capybara/email/rspec' - -diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb -index 2ca3439d..a4cbe5ed 100644 ---- a/spec/features/plantings/planting_a_crop_spec.rb -+++ b/spec/features/plantings/planting_a_crop_spec.rb -@@ -1,7 +1,9 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - require 'custom_matchers' - --describe "Planting a crop", :js do -+describe "Planting a crop", :js, :search do - let!(:maize) { FactoryBot.create :maize } - let(:garden) { FactoryBot.create :garden, owner: member, name: 'Orchard' } - let!(:planting) do -diff --git a/spec/features/plantings/prediction_spec.rb b/spec/features/plantings/prediction_spec.rb -index 1efa4ac5..c22734a7 100644 ---- a/spec/features/plantings/prediction_spec.rb -+++ b/spec/features/plantings/prediction_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - require 'custom_matchers' - describe "Display a planting", :js do -diff --git a/spec/features/plantings/show_spec.rb b/spec/features/plantings/show_spec.rb -index 7207b479..3ffcb45b 100644 ---- a/spec/features/plantings/show_spec.rb -+++ b/spec/features/plantings/show_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - require 'custom_matchers' - -diff --git a/spec/features/posts/posting_a_post_spec.rb b/spec/features/posts/posting_a_post_spec.rb -index f1b61bc8..cd1a4b0a 100644 ---- a/spec/features/posts/posting_a_post_spec.rb -+++ b/spec/features/posts/posting_a_post_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'Post a post' do -diff --git a/spec/features/rss/comments_spec.rb b/spec/features/rss/comments_spec.rb -index 1b0263d6..5b678330 100644 ---- a/spec/features/rss/comments_spec.rb -+++ b/spec/features/rss/comments_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'Comments RSS feed' do -diff --git a/spec/features/rss/crops_spec.rb b/spec/features/rss/crops_spec.rb -index 704dd60b..7e26d30e 100644 ---- a/spec/features/rss/crops_spec.rb -+++ b/spec/features/rss/crops_spec.rb -@@ -1,12 +1,16 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'Crops RSS feed' do - it 'The index feed exists' do -+ Crop.reindex - visit crops_path(format: 'rss') - # expect(page.status_code).to equal 200 - end - - it 'The index title is what we expect' do -+ Crop.reindex - visit crops_path(format: 'rss') - expect(page).to have_content "Recently added crops (#{ENV['GROWSTUFF_SITE_NAME']})" - end -diff --git a/spec/features/rss/members_spec.rb b/spec/features/rss/members_spec.rb -index 1daefcd5..ba63a1a2 100644 ---- a/spec/features/rss/members_spec.rb -+++ b/spec/features/rss/members_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'Members RSS feed' do -diff --git a/spec/features/rss/plantings_spec.rb b/spec/features/rss/plantings_spec.rb -index 7a6e31b9..30ffba94 100644 ---- a/spec/features/rss/plantings_spec.rb -+++ b/spec/features/rss/plantings_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'Plantings RSS feed' do -@@ -7,6 +9,7 @@ describe 'Plantings RSS feed' do - end - - it 'The index title is what we expect' do -+ Planting.reindex - visit plantings_path(format: 'rss') - expect(page).to have_content "Recent plantings from "\ - "#{@owner || 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" -diff --git a/spec/features/rss/posts_spec.rb b/spec/features/rss/posts_spec.rb -index 0b85590c..b07ca28c 100644 ---- a/spec/features/rss/posts_spec.rb -+++ b/spec/features/rss/posts_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'Posts RSS feed' do -diff --git a/spec/features/rss/seeds_spec.rb b/spec/features/rss/seeds_spec.rb -index 5a50e881..c0a2e141 100644 ---- a/spec/features/rss/seeds_spec.rb -+++ b/spec/features/rss/seeds_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'Seeds RSS feed' do -diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb -index 9ab32788..1b7b3fcc 100644 ---- a/spec/features/seeds/adding_seeds_spec.rb -+++ b/spec/features/seeds/adding_seeds_spec.rb -@@ -1,7 +1,9 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - require 'custom_matchers' - --describe "Seeds", :js do -+describe "Seeds", :js, :search do - context 'signed in' do - include_context 'signed in member' - let!(:maize) { create :maize } -diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb -index 0aa54f12..8de59ab4 100644 ---- a/spec/features/seeds/misc_seeds_spec.rb -+++ b/spec/features/seeds/misc_seeds_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "seeds", js: true do -diff --git a/spec/features/seeds/seed_photos.rb b/spec/features/seeds/seed_photos.rb -index 6f4d9828..37640f12 100644 ---- a/spec/features/seeds/seed_photos.rb -+++ b/spec/features/seeds/seed_photos.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - require 'custom_matchers' - -diff --git a/spec/features/shared_examples/append_date.rb b/spec/features/shared_examples/append_date.rb -index 2680dac3..3b8b6ec6 100644 ---- a/spec/features/shared_examples/append_date.rb -+++ b/spec/features/shared_examples/append_date.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - shared_examples "append date" do - let(:this_month) { Time.zone.today.strftime("%b") } - let(:this_year) { Time.zone.today.year } -diff --git a/spec/features/shared_examples/crop_suggest.rb b/spec/features/shared_examples/crop_suggest.rb -index b7e49dbd..33775c74 100644 ---- a/spec/features/shared_examples/crop_suggest.rb -+++ b/spec/features/shared_examples/crop_suggest.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - shared_examples "crop suggest" do |resource| -diff --git a/spec/features/signin_spec.rb b/spec/features/signin_spec.rb -index 5d20b461..25cf7112 100644 ---- a/spec/features/signin_spec.rb -+++ b/spec/features/signin_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "signin", js: true do -diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb -index 4a2013e5..ca9d6455 100644 ---- a/spec/features/signout_spec.rb -+++ b/spec/features/signout_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "signout" do -diff --git a/spec/features/signup_spec.rb b/spec/features/signup_spec.rb -index 331dedaa..c7a13619 100644 ---- a/spec/features/signup_spec.rb -+++ b/spec/features/signup_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "signup", js: true do -diff --git a/spec/features/timeline/index_spec.rb b/spec/features/timeline/index_spec.rb -index bf0022df..134c4a06 100644 ---- a/spec/features/timeline/index_spec.rb -+++ b/spec/features/timeline/index_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "timeline", js: true do -diff --git a/spec/features/unsubscribing_spec.rb b/spec/features/unsubscribing_spec.rb -index 039b536b..9fff6084 100644 ---- a/spec/features/unsubscribing_spec.rb -+++ b/spec/features/unsubscribing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - require 'capybara/email/rspec' - -diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb -index ae7230a0..c285f9c5 100644 ---- a/spec/helpers/application_helper_spec.rb -+++ b/spec/helpers/application_helper_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe ApplicationHelper do -diff --git a/spec/helpers/buttons_helper_spec.rb b/spec/helpers/buttons_helper_spec.rb -index b9bdc41a..b55a4668 100644 ---- a/spec/helpers/buttons_helper_spec.rb -+++ b/spec/helpers/buttons_helper_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - # Specs in this file have access to a helper object that includes -diff --git a/spec/helpers/crops_helper_spec.rb b/spec/helpers/crops_helper_spec.rb -index 532019e4..07d8bc3f 100644 ---- a/spec/helpers/crops_helper_spec.rb -+++ b/spec/helpers/crops_helper_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe CropsHelper do -diff --git a/spec/helpers/event_helper_spec.rb b/spec/helpers/event_helper_spec.rb -index f90a04c1..634953c5 100644 ---- a/spec/helpers/event_helper_spec.rb -+++ b/spec/helpers/event_helper_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - RSpec.describe EventHelper, type: :helper do -diff --git a/spec/helpers/gardens_helper_spec.rb b/spec/helpers/gardens_helper_spec.rb -index 57db618b..3b8094ea 100644 ---- a/spec/helpers/gardens_helper_spec.rb -+++ b/spec/helpers/gardens_helper_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe GardensHelper do -diff --git a/spec/helpers/harvests_helper_spec.rb b/spec/helpers/harvests_helper_spec.rb -index 4286c326..25be2d24 100644 ---- a/spec/helpers/harvests_helper_spec.rb -+++ b/spec/helpers/harvests_helper_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe HarvestsHelper do -diff --git a/spec/helpers/photos_helper_spec.rb b/spec/helpers/photos_helper_spec.rb -index b24a254c..bbd6a32b 100644 ---- a/spec/helpers/photos_helper_spec.rb -+++ b/spec/helpers/photos_helper_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe PhotosHelper do -diff --git a/spec/helpers/plantings_helper_spec.rb b/spec/helpers/plantings_helper_spec.rb -index d28ed90d..14192bb1 100644 ---- a/spec/helpers/plantings_helper_spec.rb -+++ b/spec/helpers/plantings_helper_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe PlantingsHelper do -diff --git a/spec/helpers/seeds_helper_spec.rb b/spec/helpers/seeds_helper_spec.rb -index 7fa75132..593527fa 100644 ---- a/spec/helpers/seeds_helper_spec.rb -+++ b/spec/helpers/seeds_helper_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe SeedsHelper do -diff --git a/spec/lib/actions/oauth_signup_action_spec.rb b/spec/lib/actions/oauth_signup_action_spec.rb -index dd8310d0..621b29af 100644 ---- a/spec/lib/actions/oauth_signup_action_spec.rb -+++ b/spec/lib/actions/oauth_signup_action_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - require './lib/actions/oauth_signup_action' - -diff --git a/spec/lib/haml/filters/escaped_markdown_spec.rb b/spec/lib/haml/filters/escaped_markdown_spec.rb -index 41575129..fd9b4e0b 100644 ---- a/spec/lib/haml/filters/escaped_markdown_spec.rb -+++ b/spec/lib/haml/filters/escaped_markdown_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - require 'haml/filters' - require 'haml/filters/escaped_markdown' -diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb -index cc27bd56..5a847759 100644 ---- a/spec/lib/haml/filters/growstuff_markdown_spec.rb -+++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb -@@ -1,3 +1,4 @@ -+# rubocop:disable Style/FrozenStringLiteralComment - require 'rails_helper' - require 'haml/filters' - require 'haml/filters/growstuff_markdown' -diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb -index 389ae993..c2c206a6 100644 ---- a/spec/models/ability_spec.rb -+++ b/spec/models/ability_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - require 'cancan/matchers' - -diff --git a/spec/models/alternate_name_spec.rb b/spec/models/alternate_name_spec.rb -index 5881121c..515fdaa7 100644 ---- a/spec/models/alternate_name_spec.rb -+++ b/spec/models/alternate_name_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe AlternateName do -diff --git a/spec/models/authentication_spec.rb b/spec/models/authentication_spec.rb -index 7e02a57f..2c91dfac 100644 ---- a/spec/models/authentication_spec.rb -+++ b/spec/models/authentication_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe Authentication do -diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb -index 75166df9..f684697f 100644 ---- a/spec/models/comment_spec.rb -+++ b/spec/models/comment_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe Comment do -diff --git a/spec/models/crop_companion_spec.rb b/spec/models/crop_companion_spec.rb -index 7b6223db..e1cedbfd 100644 ---- a/spec/models/crop_companion_spec.rb -+++ b/spec/models/crop_companion_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - RSpec.describe CropCompanion, type: :model do -diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb -index 98ba5136..bb3c07b0 100644 ---- a/spec/models/crop_spec.rb -+++ b/spec/models/crop_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe Crop do -diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb -index 63e397d9..4a11208b 100644 ---- a/spec/models/follow_spec.rb -+++ b/spec/models/follow_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'spec_helper' - - describe Follow do -diff --git a/spec/models/forum_spec.rb b/spec/models/forum_spec.rb -index 310c3684..cc5b34a0 100644 ---- a/spec/models/forum_spec.rb -+++ b/spec/models/forum_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe Forum do -diff --git a/spec/models/garden_spec.rb b/spec/models/garden_spec.rb -index c62fd0f1..f154eca9 100644 ---- a/spec/models/garden_spec.rb -+++ b/spec/models/garden_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe Garden do -diff --git a/spec/models/garden_type.rb b/spec/models/garden_type.rb -index cd5862c9..9ea7ac16 100644 ---- a/spec/models/garden_type.rb -+++ b/spec/models/garden_type.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe GardenType do -diff --git a/spec/models/harvest_spec.rb b/spec/models/harvest_spec.rb -index f4b11084..5465b43e 100644 ---- a/spec/models/harvest_spec.rb -+++ b/spec/models/harvest_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe Harvest do -diff --git a/spec/models/like_spec.rb b/spec/models/like_spec.rb -index 56f35bf1..aeb5797e 100644 ---- a/spec/models/like_spec.rb -+++ b/spec/models/like_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'like' do -diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb -index 10ca3f5e..f591bd3d 100644 ---- a/spec/models/member_spec.rb -+++ b/spec/models/member_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'member' do -diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb -index 2a4c7e86..2f504f86 100644 ---- a/spec/models/notification_spec.rb -+++ b/spec/models/notification_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe Notification do -diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb -index 1102253f..b7ca5189 100644 ---- a/spec/models/photo_spec.rb -+++ b/spec/models/photo_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe Photo do -diff --git a/spec/models/plant_part_spec.rb b/spec/models/plant_part_spec.rb -index ba1e5624..7747ec4e 100644 ---- a/spec/models/plant_part_spec.rb -+++ b/spec/models/plant_part_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe PlantPart do -diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb -index fe2b5299..34d5696a 100644 ---- a/spec/models/planting_spec.rb -+++ b/spec/models/planting_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe Planting do -diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb -index e8bf3cf5..5fd8c8f6 100644 ---- a/spec/models/post_spec.rb -+++ b/spec/models/post_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe Post do -diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb -index 0fc5f92b..5893a9dc 100644 ---- a/spec/models/role_spec.rb -+++ b/spec/models/role_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe Role do -diff --git a/spec/models/scientific_name_spec.rb b/spec/models/scientific_name_spec.rb -index 0b170812..7433182e 100644 ---- a/spec/models/scientific_name_spec.rb -+++ b/spec/models/scientific_name_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe ScientificName do -diff --git a/spec/models/seed_spec.rb b/spec/models/seed_spec.rb -index a2dae315..1729f5da 100644 ---- a/spec/models/seed_spec.rb -+++ b/spec/models/seed_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe Seed do -diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb -index d780aedb..5082ce6a 100644 ---- a/spec/rails_helper.rb -+++ b/spec/rails_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # This file is copied to spec/ when you run 'rails generate rspec:install' - ENV["RAILS_ENV"] ||= 'test' - require 'simplecov' -diff --git a/spec/requests/api/v1/crop_request_spec.rb b/spec/requests/api/v1/crop_request_spec.rb -index 9eaab019..06dd0311 100644 ---- a/spec/requests/api/v1/crop_request_spec.rb -+++ b/spec/requests/api/v1/crop_request_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - RSpec.describe 'Crops', type: :request do -diff --git a/spec/requests/api/v1/gardens_request_spec.rb b/spec/requests/api/v1/gardens_request_spec.rb -index 12a729a3..3116aa20 100644 ---- a/spec/requests/api/v1/gardens_request_spec.rb -+++ b/spec/requests/api/v1/gardens_request_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - RSpec.describe 'Gardens', type: :request do -diff --git a/spec/requests/api/v1/harvest_request_spec.rb b/spec/requests/api/v1/harvest_request_spec.rb -index b958f793..eb6a6e48 100644 ---- a/spec/requests/api/v1/harvest_request_spec.rb -+++ b/spec/requests/api/v1/harvest_request_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - RSpec.describe 'Harvests', type: :request do -diff --git a/spec/requests/api/v1/member_request_spec.rb b/spec/requests/api/v1/member_request_spec.rb -index 0f1d7812..38021af3 100644 ---- a/spec/requests/api/v1/member_request_spec.rb -+++ b/spec/requests/api/v1/member_request_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - RSpec.describe 'Members', type: :request do -diff --git a/spec/requests/api/v1/photos_request_spec.rb b/spec/requests/api/v1/photos_request_spec.rb -index d194e237..1db6cede 100644 ---- a/spec/requests/api/v1/photos_request_spec.rb -+++ b/spec/requests/api/v1/photos_request_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - RSpec.describe 'Photos', type: :request do -diff --git a/spec/requests/api/v1/plantings_request_spec.rb b/spec/requests/api/v1/plantings_request_spec.rb -index 8c811f51..26781cc2 100644 ---- a/spec/requests/api/v1/plantings_request_spec.rb -+++ b/spec/requests/api/v1/plantings_request_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - RSpec.describe 'Plantings', type: :request do -diff --git a/spec/requests/api/v1/seeds_request_spec.rb b/spec/requests/api/v1/seeds_request_spec.rb -index a65243c5..b0157fbf 100644 ---- a/spec/requests/api/v1/seeds_request_spec.rb -+++ b/spec/requests/api/v1/seeds_request_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - RSpec.describe 'Photos', type: :request do -diff --git a/spec/requests/authentications_spec.rb b/spec/requests/authentications_spec.rb -index 6cc612f4..6ed6f4ea 100644 ---- a/spec/requests/authentications_spec.rb -+++ b/spec/requests/authentications_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Authentications" do -diff --git a/spec/requests/conversations_spec.rb b/spec/requests/conversations_spec.rb -index 1ed99668..745a0dbd 100644 ---- a/spec/requests/conversations_spec.rb -+++ b/spec/requests/conversations_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'Converstions' do -diff --git a/spec/requests/forums_spec.rb b/spec/requests/forums_spec.rb -index ff7cb283..2833a274 100644 ---- a/spec/requests/forums_spec.rb -+++ b/spec/requests/forums_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Forums" do -diff --git a/spec/requests/garden_types_spec.rb b/spec/requests/garden_types_spec.rb -index fbacd049..d415e5bd 100644 ---- a/spec/requests/garden_types_spec.rb -+++ b/spec/requests/garden_types_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - RSpec.describe "GardenTypes", type: :request do -diff --git a/spec/requests/gardens_spec.rb b/spec/requests/gardens_spec.rb -index 91a8dc8b..890a6edb 100644 ---- a/spec/requests/gardens_spec.rb -+++ b/spec/requests/gardens_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Gardens" do -diff --git a/spec/requests/harvests_spec.rb b/spec/requests/harvests_spec.rb -index f3774b3c..839d588f 100644 ---- a/spec/requests/harvests_spec.rb -+++ b/spec/requests/harvests_spec.rb -@@ -1,11 +1,12 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Harvests" do - describe "GET /harvests" do - it "works! (now write some real specs)" do -- # Run the generator again with the --webrat flag if you want to use webrat methods/matchers - get harvests_path -- response.status.should be(200) -+ expect(response.status).to be 200 - end - end - end -diff --git a/spec/requests/photos_spec.rb b/spec/requests/photos_spec.rb -index b937ded3..6ac4694a 100644 ---- a/spec/requests/photos_spec.rb -+++ b/spec/requests/photos_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Photos" do -diff --git a/spec/requests/plant_parts_spec.rb b/spec/requests/plant_parts_spec.rb -index 1fc2150b..a96599cb 100644 ---- a/spec/requests/plant_parts_spec.rb -+++ b/spec/requests/plant_parts_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "PlantParts" do -diff --git a/spec/requests/plantings_spec.rb b/spec/requests/plantings_spec.rb -index cb66922e..90a4b534 100644 ---- a/spec/requests/plantings_spec.rb -+++ b/spec/requests/plantings_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Plantings" do -diff --git a/spec/requests/post_spec.rb b/spec/requests/post_spec.rb -index 3bb479aa..51ccf416 100644 ---- a/spec/requests/post_spec.rb -+++ b/spec/requests/post_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Posts" do -diff --git a/spec/requests/scientific_names_spec.rb b/spec/requests/scientific_names_spec.rb -index 922f6f27..f2ce118a 100644 ---- a/spec/requests/scientific_names_spec.rb -+++ b/spec/requests/scientific_names_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "ScientificNames" do -diff --git a/spec/requests/seeds_spec.rb b/spec/requests/seeds_spec.rb -index 8bc5aecc..1440d638 100644 ---- a/spec/requests/seeds_spec.rb -+++ b/spec/requests/seeds_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "Seeds" do -diff --git a/spec/routing/admin_routing_spec.rb b/spec/routing/admin_routing_spec.rb -index 66b17bc1..287bb297 100644 ---- a/spec/routing/admin_routing_spec.rb -+++ b/spec/routing/admin_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe AdminController do -diff --git a/spec/routing/authentications_routing_spec.rb b/spec/routing/authentications_routing_spec.rb -index 0601b992..877a3539 100644 ---- a/spec/routing/authentications_routing_spec.rb -+++ b/spec/routing/authentications_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe AuthenticationsController do -diff --git a/spec/routing/comments_routing_spec.rb b/spec/routing/comments_routing_spec.rb -index 5390ab06..9fbfa436 100644 ---- a/spec/routing/comments_routing_spec.rb -+++ b/spec/routing/comments_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe CommentsController do -diff --git a/spec/routing/crops_routing_spec.rb b/spec/routing/crops_routing_spec.rb -index 30f6004d..7821db6f 100644 ---- a/spec/routing/crops_routing_spec.rb -+++ b/spec/routing/crops_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe CropsController do -diff --git a/spec/routing/follows_routing_spec.rb b/spec/routing/follows_routing_spec.rb -index ddb01e00..e79c2661 100644 ---- a/spec/routing/follows_routing_spec.rb -+++ b/spec/routing/follows_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "spec_helper" - - describe FollowsController do -diff --git a/spec/routing/forums_routing_spec.rb b/spec/routing/forums_routing_spec.rb -index 9ce6f427..5c3ade54 100644 ---- a/spec/routing/forums_routing_spec.rb -+++ b/spec/routing/forums_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe ForumsController do -diff --git a/spec/routing/garden_types_routing_spec.rb b/spec/routing/garden_types_routing_spec.rb -index 986af7b7..805ebdfa 100644 ---- a/spec/routing/garden_types_routing_spec.rb -+++ b/spec/routing/garden_types_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe GardenTypesController do -diff --git a/spec/routing/gardens_routing_spec.rb b/spec/routing/gardens_routing_spec.rb -index 02183eab..365fba5e 100644 ---- a/spec/routing/gardens_routing_spec.rb -+++ b/spec/routing/gardens_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe GardensController do -@@ -12,11 +14,11 @@ describe GardensController do - end - - it "routes to #show" do -- get("/gardens/1").should route_to("gardens#show", id: "1") -+ get("/gardens/sunny-bed").should route_to("gardens#show", slug: 'sunny-bed') - end - - it "routes to #edit" do -- get("/gardens/1/edit").should route_to("gardens#edit", id: "1") -+ get("/gardens/sunny-bed/edit").should route_to("gardens#edit", slug: 'sunny-bed') - end - - it "routes to #create" do -@@ -24,11 +26,11 @@ describe GardensController do - end - - it "routes to #update" do -- put("/gardens/1").should route_to("gardens#update", id: "1") -+ put("/gardens/sunny-bed").should route_to("gardens#update", slug: 'sunny-bed') - end - - it "routes to #destroy" do -- delete("/gardens/1").should route_to("gardens#destroy", id: "1") -+ delete("/gardens/sunny-bed").should route_to("gardens#destroy", slug: 'sunny-bed') - end - end - end -diff --git a/spec/routing/harvests_routing_spec.rb b/spec/routing/harvests_routing_spec.rb -index af623c3f..22ee305f 100644 ---- a/spec/routing/harvests_routing_spec.rb -+++ b/spec/routing/harvests_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe HarvestsController do -@@ -12,11 +14,11 @@ describe HarvestsController do - end - - it "routes to #show" do -- get("/harvests/1").should route_to("harvests#show", id: "1") -+ get("/harvests/potato").should route_to("harvests#show", slug: "potato") - end - - it "routes to #edit" do -- get("/harvests/1/edit").should route_to("harvests#edit", id: "1") -+ get("/harvests/potato/edit").should route_to("harvests#edit", slug: "potato") - end - - it "routes to #create" do -@@ -24,11 +26,11 @@ describe HarvestsController do - end - - it "routes to #update" do -- put("/harvests/1").should route_to("harvests#update", id: "1") -+ put("/harvests/potato").should route_to("harvests#update", slug: "potato") - end - - it "routes to #destroy" do -- delete("/harvests/1").should route_to("harvests#destroy", id: "1") -+ delete("/harvests/potato").should route_to("harvests#destroy", slug: "potato") - end - end - end -diff --git a/spec/routing/member_routing_spec.rb b/spec/routing/member_routing_spec.rb -new file mode 100644 -index 00000000..790ff94b ---- /dev/null -+++ b/spec/routing/member_routing_spec.rb -@@ -0,0 +1,42 @@ -+# frozen_string_literal: true -+ -+require "rails_helper" -+ -+describe MembersController do -+ describe "routing" do -+ it "routes to #index" do -+ get("/members").should route_to("members#index") -+ end -+ -+ it "routes to #new" do -+ get("/members/new").should route_to("members#new") -+ end -+ -+ it "routes to #show" do -+ get("/members/name").should route_to("members#show", slug: "name") -+ end -+ -+ it "routes to #edit" do -+ get("/members/name/edit").should route_to("members#edit", slug: "name") -+ end -+ -+ # it "routes to #create" do -+ # post("/members").should route_to("members#create") -+ # end -+ -+ it "routes to #update" do -+ put("/members/name").should route_to("members#update", slug: "name") -+ end -+ -+ it "routes to #destroy" do -+ delete("/members/name").should route_to("members#destroy", slug: "name") -+ end -+ -+ it "routes to harvests#index" do -+ get("/members/name/harvests").should route_to("harvests#index", member_slug: 'name') -+ end -+ it "routes to plantings#index" do -+ get("/members/name/plantings").should route_to("plantings#index", member_slug: 'name') -+ end -+ end -+end -diff --git a/spec/routing/photos_routing_spec.rb b/spec/routing/photos_routing_spec.rb -index a645d0a6..812acf84 100644 ---- a/spec/routing/photos_routing_spec.rb -+++ b/spec/routing/photos_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe PhotosController do -diff --git a/spec/routing/plant_parts_routing_spec.rb b/spec/routing/plant_parts_routing_spec.rb -index 966047f3..3e10372d 100644 ---- a/spec/routing/plant_parts_routing_spec.rb -+++ b/spec/routing/plant_parts_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe PlantPartsController do -diff --git a/spec/routing/plantings_routing_spec.rb b/spec/routing/plantings_routing_spec.rb -index d92d3a84..e3a8b534 100644 ---- a/spec/routing/plantings_routing_spec.rb -+++ b/spec/routing/plantings_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe PlantingsController do -@@ -12,11 +14,11 @@ describe PlantingsController do - end - - it "routes to #show" do -- get("/plantings/1").should route_to("plantings#show", id: "1") -+ get("/plantings/tomato").should route_to("plantings#show", slug: "tomato") - end - - it "routes to #edit" do -- get("/plantings/1/edit").should route_to("plantings#edit", id: "1") -+ get("/plantings/tomato/edit").should route_to("plantings#edit", slug: "tomato") - end - - it "routes to #create" do -@@ -24,11 +26,11 @@ describe PlantingsController do - end - - it "routes to #update" do -- put("/plantings/1").should route_to("plantings#update", id: "1") -+ put("/plantings/tomato").should route_to("plantings#update", slug: "tomato") - end - - it "routes to #destroy" do -- delete("/plantings/1").should route_to("plantings#destroy", id: "1") -+ delete("/plantings/tomato").should route_to("plantings#destroy", slug: "tomato") - end - end - end -diff --git a/spec/routing/roles_routing_spec.rb b/spec/routing/roles_routing_spec.rb -index c601e27e..9b61b982 100644 ---- a/spec/routing/roles_routing_spec.rb -+++ b/spec/routing/roles_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe Admin::RolesController do -diff --git a/spec/routing/scientific_names_routing_spec.rb b/spec/routing/scientific_names_routing_spec.rb -index 7bbbfa76..b52f4b43 100644 ---- a/spec/routing/scientific_names_routing_spec.rb -+++ b/spec/routing/scientific_names_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe ScientificNamesController do -diff --git a/spec/routing/seeds_routing_spec.rb b/spec/routing/seeds_routing_spec.rb -index 9ebfbdb0..65710acb 100644 ---- a/spec/routing/seeds_routing_spec.rb -+++ b/spec/routing/seeds_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe SeedsController do -@@ -12,11 +14,11 @@ describe SeedsController do - end - - it "routes to #show" do -- get("/seeds/1").should route_to("seeds#show", id: "1") -+ get("/seeds/corn").should route_to("seeds#show", slug: 'corn') - end - - it "routes to #edit" do -- get("/seeds/1/edit").should route_to("seeds#edit", id: "1") -+ get("/seeds/corn/edit").should route_to("seeds#edit", slug: 'corn') - end - - it "routes to #create" do -@@ -24,11 +26,11 @@ describe SeedsController do - end - - it "routes to #update" do -- put("/seeds/1").should route_to("seeds#update", id: "1") -+ put("/seeds/corn").should route_to("seeds#update", slug: 'corn') - end - - it "routes to #destroy" do -- delete("/seeds/1").should route_to("seeds#destroy", id: "1") -+ delete("/seeds/corn").should route_to("seeds#destroy", slug: 'corn') - end - end - end -diff --git a/spec/routing/updates_routing_spec.rb b/spec/routing/updates_routing_spec.rb -index 96664751..9c971552 100644 ---- a/spec/routing/updates_routing_spec.rb -+++ b/spec/routing/updates_routing_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require "rails_helper" - - describe PostsController do -diff --git a/spec/services/timeline_service_spec.rb b/spec/services/timeline_service_spec.rb -index 4ab41f71..632c8b0a 100644 ---- a/spec/services/timeline_service_spec.rb -+++ b/spec/services/timeline_service_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'timeline' do -diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb -index df3b6f92..d84389ef 100644 ---- a/spec/spec_helper.rb -+++ b/spec/spec_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # This file was generated by the `rails generate rspec:install` command. Conventionally, all - # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. - # The generated `.rspec` file contains `--require spec_helper` which will cause this -@@ -36,7 +38,10 @@ RSpec.configure do |config| - - config.before(:suite) do - # reindex models -- Crop.reindex -+ Crop.searchkick_index.refresh -+ Seed.searchkick_index.refresh -+ Harvest.searchkick_index.refresh -+ Planting.searchkick_index.refresh - - # and disable callbacks - Searchkick.disable_callbacks -diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb -index b54cf028..f2d23aaf 100644 ---- a/spec/support/controller_macros.rb -+++ b/spec/support/controller_macros.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - # Taken unashamedly from https://github.com/plataformatec/devise/wiki/How-To%3a-Controllers-and-Views-tests-with-Rails-3-%28and-rspec%29 - module ControllerMacros - def login_member(member_factory = :member) -diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb -index 8aa07643..0821d219 100644 ---- a/spec/support/database_cleaner.rb -+++ b/spec/support/database_cleaner.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - RSpec.configure do |config| - # a warning if you turn this off - config.before(:suite) do -diff --git a/spec/support/devise.rb b/spec/support/devise.rb -index 090ffc6a..c1f9c35f 100644 ---- a/spec/support/devise.rb -+++ b/spec/support/devise.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - RSpec.configure do |config| - config.include Devise::Test::ControllerHelpers, type: :controller - config.include Devise::Test::ControllerHelpers, type: :view -diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb -index 97371862..91b877e1 100644 ---- a/spec/support/feature_helpers.rb -+++ b/spec/support/feature_helpers.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - module FeatureHelpers - def fill_autocomplete(field, options = {}) - Crop.reindex -diff --git a/spec/support/is_likeable.rb b/spec/support/is_likeable.rb -index c402d589..9fbae542 100644 ---- a/spec/support/is_likeable.rb -+++ b/spec/support/is_likeable.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - shared_examples "it is likeable" do - before do - # Possibly a horrible hack. -diff --git a/spec/swagger_helper.rb b/spec/swagger_helper.rb -index 327b2c80..67a935fa 100644 ---- a/spec/swagger_helper.rb -+++ b/spec/swagger_helper.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - RSpec.configure do |config| -diff --git a/spec/views/admin/index_spec.rb b/spec/views/admin/index_spec.rb -index 7379519c..4e8dbba2 100644 ---- a/spec/views/admin/index_spec.rb -+++ b/spec/views/admin/index_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'admin/index.html.haml', type: "view" do -diff --git a/spec/views/admin/newsletter_spec.rb b/spec/views/admin/newsletter_spec.rb -index fbae64de..464f2d6c 100644 ---- a/spec/views/admin/newsletter_spec.rb -+++ b/spec/views/admin/newsletter_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'admin/newsletter.html.haml', type: "view" do -diff --git a/spec/views/admin/roles/edit.html.haml_spec.rb b/spec/views/admin/roles/edit.html.haml_spec.rb -index 859ac249..d2ffc114 100644 ---- a/spec/views/admin/roles/edit.html.haml_spec.rb -+++ b/spec/views/admin/roles/edit.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "admin/roles/edit" do -diff --git a/spec/views/admin/roles/index.html.haml_spec.rb b/spec/views/admin/roles/index.html.haml_spec.rb -index f852dd0d..d8d0c7bc 100644 ---- a/spec/views/admin/roles/index.html.haml_spec.rb -+++ b/spec/views/admin/roles/index.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "admin/roles/index" do -diff --git a/spec/views/admin/roles/new.html.haml_spec.rb b/spec/views/admin/roles/new.html.haml_spec.rb -index 3ce6b0c8..b9b3dc7b 100644 ---- a/spec/views/admin/roles/new.html.haml_spec.rb -+++ b/spec/views/admin/roles/new.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "admin/roles/new" do -diff --git a/spec/views/comments/edit.html.haml_spec.rb b/spec/views/comments/edit.html.haml_spec.rb -index b7a547f8..b95fb9d2 100644 ---- a/spec/views/comments/edit.html.haml_spec.rb -+++ b/spec/views/comments/edit.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "comments/edit" do -diff --git a/spec/views/comments/index.rss.haml_spec.rb b/spec/views/comments/index.rss.haml_spec.rb -index d1b376ca..38b5a238 100644 ---- a/spec/views/comments/index.rss.haml_spec.rb -+++ b/spec/views/comments/index.rss.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'comments/index.rss.haml' do -diff --git a/spec/views/comments/new.html.haml_spec.rb b/spec/views/comments/new.html.haml_spec.rb -index c2d7b7e8..5b86a3a2 100644 ---- a/spec/views/comments/new.html.haml_spec.rb -+++ b/spec/views/comments/new.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "comments/new" do -diff --git a/spec/views/crops/_grown_for.html.haml_spec.rb b/spec/views/crops/_grown_for.html.haml_spec.rb -index f3beba7a..3cd68bfd 100644 ---- a/spec/views/crops/_grown_for.html.haml_spec.rb -+++ b/spec/views/crops/_grown_for.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "crops/_grown_for" do -diff --git a/spec/views/crops/_popover.html.haml_spec.rb b/spec/views/crops/_popover.html.haml_spec.rb -index 577667ec..09cd2eda 100644 ---- a/spec/views/crops/_popover.html.haml_spec.rb -+++ b/spec/views/crops/_popover.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "crops/_popover" do -diff --git a/spec/views/crops/edit.html.haml_spec.rb b/spec/views/crops/edit.html.haml_spec.rb -index ba43f645..6791c339 100644 ---- a/spec/views/crops/edit.html.haml_spec.rb -+++ b/spec/views/crops/edit.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "crops/edit" do -diff --git a/spec/views/crops/hierarchy.html.haml_spec.rb b/spec/views/crops/hierarchy.html.haml_spec.rb -index c1d79f0b..8232e14f 100644 ---- a/spec/views/crops/hierarchy.html.haml_spec.rb -+++ b/spec/views/crops/hierarchy.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "crops/hierarchy" do -diff --git a/spec/views/crops/index.html.haml_spec.rb b/spec/views/crops/index.html.haml_spec.rb -index 9c1c1680..db69f913 100644 ---- a/spec/views/crops/index.html.haml_spec.rb -+++ b/spec/views/crops/index.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "crops/index" do -diff --git a/spec/views/crops/index.rss.haml_spec.rb b/spec/views/crops/index.rss.haml_spec.rb -index a7afbba7..5d1bfaef 100644 ---- a/spec/views/crops/index.rss.haml_spec.rb -+++ b/spec/views/crops/index.rss.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'crops/index.rss.haml' do -diff --git a/spec/views/crops/new.html.haml_spec.rb b/spec/views/crops/new.html.haml_spec.rb -index 0dcf4362..95dfc5db 100644 ---- a/spec/views/crops/new.html.haml_spec.rb -+++ b/spec/views/crops/new.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "crops/new" do -diff --git a/spec/views/crops/wrangle.html.haml_spec.rb b/spec/views/crops/wrangle.html.haml_spec.rb -index 1ae400e7..89c5d0b1 100644 ---- a/spec/views/crops/wrangle.html.haml_spec.rb -+++ b/spec/views/crops/wrangle.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "crops/wrangle" do -diff --git a/spec/views/devise/confirmations/new_spec.rb b/spec/views/devise/confirmations/new_spec.rb -index de26a4ad..ce429025 100644 ---- a/spec/views/devise/confirmations/new_spec.rb -+++ b/spec/views/devise/confirmations/new_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - describe 'devise/confirmations/new.html.haml', type: "view" do - before do - @view.stub(:resource).and_return(Member.new) -diff --git a/spec/views/devise/mailer/confirmation_instructions_spec.rb b/spec/views/devise/mailer/confirmation_instructions_spec.rb -index 08e41179..0f4b25f0 100644 ---- a/spec/views/devise/mailer/confirmation_instructions_spec.rb -+++ b/spec/views/devise/mailer/confirmation_instructions_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'devise/mailer/confirmation_instructions.html.haml', type: "view" do -diff --git a/spec/views/devise/mailer/reset_password_instructions_spec.rb b/spec/views/devise/mailer/reset_password_instructions_spec.rb -index ef90f758..7dce3e1f 100644 ---- a/spec/views/devise/mailer/reset_password_instructions_spec.rb -+++ b/spec/views/devise/mailer/reset_password_instructions_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'devise/mailer/reset_password_instructions.html.haml', type: "view" do -diff --git a/spec/views/devise/mailer/unlock_instructions_spec.rb b/spec/views/devise/mailer/unlock_instructions_spec.rb -index d3ac3357..5db8a66c 100644 ---- a/spec/views/devise/mailer/unlock_instructions_spec.rb -+++ b/spec/views/devise/mailer/unlock_instructions_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - describe 'devise/mailer/unlock_instructions.html.haml', type: "view" do - context "logged in" do -diff --git a/spec/views/devise/registrations/edit_spec.rb b/spec/views/devise/registrations/edit_spec.rb -index b260d13a..1ca0ae8a 100644 ---- a/spec/views/devise/registrations/edit_spec.rb -+++ b/spec/views/devise/registrations/edit_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'devise/registrations/edit.html.haml', type: "view" do -diff --git a/spec/views/devise/registrations/new_spec.rb b/spec/views/devise/registrations/new_spec.rb -index 0ee95b5b..05c690ca 100644 ---- a/spec/views/devise/registrations/new_spec.rb -+++ b/spec/views/devise/registrations/new_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'devise/registrations/new.html.haml', type: "view" do -diff --git a/spec/views/devise/sessions/new_spec.rb b/spec/views/devise/sessions/new_spec.rb -index d8ae1c48..5537f6fd 100644 ---- a/spec/views/devise/sessions/new_spec.rb -+++ b/spec/views/devise/sessions/new_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'devise/sessions/new.html.haml', type: "view" do -diff --git a/spec/views/devise/shared/_links_spec.rb b/spec/views/devise/shared/_links_spec.rb -index c1910159..1a0c55d5 100644 ---- a/spec/views/devise/shared/_links_spec.rb -+++ b/spec/views/devise/shared/_links_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - describe 'devise/shared/_links.haml', type: "view" do - def devise_mapping(register, recover, confirm, lock, oauth) - dm = double("mappings") -diff --git a/spec/views/devise/unlocks/new_spec.rb b/spec/views/devise/unlocks/new_spec.rb -index 68666532..184b820d 100644 ---- a/spec/views/devise/unlocks/new_spec.rb -+++ b/spec/views/devise/unlocks/new_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'devise/unlocks/new.html.haml', type: "view" do -diff --git a/spec/views/forums/edit.html.haml_spec.rb b/spec/views/forums/edit.html.haml_spec.rb -index 57747391..08580e4e 100644 ---- a/spec/views/forums/edit.html.haml_spec.rb -+++ b/spec/views/forums/edit.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "forums/edit" do -diff --git a/spec/views/forums/index.html.haml_spec.rb b/spec/views/forums/index.html.haml_spec.rb -index 9bfef29e..74a0684a 100644 ---- a/spec/views/forums/index.html.haml_spec.rb -+++ b/spec/views/forums/index.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "forums/index" do -diff --git a/spec/views/forums/new.html.haml_spec.rb b/spec/views/forums/new.html.haml_spec.rb -index 4fec098d..ebb71168 100644 ---- a/spec/views/forums/new.html.haml_spec.rb -+++ b/spec/views/forums/new.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "forums/new" do -diff --git a/spec/views/forums/show.html.haml_spec.rb b/spec/views/forums/show.html.haml_spec.rb -index c40a77a8..89d2d443 100644 ---- a/spec/views/forums/show.html.haml_spec.rb -+++ b/spec/views/forums/show.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "forums/show" do -@@ -8,8 +10,8 @@ describe "forums/show" do - - it "renders attributes" do - render -- rendered.should have_content "Everything about permaculture" -- rendered.should have_content @forum.owner.to_s -+ expect(rendered).to have_content "Everything about permaculture" -+ expect(rendered).to have_content @forum.owner.to_s - end - - it "parses markdown description into html" do -@@ -24,14 +26,14 @@ describe "forums/show" do - - it 'has no posts' do - render -- rendered.should have_content "No posts yet." -+ expect(rendered).to have_content "No posts yet." - end - - it 'shows posts' do - @post = FactoryBot.create(:post, forum: @forum) - render - assert_select "table" -- rendered.should have_content @post.subject -- rendered.should have_content @post.author.to_s -+ expect(rendered).to have_content @post.subject -+ expect(rendered).to have_content @post.author.to_s - end - end -diff --git a/spec/views/garden_types/edit.html.haml_spec.rb b/spec/views/garden_types/edit.html.haml_spec.rb -index b5c69b95..c328e427 100644 ---- a/spec/views/garden_types/edit.html.haml_spec.rb -+++ b/spec/views/garden_types/edit.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "garden_types/edit" do -diff --git a/spec/views/garden_types/new.html.haml_spec.rb b/spec/views/garden_types/new.html.haml_spec.rb -index 3241666a..e48aff0d 100644 ---- a/spec/views/garden_types/new.html.haml_spec.rb -+++ b/spec/views/garden_types/new.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "garden_types/new" do -diff --git a/spec/views/garden_types/show.html.haml_spec.rb b/spec/views/garden_types/show.html.haml_spec.rb -index 10b4d83a..33fc283e 100644 ---- a/spec/views/garden_types/show.html.haml_spec.rb -+++ b/spec/views/garden_types/show.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "garden_types/show" do -diff --git a/spec/views/gardens/edit.html.haml_spec.rb b/spec/views/gardens/edit.html.haml_spec.rb -index a0564bf8..fc1ec78e 100644 ---- a/spec/views/gardens/edit.html.haml_spec.rb -+++ b/spec/views/gardens/edit.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "gardens/edit" do -diff --git a/spec/views/gardens/new.html.haml_spec.rb b/spec/views/gardens/new.html.haml_spec.rb -index d76659f7..00bcc91e 100644 ---- a/spec/views/gardens/new.html.haml_spec.rb -+++ b/spec/views/gardens/new.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "gardens/new" do -diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb -index 7535ce8d..5bb6cf0a 100644 ---- a/spec/views/gardens/show.html.haml_spec.rb -+++ b/spec/views/gardens/show.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "gardens/show" do -diff --git a/spec/views/harvests/edit.html.haml_spec.rb b/spec/views/harvests/edit.html.haml_spec.rb -index 38307f50..2647f796 100644 ---- a/spec/views/harvests/edit.html.haml_spec.rb -+++ b/spec/views/harvests/edit.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "harvests/edit" do -diff --git a/spec/views/harvests/index.html.haml_spec.rb b/spec/views/harvests/index.html.haml_spec.rb -index 1ce56c49..d018c955 100644 ---- a/spec/views/harvests/index.html.haml_spec.rb -+++ b/spec/views/harvests/index.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "harvests/index" do -diff --git a/spec/views/harvests/index.rss.haml_spec.rb b/spec/views/harvests/index.rss.haml_spec.rb -index e3f1d20b..e4384c47 100644 ---- a/spec/views/harvests/index.rss.haml_spec.rb -+++ b/spec/views/harvests/index.rss.haml_spec.rb -@@ -1,42 +1,39 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - --describe 'harvests/index.rss.haml' do -+describe 'harvests/index.rss.haml', :search do - before do - controller.stub(:current_user) { nil } - @member = FactoryBot.create(:member) - @tomato = FactoryBot.create(:tomato) -- @maize = FactoryBot.create(:maize) -- @pp = FactoryBot.create(:plant_part) -- page = 1 -- per_page = 2 -- total_entries = 2 -- harvests = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| -- pager.replace([ -- FactoryBot.create(:harvest, -- crop: @tomato, -- owner: @member), -- FactoryBot.create(:harvest, -- crop: @maize, -- plant_part: @pp, -- owner: @member, -- quantity: 2) -- ]) -- end -- assign(:harvests, harvests) -- render -- end - -- it 'shows RSS feed title' do -- rendered.should have_content "Recent harvests from all members" -+ @harvest1 = FactoryBot.create :harvest, crop: @tomato -+ @harvest2 = FactoryBot.create :harvest, crop: @tomato -+ @harvest3 = FactoryBot.create :harvest, crop: @tomato -+ -+ Harvest.searchkick_index.refresh -+ assign(:harvests, Harvest.search(load: false)) - end - -- it "displays crop's name in title" do -- assign(:crop, @tomato) -- render -- expect(rendered).to have_content @tomato.name -+ context 'all harvests' do -+ before { render } -+ it 'shows RSS feed title' do -+ expect(rendered).to have_content "Recent harvests from all members" -+ end -+ -+ it 'shows formatted content of harvest posts' do -+ expect(rendered).to have_content "

Quantity: " -+ end - end - -- it 'shows formatted content of harvest posts' do -- expect(rendered).to have_content "

Quantity: " -+ context 'for one crop' do -+ before do -+ assign(:crop, @tomato) -+ render -+ end -+ it "displays crop's name in title" do -+ expect(rendered).to have_content @tomato.name -+ end - end - end -diff --git a/spec/views/harvests/new.html.haml_spec.rb b/spec/views/harvests/new.html.haml_spec.rb -index abe1b547..6c75a385 100644 ---- a/spec/views/harvests/new.html.haml_spec.rb -+++ b/spec/views/harvests/new.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "harvests/new" do -diff --git a/spec/views/harvests/show.html.haml_spec.rb b/spec/views/harvests/show.html.haml_spec.rb -index 4a805392..8b270ab5 100644 ---- a/spec/views/harvests/show.html.haml_spec.rb -+++ b/spec/views/harvests/show.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "harvests/show" do -diff --git a/spec/views/home/_blurb.html.haml_spec.rb b/spec/views/home/_blurb.html.haml_spec.rb -index 395ce74b..2fc29313 100644 ---- a/spec/views/home/_blurb.html.haml_spec.rb -+++ b/spec/views/home/_blurb.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'home/_blurb.html.haml', type: "view" do -diff --git a/spec/views/home/_members.html.haml_spec.rb b/spec/views/home/_members.html.haml_spec.rb -index 332af1d2..b5be1f2b 100644 ---- a/spec/views/home/_members.html.haml_spec.rb -+++ b/spec/views/home/_members.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'home/_members.html.haml', type: "view" do -diff --git a/spec/views/home/_seeds.html.haml_spec.rb b/spec/views/home/_seeds.html.haml_spec.rb -index e0b2c54b..02dd6e9f 100644 ---- a/spec/views/home/_seeds.html.haml_spec.rb -+++ b/spec/views/home/_seeds.html.haml_spec.rb -@@ -1,9 +1,14 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - --describe 'home/_seeds.html.haml', type: "view" do -+describe 'home/_seeds.html.haml', type: "view", search: true do - let!(:seed) { FactoryBot.create(:tradable_seed, owner: owner) } - let(:owner) { FactoryBot.create(:london_member) } -- before { render } -+ before do -+ Seed.searchkick_index.refresh -+ render -+ end - - it 'has a heading' do - assert_select 'h2', 'Seeds available to trade' -diff --git a/spec/views/home/_stats.html.haml_spec.rb b/spec/views/home/_stats.html.haml_spec.rb -index a9979190..15d637fd 100644 ---- a/spec/views/home/_stats.html.haml_spec.rb -+++ b/spec/views/home/_stats.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'home/_stats.html.haml', type: "view" do -diff --git a/spec/views/home/index_spec.rb b/spec/views/home/index_spec.rb -index 1289df4e..83e9308d 100644 ---- a/spec/views/home/index_spec.rb -+++ b/spec/views/home/index_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'home/index.html.haml', type: "view" do -diff --git a/spec/views/layouts/_head_spec.rb b/spec/views/layouts/_head_spec.rb -index c8235510..a516a99c 100644 ---- a/spec/views/layouts/_head_spec.rb -+++ b/spec/views/layouts/_head_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'layouts/_head.html.haml', type: "view" do -diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb -index 4a39e99b..b87bcb4d 100644 ---- a/spec/views/layouts/_header_spec.rb -+++ b/spec/views/layouts/_header_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'layouts/_header.html.haml', type: "view" do -diff --git a/spec/views/layouts/application_spec.rb b/spec/views/layouts/application_spec.rb -index f2b23d91..4ccb6950 100644 ---- a/spec/views/layouts/application_spec.rb -+++ b/spec/views/layouts/application_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'layouts/application.html.haml', type: "view" do -diff --git a/spec/views/members/_location.html.haml_spec.rb b/spec/views/members/_location.html.haml_spec.rb -index db1fae09..0ab04f47 100644 ---- a/spec/views/members/_location.html.haml_spec.rb -+++ b/spec/views/members/_location.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "members/_location" do -diff --git a/spec/views/members/index.html.haml_spec.rb b/spec/views/members/index.html.haml_spec.rb -index 34fda500..8afbb85a 100644 ---- a/spec/views/members/index.html.haml_spec.rb -+++ b/spec/views/members/index.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "members/index" do -diff --git a/spec/views/members/show.rss.haml_spec.rb b/spec/views/members/show.rss.haml_spec.rb -index ce4dc4c5..873e9ecf 100644 ---- a/spec/views/members/show.rss.haml_spec.rb -+++ b/spec/views/members/show.rss.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'members/show.rss.haml', type: "view" do -diff --git a/spec/views/photos/edit.html.haml_spec.rb b/spec/views/photos/edit.html.haml_spec.rb -index ba481b10..1e94fb7b 100644 ---- a/spec/views/photos/edit.html.haml_spec.rb -+++ b/spec/views/photos/edit.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "photos/edit" do -diff --git a/spec/views/photos/index.html.haml_spec.rb b/spec/views/photos/index.html.haml_spec.rb -index ef058e82..86843ce1 100644 ---- a/spec/views/photos/index.html.haml_spec.rb -+++ b/spec/views/photos/index.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "photos/index" do -diff --git a/spec/views/photos/new.html.haml_spec.rb b/spec/views/photos/new.html.haml_spec.rb -index 9f4072ee..d15e99e2 100644 ---- a/spec/views/photos/new.html.haml_spec.rb -+++ b/spec/views/photos/new.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "photos/new" do -diff --git a/spec/views/photos/show.html.haml_spec.rb b/spec/views/photos/show.html.haml_spec.rb -index f0f1235e..19690e30 100644 ---- a/spec/views/photos/show.html.haml_spec.rb -+++ b/spec/views/photos/show.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "photos/show" do -diff --git a/spec/views/places/_map_attribution.html.haml_spec.rb b/spec/views/places/_map_attribution.html.haml_spec.rb -index afe384df..9b869a30 100644 ---- a/spec/views/places/_map_attribution.html.haml_spec.rb -+++ b/spec/views/places/_map_attribution.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "places/_map_attribution.html.haml", type: :view do -diff --git a/spec/views/places/index.html.haml_spec.rb b/spec/views/places/index.html.haml_spec.rb -index 072eb4ca..f49bb923 100644 ---- a/spec/views/places/index.html.haml_spec.rb -+++ b/spec/views/places/index.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "places/index" do -diff --git a/spec/views/places/show.html.haml_spec.rb b/spec/views/places/show.html.haml_spec.rb -index 7f9aa0c9..2ac779a1 100644 ---- a/spec/views/places/show.html.haml_spec.rb -+++ b/spec/views/places/show.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "places/show" do -diff --git a/spec/views/plant_parts/edit.html.haml_spec.rb b/spec/views/plant_parts/edit.html.haml_spec.rb -index cc6070fb..c21a9210 100644 ---- a/spec/views/plant_parts/edit.html.haml_spec.rb -+++ b/spec/views/plant_parts/edit.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "plant_parts/edit" do -diff --git a/spec/views/plant_parts/index.html.haml_spec.rb b/spec/views/plant_parts/index.html.haml_spec.rb -index b46c4a1a..828f942e 100644 ---- a/spec/views/plant_parts/index.html.haml_spec.rb -+++ b/spec/views/plant_parts/index.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "plant_parts/index" do -diff --git a/spec/views/plant_parts/new.html.haml_spec.rb b/spec/views/plant_parts/new.html.haml_spec.rb -index b0067273..203dc128 100644 ---- a/spec/views/plant_parts/new.html.haml_spec.rb -+++ b/spec/views/plant_parts/new.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "plant_parts/new" do -diff --git a/spec/views/plant_parts/show.html.haml_spec.rb b/spec/views/plant_parts/show.html.haml_spec.rb -index 9947cfcc..39dce332 100644 ---- a/spec/views/plant_parts/show.html.haml_spec.rb -+++ b/spec/views/plant_parts/show.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "plant_parts/show" do -diff --git a/spec/views/plantings/_form.html.haml_spec.rb b/spec/views/plantings/_form.html.haml_spec.rb -index 0f4c6f1a..a4f110a2 100644 ---- a/spec/views/plantings/_form.html.haml_spec.rb -+++ b/spec/views/plantings/_form.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "plantings/_form" do -diff --git a/spec/views/plantings/edit.html.haml_spec.rb b/spec/views/plantings/edit.html.haml_spec.rb -index 6baf126f..3acb1422 100644 ---- a/spec/views/plantings/edit.html.haml_spec.rb -+++ b/spec/views/plantings/edit.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "plantings/edit" do -diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb -index 4284eada..09552065 100644 ---- a/spec/views/plantings/index.html.haml_spec.rb -+++ b/spec/views/plantings/index.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "plantings/index" do -@@ -13,23 +15,28 @@ describe "plantings/index" do - total_entries = 3 - plantings = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| - pager.replace([ -- FactoryBot.create(:planting, -- garden: garden, -- crop: tomato, -- owner: member), -- FactoryBot.create(:planting, -- garden: garden, -- crop: maize, -- owner: garden.owner, -- description: '', -- planted_at: Time.zone.local(2013, 1, 13)), -- FactoryBot.create(:planting, -- garden: garden, -- owner: garden.owner, -- crop: tomato, -- planted_at: Time.zone.local(2013, 1, 13), -- finished_at: Time.zone.local(2013, 1, 20), -- finished: true) -+ { -+ 'crop_name' => tomato.name, -+ 'slug' => 'tomato-1', -+ 'owner_name' => member.login_name, -+ 'owner_slug' => member.slug -+ }, -+ { -+ 'crop_name' => maize.name, -+ 'slug' => 'maize', -+ 'owner_name' => garden.owner.login_name, -+ 'owner_slug' => garden.owner.slug, -+ 'planted_at' => Time.zone.local(2013, 1, 13) -+ }, -+ { -+ 'crop_name' => tomato.name, -+ 'slug' => 'tomato-2', -+ 'owner_name' => garden.owner.login_name, -+ 'owner_slug' => garden.owner.slug, -+ 'planted_at' => Time.zone.local(2013, 1, 13), -+ 'finished_at' => Time.zone.local(2013, 1, 20), -+ 'finished' => true -+ } - ]) - end - assign(:plantings, plantings) -@@ -37,8 +44,8 @@ describe "plantings/index" do - end - - describe "renders a list of plantings" do -- it { expect(rendered).to have_content tomato.name } -- it { expect(rendered).to have_content maize.name } -+ it { expect(rendered).to have_content 'tomato' } -+ it { expect(rendered).to have_content 'maize' } - end - - it "provides data links" do -diff --git a/spec/views/plantings/index.rss.haml_spec.rb b/spec/views/plantings/index.rss.haml_spec.rb -index 24faa046..6361aaf4 100644 ---- a/spec/views/plantings/index.rss.haml_spec.rb -+++ b/spec/views/plantings/index.rss.haml_spec.rb -@@ -1,6 +1,8 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - --describe 'plantings/index.rss.haml' do -+describe 'plantings/index.rss.haml', :search do - before do - controller.stub(:current_user) { nil } - end -@@ -10,28 +12,29 @@ describe 'plantings/index.rss.haml' do - @planting = FactoryBot.create(:planting) - @sunny = FactoryBot.create(:sunny_planting) - @seedling = FactoryBot.create(:seedling_planting) -- assign(:plantings, [@planting, @sunny, @seedling]) -+ Planting.searchkick_index.refresh -+ assign(:plantings, Planting.search(load: false)) - render - end - - it 'shows RSS feed title' do -- rendered.should have_content "Recent plantings from all members" -+ expect(rendered).to have_content "Recent plantings from all members" - end - - it 'item title shows owner and location' do -- rendered.should have_content "#{@planting.crop} in #{@planting.location}" -+ expect(rendered).to have_content "#{@planting.crop} in #{@planting.location}" - end - - it 'shows formatted content of posts' do -- rendered.should have_content "This is a really good plant." -+ expect(rendered).to have_content "This is a really good plant." - end - - it 'shows sunniness' do -- rendered.should have_content 'Sunniness: sun' -+ expect(rendered).to have_content 'Sunniness: sun' - end - - it 'shows propagation method' do -- rendered.should have_content 'Planted from: seedling' -+ expect(rendered).to have_content 'Planted from: seedling' - end - end - -@@ -44,7 +47,7 @@ describe 'plantings/index.rss.haml' do - end - - it 'shows title for single member' do -- rendered.should have_content "Recent plantings from #{@planting.owner}" -+ expect(rendered).to have_content "Recent plantings from #{@planting.owner}" - end - end - end -diff --git a/spec/views/plantings/new.html.haml_spec.rb b/spec/views/plantings/new.html.haml_spec.rb -index 3376d5cc..b0aa596f 100644 ---- a/spec/views/plantings/new.html.haml_spec.rb -+++ b/spec/views/plantings/new.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "plantings/new" do -diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb -index c774c5d4..5d7161e8 100644 ---- a/spec/views/plantings/show.html.haml_spec.rb -+++ b/spec/views/plantings/show.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "plantings/show" do -diff --git a/spec/views/posts/_single.html.haml_spec.rb b/spec/views/posts/_single.html.haml_spec.rb -index 90c15af7..403ea119 100644 ---- a/spec/views/posts/_single.html.haml_spec.rb -+++ b/spec/views/posts/_single.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "posts/_single" do -diff --git a/spec/views/posts/edit.html.haml_spec.rb b/spec/views/posts/edit.html.haml_spec.rb -index 2119f80b..c664f213 100644 ---- a/spec/views/posts/edit.html.haml_spec.rb -+++ b/spec/views/posts/edit.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "posts/edit" do -diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb -index c865b298..613f8dc5 100644 ---- a/spec/views/posts/index.html.haml_spec.rb -+++ b/spec/views/posts/index.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "posts/index" do -diff --git a/spec/views/posts/index.rss.haml_spec.rb b/spec/views/posts/index.rss.haml_spec.rb -index 030e22c0..055de59e 100644 ---- a/spec/views/posts/index.rss.haml_spec.rb -+++ b/spec/views/posts/index.rss.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'posts/index.rss.haml', type: "view" do -diff --git a/spec/views/posts/new.html.haml_spec.rb b/spec/views/posts/new.html.haml_spec.rb -index eaef7f5d..3e5e0efc 100644 ---- a/spec/views/posts/new.html.haml_spec.rb -+++ b/spec/views/posts/new.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "posts/new" do -diff --git a/spec/views/posts/show.html.haml_spec.rb b/spec/views/posts/show.html.haml_spec.rb -index bb59f2b4..e40918c1 100644 ---- a/spec/views/posts/show.html.haml_spec.rb -+++ b/spec/views/posts/show.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "posts/show" do -diff --git a/spec/views/posts/show.rss.haml_spec.rb b/spec/views/posts/show.rss.haml_spec.rb -index 802bebe9..effd8709 100644 ---- a/spec/views/posts/show.rss.haml_spec.rb -+++ b/spec/views/posts/show.rss.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe 'posts/show.rss.haml' do -diff --git a/spec/views/scientific_names/edit.html.haml_spec.rb b/spec/views/scientific_names/edit.html.haml_spec.rb -index b497b44e..b6b3cfb7 100644 ---- a/spec/views/scientific_names/edit.html.haml_spec.rb -+++ b/spec/views/scientific_names/edit.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "scientific_names/edit" do -diff --git a/spec/views/scientific_names/index.html.haml_spec.rb b/spec/views/scientific_names/index.html.haml_spec.rb -index 9d098e58..88401808 100644 ---- a/spec/views/scientific_names/index.html.haml_spec.rb -+++ b/spec/views/scientific_names/index.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "scientific_names/index" do -diff --git a/spec/views/scientific_names/new.html.haml_spec.rb b/spec/views/scientific_names/new.html.haml_spec.rb -index 1f632030..39dbedd8 100644 ---- a/spec/views/scientific_names/new.html.haml_spec.rb -+++ b/spec/views/scientific_names/new.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "scientific_names/new" do -diff --git a/spec/views/scientific_names/show.html.haml_spec.rb b/spec/views/scientific_names/show.html.haml_spec.rb -index ed815c55..1661ae8d 100644 ---- a/spec/views/scientific_names/show.html.haml_spec.rb -+++ b/spec/views/scientific_names/show.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "scientific_names/show" do -diff --git a/spec/views/seeds/edit.html.haml_spec.rb b/spec/views/seeds/edit.html.haml_spec.rb -index 4bc6bf81..d7d5cd87 100644 ---- a/spec/views/seeds/edit.html.haml_spec.rb -+++ b/spec/views/seeds/edit.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "seeds/edit" do -diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb -index cfeedd90..7940824f 100644 ---- a/spec/views/seeds/index.rss.haml_spec.rb -+++ b/spec/views/seeds/index.rss.haml_spec.rb -@@ -1,49 +1,64 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - --describe 'seeds/index.rss.haml' do -+describe 'seeds/index.rss.haml', :search do - before do - controller.stub(:current_user) { nil } - end - -- context 'all seeds' do -- before do -- @seed = FactoryBot.create(:seed) -- @tradable = FactoryBot.create(:tradable_seed) -- assign(:seeds, [@seed, @tradable]) -- render -+ shared_examples 'displays seed in rss feed' do -+ it 'has a useful item title' do -+ expect(rendered).to have_content "#{seed.owner.login_name}'s #{seed.crop.name} seeds" - end - -- it 'shows RSS feed title' do -- rendered.should have_content "Recent seeds from all members" -+ it 'shows the seed count' do -+ expect(rendered).to have_content "Quantity: #{seed.quantity}" - end - -- it 'has a useful item title' do -- rendered.should have_content "#{@seed.owner}'s #{@seed.crop} seeds" -+ it 'shows the plant_before date' do -+ expect(rendered).to have_content "Plant before: #{seed.plant_before.to_s(:ymd)}" - end -+ end - -- it 'shows the seed count' do -- rendered.should have_content "Quantity: #{@seed.quantity}" -+ context 'all seeds' do -+ let!(:seed) { FactoryBot.create(:seed) } -+ let!(:tradable) { FactoryBot.create(:tradable_seed) } -+ before do -+ Seed.searchkick_index.refresh -+ assign(:seeds, Seed.search(load: false)) -+ render - end - -- it 'shows the plant_before date' do -- rendered.should have_content "Plant before: #{@seed.plant_before}" -+ include_examples 'displays seed in rss feed' -+ -+ it 'shows RSS feed title' do -+ expect(rendered).to have_content "Recent seeds from all members" - end - - it 'mentions that one seed is tradable' do -- rendered.should have_content "Will trade #{@tradable.tradable_to} from #{@tradable.owner.location}" -+ expect(rendered).to have_content "Will trade #{tradable.tradable_to} from #{tradable.owner.location}" -+ end -+ -+ it "does not offer untradable seed as tradeable" do -+ expect(rendered).not_to have_content "Will trade #{seed.tradable_to} from #{seed.owner.location}" - end - end - - context "one member's seeds" do -+ let!(:seed) { FactoryBot.create(:seed) } -+ - before do -- @seed = FactoryBot.create(:seed) -- assign(:seeds, [@seed]) -- assign(:owner, @seed.owner) -+ assign(:owner, seed.owner) -+ Seed.searchkick_index.refresh -+ assign(:seeds, Seed.search(load: false)) - render - end - - it 'shows RSS feed title' do -- rendered.should have_content "Recent seeds from #{@seed.owner}" -+ expect(rendered).to have_content "Recent seeds from #{seed.owner}" - end -+ -+ include_examples 'displays seed in rss feed' - end - end -diff --git a/spec/views/seeds/new.html.haml_spec.rb b/spec/views/seeds/new.html.haml_spec.rb -index fc40236e..407e52d7 100644 ---- a/spec/views/seeds/new.html.haml_spec.rb -+++ b/spec/views/seeds/new.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "seeds/new" do -diff --git a/spec/views/seeds/show.html.haml_spec.rb b/spec/views/seeds/show.html.haml_spec.rb -index 34525fbb..2cc9fe14 100644 ---- a/spec/views/seeds/show.html.haml_spec.rb -+++ b/spec/views/seeds/show.html.haml_spec.rb -@@ -1,3 +1,5 @@ -+# frozen_string_literal: true -+ - require 'rails_helper' - - describe "seeds/show" do From c6988e218903e53d4e581d109a1991cadb4c3d5c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 5 Jan 2020 21:31:51 +1300 Subject: [PATCH 169/188] Re-instate the plantings quick actions --- app/controllers/harvests_controller.rb | 10 ++--- app/controllers/seeds_controller.rb | 12 +++--- app/helpers/buttons_helper.rb | 6 +-- app/models/concerns/search_seeds.rb | 54 +++++++++++++------------- app/models/seed.rb | 2 +- app/views/plantings/_card.html.haml | 23 +++++++++++ app/views/seeds/_card.html.haml | 2 +- app/views/seeds/show.html.haml | 2 +- spec/features/gardens/gardens_spec.rb | 2 +- spec/models/seed_spec.rb | 14 +++---- 10 files changed, 75 insertions(+), 52 deletions(-) diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index f6dabd566..4b6624136 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -20,10 +20,10 @@ class HarvestsController < DataController where['planting_id'] = @planting.id end - @harvests = Harvest.search('*', where: where, - limit: 100, - page: params[:page], - load: false, + @harvests = Harvest.search('*', where: where, + limit: 100, + page: params[:page], + load: false, boost_by: [:created_at]) @filename = csv_filename @@ -39,7 +39,7 @@ class HarvestsController < DataController def new @harvest = Harvest.new(harvested_at: Time.zone.today) - @planting = Planting.find_by(slug: params[:planting_id]) if params[:planting_id] + @planting = Planting.find_by(slug: params[:planting_slug]) if params[:planting_slug] @crop = Crop.find_by(id: params[:crop_id]) respond_with(@harvest) end diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index eb7f94beb..566edfc4a 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -24,11 +24,11 @@ class SeedsController < DataController @filename = csv_filename @seeds = Seed.search( - where: where, - page: params[:page], - limit: 30, + where: where, + page: params[:page], + limit: 30, boost_by: [:created_at], - load: false + load: false ) respond_with(@seeds) @@ -42,8 +42,8 @@ class SeedsController < DataController def new @seed = Seed.new - if params[:planting_id] - @planting = Planting.find_by(slug: params[:planting_id]) + if params[:planting_slug] + @planting = Planting.find_by(slug: params[:planting_slug]) else @crop = Crop.find_or_initialize_by(id: params[:crop_id]) end diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index fb1ac0458..7e822e78b 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -74,7 +74,7 @@ module ButtonsHelper def planting_finish_button(planting, classes: 'btn btn-default btn-secondary') return unless can?(:edit, planting) || planting.finished - link_to planting_path(planting, planting: { finished: 1 }), + link_to planting_path(slug: planting.slug, planting: { finished: 1 }), method: :put, class: "#{classes} append-date" do finished_icon + ' ' + t('buttons.mark_as_finished') end @@ -91,7 +91,7 @@ module ButtonsHelper def planting_harvest_button(planting, classes: 'btn btn-default') return unless planting.active && can?(:create, Harvest) && can?(:edit, planting) - link_to new_planting_harvest_path(planting), class: classes do + link_to new_planting_harvest_path(planting_slug: planting.slug), class: classes do harvest_icon + ' ' + t('buttons.record_harvest') end end @@ -99,7 +99,7 @@ module ButtonsHelper def planting_save_seeds_button(planting, classes: 'btn btn-default') return unless can?(:edit, planting) - link_to new_planting_seed_path(planting), class: classes do + link_to new_planting_seed_path(planting_slug: planting.slug), class: classes do seed_icon + ' ' + t('buttons.save_seeds') end end diff --git a/app/models/concerns/search_seeds.rb b/app/models/concerns/search_seeds.rb index 1792173e7..8785a9c2f 100644 --- a/app/models/concerns/search_seeds.rb +++ b/app/models/concerns/search_seeds.rb @@ -6,10 +6,10 @@ module SearchSeeds included do searchkick merge_mappings: true, mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, plant_before: { type: :text }, photos_count: { type: :integer }, - tradable_to: { type: :text } + tradable_to: { type: :text } } } @@ -17,51 +17,51 @@ module SearchSeeds def search_data { - slug: slug, - finished: finished?, - gmo: gmo, - active: active, - heirloom: heirloom, - location: owner.location, - organic: organic, - quantity: quantity, - plant_before: plant_before&.to_s(:ymd), - tradable_to: tradable_to, - tradable: tradable?, + slug: slug, + finished: finished?, + gmo: gmo, + active: active, + heirloom: heirloom, + location: owner.location, + organic: organic, + quantity: quantity, + plant_before: plant_before&.to_s(:ymd), + tradable_to: tradable_to, + tradable: tradable, # crop - crop_id: crop_id, - crop_name: crop.name, - crop_slug: crop.slug, + crop_id: crop_id, + crop_name: crop.name, + crop_slug: crop.slug, # owner - owner_id: owner_id, - owner_location: owner_location, + owner_id: owner_id, + owner_location: owner_location, owner_login_name: owner_login_name, - owner_slug: owner_slug, + owner_slug: owner_slug, # planting - parent_planting: parent_planting, + parent_planting: parent_planting, # counts - photos_count: photos.size, + photos_count: photos.size, # photo - has_photos: photos.size.positive?, - thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, + has_photos: photos.size.positive?, + thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, - created_at: created_at.to_i + created_at: created_at.to_i } end def self.homepage_records(limit) - search('*', limit: limit, - where: { + search('*', limit: limit, + where: { finished: false, tradable: true }, boost_by: [:created_at], - load: false) + load: false) end end end diff --git a/app/models/seed.rb b/app/models/seed.rb index 9841fa19f..b212d6acb 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -60,7 +60,7 @@ class Seed < ApplicationRecord scope :recent, -> { order(created_at: :desc) } scope :active, -> { where('finished <> true').where('finished_at IS NULL OR finished_at < ?', Time.zone.now) } - def tradable? + def tradable tradable_to != 'nowhere' end diff --git a/app/views/plantings/_card.html.haml b/app/views/plantings/_card.html.haml index d90908991..1c593fbd8 100644 --- a/app/views/plantings/_card.html.haml +++ b/app/views/plantings/_card.html.haml @@ -2,6 +2,29 @@ .card.planting{class: planting.active ? '' : 'card-finished'} = link_to planting_path(slug: planting.slug) do = image_tag planting.thumbnail_url ? planting.thumbnail_url : placeholder_image, class: 'img-card', alt: planting.crop_name + + - if member_signed_in? && current_member.id == planting.owner_id + = link_to planting_path(slug: planting.slug) do + .planting-quick-actions + .dropdown + %a.planting-menu.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button", href: '#'} + + .dropdown-menu{"aria-labelledby" => "planting-menu"} + = link_to edit_planting_path(slug: planting.slug), class: 'dropdown-item' do + = edit_icon + = t('buttons.edit') + = link_to new_photo_path(id: planting.id, type: 'planting'), class: 'dropdown-item' do + = add_photo_icon + = t('buttons.add_photo') + + - if planting.active + = planting_finish_button(planting, classes: 'dropdown-item') + = planting_harvest_button(planting, classes: 'dropdown-item') + = planting_save_seeds_button(planting, classes: 'dropdown-item') + + - if can? :destroy, planting + .dropdown-divider + = delete_button(planting, classes: 'dropdown-item text-danger') = link_to planting_path(slug: planting.slug) do .card-body.text-center %h4= planting.crop_name diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index 246629450..0bbb2a12c 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -1,7 +1,7 @@ - cache seed do .card.seed-card{class: seed.finished ? 'card-finished' : ''} = link_to seed_path(slug: seed.slug) do - = image_tag(seed.thumbnail_url ? seed.thumbnail_url : placeholder_image, alt: seed.name, class: 'img-card') + = image_tag(seed.thumbnail_url ? seed.thumbnail_url : placeholder_image, alt: seed.crop.name, class: 'img-card') .text %span.chip.member-chip = seed.owner_login_name diff --git a/app/views/seeds/show.html.haml b/app/views/seeds/show.html.haml index 14917dc9e..6ce24f7e4 100644 --- a/app/views/seeds/show.html.haml +++ b/app/views/seeds/show.html.haml @@ -50,7 +50,7 @@ #{strip_tags(@seed.description)} - if current_member - - if @seed.tradable? && current_member != @seed.owner + - if @seed.tradable && current_member != @seed.owner %p= link_to "Request seeds", new_message_path(recipient_id: @seed.owner.id, subject: "Interested in your #{@seed.crop} seeds"), diff --git a/spec/features/gardens/gardens_spec.rb b/spec/features/gardens/gardens_spec.rb index 714657952..571a7e4f5 100644 --- a/spec/features/gardens/gardens_spec.rb +++ b/spec/features/gardens/gardens_spec.rb @@ -103,7 +103,7 @@ describe "Planting a crop", js: true do describe "Making a planting inactive from garden show" do it do visit garden_path(garden) - click_link(class: 'planting-menu') + click_link(class: 'planting-menu') # quick menu click_link "Mark as finished" find(".datepicker-days td.day", text: "21").click expect(page).to have_content 'Finished' diff --git a/spec/models/seed_spec.rb b/spec/models/seed_spec.rb index 1729f5dad..98897970a 100644 --- a/spec/models/seed_spec.rb +++ b/spec/models/seed_spec.rb @@ -63,23 +63,23 @@ describe Seed do @seed.should_not be_valid end - it 'tradable? gives the right answers' do + it 'tradable gives the right answers' do @seed = FactoryBot.create(:seed, tradable_to: 'nowhere') - @seed.tradable?.should eq false + @seed.tradable.should eq false @seed = FactoryBot.create(:seed, tradable_to: 'locally') - @seed.tradable?.should eq true + @seed.tradable.should eq true @seed = FactoryBot.create(:seed, tradable_to: 'nationally') - @seed.tradable?.should eq true + @seed.tradable.should eq true @seed = FactoryBot.create(:seed, tradable_to: 'internationally') - @seed.tradable?.should eq true + @seed.tradable.should eq true end it 'recognises a tradable seed' do - FactoryBot.create(:tradable_seed).tradable?.should == true + FactoryBot.create(:tradable_seed).tradable.should == true end it 'recognises an untradable seed' do - FactoryBot.create(:untradable_seed).tradable?.should == false + FactoryBot.create(:untradable_seed).tradable.should == false end it 'scopes correctly' do From feab98e9624cbc8742342c3c3144177bbef3d26b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 5 Jan 2020 21:41:16 +1300 Subject: [PATCH 170/188] removing dead code --- app/models/concerns/search_harvests.rb | 43 +++++++++++++------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/app/models/concerns/search_harvests.rb b/app/models/concerns/search_harvests.rb index c33682776..75fb67cdb 100644 --- a/app/models/concerns/search_harvests.rb +++ b/app/models/concerns/search_harvests.rb @@ -7,9 +7,9 @@ module SearchHarvests searchkick merge_mappings: true, mappings: { properties: { harvests_count: { type: :integer }, - photos_count: { type: :integer }, - created_at: { type: :integer }, - harvested_at: { type: :date } + photos_count: { type: :integer }, + created_at: { type: :integer }, + harvested_at: { type: :date } } } @@ -17,45 +17,44 @@ module SearchHarvests def search_data { - slug: slug, - quantity: quantity, + slug: slug, + quantity: quantity, # crop - crop_id: crop_id, - crop_name: crop_name, - crop_slug: crop.slug, + crop_id: crop_id, + crop_name: crop_name, + crop_slug: crop.slug, # owner - owner_id: owner_id, + owner_id: owner_id, owner_login_name: owner_login_name, - owner_slug: owner_slug, - plant_part_name: plant_part&.name, + owner_slug: owner_slug, + plant_part_name: plant_part&.name, # planting - planting_id: planting_id, - planting_slug: planting&.slug, + planting_id: planting_id, + planting_slug: planting&.slug, # photo - has_photos: photos.size.positive?, - thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, + has_photos: photos.size.positive?, + thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, # counts - # harvests_count: harvests_count, - photos_count: photos.count, + photos_count: photos.count, # timestamps - harvested_at: harvested_at, - created_at: created_at.to_i + harvested_at: harvested_at, + created_at: created_at.to_i } end def self.homepage_records(limit) - search('*', limit: limit, - where: { + search('*', limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end From 96f0866f39f50b3501c49293bc0dd4b2fc74587c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 6 Jan 2020 21:49:00 +1300 Subject: [PATCH 171/188] rubocop fix up --- app/models/concerns/search_plantings.rb | 50 ++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/app/models/concerns/search_plantings.rb b/app/models/concerns/search_plantings.rb index 5307464d2..bb29e07f9 100644 --- a/app/models/concerns/search_plantings.rb +++ b/app/models/concerns/search_plantings.rb @@ -6,10 +6,10 @@ module SearchPlantings included do searchkick merge_mappings: true, mappings: { properties: { - active: { type: :boolean }, - created_at: { type: :integer }, + active: { type: :boolean }, + created_at: { type: :integer }, harvests_count: { type: :integer }, - photos_count: { type: :integer }, + photos_count: { type: :integer }, owner_location: { type: :text } } } @@ -18,46 +18,46 @@ module SearchPlantings def search_data { - slug: slug, - active: active, - finished: finished?, - has_photos: photos.size.positive?, - location: location, + slug: slug, + active: active, + finished: finished?, + has_photos: photos.size.positive?, + location: location, percentage_grown: percentage_grown.to_i, - planted_at: planted_at, - planted_from: planted_from, - quantity: quantity, - sunniness: sunniness, + planted_at: planted_at, + planted_from: planted_from, + quantity: quantity, + sunniness: sunniness, # crops - crop_id: crop_id, - crop_name: crop.name, - crop_slug: crop.slug, + crop_id: crop_id, + crop_name: crop.name, + crop_slug: crop.slug, # owner - owner_id: owner_id, - owner_location: owner_location, + owner_id: owner_id, + owner_location: owner_location, owner_login_name: owner_login_name, - owner_slug: owner_slug, + owner_slug: owner_slug, # photos - thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, + thumbnail_url: default_photo&.thumbnail_url || crop.default_photo&.thumbnail_url, # counts - photos_count: photos.size, - harvests_count: harvests_count, + photos_count: photos.size, + harvests_count: harvests_count, # timestamps - created_at: created_at.to_i + created_at: created_at.to_i } end def self.homepage_records(limit) - search('*', limit: limit, - where: { + search('*', limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end From bccdd6333ed1b9c8139dbfc7133d588e79c286a4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 6 Jan 2020 21:49:53 +1300 Subject: [PATCH 172/188] find the crop name from es result --- app/views/seeds/_card.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index 0bbb2a12c..6decc6778 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -1,7 +1,7 @@ - cache seed do .card.seed-card{class: seed.finished ? 'card-finished' : ''} = link_to seed_path(slug: seed.slug) do - = image_tag(seed.thumbnail_url ? seed.thumbnail_url : placeholder_image, alt: seed.crop.name, class: 'img-card') + = image_tag(seed.thumbnail_url ? seed.thumbnail_url : placeholder_image, alt: seed.crop_name, class: 'img-card') .text %span.chip.member-chip = seed.owner_login_name From 8a6c4a774a7981d2f728b366c29d864b88ae9d60 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 6 Jan 2020 21:53:02 +1300 Subject: [PATCH 173/188] reindexs photo in photo controller spec --- spec/controllers/photos_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index a13a7ccc9..4e5667180 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -10,7 +10,7 @@ describe PhotosController, :search do let!(:photo) { FactoryBot.create :photo, :reindex } before do - Photo.searchkick_index.refresh + Photo.reindex get :index end @@ -28,7 +28,7 @@ describe PhotosController, :search do before do planting.photos << crop_photo - Photo.searchkick_index.refresh + Photo.reindex get :index, params: { crop_slug: crop.to_param } end From 0acb0540044150d8eb25c4ae1ef300b82af17627 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 8 Jan 2020 07:28:53 +1300 Subject: [PATCH 174/188] reindex photos before likes spec --- spec/features/likeable_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/features/likeable_spec.rb b/spec/features/likeable_spec.rb index bb79fa129..a253c3f3f 100644 --- a/spec/features/likeable_spec.rb +++ b/spec/features/likeable_spec.rb @@ -7,6 +7,10 @@ describe 'Likeable', :js, search: true do let!(:post) { FactoryBot.create(:post, :reindex, author: member) } let!(:photo) { FactoryBot.create(:photo, :reindex, owner: member) } + before do + Photo.reindex + end + include_context 'signed in member' describe 'photos' do From 8dfb8ff954aa1d5e00c224565525c8cc2e6c75eb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 8 Jan 2020 08:10:16 +1300 Subject: [PATCH 175/188] Update params in seeds controller spec --- spec/controllers/seeds_controller_spec.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb index 4ed7bf27d..02b539d7a 100644 --- a/spec/controllers/seeds_controller_spec.rb +++ b/spec/controllers/seeds_controller_spec.rb @@ -6,10 +6,11 @@ describe SeedsController, :search do let(:owner) { FactoryBot.create(:member) } describe "GET index" do - let(:owner) { FactoryBot.create(:member) } - describe "picks up owner from params" do - before { get :index, params: { member_slug: owner.slug } } + before do + Seed.reindex + get :index, params: { member_slug: owner.slug } + end it { expect(assigns(:owner)).to eq(owner) } end @@ -25,9 +26,12 @@ describe SeedsController, :search do end context 'with parent planting' do - let(:planting) { FactoryBot.create :planting, owner: owner } + let!(:planting) { FactoryBot.create :planting, owner: owner } - before { get :new, params: { planting_id: planting.to_param } } + before do + Seed.reindex + get :new, params: { planting_slug: planting.to_param } + end it { expect(assigns(:planting)).to eq(planting) } end From 346e67b8f302656b0ebca01dd9ab3b83a62d57ab Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 8 Jan 2020 15:42:25 +1300 Subject: [PATCH 176/188] yet more reindexing in tests --- spec/features/home/home_spec.rb | 11 +++++++---- spec/spec_helper.rb | 12 ++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb index fa6bddaeb..853833899 100644 --- a/spec/features/home/home_spec.rb +++ b/spec/features/home/home_spec.rb @@ -23,10 +23,13 @@ describe "home page", :search do planting.photos << photo seed.photos << photo harvest.photos << photo - Crop.searchkick_index.refresh - Planting.searchkick_index.refresh - Seed.searchkick_index.refresh - Harvest.searchkick_index.refresh + end + + before(:each) do + Crop.reindex + Planting.reindex + Seed.reindex + Harvest.reindex end before { visit root_path } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 88eccdc20..d6713c5e8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -20,6 +20,7 @@ require 'simplecov' require 'percy' SimpleCov.start + RSpec.configure do |config| # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest @@ -36,12 +37,17 @@ RSpec.configure do |config| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end - config.before(:suite) do + def index_everything # reindex models - Photo.reindex Crop.reindex Harvest.reindex + Photo.reindex Planting.reindex + Seed.reindex + end + + config.before(:suite) do + index_everything # and disable callbacks Searchkick.disable_callbacks @@ -49,7 +55,9 @@ RSpec.configure do |config| config.around(:each, search: true) do |example| Searchkick.callbacks(true) do + index_everything example.run + index_everything end end From 7a0458e7e04adf6b46b89828b8e214de3ce961ee Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 10 Jan 2020 13:31:45 +1300 Subject: [PATCH 177/188] reindex plantings before crop planting spec --- spec/features/plantings/planting_a_crop_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index a4cbe5ed1..e5a1961d4 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -10,6 +10,8 @@ describe "Planting a crop", :js, :search do FactoryBot.create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-03-10") end + before { Planting.reindex } + context 'signed in' do include_context 'signed in member' before { visit new_planting_path } From acbc49812d03adb54619565c0f602f6fe194b5bc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 10 Jan 2020 13:36:30 +1300 Subject: [PATCH 178/188] more indexing in home spec --- spec/features/home/home_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb index 853833899..10c7c73f3 100644 --- a/spec/features/home/home_spec.rb +++ b/spec/features/home/home_spec.rb @@ -30,6 +30,7 @@ describe "home page", :search do Planting.reindex Seed.reindex Harvest.reindex + Photo.reindex end before { visit root_path } @@ -54,6 +55,7 @@ describe "home page", :search do it { expect(subject).to have_link href: planting_path(planting) } end end + shared_examples 'show harvests' do describe 'shows harvests section' do it { expect(subject).to have_text 'Recently Harvested' } From d95cacc404d7184f0e7337bf395b10523d2fbc70 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 10 Jan 2020 13:39:57 +1300 Subject: [PATCH 179/188] style fix ups --- app/controllers/likes_controller.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index ffb0604f6..953baac35 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -6,9 +6,9 @@ class LikesController < ApplicationController def create @like = Like.new( - member: current_member, + member: current_member, likeable_type: params[:type], - likeable_id: params[:id] + likeable_id: params[:id] ) if @like.likeable && @like.save @like.likeable.reindex(refresh: true) @@ -21,8 +21,8 @@ class LikesController < ApplicationController def destroy @like = Like.find_by( likeable_type: params[:type], - likeable_id: params[:id], - member: current_member + likeable_id: params[:id], + member: current_member ) if @like&.destroy @@ -37,10 +37,10 @@ class LikesController < ApplicationController def render_json(like, liked_by_member: true) { - id: like.likeable.id, - like_count: like.likeable.likes.count, + id: like.likeable.id, + like_count: like.likeable.likes.count, liked_by_member: liked_by_member, - description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like") + description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like") } end From cdff37b2eb111b96d50cf2f7bb4d757ea11383f0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 11 Jan 2020 22:57:09 +1300 Subject: [PATCH 180/188] style fix ups --- app/controllers/gardens_controller.rb | 6 ++++-- app/controllers/members_controller.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index 696377186..25acefe0f 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -52,7 +52,9 @@ class GardensController < DataController private def garden_params - params.require(:garden).permit(:name, :slug, :description, :active, - :location, :latitude, :longitude, :area, :area_unit, :garden_type_id) + params.require(:garden).permit( + :name, :slug, :description, :active, + :location, :latitude, :longitude, :area, :area_unit, :garden_type_id + ) end end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 9b65068d0..9f83044b0 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -71,7 +71,7 @@ class MembersController < ApplicationController EMAIL_TYPE_STRING = { send_notification_email: "direct message notifications", - send_planting_reminder: "planting reminders" + send_planting_reminder: "planting reminders" }.freeze def member_params From 709ca5a04f74473e9b62f1655f5d28123fa2e10d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 11 Jan 2020 23:10:33 +1300 Subject: [PATCH 181/188] Fix seeds ES query --- app/models/concerns/search_seeds.rb | 3 +-- spec/features/home/home_spec.rb | 12 +++++------- spec/models/seed_spec.rb | 12 ++++++++++++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/models/concerns/search_seeds.rb b/app/models/concerns/search_seeds.rb index 8785a9c2f..4c3c3d685 100644 --- a/app/models/concerns/search_seeds.rb +++ b/app/models/concerns/search_seeds.rb @@ -6,6 +6,7 @@ module SearchSeeds included do searchkick merge_mappings: true, mappings: { properties: { + id: { type: :integer }, created_at: { type: :integer }, plant_before: { type: :text }, photos_count: { type: :integer }, @@ -13,8 +14,6 @@ module SearchSeeds } } - scope :search_import, -> { includes(:owner, :crop, :parent_planting) } - def search_data { slug: slug, diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb index 10c7c73f3..36f0f9c90 100644 --- a/spec/features/home/home_spec.rb +++ b/spec/features/home/home_spec.rb @@ -14,26 +14,24 @@ describe "home page", :search do let(:seed) { FactoryBot.create :tradable_seed, owner: member, crop: crop } let(:harvest) { FactoryBot.create :harvest, owner: member, crop: crop } - let!(:tradable_seed) { FactoryBot.create :tradable_seed, finished: false } - let!(:finished_seed) { FactoryBot.create :tradable_seed, finished: true } - let!(:untradable_seed) { FactoryBot.create :untradable_seed } + let!(:tradable_seed) { FactoryBot.create :tradable_seed, :reindex, finished: false } + let!(:finished_seed) { FactoryBot.create :tradable_seed, :reindex, finished: true } + let!(:untradable_seed) { FactoryBot.create :untradable_seed, :reindex } before do # Add photos, so they can appear on home page planting.photos << photo seed.photos << photo harvest.photos << photo - end - before(:each) do Crop.reindex Planting.reindex Seed.reindex Harvest.reindex Photo.reindex - end - before { visit root_path } + visit root_path + end shared_examples 'shows seeds' do it "show tradeable seed" do diff --git a/spec/models/seed_spec.rb b/spec/models/seed_spec.rb index 98897970a..1c4aea5fc 100644 --- a/spec/models/seed_spec.rb +++ b/spec/models/seed_spec.rb @@ -197,4 +197,16 @@ describe Seed do end end end + + describe 'homepage', :search do + let!(:tradable_seed) { FactoryBot.create :tradable_seed, :reindex, finished: false } + let!(:finished_seed) { FactoryBot.create :tradable_seed, :reindex, finished: true } + let!(:untradable_seed) { FactoryBot.create :untradable_seed, :reindex } + + before { Seed.reindex } + subject { Seed.homepage_records(100) } + + it { expect(subject.count).to eq 1 } + it { expect(subject.first.id).to eq tradable_seed.id.to_s } + end end From 6cce74cf4dcf39d9a660b4e6fd8484aac7329fcc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 12 Jan 2020 09:52:47 +1300 Subject: [PATCH 182/188] tests we find home page records for plantings --- spec/factories/planting.rb | 7 ++++++ spec/models/planting_spec.rb | 49 ++++++++++++++++++++++-------------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/spec/factories/planting.rb b/spec/factories/planting.rb index d45afdef6..f95a626f1 100644 --- a/spec/factories/planting.rb +++ b/spec/factories/planting.rb @@ -62,6 +62,13 @@ FactoryBot.define do end end + trait :with_photo do + after(:create) do |planting, _evaluator| + planting.photos << FactoryBot.create(:photo, owner_id: planting.owner_id) + planting.save + end + end + trait :reindex do after(:create) do |planting, _evaluator| planting.reindex(refresh: true) diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index 34d5696a8..37016b497 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -179,8 +179,8 @@ describe Planting do before do FactoryBot.create(:harvest, - planting: planting, - crop: planting.crop, + planting: planting, + crop: planting.crop, harvested_at: 10.days.ago) planting.update_harvest_days! planting.crop.update_harvest_medians @@ -232,8 +232,11 @@ describe Planting do before do # Near by planting with harvests nearby_garden = FactoryBot.create :garden, location: 'Greenwich, UK' - nearby_planting = FactoryBot.create :planting, crop: crop, - garden: nearby_garden, owner: nearby_garden.owner, planted_at: '1 January 2000' + nearby_planting = FactoryBot.create(:planting, + crop: crop, + garden: nearby_garden, + owner: nearby_garden.owner, + planted_at: '1 January 2000') FactoryBot.create :harvest, planting: nearby_planting, crop: crop, harvested_at: '1 May 2019' FactoryBot.create :harvest, planting: nearby_planting, crop: crop, @@ -354,9 +357,11 @@ describe Planting do end it 'all valid planted_from values should work' do - ['seed', 'seedling', 'cutting', 'root division', - 'runner', 'bare root plant', 'advanced plant', - 'graft', 'layering', 'bulb', 'root/tuber', nil, ''].each do |p| + [ + 'seed', 'seedling', 'cutting', 'root division', + 'runner', 'bare root plant', 'advanced plant', + 'graft', 'layering', 'bulb', 'root/tuber', nil, '' + ].each do |p| @planting = FactoryBot.build(:planting, planted_from: p) @planting.should be_valid end @@ -407,16 +412,10 @@ describe Planting do before do # plantings have members created implicitly for them # each member is different, hence these are all interesting - @planting1 = FactoryBot.create(:planting, planted_at: 5.days.ago) - @planting2 = FactoryBot.create(:planting, planted_at: 4.days.ago) - @planting3 = FactoryBot.create(:planting, planted_at: 3.days.ago) - @planting4 = FactoryBot.create(:planting, planted_at: 2.days.ago) - - # plantings need photos to be interesting - [@planting1, @planting2, @planting3, @planting4].each do |p| - p.photos << FactoryBot.create(:photo, owner_id: p.owner_id) - p.save - end + @planting1 = FactoryBot.create(:planting, :with_photo, planted_at: 5.days.ago) + @planting2 = FactoryBot.create(:planting, :with_photo, planted_at: 4.days.ago) + @planting3 = FactoryBot.create(:planting, :with_photo, planted_at: 3.days.ago) + @planting4 = FactoryBot.create(:planting, :with_photo, planted_at: 2.days.ago) end it { expect(Planting.interesting).to eq([@planting4, @planting3, @planting2, @planting1]) } @@ -445,8 +444,8 @@ describe Planting do # this one is newer, and has the same owner, through the garden @planting2 = FactoryBot.create(:planting, created_at: 1.minute.ago, - garden: @planting1.garden, - owner: @planting1.owner) + garden: @planting1.garden, + owner: @planting1.owner) @planting2.photos << FactoryBot.create(:photo, owner: @planting2.owner) @planting2.save @@ -541,4 +540,16 @@ describe Planting do it { expect(member.plantings.active).to include(planting) } it { expect(member.plantings.active).not_to include(finished_planting) } end + + describe 'homepage', :search do + let!(:interesting_planting) { FactoryBot.create :planting, :reindex, :with_photo } + let!(:finished_interesting_planting) { FactoryBot.create :finished_planting, :reindex, :with_photo } + let!(:planting) { FactoryBot.create :planting, :reindex } + + before { Planting.reindex } + subject { Planting.homepage_records(100) } + + it { expect(subject.count).to eq 2 } + it { expect(subject.map(&:id)).to eq([interesting_planting.id.to_s, finished_interesting_planting.id.to_s]) } + end end From 4ca949a7034caf0b0834a39e0b442ca934376aaf Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 12 Jan 2020 10:14:20 +1300 Subject: [PATCH 183/188] Added another reindex to specs --- spec/features/plantings/planting_a_crop_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index e5a1961d4..34db09af1 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -224,6 +224,9 @@ describe "Planting a crop", :js, :search do expect(page).to have_content "Finished" expect(page).to have_content "Aug 2014" + # ensure we've indexed in elastic search + planting.reindex(refresh: true) + # shouldn't be on the page visit plantings_path expect(page).not_to have_content "maize" From 32c8698a445dd4f23621a6768f160a992e37af4d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 12 Jan 2020 10:17:07 +1300 Subject: [PATCH 184/188] style fix ups --- app/models/concerns/search_crops.rb | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/app/models/concerns/search_crops.rb b/app/models/concerns/search_crops.rb index b37fbfcc1..959627436 100644 --- a/app/models/concerns/search_crops.rb +++ b/app/models/concerns/search_crops.rb @@ -6,16 +6,16 @@ module SearchCrops included do #################################### # Elastic search configuration - searchkick word_start: %i(name description alternate_names scientific_names), + searchkick word_start: %i(name description alternate_names scientific_names), case_sensitive: false, - searchable: %i(name descriptions alternate_names scientific_names), + searchable: %i(name descriptions alternate_names scientific_names), merge_mappings: true, - mappings: { + mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, plantings_count: { type: :integer }, - harvests_count: { type: :integer }, - photos_count: { type: :integer } + harvests_count: { type: :integer }, + photos_count: { type: :integer } } } @@ -28,21 +28,21 @@ module SearchCrops def search_data { - name: name, - description: description, - slug: slug, - alternate_names: alternate_names.pluck(:name), + name: name, + description: description, + slug: slug, + alternate_names: alternate_names.pluck(:name), scientific_names: scientific_names.pluck(:name), - photos_count: photo_associations_count, + photos_count: photo_associations_count, # boost the crops that are planted the most - plantings_count: plantings_count, - harvests_count: harvests_count, + plantings_count: plantings_count, + harvests_count: harvests_count, # boost this crop for these members - planters_ids: plantings.pluck(:owner_id), - has_photos: photos.size.positive?, - thumbnail_url: thumbnail_url, - scientific_name: default_scientific_name&.name, - created_at: created_at.to_i + planters_ids: plantings.pluck(:owner_id), + has_photos: photos.size.positive?, + thumbnail_url: thumbnail_url, + scientific_name: default_scientific_name&.name, + created_at: created_at.to_i } end end From 9596d1bac7ec5737774e1e499f6cd012fff5b8cd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 12 Jan 2020 10:18:32 +1300 Subject: [PATCH 185/188] style fix ups --- app/models/concerns/search_photos.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/models/concerns/search_photos.rb b/app/models/concerns/search_photos.rb index 952dd5d63..5bf48ec67 100644 --- a/app/models/concerns/search_photos.rb +++ b/app/models/concerns/search_photos.rb @@ -6,28 +6,28 @@ module SearchPhotos included do searchkick merge_mappings: true, mappings: { properties: { - title: { type: :text }, + title: { type: :text }, created_at: { type: :integer } } } def search_data { - id: id, - title: title, - thumbnail_url: thumbnail_url, - fullsize_url: fullsize_url, + id: id, + title: title, + thumbnail_url: thumbnail_url, + fullsize_url: fullsize_url, # crops - crops: crops.pluck(:id), + crops: crops.pluck(:id), # likes liked_by_members_names: liked_by_members_names, # owner - owner_id: owner_id, - owner_login_name: owner.login_name, + owner_id: owner_id, + owner_login_name: owner.login_name, # counts - likes_count: likes_count, + likes_count: likes_count, - created_at: created_at.to_i + created_at: created_at.to_i } end end From 5d8d159cc90693d7ac6ea8c518513bc9a18bc12e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 12 Jan 2020 10:20:21 +1300 Subject: [PATCH 186/188] Update app/models/garden.rb --- app/models/garden.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/garden.rb b/app/models/garden.rb index 1a3b4a340..6490bb411 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -77,7 +77,7 @@ class Garden < ApplicationRecord end end - def reindex; end + def reindex(refresh: false); end protected From cdb60d93010c4d3c87e19729425729225635169f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 12 Jan 2020 10:23:26 +1300 Subject: [PATCH 187/188] Use planting, not @planting, in plantings/harvests view --- app/views/plantings/_harvests.html.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/plantings/_harvests.html.haml b/app/views/plantings/_harvests.html.haml index 4f9aa933b..920c553c7 100644 --- a/app/views/plantings/_harvests.html.haml +++ b/app/views/plantings/_harvests.html.haml @@ -1,20 +1,20 @@ %h2 Harvests -- if can? :edit, @planting +- if can? :edit, planting %a.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#", :role => "button"} = harvest_icon Record harvest .dropdown-menu.dropdown-secondary - PlantPart.all.each do |plant_part| - = link_to harvests_path(return: 'planting', harvest: {crop_id: @planting.crop_id, planting_id: @planting.id, plant_part_id: plant_part.id}), method: :post, class: 'dropdown-item' do + = link_to harvests_path(return: 'planting', harvest: {crop_id: planting.crop_id, planting_id: planting.id, plant_part_id: plant_part.id}), method: :post, class: 'dropdown-item' do = plant_part.name -- if @planting.harvests.empty? +- if planting.harvests.empty? %p No harvests recorded - if !planting.finished? && can?(:edit, planting) && can?(:create, Harvest) %p Record your harvests here to improve crop predictions, and you'll be able to compare with your garden next season. - else .index-cards - - @planting.harvests.each do |harvest| + - planting.harvests.each do |harvest| = render 'harvests/thumbnail', harvest: harvest From 6c9a15f95e0694e158eb5b81778982e94545cc86 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sat, 11 Jan 2020 21:29:37 +0000 Subject: [PATCH 188/188] [CodeFactor] Apply fixes --- app/controllers/crops_controller.rb | 14 +++++------ app/controllers/photos_controller.rb | 10 ++++---- app/controllers/plantings_controller.rb | 14 +++++------ app/services/crop_search_service.rb | 24 +++++++++---------- ...20191226024957_crop_photo_counter_cache.rb | 2 -- spec/controllers/harvests_controller_spec.rb | 8 +++---- spec/features/home/home_spec.rb | 2 +- spec/spec_helper.rb | 2 +- 8 files changed, 37 insertions(+), 39 deletions(-) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index d915de921..baf56aa1a 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -12,9 +12,9 @@ class CropsController < ApplicationController def index @sort = params[:sort] @crops = Crop.search('*', boost_by: %i(plantings_count harvests_count), - limit: 100, - page: params[:page], - load: false) + limit: 100, + page: params[:page], + load: false) @num_requested_crops = requested_crops.size if current_member @filename = filename respond_with @crops @@ -55,8 +55,8 @@ class CropsController < ApplicationController @term = params[:term] @crops = CropSearchService.search(@term, - page: params[:page], - per_page: Crop.per_page, + page: params[:page], + per_page: Crop.per_page, current_member: current_member) respond_with @crops end @@ -207,13 +207,13 @@ class CropsController < ApplicationController def crop_json_fields { include: { - plantings: { + plantings: { include: { owner: { only: %i(id login_name location latitude longitude) } } }, scientific_names: { only: [:name] }, - alternate_names: { only: [:name] } + alternate_names: { only: [:name] } } } end diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index e117bebf0..322c5a66e 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -23,11 +23,11 @@ class PhotosController < ApplicationController end @photos = Photo.search( - load: false, + load: false, boost_by: [:created_at], - where: where, - page: params[:page], - limit: Photo.per_page + where: where, + page: params[:page], + limit: Photo.per_page ) respond_with(@photos) end @@ -90,7 +90,7 @@ class PhotosController < ApplicationController def find_or_create_photo_from_flickr_photo photo = Photo.find_or_initialize_by( source_id: photo_params[:source_id], - source: 'flickr' + source: 'flickr' ) photo.update(photo_params) photo.owner_id = current_member.id diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index c1183e790..983fb13ff 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -21,11 +21,11 @@ class PlantingsController < DataController end @plantings = Planting.search( - where: where, - page: params[:page], - limit: 30, + where: where, + page: params[:page], + limit: 30, boost_by: [:created_at], - load: false + load: false ) @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv" @@ -49,15 +49,15 @@ class PlantingsController < DataController def new @planting = Planting.new( planted_at: Time.zone.today, - owner: current_member, - garden: current_member.gardens.first + owner: current_member, + garden: current_member.gardens.first ) @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new if params[:garden_id] @planting.garden = Garden.find_by( owner: current_member, - id: params[:garden_id] + id: params[:garden_id] ) end diff --git a/app/services/crop_search_service.rb b/app/services/crop_search_service.rb index 46989b7cc..12bbae811 100644 --- a/app/services/crop_search_service.rb +++ b/app/services/crop_search_service.rb @@ -4,14 +4,14 @@ class CropSearchService # Crop.search(string) def self.search(query, page: 1, per_page: 12, current_member: nil) search_params = { - page: page, - per_page: per_page, - fields: %i(name^5 alternate_names scientific_names), - match: :word_start, - boost_by: [:plantings_count], - includes: %i(scientific_names alternate_names), + page: page, + per_page: per_page, + fields: %i(name^5 alternate_names scientific_names), + match: :word_start, + boost_by: [:plantings_count], + includes: %i(scientific_names alternate_names), misspellings: { edit_distance: 2 }, - load: false + load: false } # prioritise crops the member has planted search_params[:boost_where] = { planters_ids: current_member.id } if current_member @@ -23,22 +23,22 @@ class CropSearchService body = { "query": { "function_score": { - "query": { "query_string": { "query": 'has_photos:true' } }, + "query": { "query_string": { "query": 'has_photos:true' } }, "random_score": { "seed": DateTime.now.to_i } } } } Crop.search( limit: limit, - load: false, - body: body + load: false, + body: body ) end def self.recent(limit) Crop.search( - limit: limit, - load: false, + limit: limit, + load: false, boost_by: { created_at: { factor: 100 } } # default factor is 1 ) end diff --git a/db/migrate/20191226024957_crop_photo_counter_cache.rb b/db/migrate/20191226024957_crop_photo_counter_cache.rb index db6f6f5f9..d4a085e24 100644 --- a/db/migrate/20191226024957_crop_photo_counter_cache.rb +++ b/db/migrate/20191226024957_crop_photo_counter_cache.rb @@ -1,7 +1,5 @@ - # frozen_string_literal: true - class CropPhotoCounterCache < ActiveRecord::Migration[5.2] def change change_table :crops do |t| diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index 50d45ba6e..6233a28dc 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -7,10 +7,10 @@ describe HarvestsController, :search do def valid_attributes { - owner_id: subject.current_member.id, - crop_id: FactoryBot.create(:crop).id, + owner_id: subject.current_member.id, + crop_id: FactoryBot.create(:crop).id, plant_part_id: FactoryBot.create(:plant_part).id, - harvested_at: '2017-01-01' + harvested_at: '2017-01-01' } end @@ -196,7 +196,7 @@ describe HarvestsController, :search do describe "does not save planting_id" do before do put :update, params: { - slug: harvest.to_param, + slug: harvest.to_param, harvest: valid_attributes.merge(planting_id: not_my_planting.id) } end diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb index 36f0f9c90..c4355d2b7 100644 --- a/spec/features/home/home_spec.rb +++ b/spec/features/home/home_spec.rb @@ -53,7 +53,7 @@ describe "home page", :search do it { expect(subject).to have_link href: planting_path(planting) } end end - + shared_examples 'show harvests' do describe 'shows harvests section' do it { expect(subject).to have_text 'Recently Harvested' } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d6713c5e8..b8d696783 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -45,7 +45,7 @@ RSpec.configure do |config| Planting.reindex Seed.reindex end - + config.before(:suite) do index_everything