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