mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-16 12:40:07 -04:00
Merge branch 'dev' into ordering
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
5
Gemfile
5
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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] },
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -11,7 +11,7 @@ module AutoSuggestHelper
|
||||
resource = resource.class.name.downcase
|
||||
source_path = Rails.application.routes.url_helpers.send("#{source}s_search_path")
|
||||
|
||||
%Q{
|
||||
%(
|
||||
<input id="#{source}" class="auto-suggest #{options[:class]}"
|
||||
type="text" value="#{default}" data-source-url="#{source_path}",
|
||||
placeholder="e.g. lettuce">
|
||||
@@ -20,6 +20,6 @@ module AutoSuggestHelper
|
||||
</noscript>
|
||||
<input id="#{resource}_#{source}_id" class="auto-suggest-id"
|
||||
type="hidden" name="#{resource}[#{source}_id]" value="#{default_id}">
|
||||
}.html_safe
|
||||
).html_safe
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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}"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Crop < ActiveRecord::Base
|
||||
extend FriendlyId
|
||||
friendly_id :name, use: [:slugged, :finders]
|
||||
friendly_id :name, use: %i(slugged finders)
|
||||
|
||||
##
|
||||
## Triggers
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 => '')
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user