diff --git a/.rubocop.yml b/.rubocop.yml
index 8f8ebda37..545e1c1fa 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -7,12 +7,14 @@ AllCops:
Exclude:
- 'db/schema.rb'
- 'vendor/**/*'
+ TargetRailsVersion: 4.0
Rails:
Enabled: true
Style/FileName:
Exclude:
+ - 'Guardfile'
- 'Gemfile'
- 'Gemfile.lock'
@@ -26,12 +28,12 @@ Style/PercentLiteralDelimiters:
'%i': ()
'%w': ()
-Style/MultilineMethodCallIndentation:
+Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: with_first_parameter, with_fixed_indentation
-Style/AlignParameters:
+Layout/AlignParameters:
EnforcedStyle: with_fixed_indentation
Metrics/LineLength:
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 211de1ca6..4e0d899c7 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --no-offense-counts`
-# on 2017-11-05 20:41:45 +1300 using RuboCop version 0.47.1.
+# on 2017-12-06 11:20:15 +1300 using RuboCop version 0.49.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
@@ -18,12 +18,6 @@ Lint/UnusedMethodArgument:
- 'app/controllers/passwords_controller.rb'
- 'app/controllers/registrations_controller.rb'
- 'app/validators/approved_validator.rb'
- - 'spec/views/plantings/show.html.haml_spec.rb'
-
-# Cop supports --auto-correct.
-Performance/StringReplacement:
- Exclude:
- - 'spec/rails_helper.rb'
Rails/FilePath:
Exclude:
@@ -62,37 +56,6 @@ Style/AsciiComments:
Exclude:
- 'config/initializers/comfortable_mexican_sofa.rb'
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, SupportedStyles.
-# SupportedStyles: percent_q, bare_percent
-Style/BarePercentLiterals:
- Exclude:
- - 'app/helpers/auto_suggest_helper.rb'
- - 'spec/support/feature_helpers.rb'
-
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
-# SupportedStyles: line_count_based, semantic, braces_for_chaining
-# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
-# FunctionalMethods: let, let!, subject, watch
-# IgnoredMethods: lambda, proc, it
-Style/BlockDelimiters:
- Exclude:
- - 'spec/controllers/order_items_controller_spec.rb'
- - 'spec/features/notifications_spec.rb'
- - 'spec/models/ability_spec.rb'
- - 'spec/models/comment_spec.rb'
- - 'spec/models/follow_spec.rb'
- - 'spec/models/member_spec.rb'
- - 'spec/models/post_spec.rb'
- - 'spec/views/crops/edit.html.haml_spec.rb'
-
-# Cop supports --auto-correct.
-Style/BlockEndNewline:
- Exclude:
- - 'spec/models/ability_spec.rb'
- - 'spec/models/member_spec.rb'
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
@@ -101,38 +64,10 @@ Style/ClassAndModuleChildren:
- 'lib/actions/oauth_signup_action.rb'
- 'lib/haml/filters/escaped_markdown.rb'
-# Cop supports --auto-correct.
-Style/ColonMethodCall:
- Exclude:
- - 'spec/lib/haml/filters/escaped_markdown_spec.rb'
- - 'spec/lib/haml/filters/growstuff_markdown_spec.rb'
-
-# Cop supports --auto-correct.
-Style/EachForSimpleLoop:
- Exclude:
- - 'spec/models/crop_spec.rb'
- - 'spec/views/home/_crops.html.haml_spec.rb'
-
-# Configuration parameters: EnforcedStyle, SupportedStyles.
-# SupportedStyles: format, sprintf, percent
-Style/FormatString:
- Exclude:
- - 'app/helpers/application_helper.rb'
- - 'spec/helpers/application_helper_spec.rb'
- - 'spec/views/shop/index_spec.rb'
-
Style/IdenticalConditionalBranches:
Exclude:
- 'app/controllers/follows_controller.rb'
-# Cop supports --auto-correct.
-# Configuration parameters: MaxLineLength.
-Style/IfUnlessModifier:
- Exclude:
- - 'app/helpers/crops_helper.rb'
- - 'config/initializers/geocoder.rb'
- - 'lib/tasks/growstuff.rake'
-
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: line_count_dependent, lambda, literal
@@ -146,32 +81,11 @@ Style/MultilineIfModifier:
Exclude:
- 'spec/rails_helper.rb'
-Style/MultilineTernaryOperator:
- Exclude:
- - 'app/controllers/order_items_controller.rb'
-
# Cop supports --auto-correct.
Style/MutableConstant:
Exclude:
- 'app/models/planting.rb'
-# Cop supports --auto-correct.
-Style/NegatedIf:
- Exclude:
- - 'app/helpers/crops_helper.rb'
-
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
-# SupportedStyles: skip_modifier_ifs, always
-Style/Next:
- Exclude:
- - 'lib/tasks/growstuff.rake'
-
-# Cop supports --auto-correct.
-Style/NilComparison:
- Exclude:
- - 'lib/tasks/growstuff.rake'
-
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
# SupportedStyles: predicate, comparison
@@ -187,14 +101,6 @@ Style/ParallelAssignment:
Exclude:
- 'app/mailers/notifier.rb'
-# Cop supports --auto-correct.
-# Configuration parameters: PreferredDelimiters.
-Style/PercentLiteralDelimiters:
- Exclude:
- - 'app/helpers/auto_suggest_helper.rb'
- - 'spec/features/signin_spec.rb'
- - 'spec/features/signout_spec.rb'
-
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
# SupportedStyles: slashes, percent_r, mixed
@@ -205,23 +111,3 @@ Style/RegexpLiteral:
- 'spec/views/devise/registrations/edit_spec.rb'
- 'spec/views/members/index.html.haml_spec.rb'
- 'spec/views/posts/index.html.haml_spec.rb'
-
-# Cop supports --auto-correct.
-# Configuration parameters: SupportedStyles.
-# SupportedStyles: use_perl_names, use_english_names
-Style/SpecialGlobalVars:
- EnforcedStyle: use_perl_names
-
-# Cop supports --auto-correct.
-# Configuration parameters: IgnoredMethods.
-# IgnoredMethods: respond_to, define_method
-Style/SymbolProc:
- Exclude:
- - 'lib/tasks/growstuff.rake'
-
-# Cop supports --auto-correct.
-# Configuration parameters: SupportedStyles, WordRegex.
-# SupportedStyles: percent, brackets
-Style/WordArray:
- EnforcedStyle: percent
- MinSize: 4
diff --git a/Gemfile b/Gemfile
index 36a8608c0..c5d5d1fe1 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
source 'https://rubygems.org'
ruby '2.4.1'
@@ -46,8 +47,8 @@ gem 'comfortable_mexican_sofa' # content management system
gem 'bootstrap-kaminari-views' # bootstrap views for kaminari
gem 'kaminari' # pagination
-gem 'activemerchant'
gem 'active_utils'
+gem 'activemerchant'
gem 'sidekiq'
# Markdown formatting for updates etc
@@ -144,7 +145,7 @@ group :development, :test do
gem 'rainbow', '< 2.2.0' # See https://github.com/sickill/rainbow/issues/44
gem 'rspec-activemodel-mocks'
gem 'rspec-rails' # unit testing framework
- gem 'rubocop', '<= 0.47.1', require: false # Pin to rubocop (0.47.1) as 0.48.0 is buggy
+ gem 'rubocop'
gem 'selenium-webdriver'
gem 'webrat' # provides HTML matchers for view tests
end
diff --git a/Gemfile.lock b/Gemfile.lock
index 7042c04c2..e3f9bf48f 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -366,6 +366,7 @@ GEM
cocaine (~> 0.5.5)
mime-types
mimemagic (~> 0.3.0)
+ parallel (1.12.0)
parser (2.4.0.2)
ast (~> 2.3)
pg (0.21.0)
@@ -461,7 +462,8 @@ GEM
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.0)
- rubocop (0.47.1)
+ rubocop (0.49.1)
+ parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
@@ -623,7 +625,7 @@ DEPENDENCIES
responders
rspec-activemodel-mocks
rspec-rails
- rubocop (<= 0.47.1)
+ rubocop
ruby-units
sass-rails
selenium-webdriver
diff --git a/Guardfile b/Guardfile
index edc8164d3..4b5f3ccb5 100644
--- a/Guardfile
+++ b/Guardfile
@@ -1,13 +1,13 @@
guard :rspec,
- cmd: 'bundle exec rspec --format documentation',
- failed_mode: :keep do
+ cmd: 'bundle exec rspec --format documentation',
+ failed_mode: :keep do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/libs/#{m[1]}_spec.rb" }
- watch('spec/spec_helper.rb') { "spec" }
+ watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
-end
\ No newline at end of file
+end
diff --git a/Rakefile b/Rakefile
old mode 100644
new mode 100755
diff --git a/app/controllers/alternate_names_controller.rb b/app/controllers/alternate_names_controller.rb
index b673a63d7..0f1471a8c 100644
--- a/app/controllers/alternate_names_controller.rb
+++ b/app/controllers/alternate_names_controller.rb
@@ -1,5 +1,5 @@
class AlternateNamesController < ApplicationController
- before_action :authenticate_member!, except: [:index, :show]
+ before_action :authenticate_member!, except: %i(index show)
load_and_authorize_resource
respond_to :html, :json
responders :flash
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index f85302d74..389efb825 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -1,5 +1,5 @@
class CommentsController < ApplicationController
- before_action :authenticate_member!, except: [:index, :show]
+ before_action :authenticate_member!, except: %i(index show)
load_and_authorize_resource
respond_to :html, :json
respond_to :rss, only: :index
diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb
index ffb5c49a1..3df1a7ca7 100644
--- a/app/controllers/crops_controller.rb
+++ b/app/controllers/crops_controller.rb
@@ -1,9 +1,9 @@
require 'will_paginate/array'
class CropsController < ApplicationController
- before_action :authenticate_member!, except: [:index, :hierarchy, :search, :show]
+ before_action :authenticate_member!, except: %i(index hierarchy search show)
load_and_authorize_resource
- skip_authorize_resource only: [:hierarchy, :search]
+ skip_authorize_resource only: %i(hierarchy search)
respond_to :html, :json, :rss, :csv
responders :flash
@@ -134,7 +134,7 @@ class CropsController < ApplicationController
end
def recreate_names(param_name, name_type)
- return unless params[param_name].present?
+ return if params[param_name].blank?
destroy_names(name_type)
params[param_name].each do |_i, value|
create_name!(name_type, value) unless value.empty?
@@ -159,9 +159,9 @@ class CropsController < ApplicationController
:request_notes,
:reason_for_rejection,
:rejection_notes,
- scientific_names_attributes: [:scientific_name,
- :_destroy,
- :id])
+ scientific_names_attributes: %i(scientific_name
+ _destroy
+ id))
end
def filename
@@ -173,7 +173,7 @@ class CropsController < ApplicationController
include: {
plantings: {
include: {
- owner: { only: [:id, :login_name, :location, :latitude, :longitude] }
+ owner: { only: %i(id login_name location latitude longitude) }
}
},
scientific_names: { only: [:name] },
diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb
index 6b345dc70..ede5c2602 100644
--- a/app/controllers/gardens_controller.rb
+++ b/app/controllers/gardens_controller.rb
@@ -1,6 +1,6 @@
class GardensController < ApplicationController
- before_action :authenticate_member!, except: [:index, :show]
- after_action :expire_homepage, only: [:create, :delete]
+ before_action :authenticate_member!, except: %i(index show)
+ after_action :expire_homepage, only: %i(create delete)
load_and_authorize_resource
respond_to :html, :json
diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb
index 1353a8720..c346eb8e3 100644
--- a/app/controllers/members_controller.rb
+++ b/app/controllers/members_controller.rb
@@ -1,6 +1,6 @@
class MembersController < ApplicationController
- load_and_authorize_resource except: [:finish_signup, :unsubscribe, :view_follows, :view_followers, :show]
- skip_authorize_resource only: [:nearby, :unsubscribe, :finish_signup]
+ load_and_authorize_resource except: %i(finish_signup unsubscribe view_follows view_followers show)
+ skip_authorize_resource only: %i(nearby unsubscribe finish_signup)
respond_to :html, :json, :rss
after_action :expire_homepage, only: :create
@@ -62,7 +62,6 @@ class MembersController < ApplicationController
@member.update(@type => false)
flash.now[:notice] = I18n.t('members.unsubscribed', email_type: EMAIL_TYPE_STRING[@type])
-
rescue ActiveSupport::MessageVerifier::InvalidSignature
flash.now[:alert] = I18n.t('members.unsubscribe.error')
end
@@ -88,11 +87,11 @@ class MembersController < ApplicationController
end
def member_json_fields
- [
- :id, :login_name,
- :slug, :bio, :created_at,
- :location, :latitude, :longitude
- ]
+ %i(
+ id login_name
+ slug bio created_at
+ location latitude longitude
+ )
end
def members
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb
index afb56d3db..3d642cd3d 100644
--- a/app/controllers/omniauth_callbacks_controller.rb
+++ b/app/controllers/omniauth_callbacks_controller.rb
@@ -30,7 +30,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
@authentication = action.establish_authentication(auth, member)
if action.member_created?
- raise "Invalid provider" unless ['facebook', 'twitter', 'flickr'].index(auth['provider'].to_s)
+ raise "Invalid provider" unless %w(facebook twitter flickr).index(auth['provider'].to_s)
session["devise.#{auth['provider']}_data"] = request.env["omniauth.auth"]
sign_in member
diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb
index 1f091b19b..18e95302b 100644
--- a/app/controllers/photos_controller.rb
+++ b/app/controllers/photos_controller.rb
@@ -1,6 +1,6 @@
class PhotosController < ApplicationController
- before_action :authenticate_member!, except: [:index, :show]
- after_action :expire_homepage, only: [:create, :delete]
+ before_action :authenticate_member!, except: %i(index show)
+ after_action :expire_homepage, only: %i(create delete)
load_and_authorize_resource
respond_to :html, :json
responders :flash
diff --git a/app/controllers/places_controller.rb b/app/controllers/places_controller.rb
index cf821e32b..4586b5d39 100644
--- a/app/controllers/places_controller.rb
+++ b/app/controllers/places_controller.rb
@@ -7,9 +7,9 @@ class PlacesController < ApplicationController
format.html
# json response is whatever we want to map here
format.json do
- render json: Member.located.to_json(only: [
- :id, :login_name, :slug, :location, :latitude, :longitude
- ])
+ render json: Member.located.to_json(only: %i(
+ id login_name slug location latitude longitude
+ ))
end
end
end
@@ -22,9 +22,9 @@ class PlacesController < ApplicationController
respond_to do |format|
format.html # show.html.haml
format.json do
- render json: @nearby_members.to_json(only: [
- :id, :login_name, :slug, :location, :latitude, :longitude
- ])
+ render json: @nearby_members.to_json(only: %i(
+ id login_name slug location latitude longitude
+ ))
end
end
end
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index 287ef6f2a..47aa6bd18 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -1,8 +1,8 @@
class PostsController < ApplicationController
- before_action :authenticate_member!, except: [:index, :show]
+ before_action :authenticate_member!, except: %i(index show)
load_and_authorize_resource
respond_to :html, :json
- respond_to :rss, only: [:index, :show]
+ respond_to :rss, only: %i(index show)
# GET /posts
# GET /posts.json
diff --git a/app/controllers/scientific_names_controller.rb b/app/controllers/scientific_names_controller.rb
index 954a94dbc..cf58fd4f7 100644
--- a/app/controllers/scientific_names_controller.rb
+++ b/app/controllers/scientific_names_controller.rb
@@ -1,5 +1,5 @@
class ScientificNamesController < ApplicationController
- before_action :authenticate_member!, except: [:index, :show]
+ before_action :authenticate_member!, except: %i(index show)
load_and_authorize_resource
respond_to :html, :json
responders :flash
diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb
index f21b1b61a..f7cf530eb 100644
--- a/app/controllers/seeds_controller.rb
+++ b/app/controllers/seeds_controller.rb
@@ -1,5 +1,5 @@
class SeedsController < ApplicationController
- before_action :authenticate_member!, except: [:index, :show]
+ before_action :authenticate_member!, except: %i(index show)
load_and_authorize_resource
respond_to :html, :json
respond_to :csv, only: :index
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 2fde0fcf8..639d27686 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,11 +1,11 @@
module ApplicationHelper
def price_in_dollars(price)
- sprintf('%.2f', price / 100.0)
+ format('%.2f', price / 100.0)
end
# 999 cents becomes 9.99 AUD -- for products/orders/etc
def price_with_currency(price)
- sprintf('%.2f %s', price / 100.0, Growstuff::Application.config.currency)
+ format('%.2f %s', price / 100.0, Growstuff::Application.config.currency)
end
def parse_date(str)
diff --git a/app/helpers/auto_suggest_helper.rb b/app/helpers/auto_suggest_helper.rb
index a8a86de56..caa0cd7ff 100644
--- a/app/helpers/auto_suggest_helper.rb
+++ b/app/helpers/auto_suggest_helper.rb
@@ -11,7 +11,7 @@ module AutoSuggestHelper
resource = resource.class.name.downcase
source_path = Rails.application.routes.url_helpers.send("#{source}s_search_path")
- %Q{
+ %(
@@ -20,6 +20,6 @@ module AutoSuggestHelper
- }.html_safe
+ ).html_safe
end
end
diff --git a/app/helpers/crops_helper.rb b/app/helpers/crops_helper.rb
index c4dc00c0c..b99d687aa 100644
--- a/app/helpers/crops_helper.rb
+++ b/app/helpers/crops_helper.rb
@@ -8,9 +8,7 @@ module CropsHelper
total_quantity += seed.quantity if seed.quantity
end
- if !seeds.any?
- return "You don't have any seeds of this crop."
- end
+ return "You don't have any seeds of this crop." if seeds.none?
if total_quantity != 0
"You have #{total_quantity} #{Seed.model_name.human(count: total_quantity)} of this crop."
diff --git a/app/helpers/harvests_helper.rb b/app/helpers/harvests_helper.rb
index 55aa92a2e..14277817b 100644
--- a/app/helpers/harvests_helper.rb
+++ b/app/helpers/harvests_helper.rb
@@ -15,7 +15,7 @@ module HarvestsHelper
if harvest.unit == 'individual' # just the number
number_to_human(harvest.quantity, strip_insignificant_zeros: true)
- elsif !harvest.unit.blank? # pluralize anything else
+ elsif harvest.unit.present? # pluralize anything else
pluralize(number_to_human(harvest.quantity, strip_insignificant_zeros: true), harvest.unit)
else
"#{number_to_human(harvest.quantity, strip_insignificant_zeros: true)} #{harvest.unit}"
diff --git a/app/helpers/plantings_helper.rb b/app/helpers/plantings_helper.rb
index b8e2b257c..f71dc8158 100644
--- a/app/helpers/plantings_helper.rb
+++ b/app/helpers/plantings_helper.rb
@@ -10,11 +10,11 @@ module PlantingsHelper
end
def display_planted_from(planting)
- !planting.planted_from.blank? ? planting.planted_from : "not specified"
+ planting.planted_from.present? ? planting.planted_from : "not specified"
end
def display_planting_quantity(planting)
- !planting.quantity.blank? ? planting.quantity : "not specified"
+ planting.quantity.present? ? planting.quantity : "not specified"
end
def display_planting(planting)
diff --git a/app/models/crop.rb b/app/models/crop.rb
index c3d4d7c7b..15787f6f1 100644
--- a/app/models/crop.rb
+++ b/app/models/crop.rb
@@ -1,6 +1,6 @@
class Crop < ActiveRecord::Base
extend FriendlyId
- friendly_id :name, use: [:slugged, :finders]
+ friendly_id :name, use: %i(slugged finders)
##
## Triggers
diff --git a/app/models/csv_importer.rb b/app/models/csv_importer.rb
index dadff9978..66297b13c 100644
--- a/app/models/csv_importer.rb
+++ b/app/models/csv_importer.rb
@@ -34,7 +34,7 @@ class CsvImporter
def add_scientific_names(scientific_names)
names_to_add = []
- if !scientific_names.blank? # i.e. we actually passed something in, which isn't a given
+ if scientific_names.present? # i.e. we actually passed something in, which isn't a given
names_to_add = scientific_names.split(/,\s*/)
elsif @crop.parent && !@crop.parent.scientific_names.empty? # pick up from parent
names_to_add = @crop.parent.scientific_names.map(&:name)
diff --git a/app/models/seed.rb b/app/models/seed.rb
index 4213a7886..56c9f809d 100644
--- a/app/models/seed.rb
+++ b/app/models/seed.rb
@@ -1,7 +1,7 @@
class Seed < ActiveRecord::Base
extend FriendlyId
include PhotoCapable
- friendly_id :seed_slug, use: [:slugged, :finders]
+ friendly_id :seed_slug, use: %i(slugged finders)
TRADABLE_TO_VALUES = %w(nowhere locally nationally internationally).freeze
ORGANIC_VALUES = ['certified organic', 'non-certified organic', 'conventional/non-organic', 'unknown'].freeze
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index ad33e335d..ec28eb983 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -43,7 +43,7 @@ Devise.setup do |config|
# Configure which authentication keys should have whitespace stripped.
# These keys will have whitespace before and after removed upon creating or
# modifying a user and when used to authenticate or find a user. Default is :email.
- config.strip_whitespace_keys = [:email, :login_name]
+ config.strip_whitespace_keys = %i(email login_name)
# Tell if authentication through request.params is enabled. True by default.
# It can be set to an array that will enable params authentication only for the
diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb
index 67ce37799..afe41f574 100644
--- a/config/initializers/geocoder.rb
+++ b/config/initializers/geocoder.rb
@@ -11,6 +11,4 @@ Geocoder.configure(
)
# This configuration takes precedence over environment/test.rb
# Reported as https://github.com/alexreisner/geocoder/issues/509
-if Geocoder.config.lookup != :test
- Geocoder.configure(lookup: :nominatim)
-end
+Geocoder.configure(lookup: :nominatim) if Geocoder.config.lookup != :test
diff --git a/config/routes.rb b/config/routes.rb
index 30327901b..1f22a521a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -12,14 +12,14 @@ Growstuff::Application.routes.draw do
devise_scope :member do
get '/members/unsubscribe/:message' => 'members#unsubscribe', :as => 'unsubscribe_member'
end
- match '/members/:id/finish_signup' => 'members#finish_signup', via: [:get, :patch], :as => :finish_signup
+ match '/members/:id/finish_signup' => 'members#finish_signup', via: %i(get patch), :as => :finish_signup
resources :members
resources :photos
delete 'photo_associations' => 'photo_associations#destroy'
- resources :authentications, only: [:create, :destroy]
+ resources :authentications, only: %i(create destroy)
resources :plantings do
resources :harvests
@@ -59,7 +59,7 @@ Growstuff::Application.routes.draw do
get 'reply', on: :member
end
- resources :follows, only: [:create, :destroy]
+ resources :follows, only: %i(create destroy)
get '/members/:login_name/follows' => 'members#view_follows', :as => 'member_follows'
get '/members/:login_name/followers' => 'members#view_followers', :as => 'member_followers'
@@ -78,7 +78,7 @@ Growstuff::Application.routes.draw do
resources :order_items
resources :products
- resources :likes, only: [:create, :destroy]
+ resources :likes, only: %i(create destroy)
get "home/index"
root to: 'home#index'
diff --git a/db/migrate/20121109130033_add_creation_index_to_updates.rb b/db/migrate/20121109130033_add_creation_index_to_updates.rb
index 4e3f4c560..46601ef3d 100644
--- a/db/migrate/20121109130033_add_creation_index_to_updates.rb
+++ b/db/migrate/20121109130033_add_creation_index_to_updates.rb
@@ -1,5 +1,5 @@
class AddCreationIndexToUpdates < ActiveRecord::Migration
def change
- add_index :updates, [:created_at, :user_id]
+ add_index :updates, %i(created_at user_id)
end
end
diff --git a/db/migrate/20130215131921_rename_notification_fields.rb b/db/migrate/20130215131921_rename_notification_fields.rb
index 3f11af8af..63f52ae6d 100644
--- a/db/migrate/20130215131921_rename_notification_fields.rb
+++ b/db/migrate/20130215131921_rename_notification_fields.rb
@@ -1,6 +1,6 @@
class RenameNotificationFields < ActiveRecord::Migration
def change
- change_table :notifications do |t| # rubocop:disable Rails/ReversibleMigration
+ change_table :notifications do |t|
t.rename :to_id, :recipient_id
t.rename :from_id, :sender_id
end
diff --git a/db/migrate/20140928044231_add_crops_posts_table.rb b/db/migrate/20140928044231_add_crops_posts_table.rb
index 475a993f5..6dcf9a494 100644
--- a/db/migrate/20140928044231_add_crops_posts_table.rb
+++ b/db/migrate/20140928044231_add_crops_posts_table.rb
@@ -4,7 +4,7 @@ class AddCropsPostsTable < ActiveRecord::Migration
t.integer :crop_id
t.integer :post_id
end
- add_index :crops_posts, [:crop_id, :post_id]
+ add_index :crops_posts, %i(crop_id post_id)
add_index :crops_posts, :crop_id
end
end
diff --git a/db/migrate/20141002022459_create_index_harvest_photos.rb b/db/migrate/20141002022459_create_index_harvest_photos.rb
index 75ef69d36..95913bd04 100644
--- a/db/migrate/20141002022459_create_index_harvest_photos.rb
+++ b/db/migrate/20141002022459_create_index_harvest_photos.rb
@@ -1,5 +1,5 @@
class CreateIndexHarvestPhotos < ActiveRecord::Migration
def change
- add_index(:harvests_photos, [:harvest_id, :photo_id])
+ add_index(:harvests_photos, %i(harvest_id photo_id))
end
end
diff --git a/db/migrate/20150127043022_add_gardens_photos_table.rb b/db/migrate/20150127043022_add_gardens_photos_table.rb
index 7e8f8bd81..0c2b99dfe 100644
--- a/db/migrate/20150127043022_add_gardens_photos_table.rb
+++ b/db/migrate/20150127043022_add_gardens_photos_table.rb
@@ -4,6 +4,6 @@ class AddGardensPhotosTable < ActiveRecord::Migration
t.integer :photo_id
t.integer :garden_id
end
- add_index(:gardens_photos, [:garden_id, :photo_id])
+ add_index(:gardens_photos, %i(garden_id photo_id))
end
end
diff --git a/db/migrate/20150201052245_create_cms.rb b/db/migrate/20150201052245_create_cms.rb
index b52816813..e8ba4fb9e 100644
--- a/db/migrate/20150201052245_create_cms.rb
+++ b/db/migrate/20150201052245_create_cms.rb
@@ -33,8 +33,8 @@ class CreateCms < ActiveRecord::Migration
t.boolean :is_shared, null: false, default: false
t.timestamps null: true
end
- add_index :comfy_cms_layouts, [:parent_id, :position]
- add_index :comfy_cms_layouts, [:site_id, :identifier], unique: true
+ add_index :comfy_cms_layouts, %i(parent_id position)
+ add_index :comfy_cms_layouts, %i(site_id identifier), unique: true
# -- Pages --------------------------------------------------------------
create_table :comfy_cms_pages do |t|
@@ -52,8 +52,8 @@ class CreateCms < ActiveRecord::Migration
t.boolean :is_shared, null: false, default: false
t.timestamps null: true
end
- add_index :comfy_cms_pages, [:site_id, :full_path]
- add_index :comfy_cms_pages, [:parent_id, :position]
+ add_index :comfy_cms_pages, %i(site_id full_path)
+ add_index :comfy_cms_pages, %i(parent_id position)
# -- Page Blocks --------------------------------------------------------
create_table :comfy_cms_blocks do |t|
@@ -63,7 +63,7 @@ class CreateCms < ActiveRecord::Migration
t.timestamps null: true
end
add_index :comfy_cms_blocks, [:identifier]
- add_index :comfy_cms_blocks, [:blockable_id, :blockable_type]
+ add_index :comfy_cms_blocks, %i(blockable_id blockable_type)
# -- Snippets -----------------------------------------------------------
create_table :comfy_cms_snippets do |t|
@@ -75,8 +75,8 @@ class CreateCms < ActiveRecord::Migration
t.boolean :is_shared, null: false, default: false
t.timestamps null: true
end
- add_index :comfy_cms_snippets, [:site_id, :identifier], unique: true
- add_index :comfy_cms_snippets, [:site_id, :position]
+ add_index :comfy_cms_snippets, %i(site_id identifier), unique: true
+ add_index :comfy_cms_snippets, %i(site_id position)
# -- Files --------------------------------------------------------------
create_table :comfy_cms_files do |t|
@@ -90,10 +90,10 @@ class CreateCms < ActiveRecord::Migration
t.integer :position, null: false, default: 0
t.timestamps null: true
end
- add_index :comfy_cms_files, [:site_id, :label]
- add_index :comfy_cms_files, [:site_id, :file_file_name]
- add_index :comfy_cms_files, [:site_id, :position]
- add_index :comfy_cms_files, [:site_id, :block_id]
+ add_index :comfy_cms_files, %i(site_id label)
+ add_index :comfy_cms_files, %i(site_id file_file_name)
+ add_index :comfy_cms_files, %i(site_id position)
+ add_index :comfy_cms_files, %i(site_id block_id)
# -- Revisions -----------------------------------------------------------
create_table :comfy_cms_revisions, force: true do |t|
@@ -102,7 +102,7 @@ class CreateCms < ActiveRecord::Migration
t.text :data, text_limit
t.datetime :created_at
end
- add_index :comfy_cms_revisions, [:record_type, :record_id, :created_at],
+ add_index :comfy_cms_revisions, %i(record_type record_id created_at),
name: 'index_cms_revisions_on_rtype_and_rid_and_created_at'
# -- Categories ---------------------------------------------------------
@@ -111,7 +111,7 @@ class CreateCms < ActiveRecord::Migration
t.string :label, null: false
t.string :categorized_type, null: false
end
- add_index :comfy_cms_categories, [:site_id, :categorized_type, :label],
+ add_index :comfy_cms_categories, %i(site_id categorized_type label),
unique: true,
name: 'index_cms_categories_on_site_id_and_cat_type_and_label'
@@ -120,7 +120,7 @@ class CreateCms < ActiveRecord::Migration
t.string :categorized_type, null: false
t.integer :categorized_id, null: false
end
- add_index :comfy_cms_categorizations, [:category_id, :categorized_type, :categorized_id],
+ add_index :comfy_cms_categorizations, %i(category_id categorized_type categorized_id),
unique: true,
name: 'index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id'
end
diff --git a/db/migrate/20161201154922_add_photos_seeds_table.rb b/db/migrate/20161201154922_add_photos_seeds_table.rb
index 31693d225..f4a2f18fe 100644
--- a/db/migrate/20161201154922_add_photos_seeds_table.rb
+++ b/db/migrate/20161201154922_add_photos_seeds_table.rb
@@ -4,6 +4,6 @@ class AddPhotosSeedsTable < ActiveRecord::Migration
t.integer :photo_id
t.integer :seed_id
end
- add_index(:photos_seeds, [:seed_id, :photo_id])
+ add_index(:photos_seeds, %i(seed_id photo_id))
end
end
diff --git a/lib/geocodable.rb b/lib/geocodable.rb
index 93a09aaf7..7e00c7566 100644
--- a/lib/geocodable.rb
+++ b/lib/geocodable.rb
@@ -6,7 +6,7 @@ module Geocodable
private
def empty_unwanted_geocodes
- return unless location.blank?
+ return if location.present?
self.latitude = nil
self.longitude = nil
end
diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake
index 1daab4175..03b2e3d0e 100644
--- a/lib/tasks/growstuff.rake
+++ b/lib/tasks/growstuff.rake
@@ -62,7 +62,7 @@ namespace :growstuff do
# this fixes up anyone who has erroneously wound up with a 0,0 lat/long
task depopulate_null_island: :environment do
Member.find_each do |m|
- if m.location and (m.latitude == nil and m.longitude == nil)
+ if m.location and (m.latitude.nil? and m.longitude.nil?)
m.geocode
m.save
end
@@ -140,9 +140,7 @@ namespace :growstuff do
puts "Giving each member an account record..."
Member.all.each do |m|
- unless m.account
- Account.create(member_id: m.id)
- end
+ Account.create(member_id: m.id) unless m.account
end
puts "Making Skud a staff account..."
@@ -224,12 +222,11 @@ namespace :growstuff do
task initialize_garden_locations: :environment do
Member.located.find_each do |m|
m.gardens.each do |g|
- if g.location.blank?
- g.location = m.location
- g.latitude = m.latitude
- g.longitude = m.longitude
- g.save
- end
+ next if g.location.present?
+ g.location = m.location
+ g.latitude = m.latitude
+ g.longitude = m.longitude
+ g.save
end
end
end
@@ -277,16 +274,12 @@ namespace :growstuff do
desc "October 2014: remove unused photos"
task remove_unused_photos: :environment do
- Photo.find_each do |p|
- p.destroy_if_unused
- end
+ Photo.find_each(&:destroy_if_unused)
end
desc "October 2014: generate crops_posts records for existing posts"
task generate_crops_posts_records: :environment do
- Post.find_each do |p|
- p.save
- end
+ Post.find_each(&:save)
end
desc "October 2014: add alternate names for crops"
diff --git a/script/check_contributors_md.rb b/script/check_contributors_md.rb
index 444cf372d..3fca50489 100755
--- a/script/check_contributors_md.rb
+++ b/script/check_contributors_md.rb
@@ -18,7 +18,7 @@ if ENV['TRAVIS']
end
else
author = `git config github.user`.chomp
- if $?.exitstatus.positive?
+ if $CHILD_STATUS.exitstatus.positive?
abort %(
Couldn't determine your GitHub username, and not in a Travis PR build
Please set it using
diff --git a/script/heroku_maintenance.rb b/script/heroku_maintenance.rb
index c4cda6aa7..d2a20d67a 100755
--- a/script/heroku_maintenance.rb
+++ b/script/heroku_maintenance.rb
@@ -18,7 +18,7 @@ when "on"
when "off"
maintenance_state = false
else
- abort "usage: #{$0} (on|off)"
+ abort "usage: #{$PROGRAM_NAME} (on|off)"
end
puts "Turning #{maintenance_state} maintenance mode on app #{app}"
diff --git a/spec/controllers/photo_associations_controller_spec.rb b/spec/controllers/photo_associations_controller_spec.rb
index a15d2143d..42e0ccc37 100644
--- a/spec/controllers/photo_associations_controller_spec.rb
+++ b/spec/controllers/photo_associations_controller_spec.rb
@@ -33,7 +33,7 @@ describe PhotoAssociationsController do
rescue
nil
end
- end.not_to change { photo.harvests.count }
+ end.not_to change(photo.harvests, :count)
end
it { expect { delete :destroy, valid_params }.to raise_error(ActiveRecord::RecordNotFound) }
end
diff --git a/spec/factories/member.rb b/spec/factories/member.rb
index b3380e628..619e7d4f2 100644
--- a/spec/factories/member.rb
+++ b/spec/factories/member.rb
@@ -2,7 +2,7 @@ FactoryBot.define do
sequence(:email) { |n| "member#{n}@example.com" }
sequence(:login_name) { |n| "member#{n}" }
- factory :member, aliases: [:author, :owner, :sender, :recipient, :creator] do
+ factory :member, aliases: %i(author owner sender recipient creator) do
login_name { generate(:login_name) }
password 'password1'
email { generate(:email) }
diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb
index feaf5d351..aa81403d6 100644
--- a/spec/features/notifications_spec.rb
+++ b/spec/features/notifications_spec.rb
@@ -5,13 +5,13 @@ feature "Notifications", :js do
let(:recipient) { create :member }
context "On existing notification" do
- let!(:notification) {
+ let!(:notification) do
create :notification,
sender: sender,
recipient: recipient,
body: "Notification body",
post_id: nil
- }
+ end
background do
login_as recipient
diff --git a/spec/features/signin_spec.rb b/spec/features/signin_spec.rb
index a6224e05a..acd9f5295 100644
--- a/spec/features/signin_spec.rb
+++ b/spec/features/signin_spec.rb
@@ -48,7 +48,7 @@ feature "signin", js: true do
end
describe "redirects to what you were trying to do" do
- %w[plantings harvests posts photos gardens seeds].each do |m|
+ %w(plantings harvests posts photos gardens seeds).each do |m|
it_behaves_like "redirects to what you were trying to do" do
let(:model_name) { m }
end
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index fe390bbc0..b3ea0ce52 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -3,7 +3,7 @@ require 'rails_helper'
describe ApplicationHelper do
it "formats prices" do
price_in_dollars(999).should eq '9.99'
- price_with_currency(999).should eq '9.99 %s' % Growstuff::Application.config.currency
+ price_with_currency(999).should eq format('9.99 %s', Growstuff::Application.config.currency)
end
it "parses dates" do
diff --git a/spec/lib/haml/filters/escaped_markdown_spec.rb b/spec/lib/haml/filters/escaped_markdown_spec.rb
index 5afac0a04..415751293 100644
--- a/spec/lib/haml/filters/escaped_markdown_spec.rb
+++ b/spec/lib/haml/filters/escaped_markdown_spec.rb
@@ -5,7 +5,7 @@ require 'haml/helpers'
describe 'Haml::Filters::Escaped_Markdown' do
it 'is registered as the handler for :escaped_markdown' do
- Haml::Filters::defined['escaped_markdown'].should ==
+ Haml::Filters.defined['escaped_markdown'].should ==
Haml::Filters::EscapedMarkdown
end
diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb
index bc1b66b66..03ad3b0e1 100644
--- a/spec/lib/haml/filters/growstuff_markdown_spec.rb
+++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb
@@ -24,7 +24,7 @@ end
describe 'Haml::Filters::Growstuff_Markdown' do
it 'is registered as the handler for :growstuff_markdown' do
- Haml::Filters::defined['growstuff_markdown'].should ==
+ Haml::Filters.defined['growstuff_markdown'].should ==
Haml::Filters::GrowstuffMarkdown
end
diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb
index f855a6cfd..ef746c8bc 100644
--- a/spec/models/ability_spec.rb
+++ b/spec/models/ability_spec.rb
@@ -111,19 +111,23 @@ describe Ability do
context "orders" do
let(:order) { FactoryBot.create(:order, member: member) }
- let(:strangers_order) {
+ let(:strangers_order) do
FactoryBot.create(:order,
- member: FactoryBot.create(:member)) }
- let(:completed_order) {
+ member: FactoryBot.create(:member))
+ end
+ let(:completed_order) do
FactoryBot.create(:completed_order,
- member: member) }
+ member: member)
+ end
let(:order_item) { FactoryBot.create(:order_item, order: order) }
- let(:strangers_order_item) {
+ let(:strangers_order_item) do
FactoryBot.create(:order_item,
- order: strangers_order) }
- let(:completed_order_item) {
+ order: strangers_order)
+ end
+ let(:completed_order_item) do
FactoryBot.create(:order_item,
- order: completed_order) }
+ order: completed_order)
+ end
context "standard member" do
it "can read their own orders" do
diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb
index b98c52062..bc90ee8ba 100644
--- a/spec/models/comment_spec.rb
+++ b/spec/models/comment_spec.rb
@@ -17,9 +17,9 @@ describe Comment do
let(:comment) { FactoryBot.create(:comment) }
it "sends a notification when a comment is posted" do
- expect {
+ expect do
FactoryBot.create(:comment)
- }.to change(Notification, :count).by(1)
+ end.to change(Notification, :count).by(1)
end
it "sets the notification fields" do
@@ -35,9 +35,9 @@ describe Comment do
it "doesn't send notifications to yourself" do
@m = FactoryBot.create(:member)
@p = FactoryBot.create(:post, author: @m)
- expect {
+ expect do
FactoryBot.create(:comment, post: @p, author: @m)
- }.to change(Notification, :count).by(0)
+ end.to change(Notification, :count).by(0)
end
end
diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb
index 5d9b671c0..73a460302 100644
--- a/spec/models/crop_spec.rb
+++ b/spec/models/crop_spec.rb
@@ -275,17 +275,17 @@ describe Crop do
@crop2 = FactoryBot.create(:crop)
# they need 3+ plantings each to be interesting
- (1..3).each do
+ 3.times do
FactoryBot.create(:planting, crop: @crop1)
end
- (1..3).each do
+ 3.times do
FactoryBot.create(:planting, crop: @crop2)
end
# crops need 3+ photos to be interesting
@photo = FactoryBot.create(:photo)
[@crop1, @crop2].each do |c|
- (1..3).each do
+ 3.times do
c.plantings.first.photos << @photo
c.plantings.first.save
end
@@ -302,13 +302,13 @@ describe Crop do
@crop2 = FactoryBot.create(:crop)
# only crop1 has plantings
- (1..3).each do
+ 3.times do
FactoryBot.create(:planting, crop: @crop1)
end
# ... and photos
@photo = FactoryBot.create(:photo)
- (1..3).each do
+ 3.times do
@crop1.plantings.first.photos << @photo
@crop1.plantings.first.save
end
@@ -324,16 +324,16 @@ describe Crop do
@crop2 = FactoryBot.create(:crop)
# both crops have plantings
- (1..3).each do
+ 3.times do
FactoryBot.create(:planting, crop: @crop1)
end
- (1..3).each do
+ 3.times do
FactoryBot.create(:planting, crop: @crop2)
end
# but only crop1 has photos
@photo = FactoryBot.create(:photo)
- (1..3).each do
+ 3.times do
@crop1.plantings.first.photos << @photo
@crop1.plantings.first.save
end
diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb
index 4bf82f2b3..bd61fe2ee 100644
--- a/spec/models/follow_spec.rb
+++ b/spec/models/follow_spec.rb
@@ -7,16 +7,16 @@ describe Follow do
end
it "sends a notification when a follow is created" do
- expect {
+ expect do
Follow.create(follower_id: @member1.id, followed_id: @member2.id)
- }.to change(Notification, :count).by(1)
+ end.to change(Notification, :count).by(1)
end
it "does not delete any members when follow is deleted" do
- expect {
+ expect do
follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id)
follow.destroy
- }.not_to change(Member, :count)
+ end.not_to change(Member, :count)
end
context "when follow is created" do
diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb
index 7dd56f1cb..1911ae8da 100644
--- a/spec/models/member_spec.rb
+++ b/spec/models/member_spec.rb
@@ -353,9 +353,10 @@ describe 'member' do
end
context "update account" do
- let(:product) {
+ let(:product) do
FactoryBot.create(:product,
- paid_months: 3)}
+ paid_months: 3)
+ end
let(:member) { FactoryBot.create(:member) }
it "sets account_type" do
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
index 566f451cb..cb8cbcc91 100644
--- a/spec/models/post_spec.rb
+++ b/spec/models/post_spec.rb
@@ -95,15 +95,15 @@ describe Post do
let(:member2) { FactoryBot.create(:member) }
it "sends a notification when a member is mentioned using @-syntax" do
- expect {
+ expect do
FactoryBot.create(:post, author: member, body: "Hey @#{member2}")
- }.to change(Notification, :count).by(1)
+ end.to change(Notification, :count).by(1)
end
it "sends a notification when a member is mentioned using [](member) syntax" do
- expect {
+ expect do
FactoryBot.create(:post, author: member, body: "Hey [#{member2}](member)")
- }.to change(Notification, :count).by(1)
+ end.to change(Notification, :count).by(1)
end
it "sets the notification field" do
@@ -117,15 +117,15 @@ describe Post do
it "sends notifications to all members mentioned" do
member3 = FactoryBot.create(:member)
- expect {
+ expect do
FactoryBot.create(:post, author: member, body: "Hey @#{member2} & @#{member3}")
- }.to change(Notification, :count).by(2)
+ end.to change(Notification, :count).by(2)
end
it "doesn't send notifications if you mention yourself" do
- expect {
+ expect do
FactoryBot.create(:post, author: member, body: "@#{member}")
- }.to change(Notification, :count).by(0)
+ end.to change(Notification, :count).by(0)
end
end
diff --git a/spec/models/seed_spec.rb b/spec/models/seed_spec.rb
index aa06af6eb..c1cd95cbd 100644
--- a/spec/models/seed_spec.rb
+++ b/spec/models/seed_spec.rb
@@ -112,7 +112,7 @@ describe Seed do
end
it 'should refuse invalid organic/GMO/heirloom values' do
- [:organic, :gmo, :heirloom].each do |field|
+ %i(organic gmo heirloom).each do |field|
@seed = FactoryBot.build(:seed, field => 'not valid')
@seed.should_not be_valid
@seed.errors[field].should_not be_empty
@@ -120,7 +120,7 @@ describe Seed do
end
it 'should not allow nil or blank values' do
- [:organic, :gmo, :heirloom].each do |field|
+ %i(organic gmo heirloom).each do |field|
@seed = FactoryBot.build(:seed, field => nil)
@seed.should_not be_valid
@seed = FactoryBot.build(:seed, field => '')
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 800df0ebb..e28dd6e24 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -37,7 +37,7 @@ if ENV['GROWSTUFF_CAPYBARA_DRIVER'].present?
end
Capybara::Screenshot.register_filename_prefix_formatter(:rspec) do |example|
- "screenshot_#{example.description.gsub(' ', '-').gsub(/^.*\/spec\//, '')}"
+ "screenshot_#{example.description.tr(' ', '-').gsub(/^.*\/spec\//, '')}"
end
Capybara.app_host = 'http://localhost'
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 488353ff7..9a0b542df 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -28,7 +28,7 @@ RSpec.configure do |config|
# # => "be bigger than 2 and smaller than 4"
# ...rather than:
# # => "be bigger than 2"
- expectations.syntax = [:should, :expect]
+ expectations.syntax = %i(should expect)
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
@@ -39,7 +39,7 @@ RSpec.configure do |config|
# a real object. This is generally recommended, and will default to
# `true` in RSpec 4.
mocks.verify_partial_doubles = false
- mocks.syntax = [:should, :expect]
+ mocks.syntax = %i(should expect)
end
# The settings below are suggested to provide a good initial experience
diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb
index fd2d2c24b..f11a3a957 100644
--- a/spec/support/feature_helpers.rb
+++ b/spec/support/feature_helpers.rb
@@ -8,7 +8,7 @@ module FeatureHelpers
def select_from_autocomplete(select)
page.should have_selector('ul.ui-autocomplete li.ui-menu-item a')
- selector = %Q{ul.ui-autocomplete li.ui-menu-item a:contains("#{select}")}
+ selector = %{ul.ui-autocomplete li.ui-menu-item a:contains("#{select}")}
page.execute_script " $('#{selector}').mouseenter().click() "
end
end
diff --git a/spec/views/crops/edit.html.haml_spec.rb b/spec/views/crops/edit.html.haml_spec.rb
index eed85528d..19fac21af 100644
--- a/spec/views/crops/edit.html.haml_spec.rb
+++ b/spec/views/crops/edit.html.haml_spec.rb
@@ -2,9 +2,9 @@ require 'rails_helper'
describe "crops/edit" do
before(:each) do
- controller.stub(:current_user) {
+ controller.stub(:current_user) do
FactoryBot.create(:crop_wrangling_member)
- }
+ end
@crop = FactoryBot.create(:maize)
3.times do
@crop.scientific_names.build
diff --git a/spec/views/shop/index_spec.rb b/spec/views/shop/index_spec.rb
index 3bd0061d7..754f05c09 100644
--- a/spec/views/shop/index_spec.rb
+++ b/spec/views/shop/index_spec.rb
@@ -20,7 +20,7 @@ describe 'shop/index.html.haml', type: "view" do
end
it 'shows prices in configured currency' do
- rendered.should have_content '9.99 %s' % Growstuff::Application.config.currency
+ rendered.should have_content format('9.99 %s', Growstuff::Application.config.currency)
end
it 'should contain an exchange rate link' do
@@ -29,7 +29,7 @@ describe 'shop/index.html.haml', type: "view" do
end
it 'shows recommended price for products that have it' do
- rendered.should have_content '12.00 %s' % Growstuff::Application.config.currency
+ rendered.should have_content format('12.00 %s', Growstuff::Application.config.currency)
end
it 'should contain an exchange rate link for recommended price' do