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 71addf491..de0b44b30 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -58,7 +58,7 @@ GEM
public_suffix (>= 2.0.2, < 4.0)
arel (6.0.4)
ast (2.3.0)
- autoprefixer-rails (7.1.6)
+ autoprefixer-rails (7.2.2)
execjs
bcrypt (3.1.11)
better_errors (2.2.0)
@@ -81,7 +81,7 @@ GEM
sass (>= 3.3.4)
bootstrap_form (2.7.0)
builder (3.2.3)
- bullet (5.6.1)
+ bullet (5.7.0)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.10.0)
byebug (9.1.0)
@@ -181,8 +181,8 @@ GEM
factory_bot_rails (4.8.2)
factory_bot (~> 4.8.2)
railties (>= 3.0.0)
- faker (1.8.4)
- i18n (~> 0.5)
+ faker (1.8.5)
+ i18n (~> 0.9.1)
faraday (0.12.2)
multipart-post (>= 1.2, < 3)
ffi (1.9.18)
@@ -232,11 +232,11 @@ GEM
haml (>= 4.0.6, < 6.0)
html2haml (>= 1.0.1)
railties (>= 4.0.1)
- haml_lint (0.25.1)
+ haml_lint (0.26.0)
haml (>= 4.0, < 5.1)
rainbow
rake (>= 10, < 13)
- rubocop (>= 0.47.0)
+ rubocop (>= 0.49.0)
sysexits (~> 1.1)
hashie (3.5.6)
heroics (0.0.24)
@@ -335,7 +335,7 @@ GEM
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
- oauth (0.5.3)
+ oauth (0.5.4)
oauth2 (1.4.0)
faraday (>= 0.8, < 0.13)
jwt (~> 1.0)
@@ -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,14 +462,15 @@ 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)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0)
- ruby-units (2.2.0)
+ ruby-units (2.2.1)
ruby_dep (1.5.0)
ruby_parser (3.10.1)
sexp_processor (~> 4.9)
@@ -519,11 +521,11 @@ GEM
thread_safe (0.3.6)
tilt (2.0.8)
timecop (0.9.1)
- tins (1.16.0)
+ tins (1.16.3)
trollop (1.16.2)
tzinfo (1.2.4)
thread_safe (~> 0.1)
- uglifier (3.2.0)
+ uglifier (4.0.2)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.3.0)
unicorn (5.3.1)
@@ -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/authentications_controller.rb b/app/controllers/authentications_controller.rb
index 311cf7a9b..fc18ff4d7 100644
--- a/app/controllers/authentications_controller.rb
+++ b/app/controllers/authentications_controller.rb
@@ -1,3 +1,4 @@
+require './lib/actions/oauth_signup_action'
class AuthenticationsController < ApplicationController
before_action :authenticate_member!
load_and_authorize_resource
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 2a16206bb..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
@@ -50,7 +50,7 @@ class CropsController < ApplicationController
def show
@crop = Crop.includes(:scientific_names, plantings: :photos).find(params[:id])
- @posts = @crop.posts.paginate(page: params[:page])
+ @posts = @crop.posts.order(created_at: :desc).paginate(page: params[:page])
respond_to do |format|
format.html # show.html.haml
@@ -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 4d21c4894..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
@@ -120,7 +120,8 @@ class Crop < ActiveRecord::Base
# later we can choose a default photo based on different criteria,
# eg. popularity
def default_photo
- return photos.first if photos.any?
+ # most recent photo
+ return photos.order(created_at: :desc).first if photos.any?
# Crop has no photos? Look for the most recent harvest with a photo.
harvest_with_photo = Harvest.where(crop_id: id).joins(:photos).order('harvests.id DESC').limit(1).first
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/app/views/devise/registrations/_edit_apps.html.haml b/app/views/devise/registrations/_edit_apps.html.haml
index d0482e015..924a0db8a 100644
--- a/app/views/devise/registrations/_edit_apps.html.haml
+++ b/app/views/devise/registrations/_edit_apps.html.haml
@@ -16,7 +16,7 @@
confirm: "Are you sure you want to remove this connection?",
method: :delete, class: "remove"
- else
- = link_to 'Connect to Twitter', '/auth/twitter'
+ = link_to 'Connect to Twitter', '/members/auth/twitter'
.row
.col-md-12
@@ -30,7 +30,7 @@
confirm: "Are you sure you want to remove this connection?",
method: :delete, class: "remove"
- else
- = link_to 'Connect to Flickr', '/auth/flickr'
+ = link_to 'Connect to Flickr', '/members/auth/flickr'
.row
.col-md-12
@@ -44,4 +44,4 @@
confirm: "Are you sure you want to remove this connection?",
method: :delete, class: "remove"
- else
- = link_to 'Connect to Facebook', '/auth/facebook'
+ = link_to 'Connect to Facebook', '/members/auth/facebook'
diff --git a/app/views/harvests/_card.html.haml b/app/views/harvests/_card.html.haml
new file mode 100644
index 000000000..e82d53725
--- /dev/null
+++ b/app/views/harvests/_card.html.haml
@@ -0,0 +1,29 @@
+.panel.panel-success
+ .panel-heading
+ %h3.panel-title
+ = link_to "#{harvest.owner.login_name}'s #{harvest.crop.name} harvest", harvest
+ - if can? :edit, harvest
+ %a.pull-right{ href: edit_harvest_path(harvest), role: "button", id: "edit_harvest_glyphicon" }
+ %span.glyphicon.glyphicon-pencil{ title: "Edit" }
+ .panel-body
+ .row
+ .col-md-4
+ = link_to image_tag((harvest.default_photo ? harvest.default_photo.thumbnail_url : 'placeholder_150.png'),
+ alt: harvest.crop.name, class: 'img'),
+ harvest
+ .col-md-8
+ %dl.dl-horizontal
+ %dt Crop :
+ %dd= link_to harvest.crop.name, harvest.crop
+ %dt Plant part :
+ %dd= link_to harvest.plant_part, harvest.plant_part
+ %dt Quantity :
+ %dd= display_quantity(harvest)
+ %dt Harvest date :
+ %dd= harvest.harvested_at
+ .panel-footer
+ %dt Description
+ %dd.truncate
+ = display_harvest_description(harvest)
+ = if harvest.description.present?
+ - link_to "Read more", harvest_path(harvest)
diff --git a/app/views/harvests/_thumbnail.html.haml b/app/views/harvests/_thumbnail.html.haml
index e82d53725..9a9beac0c 100644
--- a/app/views/harvests/_thumbnail.html.haml
+++ b/app/views/harvests/_thumbnail.html.haml
@@ -1,29 +1,9 @@
-.panel.panel-success
- .panel-heading
- %h3.panel-title
- = link_to "#{harvest.owner.login_name}'s #{harvest.crop.name} harvest", harvest
- - if can? :edit, harvest
- %a.pull-right{ href: edit_harvest_path(harvest), role: "button", id: "edit_harvest_glyphicon" }
- %span.glyphicon.glyphicon-pencil{ title: "Edit" }
- .panel-body
- .row
- .col-md-4
- = link_to image_tag((harvest.default_photo ? harvest.default_photo.thumbnail_url : 'placeholder_150.png'),
- alt: harvest.crop.name, class: 'img'),
- harvest
- .col-md-8
- %dl.dl-horizontal
- %dt Crop :
- %dd= link_to harvest.crop.name, harvest.crop
- %dt Plant part :
- %dd= link_to harvest.plant_part, harvest.plant_part
- %dt Quantity :
- %dd= display_quantity(harvest)
- %dt Harvest date :
- %dd= harvest.harvested_at
- .panel-footer
- %dt Description
- %dd.truncate
- = display_harvest_description(harvest)
- = if harvest.description.present?
- - link_to "Read more", harvest_path(harvest)
+.thumbnail
+ .harvest-thumbnail
+ - if harvest
+ = link_to image_tag((harvest.default_photo ? harvest.default_photo.thumbnail_url : 'placeholder_150.png'),
+ alt: harvest.crop.name, class: 'img'),
+ harvest
+ .harvestinfo
+ .harvest-name
+ = link_to harvest, harvest
diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml
index fa0be4ed3..f743f8ad3 100644
--- a/app/views/harvests/index.html.haml
+++ b/app/views/harvests/index.html.haml
@@ -15,7 +15,7 @@
- unless @harvests.empty?
- @harvests.each do |harvest|
.col-md-6
- = render partial: 'harvests/thumbnail', locals: { harvest: harvest }
+ = render 'harvests/card', harvest: harvest
.pagination
= page_entries_info @harvests
diff --git a/app/views/home/_discuss.html.haml b/app/views/home/_discuss.html.haml
index 9159cde46..9ffc6b502 100644
--- a/app/views/home/_discuss.html.haml
+++ b/app/views/home/_discuss.html.haml
@@ -5,7 +5,7 @@
= render partial: "posts/summary", locals: { posts: posts, howmany: 6 }
- cache cache_key_for(Forum) do
- - forums = Forum.all
+ - forums = Forum.all.order(:name)
- if forums
%ul.list-inline
%li
diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml
index 6fc76779a..7469b90b0 100644
--- a/app/views/home/_seeds.html.haml
+++ b/app/views/home/_seeds.html.haml
@@ -2,7 +2,7 @@
%h2= t('.title')
.row
.col-md-8
- - Seed.includes(:owner, crop: :photos).interesting.first(6).each do |seed|
+ - Seed.includes(:owner, crop: :photos).order(created_at: :desc).interesting.first(6).each do |seed|
.col-md-3
.thumbnail
- cache cache_key_for(Crop, seed.id) do
diff --git a/app/views/members/_thumbnail.html.haml b/app/views/members/_thumbnail.html.haml
index 5ddce4c9f..c9504ea96 100644
--- a/app/views/members/_thumbnail.html.haml
+++ b/app/views/members/_thumbnail.html.haml
@@ -13,7 +13,7 @@
%small
%br/
Recently planted:
- != member.plantings.first(3).map { |p| link_to p.crop_name, p }.join(", ")
+ != member.plantings.order(created_at: :desc).first(3).map { |p| link_to p.crop_name, p }.join(", ")
%p
%small
Joined
@@ -24,4 +24,3 @@
= [localize_plural(member.gardens, Garden),
localize_plural(member.plantings, Planting),
localize_plural(member.seeds, Seed)].join(", ")
-
diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml
index d72f6243b..b2c2d5f98 100644
--- a/app/views/plantings/_actions.html.haml
+++ b/app/views/plantings/_actions.html.haml
@@ -16,7 +16,7 @@
%span.glyphicon.glyphicon-ok{ title: "Finished" }
Mark as finished
- - if can?(:create, Harvest)
+ - if can? :edit, planting
= link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do
%span.glyphicon.glyphicon-leaf{ title: "Harvest" }
Harvest
diff --git a/app/views/plantings/_harvests.html.haml b/app/views/plantings/_harvests.html.haml
index 99535b6be..5edf14a3d 100644
--- a/app/views/plantings/_harvests.html.haml
+++ b/app/views/plantings/_harvests.html.haml
@@ -1,8 +1,12 @@
-- unless planting.harvests.empty?
- Harvests:
- %ul
- - planting.harvests.includes(:crop).each do |harvest|
- %li
- = harvest.harvested_at ? harvest.harvested_at : "undated"
- = link_to harvest, harvest_path(harvest)
- = link_to "more harvests from this planting", planting_harvests_path(planting)
+- if planting.harvests.empty?
+ %p no harvests yet
+- else
+ .row
+ - planting.harvests.order(created_at: :desc).includes(:crop).each do |harvest|
+ .col-xs-6.col-md-2
+ = render 'harvests/thumbnail', harvest: harvest
+ - if can? :edit, planting
+ .col-xs-6.col-md-2
+ = link_to new_planting_harvest_path(planting), class: 'btn btn-primary' do
+ %span.glyphicon.glyphicon-leaf{ title: "Harvest" }
+ Harvest
diff --git a/app/views/plantings/_progress.html.haml b/app/views/plantings/_progress.html.haml
index 876259b85..a594de75d 100644
--- a/app/views/plantings/_progress.html.haml
+++ b/app/views/plantings/_progress.html.haml
@@ -1,15 +1,14 @@
- if planting.crop.perennial
%p Perennial
- elsif !planting.planted?
- - if show_explanation == true
- Progress: 0% - not planted yet
+ - if show_explanation
+ %p Progress: 0% - not planted yet
= render "plantings/progress_bar", status: "not planted", progress: 0
- elsif planting.finished?
= render "plantings/progress_bar", status: 'finished', progress: 100
- elsif planting.finish_predicted_at.nil?
- if show_explanation == true
- Progress: Not enough data
+ %p Progress: Not enough data
= render "plantings/progress_bar", status: "unknown", progress: nil
-
- else
= render "plantings/progress_bar", status: 'growing', progress: planting.percentage_grown
diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml
index 099571218..7c197b7bd 100644
--- a/app/views/plantings/show.html.haml
+++ b/app/views/plantings/show.html.haml
@@ -9,6 +9,7 @@
= tag("meta", property: "og:url", content: request.original_url)
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
+%p= render 'plantings/actions', planting: @planting
.row.planting
.col-md-6
%dl.dl-horizontal.planting-attributes
@@ -45,11 +46,11 @@
%dd
- if @planting.finish_predicted_at.present?
= @planting.finish_predicted_at
- - else
+ - elsif @planting.planted_at.blank?
%strong Set planted date to get predictions
- %dt Finished:
- %dd= display_finished(@planting)
-
+ - if @planting.finished?
+ %dt Finished:
+ %dd= display_finished(@planting)
- if @planting.crop.median_lifespan.present?
%dt Expected Lifespan:
%dd #{@planting.crop.median_lifespan} days
@@ -63,10 +64,11 @@
%dt Last Harvest:
%dd #{@planting.days_to_last_harvest} days after planting
- %p= render 'plantings/harvests', planting: @planting
- %p= render 'plantings/progress', planting: @planting, show_explanation: true
- = render 'plantings/actions', planting: @planting
+ %h2 Progress
+ %p= render 'plantings/progress', planting: @planting, show_explanation: true
+ %h2 Harvests
+ %p= render 'plantings/harvests', planting: @planting
.col-md-6
= render partial: "crops/index_card", locals: { crop: @planting.crop }
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..2a9aa7d5e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -10,44 +10,44 @@ Growstuff::Application.routes.draw do
omniauth_callbacks: "omniauth_callbacks"
}
devise_scope :member do
- get '/members/unsubscribe/:message' => 'members#unsubscribe', :as => 'unsubscribe_member'
+ 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
end
- get '/plantings/owner/:owner' => 'plantings#index', :as => 'plantings_by_owner'
- get '/plantings/crop/:crop' => 'plantings#index', :as => 'plantings_by_crop'
+ get '/plantings/owner/:owner' => 'plantings#index', as: 'plantings_by_owner'
+ get '/plantings/crop/:crop' => 'plantings#index', as: 'plantings_by_crop'
resources :gardens
- get '/gardens/owner/:owner' => 'gardens#index', :as => 'gardens_by_owner'
+ get '/gardens/owner/:owner' => 'gardens#index', as: 'gardens_by_owner'
resources :seeds
- get '/seeds/owner/:owner' => 'seeds#index', :as => 'seeds_by_owner'
- get '/seeds/crop/:crop' => 'seeds#index', :as => 'seeds_by_crop'
+ get '/seeds/owner/:owner' => 'seeds#index', as: 'seeds_by_owner'
+ get '/seeds/crop/:crop' => 'seeds#index', as: 'seeds_by_crop'
resources :harvests
- get '/harvests/owner/:owner' => 'harvests#index', :as => 'harvests_by_owner'
- get '/harvests/crop/:crop' => 'harvests#index', :as => 'harvests_by_crop'
+ get '/harvests/owner/:owner' => 'harvests#index', as: 'harvests_by_owner'
+ get '/harvests/crop/:crop' => 'harvests#index', as: 'harvests_by_crop'
resources :posts
- get '/posts/author/:author' => 'posts#index', :as => 'posts_by_author'
+ get '/posts/author/:author' => 'posts#index', as: 'posts_by_author'
resources :scientific_names
resources :alternate_names
- get 'crops/requested' => 'crops#requested', :as => 'requested_crops'
- get 'crops/wrangle' => 'crops#wrangle', :as => 'wrangle_crops'
- get 'crops/hierarchy' => 'crops#hierarchy', :as => 'crops_hierarchy'
- get 'crops/search' => 'crops#search', :as => 'crops_search'
+ get 'crops/requested' => 'crops#requested', as: 'requested_crops'
+ get 'crops/wrangle' => 'crops#wrangle', as: 'wrangle_crops'
+ get 'crops/hierarchy' => 'crops#hierarchy', as: 'crops_hierarchy'
+ get 'crops/search' => 'crops#search', as: 'crops_search'
resources :crops do
get 'photos' => 'photos#index'
end
@@ -59,26 +59,26 @@ Growstuff::Application.routes.draw do
get 'reply', on: :member
end
- resources :follows, only: [:create, :destroy]
- get '/members/:login_name/follows' => 'members#view_follows', :as => 'member_follows'
- get '/members/:login_name/followers' => 'members#view_followers', :as => 'member_followers'
+ 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'
get '/places' => 'places#index'
- get '/places/search' => 'places#search', :as => 'search_places'
- get '/places/:place' => 'places#show', :as => 'place'
+ get '/places/search' => 'places#search', as: 'search_places'
+ get '/places/:place' => 'places#show', as: 'place'
# everything for paid accounts etc
resources :account_types
resources :accounts
resources :orders
- get 'orders/:id/checkout' => 'orders#checkout', :as => 'checkout_order'
- get 'orders/:id/complete' => 'orders#complete', :as => 'complete_order'
- get 'orders/:id/cancel' => 'orders#cancel', :as => 'cancel_order'
+ get 'orders/:id/checkout' => 'orders#checkout', as: 'checkout_order'
+ get 'orders/:id/complete' => 'orders#complete', as: 'complete_order'
+ get 'orders/:id/cancel' => 'orders#cancel', as: 'cancel_order'
resources :order_items
resources :products
- resources :likes, only: [:create, :destroy]
+ resources :likes, only: %i(create destroy)
get "home/index"
root to: 'home#index'
@@ -93,7 +93,7 @@ Growstuff::Application.routes.draw do
get '/admin/orders' => 'admin/orders#index'
get '/admin/orders/:action' => 'admin/orders#:action'
get '/admin' => 'admin#index'
- get '/admin/newsletter' => 'admin#newsletter', :as => :admin_newsletter
+ get '/admin/newsletter' => 'admin#newsletter', as: :admin_newsletter
get '/admin/:action' => 'admin#:action'
namespace :api do
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/package-lock.json b/package-lock.json
index fc703767c..013886a6b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -195,19 +195,13 @@
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
"dev": true
},
- "coffee-script": {
- "version": "1.11.1",
- "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.11.1.tgz",
- "integrity": "sha1-vxxHrWREOg2V0S3ysUfMCk2q1uk=",
- "dev": true
- },
"coffeelint": {
- "version": "1.16.0",
- "resolved": "https://registry.npmjs.org/coffeelint/-/coffeelint-1.16.0.tgz",
- "integrity": "sha1-g9jtHa/eOmd95E57ihi+YHdh5tg=",
+ "version": "2.0.7",
+ "resolved": "https://registry.npmjs.org/coffeelint/-/coffeelint-2.0.7.tgz",
+ "integrity": "sha1-lg/VuXVrhFGU6fl6R1bmKGEha3Q=",
"dev": true,
"requires": {
- "coffee-script": "1.11.1",
+ "coffeescript": "2.0.3",
"glob": "7.1.2",
"ignore": "3.3.7",
"optimist": "0.6.1",
@@ -215,6 +209,12 @@
"strip-json-comments": "1.0.4"
}
},
+ "coffeescript": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/coffeescript/-/coffeescript-2.0.3.tgz",
+ "integrity": "sha512-iIfUN+71IyI2FQABXh1luzZeQgqwUPeWh6lDovJatQQs+30bvyGnBY0r4BnD0hoMAasNuZVHlL1U09Oy1ZfSeg==",
+ "dev": true
+ },
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
diff --git a/package.json b/package.json
index a46ef1516..f41b67b64 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,7 @@
"main": "index.js",
"dependencies": {},
"devDependencies": {
- "coffeelint": "^1.16.0",
+ "coffeelint": "^2.0.7",
"csslint": "^1.0.5",
"eslint": "^3.17.1",
"jshint": "^2.9.4"
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