From 723ebff92390fcdef1272ab810deda26791b76d7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 26 Nov 2016 12:13:17 +1300 Subject: [PATCH] Spacing fixes --- .rubocop_todo.yml | 195 ------------------ app/controllers/admin/orders_controller.rb | 2 +- app/controllers/application_controller.rb | 2 +- app/controllers/crops_controller.rb | 6 +- app/controllers/follows_controller.rb | 4 +- app/controllers/harvests_controller.rb | 2 +- .../omniauth_callbacks_controller.rb | 2 +- app/controllers/plantings_controller.rb | 2 +- app/controllers/posts_controller.rb | 2 +- app/controllers/robots_controller.rb | 2 +- app/controllers/seeds_controller.rb | 4 +- app/helpers/application_helper.rb | 2 +- app/helpers/auto_suggest_helper.rb | 2 +- app/helpers/crops_helper.rb | 2 +- app/helpers/harvests_helper.rb | 6 +- app/models/ability.rb | 2 +- app/models/crop.rb | 26 +-- app/models/garden.rb | 2 +- app/models/harvest.rb | 4 +- app/models/member.rb | 14 +- app/models/order.rb | 2 +- app/models/planting.rb | 8 +- app/models/post.rb | 6 +- app/models/seed.rb | 2 +- bin/rails | 2 +- config.ru | 2 +- config/environments/test.rb | 4 +- config/initializers/devise.rb | 10 +- db/migrate/20150201052245_create_cms.rb | 6 +- db/seeds.rb | 4 +- lib/actions/oauth_signup_action.rb | 4 +- lib/geocodable.rb | 2 +- script/rails | 4 +- .../admin/orders_controller_spec.rb | 4 +- spec/controllers/comments_controller_spec.rb | 10 +- spec/controllers/gardens_controller_spec.rb | 2 +- spec/controllers/harvests_controller_spec.rb | 34 +-- spec/controllers/member_controller_spec.rb | 14 +- .../notifications_controller_spec.rb | 10 +- .../order_items_controller_spec.rb | 12 +- spec/controllers/orders_controller_spec.rb | 8 +- spec/controllers/plantings_controller_spec.rb | 8 +- spec/controllers/robots_controller_spec.rb | 2 +- spec/controllers/seeds_controller_spec.rb | 2 +- spec/custom_matchers.rb | 2 +- spec/factories/crop.rb | 2 +- spec/factories/member.rb | 6 +- spec/features/crops/browse_crops_spec.rb | 2 +- spec/features/crops/crop_detail_page_spec.rb | 10 +- spec/features/rss/plantings_spec.rb | 2 +- spec/features/rss/posts_spec.rb | 2 +- spec/features/rss/seeds_spec.rb | 2 +- spec/lib/actions/oauth_signup_action_spec.rb | 2 +- .../haml/filters/growstuff_markdown_spec.rb | 6 +- spec/models/crop_spec.rb | 2 +- spec/models/harvest_spec.rb | 3 +- spec/models/member_spec.rb | 2 +- spec/models/planting_spec.rb | 2 +- spec/models/role_spec.rb | 2 +- spec/rails_helper.rb | 4 +- spec/support/controller_macros.rb | 2 +- spec/support/elasticsearch_helpers.rb | 2 +- spec/support/feature_helpers.rb | 2 +- .../crops/_planting_advice.html.haml_spec.rb | 2 +- spec/views/crops/index.html.haml_spec.rb | 2 +- spec/views/crops/wrangle.html.haml_spec.rb | 2 +- spec/views/devise/shared/_links_spec.rb | 4 +- spec/views/forums/index.html.haml_spec.rb | 2 +- spec/views/gardens/show.html.haml_spec.rb | 2 +- spec/views/harvests/index.html.haml_spec.rb | 2 +- spec/views/members/index.html.haml_spec.rb | 2 +- .../notifications/index.html.haml_spec.rb | 2 +- .../views/notifications/new.html.haml_spec.rb | 2 +- .../notifications/show.html.haml_spec.rb | 2 +- spec/views/orders/index.html.haml_spec.rb | 2 +- spec/views/photos/new.html.haml_spec.rb | 4 +- spec/views/plantings/index.html.haml_spec.rb | 2 +- spec/views/plantings/index.rss.haml_spec.rb | 2 +- spec/views/posts/_single.html.haml_spec.rb | 4 +- spec/views/posts/edit.html.haml_spec.rb | 2 +- spec/views/posts/show.html.haml_spec.rb | 2 +- spec/views/seeds/index.rss.haml_spec.rb | 4 +- 82 files changed, 177 insertions(+), 371 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 24a74057f..72007840e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -610,31 +610,6 @@ Style/EmptyLiteral: Exclude: - 'app/models/member.rb' -# Offense count: 23 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. -Style/ExtraSpacing: - Exclude: - - 'app/controllers/harvests_controller.rb' - - 'app/controllers/seeds_controller.rb' - - 'app/models/ability.rb' - - 'app/models/crop.rb' - - 'app/models/member.rb' - - 'app/models/post.rb' - - 'bin/rails' - - 'config.ru' - - 'config/environments/test.rb' - - 'db/migrate/20150201052245_create_cms.rb' - - 'script/rails' - - 'spec/features/crops/browse_crops_spec.rb' - - 'spec/lib/actions/oauth_signup_action_spec.rb' - - 'spec/models/planting_spec.rb' - - 'spec/models/role_spec.rb' - - 'spec/views/crops/_planting_advice.html.haml_spec.rb' - - 'spec/views/devise/shared/_links_spec.rb' - - 'spec/views/gardens/show.html.haml_spec.rb' - - 'spec/views/photos/new.html.haml_spec.rb' - # Offense count: 1 # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: for, each @@ -714,16 +689,6 @@ Style/Lambda: - 'spec/controllers/member_controller_spec.rb' - 'spec/models/photo_spec.rb' -# Offense count: 6 -# Cop supports --auto-correct. -Style/LeadingCommentSpace: - Exclude: - - 'app/controllers/application_controller.rb' - - 'app/controllers/omniauth_callbacks_controller.rb' - - 'app/controllers/plantings_controller.rb' - - 'app/controllers/posts_controller.rb' - - 'app/controllers/seeds_controller.rb' - - 'spec/factories/crop.rb' # Offense count: 3 # Cop supports --auto-correct. @@ -1032,166 +997,6 @@ Style/SelfAssignment: Exclude: - 'app/helpers/crops_helper.rb' -# Offense count: 20 -# Cop supports --auto-correct. -Style/SpaceAfterComma: - Exclude: - - 'app/models/crop.rb' - - 'db/seeds.rb' - - 'lib/actions/oauth_signup_action.rb' - - 'spec/models/harvest_spec.rb' - - 'spec/rails_helper.rb' - -# Offense count: 6 -# Cop supports --auto-correct. -Style/SpaceAfterNot: - Exclude: - - 'app/helpers/harvests_helper.rb' - - 'app/models/crop.rb' - - 'app/models/garden.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleInsidePipes, SupportedStyles. -# SupportedStyles: space, no_space -Style/SpaceAroundBlockParameters: - Exclude: - - 'spec/custom_matchers.rb' - -# Offense count: 14 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: space, no_space -Style/SpaceAroundEqualsInParameterDefault: - Exclude: - - 'app/helpers/application_helper.rb' - - 'app/helpers/auto_suggest_helper.rb' - - 'app/models/crop.rb' - - 'app/models/member.rb' - - 'app/models/order.rb' - - 'app/models/planting.rb' - - 'spec/lib/haml/filters/growstuff_markdown_spec.rb' - - 'spec/support/controller_macros.rb' - - 'spec/support/feature_helpers.rb' - -# Offense count: 13 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Style/SpaceAroundOperators: - Exclude: - - 'app/controllers/harvests_controller.rb' - - 'app/controllers/seeds_controller.rb' - - 'app/models/planting.rb' - - 'app/models/post.rb' - - 'config/environments/test.rb' - - 'db/seeds.rb' - - 'spec/views/crops/_planting_advice.html.haml_spec.rb' - - 'spec/views/gardens/show.html.haml_spec.rb' - - 'spec/views/harvests/index.html.haml_spec.rb' - - 'spec/views/plantings/index.html.haml_spec.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: space, no_space -Style/SpaceBeforeBlockBraces: - Exclude: - - 'app/models/crop.rb' - - 'app/models/post.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Style/SpaceBeforeComma: - Exclude: - - 'spec/controllers/member_controller_spec.rb' - -# Offense count: 16 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -Style/SpaceInsideBlockBraces: - Exclude: - - 'app/helpers/crops_helper.rb' - - 'app/models/crop.rb' - - 'app/models/member.rb' - - 'app/models/post.rb' - - 'spec/factories/member.rb' - - 'spec/rails_helper.rb' - - 'spec/support/elasticsearch_helpers.rb' - - 'spec/views/notifications/new.html.haml_spec.rb' - -# Offense count: 43 -# Cop supports --auto-correct. -Style/SpaceInsideBrackets: - Exclude: - - 'app/models/crop.rb' - - 'config/initializers/devise.rb' - - 'spec/controllers/member_controller_spec.rb' - - 'spec/factories/member.rb' - - 'spec/models/crop_spec.rb' - - 'spec/models/member_spec.rb' - - 'spec/views/crops/index.html.haml_spec.rb' - - 'spec/views/crops/wrangle.html.haml_spec.rb' - - 'spec/views/forums/index.html.haml_spec.rb' - - 'spec/views/members/index.html.haml_spec.rb' - - 'spec/views/notifications/index.html.haml_spec.rb' - - 'spec/views/orders/index.html.haml_spec.rb' - - 'spec/views/plantings/index.rss.haml_spec.rb' - - 'spec/views/seeds/index.rss.haml_spec.rb' - -# Offense count: 137 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. -# SupportedStyles: space, no_space, compact -Style/SpaceInsideHashLiteralBraces: - Exclude: - - 'app/controllers/admin/orders_controller.rb' - - 'app/controllers/crops_controller.rb' - - 'app/models/crop.rb' - - 'app/models/harvest.rb' - - 'app/models/member.rb' - - 'app/models/planting.rb' - - 'app/models/seed.rb' - - 'db/migrate/20150201052245_create_cms.rb' - - 'lib/geocodable.rb' - - 'spec/controllers/admin/orders_controller_spec.rb' - - 'spec/controllers/comments_controller_spec.rb' - - 'spec/controllers/gardens_controller_spec.rb' - - 'spec/controllers/harvests_controller_spec.rb' - - 'spec/controllers/member_controller_spec.rb' - - 'spec/controllers/notifications_controller_spec.rb' - - 'spec/controllers/order_items_controller_spec.rb' - - 'spec/controllers/orders_controller_spec.rb' - - 'spec/controllers/plantings_controller_spec.rb' - - 'spec/controllers/seeds_controller_spec.rb' - - 'spec/views/notifications/show.html.haml_spec.rb' - - 'spec/views/photos/new.html.haml_spec.rb' - - 'spec/views/posts/_single.html.haml_spec.rb' - - 'spec/views/posts/show.html.haml_spec.rb' - -# Offense count: 5 -# Cop supports --auto-correct. -Style/SpaceInsideParens: - Exclude: - - 'app/models/crop.rb' - - 'config/environments/test.rb' - - 'spec/lib/haml/filters/growstuff_markdown_spec.rb' - - 'spec/views/posts/edit.html.haml_spec.rb' - -# Offense count: 12 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: space, no_space -Style/SpaceInsideStringInterpolation: - Exclude: - - 'app/controllers/follows_controller.rb' - - 'app/controllers/robots_controller.rb' - - 'spec/controllers/robots_controller_spec.rb' - - 'spec/features/crops/crop_detail_page_spec.rb' - - 'spec/features/rss/plantings_spec.rb' - - 'spec/features/rss/posts_spec.rb' - - 'spec/features/rss/seeds_spec.rb' - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: SupportedStyles. diff --git a/app/controllers/admin/orders_controller.rb b/app/controllers/admin/orders_controller.rb index 88b9bc611..574afc024 100644 --- a/app/controllers/admin/orders_controller.rb +++ b/app/controllers/admin/orders_controller.rb @@ -8,7 +8,7 @@ class Admin::OrdersController < ApplicationController def search authorize! :manage, :all - @orders = Order.search({by: params[:search_by], for: params[:search_text]}) + @orders = Order.search({ by: params[:search_by], for: params[:search_text] }) if @orders.empty? flash[:alert] = "Couldn't find order with #{params[:search_by]} = #{params[:search_text]}" diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9cd3fa3de..45c657b64 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -73,7 +73,7 @@ class ApplicationController < ActionController::Base :bio, :location, :latitude, :longitude, # email settings :show_email, :newsletter, :send_notification_email, :send_planting_reminder, - #update password + # update password :current_password ) end diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index 4dc5377fd..dac763665 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -11,11 +11,11 @@ class CropsController < ApplicationController @sort = params[:sort] if @sort == 'alpha' # alphabetical order - @crops = Crop.includes(:scientific_names, {plantings: :photos}) + @crops = Crop.includes(:scientific_names, { plantings: :photos }) @paginated_crops = @crops.approved.paginate(page: params[:page]) else # default to sorting by popularity - @crops = Crop.popular.includes(:scientific_names, {plantings: :photos}) + @crops = Crop.popular.includes(:scientific_names, { plantings: :photos }) @paginated_crops = @crops.approved.paginate(page: params[:page]) end @@ -77,7 +77,7 @@ class CropsController < ApplicationController # GET /crops/1 # GET /crops/1.json def show - @crop = Crop.includes(:scientific_names, {plantings: :photos}).find(params[:id]) + @crop = Crop.includes(:scientific_names, { plantings: :photos }).find(params[:id]) @posts = @crop.posts.paginate(page: params[:page]) respond_to do |format| diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index 4e62925e6..58a1ce795 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -8,7 +8,7 @@ class FollowsController < ApplicationController @follow = current_member.follows.build(followed_id: follow_params[:followed_id]) if @follow.save - flash[:notice] = "Followed #{ @follow.followed.login_name }" + flash[:notice] = "Followed #{@follow.followed.login_name}" redirect_to :back else flash[:error] = "Already following or error while following." @@ -22,7 +22,7 @@ class FollowsController < ApplicationController unfollowed_name = @follow.followed.login_name @follow.destroy - flash[:notice] = "Unfollowed #{ unfollowed_name }" + flash[:notice] = "Unfollowed #{unfollowed_name}" redirect_to root_path end diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index ad557efcd..051cb1132 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -32,7 +32,7 @@ class HarvestsController < ApplicationController @harvest = Harvest.new('harvested_at' => Date.today) # using find_by_id here because it returns nil, unlike find - @crop = Crop.find_by_id(params[:crop_id]) || Crop.new + @crop = Crop.find_by_id(params[:crop_id]) || Crop.new respond_to do |format| format.html # new.html.erb diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index f6912f55f..e89f7577a 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -28,7 +28,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController @authentication = action.establish_authentication(auth, member) unless action.member_created? - sign_in_and_redirect member, event: :authentication #this will throw if @user is not activated + sign_in_and_redirect member, event: :authentication # this will throw if @user is not activated set_flash_message(:notice, :success, kind: auth['provider']) if is_navigational_format? else raise "Invalid provider" unless ['facebook', 'twitter', 'flickr'].index(auth['provider'].to_s) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 11e9662f8..2c4589e40 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -18,7 +18,7 @@ class PlantingsController < ApplicationController respond_to do |format| format.html { @plantings = @plantings.paginate(page: params[:page]) } format.json { render json: @plantings } - format.rss { render layout: false } #index.rss.builder + format.rss { render layout: false } # index.rss.builder format.csv do specifics = (@owner ? "#{@owner.login_name}-" : @crop ? "#{@crop.name}-" : nil) @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv" diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index f1d2b62ae..48216ac87 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -16,7 +16,7 @@ class PostsController < ApplicationController respond_to do |format| format.html # index.html.haml format.json { render json: @posts } - format.rss { render layout: false } #index.rss.builder + format.rss { render layout: false } # index.rss.builder end end diff --git a/app/controllers/robots_controller.rb b/app/controllers/robots_controller.rb index 777bc9aa4..d74ffe20f 100644 --- a/app/controllers/robots_controller.rb +++ b/app/controllers/robots_controller.rb @@ -2,7 +2,7 @@ class RobotsController < ApplicationController DEFAULT_FILENAME = 'config/robots.txt'.freeze def robots - filename = "config/robots.#{ subdomain }.txt" if subdomain && subdomain != 'www' + filename = "config/robots.#{subdomain}.txt" if subdomain && subdomain != 'www' file_to_render = File.exists?(filename.to_s) ? filename : DEFAULT_FILENAME render file: file_to_render, layout: false, content_type: 'text/plain' end diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index 092dbc2ba..188855f45 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -18,7 +18,7 @@ class SeedsController < ApplicationController respond_to do |format| format.html # index.html.erb format.json { render json: @seeds } - format.rss { render layout: false } #index.rss.builder + format.rss { render layout: false } # index.rss.builder format.csv do if @owner @filename = "Growstuff-#{@owner}-Seeds-#{Time.zone.now.to_s(:number)}.csv" @@ -49,7 +49,7 @@ class SeedsController < ApplicationController @seed = Seed.new # using find_by_id here because it returns nil, unlike find - @crop = Crop.find_by_id(params[:crop_id]) || Crop.new + @crop = Crop.find_by_id(params[:crop_id]) || Crop.new respond_to do |format| format.html # new.html.erb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 60e057301..0aa552bdf 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -38,7 +38,7 @@ module ApplicationHelper end # Produces a cache key for uniquely identifying cached fragments. - def cache_key_for(klass, identifier="all") + def cache_key_for(klass, identifier = "all") count = klass.count max_updated_at = klass.maximum(:updated_at).try(:utc).try(:to_s, :number) "#{klass.name.downcase.pluralize}/#{identifier}-#{count}-#{max_updated_at}" diff --git a/app/helpers/auto_suggest_helper.rb b/app/helpers/auto_suggest_helper.rb index fb29cdfc3..a8a86de56 100644 --- a/app/helpers/auto_suggest_helper.rb +++ b/app/helpers/auto_suggest_helper.rb @@ -1,5 +1,5 @@ module AutoSuggestHelper - def auto_suggest(resource, source, options={}) + def auto_suggest(resource, source, options = {}) if options[:default] && !options[:default].new_record? default = options[:default] default_id = options[:default].try(:id) diff --git a/app/helpers/crops_helper.rb b/app/helpers/crops_helper.rb index 512efce8d..da3f72f10 100644 --- a/app/helpers/crops_helper.rb +++ b/app/helpers/crops_helper.rb @@ -2,7 +2,7 @@ module CropsHelper def display_seed_availability(member, crop) total_quantity = 0 - seeds = member.seeds.select {|seed| seed.crop.name == crop.name } + seeds = member.seeds.select { |seed| seed.crop.name == crop.name } seeds.each do |seed| total_quantity = total_quantity + seed.quantity if seed.quantity diff --git a/app/helpers/harvests_helper.rb b/app/helpers/harvests_helper.rb index 431083de3..d848d919f 100644 --- a/app/helpers/harvests_helper.rb +++ b/app/helpers/harvests_helper.rb @@ -15,10 +15,10 @@ module HarvestsHelper end def display_human_quantity(harvest) - if ! harvest.quantity.blank? && harvest.quantity > 0 + if !harvest.quantity.blank? && harvest.quantity > 0 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.blank? # pluralize anything else return pluralize(number_to_human(harvest.quantity, strip_insignificant_zeros: true), harvest.unit) else return "#{number_to_human(harvest.quantity, strip_insignificant_zeros: true)} #{harvest.unit}" @@ -29,7 +29,7 @@ module HarvestsHelper end def display_weight(harvest) - if ! harvest.weight_quantity.blank? && harvest.weight_quantity > 0 + if !harvest.weight_quantity.blank? && harvest.weight_quantity > 0 return "#{number_to_human(harvest.weight_quantity, strip_insignificant_zeros: true)} #{harvest.weight_unit}" else return nil diff --git a/app/models/ability.rb b/app/models/ability.rb index d0b9c2f56..4ce056438 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -108,7 +108,7 @@ class Ability can :cancel, Order, member_id: member.id, completed_at: nil can :destroy, Order, member_id: member.id, completed_at: nil - can :create, OrderItem + can :create, OrderItem # for now, let's not let people mess with individual order items cannot :read, OrderItem, order: { member_id: member.id } cannot :update, OrderItem, order: { member_id: member.id, completed_at: nil } diff --git a/app/models/crop.rb b/app/models/crop.rb index 0bf6916e3..47829f463 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -19,7 +19,7 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength belongs_to :parent, class_name: 'Crop' has_many :varieties, class_name: 'Crop', foreign_key: 'parent_id' has_and_belongs_to_many :posts - before_destroy {|crop| crop.posts.clear} + before_destroy { |crop| crop.posts.clear } default_scope { order("lower(name) asc") } scope :recent, lambda { @@ -31,7 +31,7 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength scope :popular, lambda { where(approval_status: "approved").reorder("plantings_count desc, lower(name) asc") } - scope :randomized, lambda { + scope :randomized, lambda { # ok on sqlite and psql, but not on mysql where(approval_status: "approved").reorder('random()') } @@ -69,12 +69,12 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength analysis: { tokenizer: { gs_edgeNGram_tokenizer: { - type: "edgeNGram", # edgeNGram: NGram match from the start of a token + type: "edgeNGram", # edgeNGram: NGram match from the start of a token min_gram: 3, max_gram: 10, # token_chars: Elasticsearch will split on characters # that don’t belong to any of these classes - token_chars: [ "letter", "digit" ] + token_chars: ["letter", "digit"] } }, analyzer: { @@ -103,7 +103,7 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength end end - def as_indexed_json(options={}) + def as_indexed_json(options = {}) self.as_json( only: [:id, :name, :approval_status], include: { @@ -210,11 +210,11 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength end def approval_statuses - [ 'rejected', 'pending', 'approved' ] + ['rejected', 'pending', 'approved'] end def reasons_for_rejection - [ "already in database", "not edible", "not enough information", "other" ] + ["already in database", "not edible", "not enough information", "other"] end # Crop.interesting @@ -239,7 +239,7 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength # - scientific name (optional, can be picked up from parent if it has one) def Crop.create_from_csv(row) - name,en_wikipedia_url,parent,scientific_names,alternate_names = row + name, en_wikipedia_url, parent, scientific_names, alternate_names = row cropbot = Member.find_by_login_name('cropbot') raise "cropbot account not found: run rake db:seed" unless cropbot @@ -265,10 +265,10 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength def add_scientific_names_from_csv(scientific_names) names_to_add = [] - if ! scientific_names.blank? # i.e. we actually passed something in, which isn't a given + if !scientific_names.blank? # i.e. we actually passed something in, which isn't a given names_to_add = scientific_names.split(%r{,\s*}) elsif parent && parent.scientific_names.size > 0 # pick up from parent - names_to_add = parent.scientific_names.map{|s| s.scientific_name} + names_to_add = parent.scientific_names.map { |s| s.scientific_name } else logger.warn("Warning: no scientific name (not even on parent crop) for #{self}") end @@ -293,7 +293,7 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength def add_alternate_names_from_csv(alternate_names) names_to_add = [] - if ! alternate_names.blank? # i.e. we actually passed something in, which isn't a given + if !alternate_names.blank? # i.e. we actually passed something in, which isn't a given cropbot = Member.find_by_login_name('cropbot') raise "cropbot account not found: run rake db:seed" unless cropbot @@ -325,7 +325,7 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength def self.search(query) if ENV['GROWSTUFF_ELASTICSEARCH'] == "true" search_str = query.nil? ? "" : query.downcase - response = __elasticsearch__.search( { + response = __elasticsearch__.search({ # Finds documents which match any field, but uses the _score from # the best field insead of adding up _score from each field. query: { @@ -338,7 +338,7 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength } }, filter: { - term: {approval_status: "approved"} + term: { approval_status: "approved" } }, size: 50 } diff --git a/app/models/garden.rb b/app/models/garden.rb index f13754946..79ebe0260 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -76,7 +76,7 @@ class Garden < ActiveRecord::Base seen_crops = [] plantings.each do |p| - if (! seen_crops.include?(p.crop)) + if (!seen_crops.include?(p.crop)) unique_plantings.push(p) seen_crops.push(p.crop) end diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 7ac418287..425ae0da9 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -22,9 +22,9 @@ class Harvest < ActiveRecord::Base validates :crop, approved: true - validates :crop, presence: {message: "must be present and exist in our database"} + validates :crop, presence: { message: "must be present and exist in our database" } - validates :plant_part, presence: {message: "must be present and exist in our database"} + validates :plant_part, presence: { message: "must be present and exist in our database" } validates :quantity, numericality: { diff --git a/app/models/member.rb b/app/models/member.rb index 4e403deb5..018860365 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -4,7 +4,7 @@ class Member < ActiveRecord::Base friendly_id :login_name, use: [:slugged, :finders] - has_many :posts, foreign_key: 'author_id' + has_many :posts, foreign_key: 'author_id' has_many :comments, foreign_key: 'author_id' has_many :forums, foreign_key: 'owner_id' @@ -79,12 +79,12 @@ class Member < ActiveRecord::Base } # Give each new member a default garden - after_create {|member| Garden.create(name: "Garden", owner_id: member.id) } + after_create { |member| Garden.create(name: "Garden", owner_id: member.id) } # and an account record (for paid accounts etc) # we use find_or_create to avoid accidentally creating a second one, # which can happen sometimes especially with FactoryGirl associations - after_create {|member| Account.find_or_create_by(member_id: member.id) } + after_create { |member| Account.find_or_create_by(member_id: member.id) } after_save :update_newsletter_subscription @@ -158,7 +158,7 @@ class Member < ActiveRecord::Base # Fetches a collection of photos from Flickr # Returns a [[page of photos], total] pair. # Total is needed for pagination. - def flickr_photos(page_num=1, set=nil) + def flickr_photos(page_num = 1, set = nil) result = false result = if set flickr.photosets.getPhotos( @@ -212,7 +212,7 @@ class Member < ActiveRecord::Base def Member.nearest_to(place) nearby_members = [] if place - latitude, longitude = Geocoder.coordinates(place, params: {limit: 1}) + latitude, longitude = Geocoder.coordinates(place, params: { limit: 1 }) if latitude && longitude nearby_members = Member.located.sort_by { |x| x.distance_from([latitude, longitude]) } end @@ -234,7 +234,7 @@ class Member < ActiveRecord::Base end end - def newsletter_subscribe(testing=false) + def newsletter_subscribe(testing = false) return true if (Rails.env.test? && !testing) gb = Gibbon::API.new res = gb.lists.subscribe({ @@ -245,7 +245,7 @@ class Member < ActiveRecord::Base }) end - def newsletter_unsubscribe(testing=false) + def newsletter_unsubscribe(testing = false) return true if (Rails.env.test? && !testing) gb = Gibbon::API.new res = gb.lists.unsubscribe({ diff --git a/app/models/order.rb b/app/models/order.rb index 9a15091d6..df8609184 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -62,7 +62,7 @@ class Order < ActiveRecord::Base # search orders (used by admin/orders) # usage: Order.search({ :by => 'member', :for => 'Skud' }) # can search by: member, order_id, paypal_token, paypal_payer_id, - def Order.search(args={}) + def Order.search(args = {}) if args[:for] case args[:by] when "member" diff --git a/app/models/planting.rb b/app/models/planting.rb index 899b13e90..8dc339687 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -32,7 +32,7 @@ class Planting < ActiveRecord::Base validates :crop, approved: true - validates :crop, presence: {message: "must be present and exist in our database"} + validates :crop, presence: { message: "must be present and exist in our database" } validates :quantity, numericality: { @@ -105,7 +105,7 @@ class Planting < ActiveRecord::Base if differences.compact.empty? nil else - differences.compact.sum/differences.compact.size + differences.compact.sum / differences.compact.size end end @@ -120,7 +120,7 @@ class Planting < ActiveRecord::Base return 0 if current_date < planted_at return 100 if days > days_before_maturity - percent = (days/days_before_maturity*100).to_i + percent = (days / days_before_maturity * 100).to_i if percent >= 100 percent = 100 @@ -132,7 +132,7 @@ class Planting < ActiveRecord::Base # return a list of interesting plantings, for the homepage etc. # we can't do this via a scope (as far as we know) so sadly we have to # do it this way. - def Planting.interesting(howmany=12, require_photo=true) + def Planting.interesting(howmany = 12, require_photo = true) interesting_plantings = [] seen_owners = Hash.new(false) # keep track of which owners we've seen already diff --git a/app/models/post.rb b/app/models/post.rb index f875c8ad8..ed4bcad73 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -5,14 +5,14 @@ class Post < ActiveRecord::Base belongs_to :forum has_many :comments, dependent: :destroy has_and_belongs_to_many :crops - before_destroy {|post| post.crops.clear} + before_destroy { |post| post.crops.clear } after_save :update_crops_posts_association # also has_many notifications, but kinda meaningless to get at them # from this direction, so we won't set up an association for now. after_create do recipients = [] - sender = self.author.id + sender = self.author.id self.body.scan(Haml::Filters::GrowstuffMarkdown::MEMBER_REGEX) do |m| # find member case-insensitively and add to list of recipients member = Member.where('lower(login_name) = ?', $1.downcase).first @@ -24,7 +24,7 @@ class Post < ActiveRecord::Base recipients << member if member && !recipients.include?(member) end # don't send notifications to yourself - recipients.map{ |r| r.id }.each do |recipient| + recipients.map { |r| r.id }.each do |recipient| if recipient != sender Notification.create( recipient_id: recipient, diff --git a/app/models/seed.rb b/app/models/seed.rb index 153b18a48..4c8a1c1c7 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -9,7 +9,7 @@ class Seed < ActiveRecord::Base validates :crop, approved: true - validates :crop, presence: {message: "must be present and exist in our database"} + validates :crop, presence: { message: "must be present and exist in our database" } validates :quantity, numericality: { only_integer: true, diff --git a/bin/rails b/bin/rails index 728cd85aa..5191e6927 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../../config/application', __FILE__) +APP_PATH = File.expand_path('../../config/application', __FILE__) require_relative '../config/boot' require 'rails/commands' diff --git a/config.ru b/config.ru index f2d9c08c2..d30ee4f18 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,4 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require ::File.expand_path('../config/environment', __FILE__) run Growstuff::Application diff --git a/config/environments/test.rb b/config/environments/test.rb index d00fecf0e..35836c90b 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -26,7 +26,7 @@ Growstuff::Application.configure do config.action_dispatch.show_exceptions = true # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false + config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the @@ -100,7 +100,7 @@ Geocoder::Lookup::Test.add_stub( ) # Unknown location -Geocoder::Lookup::Test.add_stub( "Tatooine", []) +Geocoder::Lookup::Test.add_stub("Tatooine", []) Capybara.configure do |config| config.always_include_port = true diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 3a7e49d44..ad33e335d 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -26,7 +26,7 @@ Devise.setup do |config| # session. If you need permissions, you should implement that in a before filter. # You can also supply a hash where the value is a boolean determining whether # or not authentication should be aborted when the value is not present. - config.authentication_keys = [ :login ] + config.authentication_keys = [:login] # Configure parameters from the request object used for authentication. Each entry # given should be a request method and it will automatically be passed to the @@ -38,12 +38,12 @@ Devise.setup do |config| # Configure which authentication keys should be case-insensitive. # These keys will be downcased upon creating or modifying a user and when used # to authenticate or find a user. Default is :email. - config.case_insensitive_keys = [ :email ] + config.case_insensitive_keys = [:email] # 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 = [: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 @@ -102,7 +102,7 @@ Devise.setup do |config| config.reconfirmable = true # Defines which key will be used when confirming an account - config.confirmation_keys = [ :login ] + config.confirmation_keys = [:login] # ==> Configuration for :rememberable # The time the user will be remembered without asking for credentials again. @@ -158,7 +158,7 @@ Devise.setup do |config| # ==> Configuration for :recoverable # # Defines which key will be used when recovering the password for an account - config.reset_password_keys = [ :login ] + config.reset_password_keys = [:login] # Time interval you can reset your password with a reset password key. # Don't put a too small interval or your users won't have the time to diff --git a/db/migrate/20150201052245_create_cms.rb b/db/migrate/20150201052245_create_cms.rb index a464e5b06..2a187e66f 100644 --- a/db/migrate/20150201052245_create_cms.rb +++ b/db/migrate/20150201052245_create_cms.rb @@ -2,7 +2,7 @@ class CreateCms < ActiveRecord::Migration def self.up # rubocop:disable Metrics/MethodLength text_limit = case ActiveRecord::Base.connection.adapter_name when 'PostgreSQL' - { } + {} else { limit: 16777215 } end @@ -42,7 +42,7 @@ class CreateCms < ActiveRecord::Migration t.integer :layout_id t.integer :parent_id t.integer :target_page_id - t.string :label, null: false + t.string :label, null: false t.string :slug t.string :full_path, null: false t.text :content_cache, text_limit @@ -80,7 +80,7 @@ class CreateCms < ActiveRecord::Migration # -- Files -------------------------------------------------------------- create_table :comfy_cms_files do |t| - t.integer :site_id, null: false + t.integer :site_id, null: false t.integer :block_id t.string :label, null: false t.string :file_file_name, null: false diff --git a/db/seeds.rb b/db/seeds.rb index 551dd8308..6503cde74 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -87,7 +87,7 @@ def load_test_users suburb_file.pos = 0 if suburb_file.eof? row = CSV.parse(suburb_file.readline) - suburb,country,state,latitude,longitude = row[0] + suburb, country, state, latitude, longitude = row[0] # Using 'update_column' method instead of 'update' so that # it avoids accessing Geocoding service for faster processing @user.gardens.first.update_columns(location: suburb, latitude: latitude, longitude: longitude) @@ -198,7 +198,7 @@ def load_plant_parts end def select_random_item(array) - array[rand(0..array.size-1) % array.size] + array[rand(0..array.size - 1) % array.size] end load_data diff --git a/lib/actions/oauth_signup_action.rb b/lib/actions/oauth_signup_action.rb index 533a69b64..7d4913c21 100644 --- a/lib/actions/oauth_signup_action.rb +++ b/lib/actions/oauth_signup_action.rb @@ -11,14 +11,14 @@ class Growstuff::OauthSignupAction def find_or_create_from_authorization(auth) member ||= Member.where(email: auth.info.email).first_or_create do |m| m.email = auth.info.email - m.password = Devise.friendly_token[0,20] + m.password = Devise.friendly_token[0, 20] # First, try the nickname or friendly generate from the email m.login_name = auth.info.nickname || auth.info.email.split("@").first.gsub(/[^A-Za-z]+/, '_').underscore # Do we have a collision with an existing account? Generate a 20 character long random name # so the user can update it later - m.login_name = Devise.friendly_token[0,20] if Member.where(login_name: m.login_name).any? + m.login_name = Devise.friendly_token[0, 20] if Member.where(login_name: m.login_name).any? m.preferred_avatar_uri = auth.info.image # assuming the user model has an image m.skip_confirmation! diff --git a/lib/geocodable.rb b/lib/geocodable.rb index 3e960b0de..68b137acf 100644 --- a/lib/geocodable.rb +++ b/lib/geocodable.rb @@ -8,7 +8,7 @@ module Geocodable def geocode unless self.location.blank? self.latitude, self.longitude = - Geocoder.coordinates(location, params: {limit: 1}) + Geocoder.coordinates(location, params: { limit: 1 }) end end diff --git a/script/rails b/script/rails index 8c7d72b27..9092f9f3c 100755 --- a/script/rails +++ b/script/rails @@ -2,6 +2,6 @@ # This command will automatically be run when you run "rails" # with Rails 3 gems installed from the root of your application. -APP_PATH = File.expand_path('../../config/application', __FILE__) -require File.expand_path('../../config/boot', __FILE__) +APP_PATH = File.expand_path('../../config/application', __FILE__) +require File.expand_path('../../config/boot', __FILE__) require 'rails/commands' diff --git a/spec/controllers/admin/orders_controller_spec.rb b/spec/controllers/admin/orders_controller_spec.rb index 0efdc0969..4c407c34d 100644 --- a/spec/controllers/admin/orders_controller_spec.rb +++ b/spec/controllers/admin/orders_controller_spec.rb @@ -18,13 +18,13 @@ describe Admin::OrdersController do describe "GET search" do it "assigns @orders" do order = FactoryGirl.create(:order) - get :search, {search_by: 'order_id', search_text: order.id} + get :search, { search_by: 'order_id', search_text: order.id } assigns(:orders).should eq([order]) end it "sets an error message if nothing found" do order = FactoryGirl.create(:order) - get :search, {search_by: 'order_id', search_text: 'foo'} + get :search, { search_by: 'order_id', search_text: 'foo' } flash[:alert].should match /Couldn't find order with/ end end diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index be816dfa9..01d41e7b7 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -36,14 +36,14 @@ describe CommentsController do describe "GET new" do it "picks up post from params" do post = FactoryGirl.create(:post) - get :new, {post_id: post.id} + get :new, { post_id: post.id } assigns(:post).should eq(post) end it "assigns the old comments as @comments" do post = FactoryGirl.create(:post) old_comment = FactoryGirl.create(:comment, post: post) - get :new, {post_id: post.id} + get :new, { post_id: post.id } assigns(:comments).should eq [old_comment] end @@ -58,7 +58,7 @@ describe CommentsController do post = FactoryGirl.create(:post) old_comment = FactoryGirl.create(:comment, post: post) comment = FactoryGirl.create(:comment, post: post, author: @member) - get :edit, {id: comment.to_param} + get :edit, { id: comment.to_param } assigns(:comments).should eq([comment, old_comment]) end end @@ -67,7 +67,7 @@ describe CommentsController do describe "with valid params" do it "redirects to the comment's post" do comment = Comment.create! valid_attributes - put :update, {id: comment.to_param, comment: valid_attributes} + put :update, { id: comment.to_param, comment: valid_attributes } response.should redirect_to(comment.post) end end @@ -77,7 +77,7 @@ describe CommentsController do it "redirects to the post the comment was on" do comment = Comment.create! valid_attributes post = comment.post - delete :destroy, {id: comment.to_param} + delete :destroy, { id: comment.to_param } response.should redirect_to(post) end end diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb index 3483d70c3..790e1f8be 100644 --- a/spec/controllers/gardens_controller_spec.rb +++ b/spec/controllers/gardens_controller_spec.rb @@ -17,6 +17,6 @@ describe GardensController do def valid_attributes member = FactoryGirl.create(:member) - {name: 'My Garden', owner_id: member.id } + { name: 'My Garden', owner_id: member.id } end end diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index 2eedfc2e3..b07f1c08a 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -39,19 +39,19 @@ describe HarvestsController do end it "picks up owner from params and shows owner's harvests only" do - get :index, {owner: @member1.slug} + get :index, { owner: @member1.slug } assigns(:owner).should eq @member1 assigns(:harvests).should eq [@harvest1] end it "picks up crop from params and shows the harvests for the crop only" do - get :index, {crop: @maize.name} + get :index, { crop: @maize.name } assigns(:crop).should eq @maize assigns(:harvests).should eq [@harvest2] end it "generates a csv" do - get :index, {format: "csv"} + get :index, { format: "csv" } response.status.should eq 200 end end @@ -59,7 +59,7 @@ describe HarvestsController do describe "GET show" do it "assigns the requested harvest as @harvest" do harvest = Harvest.create! valid_attributes - get :show, {id: harvest.to_param} + get :show, { id: harvest.to_param } assigns(:harvest).should eq(harvest) end end @@ -74,7 +74,7 @@ describe HarvestsController do describe "GET edit" do it "assigns the requested harvest as @harvest" do harvest = Harvest.create! valid_attributes - get :edit, {id: harvest.to_param} + get :edit, { id: harvest.to_param } assigns(:harvest).should eq(harvest) end end @@ -83,18 +83,18 @@ describe HarvestsController do describe "with valid params" do it "creates a new Harvest" do expect { - post :create, {harvest: valid_attributes} + post :create, { harvest: valid_attributes } }.to change(Harvest, :count).by(1) end it "assigns a newly created harvest as @harvest" do - post :create, {harvest: valid_attributes} + post :create, { harvest: valid_attributes } assigns(:harvest).should be_a(Harvest) assigns(:harvest).should be_persisted end it "redirects to the created harvest" do - post :create, {harvest: valid_attributes} + post :create, { harvest: valid_attributes } response.should redirect_to(Harvest.last) end end @@ -103,14 +103,14 @@ describe HarvestsController do it "assigns a newly created but unsaved harvest as @harvest" do # Trigger the behavior that occurs when invalid params are submitted Harvest.any_instance.stub(:save).and_return(false) - post :create, {harvest: { "crop_id" => "invalid value" }} + post :create, { harvest: { "crop_id" => "invalid value" } } assigns(:harvest).should be_a_new(Harvest) end it "re-renders the 'new' template" do # Trigger the behavior that occurs when invalid params are submitted Harvest.any_instance.stub(:save).and_return(false) - post :create, {harvest: { "crop_id" => "invalid value" }} + post :create, { harvest: { "crop_id" => "invalid value" } } response.should render_template("new") end end @@ -125,18 +125,18 @@ describe HarvestsController do # receives the :update message with whatever params are # submitted in the request. Harvest.any_instance.should_receive(:update).with({ "crop_id" => "1" }) - put :update, {id: harvest.to_param, harvest: { "crop_id" => "1" }} + put :update, { id: harvest.to_param, harvest: { "crop_id" => "1" } } end it "assigns the requested harvest as @harvest" do harvest = Harvest.create! valid_attributes - put :update, {id: harvest.to_param, harvest: valid_attributes} + put :update, { id: harvest.to_param, harvest: valid_attributes } assigns(:harvest).should eq(harvest) end it "redirects to the harvest" do harvest = Harvest.create! valid_attributes - put :update, {id: harvest.to_param, harvest: valid_attributes} + put :update, { id: harvest.to_param, harvest: valid_attributes } response.should redirect_to(harvest) end end @@ -146,7 +146,7 @@ describe HarvestsController do harvest = Harvest.create! valid_attributes # Trigger the behavior that occurs when invalid params are submitted Harvest.any_instance.stub(:save).and_return(false) - put :update, {id: harvest.to_param, harvest: { "crop_id" => "invalid value" }} + put :update, { id: harvest.to_param, harvest: { "crop_id" => "invalid value" } } assigns(:harvest).should eq(harvest) end @@ -154,7 +154,7 @@ describe HarvestsController do harvest = Harvest.create! valid_attributes # Trigger the behavior that occurs when invalid params are submitted Harvest.any_instance.stub(:save).and_return(false) - put :update, {id: harvest.to_param, harvest: { "crop_id" => "invalid value" }} + put :update, { id: harvest.to_param, harvest: { "crop_id" => "invalid value" } } response.should render_template("edit") end end @@ -164,13 +164,13 @@ describe HarvestsController do it "destroys the requested harvest" do harvest = Harvest.create! valid_attributes expect { - delete :destroy, {id: harvest.to_param} + delete :destroy, { id: harvest.to_param } }.to change(Harvest, :count).by(-1) end it "redirects to the harvests list" do harvest = Harvest.create! valid_attributes - delete :destroy, {id: harvest.to_param} + delete :destroy, { id: harvest.to_param } response.should redirect_to(harvests_url) end end diff --git a/spec/controllers/member_controller_spec.rb b/spec/controllers/member_controller_spec.rb index 58ad66c8a..735a4c825 100644 --- a/spec/controllers/member_controller_spec.rb +++ b/spec/controllers/member_controller_spec.rb @@ -15,7 +15,7 @@ require 'rails_helper' describe MembersController do before :each do @member = FactoryGirl.create(:member) - @posts = [ FactoryGirl.create(:post, author: @member) ] + @posts = [FactoryGirl.create(:post, author: @member)] @twitter_auth = FactoryGirl.create(:authentication, member: @member) @flickr_auth = FactoryGirl.create(:flickr_authentication, member: @member) end @@ -36,32 +36,32 @@ describe MembersController do describe "GET show" do it "provides JSON for member profile" do - get :show, { id: @member.id , format: 'json' } + get :show, { id: @member.id, format: 'json' } response.should be_success end it "assigns @posts with the member's posts" do - get :show, {id: @member.id} + get :show, { id: @member.id } assigns(:posts).should eq(@posts) end it "assigns @twitter_auth" do - get :show, {id: @member.id} + get :show, { id: @member.id } assigns(:twitter_auth).should eq(@twitter_auth) end it "assigns @flickr_auth" do - get :show, {id: @member.id} + get :show, { id: @member.id } assigns(:flickr_auth).should eq(@flickr_auth) end it "doesn't show completely nonsense members" do - lambda { get :show, {id: 9999} }.should raise_error(ActiveRecord::RecordNotFound) + lambda { get :show, { id: 9999 } }.should raise_error(ActiveRecord::RecordNotFound) end it "doesn't show unconfirmed members" do @member2 = FactoryGirl.create(:unconfirmed_member) - lambda { get :show, {id: @member2.id} }.should raise_error(ActiveRecord::RecordNotFound) + lambda { get :show, { id: @member2.id } }.should raise_error(ActiveRecord::RecordNotFound) end end diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index 6a6e411ad..2231edaad 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -51,14 +51,14 @@ describe NotificationsController do describe "GET show" do it "assigns the requested notification as @notification" do notification = FactoryGirl.create(:notification, recipient_id: subject.current_member.id) - get :show, {id: notification.to_param} + get :show, { id: notification.to_param } assigns(:notification).should eq(notification) end it "assigns the reply link for a post comment" do notification = FactoryGirl.create(:notification, recipient_id: subject.current_member.id) - get :show, {id: notification.to_param} + get :show, { id: notification.to_param } assigns(:reply_link).should_not be_nil assigns(:reply_link).should eq new_comment_url( post_id: notification.post.id @@ -67,7 +67,7 @@ describe NotificationsController do it "marks notifications as read" do notification = FactoryGirl.create(:notification, recipient_id: subject.current_member.id) - get :show, {id: notification.to_param} + get :show, { id: notification.to_param } # we need to fetch it from the db again, can't test against the old one n = Notification.find(notification.id) n.read.should eq true @@ -77,7 +77,7 @@ describe NotificationsController do describe "GET reply" do it "marks notifications as read" do notification = FactoryGirl.create(:notification, recipient_id: subject.current_member.id) - get :reply, {id: notification.to_param} + get :reply, { id: notification.to_param } # we need to fetch it from the db again, can't test against the old one n = Notification.find(notification.id) n.read.should eq true @@ -87,7 +87,7 @@ describe NotificationsController do describe "GET new" do it "assigns a recipient" do @recipient = FactoryGirl.create(:member) - get :new, {recipient_id: @recipient.id } + get :new, { recipient_id: @recipient.id } assigns(:recipient).should be_an_instance_of(Member) end end diff --git a/spec/controllers/order_items_controller_spec.rb b/spec/controllers/order_items_controller_spec.rb index 07e7d3e38..d455cbe9b 100644 --- a/spec/controllers/order_items_controller_spec.rb +++ b/spec/controllers/order_items_controller_spec.rb @@ -30,11 +30,11 @@ describe OrderItemsController do describe "POST create" do it "redirects to order" do @order = FactoryGirl.create(:order, member: @member) - post :create, {order_item: { + post :create, { order_item: { order_id: @order.id, product_id: @product.id, price: @product.min_price - }} + } } response.should redirect_to(OrderItem.last.order) end @@ -43,10 +43,10 @@ describe OrderItemsController do sign_in @member @product = FactoryGirl.create(:product) expect { - post :create, {order_item: { + post :create, { order_item: { product_id: @product.id, price: @product.min_price - }} + } } }.to change(Order, :count).by(1) OrderItem.last.order.should be_an_instance_of Order end @@ -56,11 +56,11 @@ describe OrderItemsController do @order = FactoryGirl.create(:order, member: @member) @product = FactoryGirl.create(:product, min_price: 1) expect { - post :create, {order_item: { + post :create, { order_item: { order_id: @order.id, product_id: @product.id, price: 3.33 - }} + } } }.to change(OrderItem, :count).by(1) OrderItem.last.price.should eq 333 end diff --git a/spec/controllers/orders_controller_spec.rb b/spec/controllers/orders_controller_spec.rb index a1dd1fce9..78bc0b99a 100644 --- a/spec/controllers/orders_controller_spec.rb +++ b/spec/controllers/orders_controller_spec.rb @@ -28,7 +28,7 @@ describe OrdersController do member = FactoryGirl.create(:member) sign_in member order = Order.create!(member_id: member.id) - get :checkout, {id: order.to_param, referral_code: 'FOOBAR'} + get :checkout, { id: order.to_param, referral_code: 'FOOBAR' } order.reload order.referral_code.should eq 'FOOBAR' end @@ -37,7 +37,7 @@ describe OrdersController do member = FactoryGirl.create(:member) sign_in member order = Order.create!(member_id: member.id) - get :checkout, {id: order.to_param} + get :checkout, { id: order.to_param } response.status.should eq 302 response.redirect_url.should match /paypal\.com/ end @@ -48,7 +48,7 @@ describe OrdersController do member = FactoryGirl.create(:member) sign_in member order = Order.create!(member_id: member.id) - get :complete, {id: order.to_param} + get :complete, { id: order.to_param } assigns(:order).should eq(order) end end @@ -58,7 +58,7 @@ describe OrdersController do member = FactoryGirl.create(:member) sign_in member order = Order.create!(member_id: member.id) - delete :destroy, {id: order.id} + delete :destroy, { id: order.id } response.should redirect_to(shop_url) end end diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index 1dc38ba72..f51086114 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -38,13 +38,13 @@ describe PlantingsController do end it "picks up owner from params and shows owner's plantings only" do - get :index, {owner: @member1.slug} + get :index, { owner: @member1.slug } assigns(:owner).should eq @member1 assigns(:plantings).should eq [@planting1] end it "picks up crop from params and shows the plantings for the crop only" do - get :index, {crop: @maize.name} + get :index, { crop: @maize.name } assigns(:crop).should eq @maize assigns(:plantings).should eq [@planting2] end @@ -53,7 +53,7 @@ describe PlantingsController do describe "GET new" do it "picks up crop from params" do crop = FactoryGirl.create(:crop) - get :new, {crop_id: crop.id} + get :new, { crop_id: crop.id } assigns(:crop).should eq(crop) end @@ -65,7 +65,7 @@ describe PlantingsController do it "picks up garden from params" do member = FactoryGirl.create(:member) garden = FactoryGirl.create(:garden, owner: member) - get :new, {garden_id: garden.id} + get :new, { garden_id: garden.id } assigns(:garden).should eq(garden) end diff --git a/spec/controllers/robots_controller_spec.rb b/spec/controllers/robots_controller_spec.rb index 16220cfe2..e8917aa29 100644 --- a/spec/controllers/robots_controller_spec.rb +++ b/spec/controllers/robots_controller_spec.rb @@ -6,7 +6,7 @@ describe RobotsController do let(:staging_filename) { 'config/robots.staging.txt' } before do - @request.host = "#{ subdomain }.localhost.com" + @request.host = "#{subdomain}.localhost.com" end context 'subdomain is staging' do diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb index e79160dfd..b17a948c4 100644 --- a/spec/controllers/seeds_controller_spec.rb +++ b/spec/controllers/seeds_controller_spec.rb @@ -16,7 +16,7 @@ describe SeedsController do describe "GET index" do it "picks up owner from params" do owner = FactoryGirl.create(:member) - get :index, {owner: owner.slug} + get :index, { owner: owner.slug } assigns(:owner).should eq(owner) end end diff --git a/spec/custom_matchers.rb b/spec/custom_matchers.rb index 6d52388bb..1cb9d61ab 100644 --- a/spec/custom_matchers.rb +++ b/spec/custom_matchers.rb @@ -1,6 +1,6 @@ require 'rspec/expectations' -RSpec::Matchers.define :have_optional do | expected | +RSpec::Matchers.define :have_optional do |expected| match do |actual| actual.has_selector? "#{expected} + span", text: '(Optional)' end diff --git a/spec/factories/crop.rb b/spec/factories/crop.rb index c4d73f9d1..6467cb813 100644 --- a/spec/factories/crop.rb +++ b/spec/factories/crop.rb @@ -58,7 +58,7 @@ FactoryGirl.define do creator "cropbot" end - #for testing crop request + # for testing crop request factory :crop_request do name "Ultra berry" en_wikipedia_url "" diff --git a/spec/factories/member.rb b/spec/factories/member.rb index 76493d773..7fb02594b 100644 --- a/spec/factories/member.rb +++ b/spec/factories/member.rb @@ -60,12 +60,12 @@ FactoryGirl.define do end factory :admin_member do - roles { [ FactoryGirl.create(:admin) ] } + roles { [FactoryGirl.create(:admin)] } end factory :crop_wrangling_member do - roles { [ FactoryGirl.create(:crop_wrangler) ] } - sequence(:login_name) {|n| "wrangler#{n}"} + roles { [FactoryGirl.create(:crop_wrangler)] } + sequence(:login_name) { |n| "wrangler#{n}" } end factory :invalid_member_shortname do diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb index c486d3963..72e63c8fd 100644 --- a/spec/features/crops/browse_crops_spec.rb +++ b/spec/features/crops/browse_crops_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' feature "browse crops" do let(:tomato) { create :tomato } let(:maize) { create :maize } - let(:pending_crop) { create :crop_request } + let(:pending_crop) { create :crop_request } let(:rejected_crop) { create :rejected_crop } scenario "has a form for sorting by" do diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index e80e235ad..cf2d3f502 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -111,23 +111,23 @@ feature "crop detail page", js: true do background { subject } scenario "has seed heading with SEO" do - expect(page).to have_content "Find #{ crop.name } seeds" + expect(page).to have_content "Find #{crop.name} seeds" end scenario "has harvest heading with SEO" do - expect(page).to have_content "#{ crop.name.capitalize } harvests" + expect(page).to have_content "#{crop.name.capitalize} harvests" end scenario "has planting heading with SEO" do - expect(page).to have_content "See who's planted #{ crop.name.pluralize }" + expect(page).to have_content "See who's planted #{crop.name.pluralize}" end scenario "has planting advice with SEO" do - expect(page).to have_content "How to grow #{ crop.name }" + expect(page).to have_content "How to grow #{crop.name}" end scenario "has a link to Wikipedia with SEO" do - expect(page).to have_content "Learn more about #{ crop.name }" + expect(page).to have_content "Learn more about #{crop.name}" expect(page).to have_link "Wikipedia (English)", href: crop.en_wikipedia_url end diff --git a/spec/features/rss/plantings_spec.rb b/spec/features/rss/plantings_spec.rb index 597d82c01..59833eff1 100644 --- a/spec/features/rss/plantings_spec.rb +++ b/spec/features/rss/plantings_spec.rb @@ -9,6 +9,6 @@ feature 'Plantings RSS feed' do scenario 'The index title is what we expect' do visit plantings_path(format: 'rss') expect(page).to have_content "Recent plantings from "\ - "#{ @owner ? @owner : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})" + "#{@owner ? @owner : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" end end diff --git a/spec/features/rss/posts_spec.rb b/spec/features/rss/posts_spec.rb index 8c48ad5d2..445a50cca 100644 --- a/spec/features/rss/posts_spec.rb +++ b/spec/features/rss/posts_spec.rb @@ -9,6 +9,6 @@ feature 'Posts RSS feed' do scenario 'The index title is what we expect' do visit posts_path(format: 'rss') expect(page).to have_content "Recent posts from "\ - "#{ @author ? @author : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})" + "#{@author ? @author : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" end end diff --git a/spec/features/rss/seeds_spec.rb b/spec/features/rss/seeds_spec.rb index 0d3957f19..888cc42ec 100644 --- a/spec/features/rss/seeds_spec.rb +++ b/spec/features/rss/seeds_spec.rb @@ -9,6 +9,6 @@ feature 'Seeds RSS feed' do scenario 'The index title is what we expect' do visit seeds_path(format: 'rss') expect(page).to have_content "Recent seeds from "\ - "#{ @owner ? @owner : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})" + "#{@owner ? @owner : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" end end diff --git a/spec/lib/actions/oauth_signup_action_spec.rb b/spec/lib/actions/oauth_signup_action_spec.rb index 57dd28af4..4bb4f74bb 100644 --- a/spec/lib/actions/oauth_signup_action_spec.rb +++ b/spec/lib/actions/oauth_signup_action_spec.rb @@ -28,7 +28,7 @@ describe 'Growstuff::OauthSignupAction' do before :each do @auth['info']['email'] = 'no.existing.user@gmail.com' - Member.where(email: @auth['info']['email']).delete_all + Member.where(email: @auth['info']['email']).delete_all @member = @action.find_or_create_from_authorization(@auth) @authentication = @action.establish_authentication(@auth, @member) diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb index ecefbadd2..debce3111 100644 --- a/spec/lib/haml/filters/growstuff_markdown_spec.rb +++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb @@ -6,7 +6,7 @@ def input_link(name) return "[#{name}](crop)" end -def output_link(crop, name=nil) +def output_link(crop, name = nil) url = Rails.application.routes.url_helpers.crop_url(crop, host: Growstuff::Application.config.host) if name return "#{name}" @@ -19,7 +19,7 @@ def input_member_link(name) return "[#{name}](member)" end -def output_member_link(member, name=nil) +def output_member_link(member, name = nil) url = Rails.application.routes.url_helpers.member_url(member, only_path: true) if name return "#{name}" @@ -47,7 +47,7 @@ describe 'Haml::Filters::Growstuff_Markdown' do it "doesn't convert escaped crop links" do @crop = FactoryGirl.create(:crop) - rendered = Haml::Filters::GrowstuffMarkdown.render( "\\" << input_link(@crop.name)) + rendered = Haml::Filters::GrowstuffMarkdown.render("\\" << input_link(@crop.name)) rendered.should match /\[#{@crop.name}\]\(crop\)/ end diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index fbde31504..b497b6222 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -100,7 +100,7 @@ describe Crop do it 'toplevel scope works' do @tomato = FactoryGirl.create(:tomato) @roma = FactoryGirl.create(:roma, parent_id: @tomato.id) - Crop.toplevel.should eq [ @tomato ] + Crop.toplevel.should eq [@tomato] end end diff --git a/spec/models/harvest_spec.rb b/spec/models/harvest_spec.rb index f4ef03c04..a3aedddf2 100644 --- a/spec/models/harvest_spec.rb +++ b/spec/models/harvest_spec.rb @@ -45,7 +45,8 @@ describe Harvest do context 'units' do it 'all valid units should work' do - ['individual','bunch','sprig','handful','litre','pint','quart','bucket','basket','bushel', nil, ''].each do |s| + ['individual', 'bunch', 'sprig', 'handful', 'litre', + 'pint', 'quart', 'bucket', 'basket', 'bushel', nil, ''].each do |s| @harvest = FactoryGirl.build(:harvest, unit: s) @harvest.should be_valid end diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index e3dc5d2f0..cc6281fc4 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -275,7 +275,7 @@ describe 'member' do @member2.updated_at = 2.days.ago @member3.updated_at = 1.days.ago - Member.interesting.should eq [ @member3, @member2, @member1 ] + Member.interesting.should eq [@member3, @member2, @member1] end end diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index e4a5f11b7..327379fc3 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -300,7 +300,7 @@ describe Planting do context "finished date validation" do it 'requires finished date after planting date' do - @f = FactoryGirl.build(:finished_planting, planted_at: '2014-01-01', finished_at: '2013-01-01') + @f = FactoryGirl.build(:finished_planting, planted_at: '2014-01-01', finished_at: '2013-01-01') @f.should_not be_valid end diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb index 6ea5d1a9d..f8393ae84 100644 --- a/spec/models/role_spec.rb +++ b/spec/models/role_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe Role do - let(:member) { FactoryGirl.create(:member) } + let(:member) { FactoryGirl.create(:member) } subject do role = FactoryGirl.create(:role, name: 'Crop Wrangler') diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 5ec7f100a..cdfb951cb 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.gsub(' ', '-').gsub(/^.*\/spec\//, '')}" end Capybara.app_host = 'http://localhost' @@ -59,7 +59,7 @@ include Warden::Test::Helpers # require only the support files necessary. # Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } -Dir[Rails.root.join("spec/features/shared_examples/**/*.rb")].each {|f| require f} +Dir[Rails.root.join("spec/features/shared_examples/**/*.rb")].each { |f| require f } # Checks for pending migrations before tests are run. # If you are not using ActiveRecord, you can remove this line. diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb index ce2e124fd..393d7221b 100644 --- a/spec/support/controller_macros.rb +++ b/spec/support/controller_macros.rb @@ -1,6 +1,6 @@ # Taken unashamedly from https://github.com/plataformatec/devise/wiki/How-To%3a-Controllers-and-Views-tests-with-Rails-3-%28and-rspec%29 module ControllerMacros - def login_member(member_factory=:member) + def login_member(member_factory = :member) let(:member) { member = FactoryGirl.create(member_factory || :member) } before(:each) do @request.env["devise.mapping"] = Devise.mappings[:member] diff --git a/spec/support/elasticsearch_helpers.rb b/spec/support/elasticsearch_helpers.rb index 94cf447ff..1d1db1db3 100644 --- a/spec/support/elasticsearch_helpers.rb +++ b/spec/support/elasticsearch_helpers.rb @@ -1,7 +1,7 @@ module ElasticsearchHelpers def sync_elasticsearch(crops) if ENV['GROWSTUFF_ELASTICSEARCH'] == "true" - crops.each {|crop| crop.__elasticsearch__.index_document} + crops.each { |crop| crop.__elasticsearch__.index_document } Crop.__elasticsearch__.refresh_index! end end diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index f3562b07c..dbe4f327b 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -1,5 +1,5 @@ module FeatureHelpers - def fill_autocomplete(field, options={}) + def fill_autocomplete(field, options = {}) fill_in field, with: options[:with] page.execute_script %Q{ $('##{field}').trigger('focus'); } diff --git a/spec/views/crops/_planting_advice.html.haml_spec.rb b/spec/views/crops/_planting_advice.html.haml_spec.rb index 1c0390e23..62d85bcfa 100644 --- a/spec/views/crops/_planting_advice.html.haml_spec.rb +++ b/spec/views/crops/_planting_advice.html.haml_spec.rb @@ -14,7 +14,7 @@ require 'rails_helper' describe "crops/_planting_advice" do before(:each) do - @owner = FactoryGirl.create(:member) + @owner = FactoryGirl.create(:member) @crop = FactoryGirl.create(:crop) @garden = FactoryGirl.create(:garden, owner: @owner) @planting = FactoryGirl.create(:planting, diff --git a/spec/views/crops/index.html.haml_spec.rb b/spec/views/crops/index.html.haml_spec.rb index 7b5f27805..a11cbcb76 100644 --- a/spec/views/crops/index.html.haml_spec.rb +++ b/spec/views/crops/index.html.haml_spec.rb @@ -22,7 +22,7 @@ describe "crops/index" do @maize = FactoryGirl.create(:maize) assign(:crops, [@tomato, @maize]) paginated_crops = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| - pager.replace([ @tomato, @maize ]) + pager.replace([@tomato, @maize]) end assign(:paginated_crops, paginated_crops) end diff --git a/spec/views/crops/wrangle.html.haml_spec.rb b/spec/views/crops/wrangle.html.haml_spec.rb index d2eb584bb..b0ff06281 100644 --- a/spec/views/crops/wrangle.html.haml_spec.rb +++ b/spec/views/crops/wrangle.html.haml_spec.rb @@ -22,7 +22,7 @@ describe "crops/wrangle" do @tomato = FactoryGirl.create(:tomato) @maize = FactoryGirl.create(:maize) crops = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| - pager.replace([ @tomato, @maize ]) + pager.replace([@tomato, @maize]) end assign(:crops, crops) assign(:crop_wranglers, Role.crop_wranglers) diff --git a/spec/views/devise/shared/_links_spec.rb b/spec/views/devise/shared/_links_spec.rb index d40a84d88..c567339d6 100644 --- a/spec/views/devise/shared/_links_spec.rb +++ b/spec/views/devise/shared/_links_spec.rb @@ -12,14 +12,14 @@ describe 'devise/shared/_links.haml', type: "view" do it 'should have a sign-in link if not in sessions' do @view.stub(:controller_name).and_return("anything but sessions") @view.stub(:resource_name).and_return("member") - @view.stub(devise_mapping: devise_mapping(false, false, false, false, false)) + @view.stub(devise_mapping: devise_mapping(false, false, false, false, false)) render end it "shouldn't have a sign-in link if in sessions" do @view.stub(:controller_name).and_return("sessions") @view.stub(:resource_name).and_return("member") - @view.stub(devise_mapping: devise_mapping(false, false, false, false, false)) + @view.stub(devise_mapping: devise_mapping(false, false, false, false, false)) render end end diff --git a/spec/views/forums/index.html.haml_spec.rb b/spec/views/forums/index.html.haml_spec.rb index 7fc1a6574..701504d7f 100644 --- a/spec/views/forums/index.html.haml_spec.rb +++ b/spec/views/forums/index.html.haml_spec.rb @@ -18,7 +18,7 @@ describe "forums/index" do controller.stub(:current_user) { @admin } @forum1 = FactoryGirl.create(:forum) @forum2 = FactoryGirl.create(:forum) - assign(:forums, [ @forum1, @forum2 ]) + assign(:forums, [@forum1, @forum2]) end it "renders a list of forums" do diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index d4f9eb38b..0e166e453 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -14,7 +14,7 @@ require 'rails_helper' describe "gardens/show" do before(:each) do - @owner = FactoryGirl.create(:member) + @owner = FactoryGirl.create(:member) controller.stub(:current_user) { @owner } @garden = FactoryGirl.create(:garden, owner: @owner) @planting = FactoryGirl.create(:planting, garden: @garden) diff --git a/spec/views/harvests/index.html.haml_spec.rb b/spec/views/harvests/index.html.haml_spec.rb index cc24f1591..32baadc1a 100644 --- a/spec/views/harvests/index.html.haml_spec.rb +++ b/spec/views/harvests/index.html.haml_spec.rb @@ -15,7 +15,7 @@ require 'rails_helper' describe "harvests/index" do before(:each) do controller.stub(:current_user) { nil } - @member = FactoryGirl.create(:member) + @member = FactoryGirl.create(:member) @tomato = FactoryGirl.create(:tomato) @maize = FactoryGirl.create(:maize) @pp = FactoryGirl.create(:plant_part) diff --git a/spec/views/members/index.html.haml_spec.rb b/spec/views/members/index.html.haml_spec.rb index b54c9f4bb..122b88b48 100644 --- a/spec/views/members/index.html.haml_spec.rb +++ b/spec/views/members/index.html.haml_spec.rb @@ -20,7 +20,7 @@ describe "members/index" do total_entries = 2 @member = FactoryGirl.create(:london_member) members = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| - pager.replace([ @member, @member ]) + pager.replace([@member, @member]) end assign(:members, members) render diff --git a/spec/views/notifications/index.html.haml_spec.rb b/spec/views/notifications/index.html.haml_spec.rb index 2331215e2..5e0f95beb 100644 --- a/spec/views/notifications/index.html.haml_spec.rb +++ b/spec/views/notifications/index.html.haml_spec.rb @@ -22,7 +22,7 @@ describe "notifications/index" do before(:each) do @notification = FactoryGirl.create(:notification, sender: @member, recipient: @member) - assign(:notifications, Kaminari.paginate_array([ @notification, @notification ]).page(1)) + assign(:notifications, Kaminari.paginate_array([@notification, @notification]).page(1)) render end diff --git a/spec/views/notifications/new.html.haml_spec.rb b/spec/views/notifications/new.html.haml_spec.rb index f3538efdc..a5daa64f5 100644 --- a/spec/views/notifications/new.html.haml_spec.rb +++ b/spec/views/notifications/new.html.haml_spec.rb @@ -18,7 +18,7 @@ describe "notifications/new" do @sender = FactoryGirl.create(:member) assign(:notification, FactoryGirl.create(:notification, recipient_id: @recipient.id, sender_id: @sender.id)) sign_in @sender - controller.stub(:current_user) { @sender} + controller.stub(:current_user) { @sender } end it "renders new message form" do diff --git a/spec/views/notifications/show.html.haml_spec.rb b/spec/views/notifications/show.html.haml_spec.rb index 4d59495fa..4d5a71dfc 100644 --- a/spec/views/notifications/show.html.haml_spec.rb +++ b/spec/views/notifications/show.html.haml_spec.rb @@ -32,6 +32,6 @@ describe "notifications/show" do end it "includes a reply button" do - assert_select "a", {href: @reply_link}, "Reply" + assert_select "a", { href: @reply_link }, "Reply" end end diff --git a/spec/views/orders/index.html.haml_spec.rb b/spec/views/orders/index.html.haml_spec.rb index 182542cc5..38ab39362 100644 --- a/spec/views/orders/index.html.haml_spec.rb +++ b/spec/views/orders/index.html.haml_spec.rb @@ -18,7 +18,7 @@ describe "orders/index" do sign_in @member @order1 = FactoryGirl.create(:order, member: @member) @order2 = FactoryGirl.create(:completed_order, member: @member) - assign(:orders, [ @order1, @order2 ]) + assign(:orders, [@order1, @order2]) end it "shows your current account status" do diff --git a/spec/views/photos/new.html.haml_spec.rb b/spec/views/photos/new.html.haml_spec.rb index 0b19ba81b..dab06e8b0 100644 --- a/spec/views/photos/new.html.haml_spec.rb +++ b/spec/views/photos/new.html.haml_spec.rb @@ -35,7 +35,7 @@ describe "photos/new" do context "user has photosets" do before(:each) do - assign(:sets, {"foo" => "bar"}) # Hash of names => IDs + assign(:sets, { "foo" => "bar" }) # Hash of names => IDs end it "shows a dropdown with sets from Flickr" do @@ -44,7 +44,7 @@ describe "photos/new" do end it "shows the current photoset" do - assign(:current_set, "bar") # the ID of the set + assign(:current_set, "bar") # the ID of the set render assert_select "h2", "foo" # the name of the set end diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index 63b612297..54f2bb63a 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -15,7 +15,7 @@ require 'rails_helper' describe "plantings/index" do before(:each) do controller.stub(:current_user) { nil } - @member = FactoryGirl.create(:member) + @member = FactoryGirl.create(:member) @garden = FactoryGirl.create(:garden, owner: @member) @tomato = FactoryGirl.create(:tomato) @maize = FactoryGirl.create(:maize) diff --git a/spec/views/plantings/index.rss.haml_spec.rb b/spec/views/plantings/index.rss.haml_spec.rb index 9d7933ef6..58a4a2996 100644 --- a/spec/views/plantings/index.rss.haml_spec.rb +++ b/spec/views/plantings/index.rss.haml_spec.rb @@ -50,7 +50,7 @@ describe 'plantings/index.rss.haml' do context "one person's plantings" do before :each do @planting = FactoryGirl.create(:planting) - assign(:plantings, [@planting ]) + assign(:plantings, [@planting]) assign(:owner, @planting.owner) render end diff --git a/spec/views/posts/_single.html.haml_spec.rb b/spec/views/posts/_single.html.haml_spec.rb index 49830a45a..656a4194b 100644 --- a/spec/views/posts/_single.html.haml_spec.rb +++ b/spec/views/posts/_single.html.haml_spec.rb @@ -32,7 +32,7 @@ describe "posts/_single" do end it "doesn't contain a link to new comment" do - assert_select("a", {href: new_comment_path(post_id: @post.id)}, false) + assert_select("a", { href: new_comment_path(post_id: @post.id) }, false) end end @@ -45,7 +45,7 @@ describe "posts/_single" do end it "contains link to new comment" do - assert_select("a", {href: new_comment_path(post_id: @post.id)}, "Reply") + assert_select("a", { href: new_comment_path(post_id: @post.id) }, "Reply") end it "does not contain an edit link" do diff --git a/spec/views/posts/edit.html.haml_spec.rb b/spec/views/posts/edit.html.haml_spec.rb index 00b063d4a..d3342f5b9 100644 --- a/spec/views/posts/edit.html.haml_spec.rb +++ b/spec/views/posts/edit.html.haml_spec.rb @@ -43,7 +43,7 @@ describe "posts/edit" do context "forum specified" do before(:each) do @forum = assign(:forum, FactoryGirl.create(:forum)) - assign(:post, FactoryGirl.create( :post, + assign(:post, FactoryGirl.create(:post, forum: @forum, author: @author )) diff --git a/spec/views/posts/show.html.haml_spec.rb b/spec/views/posts/show.html.haml_spec.rb index 11ac223ad..9564e7ee8 100644 --- a/spec/views/posts/show.html.haml_spec.rb +++ b/spec/views/posts/show.html.haml_spec.rb @@ -114,7 +114,7 @@ describe "posts/show" do end it 'shows a comment button' do - assert_select "a", {href: new_comment_path(post_id: @post.id)}, "Comment" + assert_select "a", { href: new_comment_path(post_id: @post.id) }, "Comment" end end end diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb index b2634d6b8..2de2fff1f 100644 --- a/spec/views/seeds/index.rss.haml_spec.rb +++ b/spec/views/seeds/index.rss.haml_spec.rb @@ -21,7 +21,7 @@ describe 'seeds/index.rss.haml' do before(:each) do @seed = FactoryGirl.create(:seed) @tradable = FactoryGirl.create(:tradable_seed) - assign(:seeds, [ @seed, @tradable ]) + assign(:seeds, [@seed, @tradable]) render end @@ -49,7 +49,7 @@ describe 'seeds/index.rss.haml' do context "one member's seeds" do before(:each) do @seed = FactoryGirl.create(:seed) - assign(:seeds, [ @seed ]) + assign(:seeds, [@seed]) assign(:owner, @seed.owner) render end