From 4b4e0cf69ac3216efe2d2f990c5668e39faefa27 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Thu, 14 Apr 2016 10:06:02 +0930 Subject: [PATCH] $ rubocop --only HashSyntax --auto-correct 483 files inspected, 2018 offenses detected, 2018 offenses corrected --- app/controllers/admin/orders_controller.rb | 2 +- app/controllers/alternate_names_controller.rb | 2 +- app/controllers/application_controller.rb | 2 +- app/controllers/authentications_controller.rb | 12 +- app/controllers/comments_controller.rb | 8 +- app/controllers/crops_controller.rb | 34 ++--- app/controllers/follows_controller.rb | 4 +- app/controllers/gardens_controller.rb | 8 +- app/controllers/harvests_controller.rb | 6 +- app/controllers/members_controller.rb | 20 +-- app/controllers/order_items_controller.rb | 2 +- app/controllers/orders_controller.rb | 22 +-- app/controllers/photos_controller.rb | 4 +- app/controllers/places_controller.rb | 4 +- app/controllers/plantings_controller.rb | 14 +- app/controllers/posts_controller.rb | 14 +- app/controllers/registrations_controller.rb | 2 +- .../scientific_names_controller.rb | 2 +- app/controllers/seeds_controller.rb | 12 +- app/helpers/application_helper.rb | 6 +- app/helpers/harvests_helper.rb | 8 +- app/helpers/notifications_helper.rb | 2 +- app/mailers/notifier.rb | 14 +- app/models/ability.rb | 62 ++++---- app/models/account.rb | 4 +- app/models/alternate_name.rb | 2 +- app/models/comment.rb | 12 +- app/models/crop.rb | 58 ++++---- app/models/follow.rb | 10 +- app/models/forum.rb | 2 +- app/models/garden.rb | 34 ++--- app/models/harvest.rb | 40 ++--- app/models/member.rb | 94 ++++++------ app/models/notification.rb | 8 +- app/models/order.rb | 16 +- app/models/order_item.rb | 2 +- app/models/photo.rb | 16 +- app/models/plant_part.rb | 4 +- app/models/planting.rb | 42 +++--- app/models/post.rb | 18 +-- app/models/product.rb | 8 +- app/models/scientific_name.rb | 2 +- app/models/seed.rb | 62 ++++---- config/application.rb | 8 +- config/database.yml | 3 +- config/environments/development.rb | 18 +-- config/environments/production.rb | 20 +-- config/environments/staging.rb | 20 +-- config/environments/test.rb | 4 +- .../initializers/comfortable_mexican_sofa.rb | 2 +- config/initializers/geocoder.rb | 8 +- config/routes.rb | 12 +- .../20120903092956_devise_create_users.rb | 16 +- ...003190731_require_system_name_for_crops.rb | 4 +- db/migrate/20121105032913_create_gardens.rb | 4 +- .../20121107012827_create_scientific_names.rb | 4 +- db/migrate/20121108105440_create_updates.rb | 6 +- db/migrate/20121219022554_create_plantings.rb | 4 +- ...30208034248_require_fields_for_comments.rb | 12 +- .../20130212123628_create_notifications.rb | 2 +- db/migrate/20130213014511_create_forums.rb | 6 +- db/migrate/20130214024117_create_roles.rb | 2 +- .../20130214034838_add_members_roles_table.rb | 2 +- .../20130222060730_default_read_to_false.rb | 4 +- ...20130327120024_add_send_email_to_member.rb | 2 +- .../20130404174459_create_authentications.rb | 4 +- ...130409103549_make_post_subject_non_null.rb | 2 +- db/migrate/20130507105357_create_products.rb | 6 +- db/migrate/20130507110411_create_orders.rb | 2 +- ...0130507113915_add_orders_products_table.rb | 2 +- db/migrate/20130508104506_create_photos.rb | 8 +- .../20130509123711_add_metadata_to_photos.rb | 6 +- .../20130517015920_create_account_details.rb | 2 +- ...0130517234458_require_account_type_name.rb | 4 +- ...130531110729_add_photos_plantings_table.rb | 2 +- db/migrate/20130715110134_create_seeds.rb | 4 +- db/migrate/20130917053547_create_harvests.rb | 4 +- .../20131025104228_add_fields_to_gardens.rb | 2 +- ...8075753_default_plantings_count_to_zero.rb | 4 +- ...20140829230600_add_finished_to_planting.rb | 2 +- ...0140905001730_add_harvests_photos_table.rb | 2 +- .../20140928044231_add_crops_posts_table.rb | 2 +- ...13_add_send_planting_reminder_to_member.rb | 2 +- .../20141018111015_create_alternate_names.rb | 6 +- .../20150124110540_add_properties_to_seeds.rb | 6 +- ...20150127043022_add_gardens_photos_table.rb | 2 +- db/migrate/20150201052245_create_cms.rb | 100 ++++++------- db/seeds.rb | 78 +++++----- lib/haml/filters/growstuff_markdown.rb | 6 +- lib/tasks/growstuff.rake | 90 ++++++------ lib/tasks/hooks.rake | 2 +- lib/tasks/testing.rake | 2 +- script/heroku_maintenance.rb | 2 +- .../admin/orders_controller_spec.rb | 4 +- .../authentications_controller_spec.rb | 2 +- spec/controllers/comments_controller_spec.rb | 20 +-- spec/controllers/crops_controller_spec.rb | 8 +- spec/controllers/gardens_controller_spec.rb | 2 +- spec/controllers/harvests_controller_spec.rb | 44 +++--- spec/controllers/member_controller_spec.rb | 22 +-- .../notifications_controller_spec.rb | 20 +-- .../order_items_controller_spec.rb | 36 ++--- spec/controllers/orders_controller_spec.rb | 16 +- spec/controllers/photos_controller_spec.rb | 116 +++++++-------- spec/controllers/places_controller_spec.rb | 6 +- spec/controllers/plantings_controller_spec.rb | 20 +-- spec/controllers/posts_controller_spec.rb | 6 +- spec/controllers/products_controller_spec.rb | 6 +- .../registrations_controller_spec.rb | 4 +- .../scientific_names_controller_spec.rb | 4 +- spec/controllers/seeds_controller_spec.rb | 2 +- spec/controllers/shop_controller_spec.rb | 2 +- spec/features/admin/account_types_spec.rb | 4 +- spec/features/admin/forums_spec.rb | 4 +- spec/features/crops/alternate_name_spec.rb | 2 +- spec/features/crops/crop_detail_page_spec.rb | 4 +- spec/features/crops/crop_wranglers_spec.rb | 4 +- spec/features/footer_spec.rb | 2 +- spec/features/gardens_spec.rb | 2 +- spec/features/locale_spec.rb | 2 +- spec/features/member_profile_spec.rb | 4 +- spec/features/members_list_spec.rb | 2 +- spec/features/scientific_name_spec.rb | 2 +- spec/features/seeds/adding_seeds_spec.rb | 12 +- spec/features/seeds/misc_seeds_spec.rb | 2 +- spec/features/shared_examples/crop_suggest.rb | 2 +- spec/features/signin_spec.rb | 2 +- spec/features/signup_spec.rb | 2 +- spec/helpers/harvests_helper_spec.rb | 46 +++--- spec/helpers/notifications_helper_spec.rb | 6 +- spec/helpers/plantings_helper_spec.rb | 38 ++--- .../haml/filters/growstuff_markdown_spec.rb | 6 +- spec/models/ability_spec.rb | 26 ++-- spec/models/account_spec.rb | 2 +- spec/models/alternate_name_spec.rb | 6 +- spec/models/comment_spec.rb | 10 +- spec/models/crop_spec.rb | 138 +++++++++--------- spec/models/follow_spec.rb | 8 +- spec/models/forum_spec.rb | 8 +- spec/models/garden_spec.rb | 70 ++++----- spec/models/harvest_spec.rb | 128 ++++++++-------- spec/models/member_spec.rb | 64 ++++---- spec/models/notification_spec.rb | 10 +- spec/models/order_item_spec.rb | 6 +- spec/models/order_spec.rb | 58 ++++---- spec/models/photo_spec.rb | 2 +- spec/models/plant_part_spec.rb | 16 +- spec/models/planting_spec.rb | 43 +++--- spec/models/post_spec.rb | 56 +++---- spec/models/seed_spec.rb | 36 ++--- spec/rails_helper.rb | 4 +- spec/routing/account_types_routing_spec.rb | 8 +- spec/routing/authentications_routing_spec.rb | 2 +- spec/routing/comments_routing_spec.rb | 8 +- spec/routing/crops_routing_spec.rb | 8 +- spec/routing/follows_routing_spec.rb | 2 +- spec/routing/forums_routing_spec.rb | 8 +- spec/routing/gardens_routing_spec.rb | 8 +- spec/routing/harvests_routing_spec.rb | 8 +- spec/routing/notifications_routing_spec.rb | 8 +- spec/routing/order_items_routing_spec.rb | 8 +- spec/routing/orders_routing_spec.rb | 8 +- spec/routing/photos_routing_spec.rb | 8 +- spec/routing/plant_parts_routing_spec.rb | 8 +- spec/routing/plantings_routing_spec.rb | 8 +- spec/routing/products_routing_spec.rb | 8 +- spec/routing/roles_routing_spec.rb | 8 +- spec/routing/scientific_names_routing_spec.rb | 8 +- spec/routing/seeds_routing_spec.rb | 8 +- spec/routing/updates_routing_spec.rb | 8 +- spec/support/database_cleaner.rb | 2 +- spec/support/devise.rb | 4 +- spec/support/feature_helpers.rb | 4 +- spec/views/about/contact_spec.rb | 2 +- .../account_types/edit.html.haml_spec.rb | 14 +- .../account_types/index.html.haml_spec.rb | 2 +- .../views/account_types/new.html.haml_spec.rb | 14 +- .../account_types/show.html.haml_spec.rb | 6 +- spec/views/accounts/edit.html.haml_spec.rb | 6 +- spec/views/accounts/index.html.haml_spec.rb | 2 +- spec/views/accounts/new.html.haml_spec.rb | 6 +- spec/views/admin/index_spec.rb | 10 +- spec/views/admin/newsletter_spec.rb | 2 +- spec/views/admin/orders/index_spec.rb | 4 +- spec/views/comments/edit.html.haml_spec.rb | 4 +- spec/views/comments/index.html.haml_spec.rb | 4 +- spec/views/comments/index.rss.haml_spec.rb | 4 +- spec/views/comments/new.html.haml_spec.rb | 6 +- spec/views/crops/_grown_for.html.haml_spec.rb | 8 +- .../crops/_planting_advice.html.haml_spec.rb | 34 ++--- spec/views/crops/_popover.html.haml_spec.rb | 6 +- spec/views/crops/hierarchy.html.haml_spec.rb | 4 +- spec/views/crops/index.html.haml_spec.rb | 12 +- spec/views/crops/wrangle.html.haml_spec.rb | 6 +- spec/views/devise/confirmations/new_spec.rb | 2 +- .../mailer/confirmation_instructions_spec.rb | 2 +- .../reset_password_instructions_spec.rb | 2 +- .../devise/mailer/unlock_instructions_spec.rb | 2 +- spec/views/devise/registrations/edit_spec.rb | 18 +-- spec/views/devise/registrations/new_spec.rb | 2 +- spec/views/devise/sessions/new_spec.rb | 2 +- spec/views/devise/shared/_links_spec.rb | 18 +-- spec/views/devise/unlocks/new_spec.rb | 2 +- spec/views/forums/edit.html.haml_spec.rb | 14 +- spec/views/forums/index.html.haml_spec.rb | 8 +- spec/views/forums/new.html.haml_spec.rb | 8 +- spec/views/forums/show.html.haml_spec.rb | 4 +- spec/views/gardens/edit.html.haml_spec.rb | 16 +- spec/views/gardens/new.html.haml_spec.rb | 16 +- spec/views/gardens/show.html.haml_spec.rb | 4 +- spec/views/harvests/edit.html.haml_spec.rb | 18 +-- spec/views/harvests/index.html.haml_spec.rb | 14 +- spec/views/harvests/new.html.haml_spec.rb | 18 +-- spec/views/harvests/show.html.haml_spec.rb | 2 +- spec/views/home/_blurb.html.haml_spec.rb | 6 +- spec/views/home/_crops.html.haml_spec.rb | 12 +- spec/views/home/_members.html.haml_spec.rb | 4 +- spec/views/home/_seeds.html.haml_spec.rb | 10 +- spec/views/home/_stats.html.haml_spec.rb | 2 +- spec/views/home/index_spec.rb | 6 +- spec/views/layouts/_header_spec.rb | 14 +- spec/views/layouts/_meta_spec.rb | 8 +- spec/views/layouts/application_spec.rb | 4 +- .../views/members/_location.html.haml_spec.rb | 6 +- spec/views/members/index.html.haml_spec.rb | 2 +- spec/views/members/show.rss.haml_spec.rb | 6 +- .../notifications/index.html.haml_spec.rb | 14 +- .../views/notifications/new.html.haml_spec.rb | 14 +- .../notifications/show.html.haml_spec.rb | 2 +- spec/views/notifier/notify.html.haml_spec.rb | 8 +- spec/views/orders/index.html.haml_spec.rb | 8 +- spec/views/orders/show.html.haml_spec.rb | 24 +-- spec/views/photos/edit.html.haml_spec.rb | 8 +- spec/views/photos/index.html.haml_spec.rb | 4 +- spec/views/photos/new.html.haml_spec.rb | 2 +- spec/views/photos/show.html.haml_spec.rb | 10 +- .../places/_map_attribution.html.haml_spec.rb | 12 +- spec/views/places/show.html.haml_spec.rb | 2 +- spec/views/plant_parts/edit.html.haml_spec.rb | 6 +- .../views/plant_parts/index.html.haml_spec.rb | 2 +- spec/views/plant_parts/new.html.haml_spec.rb | 6 +- spec/views/plant_parts/show.html.haml_spec.rb | 4 +- spec/views/plantings/_form.html.haml_spec.rb | 8 +- spec/views/plantings/edit.html.haml_spec.rb | 24 +-- spec/views/plantings/index.html.haml_spec.rb | 32 ++-- spec/views/plantings/new.html.haml_spec.rb | 28 ++-- spec/views/plantings/show.html.haml_spec.rb | 8 +- spec/views/policy/community_spec.rb | 2 +- spec/views/policy/tos_spec.rb | 2 +- spec/views/posts/_single.html.haml_spec.rb | 22 +-- spec/views/posts/edit.html.haml_spec.rb | 12 +- spec/views/posts/index.html.haml_spec.rb | 16 +- spec/views/posts/index.rss.haml_spec.rb | 6 +- spec/views/posts/new.html.haml_spec.rb | 10 +- spec/views/posts/show.html.haml_spec.rb | 34 ++--- spec/views/posts/show.rss.haml_spec.rb | 4 +- spec/views/products/edit.html.haml_spec.rb | 16 +- spec/views/products/index.html.haml_spec.rb | 6 +- spec/views/products/new.html.haml_spec.rb | 20 +-- spec/views/roles/edit.html.haml_spec.rb | 10 +- spec/views/roles/index.html.haml_spec.rb | 12 +- spec/views/roles/new.html.haml_spec.rb | 10 +- spec/views/roles/show.html.haml_spec.rb | 4 +- .../scientific_names/edit.html.haml_spec.rb | 6 +- .../scientific_names/index.html.haml_spec.rb | 4 +- .../scientific_names/new.html.haml_spec.rb | 6 +- spec/views/seeds/edit.html.haml_spec.rb | 18 +-- spec/views/seeds/new.html.haml_spec.rb | 22 +-- spec/views/seeds/show.html.haml_spec.rb | 8 +- spec/views/shop/index_spec.rb | 8 +- spec/views/support/index_spec.rb | 2 +- 271 files changed, 1719 insertions(+), 1721 deletions(-) diff --git a/app/controllers/admin/orders_controller.rb b/app/controllers/admin/orders_controller.rb index e39ddc48a..c092ba7f2 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/alternate_names_controller.rb b/app/controllers/alternate_names_controller.rb index f75f8e442..35bd6f289 100644 --- a/app/controllers/alternate_names_controller.rb +++ b/app/controllers/alternate_names_controller.rb @@ -1,5 +1,5 @@ class AlternateNamesController < ApplicationController - before_filter :authenticate_member!, :except => [:index, :show] + before_filter :authenticate_member!, except: [:index, :show] load_and_authorize_resource # GET /alternate_names diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bb1d276a5..0c30ee1e1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -35,7 +35,7 @@ class ApplicationController < ActionController::Base # CanCan error handling rescue_from CanCan::AccessDenied do |exception| - redirect_to request.referer || root_url, :alert => exception.message + redirect_to request.referer || root_url, alert: exception.message end def set_locale diff --git a/app/controllers/authentications_controller.rb b/app/controllers/authentications_controller.rb index 9a873bebb..7a6ddf724 100644 --- a/app/controllers/authentications_controller.rb +++ b/app/controllers/authentications_controller.rb @@ -20,14 +20,14 @@ class AuthenticationsController < ApplicationController @authentication = current_member.authentications .create_with( - :name => name, - :token => auth['credentials']['token'], - :secret => auth['credentials']['secret'] + name: name, + token: auth['credentials']['token'], + secret: auth['credentials']['secret'] ) .find_or_create_by( - :provider => auth['provider'], - :uid => auth['uid'], - :name => name) + provider: auth['provider'], + uid: auth['uid'], + name: name) flash[:notice] = "Authentication successful." else diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 0caac18ed..1fdc8d70b 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,16 +1,16 @@ class CommentsController < ApplicationController - before_filter :authenticate_member!, :except => [:index, :show] + before_filter :authenticate_member!, except: [:index, :show] load_and_authorize_resource # GET /comments # GET /comments.json def index - @comments = Comment.paginate(:page => params[:page]) + @comments = Comment.paginate(page: params[:page]) respond_to do |format| format.html # index.html.erb format.json { render json: @comments } - format.rss { render :layout => false } + format.rss { render layout: false } end end @@ -39,7 +39,7 @@ class CommentsController < ApplicationController end else redirect_to request.referer || root_url, - :alert => "Can't post a comment on a non-existent post" + alert: "Can't post a comment on a non-existent post" end end diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index 25cfee941..6182e354c 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -1,9 +1,9 @@ require 'will_paginate/array' class CropsController < ApplicationController - before_filter :authenticate_member!, :except => [:index, :hierarchy, :search, :show] + before_filter :authenticate_member!, except: [:index, :hierarchy, :search, :show] load_and_authorize_resource - skip_authorize_resource :only => [:hierarchy, :search] + skip_authorize_resource only: [:hierarchy, :search] # GET /crops # GET /crops.json @@ -11,25 +11,25 @@ class CropsController < ApplicationController @sort = params[:sort] if @sort == 'alpha' # alphabetical order - @crops = Crop.includes(:scientific_names, {:plantings => :photos}) - @paginated_crops = @crops.approved.paginate(:page => params[:page]) + @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}) - @paginated_crops = @crops.approved.paginate(:page => params[:page]) + @crops = Crop.popular.includes(:scientific_names, {plantings: :photos}) + @paginated_crops = @crops.approved.paginate(page: params[:page]) end respond_to do |format| format.html - format.json { render :json => @crops } + format.json { render json: @crops } format.rss do @crops = Crop.recent.includes(:scientific_names, :creator) - render :rss => @crops + render rss: @crops end format.csv do @filename = "Growstuff-Crops-#{Time.zone.now.to_s(:number)}.csv" @crops = Crop.includes(:scientific_names, :plantings, :seeds, :creator) - render :csv => @crops + render csv: @crops end end end @@ -46,7 +46,7 @@ class CropsController < ApplicationController @crops = Crop.recent end - @crops = @crops.paginate(:page => params[:page]) + @crops = @crops.paginate(page: params[:page]) @crop_wranglers = Role.crop_wranglers respond_to do |format| @@ -66,25 +66,25 @@ class CropsController < ApplicationController def search @term = params[:term] @matches = Crop.search(@term) - @paginated_matches = @matches.paginate(:page => params[:page]) + @paginated_matches = @matches.paginate(page: params[:page]) respond_to do |format| format.html - format.json { render :json => @matches } + format.json { render json: @matches } end end # GET /crops/1 # GET /crops/1.json def show - @crop = Crop.includes(:scientific_names, {:plantings => :photos}).find(params[:id]) - @posts = @crop.posts.paginate(:page => params[:page]) + @crop = Crop.includes(:scientific_names, {plantings: :photos}).find(params[:id]) + @posts = @crop.posts.paginate(page: params[:page]) respond_to do |format| format.html # show.html.haml format.json do - render :json => @crop.to_json(:include => { - :plantings => { :include => { :owner => { :only => [:id, :login_name, :location, :latitude, :longitude] }}} + render json: @crop.to_json(include: { + plantings: { include: { owner: { only: [:id, :login_name, :location, :latitude, :longitude] }}} }) end end @@ -207,6 +207,6 @@ class CropsController < ApplicationController private def crop_params - params.require(:crop).permit(:en_wikipedia_url, :name, :parent_id, :creator_id, :approval_status, :request_notes, :reason_for_rejection, :rejection_notes, :scientific_names_attributes => [:scientific_name, :_destroy, :id]) + params.require(:crop).permit(:en_wikipedia_url, :name, :parent_id, :creator_id, :approval_status, :request_notes, :reason_for_rejection, :rejection_notes, scientific_names_attributes: [:scientific_name, :_destroy, :id]) end end diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index b5a0b48ab..2e2e5ec48 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -1,12 +1,12 @@ class FollowsController < ApplicationController before_filter :authenticate_member! load_and_authorize_resource - skip_load_resource :only => :create + skip_load_resource only: :create # POST /follows def create - @follow = current_member.follows.build(:followed_id => follow_params[:followed_id]) + @follow = current_member.follows.build(followed_id: follow_params[:followed_id]) if @follow.save flash[:notice] = "Followed #{ @follow.followed.login_name }" diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index f2ce6103a..68bb919c4 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -1,15 +1,15 @@ class GardensController < ApplicationController - before_filter :authenticate_member!, :except => [:index, :show] + before_filter :authenticate_member!, except: [:index, :show] load_and_authorize_resource # GET /gardens # GET /gardens.json def index - @gardens = Garden.paginate(:page => params[:page]) + @gardens = Garden.paginate(page: params[:page]) @owner = Member.find_by_slug(params[:owner]) if @owner - @gardens = @owner.gardens.paginate(:page => params[:page]) + @gardens = @owner.gardens.paginate(page: params[:page]) end respond_to do |format| @@ -87,7 +87,7 @@ class GardensController < ApplicationController expire_fragment("homepage_stats") respond_to do |format| - format.html { redirect_to gardens_by_owner_path(:owner => @garden.owner), notice: 'Garden was successfully deleted.' } + format.html { redirect_to gardens_by_owner_path(owner: @garden.owner), notice: 'Garden was successfully deleted.' } format.json { head :no_content } end end diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index 4bc3a5d90..55f652a61 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -1,5 +1,5 @@ class HarvestsController < ApplicationController - before_filter :authenticate_member!, :except => [:index, :show] + before_filter :authenticate_member!, except: [:index, :show] load_and_authorize_resource @@ -17,12 +17,12 @@ class HarvestsController < ApplicationController end respond_to do |format| - format.html { @harvests = @harvests.paginate(:page => params[:page]) } + format.html { @harvests = @harvests.paginate(page: params[:page]) } format.json { render json: @harvests } format.csv do specifics = (@owner ? "#{@owner.login_name}-" : @crop ? "#{@crop.name}-" : nil) @filename = "Growstuff-#{specifics}Harvests-#{Time.zone.now.to_s(:number)}.csv" - render :csv => @harvests + render csv: @harvests end end end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 013ae44de..7d8c892bb 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -1,21 +1,21 @@ class MembersController < ApplicationController load_and_authorize_resource - skip_authorize_resource :only => [:nearby, :unsubscribe] + skip_authorize_resource only: [:nearby, :unsubscribe] - after_action :expire_cache_fragments, :only => :create + after_action :expire_cache_fragments, only: :create def index @sort = params[:sort] if @sort == 'recently_joined' - @members = Member.confirmed.recently_joined.paginate(:page => params[:page]) + @members = Member.confirmed.recently_joined.paginate(page: params[:page]) else - @members = Member.confirmed.paginate(:page => params[:page]) + @members = Member.confirmed.paginate(page: params[:page]) end respond_to do |format| format.html # index.html.haml - format.json { render :json => @members.to_json(:only => [:id, :login_name, :slug, :bio, :created_at, :location, :latitude, :longitude]) } + format.json { render json: @members.to_json(only: [:id, :login_name, :slug, :bio, :created_at, :location, :latitude, :longitude]) } end end @@ -31,22 +31,22 @@ class MembersController < ApplicationController respond_to do |format| format.html # show.html.haml - format.json { render :json => @member.to_json(:only => [:id, :login_name, :bio, :created_at, :slug, :location, :latitude, :longitude]) } + format.json { render json: @member.to_json(only: [:id, :login_name, :bio, :created_at, :slug, :location, :latitude, :longitude]) } format.rss { render( - :layout => false, - :locals => { :member => @member } + layout: false, + locals: { member: @member } )} end end def view_follows @member = Member.confirmed.find(params[:login_name]) - @follows = @member.followed.paginate(:page => params[:page]) + @follows = @member.followed.paginate(page: params[:page]) end def view_followers @member = Member.confirmed.find(params[:login_name]) - @followers = @member.followers.paginate(:page => params[:page]) + @followers = @member.followers.paginate(page: params[:page]) end EMAIL_TYPE_STRING = { diff --git a/app/controllers/order_items_controller.rb b/app/controllers/order_items_controller.rb index 37a7e7b74..7781913d4 100644 --- a/app/controllers/order_items_controller.rb +++ b/app/controllers/order_items_controller.rb @@ -8,7 +8,7 @@ class OrderItemsController < ApplicationController params[:order_item][:price] = params[:order_item][:price].to_f * 100 # convert to cents end @order_item = OrderItem.new(order_item_params) - @order_item.order = current_member.current_order || Order.create(:member_id => current_member.id) + @order_item.order = current_member.current_order || Order.create(member_id: current_member.id) respond_to do |format| if @order_item.save diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 3cc4caa9c..82bb337f9 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -34,15 +34,15 @@ class OrdersController < ApplicationController @order = Order.find(params[:id]) respond_to do |format| - if @order.update_attributes(:referral_code => params[:referral_code]) + if @order.update_attributes(referral_code: params[:referral_code]) response = EXPRESS_GATEWAY.setup_purchase( @order.total, - :items => @order.activemerchant_items, - :currency => Growstuff::Application.config.currency, - :no_shipping => true, - :ip => request.remote_ip, - :return_url => complete_order_url, - :cancel_return_url => shop_url + items: @order.activemerchant_items, + currency: Growstuff::Application.config.currency, + no_shipping: true, + ip: request.remote_ip, + return_url: complete_order_url, + cancel_return_url: shop_url ) format.html { redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token) } else @@ -58,10 +58,10 @@ class OrdersController < ApplicationController if (params[:token] && params['PayerID']) purchase = EXPRESS_GATEWAY.purchase( @order.total, - :currency => Growstuff::Application.config.currency, - :ip => request.remote_ip, - :payer_id => params['PayerID'], - :token => params[:token] + currency: Growstuff::Application.config.currency, + ip: request.remote_ip, + payer_id: params['PayerID'], + token: params[:token] ) if purchase.success? @order.completed_at = Time.zone.now diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 9f39aa7ab..8130ef4e1 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -1,11 +1,11 @@ class PhotosController < ApplicationController - before_filter :authenticate_member!, :except => [:index, :show] + before_filter :authenticate_member!, except: [:index, :show] load_and_authorize_resource # GET /photos # GET /photos.json def index - @photos = Photo.paginate(:page => params[:page]) + @photos = Photo.paginate(page: params[:page]) respond_to do |format| format.html # index.html.erb diff --git a/app/controllers/places_controller.rb b/app/controllers/places_controller.rb index 82189cb68..13c0bd05c 100644 --- a/app/controllers/places_controller.rb +++ b/app/controllers/places_controller.rb @@ -5,7 +5,7 @@ class PlacesController < ApplicationController respond_to do |format| format.html # json response is whatever we want to map here - format.json { render :json => Member.located.to_json(:only => [:id, :login_name, :slug, :location, :latitude, :longitude]) } + format.json { render json: Member.located.to_json(only: [:id, :login_name, :slug, :location, :latitude, :longitude]) } end end @@ -16,7 +16,7 @@ class PlacesController < ApplicationController @nearby_members = Member.nearest_to(params[:place]) respond_to do |format| format.html # show.html.haml - format.json { render :json => @nearby_members.to_json(:only => [:id, :login_name, :slug, :location, :latitude, :longitude]) } + format.json { render json: @nearby_members.to_json(only: [:id, :login_name, :slug, :location, :latitude, :longitude]) } end end diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 543981170..276024309 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -1,5 +1,5 @@ class PlantingsController < ApplicationController - before_filter :authenticate_member!, :except => [:index, :show] + before_filter :authenticate_member!, except: [:index, :show] load_and_authorize_resource # GET /plantings @@ -8,21 +8,21 @@ class PlantingsController < ApplicationController @owner = Member.find_by_slug(params[:owner]) @crop = Crop.find_by_slug(params[:crop]) if @owner - @plantings = @owner.plantings.includes(:owner, :crop, :garden).paginate(:page => params[:page]) + @plantings = @owner.plantings.includes(:owner, :crop, :garden).paginate(page: params[:page]) elsif @crop - @plantings = @crop.plantings.includes(:owner, :crop, :garden).paginate(:page => params[:page]) + @plantings = @crop.plantings.includes(:owner, :crop, :garden).paginate(page: params[:page]) else - @plantings = Planting.includes(:owner, :crop, :garden).paginate(:page => params[:page]) + @plantings = Planting.includes(:owner, :crop, :garden).paginate(page: params[:page]) end respond_to do |format| - format.html { @plantings = @plantings.paginate(:page => params[:page]) } + 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" - render :csv => @plantings + render csv: @plantings end end end diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index ceb4730cc..e30ea1f7f 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -1,5 +1,5 @@ class PostsController < ApplicationController - before_filter :authenticate_member!, :except => [:index, :show] + before_filter :authenticate_member!, except: [:index, :show] load_and_authorize_resource # GET /posts @@ -8,29 +8,29 @@ class PostsController < ApplicationController def index @author = Member.find_by_slug(params[:author]) if @author - @posts = @author.posts.includes(:author, { :comments => :author }).paginate(:page => params[:page]) + @posts = @author.posts.includes(:author, { comments: :author }).paginate(page: params[:page]) else - @posts = Post.includes(:author, { :comments => :author }).paginate(:page => params[:page]) + @posts = Post.includes(:author, { comments: :author }).paginate(page: params[:page]) end 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 # GET /posts/1 # GET /posts/1.json def show - @post = Post.includes(:author, { :comments => :author }).find(params[:id]) + @post = Post.includes(:author, { comments: :author }).find(params[:id]) respond_to do |format| format.html # show.html.haml format.json { render json: @post } format.rss { render( - :layout => false, - :locals => { :post => @post } + layout: false, + locals: { post: @post } )} end end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index c4883bd4d..d0ab917b0 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -28,7 +28,7 @@ class RegistrationsController < Devise::RegistrationsController if successfully_updated set_flash_message :notice, :updated # Sign in the member bypassing validation in case their password changed - sign_in @member, :bypass => true + sign_in @member, bypass: true redirect_to edit_member_registration_path else render "edit" diff --git a/app/controllers/scientific_names_controller.rb b/app/controllers/scientific_names_controller.rb index 511a96279..cc7723b0b 100644 --- a/app/controllers/scientific_names_controller.rb +++ b/app/controllers/scientific_names_controller.rb @@ -1,5 +1,5 @@ class ScientificNamesController < ApplicationController - before_filter :authenticate_member!, :except => [:index, :show] + before_filter :authenticate_member!, except: [:index, :show] load_and_authorize_resource # GET /scientific_names diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index a2e79afaf..70f3936a1 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -1,5 +1,5 @@ class SeedsController < ApplicationController - before_filter :authenticate_member!, :except => [:index, :show] + before_filter :authenticate_member!, except: [:index, :show] load_and_authorize_resource # GET /seeds @@ -8,17 +8,17 @@ class SeedsController < ApplicationController @owner = Member.find_by_slug(params[:owner]) @crop = Crop.find_by_slug(params[:crop]) if @owner - @seeds = @owner.seeds.includes(:owner, :crop).paginate(:page => params[:page]) + @seeds = @owner.seeds.includes(:owner, :crop).paginate(page: params[:page]) elsif @crop - @seeds = @crop.seeds.includes(:owner, :crop).paginate(:page => params[:page]) + @seeds = @crop.seeds.includes(:owner, :crop).paginate(page: params[:page]) else - @seeds = Seed.includes(:owner, :crop).paginate(:page => params[:page]) + @seeds = Seed.includes(:owner, :crop).paginate(page: params[:page]) end 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" @@ -27,7 +27,7 @@ class SeedsController < ApplicationController @filename = "Growstuff-Seeds-#{Time.zone.now.to_s(:number)}.csv" @seeds = Seed.includes(:owner, :crop) end - render :csv => @seeds + render csv: @seeds end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d8470392d..8c0a0c937 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -21,7 +21,7 @@ module ApplicationHelper link = "http://www.wolframalpha.com/input/?i=#{pid}+#{currency}" return link_to "(convert)", link, - :target => "_blank" + target: "_blank" end # Produces a cache key for uniquely identifying cached fragments. @@ -46,8 +46,8 @@ module ApplicationHelper return member.preferred_avatar_uri if member.preferred_avatar_uri.present? Gravatar.new(member.email).image_url({ - :size => size, - :default => :identicon + size: size, + default: :identicon }) end end diff --git a/app/helpers/harvests_helper.rb b/app/helpers/harvests_helper.rb index 16371b4e9..3055db065 100644 --- a/app/helpers/harvests_helper.rb +++ b/app/helpers/harvests_helper.rb @@ -18,11 +18,11 @@ module HarvestsHelper def display_human_quantity(harvest) if ! harvest.quantity.blank? && harvest.quantity > 0 if harvest.unit == 'individual' # just the number - number_to_human(harvest.quantity, :strip_insignificant_zeros => true) + number_to_human(harvest.quantity, strip_insignificant_zeros: true) elsif ! harvest.unit.blank? # pluralize anything else - return pluralize(number_to_human(harvest.quantity, :strip_insignificant_zeros => true), harvest.unit) + 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}" + return "#{number_to_human(harvest.quantity, strip_insignificant_zeros: true)} #{harvest.unit}" end else return nil @@ -31,7 +31,7 @@ module HarvestsHelper def display_weight(harvest) if ! harvest.weight_quantity.blank? && harvest.weight_quantity > 0 - return "#{number_to_human(harvest.weight_quantity, :strip_insignificant_zeros => true)} #{harvest.weight_unit}" + return "#{number_to_human(harvest.weight_quantity, strip_insignificant_zeros: true)} #{harvest.weight_unit}" else return nil end diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index cef59c9c8..bb3695851 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -2,7 +2,7 @@ module NotificationsHelper def reply_link(notification) if notification.post # comment on the post in question - new_comment_url(:post_id => notification.post.id) + new_comment_url(post_id: notification.post.id) else # by default, reply link sends a PM in return reply_notification_url(notification) diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index 5ffb862d6..e7f1a9e8b 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -17,8 +17,8 @@ class Notifier < ActionMailer::Base # Encrypting @signed_message = verifier.generate ({ member_id: @notification.recipient.id, type: :send_notification_email }) - mail(:to => @notification.recipient.email, - :subject => @notification.subject) + mail(to: @notification.recipient.email, + subject: @notification.subject) end def planting_reminder(member) @@ -31,24 +31,24 @@ class Notifier < ActionMailer::Base @signed_message = verifier.generate ({ member_id: @member.id, type: :send_planting_reminder }) if @member.send_planting_reminder - mail(:to => @member.email, - :subject => "What have you planted lately?") + mail(to: @member.email, + subject: "What have you planted lately?") end end def new_crop_request(member, request) @member, @request = member, request - mail(:to => @member.email, :subject => "#{@request.requester.login_name} has requested #{@request.name} as a new crop") + mail(to: @member.email, subject: "#{@request.requester.login_name} has requested #{@request.name} as a new crop") end def crop_request_approved(member, crop) @member, @crop = member, crop - mail(:to => @member.email, :subject => "#{crop.name.capitalize} has been approved") + mail(to: @member.email, subject: "#{crop.name.capitalize} has been approved") end def crop_request_rejected(member, crop) @member, @crop = member, crop - mail(:to => @member.email, :subject => "#{crop.name.capitalize} has been rejected") + mail(to: @member.email, subject: "#{crop.name.capitalize} has been rejected") end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 6ec3aea25..96b4ea69e 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -24,7 +24,7 @@ class Ability # nobody should be able to view unapproved crops unless they # are wranglers or admins cannot :read, Crop - can :read, Crop, :approval_status => "approved" + can :read, Crop, approval_status: "approved" # scientific names should only be viewable if associated crop is approved cannot :read, ScientificName can :read, ScientificName do |sn| @@ -38,15 +38,15 @@ class Ability if member # members can see even rejected or pending crops if they requested it - can :read, Crop, :requester_id => member.id + can :read, Crop, requester_id: member.id # managing your own user settings - can :update, Member, :id => member.id + can :update, Member, id: member.id # can read/delete notifications that were sent to them - can :read, Notification, :recipient_id => member.id - can :destroy, Notification, :recipient_id => member.id - can :reply, Notification, :recipient_id => member.id + can :read, Notification, recipient_id: member.id + can :destroy, Notification, recipient_id: member.id + can :reply, Notification, recipient_id: member.id # can send a private message to anyone but themselves # note: sadly, we can't test for this from the view, but it works # for the model/controller @@ -68,58 +68,58 @@ class Ability # can create & destroy their own authentications against other sites. can :create, Authentication - can :destroy, Authentication, :member_id => member.id + can :destroy, Authentication, member_id: member.id # anyone can create a post, or comment on a post, # but only the author can edit/destroy it. can :create, Post - can :update, Post, :author_id => member.id - can :destroy, Post, :author_id => member.id + can :update, Post, author_id: member.id + can :destroy, Post, author_id: member.id can :create, Comment - can :update, Comment, :author_id => member.id - can :destroy, Comment, :author_id => member.id + can :update, Comment, author_id: member.id + can :destroy, Comment, author_id: member.id # same deal for gardens and plantings can :create, Garden - can :update, Garden, :owner_id => member.id - can :destroy, Garden, :owner_id => member.id + can :update, Garden, owner_id: member.id + can :destroy, Garden, owner_id: member.id can :create, Planting - can :update, Planting, :garden => { :owner_id => member.id } - can :destroy, Planting, :garden => { :owner_id => member.id } + can :update, Planting, garden: { owner_id: member.id } + can :destroy, Planting, garden: { owner_id: member.id } can :create, Harvest - can :update, Harvest, :owner_id => member.id - can :destroy, Harvest, :owner_id => member.id + can :update, Harvest, owner_id: member.id + can :destroy, Harvest, owner_id: member.id can :create, Photo - can :update, Photo, :owner_id => member.id - can :destroy, Photo, :owner_id => member.id + can :update, Photo, owner_id: member.id + can :destroy, Photo, owner_id: member.id can :create, Seed - can :update, Seed, :owner_id => member.id - can :destroy, Seed, :owner_id => member.id + can :update, Seed, owner_id: member.id + can :destroy, Seed, owner_id: member.id # orders/shop/etc can :create, Order - can :read, Order, :member_id => member.id - can :complete, Order, :member_id => member.id, :completed_at => nil - can :checkout, Order, :member_id => member.id, :completed_at => nil - can :cancel, Order, :member_id => member.id, :completed_at => nil - can :destroy, Order, :member_id => member.id, :completed_at => nil + can :read, Order, member_id: member.id + can :complete, Order, member_id: member.id, completed_at: nil + can :checkout, Order, member_id: member.id, completed_at: nil + can :cancel, Order, member_id: member.id, completed_at: nil + can :destroy, Order, member_id: member.id, completed_at: nil 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 } - cannot :destroy, OrderItem, :order => { :member_id => member.id, :completed_at => nil } + cannot :read, OrderItem, order: { member_id: member.id } + cannot :update, OrderItem, order: { member_id: member.id, completed_at: nil } + cannot :destroy, OrderItem, order: { member_id: member.id, completed_at: nil } # following/unfollowing permissions can :create, Follow - cannot :create, Follow, :followed_id => member.id # can't follow yourself + cannot :create, Follow, followed_id: member.id # can't follow yourself can :destroy, Follow - cannot :destroy, Follow, :followed_id => member.id # can't unfollow yourself + cannot :destroy, Follow, followed_id: member.id # can't unfollow yourself if member.has_role? :admin diff --git a/app/models/account.rb b/app/models/account.rb index 547fc57bf..bfbf60e5d 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -2,8 +2,8 @@ class Account < ActiveRecord::Base belongs_to :member belongs_to :account_type - validates :member_id, :uniqueness => { - :message => 'already has account details associated with it' + validates :member_id, uniqueness: { + message: 'already has account details associated with it' } before_create do |account| diff --git a/app/models/alternate_name.rb b/app/models/alternate_name.rb index 857adf7ec..30923bfac 100644 --- a/app/models/alternate_name.rb +++ b/app/models/alternate_name.rb @@ -1,5 +1,5 @@ class AlternateName < ActiveRecord::Base after_commit { |an| an.crop.__elasticsearch__.index_document if an.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == "true" } belongs_to :crop - belongs_to :creator, :class_name => 'Member' + belongs_to :creator, class_name: 'Member' end diff --git a/app/models/comment.rb b/app/models/comment.rb index f7da18842..e649eb2b4 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,5 +1,5 @@ class Comment < ActiveRecord::Base - belongs_to :author, :class_name => 'Member' + belongs_to :author, class_name: 'Member' belongs_to :post default_scope { order("created_at DESC") } @@ -11,11 +11,11 @@ class Comment < ActiveRecord::Base # don't send notifications to yourself if recipient != sender Notification.create( - :recipient_id => recipient, - :sender_id => sender, - :subject => "#{self.author} commented on #{self.post.subject}", - :body => self.body, - :post_id => self.post.id + recipient_id: recipient, + sender_id: sender, + subject: "#{self.author} commented on #{self.post.subject}", + body: self.body, + post_id: self.post.id ) end end diff --git a/app/models/crop.rb b/app/models/crop.rb index fe593fe37..ec7dc7d0d 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -4,42 +4,42 @@ class Crop < ActiveRecord::Base has_many :scientific_names, after_add: :update_index, after_remove: :update_index accepts_nested_attributes_for :scientific_names, - :allow_destroy => true, - :reject_if => :all_blank + allow_destroy: true, + reject_if: :all_blank has_many :alternate_names, after_add: :update_index, after_remove: :update_index, dependent: :destroy has_many :plantings - has_many :photos, :through => :plantings + has_many :photos, through: :plantings has_many :seeds has_many :harvests - has_many :plant_parts, -> { uniq }, :through => :harvests - belongs_to :creator, :class_name => 'Member' - belongs_to :requester, :class_name => 'Member' + has_many :plant_parts, -> { uniq }, through: :harvests + belongs_to :creator, class_name: 'Member' + belongs_to :requester, class_name: 'Member' - belongs_to :parent, :class_name => 'Crop' - has_many :varieties, :class_name => 'Crop', :foreign_key => 'parent_id' + 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} default_scope { order("lower(name) asc") } - scope :recent, -> { where(:approval_status => "approved").reorder("created_at desc") } - scope :toplevel, -> { where(:approval_status => "approved", :parent_id => nil) } - scope :popular, -> { where(:approval_status => "approved").reorder("plantings_count desc, lower(name) asc") } - scope :randomized, -> { where(:approval_status => "approved").reorder('random()') } # ok on sqlite and psql, but not on mysql - scope :pending_approval, -> { where(:approval_status => "pending") } - scope :approved, -> { where(:approval_status => "approved") } - scope :rejected, -> { where(:approval_status => "rejected") } + scope :recent, -> { where(approval_status: "approved").reorder("created_at desc") } + scope :toplevel, -> { where(approval_status: "approved", parent_id: nil) } + scope :popular, -> { where(approval_status: "approved").reorder("plantings_count desc, lower(name) asc") } + scope :randomized, -> { where(approval_status: "approved").reorder('random()') } # ok on sqlite and psql, but not on mysql + scope :pending_approval, -> { where(approval_status: "pending") } + scope :approved, -> { where(approval_status: "approved") } + scope :rejected, -> { where(approval_status: "rejected") } ## Wikipedia urls are only necessary when approving a crop validates :en_wikipedia_url, - :format => { - :with => /\Ahttps?:\/\/en\.wikipedia\.org\/wiki/, - :message => 'is not a valid English Wikipedia URL' + format: { + with: /\Ahttps?:\/\/en\.wikipedia\.org\/wiki/, + message: 'is not a valid English Wikipedia URL' }, - :if => :approved? + if: :approved? ## Reasons are only necessary when rejecting - validates :reason_for_rejection, :presence => true, :if => :rejected? + validates :reason_for_rejection, presence: true, if: :rejected? ## This validation addresses a race condition validate :approval_status_cannot_be_changed_again @@ -231,14 +231,14 @@ class Crop < ActiveRecord::Base crop = Crop.find_or_create_by(name: name) crop.update_attributes( - :en_wikipedia_url => en_wikipedia_url, - :creator_id => cropbot.id + en_wikipedia_url: en_wikipedia_url, + creator_id: cropbot.id ) if parent parent = Crop.find_by_name(parent) if parent - crop.update_attributes(:parent_id => parent.id) + crop.update_attributes(parent_id: parent.id) else logger.warn("Warning: parent crop #{parent} not found") end @@ -264,13 +264,13 @@ class Crop < ActiveRecord::Base raise "cropbot account not found: run rake db:seed" unless cropbot names_to_add.each do |n| - if self.scientific_names.exists?(:scientific_name => n) + if self.scientific_names.exists?(scientific_name: n) logger.warn("Warning: skipping duplicate scientific name #{n} for #{self}") else self.scientific_names.create( - :scientific_name => n, - :creator_id => cropbot.id + scientific_name: n, + creator_id: cropbot.id ) end end @@ -286,12 +286,12 @@ class Crop < ActiveRecord::Base names_to_add = alternate_names.split(%r{,\s*}) names_to_add.each do |n| - if self.alternate_names.exists?(:name => n) + if self.alternate_names.exists?(name: n) logger.warn("Warning: skipping duplicate alternate name #{n} for #{self}") else self.alternate_names.create( - :name => n, - :creator_id => cropbot.id + name: n, + creator_id: cropbot.id ) end end diff --git a/app/models/follow.rb b/app/models/follow.rb index d7028c8ed..997352ebf 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -1,14 +1,14 @@ class Follow < ActiveRecord::Base belongs_to :follower, class_name: "Member" belongs_to :followed, class_name: "Member" - validates :follower_id, uniqueness: { :scope => :followed_id } + validates :follower_id, uniqueness: { scope: :followed_id } after_create do Notification.create( - :recipient_id => self.followed_id, - :sender_id => self.follower_id, - :subject => "#{self.follower.login_name} is now following you", - :body => "#{self.follower.login_name} just followed you on #{ENV["GROWSTUFF_SITE_NAME"]}. " + recipient_id: self.followed_id, + sender_id: self.follower_id, + subject: "#{self.follower.login_name} is now following you", + body: "#{self.follower.login_name} just followed you on #{ENV["GROWSTUFF_SITE_NAME"]}. " ) end diff --git a/app/models/forum.rb b/app/models/forum.rb index fd4a79509..0e2e2615d 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -3,7 +3,7 @@ class Forum < ActiveRecord::Base friendly_id :name, use: [:slugged, :finders] has_many :posts - belongs_to :owner, :class_name => "Member" + belongs_to :owner, class_name: "Member" def to_s return name diff --git a/app/models/garden.rb b/app/models/garden.rb index 15bbaa9de..448d7d60e 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -3,9 +3,9 @@ class Garden < ActiveRecord::Base extend FriendlyId friendly_id :garden_slug, use: [:slugged, :finders] - belongs_to :owner, :class_name => 'Member', :foreign_key => 'owner_id' - has_many :plantings, -> { order(created_at: :desc) }, :dependent => :destroy - has_many :crops, :through => :plantings + belongs_to :owner, class_name: 'Member', foreign_key: 'owner_id' + has_many :plantings, -> { order(created_at: :desc) }, dependent: :destroy + has_many :crops, through: :plantings has_and_belongs_to_many :photos @@ -25,23 +25,23 @@ class Garden < ActiveRecord::Base after_save :mark_inactive_garden_plantings_as_finished default_scope { order("lower(name) asc") } - scope :active, -> { where(:active => true) } - scope :inactive, -> { where(:active => false) } + scope :active, -> { where(active: true) } + scope :inactive, -> { where(active: false) } validates :location, - :length => { :maximum => 255 } + length: { maximum: 255 } validates :name, - :format => { - :with => /\S/ + format: { + with: /\S/ }, - :length => { :maximum => 255 } + length: { maximum: 255 } validates :area, - :numericality => { - :only_integer => false, - :greater_than_or_equal_to => 0 }, - :allow_nil => true + numericality: { + only_integer: false, + greater_than_or_equal_to: 0 }, + allow_nil: true AREA_UNITS_VALUES = { "square metres" => "square metre", @@ -49,10 +49,10 @@ class Garden < ActiveRecord::Base "hectares" => "hectare", "acres" => "acre" } - validates :area_unit, :inclusion => { :in => AREA_UNITS_VALUES.values, - :message => "%{value} is not a valid area unit" }, - :allow_nil => true, - :allow_blank => true + validates :area_unit, inclusion: { in: AREA_UNITS_VALUES.values, + message: "%{value} is not a valid area unit" }, + allow_nil: true, + allow_blank: true after_validation :cleanup_area diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 7bbd2b6ee..e648bec39 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -4,7 +4,7 @@ class Harvest < ActiveRecord::Base friendly_id :harvest_slug, use: [:slugged, :finders] belongs_to :crop - belongs_to :owner, :class_name => 'Member' + belongs_to :owner, class_name: 'Member' belongs_to :plant_part has_and_belongs_to_many :photos @@ -20,17 +20,17 @@ class Harvest < ActiveRecord::Base default_scope { order('created_at DESC') } - validates :crop, :approved => true + 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 => { - :only_integer => false, - :greater_than_or_equal_to => 0 }, - :allow_nil => true + numericality: { + only_integer: false, + greater_than_or_equal_to: 0 }, + allow_nil: true UNITS_VALUES = { "individual" => "individual", @@ -44,24 +44,24 @@ class Harvest < ActiveRecord::Base "baskets" => "basket", "bushels" => "bushel" } - validates :unit, :inclusion => { :in => UNITS_VALUES.values, - :message => "%{value} is not a valid unit" }, - :allow_nil => true, - :allow_blank => true + validates :unit, inclusion: { in: UNITS_VALUES.values, + message: "%{value} is not a valid unit" }, + allow_nil: true, + allow_blank: true validates :weight_quantity, - :numericality => { :only_integer => false }, - :allow_nil => true + numericality: { only_integer: false }, + allow_nil: true WEIGHT_UNITS_VALUES = { "kg" => "kg", "lb" => "lb", "oz" => "oz" } - validates :weight_unit, :inclusion => { :in => WEIGHT_UNITS_VALUES.values, - :message => "%{value} is not a valid unit" }, - :allow_nil => true, - :allow_blank => true + validates :weight_unit, inclusion: { in: WEIGHT_UNITS_VALUES.values, + message: "%{value} is not a valid unit" }, + allow_nil: true, + allow_blank: true after_validation :cleanup_quantities @@ -104,7 +104,7 @@ class Harvest < ActiveRecord::Base # 2 buckets of apricots, weighing 10kg string = '' if self.quantity - string += "#{number_to_human(self.quantity.to_s, :strip_insignificant_zeros => true)} " + string += "#{number_to_human(self.quantity.to_s, strip_insignificant_zeros: true)} " if self.unit == 'individual' string += 'individual ' else @@ -125,7 +125,7 @@ class Harvest < ActiveRecord::Base end if self.weight_quantity - string += " weighing #{number_to_human(self.weight_quantity, :strip_insignificant_zeros => true)} #{self.weight_unit}" + string += " weighing #{number_to_human(self.weight_quantity, strip_insignificant_zeros: true)} #{self.weight_unit}" end return string diff --git a/app/models/member.rb b/app/models/member.rb index a8af799b1..28a0d6f10 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -4,26 +4,26 @@ class Member < ActiveRecord::Base friendly_id :login_name, use: [:slugged, :finders] - has_many :posts, :foreign_key => 'author_id' - has_many :comments, :foreign_key => 'author_id' - has_many :forums, :foreign_key => 'owner_id' + has_many :posts, foreign_key: 'author_id' + has_many :comments, foreign_key: 'author_id' + has_many :forums, foreign_key: 'owner_id' - has_many :gardens, :foreign_key => 'owner_id' - has_many :plantings, :foreign_key => 'owner_id' + has_many :gardens, foreign_key: 'owner_id' + has_many :plantings, foreign_key: 'owner_id' - has_many :seeds, :foreign_key => 'owner_id' - has_many :harvests, :foreign_key => 'owner_id' + has_many :seeds, foreign_key: 'owner_id' + has_many :harvests, foreign_key: 'owner_id' has_and_belongs_to_many :roles - has_many :notifications, :foreign_key => 'recipient_id' - has_many :sent_notifications, :foreign_key => 'sender_id' + has_many :notifications, foreign_key: 'recipient_id' + has_many :sent_notifications, foreign_key: 'sender_id' has_many :authentications has_many :orders has_one :account - has_one :account_type, :through => :account + has_one :account_type, through: :account has_many :photos @@ -33,13 +33,13 @@ class Member < ActiveRecord::Base scope :located, -> { where("location <> '' and latitude IS NOT NULL and longitude IS NOT NULL") } scope :recently_signed_in, -> { reorder('updated_at DESC') } scope :recently_joined, -> { reorder("confirmed_at desc") } - scope :wants_newsletter, -> { where(:newsletter => true) } + scope :wants_newsletter, -> { where(newsletter: true) } - has_many :follows, :class_name => "Follow", :foreign_key => "follower_id" - has_many :followed, :through => :follows + has_many :follows, class_name: "Follow", foreign_key: "follower_id" + has_many :followed, through: :follows - has_many :inverse_follows, :class_name => "Follow", :foreign_key => "followed_id" - has_many :followers, :through => :inverse_follows, :source => :follower + has_many :inverse_follows, class_name: "Follow", foreign_key: "followed_id" + has_many :followers, through: :inverse_follows, source: :follower # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, @@ -58,34 +58,34 @@ class Member < ActiveRecord::Base attr_accessor :login # Requires acceptance of the Terms of Service - validates_acceptance_of :tos_agreement, :allow_nil => false, - :accept => true + validates_acceptance_of :tos_agreement, allow_nil: false, + accept: true validates :login_name, - :length => { - :minimum => 2, - :maximum => 25, - :message => "should be between 2 and 25 characters long" + length: { + minimum: 2, + maximum: 25, + message: "should be between 2 and 25 characters long" }, - :exclusion => { - :in => %w(growstuff admin moderator staff nearby), - :message => "name is reserved" + exclusion: { + in: %w(growstuff admin moderator staff nearby), + message: "name is reserved" }, - :format => { - :with => /\A\w+\z/, - :message => "may only include letters, numbers, or underscores" + format: { + with: /\A\w+\z/, + message: "may only include letters, numbers, or underscores" }, - :uniqueness => { - :case_sensitive => false + uniqueness: { + case_sensitive: false } # 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 @@ -93,7 +93,7 @@ class Member < ActiveRecord::Base def self.find_first_by_auth_conditions(warden_conditions) conditions = warden_conditions.dup if login = conditions.delete(:login) - where(conditions).where(["lower(login_name) = :value OR lower(email) = :value", { :value => login.downcase }]).first + where(conditions).where(["lower(login_name) = :value OR lower(email) = :value", { value: login.downcase }]).first else where(conditions).first end @@ -108,7 +108,7 @@ class Member < ActiveRecord::Base end def current_order - orders.where(:completed_at => nil).first + orders.where(completed_at: nil).first end # when purchasing a product that gives you a paid account, this method @@ -163,15 +163,15 @@ class Member < ActiveRecord::Base result = false if set result = flickr.photosets.getPhotos( - :photoset_id => set, - :page => page_num, - :per_page => 30 + photoset_id: set, + page: page_num, + per_page: 30 ) else result = flickr.people.getPhotos( - :user_id => 'me', - :page => page_num, - :per_page => 30 + user_id: 'me', + page: page_num, + per_page: 30 ) end if result @@ -239,10 +239,10 @@ class Member < ActiveRecord::Base return true if (Rails.env.test? && !testing) gb = Gibbon::API.new res = gb.lists.subscribe({ - :id => Gibbon::API.api_key, - :email => { :email => email }, - :merge_vars => { :login_name => login_name }, - :double_optin => false # they already confirmed their email with us + id: Gibbon::API.api_key, + email: { email: email }, + merge_vars: { login_name: login_name }, + double_optin: false # they already confirmed their email with us }) end @@ -250,17 +250,17 @@ class Member < ActiveRecord::Base return true if (Rails.env.test? && !testing) gb = Gibbon::API.new res = gb.lists.unsubscribe({ - :id => ENV['GROWSTUFF_MAILCHIMP_NEWSLETTER_ID'], - :email => { :email => email } + id: ENV['GROWSTUFF_MAILCHIMP_NEWSLETTER_ID'], + email: { email: email } }) end def already_following?(member) - self.follows.exists?(:followed_id => member.id) + self.follows.exists?(followed_id: member.id) end def get_follow(member) - self.follows.where(:followed_id => member.id).first if already_following?(member) + self.follows.where(followed_id: member.id).first if already_following?(member) end end diff --git a/app/models/notification.rb b/app/models/notification.rb index 01f157df9..0668167f4 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -1,12 +1,12 @@ class Notification < ActiveRecord::Base - belongs_to :sender, :class_name => 'Member' - belongs_to :recipient, :class_name => 'Member' + belongs_to :sender, class_name: 'Member' + belongs_to :recipient, class_name: 'Member' belongs_to :post - validates :subject, :length => { :maximum => 255 } + validates :subject, length: { maximum: 255 } default_scope { order('created_at DESC') } - scope :unread, -> { where(:read => false) } + scope :unread, -> { where(read: false) } before_create :replace_blank_subject after_create :send_email diff --git a/app/models/order.rb b/app/models/order.rb index e9f97034f..f3a4eaafb 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,13 +1,13 @@ class Order < ActiveRecord::Base belongs_to :member - has_many :order_items, :dependent => :destroy + has_many :order_items, dependent: :destroy default_scope { order('created_at DESC') } - validates :referral_code, :format => { - :with => /\A[a-zA-Z0-9 ]*\z/, - :message => "may only include letters and numbers" + validates :referral_code, format: { + with: /\A[a-zA-Z0-9 ]*\z/, + message: "may only include letters and numbers" } before_save :standardize_referral_code @@ -27,9 +27,9 @@ class Order < ActiveRecord::Base items = [] order_items.each do |i| items.push({ - :name => i.product.name, - :quantity => i.quantity, - :amount => i.price + name: i.product.name, + quantity: i.quantity, + amount: i.price }) end return items @@ -87,7 +87,7 @@ class Order < ActiveRecord::Base end when "referral_code" # coerce to uppercase - return Order.where(:referral_code => args[:for].upcase) + return Order.where(referral_code: args[:for].upcase) end end return [] diff --git a/app/models/order_item.rb b/app/models/order_item.rb index 159876dd5..da26f3a42 100644 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -4,7 +4,7 @@ class OrderItem < ActiveRecord::Base validate :price_must_be_greater_than_minimum - validates_uniqueness_of :order_id, :message => "may only have one item." + validates_uniqueness_of :order_id, message: "may only have one item." def price_must_be_greater_than_minimum @product = Product.find(product_id) diff --git a/app/models/photo.rb b/app/models/photo.rb index 54cc94de3..1abef6047 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -1,5 +1,5 @@ class Photo < ActiveRecord::Base - belongs_to :owner, :class_name => 'Member' + belongs_to :owner, class_name: 'Member' has_and_belongs_to_many :plantings has_and_belongs_to_many :harvests @@ -23,16 +23,16 @@ class Photo < ActiveRecord::Base # for easier stubbing and testing. def flickr_metadata flickr = owner.flickr - info = flickr.photos.getInfo(:photo_id => flickr_photo_id) + info = flickr.photos.getInfo(photo_id: flickr_photo_id) licenses = flickr.photos.licenses.getInfo() license = licenses.find { |l| l.id == info.license } return { - :title => info.title || "Untitled", - :license_name => license.name, - :license_url => license.url, - :thumbnail_url => FlickRaw.url_q(info), - :fullsize_url => FlickRaw.url_z(info), - :link_url => FlickRaw.url_photopage(info) + title: info.title || "Untitled", + license_name: license.name, + license_url: license.url, + thumbnail_url: FlickRaw.url_q(info), + fullsize_url: FlickRaw.url_z(info), + link_url: FlickRaw.url_photopage(info) } end diff --git a/app/models/plant_part.rb b/app/models/plant_part.rb index 33d2292fa..652bc894b 100644 --- a/app/models/plant_part.rb +++ b/app/models/plant_part.rb @@ -1,9 +1,9 @@ class PlantPart < ActiveRecord::Base extend FriendlyId - friendly_id :name, :use => [:slugged, :finders] + friendly_id :name, use: [:slugged, :finders] has_many :harvests - has_many :crops, -> { uniq }, :through => :harvests + has_many :crops, -> { uniq }, through: :harvests def to_s return name diff --git a/app/models/planting.rb b/app/models/planting.rb index 7ccfe5572..02028f909 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -3,8 +3,8 @@ class Planting < ActiveRecord::Base friendly_id :planting_slug, use: [:slugged, :finders] belongs_to :garden - belongs_to :owner, :class_name => 'Member', :counter_cache => true - belongs_to :crop, :counter_cache => true + belongs_to :owner, class_name: 'Member', counter_cache: true + belongs_to :crop, counter_cache: true has_and_belongs_to_many :photos @@ -18,33 +18,33 @@ class Planting < ActiveRecord::Base end default_scope { order("created_at desc") } - scope :finished, -> { where(:finished => true) } - scope :current, -> { where(:finished => false) } + scope :finished, -> { where(finished: true) } + scope :current, -> { where(finished: false) } delegate :name, :en_wikipedia_url, :default_scientific_name, :plantings_count, - :to => :crop, - :prefix => true + to: :crop, + prefix: true default_scope { order("created_at desc") } - validates :crop, :approved => true + 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, - :greater_than_or_equal_to => 0 }, - :allow_nil => true + numericality: { + only_integer: true, + greater_than_or_equal_to: 0 }, + allow_nil: true SUNNINESS_VALUES = %w(sun semi-shade shade) - validates :sunniness, :inclusion => { :in => SUNNINESS_VALUES, - :message => "%{value} is not a valid sunniness value" }, - :allow_nil => true, - :allow_blank => true + validates :sunniness, inclusion: { in: SUNNINESS_VALUES, + message: "%{value} is not a valid sunniness value" }, + allow_nil: true, + allow_blank: true PLANTED_FROM_VALUES = [ 'seed', @@ -59,10 +59,10 @@ class Planting < ActiveRecord::Base 'graft', 'layering' ] - validates :planted_from, :inclusion => { :in => PLANTED_FROM_VALUES, - :message => "%{value} is not a valid planting method" }, - :allow_nil => true, - :allow_blank => true + validates :planted_from, inclusion: { in: PLANTED_FROM_VALUES, + message: "%{value} is not a valid planting method" }, + allow_nil: true, + allow_blank: true validate :finished_must_be_after_planted @@ -95,7 +95,7 @@ class Planting < ActiveRecord::Base end def calculate_days_before_maturity(planting, crop) - p_crop = Planting.where(:crop_id => crop).where.not(:id => planting) + p_crop = Planting.where(crop_id: crop).where.not(id: planting) differences = p_crop.collect do |p| if p.finished and !p.finished_at.nil? (p.finished_at - p.planted_at).to_i diff --git a/app/models/post.rb b/app/models/post.rb index 6aaf8b72d..a6852bbb4 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1,9 +1,9 @@ class Post < ActiveRecord::Base extend FriendlyId friendly_id :author_date_subject, use: [:slugged, :finders] - belongs_to :author, :class_name => 'Member' + belongs_to :author, class_name: 'Member' belongs_to :forum - has_many :comments, :dependent => :destroy + has_many :comments, dependent: :destroy has_and_belongs_to_many :crops before_destroy {|post| post.crops.clear} after_save :update_crops_posts_association @@ -27,10 +27,10 @@ class Post < ActiveRecord::Base recipients.map{ |r| r.id }.each do |recipient| if recipient != sender Notification.create( - :recipient_id => recipient, - :sender_id => sender, - :subject => "#{self.author} mentioned you in their post #{self.subject}", - :body => self.body, + recipient_id: recipient, + sender_id: sender, + subject: "#{self.author} mentioned you in their post #{self.subject}", + body: self.body, ) end end @@ -39,10 +39,10 @@ class Post < ActiveRecord::Base default_scope { order("created_at desc") } validates :subject, - :format => { - :with => /\S/ + format: { + with: /\S/ }, - :length => { :maximum => 255 } + length: { maximum: 255 } def author_date_subject diff --git a/app/models/product.rb b/app/models/product.rb index 68d483665..942e2603b 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -3,10 +3,10 @@ class Product < ActiveRecord::Base belongs_to :account_type validates :paid_months, - :numericality => { - :only_integer => true, - :greater_than_or_equal_to => 0 }, - :allow_nil => true + numericality: { + only_integer: true, + greater_than_or_equal_to: 0 }, + allow_nil: true def to_s name diff --git a/app/models/scientific_name.rb b/app/models/scientific_name.rb index aec8f1091..2df6aa5e7 100644 --- a/app/models/scientific_name.rb +++ b/app/models/scientific_name.rb @@ -1,5 +1,5 @@ class ScientificName < ActiveRecord::Base after_commit { |sn| sn.crop.__elasticsearch__.index_document if sn.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == "true" } belongs_to :crop - belongs_to :creator, :class_name => 'Member' + belongs_to :creator, class_name: 'Member' end diff --git a/app/models/seed.rb b/app/models/seed.rb index c72187fc7..b05528680 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -3,62 +3,62 @@ class Seed < ActiveRecord::Base friendly_id :seed_slug, use: [:slugged, :finders] belongs_to :crop - belongs_to :owner, :class_name => 'Member', :foreign_key => 'owner_id' + belongs_to :owner, class_name: 'Member', foreign_key: 'owner_id' default_scope { order("created_at desc") } - validates :crop, :approved => true + 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, - :greater_than_or_equal_to => 0 }, - :allow_nil => true + numericality: { + only_integer: true, + greater_than_or_equal_to: 0 }, + allow_nil: true validates :days_until_maturity_min, - :numericality => { - :only_integer => true, - :greater_than_or_equal_to => 0 }, - :allow_nil => true + numericality: { + only_integer: true, + greater_than_or_equal_to: 0 }, + allow_nil: true validates :days_until_maturity_max, - :numericality => { - :only_integer => true, - :greater_than_or_equal_to => 0 }, - :allow_nil => true + numericality: { + only_integer: true, + greater_than_or_equal_to: 0 }, + allow_nil: true scope :tradable, -> { where("tradable_to != 'nowhere'") } TRADABLE_TO_VALUES = %w(nowhere locally nationally internationally) - validates :tradable_to, :inclusion => { :in => TRADABLE_TO_VALUES, - :message => "You may only trade seed nowhere, locally, nationally, or internationally" }, - :allow_nil => false, - :allow_blank => false + validates :tradable_to, inclusion: { in: TRADABLE_TO_VALUES, + message: "You may only trade seed nowhere, locally, nationally, or internationally" }, + allow_nil: false, + allow_blank: false ORGANIC_VALUES = [ 'certified organic', 'non-certified organic', 'conventional/non-organic', 'unknown'] - validates :organic, :inclusion => { :in => ORGANIC_VALUES, - :message => "You must say whether the seeds are organic or not, or that you don't know" }, - :allow_nil => false, - :allow_blank => false + validates :organic, inclusion: { in: ORGANIC_VALUES, + message: "You must say whether the seeds are organic or not, or that you don't know" }, + allow_nil: false, + allow_blank: false GMO_VALUES = [ 'certified GMO-free', 'non-certified GMO-free', 'GMO', 'unknown'] - validates :gmo, :inclusion => { :in => GMO_VALUES, - :message => "You must say whether the seeds are genetically modified or not, or that you don't know" }, - :allow_nil => false, - :allow_blank => false + validates :gmo, inclusion: { in: GMO_VALUES, + message: "You must say whether the seeds are genetically modified or not, or that you don't know" }, + allow_nil: false, + allow_blank: false HEIRLOOM_VALUES = %w(heirloom hybrid unknown) - validates :heirloom, :inclusion => { :in => HEIRLOOM_VALUES, - :message => "You must say whether the seeds are heirloom, hybrid, or unknown" }, - :allow_nil => false, - :allow_blank => false + validates :heirloom, inclusion: { in: HEIRLOOM_VALUES, + message: "You must say whether the seeds are heirloom, hybrid, or unknown" }, + allow_nil: false, + allow_blank: false def tradable? if self.tradable_to == 'nowhere' diff --git a/config/application.rb b/config/application.rb index 113d0bc66..facb29787 100644 --- a/config/application.rb +++ b/config/application.rb @@ -5,7 +5,7 @@ require 'openssl' if defined?(Bundler) # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups(:assets => %w(development test))) + Bundler.require(*Rails.groups(assets: %w(development test))) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end @@ -84,9 +84,9 @@ module Growstuff config.action_mailer.delivery_method = :sendmail config.action_mailer.sendmail_settings = { - :location => '/usr/sbin/sendmail', - :arguments => '-i -t', - :openssl_verify_mode => 'none' + location: '/usr/sbin/sendmail', + arguments: '-i -t', + openssl_verify_mode: 'none' } # Growstuff-specific configuration variables diff --git a/config/database.yml b/config/database.yml index 6aeb5d961..eb75b3791 100644 --- a/config/database.yml +++ b/config/database.yml @@ -3,13 +3,14 @@ development: database: growstuff_dev host: localhost user: postgres - password: password + password: postgres test: adapter: postgresql database: growstuff_test host: localhost user: postgres + password: postgres production: adapter: postgresql diff --git a/config/environments/development.rb b/config/environments/development.rb index 282071cda..700771c10 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -44,15 +44,15 @@ Growstuff::Application.configure do # config.action_view.raise_on_missing_translations = true # Growstuff config - config.action_mailer.default_url_options = { :host => 'localhost:8080' } + config.action_mailer.default_url_options = { host: 'localhost:8080' } config.action_mailer.delivery_method = :letter_opener config.action_mailer.smtp_settings = { - :port => '587', - :address => 'smtp.mandrillapp.com', - :user_name => ENV['GROWSTUFF_MANDRILL_USERNAME'], - :password => ENV['GROWSTUFF_MANDRILL_APIKEY'], - :authentication => :login + port: '587', + address: 'smtp.mandrillapp.com', + user_name: ENV['GROWSTUFF_MANDRILL_USERNAME'], + password: ENV['GROWSTUFF_MANDRILL_APIKEY'], + authentication: :login } config.host = 'localhost:8080' @@ -65,9 +65,9 @@ Growstuff::Application.configure do config.after_initialize do ActiveMerchant::Billing::Base.mode = :test paypal_options = { - :login => ENV['GROWSTUFF_PAYPAL_USERNAME'] || 'dummy', - :password => ENV['GROWSTUFF_PAYPAL_PASSWORD'] || 'dummy', - :signature => ENV['GROWSTUFF_PAYPAL_SIGNATURE'] || 'dummy' + login: ENV['GROWSTUFF_PAYPAL_USERNAME'] || 'dummy', + password: ENV['GROWSTUFF_PAYPAL_PASSWORD'] || 'dummy', + signature: ENV['GROWSTUFF_PAYPAL_SIGNATURE'] || 'dummy' } ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options) ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options) diff --git a/config/environments/production.rb b/config/environments/production.rb index 2410617fb..3b61a9255 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -67,15 +67,15 @@ Growstuff::Application.configure do config.active_record.dump_schema_after_migration = false # Growstuff configuration - config.action_mailer.default_url_options = { :host => 'growstuff.org' } + config.action_mailer.default_url_options = { host: 'growstuff.org' } config.action_mailer.smtp_settings = { - :port => '587', - :address => 'smtp.mandrillapp.com', - :user_name => ENV['GROWSTUFF_MANDRILL_USERNAME'], - :password => ENV['GROWSTUFF_MANDRILL_APIKEY'], - :domain => 'heroku.com', - :authentication => :plain + port: '587', + address: 'smtp.mandrillapp.com', + user_name: ENV['GROWSTUFF_MANDRILL_USERNAME'], + password: ENV['GROWSTUFF_MANDRILL_APIKEY'], + domain: 'heroku.com', + authentication: :plain } config.action_mailer.delivery_method = :smtp @@ -93,9 +93,9 @@ Growstuff::Application.configure do config.after_initialize do ActiveMerchant::Billing::Base.mode = :production paypal_options = { - :login => ENV['GROWSTUFF_PAYPAL_USERNAME'], - :password => ENV['GROWSTUFF_PAYPAL_PASSWORD'], - :signature => ENV['GROWSTUFF_PAYPAL_SIGNATURE'] + login: ENV['GROWSTUFF_PAYPAL_USERNAME'], + password: ENV['GROWSTUFF_PAYPAL_PASSWORD'], + signature: ENV['GROWSTUFF_PAYPAL_SIGNATURE'] } ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options) ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options) diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 4b69b498c..e9702cad0 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -69,15 +69,15 @@ Growstuff::Application.configure do config.active_record.dump_schema_after_migration = false # Growstuff configuration - config.action_mailer.default_url_options = { :host => 'staging.growstuff.org' } + config.action_mailer.default_url_options = { host: 'staging.growstuff.org' } config.action_mailer.smtp_settings = { - :port => '587', - :address => 'smtp.mandrillapp.com', - :user_name => ENV['GROWSTUFF_MANDRILL_USERNAME'], - :password => ENV['GROWSTUFF_MANDRILL_APIKEY'], - :domain => 'heroku.com', - :authentication => :plain + port: '587', + address: 'smtp.mandrillapp.com', + user_name: ENV['GROWSTUFF_MANDRILL_USERNAME'], + password: ENV['GROWSTUFF_MANDRILL_APIKEY'], + domain: 'heroku.com', + authentication: :plain } config.action_mailer.delivery_method = :smtp @@ -91,9 +91,9 @@ Growstuff::Application.configure do config.after_initialize do ActiveMerchant::Billing::Base.mode = :test paypal_options = { - :login => ENV['GROWSTUFF_PAYPAL_USERNAME'], - :password => ENV['GROWSTUFF_PAYPAL_PASSWORD'], - :signature => ENV['GROWSTUFF_PAYPAL_SIGNATURE'] + login: ENV['GROWSTUFF_PAYPAL_USERNAME'], + password: ENV['GROWSTUFF_PAYPAL_PASSWORD'], + signature: ENV['GROWSTUFF_PAYPAL_SIGNATURE'] } ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options) ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options) diff --git a/config/environments/test.rb b/config/environments/test.rb index c5c05f8d5..61eba7adc 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -40,7 +40,7 @@ Growstuff::Application.configure do # config.action_view.raise_on_missing_translations = true # Growstuff config - config.action_mailer.default_url_options = { :host => 'localhost:8080' } + config.action_mailer.default_url_options = { host: 'localhost:8080' } Growstuff::Application.configure do config.host = 'test.example.com' @@ -56,7 +56,7 @@ Growstuff::Application.configure do end -Geocoder.configure(:lookup => :test) +Geocoder.configure(lookup: :test) Geocoder::Lookup::Test.add_stub( "Amundsen-Scott Base, Antarctica", [ diff --git a/config/initializers/comfortable_mexican_sofa.rb b/config/initializers/comfortable_mexican_sofa.rb index fe6e80ace..fc5025933 100644 --- a/config/initializers/comfortable_mexican_sofa.rb +++ b/config/initializers/comfortable_mexican_sofa.rb @@ -97,7 +97,7 @@ end module CmsDeviseAuth def authenticate unless current_member && current_member.has_role?(:admin) - redirect_to root_path, :alert => 'Permission denied. Please sign in as an admin user to use the CMS admin area.' + redirect_to root_path, alert: 'Permission denied. Please sign in as an admin user to use the CMS admin area.' end end end diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb index 0d221664e..9c52ced91 100644 --- a/config/initializers/geocoder.rb +++ b/config/initializers/geocoder.rb @@ -1,9 +1,9 @@ require 'geocodable' Geocoder.configure( - :units => :km, - :timeout => 10, - :http_headers => { + units: :km, + timeout: 10, + http_headers: { "User-Agent" => "#{Growstuff::Application.config.user_agent} #{Growstuff::Application.config.user_agent_email}", "From" => Growstuff::Application.config.user_agent_email @@ -12,5 +12,5 @@ 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) + Geocoder.configure(lookup: :nominatim) end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 1aa7e772a..9980edadd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,7 +4,7 @@ Growstuff::Application.routes.draw do resources :plant_parts - devise_for :members, :controllers => { :registrations => "registrations", :passwords => "passwords" } + devise_for :members, controllers: { registrations: "registrations", passwords: "passwords" } devise_scope :member do get '/members/unsubscribe/:message' => 'members#unsubscribe', :as => 'unsubscribe_member' end @@ -13,7 +13,7 @@ Growstuff::Application.routes.draw do resources :photos - resources :authentications, :only => [:create, :destroy] + resources :authentications, only: [:create, :destroy] resources :plantings get '/plantings/owner/:owner' => 'plantings#index', :as => 'plantings_by_owner' @@ -48,7 +48,7 @@ Growstuff::Application.routes.draw do get 'reply', on: :member end - resources :follows, :only => [:create, :destroy] + resources :follows, only: [:create, :destroy] get '/members/:login_name/follows' => 'members#view_follows', :as => 'member_follows' get '/members/:login_name/followers' => 'members#view_followers', :as => 'member_followers' @@ -69,7 +69,7 @@ Growstuff::Application.routes.draw do resources :products get "home/index" - root :to => 'home#index' + root to: 'home#index' get 'auth/:provider/callback' => 'authentications#create' @@ -85,7 +85,7 @@ Growstuff::Application.routes.draw do get '/shop' => 'shop#index' get '/shop/:action' => 'shop#:action' - comfy_route :cms_admin, :path => '/admin/cms' + comfy_route :cms_admin, path: '/admin/cms' get '/admin/orders' => 'admin/orders#index' get '/admin/orders/:action' => 'admin/orders#:action' get '/admin' => 'admin#index' @@ -93,6 +93,6 @@ Growstuff::Application.routes.draw do get '/admin/:action' => 'admin#:action' # CMS stuff -- must remain LAST - comfy_route :cms, :path => '/', :sitemap => false + comfy_route :cms, path: '/', sitemap: false end diff --git a/db/migrate/20120903092956_devise_create_users.rb b/db/migrate/20120903092956_devise_create_users.rb index 2dd95591c..cb9c47966 100644 --- a/db/migrate/20120903092956_devise_create_users.rb +++ b/db/migrate/20120903092956_devise_create_users.rb @@ -2,8 +2,8 @@ class DeviseCreateUsers < ActiveRecord::Migration def change create_table(:users) do |t| ## Database authenticatable - t.string :email, :null => false, :default => "" - t.string :encrypted_password, :null => false, :default => "" + t.string :email, null: false, default: "" + t.string :encrypted_password, null: false, default: "" ## Recoverable t.string :reset_password_token @@ -13,7 +13,7 @@ class DeviseCreateUsers < ActiveRecord::Migration t.datetime :remember_created_at ## Trackable - t.integer :sign_in_count, :default => 0 + t.integer :sign_in_count, default: 0 t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip @@ -26,7 +26,7 @@ class DeviseCreateUsers < ActiveRecord::Migration t.string :unconfirmed_email # Only if using reconfirmable ## Lockable - t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts + t.integer :failed_attempts, default: 0 # Only if lock strategy is :failed_attempts t.string :unlock_token # Only if unlock strategy is :email or :both t.datetime :locked_at @@ -37,10 +37,10 @@ class DeviseCreateUsers < ActiveRecord::Migration t.timestamps end - add_index :users, :email, :unique => true - add_index :users, :reset_password_token, :unique => true - add_index :users, :confirmation_token, :unique => true - add_index :users, :unlock_token, :unique => true + add_index :users, :email, unique: true + add_index :users, :reset_password_token, unique: true + add_index :users, :confirmation_token, unique: true + add_index :users, :unlock_token, unique: true # add_index :users, :authentication_token, :unique => true end end diff --git a/db/migrate/20121003190731_require_system_name_for_crops.rb b/db/migrate/20121003190731_require_system_name_for_crops.rb index 47a46ec26..f4536c18b 100644 --- a/db/migrate/20121003190731_require_system_name_for_crops.rb +++ b/db/migrate/20121003190731_require_system_name_for_crops.rb @@ -2,13 +2,13 @@ class RequireSystemNameForCrops < ActiveRecord::Migration def up change_table :crops do |t| t.index :system_name - t.change :system_name, :string, :null => false + t.change :system_name, :string, null: false end end def down change_table :crops do |t| - t.change :system_name, :string, :null => true + t.change :system_name, :string, null: true t.remove_index :system_name end end diff --git a/db/migrate/20121105032913_create_gardens.rb b/db/migrate/20121105032913_create_gardens.rb index eaa7715d6..373179c26 100644 --- a/db/migrate/20121105032913_create_gardens.rb +++ b/db/migrate/20121105032913_create_gardens.rb @@ -1,9 +1,9 @@ class CreateGardens < ActiveRecord::Migration def change create_table :gardens do |t| - t.string :name, :null => false + t.string :name, null: false t.integer :user_id - t.string :slug, :null => false + t.string :slug, null: false t.timestamps end diff --git a/db/migrate/20121107012827_create_scientific_names.rb b/db/migrate/20121107012827_create_scientific_names.rb index 4651a5b91..36140e27a 100644 --- a/db/migrate/20121107012827_create_scientific_names.rb +++ b/db/migrate/20121107012827_create_scientific_names.rb @@ -1,8 +1,8 @@ class CreateScientificNames < ActiveRecord::Migration def change create_table :scientific_names do |t| - t.string :scientific_name, :null => false - t.integer :crop_id, :null => false + t.string :scientific_name, null: false + t.integer :crop_id, null: false t.timestamps end diff --git a/db/migrate/20121108105440_create_updates.rb b/db/migrate/20121108105440_create_updates.rb index fa96f17a5..a2b29ed03 100644 --- a/db/migrate/20121108105440_create_updates.rb +++ b/db/migrate/20121108105440_create_updates.rb @@ -1,9 +1,9 @@ class CreateUpdates < ActiveRecord::Migration def change create_table :updates do |t| - t.integer :user_id, :null => false - t.string :subject, :null => false - t.text :body, :null => false + t.integer :user_id, null: false + t.string :subject, null: false + t.text :body, null: false t.timestamps end diff --git a/db/migrate/20121219022554_create_plantings.rb b/db/migrate/20121219022554_create_plantings.rb index 2c50a7813..7fe96782e 100644 --- a/db/migrate/20121219022554_create_plantings.rb +++ b/db/migrate/20121219022554_create_plantings.rb @@ -1,8 +1,8 @@ class CreatePlantings < ActiveRecord::Migration def change create_table :plantings do |t| - t.integer :garden_id, :null => false - t.integer :crop_id, :null => false + t.integer :garden_id, null: false + t.integer :crop_id, null: false t.datetime :planted_at t.integer :quantity t.text :description diff --git a/db/migrate/20130208034248_require_fields_for_comments.rb b/db/migrate/20130208034248_require_fields_for_comments.rb index c1adea261..ecb17f302 100644 --- a/db/migrate/20130208034248_require_fields_for_comments.rb +++ b/db/migrate/20130208034248_require_fields_for_comments.rb @@ -1,17 +1,17 @@ class RequireFieldsForComments < ActiveRecord::Migration def up change_table :comments do |t| - t.change :post_id, :integer, :null => false - t.change :author_id, :integer, :null => false - t.change :body, :text, :null => false + t.change :post_id, :integer, null: false + t.change :author_id, :integer, null: false + t.change :body, :text, null: false end end def down change_table :comments do |t| - t.change :post_id, :integer, :null => true - t.change :author_id, :integer, :null => true - t.change :body, :text, :null => true + t.change :post_id, :integer, null: true + t.change :author_id, :integer, null: true + t.change :body, :text, null: true end end end diff --git a/db/migrate/20130212123628_create_notifications.rb b/db/migrate/20130212123628_create_notifications.rb index 0bb5e1bec..03ca126a8 100644 --- a/db/migrate/20130212123628_create_notifications.rb +++ b/db/migrate/20130212123628_create_notifications.rb @@ -2,7 +2,7 @@ class CreateNotifications < ActiveRecord::Migration def change create_table :notifications do |t| t.integer :from_id - t.integer :to_id, :null => false + t.integer :to_id, null: false t.string :subject t.text :body t.boolean :read diff --git a/db/migrate/20130213014511_create_forums.rb b/db/migrate/20130213014511_create_forums.rb index 6388876e6..1969b09dc 100644 --- a/db/migrate/20130213014511_create_forums.rb +++ b/db/migrate/20130213014511_create_forums.rb @@ -1,9 +1,9 @@ class CreateForums < ActiveRecord::Migration def change create_table :forums do |t| - t.string :name, :null => false - t.text :description, :null => false - t.integer :owner_id, :null => false + t.string :name, null: false + t.text :description, null: false + t.integer :owner_id, null: false t.timestamps end diff --git a/db/migrate/20130214024117_create_roles.rb b/db/migrate/20130214024117_create_roles.rb index 8ccaf5ca6..8797691d5 100644 --- a/db/migrate/20130214024117_create_roles.rb +++ b/db/migrate/20130214024117_create_roles.rb @@ -1,7 +1,7 @@ class CreateRoles < ActiveRecord::Migration def change create_table :roles do |t| - t.string :name, :null => false + t.string :name, null: false t.text :description t.timestamps diff --git a/db/migrate/20130214034838_add_members_roles_table.rb b/db/migrate/20130214034838_add_members_roles_table.rb index a8044ebc8..9e84fd37d 100644 --- a/db/migrate/20130214034838_add_members_roles_table.rb +++ b/db/migrate/20130214034838_add_members_roles_table.rb @@ -1,6 +1,6 @@ class AddMembersRolesTable < ActiveRecord::Migration def change - create_table :members_roles, :id => false do |t| + create_table :members_roles, id: false do |t| t.integer :member_id t.integer :role_id end diff --git a/db/migrate/20130222060730_default_read_to_false.rb b/db/migrate/20130222060730_default_read_to_false.rb index b7250b8c6..efe6d4b61 100644 --- a/db/migrate/20130222060730_default_read_to_false.rb +++ b/db/migrate/20130222060730_default_read_to_false.rb @@ -1,13 +1,13 @@ class DefaultReadToFalse < ActiveRecord::Migration def up change_table :notifications do |t| - t.change :read, :boolean, :default => false + t.change :read, :boolean, default: false end end def down change_table :notifications do |t| - t.change :read, :boolean, :default => nil + t.change :read, :boolean, default: nil end end end diff --git a/db/migrate/20130327120024_add_send_email_to_member.rb b/db/migrate/20130327120024_add_send_email_to_member.rb index b52c5fdb2..b83dd9e03 100644 --- a/db/migrate/20130327120024_add_send_email_to_member.rb +++ b/db/migrate/20130327120024_add_send_email_to_member.rb @@ -1,5 +1,5 @@ class AddSendEmailToMember < ActiveRecord::Migration def change - add_column :members, :send_notification_email, :boolean, :default => true + add_column :members, :send_notification_email, :boolean, default: true end end diff --git a/db/migrate/20130404174459_create_authentications.rb b/db/migrate/20130404174459_create_authentications.rb index 3acdf6080..aeeb109da 100644 --- a/db/migrate/20130404174459_create_authentications.rb +++ b/db/migrate/20130404174459_create_authentications.rb @@ -1,8 +1,8 @@ class CreateAuthentications < ActiveRecord::Migration def change create_table :authentications do |t| - t.integer :member_id, :null => false - t.string :provider, :null => false + t.integer :member_id, null: false + t.string :provider, null: false t.string :uid t.string :token t.string :secret diff --git a/db/migrate/20130409103549_make_post_subject_non_null.rb b/db/migrate/20130409103549_make_post_subject_non_null.rb index 0a7f8db34..877bd048f 100644 --- a/db/migrate/20130409103549_make_post_subject_non_null.rb +++ b/db/migrate/20130409103549_make_post_subject_non_null.rb @@ -1,3 +1,3 @@ class MakePostSubjectNonNull < ActiveRecord::Migration - change_column :posts, :subject, :string, :null => false + change_column :posts, :subject, :string, null: false end diff --git a/db/migrate/20130507105357_create_products.rb b/db/migrate/20130507105357_create_products.rb index 0ad9b1063..8e8901293 100644 --- a/db/migrate/20130507105357_create_products.rb +++ b/db/migrate/20130507105357_create_products.rb @@ -1,9 +1,9 @@ class CreateProducts < ActiveRecord::Migration def change create_table :products do |t| - t.string :name, :null => false - t.string :description, :null => false - t.decimal :min_price, :null => false + t.string :name, null: false + t.string :description, null: false + t.decimal :min_price, null: false t.timestamps end diff --git a/db/migrate/20130507110411_create_orders.rb b/db/migrate/20130507110411_create_orders.rb index 0aed92dfb..7cde95ad2 100644 --- a/db/migrate/20130507110411_create_orders.rb +++ b/db/migrate/20130507110411_create_orders.rb @@ -1,7 +1,7 @@ class CreateOrders < ActiveRecord::Migration def change create_table :orders do |t| - t.string :member_id, :null => false + t.string :member_id, null: false t.timestamps end diff --git a/db/migrate/20130507113915_add_orders_products_table.rb b/db/migrate/20130507113915_add_orders_products_table.rb index 92af21427..8666e01ab 100644 --- a/db/migrate/20130507113915_add_orders_products_table.rb +++ b/db/migrate/20130507113915_add_orders_products_table.rb @@ -1,6 +1,6 @@ class AddOrdersProductsTable < ActiveRecord::Migration def change - create_table :orders_products, :id => false do |t| + create_table :orders_products, id: false do |t| t.integer :order_id t.integer :product_id end diff --git a/db/migrate/20130508104506_create_photos.rb b/db/migrate/20130508104506_create_photos.rb index f7c56188d..f6c908529 100644 --- a/db/migrate/20130508104506_create_photos.rb +++ b/db/migrate/20130508104506_create_photos.rb @@ -1,10 +1,10 @@ class CreatePhotos < ActiveRecord::Migration def change create_table :photos do |t| - t.integer :owner_id, :null => false - t.integer :flickr_photo_id, :null => false - t.string :thumbnail_url, :null => false - t.string :fullsize_url, :null => false + t.integer :owner_id, null: false + t.integer :flickr_photo_id, null: false + t.string :thumbnail_url, null: false + t.string :fullsize_url, null: false t.timestamps end diff --git a/db/migrate/20130509123711_add_metadata_to_photos.rb b/db/migrate/20130509123711_add_metadata_to_photos.rb index 9e73a6272..cb76a901a 100644 --- a/db/migrate/20130509123711_add_metadata_to_photos.rb +++ b/db/migrate/20130509123711_add_metadata_to_photos.rb @@ -5,9 +5,9 @@ class AddMetadataToPhotos < ActiveRecord::Migration t.string :license_name t.string :license_url t.string :link_url - t.change :title, :string, :null => false - t.change :license_name, :string, :null => false - t.change :link_url, :string, :null => false + t.change :title, :string, null: false + t.change :license_name, :string, null: false + t.change :link_url, :string, null: false end end diff --git a/db/migrate/20130517015920_create_account_details.rb b/db/migrate/20130517015920_create_account_details.rb index 8eb899fd5..99f4c4eb8 100644 --- a/db/migrate/20130517015920_create_account_details.rb +++ b/db/migrate/20130517015920_create_account_details.rb @@ -1,7 +1,7 @@ class CreateAccountDetails < ActiveRecord::Migration def change create_table :account_details do |t| - t.integer :member_id, :null => false + t.integer :member_id, null: false t.integer :account_type_id t.datetime :paid_until diff --git a/db/migrate/20130517234458_require_account_type_name.rb b/db/migrate/20130517234458_require_account_type_name.rb index c4bdfa69a..6e745cb4b 100644 --- a/db/migrate/20130517234458_require_account_type_name.rb +++ b/db/migrate/20130517234458_require_account_type_name.rb @@ -1,9 +1,9 @@ class RequireAccountTypeName < ActiveRecord::Migration def up - change_column :account_types, :name, :string, :null => false + change_column :account_types, :name, :string, null: false end def down - change_column :account_types, :name, :string, :null => true + change_column :account_types, :name, :string, null: true end end diff --git a/db/migrate/20130531110729_add_photos_plantings_table.rb b/db/migrate/20130531110729_add_photos_plantings_table.rb index 07040ed93..ab08ff0d1 100644 --- a/db/migrate/20130531110729_add_photos_plantings_table.rb +++ b/db/migrate/20130531110729_add_photos_plantings_table.rb @@ -1,6 +1,6 @@ class AddPhotosPlantingsTable < ActiveRecord::Migration def change - create_table :photos_plantings, :id => false do |t| + create_table :photos_plantings, id: false do |t| t.integer :photo_id t.integer :planting_id end diff --git a/db/migrate/20130715110134_create_seeds.rb b/db/migrate/20130715110134_create_seeds.rb index 1d0d49225..d5ece87ec 100644 --- a/db/migrate/20130715110134_create_seeds.rb +++ b/db/migrate/20130715110134_create_seeds.rb @@ -1,8 +1,8 @@ class CreateSeeds < ActiveRecord::Migration def change create_table :seeds do |t| - t.integer :owner_id, :null => false - t.integer :crop_id, :null => false + t.integer :owner_id, null: false + t.integer :crop_id, null: false t.text :description t.integer :quantity t.date :use_by diff --git a/db/migrate/20130917053547_create_harvests.rb b/db/migrate/20130917053547_create_harvests.rb index e7b7db6b4..8a808ac1a 100644 --- a/db/migrate/20130917053547_create_harvests.rb +++ b/db/migrate/20130917053547_create_harvests.rb @@ -1,8 +1,8 @@ class CreateHarvests < ActiveRecord::Migration def change create_table :harvests do |t| - t.integer :crop_id, :null => false - t.integer :owner_id, :null => false + t.integer :crop_id, null: false + t.integer :owner_id, null: false t.date :harvested_at t.decimal :quantity t.string :units diff --git a/db/migrate/20131025104228_add_fields_to_gardens.rb b/db/migrate/20131025104228_add_fields_to_gardens.rb index 24b73c966..2c3983507 100644 --- a/db/migrate/20131025104228_add_fields_to_gardens.rb +++ b/db/migrate/20131025104228_add_fields_to_gardens.rb @@ -1,6 +1,6 @@ class AddFieldsToGardens < ActiveRecord::Migration def change - add_column :gardens, :active, :boolean, :default => true + add_column :gardens, :active, :boolean, default: true add_column :gardens, :location, :string add_column :gardens, :latitude, :float add_column :gardens, :longitude, :float diff --git a/db/migrate/20140718075753_default_plantings_count_to_zero.rb b/db/migrate/20140718075753_default_plantings_count_to_zero.rb index 608821fbc..ce8d0d075 100644 --- a/db/migrate/20140718075753_default_plantings_count_to_zero.rb +++ b/db/migrate/20140718075753_default_plantings_count_to_zero.rb @@ -1,9 +1,9 @@ class DefaultPlantingsCountToZero < ActiveRecord::Migration def up - change_column :crops, :plantings_count, :integer, :default => 0 + change_column :crops, :plantings_count, :integer, default: 0 end def down - change_column :crops, :plantings_count, :integer, :default => nil + change_column :crops, :plantings_count, :integer, default: nil end end diff --git a/db/migrate/20140829230600_add_finished_to_planting.rb b/db/migrate/20140829230600_add_finished_to_planting.rb index 8be30756a..f8cb41663 100644 --- a/db/migrate/20140829230600_add_finished_to_planting.rb +++ b/db/migrate/20140829230600_add_finished_to_planting.rb @@ -1,6 +1,6 @@ class AddFinishedToPlanting < ActiveRecord::Migration def change - add_column :plantings, :finished, :boolean, :default => false + add_column :plantings, :finished, :boolean, default: false add_column :plantings, :finished_at, :date end end diff --git a/db/migrate/20140905001730_add_harvests_photos_table.rb b/db/migrate/20140905001730_add_harvests_photos_table.rb index edacd061b..fb9c73a37 100644 --- a/db/migrate/20140905001730_add_harvests_photos_table.rb +++ b/db/migrate/20140905001730_add_harvests_photos_table.rb @@ -1,6 +1,6 @@ class AddHarvestsPhotosTable < ActiveRecord::Migration def change - create_table :harvests_photos, :id => false do |t| + create_table :harvests_photos, id: false do |t| t.integer :photo_id t.integer :harvest_id end diff --git a/db/migrate/20140928044231_add_crops_posts_table.rb b/db/migrate/20140928044231_add_crops_posts_table.rb index a8c06927b..6f200c3d8 100644 --- a/db/migrate/20140928044231_add_crops_posts_table.rb +++ b/db/migrate/20140928044231_add_crops_posts_table.rb @@ -1,6 +1,6 @@ class AddCropsPostsTable < ActiveRecord::Migration def change - create_table :crops_posts, :id => false do |t| + create_table :crops_posts, id: false do |t| t.integer :crop_id t.integer :post_id end diff --git a/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb b/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb index e6a5ec214..67c7184d7 100644 --- a/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb +++ b/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb @@ -1,5 +1,5 @@ class AddSendPlantingReminderToMember < ActiveRecord::Migration def change - add_column :members, :send_planting_reminder, :boolean, :default => true + add_column :members, :send_planting_reminder, :boolean, default: true end end diff --git a/db/migrate/20141018111015_create_alternate_names.rb b/db/migrate/20141018111015_create_alternate_names.rb index 8a63471c8..7364fceb0 100644 --- a/db/migrate/20141018111015_create_alternate_names.rb +++ b/db/migrate/20141018111015_create_alternate_names.rb @@ -1,9 +1,9 @@ class CreateAlternateNames < ActiveRecord::Migration def change create_table :alternate_names do |t| - t.string :name, :null => false - t.integer :crop_id, :null => false - t.integer :creator_id, :null => false + t.string :name, null: false + t.integer :crop_id, null: false + t.integer :creator_id, null: false t.timestamps end diff --git a/db/migrate/20150124110540_add_properties_to_seeds.rb b/db/migrate/20150124110540_add_properties_to_seeds.rb index e2fa64fe7..7d60735fd 100644 --- a/db/migrate/20150124110540_add_properties_to_seeds.rb +++ b/db/migrate/20150124110540_add_properties_to_seeds.rb @@ -2,8 +2,8 @@ class AddPropertiesToSeeds < ActiveRecord::Migration def change add_column :seeds, :days_until_maturity_min, :integer add_column :seeds, :days_until_maturity_max, :integer - add_column :seeds, :organic, :text, :default => 'unknown' - add_column :seeds, :gmo, :text, :default => 'unknown' - add_column :seeds, :heirloom, :text, :default => 'unknown' + add_column :seeds, :organic, :text, default: 'unknown' + add_column :seeds, :gmo, :text, default: 'unknown' + add_column :seeds, :heirloom, :text, default: 'unknown' end end diff --git a/db/migrate/20150127043022_add_gardens_photos_table.rb b/db/migrate/20150127043022_add_gardens_photos_table.rb index c0cfd76fc..7e8f8bd81 100644 --- a/db/migrate/20150127043022_add_gardens_photos_table.rb +++ b/db/migrate/20150127043022_add_gardens_photos_table.rb @@ -1,6 +1,6 @@ class AddGardensPhotosTable < ActiveRecord::Migration def change - create_table :gardens_photos, :id => false do |t| + create_table :gardens_photos, id: false do |t| t.integer :photo_id t.integer :garden_id end diff --git a/db/migrate/20150201052245_create_cms.rb b/db/migrate/20150201052245_create_cms.rb index 9e999488f..0a29e2b6d 100644 --- a/db/migrate/20150201052245_create_cms.rb +++ b/db/migrate/20150201052245_create_cms.rb @@ -6,52 +6,52 @@ class CreateCms < ActiveRecord::Migration when 'PostgreSQL' { } else - { :limit => 16777215 } + { limit: 16777215 } end # -- Sites -------------------------------------------------------------- create_table :comfy_cms_sites do |t| - t.string :label, :null => false - t.string :identifier, :null => false - t.string :hostname, :null => false + t.string :label, null: false + t.string :identifier, null: false + t.string :hostname, null: false t.string :path - t.string :locale, :null => false, :default => 'en' - t.boolean :is_mirrored, :null => false, :default => false + t.string :locale, null: false, default: 'en' + t.boolean :is_mirrored, null: false, default: false end add_index :comfy_cms_sites, :hostname add_index :comfy_cms_sites, :is_mirrored # -- Layouts ------------------------------------------------------------ create_table :comfy_cms_layouts do |t| - t.integer :site_id, :null => false + t.integer :site_id, null: false t.integer :parent_id t.string :app_layout - t.string :label, :null => false - t.string :identifier, :null => false + t.string :label, null: false + t.string :identifier, null: false t.text :content, text_limit t.text :css, text_limit t.text :js, text_limit - t.integer :position, :null => false, :default => 0 - t.boolean :is_shared, :null => false, :default => false + t.integer :position, null: false, default: 0 + t.boolean :is_shared, null: false, default: false t.timestamps end add_index :comfy_cms_layouts, [:parent_id, :position] - add_index :comfy_cms_layouts, [:site_id, :identifier], :unique => true + add_index :comfy_cms_layouts, [:site_id, :identifier], unique: true # -- Pages -------------------------------------------------------------- create_table :comfy_cms_pages do |t| - t.integer :site_id, :null => false + t.integer :site_id, null: false 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.string :full_path, null: false t.text :content_cache, text_limit - t.integer :position, :null => false, :default => 0 - t.integer :children_count, :null => false, :default => 0 - t.boolean :is_published, :null => false, :default => true - t.boolean :is_shared, :null => false, :default => false + t.integer :position, null: false, default: 0 + t.integer :children_count, null: false, default: 0 + t.boolean :is_published, null: false, default: true + t.boolean :is_shared, null: false, default: false t.timestamps end add_index :comfy_cms_pages, [:site_id, :full_path] @@ -59,9 +59,9 @@ class CreateCms < ActiveRecord::Migration # -- Page Blocks -------------------------------------------------------- create_table :comfy_cms_blocks do |t| - t.string :identifier, :null => false + t.string :identifier, null: false t.text :content, text_limit - t.references :blockable, :polymorphic => true + t.references :blockable, polymorphic: true t.timestamps end add_index :comfy_cms_blocks, [:identifier] @@ -69,27 +69,27 @@ class CreateCms < ActiveRecord::Migration # -- Snippets ----------------------------------------------------------- create_table :comfy_cms_snippets do |t| - t.integer :site_id, :null => false - t.string :label, :null => false - t.string :identifier, :null => false + t.integer :site_id, null: false + t.string :label, null: false + t.string :identifier, null: false t.text :content, text_limit - t.integer :position, :null => false, :default => 0 - t.boolean :is_shared, :null => false, :default => false + t.integer :position, null: false, default: 0 + t.boolean :is_shared, null: false, default: false t.timestamps end - add_index :comfy_cms_snippets, [:site_id, :identifier], :unique => true + add_index :comfy_cms_snippets, [:site_id, :identifier], unique: true add_index :comfy_cms_snippets, [:site_id, :position] # -- 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 - t.string :file_content_type, :null => false - t.integer :file_file_size, :null => false - t.string :description, :limit => 2048 - t.integer :position, :null => false, :default => 0 + t.string :label, null: false + t.string :file_file_name, null: false + t.string :file_content_type, null: false + t.integer :file_file_size, null: false + t.string :description, limit: 2048 + t.integer :position, null: false, default: 0 t.timestamps end add_index :comfy_cms_files, [:site_id, :label] @@ -98,31 +98,31 @@ class CreateCms < ActiveRecord::Migration add_index :comfy_cms_files, [:site_id, :block_id] # -- Revisions ----------------------------------------------------------- - create_table :comfy_cms_revisions, :force => true do |t| - t.string :record_type, :null => false - t.integer :record_id, :null => false + create_table :comfy_cms_revisions, force: true do |t| + t.string :record_type, null: false + t.integer :record_id, null: false t.text :data, text_limit t.datetime :created_at end add_index :comfy_cms_revisions, [:record_type, :record_id, :created_at], - :name => 'index_cms_revisions_on_rtype_and_rid_and_created_at' + name: 'index_cms_revisions_on_rtype_and_rid_and_created_at' # -- Categories --------------------------------------------------------- - create_table :comfy_cms_categories, :force => true do |t| - t.integer :site_id, :null => false - t.string :label, :null => false - t.string :categorized_type, :null => false + create_table :comfy_cms_categories, force: true do |t| + t.integer :site_id, null: false + t.string :label, null: false + t.string :categorized_type, null: false end - add_index :comfy_cms_categories, [:site_id, :categorized_type, :label], :unique => true, - :name => 'index_cms_categories_on_site_id_and_cat_type_and_label' + add_index :comfy_cms_categories, [:site_id, :categorized_type, :label], unique: true, + name: 'index_cms_categories_on_site_id_and_cat_type_and_label' - create_table :comfy_cms_categorizations, :force => true do |t| - t.integer :category_id, :null => false - t.string :categorized_type, :null => false - t.integer :categorized_id, :null => false + create_table :comfy_cms_categorizations, force: true do |t| + t.integer :category_id, null: false + t.string :categorized_type, null: false + t.integer :categorized_id, null: false end - add_index :comfy_cms_categorizations, [:category_id, :categorized_type, :categorized_id], :unique => true, - :name => 'index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id' + add_index :comfy_cms_categorizations, [:category_id, :categorized_type, :categorized_id], unique: true, + name: 'index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id' end def self.down diff --git a/db/seeds.rb b/db/seeds.rb index 37fb28204..f1b8d67cb 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -39,22 +39,22 @@ end def load_roles puts "Creating admin role..." - @admin = Role.create(:name => 'Admin') + @admin = Role.create(name: 'Admin') puts "Creating crop wrangler role..." - @wrangler = Role.create(:name => 'Crop Wrangler') + @wrangler = Role.create(name: 'Crop Wrangler') end def load_basic_account_types puts "Adding 'free' and 'staff' account types..." AccountType.create!( - :name => "Free", - :is_paid => false, - :is_permanent_paid => false + name: "Free", + is_paid: false, + is_permanent_paid: false ) AccountType.create!( - :name => "Staff", - :is_paid => true, - :is_permanent_paid => true + name: "Staff", + is_paid: true, + is_permanent_paid: true ) end @@ -75,10 +75,10 @@ def load_test_users (1..member_size).each do |i| @user = Member.new( - :login_name => "test#{i}", - :email => "test#{i}@example.com", - :password => "password#{i}", - :tos_agreement => true + login_name: "test#{i}", + email: "test#{i}@example.com", + password: "password#{i}", + tos_agreement: true ) @user.skip_confirmation! @user.save! @@ -112,20 +112,20 @@ end def load_admin_users puts "Adding admin and crop wrangler members..." @admin_user = Member.new( - :login_name => "admin1", - :email => "admin1@example.com", - :password => "password1", - :tos_agreement => true + login_name: "admin1", + email: "admin1@example.com", + password: "password1", + tos_agreement: true ) @admin_user.skip_confirmation! @admin_user.roles << @admin @admin_user.save! @wrangler_user = Member.new( - :login_name => "wrangler1", - :email => "wrangler1@example.com", - :password => "password1", - :tos_agreement => true + login_name: "wrangler1", + email: "wrangler1@example.com", + password: "password1", + tos_agreement: true ) @wrangler_user.skip_confirmation! @wrangler_user.roles << @wrangler @@ -134,10 +134,10 @@ end def create_cropbot @cropbot_user = Member.new( - :login_name => "cropbot", - :email => Growstuff::Application.config.bot_email, - :password => SecureRandom.urlsafe_base64(64), - :tos_agreement => true + login_name: "cropbot", + email: Growstuff::Application.config.bot_email, + password: SecureRandom.urlsafe_base64(64), + tos_agreement: true ) @cropbot_user.skip_confirmation! @cropbot_user.roles << @wrangler @@ -149,31 +149,31 @@ end def load_paid_account_types puts "Adding 'paid' and 'seed' account types..." @paid_account = AccountType.create!( - :name => "Paid", - :is_paid => true, - :is_permanent_paid => false + name: "Paid", + is_paid: true, + is_permanent_paid: false ) @seed_account = AccountType.create!( - :name => "Seed", - :is_paid => true, - :is_permanent_paid => true + name: "Seed", + is_paid: true, + is_permanent_paid: true ) end def load_products puts "Adding products..." Product.create!( - :name => "Annual subscription", - :description => "Paid account, 1 year", - :min_price => 3000, - :account_type_id => @paid_account.id, - :paid_months => 12 + name: "Annual subscription", + description: "Paid account, 1 year", + min_price: 3000, + account_type_id: @paid_account.id, + paid_months: 12 ) Product.create!( - :name => "Seed account", - :description => "Paid account, in perpetuity", - :min_price => 15000, - :account_type_id => @seed_account.id, + name: "Seed account", + description: "Paid account, in perpetuity", + min_price: 15000, + account_type_id: @seed_account.id, ) end diff --git a/lib/haml/filters/growstuff_markdown.rb b/lib/haml/filters/growstuff_markdown.rb index 6711461e0..bb665e810 100644 --- a/lib/haml/filters/growstuff_markdown.rb +++ b/lib/haml/filters/growstuff_markdown.rb @@ -16,7 +16,7 @@ module Haml::Filters # find crop case-insensitively crop = Crop.where('lower(name) = ?', crop_str.downcase).first if crop - url = Rails.application.routes.url_helpers.crop_url(crop, :host => Growstuff::Application.config.host) + url = Rails.application.routes.url_helpers.crop_url(crop, host: Growstuff::Application.config.host) "[#{crop_str}](#{url})" else crop_str @@ -29,7 +29,7 @@ module Haml::Filters # find member case-insensitively member = Member.where('lower(login_name) = ?', member_str.downcase).first if member - url = Rails.application.routes.url_helpers.member_url(member, :only_path => true) + url = Rails.application.routes.url_helpers.member_url(member, only_path: true) "[#{member_str}](#{url})" else member_str @@ -42,7 +42,7 @@ module Haml::Filters # find member case-insensitively member = Member.where('lower(login_name) = ?', member_str[1..-1].downcase).first if member - url = Rails.application.routes.url_helpers.member_url(member, :only_path => true) + url = Rails.application.routes.url_helpers.member_url(member, only_path: true) "[#{member_str}](#{url})" else member_str diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake index bfb7b8642..58372327a 100644 --- a/lib/tasks/growstuff.rake +++ b/lib/tasks/growstuff.rake @@ -3,7 +3,7 @@ namespace :growstuff do desc "Add an admin user, by name" # usage: rake growstuff:admin_user name=skud - task :admin_user => :environment do + task admin_user: :environment do member = Member.find_by_login_name(ENV['name']) or raise "Usage: rake growstuff:admin_user name=whoever (login name is case-sensitive)" admin = Role.find('admin') member.roles << admin @@ -12,7 +12,7 @@ namespace :growstuff do desc "Add a crop wrangler user, by name" # usage: rake growstuff:cropwrangler_user name=skud - task :cropwrangler_user => :environment do + task cropwrangler_user: :environment do member = Member.find_by_login_name(ENV['name']) or raise "Usage: rake growstuff:cropwrangler_user name=whoever (login name is case-sensitive)" cw = Role.find('crop-wrangler') member.roles << cw @@ -21,7 +21,7 @@ namespace :growstuff do desc "Upload crops from a CSV file" # usage: rake growstuff:import_crops file=filename.csv - task :import_crops => :environment do + task import_crops: :environment do require 'csv' @file = ENV['file'] or raise "Usage: rake growstuff:import_crops file=file.csv" @@ -38,7 +38,7 @@ namespace :growstuff do desc "Send planting reminder email" # usage: rake growstuff:send_planting_reminder - task :send_planting_reminder => :environment do + task send_planting_reminder: :environment do # Heroku scheduler only lets us run things daily, so this checks # whether it's the right day to actually do the deed. # Note that Heroku scheduler runs on UTC. @@ -56,7 +56,7 @@ namespace :growstuff do desc "Depopulate Null Island" # this fixes up anyone who has erroneously wound up with a 0,0 lat/long - task :depopulate_null_island => :environment do + task depopulate_null_island: :environment do Member.find_each do |m| if m.location and (m.latitude == nil and m.longitude == nil) m.geocode @@ -69,7 +69,7 @@ namespace :growstuff do namespace :oneoff do desc "May 2013: replace any empty notification subjects with (no subject)" - task :empty_subjects => :environment do + task empty_subjects: :environment do # this is inefficient as it checks every Notification, but the # site is small and there aren't many of them, so it shouldn't matter @@ -81,7 +81,7 @@ namespace :growstuff do end desc "May 2013: replace any empty garden names with Garden" - task :empty_garden_names => :environment do + task empty_garden_names: :environment do # this is inefficient as it checks every Garden, but the # site is small and there aren't many of them, so it shouldn't matter @@ -96,48 +96,48 @@ namespace :growstuff do desc "June 2013: create account types and products." - task :setup_shop => :environment do + task setup_shop: :environment do puts "Adding account types..." AccountType.find_or_create_by( - :name => "Free", - :is_paid => false, - :is_permanent_paid => false + name: "Free", + is_paid: false, + is_permanent_paid: false ) @paid_account = AccountType.find_or_create_by( - :name => "Paid", - :is_paid => true, - :is_permanent_paid => false + name: "Paid", + is_paid: true, + is_permanent_paid: false ) @seed_account = AccountType.find_or_create_by( - :name => "Seed", - :is_paid => true, - :is_permanent_paid => true + name: "Seed", + is_paid: true, + is_permanent_paid: true ) @staff_account = AccountType.find_or_create_by( - :name => "Staff", - :is_paid => true, - :is_permanent_paid => true + name: "Staff", + is_paid: true, + is_permanent_paid: true ) puts "Adding products..." Product.find_or_create_by( - :name => "Annual subscription", - :description => "An annual subscription gives you access to paid account features for one year. Does not auto-renew.", - :min_price => 3000, - :account_type_id => @paid_account.id, - :paid_months => 12 + name: "Annual subscription", + description: "An annual subscription gives you access to paid account features for one year. Does not auto-renew.", + min_price: 3000, + account_type_id: @paid_account.id, + paid_months: 12 ) Product.find_or_create_by( - :name => "Seed account", - :description => "A seed account helps Growstuff grow in its early days. It gives you all the features of a paid account, in perpetuity. This account type never expires.", - :min_price => 15000, - :account_type_id => @seed_account.id, + name: "Seed account", + description: "A seed account helps Growstuff grow in its early days. It gives you all the features of a paid account, in perpetuity. This account type never expires.", + min_price: 15000, + account_type_id: @seed_account.id, ) puts "Giving each member an account record..." Member.all.each do |m| unless m.account - Account.create(:member_id => m.id) + Account.create(member_id: m.id) end end @@ -152,7 +152,7 @@ namespace :growstuff do end desc "June 2013: replace nil account_types with free accounts" - task :nil_account_type => :environment do + task nil_account_type: :environment do free = AccountType.find_by_name("Free") raise "Free account type not found: run rake growstuff:oneoff:setup_shop"\ @@ -166,7 +166,7 @@ namespace :growstuff do end desc "July 2013: replace nil seed.tradable_to with nowhere" - task :tradable_to_nowhere => :environment do + task tradable_to_nowhere: :environment do Seed.all.each do |s| unless s.tradable_to @@ -177,7 +177,7 @@ namespace :growstuff do end desc "August 2013: set up plantings_count cache on crop" - task :reset_crop_plantings_count => :environment do + task reset_crop_plantings_count: :environment do Crop.find_each do |c| Crop.reset_counters c.id, :plantings @@ -185,7 +185,7 @@ namespace :growstuff do end desc "August 2013: set default creator on existing crops" - task :set_default_crop_creator => :environment do + task set_default_crop_creator: :environment do cropbot = Member.find_by_login_name("cropbot") raise "cropbot not found: create cropbot member on site or run rake db:seed" unless cropbot @@ -207,7 +207,7 @@ namespace :growstuff do end desc "August 2013: set planting owner" - task :set_planting_owner => :environment do + task set_planting_owner: :environment do Planting.find_each do |p| p.owner = p.garden.owner p.save @@ -215,14 +215,14 @@ namespace :growstuff do end desc "August 2013: initialize member planting counter" - task :initialize_member_planting_count => :environment do + task initialize_member_planting_count: :environment do Member.find_each do |m| Member.reset_counters m.id, :plantings end end desc "October 2013: set garden locations to member locations" - task :initialize_garden_locations => :environment do + task initialize_garden_locations: :environment do Member.located.find_each do |m| m.gardens.each do |g| if g.location.blank? @@ -236,7 +236,7 @@ namespace :growstuff do end desc "October 2013: import initial plant parts" - task :import_plant_parts => :environment do + task import_plant_parts: :environment do plant_parts = [ 'fruit', 'flower', @@ -257,7 +257,7 @@ namespace :growstuff do end desc "July 2014: set planting_count to 0 by default, not nil" - task :zero_plantings_count => :environment do + task zero_plantings_count: :environment do Crop.find_each do |c| if c.plantings_count.nil? c.plantings_count = 0 @@ -267,7 +267,7 @@ namespace :growstuff do end desc "August 2014: fix ping to pint in database" - task :ping_to_pint => :environment do + task ping_to_pint: :environment do Harvest.find_each do |h| if h.unit == "ping" h.unit = "pint" @@ -277,21 +277,21 @@ namespace :growstuff do end desc "October 2014: remove unused photos" - task :remove_unused_photos => :environment do + task remove_unused_photos: :environment do Photo.find_each do |p| p.destroy_if_unused end end desc "October 2014: generate crops_posts records for existing posts" - task :generate_crops_posts_records => :environment do + task generate_crops_posts_records: :environment do Post.find_each do |p| p.save end end desc "October 2014: add alternate names for crops" - task :add_alternate_names => :environment do + task add_alternate_names: :environment do require 'csv' file = "db/seeds/alternate_names_201410.csv" puts "Loading alternate names from #{file}..." @@ -316,7 +316,7 @@ namespace :growstuff do end desc "January 2015: fill in si_weight column" - task :populate_si_weight => :environment do + task populate_si_weight: :environment do Harvest.find_each do |h| h.set_si_weight h.save @@ -324,7 +324,7 @@ namespace :growstuff do end desc "January 2015: build Elasticsearch index" - task :elasticsearch_create_index => :environment do + task elasticsearch_create_index: :environment do Crop.__elasticsearch__.create_index! force: true Crop.import end diff --git a/lib/tasks/hooks.rake b/lib/tasks/hooks.rake index 036032414..93d599831 100644 --- a/lib/tasks/hooks.rake +++ b/lib/tasks/hooks.rake @@ -1,5 +1,5 @@ desc "Install git hooks" task :hooks do FileUtils.symlink '../../script/pre-commit.sh', '.git/hooks/pre-commit', - :force => true + force: true end diff --git a/lib/tasks/testing.rake b/lib/tasks/testing.rake index 1f7f000ef..a7908d590 100644 --- a/lib/tasks/testing.rake +++ b/lib/tasks/testing.rake @@ -2,7 +2,7 @@ require 'rake' begin require 'rspec/core/rake_task' task(:spec).clear - RSpec::Core::RakeTask.new(:spec => 'db:test:prepare') do |t| + RSpec::Core::RakeTask.new(spec: 'db:test:prepare') do |t| t.verbose = false end rescue LoadError diff --git a/script/heroku_maintenance.rb b/script/heroku_maintenance.rb index cf23b398f..4fd898148 100755 --- a/script/heroku_maintenance.rb +++ b/script/heroku_maintenance.rb @@ -3,7 +3,7 @@ require 'heroku-api' require 'yaml' -heroku = Heroku::API.new(:api_key => ENV['HEROKU_API_KEY']) +heroku = Heroku::API.new(api_key: ENV['HEROKU_API_KEY']) branch = ENV['TRAVIS_BRANCH'] travis_config = YAML.load_file('.travis.yml') if travis_config['deploy']['app'].has_key? branch diff --git a/spec/controllers/admin/orders_controller_spec.rb b/spec/controllers/admin/orders_controller_spec.rb index aa79e2895..28fe0203a 100644 --- a/spec/controllers/admin/orders_controller_spec.rb +++ b/spec/controllers/admin/orders_controller_spec.rb @@ -24,13 +24,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/authentications_controller_spec.rb b/spec/controllers/authentications_controller_spec.rb index 9365ed782..e3dd39447 100644 --- a/spec/controllers/authentications_controller_spec.rb +++ b/spec/controllers/authentications_controller_spec.rb @@ -22,7 +22,7 @@ describe AuthenticationsController do @member = FactoryGirl.create(:member) sign_in @member controller.stub(:current_member) { @member } - @auth = FactoryGirl.create(:authentication, :member => @member) + @auth = FactoryGirl.create(:authentication, member: @member) request.env['omniauth.auth'] = { 'provider' => 'foo', 'uid' => 'bar', diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index cac37fe7e..3e60a642b 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -26,12 +26,12 @@ describe CommentsController do def valid_attributes @post = FactoryGirl.create(:post) - { :post_id => @post.id, :author_id => @member.id, :body => "some text" } + { post_id: @post.id, author_id: @member.id, body: "some text" } end describe "GET RSS feed" do it "returns an RSS feed" do - get :index, :format => "rss" + get :index, format: "rss" response.should be_success response.should render_template("comments/index") response.content_type.should eq("application/rss+xml") @@ -41,14 +41,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} + old_comment = FactoryGirl.create(:comment, post: post) + get :new, {post_id: post.id} assigns(:comments).should eq [old_comment] end @@ -61,9 +61,9 @@ describe CommentsController do describe "GET edit" do it "assigns previous comments as @comments" 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} + old_comment = FactoryGirl.create(:comment, post: post) + comment = FactoryGirl.create(:comment, post: post, author: @member) + get :edit, {id: comment.to_param} assigns(:comments).should eq([comment, old_comment]) end end @@ -72,7 +72,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 @@ -82,7 +82,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/crops_controller_spec.rb b/spec/controllers/crops_controller_spec.rb index b9b6d44ba..894858057 100644 --- a/spec/controllers/crops_controller_spec.rb +++ b/spec/controllers/crops_controller_spec.rb @@ -22,9 +22,9 @@ describe CropsController do def valid_attributes { - :name => "Tomato", - :en_wikipedia_url => 'http://en.wikipedia.org/wiki/Tomato', - :approval_status => 'approved' + name: "Tomato", + en_wikipedia_url: 'http://en.wikipedia.org/wiki/Tomato', + approval_status: 'approved' } end @@ -55,7 +55,7 @@ describe CropsController do describe "GET RSS feed" do it "returns an RSS feed" do - get :index, :format => "rss" + get :index, format: "rss" response.should be_success response.should render_template("crops/index") response.content_type.should eq("application/rss+xml") diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb index 5905c8200..4e9d0fc1c 100644 --- a/spec/controllers/gardens_controller_spec.rb +++ b/spec/controllers/gardens_controller_spec.rb @@ -22,7 +22,7 @@ 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 b1e6312cd..80822c564 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -22,9 +22,9 @@ describe HarvestsController do def valid_attributes { - :owner_id => subject.current_member.id, - :crop_id => FactoryGirl.create(:crop).id, - :plant_part_id => FactoryGirl.create(:plant_part).id + owner_id: subject.current_member.id, + crop_id: FactoryGirl.create(:crop).id, + plant_part_id: FactoryGirl.create(:plant_part).id } end @@ -34,8 +34,8 @@ describe HarvestsController do @member2 = FactoryGirl.create(:member) @tomato = FactoryGirl.create(:tomato) @maize = FactoryGirl.create(:maize) - @harvest1 = FactoryGirl.create(:harvest, :owner_id => @member1.id, :crop_id => @tomato.id) - @harvest2 = FactoryGirl.create(:harvest, :owner_id => @member2.id, :crop_id => @maize.id) + @harvest1 = FactoryGirl.create(:harvest, owner_id: @member1.id, crop_id: @tomato.id) + @harvest2 = FactoryGirl.create(:harvest, owner_id: @member2.id, crop_id: @maize.id) end it "assigns all harvests as @harvests" do @@ -44,19 +44,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 @@ -64,7 +64,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 @@ -79,7 +79,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 @@ -88,18 +88,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 @@ -108,14 +108,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 @@ -130,18 +130,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 @@ -151,7 +151,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 @@ -159,7 +159,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 @@ -169,13 +169,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 4bd1f6826..be178341e 100644 --- a/spec/controllers/member_controller_spec.rb +++ b/spec/controllers/member_controller_spec.rb @@ -20,9 +20,9 @@ describe MembersController do before :each do @member = FactoryGirl.create(:member) - @posts = [ FactoryGirl.create(:post, :author => @member) ] - @twitter_auth = FactoryGirl.create(:authentication, :member => @member) - @flickr_auth = FactoryGirl.create(:flickr_authentication, :member => @member) + @posts = [ FactoryGirl.create(:post, author: @member) ] + @twitter_auth = FactoryGirl.create(:authentication, member: @member) + @flickr_auth = FactoryGirl.create(:flickr_authentication, member: @member) end describe "GET index" do @@ -34,7 +34,7 @@ describe MembersController do describe "GET JSON index" do it "provides JSON for members" do - get :index, :format => 'json' + get :index, format: 'json' response.should be_success end end @@ -42,39 +42,39 @@ 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 describe "GET member's RSS feed" do it "returns an RSS feed" do - get :show, { :id => @member.to_param, :format => "rss" } + get :show, { id: @member.to_param, format: "rss" } response.should be_success response.should render_template("members/show") response.content_type.should eq("application/rss+xml") diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index 55bf1d72d..1b70d0f33 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -47,7 +47,7 @@ describe NotificationsController do describe "GET index" do it "assigns all notifications as @notifications" do - notification = FactoryGirl.create(:notification, :recipient_id => subject.current_member.id) + notification = FactoryGirl.create(:notification, recipient_id: subject.current_member.id) get :index, {} assigns(:notifications).should eq([notification]) end @@ -55,24 +55,24 @@ 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} + notification = FactoryGirl.create(:notification, recipient_id: subject.current_member.id) + 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) + 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 + post_id: notification.post.id ) end it "marks notifications as read" do - notification = FactoryGirl.create(:notification, :recipient_id => subject.current_member.id) - get :show, {:id => notification.to_param} + notification = FactoryGirl.create(:notification, recipient_id: subject.current_member.id) + 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 @@ -82,7 +82,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 @@ -91,7 +91,7 @@ describe NotificationsController do describe "with valid params" do it "redirects to the recipient's profile" do @recipient = FactoryGirl.create(:member) - post :create, { :notification => { :recipient_id => @recipient.id, :subject => 'foo' } } + post :create, { notification: { recipient_id: @recipient.id, subject: 'foo' } } response.should redirect_to(notifications_path) end end diff --git a/spec/controllers/order_items_controller_spec.rb b/spec/controllers/order_items_controller_spec.rb index 5188b5127..f081c85b7 100644 --- a/spec/controllers/order_items_controller_spec.rb +++ b/spec/controllers/order_items_controller_spec.rb @@ -24,22 +24,22 @@ describe OrderItemsController do @member = FactoryGirl.create(:member) sign_in @member @product = FactoryGirl.create(:product) - @order = FactoryGirl.create(:order, :member => @member) + @order = FactoryGirl.create(:order, member: @member) @order_item = FactoryGirl.create(:order_item, - :order => @order, - :product => @product, - :price => @product.min_price + order: @order, + product: @product, + price: @product.min_price ) end describe "POST create" do it "redirects to order" do - @order = FactoryGirl.create(:order, :member => @member) - post :create, {:order_item => { - :order_id => @order.id, - :product_id => @product.id, - :price => @product.min_price + @order = FactoryGirl.create(:order, member: @member) + post :create, {order_item: { + order_id: @order.id, + product_id: @product.id, + price: @product.min_price }} response.should redirect_to(OrderItem.last.order) end @@ -49,9 +49,9 @@ describe OrderItemsController do sign_in @member @product = FactoryGirl.create(:product) expect { - post :create, {:order_item => { - :product_id => @product.id, - :price => @product.min_price + 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 @@ -59,13 +59,13 @@ describe OrderItemsController do describe "with non-int price" do it "converts 3.33 to 333 cents" do - @order = FactoryGirl.create(:order, :member => @member) - @product = FactoryGirl.create(:product, :min_price => 1) + @order = FactoryGirl.create(:order, member: @member) + @product = FactoryGirl.create(:product, min_price: 1) expect { - post :create, {:order_item => { - :order_id => @order.id, - :product_id => @product.id, - :price => 3.33 + 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 diff --git a/spec/controllers/orders_controller_spec.rb b/spec/controllers/orders_controller_spec.rb index c884bdca9..81e74a5b5 100644 --- a/spec/controllers/orders_controller_spec.rb +++ b/spec/controllers/orders_controller_spec.rb @@ -32,8 +32,8 @@ describe OrdersController do it 'sets the referral_code' do member = FactoryGirl.create(:member) sign_in member - order = Order.create!(:member_id => member.id) - get :checkout, {:id => order.to_param, :referral_code => 'FOOBAR'} + order = Order.create!(member_id: member.id) + get :checkout, {id: order.to_param, referral_code: 'FOOBAR'} order.reload order.referral_code.should eq 'FOOBAR' end @@ -41,8 +41,8 @@ describe OrdersController do it "redirects to Paypal" do member = FactoryGirl.create(:member) sign_in member - order = Order.create!(:member_id => member.id) - get :checkout, {:id => order.to_param} + order = Order.create!(member_id: member.id) + get :checkout, {id: order.to_param} response.status.should eq 302 response.redirect_url.should match /paypal\.com/ end @@ -52,8 +52,8 @@ describe OrdersController do it "assigns the requested order as @order" do member = FactoryGirl.create(:member) sign_in member - order = Order.create!(:member_id => member.id) - get :complete, {:id => order.to_param} + order = Order.create!(member_id: member.id) + get :complete, {id: order.to_param} assigns(:order).should eq(order) end end @@ -62,8 +62,8 @@ describe OrdersController do it "redirects to the shop" do member = FactoryGirl.create(:member) sign_in member - order = Order.create!(:member_id => member.id) - delete :destroy, {:id => order.id} + order = Order.create!(member_id: member.id) + delete :destroy, {id: order.id} response.should redirect_to(shop_url) end end diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 603959b46..e73ba5317 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -47,31 +47,31 @@ describe PhotosController do end it "assigns the flickr auth as @flickr_auth" do - @auth = FactoryGirl.create(:flickr_authentication, :member => @member) + @auth = FactoryGirl.create(:flickr_authentication, member: @member) get :new, {} assigns(:flickr_auth).should be_an_instance_of(Authentication) end it "assigns a planting id" do - get :new, { :type => "planting", :id => 5 } + get :new, { type: "planting", id: 5 } assigns(:id).should eq "5" assigns(:type).should eq "planting" end it "assigns a harvest id" do - get :new, { :type => "harvest", :id => 5 } + get :new, { type: "harvest", id: 5 } assigns(:id).should eq "5" assigns(:type).should eq "harvest" end it "assigns a garden id" do - get :new, { :type => "garden", :id => 5 } + get :new, { type: "garden", id: 5 } assigns(:id).should eq "5" assigns(:type).should eq "garden" end it "assigns the current set as @current_set" do - get :new, { :set => 'foo' } + get :new, { set: 'foo' } assigns(:current_set).should eq "foo" end @@ -80,12 +80,12 @@ describe PhotosController do describe "POST create" do before(:each) do Photo.any_instance.stub(:flickr_metadata).and_return( { - :title => "A Heartbreaking work of staggering genius", - :license_name => "CC-BY", - :license_url => "http://example.com/aybpl", - :thumbnail_url => "http://example.com/thumb.jpg", - :fullsize_url => "http://example.com/full.jpg", - :link_url => "http://example.com" + title: "A Heartbreaking work of staggering genius", + license_name: "CC-BY", + license_url: "http://example.com/aybpl", + thumbnail_url: "http://example.com/thumb.jpg", + fullsize_url: "http://example.com/full.jpg", + link_url: "http://example.com" }) end @@ -94,52 +94,52 @@ describe PhotosController do it "attaches the photo to a planting" do member = FactoryGirl.create(:member) controller.stub(:current_member) { member } - garden = FactoryGirl.create(:garden, :owner => member) - planting = FactoryGirl.create(:planting, :garden => garden, :owner => member) - photo = FactoryGirl.create(:photo, :owner => member) - post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id }, - :type => "planting", - :id => planting.id } + garden = FactoryGirl.create(:garden, owner: member) + planting = FactoryGirl.create(:planting, garden: garden, owner: member) + photo = FactoryGirl.create(:photo, owner: member) + post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, + type: "planting", + id: planting.id } Photo.last.plantings.first.should eq planting end it "doesn't attach a photo to a planting twice" do member = FactoryGirl.create(:member) controller.stub(:current_member) { member } - garden = FactoryGirl.create(:garden, :owner => member) - planting = FactoryGirl.create(:planting, :garden => garden, :owner => member) - photo = FactoryGirl.create(:photo, :owner => member) - post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id }, - :type => "planting", - :id => planting.id } - post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id }, - :type => "planting", - :id => planting.id } + garden = FactoryGirl.create(:garden, owner: member) + planting = FactoryGirl.create(:planting, garden: garden, owner: member) + photo = FactoryGirl.create(:photo, owner: member) + post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, + type: "planting", + id: planting.id } + post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, + type: "planting", + id: planting.id } Photo.last.plantings.size.should eq 1 end it "attaches the photo to a harvest" do member = FactoryGirl.create(:member) controller.stub(:current_member) { member } - harvest = FactoryGirl.create(:harvest, :owner => member) - photo = FactoryGirl.create(:photo, :owner => member) - post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id }, - :type => "harvest", - :id => harvest.id } + harvest = FactoryGirl.create(:harvest, owner: member) + photo = FactoryGirl.create(:photo, owner: member) + post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, + type: "harvest", + id: harvest.id } Photo.last.harvests.first.should eq harvest end it "doesn't attach a photo to a harvest twice" do member = FactoryGirl.create(:member) controller.stub(:current_member) { member } - harvest = FactoryGirl.create(:harvest, :owner => member) - photo = FactoryGirl.create(:photo, :owner => member) - post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id }, - :type => "harvest", - :id => harvest.id } - post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id }, - :type => "harvest", - :id => harvest.id } + harvest = FactoryGirl.create(:harvest, owner: member) + photo = FactoryGirl.create(:photo, owner: member) + post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, + type: "harvest", + id: harvest.id } + post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, + type: "harvest", + id: harvest.id } Photo.last.harvests.size.should eq 1 end end @@ -147,10 +147,10 @@ describe PhotosController do describe "for the second time" do it "does not add a photo twice" do expect { - post :create, {:photo => { :flickr_photo_id => 1 } } + post :create, {photo: { flickr_photo_id: 1 } } }.to change(Photo, :count).by(1) expect { - post :create, {:photo => { :flickr_photo_id => 1 } } + post :create, {photo: { flickr_photo_id: 1 } } }.to change(Photo, :count).by(0) end end @@ -159,23 +159,23 @@ describe PhotosController do it "creates the planting/photo link" do member = FactoryGirl.create(:member) controller.stub(:current_member) { member } - garden = FactoryGirl.create(:garden, :owner => member) - planting = FactoryGirl.create(:planting, :garden => garden, :owner => member) - photo = FactoryGirl.create(:photo, :owner => member) - post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id }, - :type => "planting", - :id => planting.id } + garden = FactoryGirl.create(:garden, owner: member) + planting = FactoryGirl.create(:planting, garden: garden, owner: member) + photo = FactoryGirl.create(:photo, owner: member) + post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, + type: "planting", + id: planting.id } Photo.last.plantings.first.should eq planting end it "creates the harvest/photo link" do member = FactoryGirl.create(:member) controller.stub(:current_member) { member } - harvest = FactoryGirl.create(:harvest, :owner => member) - photo = FactoryGirl.create(:photo, :owner => member) - post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id }, - :type => "harvest", - :id => harvest.id } + harvest = FactoryGirl.create(:harvest, owner: member) + photo = FactoryGirl.create(:photo, owner: member) + post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, + type: "harvest", + id: harvest.id } Photo.last.harvests.first.should eq harvest end end @@ -185,9 +185,9 @@ describe PhotosController do # members will be auto-created, and different planting = FactoryGirl.create(:planting) photo = FactoryGirl.create(:photo) - post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id }, - :type => "planting", - :id => planting.id } + post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, + type: "planting", + id: planting.id } Photo.last.plantings.first.should_not eq planting end @@ -195,9 +195,9 @@ describe PhotosController do # members will be auto-created, and different harvest = FactoryGirl.create(:harvest) photo = FactoryGirl.create(:photo) - post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id }, - :type => "harvest", - :id => harvest.id } + post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, + type: "harvest", + id: harvest.id } Photo.last.harvests.first.should_not eq harvest end end diff --git a/spec/controllers/places_controller_spec.rb b/spec/controllers/places_controller_spec.rb index 1f6da6ed0..4c8c34d3c 100644 --- a/spec/controllers/places_controller_spec.rb +++ b/spec/controllers/places_controller_spec.rb @@ -28,12 +28,12 @@ describe PlacesController do end it "assigns place name" do - get :show, { :place => @member_london.location } + get :show, { place: @member_london.location } assigns(:place).should eq @member_london.location end it "assigns nearby members" do - get :show, { :place => @member_london.location } + get :show, { place: @member_london.location } assigns(:nearby_members).should eq [@member_london, @member_south_pole] end @@ -41,7 +41,7 @@ describe PlacesController do describe "GET search" do it "redirects to the new place" do - get :search, { :new_place => "foo" } + get :search, { new_place: "foo" } response.should redirect_to place_path("foo") end end diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index 2e6b2e366..68514b634 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -22,8 +22,8 @@ describe PlantingsController do def valid_attributes { - :garden_id => FactoryGirl.create(:garden, :owner => subject.current_member).id, - :crop_id => FactoryGirl.create(:crop).id + garden_id: FactoryGirl.create(:garden, owner: subject.current_member).id, + crop_id: FactoryGirl.create(:crop).id } end @@ -33,8 +33,8 @@ describe PlantingsController do @member2 = FactoryGirl.create(:member) @tomato = FactoryGirl.create(:tomato) @maize = FactoryGirl.create(:maize) - @planting1 = FactoryGirl.create(:planting, :crop => @tomato, :owner => @member1) - @planting2 = FactoryGirl.create(:planting, :crop => @maize, :owner => @member2) + @planting1 = FactoryGirl.create(:planting, crop: @tomato, owner: @member1) + @planting2 = FactoryGirl.create(:planting, crop: @maize, owner: @member2) end it "assigns all plantings as @plantings" do @@ -43,13 +43,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 @@ -59,7 +59,7 @@ describe PlantingsController 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 @@ -70,8 +70,8 @@ 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} + garden = FactoryGirl.create(:garden, owner: member) + get :new, {garden_id: garden.id} assigns(:garden).should eq(garden) end @@ -86,7 +86,7 @@ describe PlantingsController do end it "sets the owner automatically" do - post :create, { :planting => valid_attributes } + post :create, { planting: valid_attributes } assigns(:planting).owner.should eq subject.current_member end diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index b11434a98..b53a67f40 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -22,12 +22,12 @@ describe PostsController do def valid_attributes member = FactoryGirl.create(:member) - { :author_id => member.id, :subject => "blah", :body => "blah blah" } + { author_id: member.id, subject: "blah", body: "blah blah" } end describe "GET RSS feed" do it "returns an RSS feed" do - get :index, :format => "rss" + get :index, format: "rss" response.should be_success response.should render_template("posts/index") response.content_type.should eq("application/rss+xml") @@ -37,7 +37,7 @@ describe PostsController do describe "GET RSS feed for individual post" do it "returns an RSS feed" do post = Post.create! valid_attributes - get :show, { :format => "rss", :id => post.slug } + get :show, { format: "rss", id: post.slug } response.should be_success response.should render_template("posts/show") response.content_type.should eq("application/rss+xml") diff --git a/spec/controllers/products_controller_spec.rb b/spec/controllers/products_controller_spec.rb index 84875191d..f8ca75083 100644 --- a/spec/controllers/products_controller_spec.rb +++ b/spec/controllers/products_controller_spec.rb @@ -22,9 +22,9 @@ describe ProductsController do def valid_attributes { - :name => "product name", - :description => 'some description', - :min_price => 9.99 + name: "product name", + description: 'some description', + min_price: 9.99 } end diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 028356209..ac9990254 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -32,13 +32,13 @@ describe RegistrationsController do end it "picks up the twitter auth" do - @auth = FactoryGirl.create(:authentication, :member => @member) + @auth = FactoryGirl.create(:authentication, member: @member) get :edit assigns(:twitter_auth).should eq @auth end it "picks up the flickr auth" do - @auth = FactoryGirl.create(:flickr_authentication, :member => @member) + @auth = FactoryGirl.create(:flickr_authentication, member: @member) get :edit assigns(:flickr_auth).should eq @auth end diff --git a/spec/controllers/scientific_names_controller_spec.rb b/spec/controllers/scientific_names_controller_spec.rb index 47f3ff29c..ab40494fb 100644 --- a/spec/controllers/scientific_names_controller_spec.rb +++ b/spec/controllers/scientific_names_controller_spec.rb @@ -25,12 +25,12 @@ describe ScientificNamesController do end def valid_attributes - { :scientific_name => 'Solanum lycopersicum', :crop_id => @crop.id } + { scientific_name: 'Solanum lycopersicum', crop_id: @crop.id } end describe "GET new" do it "assigns crop if specified" do - get :new, { :crop_id => 1 } + get :new, { crop_id: 1 } assigns(:crop).should be_an_instance_of Crop end diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb index 97016cf31..bfb880477 100644 --- a/spec/controllers/seeds_controller_spec.rb +++ b/spec/controllers/seeds_controller_spec.rb @@ -20,7 +20,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/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb index 51bb36437..a02d4fbad 100644 --- a/spec/controllers/shop_controller_spec.rb +++ b/spec/controllers/shop_controller_spec.rb @@ -42,7 +42,7 @@ describe ShopController do it "assigns @order as current_order if there is one" do @member = FactoryGirl.create(:member) sign_in @member - @order = FactoryGirl.create(:order, :member => @member) + @order = FactoryGirl.create(:order, member: @member) get :index, {} assigns(:order).should eq @order end diff --git a/spec/features/admin/account_types_spec.rb b/spec/features/admin/account_types_spec.rb index 71d763377..dac241586 100644 --- a/spec/features/admin/account_types_spec.rb +++ b/spec/features/admin/account_types_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "account types", :js => true do +feature "account types", js: true do context "admin user" do let(:member) { create :admin_member } let(:account_type) { create :account_type } @@ -19,7 +19,7 @@ feature "account types", :js => true do expect(current_path).to eq account_types_path end - scenario "navigating to account type admin without JavaScript - Accessility version", :js => false do + scenario "navigating to account type admin without JavaScript - Accessility version", js: false do visit root_path # Extra link not needed as menu is already expanded click_link "Admin" diff --git a/spec/features/admin/forums_spec.rb b/spec/features/admin/forums_spec.rb index 5e9627114..a385289a6 100644 --- a/spec/features/admin/forums_spec.rb +++ b/spec/features/admin/forums_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "forums", :js => true do +feature "forums", js: true do context "as an admin user" do let(:member) { create :admin_member } let(:forum) { create :forum } @@ -9,7 +9,7 @@ feature "forums", :js => true do login_as member end - scenario "navigating to forum admin without js", :js => false do + scenario "navigating to forum admin without js", js: false do visit root_path click_link "Admin" expect(current_path).to eq admin_path diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index ce7984638..de8843708 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "Alternate names", :js => true do +feature "Alternate names", js: true do let!(:alternate_eggplant) { create :alternate_eggplant } let(:crop) { alternate_eggplant.crop } diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 88c7ed7ad..865925bce 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "crop detail page", :js => true do +feature "crop detail page", js: true do let(:crop) { create :crop } subject { visit crop_path(crop) } @@ -46,7 +46,7 @@ feature "crop detail page", :js => true do end end - scenario "The crop has 5 varieties, including grandchild", :js => true do + scenario "The crop has 5 varieties, including grandchild", js: true do create :crop, name: 'Roma tomato child 1', parent: roma4 subject diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb index cbb410ab4..620034fb2 100644 --- a/spec/features/crops/crop_wranglers_spec.rb +++ b/spec/features/crops/crop_wranglers_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "crop wranglers", :js => true do +feature "crop wranglers", js: true do context "signed in wrangler" do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:wrangler) { crop_wranglers.first } @@ -72,7 +72,7 @@ feature "crop wranglers", :js => true do background { login_as member } - scenario "can't see wrangling page without js", :js => false do + scenario "can't see wrangling page without js", js: false do visit root_path expect(page).not_to have_link "Crop Wrangling" end diff --git a/spec/features/footer_spec.rb b/spec/features/footer_spec.rb index 47fb42631..8a2c21bbd 100644 --- a/spec/features/footer_spec.rb +++ b/spec/features/footer_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "footer", :js => true do +feature "footer", js: true do before { visit root_path } diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 8ae4aa1da..90f2f9ed7 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "Planting a crop", :js => true do +feature "Planting a crop", js: true do let!(:garden) { create :garden } let!(:planting) { create :planting, garden: garden, planted_at: Date.parse("2013-3-10") } let!(:tomato) { create :tomato } diff --git a/spec/features/locale_spec.rb b/spec/features/locale_spec.rb index 6d8502cdf..74cf208be 100644 --- a/spec/features/locale_spec.rb +++ b/spec/features/locale_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "Changing locales", :js => true do +feature "Changing locales", js: true do after { I18n.locale = :en } diff --git a/spec/features/member_profile_spec.rb b/spec/features/member_profile_spec.rb index c336dfa94..cfa0753ba 100644 --- a/spec/features/member_profile_spec.rb +++ b/spec/features/member_profile_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "member profile", :js => true do +feature "member profile", js: true do context "signed out member" do let(:member) { create :member } @@ -157,7 +157,7 @@ feature "member profile", :js => true do end scenario "has a private message button" do - expect(page).to have_link "Send message", href: new_notification_path(:recipient_id => other_member.id) + expect(page).to have_link "Send message", href: new_notification_path(recipient_id: other_member.id) end end diff --git a/spec/features/members_list_spec.rb b/spec/features/members_list_spec.rb index a7857bafd..99e15820a 100644 --- a/spec/features/members_list_spec.rb +++ b/spec/features/members_list_spec.rb @@ -20,7 +20,7 @@ feature "members list" do visit members_path expect(page).to have_css "#sort" expect(page).to have_selector "form" - select("recently", :from => 'sort') + select("recently", from: 'sort') click_button('Show') all_links = page.all("#maincontainer p.login-name") expect(all_links.first).to have_text member3.login_name diff --git a/spec/features/scientific_name_spec.rb b/spec/features/scientific_name_spec.rb index 7966ad2ee..c5b621e10 100644 --- a/spec/features/scientific_name_spec.rb +++ b/spec/features/scientific_name_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "Scientific names", :js => true do +feature "Scientific names", js: true do let!(:zea_mays) { create :zea_mays } let(:crop) { zea_mays.crop } diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb index e1e1db2df..f3c463b17 100644 --- a/spec/features/seeds/adding_seeds_spec.rb +++ b/spec/features/seeds/adding_seeds_spec.rb @@ -29,19 +29,19 @@ feature "Seeds", :js do expect(page).to have_selector '.form-group.required', text: 'Will trade:' end - scenario "Adding a new seed", :js => true do - fill_autocomplete "crop", :with => "mai" + scenario "Adding a new seed", js: true do + fill_autocomplete "crop", with: "mai" select_from_autocomplete "maize" within "form#new_seed" do fill_in "Quantity:", with: 42 fill_in "Plant before:", with: "2014-06-15" fill_in "Days until maturity:", with: 999 fill_in "to", with: 1999 - select "certified organic", :from => "Organic?" - select "non-certified GMO-free", :from => "GMO?" - select "heirloom", :from => "Heirloom?" + select "certified organic", from: "Organic?" + select "non-certified GMO-free", from: "GMO?" + select "heirloom", from: "Heirloom?" fill_in "Description", with: "It's killer." - select "internationally", :from => "Will trade:" + select "internationally", from: "Will trade:" click_button "Save" end diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb index 4c238a691..1db053a80 100644 --- a/spec/features/seeds/misc_seeds_spec.rb +++ b/spec/features/seeds/misc_seeds_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "seeds", :js => true do +feature "seeds", js: true do context "signed in user" do let(:member) { create :member } let(:crop) { create :crop } diff --git a/spec/features/shared_examples/crop_suggest.rb b/spec/features/shared_examples/crop_suggest.rb index 9828a7865..8f45c1e96 100644 --- a/spec/features/shared_examples/crop_suggest.rb +++ b/spec/features/shared_examples/crop_suggest.rb @@ -41,7 +41,7 @@ shared_examples "crop suggest" do |resource| select_from_autocomplete("pear") - expect(page).to have_selector("input##{resource}_crop_id[value='#{pear.id}']", :visible => false) + expect(page).to have_selector("input##{resource}_crop_id[value='#{pear.id}']", visible: false) end scenario "Typing and pausing does not affect input" do diff --git a/spec/features/signin_spec.rb b/spec/features/signin_spec.rb index 4b9220a11..693a8ec6b 100644 --- a/spec/features/signin_spec.rb +++ b/spec/features/signin_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature "signin", :js => true do +feature "signin", js: true do let(:member) { create :member } let(:recipient) { create :member } let(:notification) { create :notification } diff --git a/spec/features/signup_spec.rb b/spec/features/signup_spec.rb index 1160f9efb..f35ddd0c9 100644 --- a/spec/features/signup_spec.rb +++ b/spec/features/signup_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "signup", :js => true do +feature "signup", js: true do scenario "sign up for new account from top menubar" do visit crops_path # something other than front page, which has multiple signup links diff --git a/spec/helpers/harvests_helper_spec.rb b/spec/helpers/harvests_helper_spec.rb index 7bc516162..c65d8b36e 100644 --- a/spec/helpers/harvests_helper_spec.rb +++ b/spec/helpers/harvests_helper_spec.rb @@ -5,8 +5,8 @@ describe HarvestsHelper do it "blank" do harvest = FactoryGirl.create(:harvest, - :quantity => nil, - :weight_quantity => nil + quantity: nil, + weight_quantity: nil ) result = helper.display_quantity(harvest) result.should eq 'not specified' @@ -14,9 +14,9 @@ describe HarvestsHelper do it '3 individual' do harvest = FactoryGirl.create(:harvest, - :quantity => 3, - :unit => 'individual', - :weight_quantity => nil + quantity: 3, + unit: 'individual', + weight_quantity: nil ) result = helper.display_quantity(harvest) result.should eq '3' @@ -24,9 +24,9 @@ describe HarvestsHelper do it '1 bunch' do harvest = FactoryGirl.create(:harvest, - :quantity => 1, - :unit => 'bunch', - :weight_quantity => nil + quantity: 1, + unit: 'bunch', + weight_quantity: nil ) result = helper.display_quantity(harvest) result.should eq '1 bunch' @@ -34,9 +34,9 @@ describe HarvestsHelper do it '3 bunches' do harvest = FactoryGirl.create(:harvest, - :quantity => 3, - :unit => 'bunch', - :weight_quantity => nil + quantity: 3, + unit: 'bunch', + weight_quantity: nil ) result = helper.display_quantity(harvest) result.should eq '3 bunches' @@ -44,10 +44,10 @@ describe HarvestsHelper do it '3 kg' do harvest = FactoryGirl.create(:harvest, - :quantity => nil, - :unit => nil, - :weight_quantity => 3, - :weight_unit => 'kg' + quantity: nil, + unit: nil, + weight_quantity: 3, + weight_unit: 'kg' ) result = helper.display_quantity(harvest) result.should eq '3 kg' @@ -55,10 +55,10 @@ describe HarvestsHelper do it '3 individual weighing 3 kg' do harvest = FactoryGirl.create(:harvest, - :quantity => 3, - :unit => 'individual', - :weight_quantity => 3, - :weight_unit => 'kg' + quantity: 3, + unit: 'individual', + weight_quantity: 3, + weight_unit: 'kg' ) result = helper.display_quantity(harvest) result.should eq '3, weighing 3 kg' @@ -66,10 +66,10 @@ describe HarvestsHelper do it '3 bunches weighing 3 kg' do harvest = FactoryGirl.create(:harvest, - :quantity => 3, - :unit => 'bunch', - :weight_quantity => 3, - :weight_unit => 'kg' + quantity: 3, + unit: 'bunch', + weight_quantity: 3, + weight_unit: 'kg' ) result = helper.display_quantity(harvest) result.should eq '3 bunches, weighing 3 kg' diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 5c3c7e1a2..109bf0c87 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -6,7 +6,7 @@ describe NotificationsHelper do let(:member) { FactoryGirl.create(:member) } it "replies to PMs with PMs" do - notification = FactoryGirl.create(:notification, :recipient_id => member.id, :post_id => nil) + notification = FactoryGirl.create(:notification, recipient_id: member.id, post_id: nil) subject = "Re: " + notification.subject link = helper.reply_link(notification) @@ -15,12 +15,12 @@ describe NotificationsHelper do end it "replies to post comments with post comments" do - notification = FactoryGirl.create(:notification, :recipient_id => member.id) + notification = FactoryGirl.create(:notification, recipient_id: member.id) link = helper.reply_link(notification) link.should_not be_nil link.should eq new_comment_url( - :post_id => notification.post.id + post_id: notification.post.id ) end diff --git a/spec/helpers/plantings_helper_spec.rb b/spec/helpers/plantings_helper_spec.rb index 4cb2c63a7..ae8c78c78 100644 --- a/spec/helpers/plantings_helper_spec.rb +++ b/spec/helpers/plantings_helper_spec.rb @@ -3,13 +3,13 @@ require 'rails_helper' describe PlantingsHelper do describe "display_planting" do - let!(:member) { FactoryGirl.build(:member, :login_name => 'crop_lady') } + let!(:member) { FactoryGirl.build(:member, login_name: 'crop_lady') } it "does not have a quantity nor a planted from value provided" do planting = FactoryGirl.build(:planting, - :quantity => nil, - :planted_from => '', - :owner => member + quantity: nil, + planted_from: '', + owner: member ) result = helper.display_planting(planting) expect(result).to eq "crop_lady." @@ -17,9 +17,9 @@ describe PlantingsHelper do it "does not have a quantity provided" do planting = FactoryGirl.build(:planting, - :quantity => nil, - :planted_from => 'seed', - :owner => member + quantity: nil, + planted_from: 'seed', + owner: member ) result = helper.display_planting(planting) expect(result).to eq "crop_lady planted seeds." @@ -28,9 +28,9 @@ describe PlantingsHelper do context "when quantity is greater than 1" do it "does not have a planted from value provided" do planting = FactoryGirl.build(:planting, - :quantity => 10, - :planted_from => '', - :owner => member + quantity: 10, + planted_from: '', + owner: member ) result = helper.display_planting(planting) expect(result).to eq "crop_lady planted 10 units." @@ -38,9 +38,9 @@ describe PlantingsHelper do it "does have a planted from value provided" do planting = FactoryGirl.build(:planting, - :quantity => 5, - :planted_from => 'seed', - :owner => member + quantity: 5, + planted_from: 'seed', + owner: member ) result = helper.display_planting(planting) expect(result).to eq "crop_lady planted 5 seeds." @@ -50,9 +50,9 @@ describe PlantingsHelper do context "when quantity is 1" do it "does not have a planted from value provided" do planting = FactoryGirl.build(:planting, - :quantity => 1, - :planted_from => '', - :owner => member + quantity: 1, + planted_from: '', + owner: member ) result = helper.display_planting(planting) expect(result).to eq "crop_lady planted 1 unit." @@ -60,9 +60,9 @@ describe PlantingsHelper do it "does have a planted from value provided" do planting = FactoryGirl.build(:planting, - :quantity => 1, - :planted_from => 'seed', - :owner => member + quantity: 1, + planted_from: 'seed', + owner: member ) result = helper.display_planting(planting) expect(result).to eq "crop_lady planted 1 seed." diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb index 979b3f305..2aba8fb89 100644 --- a/spec/lib/haml/filters/growstuff_markdown_spec.rb +++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb @@ -7,7 +7,7 @@ def input_link(name) end def output_link(crop, name=nil) - url = Rails.application.routes.url_helpers.crop_url(crop, :host => Growstuff::Application.config.host) + url = Rails.application.routes.url_helpers.crop_url(crop, host: Growstuff::Application.config.host) if name return "#{name}" else @@ -20,7 +20,7 @@ def input_member_link(name) end def output_member_link(member, name=nil) - url = Rails.application.routes.url_helpers.member_url(member, :only_path => true) + url = Rails.application.routes.url_helpers.member_url(member, only_path: true) if name return "#{name}" else @@ -67,7 +67,7 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "finds crops case insensitively" do - @crop = FactoryGirl.create(:crop, :name => 'tomato') + @crop = FactoryGirl.create(:crop, name: 'tomato') rendered = Haml::Filters::GrowstuffMarkdown.render(input_link('ToMaTo')) rendered.should match /#{output_link(@crop, 'ToMaTo')}/ end diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 6a054083b..f31f7f845 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -9,29 +9,29 @@ describe Ability do context "notifications" do it 'member can view their own notifications' do - notification = FactoryGirl.create(:notification, :recipient => member) + notification = FactoryGirl.create(:notification, recipient: member) ability.should be_able_to(:read, notification) end it "member can't view someone else's notifications" do notification = FactoryGirl.create(:notification, - :recipient => FactoryGirl.create(:member) + recipient: FactoryGirl.create(:member) ) ability.should_not be_able_to(:read, notification) end it "member can't send messages to themself" do ability.should_not be_able_to(:create, FactoryGirl.create(:notification, - :recipient => member, - :sender => member + recipient: member, + sender: member ) ) end it "member can send messages to someone else" do ability.should be_able_to(:create, FactoryGirl.create(:notification, - :recipient => FactoryGirl.create(:member), - :sender => member + recipient: FactoryGirl.create(:member), + sender: member ) ) end @@ -123,16 +123,16 @@ describe Ability do context "orders" do - let(:order) { FactoryGirl.create(:order, :member => member) } + let(:order) { FactoryGirl.create(:order, member: member) } let(:strangers_order) { FactoryGirl.create(:order, - :member => FactoryGirl.create(:member)) } + member: FactoryGirl.create(:member)) } let(:completed_order) { FactoryGirl.create(:completed_order, - :member => member) } - let(:order_item) { FactoryGirl.create(:order_item, :order => order) } + member: member) } + let(:order_item) { FactoryGirl.create(:order_item, order: order) } let(:strangers_order_item) { FactoryGirl.create(:order_item, - :order => strangers_order) } + order: strangers_order) } let(:completed_order_item) { FactoryGirl.create(:order_item, - :order => completed_order) } + order: completed_order) } context "standard member" do it "can read their own orders" do @@ -315,7 +315,7 @@ describe Ability do end it "can't delete a plant part that has harvests" do - @harvest = FactoryGirl.create(:harvest, :plant_part => plant_part) + @harvest = FactoryGirl.create(:harvest, plant_part: plant_part) ability.should_not be_able_to(:destroy, plant_part) end diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 2a41ed983..1274a825e 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -9,7 +9,7 @@ describe Account do end it "won't let you create two account details for the same member" do - @details = Account.new(:member_id => member.id) + @details = Account.new(member_id: member.id) @details.should_not be_valid end diff --git a/spec/models/alternate_name_spec.rb b/spec/models/alternate_name_spec.rb index ecbdc10eb..5e12b02de 100644 --- a/spec/models/alternate_name_spec.rb +++ b/spec/models/alternate_name_spec.rb @@ -10,9 +10,9 @@ describe AlternateName do it 'should be possible to add multiple alternate names to a crop' do crop = an.crop an2 = AlternateName.create( - :name => "really alternative tomato", - :crop_id => crop.id, - :creator_id => an.creator.id + name: "really alternative tomato", + crop_id: crop.id, + creator_id: an.creator.id ) crop.alternate_names << an2 expect(crop.alternate_names).to include an diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 9fbf1ca1e..f3c94860e 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -37,9 +37,9 @@ describe Comment do it "doesn't send notifications to yourself" do @m = FactoryGirl.create(:member) - @p = FactoryGirl.create(:post, :author => @m) + @p = FactoryGirl.create(:post, author: @m) expect { - FactoryGirl.create(:comment, :post => @p, :author => @m) + FactoryGirl.create(:comment, post: @p, author: @m) }.to change(Notification, :count).by(0) end end @@ -47,9 +47,9 @@ describe Comment do context "ordering" do before(:each) do @m = FactoryGirl.create(:member) - @p = FactoryGirl.create(:post, :author => @m) - @c1 = FactoryGirl.create(:comment, :post => @p, :author => @m) - @c2 = FactoryGirl.create(:comment, :post => @p, :author => @m) + @p = FactoryGirl.create(:post, author: @m) + @c1 = FactoryGirl.create(:comment, post: @p, author: @m) + @c2 = FactoryGirl.create(:comment, post: @p, author: @m) end it 'is in DESC order by default' do diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index c79944c61..047ca0c6a 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -30,15 +30,15 @@ describe Crop do context 'invalid data' do it 'should not save a crop without a system name' do - crop = FactoryGirl.build(:crop, :name => nil) + crop = FactoryGirl.build(:crop, name: nil) expect { crop.save }.to raise_error ActiveRecord::StatementInvalid end end context 'ordering' do before do - @uppercase = FactoryGirl.create(:uppercasecrop, :created_at => 1.minute.ago) - @lowercase = FactoryGirl.create(:lowercasecrop, :created_at => 2.days.ago) + @uppercase = FactoryGirl.create(:uppercasecrop, created_at: 1.minute.ago) + @lowercase = FactoryGirl.create(:lowercasecrop, created_at: 2.days.ago) end it "should be sorted case-insensitively" do @@ -54,16 +54,16 @@ describe Crop do let(:tomato) { FactoryGirl.create(:tomato) } let(:maize) { FactoryGirl.create(:maize) } - let(:cucumber) { FactoryGirl.create(:crop, :name => 'cucumber') } + let(:cucumber) { FactoryGirl.create(:crop, name: 'cucumber') } before do - FactoryGirl.create_list(:planting, 10, :crop => maize) - FactoryGirl.create_list(:planting, 3, :crop => tomato) + FactoryGirl.create_list(:planting, 10, crop: maize) + FactoryGirl.create_list(:planting, 3, crop: tomato) end it "sorts by most plantings" do Crop.popular.first.should eq maize - FactoryGirl.create_list(:planting, 10, :crop => tomato) + FactoryGirl.create_list(:planting, 10, crop: tomato) Crop.popular.first.should eq tomato end @@ -72,7 +72,7 @@ describe Crop do it 'finds a default scientific name' do @crop = FactoryGirl.create(:tomato) @crop.default_scientific_name.should eq nil - @sn = FactoryGirl.create(:solanum_lycopersicum, :crop => @crop) + @sn = FactoryGirl.create(:solanum_lycopersicum, crop: @crop) @crop.reload @crop.default_scientific_name.should eq @sn.scientific_name end @@ -80,29 +80,29 @@ describe Crop do it 'counts plantings' do @crop = FactoryGirl.create(:tomato) @crop.plantings.size.should eq 0 - @planting = FactoryGirl.create(:planting, :crop => @crop) + @planting = FactoryGirl.create(:planting, crop: @crop) @crop.reload @crop.plantings.size.should eq 1 end it 'validates en_wikipedia_url' do - @crop = FactoryGirl.build(:tomato, :en_wikipedia_url => 'this is not valid') + @crop = FactoryGirl.build(:tomato, en_wikipedia_url: 'this is not valid') @crop.should_not be_valid - @crop = FactoryGirl.build(:tomato, :en_wikipedia_url => 'http://en.wikipedia.org/wiki/SomePage') + @crop = FactoryGirl.build(:tomato, en_wikipedia_url: 'http://en.wikipedia.org/wiki/SomePage') @crop.should be_valid end context 'varieties' do it 'has a crop hierarchy' do @tomato = FactoryGirl.create(:tomato) - @roma = FactoryGirl.create(:roma, :parent_id => @tomato.id) + @roma = FactoryGirl.create(:roma, parent_id: @tomato.id) @roma.parent.should eq @tomato @tomato.varieties.should eq [@roma] end it 'toplevel scope works' do @tomato = FactoryGirl.create(:tomato) - @roma = FactoryGirl.create(:roma, :parent_id => @tomato.id) + @roma = FactoryGirl.create(:roma, parent_id: @tomato.id) Crop.toplevel.should eq [ @tomato ] end end @@ -110,7 +110,7 @@ describe Crop do context 'photos' do it 'has a default photo' do @crop = FactoryGirl.create(:tomato) - @planting = FactoryGirl.create(:planting, :crop => @crop) + @planting = FactoryGirl.create(:planting, crop: @crop) @photo = FactoryGirl.create(:photo) @planting.photos << @photo @crop.default_photo.should be_an_instance_of Photo @@ -122,25 +122,25 @@ describe Crop do let(:crop) { FactoryGirl.create(:tomato) } it 'returns a hash of sunniness values' do - planting1 = FactoryGirl.create(:sunny_planting, :crop => crop) - planting2 = FactoryGirl.create(:sunny_planting, :crop => crop) - planting3 = FactoryGirl.create(:semi_shady_planting, :crop => crop) - planting4 = FactoryGirl.create(:shady_planting, :crop => crop) + planting1 = FactoryGirl.create(:sunny_planting, crop: crop) + planting2 = FactoryGirl.create(:sunny_planting, crop: crop) + planting3 = FactoryGirl.create(:semi_shady_planting, crop: crop) + planting4 = FactoryGirl.create(:shady_planting, crop: crop) crop.sunniness.should be_an_instance_of Hash end it 'counts each sunniness value' do - planting1 = FactoryGirl.create(:sunny_planting, :crop => crop) - planting2 = FactoryGirl.create(:sunny_planting, :crop => crop) - planting3 = FactoryGirl.create(:semi_shady_planting, :crop => crop) - planting4 = FactoryGirl.create(:shady_planting, :crop => crop) + planting1 = FactoryGirl.create(:sunny_planting, crop: crop) + planting2 = FactoryGirl.create(:sunny_planting, crop: crop) + planting3 = FactoryGirl.create(:semi_shady_planting, crop: crop) + planting4 = FactoryGirl.create(:shady_planting, crop: crop) crop.sunniness.should == { 'sun' => 2, 'shade' => 1, 'semi-shade' => 1 } end it 'ignores unused sunniness values' do - planting1 = FactoryGirl.create(:sunny_planting, :crop => crop) - planting2 = FactoryGirl.create(:sunny_planting, :crop => crop) - planting3 = FactoryGirl.create(:semi_shady_planting, :crop => crop) + planting1 = FactoryGirl.create(:sunny_planting, crop: crop) + planting2 = FactoryGirl.create(:sunny_planting, crop: crop) + planting3 = FactoryGirl.create(:semi_shady_planting, crop: crop) crop.sunniness.should == { 'sun' => 2, 'semi-shade' => 1 } end end @@ -150,25 +150,25 @@ describe Crop do let(:crop) { FactoryGirl.create(:tomato) } it 'returns a hash of sunniness values' do - planting1 = FactoryGirl.create(:seed_planting, :crop => crop) - planting2 = FactoryGirl.create(:seed_planting, :crop => crop) - planting3 = FactoryGirl.create(:seedling_planting, :crop => crop) - planting4 = FactoryGirl.create(:cutting_planting, :crop => crop) + planting1 = FactoryGirl.create(:seed_planting, crop: crop) + planting2 = FactoryGirl.create(:seed_planting, crop: crop) + planting3 = FactoryGirl.create(:seedling_planting, crop: crop) + planting4 = FactoryGirl.create(:cutting_planting, crop: crop) crop.planted_from.should be_an_instance_of Hash end it 'counts each planted_from value' do - planting1 = FactoryGirl.create(:seed_planting, :crop => crop) - planting2 = FactoryGirl.create(:seed_planting, :crop => crop) - planting3 = FactoryGirl.create(:seedling_planting, :crop => crop) - planting4 = FactoryGirl.create(:cutting_planting, :crop => crop) + planting1 = FactoryGirl.create(:seed_planting, crop: crop) + planting2 = FactoryGirl.create(:seed_planting, crop: crop) + planting3 = FactoryGirl.create(:seedling_planting, crop: crop) + planting4 = FactoryGirl.create(:cutting_planting, crop: crop) crop.planted_from.should == { 'seed' => 2, 'seedling' => 1, 'cutting' => 1 } end it 'ignores unused planted_from values' do - planting1 = FactoryGirl.create(:seed_planting, :crop => crop) - planting2 = FactoryGirl.create(:seed_planting, :crop => crop) - planting3 = FactoryGirl.create(:seedling_planting, :crop => crop) + planting1 = FactoryGirl.create(:seed_planting, crop: crop) + planting2 = FactoryGirl.create(:seed_planting, crop: crop) + planting3 = FactoryGirl.create(:seedling_planting, crop: crop) crop.planted_from.should == { 'seed' => 2, 'seedling' => 1 } end end @@ -187,20 +187,20 @@ describe Crop do @root = FactoryGirl.create(:plant_part) @bulb = FactoryGirl.create(:plant_part) @harvest1 = FactoryGirl.create(:harvest, - :crop => crop, - :plant_part => @fruit + crop: crop, + plant_part: @fruit ) @harvest2 = FactoryGirl.create(:harvest, - :crop => crop, - :plant_part => @fruit + crop: crop, + plant_part: @fruit ) @harvest3 = FactoryGirl.create(:harvest, - :crop => crop, - :plant_part => @seed + crop: crop, + plant_part: @seed ) @harvest4 = FactoryGirl.create(:harvest, - :crop => crop, - :plant_part => @root + crop: crop, + plant_part: @root ) crop.popular_plant_parts.should == { @fruit => 2, @seed => 1, @root => 1 } end @@ -215,10 +215,10 @@ describe Crop do # they need 3+ plantings each to be interesting (1..3).each do - FactoryGirl.create(:planting, :crop => @crop1) + FactoryGirl.create(:planting, crop: @crop1) end (1..3).each do - FactoryGirl.create(:planting, :crop => @crop2) + FactoryGirl.create(:planting, crop: @crop2) end # crops need 3+ photos to be interesting @@ -242,7 +242,7 @@ describe Crop do # only crop1 has plantings (1..3).each do - FactoryGirl.create(:planting, :crop => @crop1) + FactoryGirl.create(:planting, crop: @crop1) end # ... and photos @@ -265,10 +265,10 @@ describe Crop do # both crops have plantings (1..3).each do - FactoryGirl.create(:planting, :crop => @crop1) + FactoryGirl.create(:planting, crop: @crop1) end (1..3).each do - FactoryGirl.create(:planting, :crop => @crop2) + FactoryGirl.create(:planting, crop: @crop2) end # but only crop1 has photos @@ -288,7 +288,7 @@ describe Crop do context "harvests" do it "has harvests" do crop = FactoryGirl.create(:crop) - harvest = FactoryGirl.create(:harvest, :crop => crop) + harvest = FactoryGirl.create(:harvest, crop: crop) crop.harvests.should eq [harvest] end end @@ -298,12 +298,12 @@ describe Crop do @pp1 = FactoryGirl.create(:plant_part) @pp2 = FactoryGirl.create(:plant_part) @h1 = FactoryGirl.create(:harvest, - :crop => @maize, - :plant_part => @pp1 + crop: @maize, + plant_part: @pp1 ) @h2 = FactoryGirl.create(:harvest, - :crop => @maize, - :plant_part => @pp2 + crop: @maize, + plant_part: @pp2 ) @maize.plant_parts.should include @pp1 @maize.plant_parts.should include @pp2 @@ -313,19 +313,19 @@ describe Crop do @maize = FactoryGirl.create(:maize) @pp1 = FactoryGirl.create(:plant_part) @h1 = FactoryGirl.create(:harvest, - :crop => @maize, - :plant_part => @pp1 + crop: @maize, + plant_part: @pp1 ) @h2 = FactoryGirl.create(:harvest, - :crop => @maize, - :plant_part => @pp1 + crop: @maize, + plant_part: @pp1 ) @maize.plant_parts.should eq [@pp1] end context "search" do - let(:mushroom) { FactoryGirl.create(:crop, :name => 'mushroom') } + let(:mushroom) { FactoryGirl.create(:crop, name: 'mushroom') } before do sync_elasticsearch([mushroom]) @@ -344,12 +344,12 @@ describe Crop do Crop.search('mUsH').should include mushroom end it "doesn't find 'rejected' crop" do - @rejected_crop = FactoryGirl.create(:rejected_crop, :name => 'tomato') + @rejected_crop = FactoryGirl.create(:rejected_crop, name: 'tomato') sync_elasticsearch([@rejected_crop]) Crop.search('tomato').should_not include @rejected_crop end it "doesn't find 'pending' crop" do - @crop_request = FactoryGirl.create(:crop_request, :name => 'tomato') + @crop_request = FactoryGirl.create(:crop_request, name: 'tomato') sync_elasticsearch([@crop_request]) Crop.search('tomato').should_not include @crop_request end @@ -374,12 +374,12 @@ describe Crop do end it "picks up scientific name from parent crop if available" do - parent = FactoryGirl.create(:crop, :name => 'parent crop') + parent = FactoryGirl.create(:crop, name: 'parent crop') parent.add_scientific_names_from_csv("Parentis cropis") parent.save parent.reload - tomato = FactoryGirl.create(:tomato, :parent => parent) + tomato = FactoryGirl.create(:tomato, parent: parent) expect(tomato.parent).to eq parent expect(tomato.parent.default_scientific_name).to eq "Parentis cropis" @@ -399,12 +399,12 @@ describe Crop do end it "doesn't add a duplicate scientific name from parent" do - parent = FactoryGirl.create(:crop, :name => 'parent') + parent = FactoryGirl.create(:crop, name: 'parent') parent.add_scientific_names_from_csv("Parentis cropis") parent.save parent.reload - tomato = FactoryGirl.create(:tomato, :parent => parent) + tomato = FactoryGirl.create(:tomato, parent: parent) expect(tomato.scientific_names.size).to eq 0 tomato.add_scientific_names_from_csv('') expect(tomato.scientific_names.size).to eq 1 # picks up parent SN @@ -509,7 +509,7 @@ describe Crop do end it "loads a crop with a parent" do - parent = FactoryGirl.create(:crop, :name => 'parent') + parent = FactoryGirl.create(:crop, name: 'parent') tomato_row = "tomato,http://en.wikipedia.org/wiki/Tomato,parent" CSV.parse(tomato_row) do |row| @@ -539,7 +539,7 @@ describe Crop do context "crop-post association" do let!(:tomato) { FactoryGirl.create(:tomato) } let!(:maize) { FactoryGirl.create(:maize) } - let!(:post) { FactoryGirl.create(:post, :body => "[maize](crop)[tomato](crop)[tomato](crop)") } + let!(:post) { FactoryGirl.create(:post, body: "[maize](crop)[tomato](crop)[tomato](crop)") } describe "destroying a crop" do before do @@ -557,8 +557,8 @@ describe Crop do end context "crop rejections" do - let!(:rejected_reason) { FactoryGirl.create(:crop, :name => 'tomato', :approval_status => 'rejected', :reason_for_rejection => 'not edible') } - let!(:rejected_other) { FactoryGirl.create(:crop, :name => 'tomato', :approval_status => 'rejected', :reason_for_rejection => 'other', :rejection_notes => 'blah blah blah') } + let!(:rejected_reason) { FactoryGirl.create(:crop, name: 'tomato', approval_status: 'rejected', reason_for_rejection: 'not edible') } + let!(:rejected_other) { FactoryGirl.create(:crop, name: 'tomato', approval_status: 'rejected', reason_for_rejection: 'other', rejection_notes: 'blah blah blah') } describe "rejecting a crop" do it "should give reason if a default option" do diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb index 27b42de15..7bebbc7f3 100644 --- a/spec/models/follow_spec.rb +++ b/spec/models/follow_spec.rb @@ -9,13 +9,13 @@ describe Follow do it "sends a notification when a follow is created" do expect { - Follow.create(:follower_id => @member1.id, :followed_id => @member2.id) + Follow.create(follower_id: @member1.id, followed_id: @member2.id) }.to change(Notification, :count).by(1) end it "does not delete any members when follow is deleted" do expect { - follow = Follow.create(:follower_id => @member1.id, :followed_id => @member2.id) + follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id) follow.destroy }.not_to change(Member, :count) end @@ -23,11 +23,11 @@ describe Follow do context "when follow is created" do before (:each) do - @follow = Follow.create(:follower_id => @member1.id, :followed_id => @member2.id) + @follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id) end it "should not duplicate follows" do - expect(Follow.create(:follower_id => @member1.id, :followed_id => @member2.id)).not_to be_valid + expect(Follow.create(follower_id: @member1.id, followed_id: @member2.id)).not_to be_valid end it "should list users in following/follower collections when follow is created" do diff --git a/spec/models/forum_spec.rb b/spec/models/forum_spec.rb index 7c26c8f4b..72fafd31c 100644 --- a/spec/models/forum_spec.rb +++ b/spec/models/forum_spec.rb @@ -17,14 +17,14 @@ describe Forum do end it "has many posts" do - @post1 = FactoryGirl.create(:forum_post, :forum => forum) - @post2 = FactoryGirl.create(:forum_post, :forum => forum) + @post1 = FactoryGirl.create(:forum_post, forum: forum) + @post2 = FactoryGirl.create(:forum_post, forum: forum) forum.posts.size.should == 2 end it "orders posts in reverse chron order" do - @post1 = FactoryGirl.create(:forum_post, :forum => forum, :created_at => 2.days.ago) - @post2 = FactoryGirl.create(:forum_post, :forum => forum, :created_at => 1.day.ago) + @post1 = FactoryGirl.create(:forum_post, forum: forum, created_at: 2.days.ago) + @post2 = FactoryGirl.create(:forum_post, forum: forum, created_at: 1.day.ago) forum.posts.first.should eq @post2 end diff --git a/spec/models/garden_spec.rb b/spec/models/garden_spec.rb index ab52e2fac..1332e7287 100644 --- a/spec/models/garden_spec.rb +++ b/spec/models/garden_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe Garden do let(:owner) { FactoryGirl.create(:member) } - let(:garden) { FactoryGirl.create(:garden, :owner => owner) } + let(:garden) { FactoryGirl.create(:garden, owner: owner) } it "should have a slug" do garden.slug.should match(/member\d+-springfield-community-garden/) @@ -14,17 +14,17 @@ describe Garden do end it "doesn't allow a nil name" do - garden = FactoryGirl.build(:garden, :name => nil) + garden = FactoryGirl.build(:garden, name: nil) garden.should_not be_valid end it "doesn't allow a blank name" do - garden = FactoryGirl.build(:garden, :name => "") + garden = FactoryGirl.build(:garden, name: "") garden.should_not be_valid end it "doesn't allow a name with only spaces" do - garden = FactoryGirl.build(:garden, :name => " ") + garden = FactoryGirl.build(:garden, name: " ") garden.should_not be_valid end @@ -46,31 +46,31 @@ describe Garden do let(:walnut) { FactoryGirl.create(:walnut) } it "should fetch < 4 featured plantings if insufficient exist" do - @p1 = FactoryGirl.create(:planting, :crop => tomato, :garden => garden) - @p2 = FactoryGirl.create(:planting, :crop => maize, :garden => garden) + @p1 = FactoryGirl.create(:planting, crop: tomato, garden: garden) + @p2 = FactoryGirl.create(:planting, crop: maize, garden: garden) garden.featured_plantings.should eq [@p2, @p1] end it "should fetch most recent 4 featured plantings" do - @p1 = FactoryGirl.create(:planting, :crop => tomato, :garden => garden) - @p2 = FactoryGirl.create(:planting, :crop => maize, :garden => garden) - @p3 = FactoryGirl.create(:planting, :crop => chard, :garden => garden) - @p4 = FactoryGirl.create(:planting, :crop => apple, :garden => garden) - @p5 = FactoryGirl.create(:planting, :crop => walnut, :garden => garden) + @p1 = FactoryGirl.create(:planting, crop: tomato, garden: garden) + @p2 = FactoryGirl.create(:planting, crop: maize, garden: garden) + @p3 = FactoryGirl.create(:planting, crop: chard, garden: garden) + @p4 = FactoryGirl.create(:planting, crop: apple, garden: garden) + @p5 = FactoryGirl.create(:planting, crop: walnut, garden: garden) garden.featured_plantings.should eq [@p5, @p4, @p3, @p2] end it "should skip repeated plantings" do - @p1 = FactoryGirl.create(:planting, :crop => tomato, :garden => garden) - @p2 = FactoryGirl.create(:planting, :crop => maize, :garden => garden) - @p3 = FactoryGirl.create(:planting, :crop => chard, :garden => garden) - @p4 = FactoryGirl.create(:planting, :crop => apple, :garden => garden) - @p5 = FactoryGirl.create(:planting, :crop => walnut, :garden => garden) - @p6 = FactoryGirl.create(:planting, :crop => apple, :garden => garden) - @p7 = FactoryGirl.create(:planting, :crop => pear, :garden => garden) + @p1 = FactoryGirl.create(:planting, crop: tomato, garden: garden) + @p2 = FactoryGirl.create(:planting, crop: maize, garden: garden) + @p3 = FactoryGirl.create(:planting, crop: chard, garden: garden) + @p4 = FactoryGirl.create(:planting, crop: apple, garden: garden) + @p5 = FactoryGirl.create(:planting, crop: walnut, garden: garden) + @p6 = FactoryGirl.create(:planting, crop: apple, garden: garden) + @p7 = FactoryGirl.create(:planting, crop: pear, garden: garden) garden.featured_plantings.should eq [@p7, @p6, @p5, @p3] end @@ -85,9 +85,9 @@ describe Garden do end it "destroys plantings when deleted" do - garden = FactoryGirl.create(:garden, :owner => owner) - @planting1 = FactoryGirl.create(:planting, :garden => garden) - @planting2 = FactoryGirl.create(:planting, :garden => garden) + garden = FactoryGirl.create(:garden, owner: owner) + @planting1 = FactoryGirl.create(:planting, garden: garden) + @planting2 = FactoryGirl.create(:planting, garden: garden) garden.plantings.size.should == 2 all = Planting.count garden.destroy @@ -96,37 +96,37 @@ describe Garden do context 'area' do it 'allows numeric area' do - garden = FactoryGirl.build(:garden, :area => 33) + garden = FactoryGirl.build(:garden, area: 33) garden.should be_valid end it "doesn't allow negative area" do - garden = FactoryGirl.build(:garden, :area => -5) + garden = FactoryGirl.build(:garden, area: -5) garden.should_not be_valid end it 'allows decimal quantities' do - garden = FactoryGirl.build(:garden, :area => 3.3) + garden = FactoryGirl.build(:garden, area: 3.3) garden.should be_valid end it 'allows blank quantities' do - garden = FactoryGirl.build(:garden, :area => '') + garden = FactoryGirl.build(:garden, area: '') garden.should be_valid end it 'allows nil quantities' do - garden = FactoryGirl.build(:garden, :area => nil) + garden = FactoryGirl.build(:garden, area: nil) garden.should be_valid end it 'cleans up zero quantities' do - garden = FactoryGirl.build(:garden, :area => 0) + garden = FactoryGirl.build(:garden, area: 0) garden.area.should == 0 end it "doesn't allow non-numeric quantities" do - garden = FactoryGirl.build(:garden, :area => "99a") + garden = FactoryGirl.build(:garden, area: "99a") garden.should_not be_valid end end @@ -134,19 +134,19 @@ describe Garden do context 'units' do Garden::AREA_UNITS_VALUES.values.push(nil, '').each do |s| it "#{s} should be a valid unit" do - garden = FactoryGirl.build(:garden, :area_unit => s) + garden = FactoryGirl.build(:garden, area_unit: s) garden.should be_valid end end it 'should refuse invalid unit values' do - garden = FactoryGirl.build(:garden, :area_unit => 'not valid') + garden = FactoryGirl.build(:garden, area_unit: 'not valid') garden.should_not be_valid garden.errors[:area_unit].should include("not valid is not a valid area unit") end it 'sets area unit to blank if area is blank' do - garden = FactoryGirl.build(:garden, :area => '', :area_unit => 'acre') + garden = FactoryGirl.build(:garden, area: '', area_unit: 'acre') garden.should be_valid garden.area_unit.should eq nil end @@ -169,8 +169,8 @@ describe Garden do it "marks plantings as finished when garden is inactive" do garden = FactoryGirl.create(:garden) - p1 = FactoryGirl.create(:planting, :garden => garden) - p2 = FactoryGirl.create(:planting, :garden => garden) + p1 = FactoryGirl.create(:planting, garden: garden) + p2 = FactoryGirl.create(:planting, garden: garden) p1.finished.should eq false p2.finished.should eq false @@ -187,8 +187,8 @@ describe Garden do it "doesn't mark the wrong plantings as finished" do g1 = FactoryGirl.create(:garden) g2 = FactoryGirl.create(:garden) - p1 = FactoryGirl.create(:planting, :garden => g1) - p2 = FactoryGirl.create(:planting, :garden => g2) + p1 = FactoryGirl.create(:planting, garden: g1) + p2 = FactoryGirl.create(:planting, garden: g2) # mark the garden as inactive g1.active = false diff --git a/spec/models/harvest_spec.rb b/spec/models/harvest_spec.rb index f8e2c4f5a..583363aa2 100644 --- a/spec/models/harvest_spec.rb +++ b/spec/models/harvest_spec.rb @@ -14,32 +14,32 @@ describe Harvest do context 'quantity' do it 'allows numeric quantities' do - @harvest = FactoryGirl.build(:harvest, :quantity => 33) + @harvest = FactoryGirl.build(:harvest, quantity: 33) @harvest.should be_valid end it 'allows decimal quantities' do - @harvest = FactoryGirl.build(:harvest, :quantity => 3.3) + @harvest = FactoryGirl.build(:harvest, quantity: 3.3) @harvest.should be_valid end it 'allows blank quantities' do - @harvest = FactoryGirl.build(:harvest, :quantity => '') + @harvest = FactoryGirl.build(:harvest, quantity: '') @harvest.should be_valid end it 'allows nil quantities' do - @harvest = FactoryGirl.build(:harvest, :quantity => nil) + @harvest = FactoryGirl.build(:harvest, quantity: nil) @harvest.should be_valid end it 'cleans up zero quantities' do - @harvest = FactoryGirl.build(:harvest, :quantity => 0) + @harvest = FactoryGirl.build(:harvest, quantity: 0) @harvest.quantity.should == 0 end it "doesn't allow non-numeric quantities" do - @harvest = FactoryGirl.build(:harvest, :quantity => "99a") + @harvest = FactoryGirl.build(:harvest, quantity: "99a") @harvest.should_not be_valid end end @@ -47,19 +47,19 @@ 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| - @harvest = FactoryGirl.build(:harvest, :unit => s) + @harvest = FactoryGirl.build(:harvest, unit: s) @harvest.should be_valid end end it 'should refuse invalid unit values' do - @harvest = FactoryGirl.build(:harvest, :unit => 'not valid') + @harvest = FactoryGirl.build(:harvest, unit: 'not valid') @harvest.should_not be_valid @harvest.errors[:unit].should include("not valid is not a valid unit") end it 'sets unit to blank if quantity is blank' do - @harvest = FactoryGirl.build(:harvest, :quantity => '', :unit => 'individual') + @harvest = FactoryGirl.build(:harvest, quantity: '', unit: 'individual') @harvest.should be_valid @harvest.unit.should eq nil end @@ -67,32 +67,32 @@ describe Harvest do context 'weight quantity' do it 'allows numeric weight quantities' do - @harvest = FactoryGirl.build(:harvest, :weight_quantity => 33) + @harvest = FactoryGirl.build(:harvest, weight_quantity: 33) @harvest.should be_valid end it 'allows decimal weight quantities' do - @harvest = FactoryGirl.build(:harvest, :weight_quantity => 3.3) + @harvest = FactoryGirl.build(:harvest, weight_quantity: 3.3) @harvest.should be_valid end it 'allows blank weight quantities' do - @harvest = FactoryGirl.build(:harvest, :weight_quantity => '') + @harvest = FactoryGirl.build(:harvest, weight_quantity: '') @harvest.should be_valid end it 'allows nil weight quantities' do - @harvest = FactoryGirl.build(:harvest, :weight_quantity => nil) + @harvest = FactoryGirl.build(:harvest, weight_quantity: nil) @harvest.should be_valid end it 'cleans up zero quantities' do - @harvest = FactoryGirl.build(:harvest, :weight_quantity => 0) + @harvest = FactoryGirl.build(:harvest, weight_quantity: 0) @harvest.weight_quantity.should == 0 end it "doesn't allow non-numeric weight quantities" do - @harvest = FactoryGirl.build(:harvest, :weight_quantity => "99a") + @harvest = FactoryGirl.build(:harvest, weight_quantity: "99a") @harvest.should_not be_valid end end @@ -100,19 +100,19 @@ describe Harvest do context 'weight units' do it 'all valid units should work' do ['kg', 'lb', 'oz', nil, ''].each do |s| - @harvest = FactoryGirl.build(:harvest, :weight_unit => s) + @harvest = FactoryGirl.build(:harvest, weight_unit: s) @harvest.should be_valid end end it 'should refuse invalid weight unit values' do - @harvest = FactoryGirl.build(:harvest, :weight_unit => 'not valid') + @harvest = FactoryGirl.build(:harvest, weight_unit: 'not valid') @harvest.should_not be_valid @harvest.errors[:weight_unit].should include("not valid is not a valid unit") end it 'sets weight_unit to blank if quantity is blank' do - @harvest = FactoryGirl.build(:harvest, :weight_quantity => '', :weight_unit => 'kg') + @harvest = FactoryGirl.build(:harvest, weight_quantity: '', weight_unit: 'kg') @harvest.should be_valid @harvest.weight_unit.should eq nil end @@ -120,19 +120,19 @@ describe Harvest do context "standardized weights" do it 'converts from pounds' do - @harvest = FactoryGirl.create(:harvest, :weight_quantity => 2, :weight_unit => "lb") + @harvest = FactoryGirl.create(:harvest, weight_quantity: 2, weight_unit: "lb") @harvest.should be_valid @harvest.reload.si_weight.should eq 0.907 end it 'converts from ounces' do - @harvest = FactoryGirl.create(:harvest, :weight_quantity => 16, :weight_unit => "oz") + @harvest = FactoryGirl.create(:harvest, weight_quantity: 16, weight_unit: "oz") @harvest.should be_valid @harvest.reload.si_weight.should eq 0.454 end it 'leaves kg alone' do - @harvest = FactoryGirl.create(:harvest, :weight_quantity => 2, :weight_unit => "kg") + @harvest = FactoryGirl.create(:harvest, weight_quantity: 2, weight_unit: "kg") @harvest.should be_valid @harvest.reload.si_weight.should eq 2.0 end @@ -140,92 +140,92 @@ describe Harvest do context 'ordering' do it 'lists most recent harvests first' do - @h1 = FactoryGirl.create(:harvest, :created_at => 1.day.ago) - @h2 = FactoryGirl.create(:harvest, :created_at => 1.hour.ago) + @h1 = FactoryGirl.create(:harvest, created_at: 1.day.ago) + @h2 = FactoryGirl.create(:harvest, created_at: 1.hour.ago) Harvest.all.should eq [@h2, @h1] end end context "stringification" do - let(:crop) { FactoryGirl.create(:crop, :name => "apricot") } + let(:crop) { FactoryGirl.create(:crop, name: "apricot") } it "apricots" do - @h = FactoryGirl.create(:harvest, :crop => crop, - :quantity => nil, - :unit => nil, - :weight_quantity => nil, - :weight_unit => nil + @h = FactoryGirl.create(:harvest, crop: crop, + quantity: nil, + unit: nil, + weight_quantity: nil, + weight_unit: nil ) @h.to_s.should eq "apricots" end it "1 individual apricot" do - @h = FactoryGirl.create(:harvest, :crop => crop, - :quantity => 1, - :unit => 'individual', - :weight_quantity => nil, - :weight_unit => nil + @h = FactoryGirl.create(:harvest, crop: crop, + quantity: 1, + unit: 'individual', + weight_quantity: nil, + weight_unit: nil ) @h.to_s.should eq "1 individual apricot" end it "10 individual apricots" do - @h = FactoryGirl.create(:harvest, :crop => crop, - :quantity => 10, - :unit => 'individual', - :weight_quantity => nil, - :weight_unit => nil + @h = FactoryGirl.create(:harvest, crop: crop, + quantity: 10, + unit: 'individual', + weight_quantity: nil, + weight_unit: nil ) @h.to_s.should eq "10 individual apricots" end it "1 bushel of apricots" do - @h = FactoryGirl.create(:harvest, :crop => crop, - :quantity => 1, - :unit => 'bushel', - :weight_quantity => nil, - :weight_unit => nil + @h = FactoryGirl.create(:harvest, crop: crop, + quantity: 1, + unit: 'bushel', + weight_quantity: nil, + weight_unit: nil ) @h.to_s.should eq "1 bushel of apricots" end it "1.5 bushels of apricots" do - @h = FactoryGirl.create(:harvest, :crop => crop, - :quantity => 1.5, - :unit => 'bushel', - :weight_quantity => nil, - :weight_unit => nil + @h = FactoryGirl.create(:harvest, crop: crop, + quantity: 1.5, + unit: 'bushel', + weight_quantity: nil, + weight_unit: nil ) @h.to_s.should eq "1.5 bushels of apricots" end it "10 bushels of apricots" do - @h = FactoryGirl.create(:harvest, :crop => crop, - :quantity => 10, - :unit => 'bushel', - :weight_quantity => nil, - :weight_unit => nil + @h = FactoryGirl.create(:harvest, crop: crop, + quantity: 10, + unit: 'bushel', + weight_quantity: nil, + weight_unit: nil ) @h.to_s.should eq "10 bushels of apricots" end it "apricots weighing 1.2 kg" do - @h = FactoryGirl.create(:harvest, :crop => crop, - :quantity => nil, - :unit => nil, - :weight_quantity => 1.2, - :weight_unit => 'kg' + @h = FactoryGirl.create(:harvest, crop: crop, + quantity: nil, + unit: nil, + weight_quantity: 1.2, + weight_unit: 'kg' ) @h.to_s.should eq "apricots weighing 1.2 kg" end it "10 bushels of apricots weighing 100 kg" do - @h = FactoryGirl.create(:harvest, :crop => crop, - :quantity => 10, - :unit => 'bushel', - :weight_quantity => 100, - :weight_unit => 'kg') + @h = FactoryGirl.create(:harvest, crop: crop, + quantity: 10, + unit: 'bushel', + weight_quantity: 100, + weight_unit: 'kg') @h.to_s.should eq "10 bushels of apricots weighing 100 kg" end diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index 93760a904..dfb413df0 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -45,7 +45,7 @@ describe 'member' do end it 'should be able to fetch posts' do - @post = FactoryGirl.create(:post, :author => member) + @post = FactoryGirl.create(:post, author: member) member.posts.should eq [@post] end @@ -54,39 +54,39 @@ describe 'member' do end it 'has many plantings' do - @planting = FactoryGirl.create(:planting, :owner => member) + @planting = FactoryGirl.create(:planting, owner: member) member.plantings.size.should eq 1 end it "has many comments" do - @comment1 = FactoryGirl.create(:comment, :author => member) - @comment2 = FactoryGirl.create(:comment, :author => member) + @comment1 = FactoryGirl.create(:comment, author: member) + @comment2 = FactoryGirl.create(:comment, author: member) member.comments.size.should == 2 end it "has many forums" do - @forum1 = FactoryGirl.create(:forum, :owner => member) - @forum2 = FactoryGirl.create(:forum, :owner => member) + @forum1 = FactoryGirl.create(:forum, owner: member) + @forum2 = FactoryGirl.create(:forum, owner: member) member.forums.size.should == 2 end it 'has location and lat/long fields' do - member.update_attributes(:location => 'Greenwich, UK') + member.update_attributes(location: 'Greenwich, UK') member.location.should eq 'Greenwich, UK' member.latitude.round(2).should eq 51.48 member.longitude.round(2).should eq 0.00 end it 'empties the lat/long if location removed' do - member.update_attributes(:location => 'Greenwich, UK') - member.update_attributes(:location => '') + member.update_attributes(location: 'Greenwich, UK') + member.update_attributes(location: '') member.location.should eq '' member.latitude.should be_nil member.longitude.should be_nil end it 'fails gracefully for unfound locations' do - member.update_attributes(:location => 'Tatooine') + member.update_attributes(location: 'Tatooine') member.location.should eq 'Tatooine' member.latitude.should be_nil member.longitude.should be_nil @@ -114,15 +114,15 @@ describe 'member' do context 'same :login_name' do it "should not allow two members with the same login_name" do - FactoryGirl.create(:member, :login_name => "bob") - member = FactoryGirl.build(:member, :login_name => "bob") + FactoryGirl.create(:member, login_name: "bob") + member = FactoryGirl.build(:member, login_name: "bob") member.should_not be_valid member.errors[:login_name].should include("has already been taken") end it "tests uniqueness case-insensitively" do - FactoryGirl.create(:member, :login_name => "bob") - member = FactoryGirl.build(:member, :login_name => "BoB") + FactoryGirl.create(:member, login_name: "bob") + member = FactoryGirl.build(:member, login_name: "BoB") member.should_not be_valid member.errors[:login_name].should include("has already been taken") end @@ -130,7 +130,7 @@ describe 'member' do context 'case sensitivity' do it 'preserves case of login name' do - member = FactoryGirl.create(:member, :login_name => "BOB") + member = FactoryGirl.create(:member, login_name: "BOB") check = Member.find('bob') check.login_name.should eq 'BOB' end @@ -138,8 +138,8 @@ describe 'member' do context 'ordering' do it "should be sorted by name" do - z = FactoryGirl.create(:member, :login_name => "Zoe") - a = FactoryGirl.create(:member, :login_name => "Anna") + z = FactoryGirl.create(:member, login_name: "Zoe") + a = FactoryGirl.create(:member, login_name: "Anna") Member.first.should == a end end @@ -208,7 +208,7 @@ describe 'member' do it 'converts role names properly' do # need to make sure spaces get turned to underscores - @role = FactoryGirl.create(:role, :name => "a b c") + @role = FactoryGirl.create(:role, name: "a b c") member.roles << @role member.has_role?(:a_b_c).should eq true end @@ -246,7 +246,7 @@ describe 'member' do @london_member = FactoryGirl.create(:london_member) @london_member.latitude = nil @london_member.longitude = nil - @london_member.save(:validate => false) + @london_member.save(validate: false) Member.located.should_not include @london_member end end @@ -273,7 +273,7 @@ describe 'member' do @member4 = FactoryGirl.create(:unconfirmed_member) [@member1, @member2, @member3, @member4].each do |m| - FactoryGirl.create(:planting, :owner => m) + FactoryGirl.create(:planting, owner: m) end @member1.updated_at = 3.days.ago @@ -289,15 +289,15 @@ describe 'member' do context 'orders' do it 'finds the current order' do @member = FactoryGirl.create(:member) - @order1 = FactoryGirl.create(:completed_order, :member => @member) - @order2 = FactoryGirl.create(:order, :member => @member) + @order1 = FactoryGirl.create(:completed_order, member: @member) + @order2 = FactoryGirl.create(:order, member: @member) @member.current_order.should eq @order2 end it "copes if there's no current order" do @member = FactoryGirl.create(:member) - @order1 = FactoryGirl.create(:completed_order, :member => @member) - @order2 = FactoryGirl.create(:completed_order, :member => @member) + @order1 = FactoryGirl.create(:completed_order, member: @member) + @order2 = FactoryGirl.create(:completed_order, member: @member) @member.current_order.should be_nil end end @@ -308,14 +308,14 @@ describe 'member' do it "recognises a permanent paid account" do @account_type = FactoryGirl.create(:account_type, - :is_paid => true, :is_permanent_paid => true) + is_paid: true, is_permanent_paid: true) member.account.account_type = @account_type member.is_paid?.should be(true) end it "recognises a current paid account" do @account_type = FactoryGirl.create(:account_type, - :is_paid => true, :is_permanent_paid => false) + is_paid: true, is_permanent_paid: false) member.account.account_type = @account_type member.account.paid_until = Time.zone.now + 1.month member.is_paid?.should be(true) @@ -323,7 +323,7 @@ describe 'member' do it "recognises an expired paid account" do @account_type = FactoryGirl.create(:account_type, - :is_paid => true, :is_permanent_paid => false) + is_paid: true, is_permanent_paid: false) member.account.account_type = @account_type member.account.paid_until = Time.zone.now - 1.minute member.is_paid?.should be(false) @@ -331,14 +331,14 @@ describe 'member' do it "recognises a free account" do @account_type = FactoryGirl.create(:account_type, - :is_paid => false, :is_permanent_paid => false) + is_paid: false, is_permanent_paid: false) member.account.account_type = @account_type member.is_paid?.should be(false) end it "recognises a free account even with paid_until set" do @account_type = FactoryGirl.create(:account_type, - :is_paid => false, :is_permanent_paid => false) + is_paid: false, is_permanent_paid: false) member.account.account_type = @account_type member.account.paid_until = Time.zone.now + 1.month member.is_paid?.should be(false) @@ -349,7 +349,7 @@ describe 'member' do context "update account" do let(:product) { FactoryGirl.create(:product, - :paid_months => 3 + paid_months: 3 )} let(:member) { FactoryGirl.create(:member) } @@ -374,7 +374,7 @@ describe 'member' do context 'harvests' do it 'has harvests' do member = FactoryGirl.create(:member) - harvest = FactoryGirl.create(:harvest, :owner => member) + harvest = FactoryGirl.create(:harvest, owner: member) member.harvests.should eq [harvest] end end @@ -387,7 +387,7 @@ describe 'member' do let(:member3) { FactoryGirl.create(:member) } before do - @follow = member1.follows.create(:follower_id => member1.id, :followed_id => member2.id) + @follow = member1.follows.create(follower_id: member1.id, followed_id: member2.id) end context 'already_following' do diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index d14f731d1..e38444d5d 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -18,15 +18,15 @@ describe Notification do it "has a scope for unread" do Notification.unread.should eq [notification] - @n2 = FactoryGirl.create(:notification, :read => true) + @n2 = FactoryGirl.create(:notification, read: true) Notification.unread.should eq [notification] - @n3 = FactoryGirl.create(:notification, :read => false) + @n3 = FactoryGirl.create(:notification, read: false) Notification.unread.should eq [@n3, notification] end it "counts unread" do @who = notification.recipient - @n2 = FactoryGirl.create(:notification, :recipient => @who, :read => false) + @n2 = FactoryGirl.create(:notification, recipient: @who, read: false) @who.notifications.unread_count.should eq 2 end @@ -48,12 +48,12 @@ describe Notification do end it "replaces missing subjects with (no subject)" do - notification = FactoryGirl.create(:notification, :subject => nil) + notification = FactoryGirl.create(:notification, subject: nil) notification.subject.should == "(no subject)" end it "replaces whitespace-only subjects with (no subject)" do - notification = FactoryGirl.create(:notification, :subject => " ") + notification = FactoryGirl.create(:notification, subject: " ") notification.subject.should == "(no subject)" end diff --git a/spec/models/order_item_spec.rb b/spec/models/order_item_spec.rb index bd3b8f195..67f86415c 100644 --- a/spec/models/order_item_spec.rb +++ b/spec/models/order_item_spec.rb @@ -11,17 +11,17 @@ describe OrderItem do it "validates price > product.min_price" do @product = FactoryGirl.create(:product) - order_item = FactoryGirl.build(:order_item, :price => @product.min_price - 1) + order_item = FactoryGirl.build(:order_item, price: @product.min_price - 1) order_item.should_not be_valid end it "doesn't let you add two items to an order" do @product = FactoryGirl.create(:product) @order = FactoryGirl.create(:order) - order_item = FactoryGirl.build(:order_item, :order => @order) + order_item = FactoryGirl.build(:order_item, order: @order) order_item.should be_valid order_item.save - @order_item2 = FactoryGirl.build(:order_item, :order => @order) + @order_item2 = FactoryGirl.build(:order_item, order: @order) @order_item2.should_not be_valid end diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index 50fb6f949..9291e1a3f 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -5,7 +5,7 @@ describe Order do @order = FactoryGirl.create(:order) @product = FactoryGirl.create(:product) @order_item = FactoryGirl.create(:order_item, - :order_id => @order.id, :product_id => @product.id) + order_id: @order.id, product_id: @product.id) end it 'has order_items' do @@ -19,14 +19,14 @@ describe Order do it 'updates the account details' do @member = FactoryGirl.create(:member) - @order = FactoryGirl.create(:order, :member => @member) - @account_type = FactoryGirl.create(:account_type, :name => 'paid') + @order = FactoryGirl.create(:order, member: @member) + @account_type = FactoryGirl.create(:account_type, name: 'paid') @product = FactoryGirl.create(:product, - :account_type => @account_type, - :paid_months => 3 + account_type: @account_type, + paid_months: 3 ) @order_item = FactoryGirl.create(:order_item, - :order_id => @order.id, :product_id => @product.id) + order_id: @order.id, product_id: @product.id) @member.account.paid_until.should be_nil @@ -38,48 +38,48 @@ describe Order do it "totals the amount due" do @member = FactoryGirl.create(:member) - @order = FactoryGirl.create(:order, :member => @member) + @order = FactoryGirl.create(:order, member: @member) @product = FactoryGirl.create(:product, - :min_price => 1000 + min_price: 1000 ) # we force an order to only have one item at present. Add more if wanted # later. @order_item1 = FactoryGirl.create(:order_item, - :order_id => @order.id, :product_id => @product.id, :price => 1111, :quantity => 1) + order_id: @order.id, product_id: @product.id, price: 1111, quantity: 1) @order.total.should eq 1111 end it "gives the correct total for quantities more than 1" do @member = FactoryGirl.create(:member) - @order = FactoryGirl.create(:order, :member => @member) + @order = FactoryGirl.create(:order, member: @member) @product = FactoryGirl.create(:product, - :min_price => 1000 + min_price: 1000 ) # we force an order to only have one item at present. Add more if wanted # later. @order_item1 = FactoryGirl.create(:order_item, - :order_id => @order.id, :product_id => @product.id, :price => 1111, :quantity => 2) + order_id: @order.id, product_id: @product.id, price: 1111, quantity: 2) @order.total.should eq 2222 end it "formats order items for activemerchant" do @member = FactoryGirl.create(:member) - @order = FactoryGirl.create(:order, :member => @member) + @order = FactoryGirl.create(:order, member: @member) @product = FactoryGirl.create(:product, - :name => 'foo', - :min_price => 1000 + name: 'foo', + min_price: 1000 ) # we force an order to only have one item at present. Add more if wanted # later. @order_item1 = FactoryGirl.create(:order_item, - :order_id => @order.id, :product_id => @product.id, :price => 1111, :quantity => 1) + order_id: @order.id, product_id: @product.id, price: 1111, quantity: 1) @order.activemerchant_items.should eq [{ - :name => 'foo', - :quantity => 1, - :amount => 1111 + name: 'foo', + quantity: 1, + amount: 1111 }] end @@ -91,12 +91,12 @@ describe Order do end it "validates referral codes" do - referred_order = FactoryGirl.build(:order, :referral_code => 'CAMP_AIGN1?') + referred_order = FactoryGirl.build(:order, referral_code: 'CAMP_AIGN1?') referred_order.should_not be_valid end it "cleans up messy referral codes" do - referred_order = FactoryGirl.create(:order, :referral_code => 'CaMpAiGn 1 ') + referred_order = FactoryGirl.create(:order, referral_code: 'CaMpAiGn 1 ') referred_order.referral_code.should eq 'CAMPAIGN1' end end @@ -104,27 +104,27 @@ describe Order do context 'search' do it 'finds orders by member' do order = FactoryGirl.create(:order) - Order.search(:by => 'member', :for => order.member.login_name).should eq [order] + Order.search(by: 'member', for: order.member.login_name).should eq [order] end it 'finds orders by order_id' do order = FactoryGirl.create(:order) - Order.search(:by => 'order_id', :for => order.id).should eq [order] + Order.search(by: 'order_id', for: order.id).should eq [order] end it 'finds orders by paypal_token' do - order = FactoryGirl.create(:order, :paypal_express_token => 'foo') - Order.search(:by => 'paypal_token', :for => 'foo').should eq [order] + order = FactoryGirl.create(:order, paypal_express_token: 'foo') + Order.search(by: 'paypal_token', for: 'foo').should eq [order] end it 'finds orders by paypal_payer_id' do - order = FactoryGirl.create(:order, :paypal_express_payer_id => 'bar') - Order.search(:by => 'paypal_payer_id', :for => 'bar').should eq [order] + order = FactoryGirl.create(:order, paypal_express_payer_id: 'bar') + Order.search(by: 'paypal_payer_id', for: 'bar').should eq [order] end it 'finds orders by referral_code' do - order = FactoryGirl.create(:order, :referral_code => 'baz') - Order.search(:by => 'referral_code', :for => 'baz').should eq [order] + order = FactoryGirl.create(:order, referral_code: 'baz') + Order.search(by: 'referral_code', for: 'baz').should eq [order] end end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 36a9eb068..bd6335be2 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -115,7 +115,7 @@ describe Photo do # which was epistemologically unsatisfactory. # So we're just going to test that the method exists. it 'exists' do - photo = Photo.new(:owner_id => 1) + photo = Photo.new(owner_id: 1) photo.should.respond_to? :flickr_metadata end end diff --git a/spec/models/plant_part_spec.rb b/spec/models/plant_part_spec.rb index 30e118af8..ef3705ef2 100644 --- a/spec/models/plant_part_spec.rb +++ b/spec/models/plant_part_spec.rb @@ -11,12 +11,12 @@ describe PlantPart do @tomato = FactoryGirl.create(:tomato) @pp1 = FactoryGirl.create(:plant_part) @h1 = FactoryGirl.create(:harvest, - :crop => @tomato, - :plant_part => @pp1 + crop: @tomato, + plant_part: @pp1 ) @h2 = FactoryGirl.create(:harvest, - :crop => @maize, - :plant_part => @pp1 + crop: @maize, + plant_part: @pp1 ) @pp1.crops.should include @tomato @pp1.crops.should include @maize @@ -26,12 +26,12 @@ describe PlantPart do @maize = FactoryGirl.create(:maize) @pp1 = FactoryGirl.create(:plant_part) @h1 = FactoryGirl.create(:harvest, - :crop => @maize, - :plant_part => @pp1 + crop: @maize, + plant_part: @pp1 ) @h2 = FactoryGirl.create(:harvest, - :crop => @maize, - :plant_part => @pp1 + crop: @maize, + plant_part: @pp1 ) @pp1.crops.should eq [@maize] end diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index 9f48766be..3663f8c29 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -4,9 +4,9 @@ describe Planting do let(:crop) { FactoryGirl.create(:tomato) } let(:garden_owner) { FactoryGirl.create(:member) } - let(:garden) { FactoryGirl.create(:garden, :owner => garden_owner) } + let(:garden) { FactoryGirl.create(:garden, owner: garden_owner) } let(:planting) { FactoryGirl.create(:planting, - :crop => crop, :garden => garden)} + crop: crop, garden: garden)} it 'has an owner' do planting.owner.should be_an_instance_of Member @@ -100,24 +100,24 @@ describe Planting do context 'quantity' do it 'allows integer quantities' do - @planting = FactoryGirl.build(:planting, :quantity => 99) + @planting = FactoryGirl.build(:planting, quantity: 99) @planting.should be_valid end it "doesn't allow decimal quantities" do - @planting = FactoryGirl.build(:planting, :quantity => 99.9) + @planting = FactoryGirl.build(:planting, quantity: 99.9) @planting.should_not be_valid end it "doesn't allow non-numeric quantities" do - @planting = FactoryGirl.build(:planting, :quantity => 'foo') + @planting = FactoryGirl.build(:planting, quantity: 'foo') @planting.should_not be_valid end it "allows blank quantities" do - @planting = FactoryGirl.build(:planting, :quantity => nil) + @planting = FactoryGirl.build(:planting, quantity: nil) @planting.should be_valid - @planting = FactoryGirl.build(:planting, :quantity => '') + @planting = FactoryGirl.build(:planting, quantity: '') @planting.should be_valid end end @@ -132,13 +132,13 @@ describe Planting do it 'all three valid sunniness values should work' do ['sun', 'shade', 'semi-shade', nil, ''].each do |s| - @planting = FactoryGirl.build(:planting, :sunniness => s) + @planting = FactoryGirl.build(:planting, sunniness: s) @planting.should be_valid end end it 'should refuse invalid sunniness values' do - @planting = FactoryGirl.build(:planting, :sunniness => 'not valid') + @planting = FactoryGirl.build(:planting, sunniness: 'not valid') @planting.should_not be_valid @planting.errors[:sunniness].should include("not valid is not a valid sunniness value") end @@ -154,13 +154,13 @@ describe Planting do ['seed', 'seedling', 'cutting', 'root division', 'runner', 'bare root plant', 'advanced plant', 'graft', 'layering', 'bulb', 'root/tuber', nil, ''].each do |p| - @planting = FactoryGirl.build(:planting, :planted_from => p) + @planting = FactoryGirl.build(:planting, planted_from: p) @planting.should be_valid end end it 'should refuse invalid planted_from values' do - @planting = FactoryGirl.build(:planting, :planted_from => 'not valid') + @planting = FactoryGirl.build(:planting, planted_from: 'not valid') @planting.should_not be_valid @planting.errors[:planted_from].should include("not valid is not a valid planting method") end @@ -202,10 +202,10 @@ describe Planting do it 'picks up interesting plantings' do # plantings have members created implicitly for them # each member is different, hence these are all interesting - @planting1 = FactoryGirl.create(:planting, :created_at => 5.days.ago) - @planting2 = FactoryGirl.create(:planting, :created_at => 4.days.ago) - @planting3 = FactoryGirl.create(:planting, :created_at => 3.days.ago) - @planting4 = FactoryGirl.create(:planting, :created_at => 2.days.ago) + @planting1 = FactoryGirl.create(:planting, created_at: 5.days.ago) + @planting2 = FactoryGirl.create(:planting, created_at: 4.days.ago) + @planting3 = FactoryGirl.create(:planting, created_at: 3.days.ago) + @planting4 = FactoryGirl.create(:planting, created_at: 2.days.ago) # plantings need photos to be interesting @photo = FactoryGirl.create(:photo) @@ -238,14 +238,14 @@ describe Planting do it 'ignores plantings with the same owner' do # this planting is older - @planting1 = FactoryGirl.create(:planting, :created_at => 1.day.ago) + @planting1 = FactoryGirl.create(:planting, created_at: 1.day.ago) @planting1.photos << FactoryGirl.create(:photo) @planting1.save # this one is newer, and has the same owner, through the garden @planting2 = FactoryGirl.create(:planting, - :created_at => 1.minute.ago, - :owner_id => @planting1.owner.id + created_at: 1.minute.ago, + owner_id: @planting1.owner.id ) @planting2.photos << FactoryGirl.create(:photo) @planting2.save @@ -304,18 +304,17 @@ 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 it 'allows just the planted date' do - @f = FactoryGirl.build(:planting, :planted_at => '2013-01-01', :finished_at => nil) + @f = FactoryGirl.build(:planting, planted_at: '2013-01-01', finished_at: nil) @f.should be_valid end it 'allows just the finished date' do - @f = FactoryGirl.build(:planting, :finished_at => '2013-01-01', :planted_at => nil) + @f = FactoryGirl.build(:planting, finished_at: '2013-01-01', planted_at: nil) @f.should be_valid end end diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 61eb24bc1..45a37c47b 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -6,20 +6,20 @@ describe Post do it "should be sorted in reverse order" do FactoryGirl.create(:post, - :subject => 'first entry', - :author => member, - :created_at => 2.days.ago + subject: 'first entry', + author: member, + created_at: 2.days.ago ) FactoryGirl.create(:post, - :subject => 'second entry', - :author => member, - :created_at => 1.day.ago + subject: 'second entry', + author: member, + created_at: 1.day.ago ) Post.first.subject.should == "second entry" end it "should have a slug" do - @post = FactoryGirl.create(:post, :author => member) + @post = FactoryGirl.create(:post, author: member) @time = @post.created_at @datestr = @time.strftime("%Y%m%d") # 2 digit day and month, full-length years @@ -29,16 +29,16 @@ describe Post do end it "has many comments" do - @post = FactoryGirl.create(:post, :author => member) - @comment1 = FactoryGirl.create(:comment, :post => @post) - @comment2 = FactoryGirl.create(:comment, :post => @post) + @post = FactoryGirl.create(:post, author: member) + @comment1 = FactoryGirl.create(:comment, post: @post) + @comment2 = FactoryGirl.create(:comment, post: @post) @post.comments.size.should == 2 end it "destroys comments when deleted" do - @post = FactoryGirl.create(:post, :author => member) - @comment1 = FactoryGirl.create(:comment, :post => @post) - @comment2 = FactoryGirl.create(:comment, :post => @post) + @post = FactoryGirl.create(:post, author: member) + @comment1 = FactoryGirl.create(:comment, post: @post) + @comment2 = FactoryGirl.create(:comment, post: @post) @post.comments.size.should == 2 all = Comment.count @post.destroy @@ -51,47 +51,47 @@ describe Post do end it "doesn't allow a nil subject" do - @post = FactoryGirl.build(:post, :subject => nil) + @post = FactoryGirl.build(:post, subject: nil) @post.should_not be_valid end it "doesn't allow a blank subject" do - @post = FactoryGirl.build(:post, :subject => "") + @post = FactoryGirl.build(:post, subject: "") @post.should_not be_valid end it "doesn't allow a subject with only spaces" do - @post = FactoryGirl.build(:post, :subject => " ") + @post = FactoryGirl.build(:post, subject: " ") @post.should_not be_valid end context "recent activity" do before do - Time.stub(:now => Time.now) + Time.stub(now: Time.now) end - let(:post) { FactoryGirl.create(:post, :created_at => 1.day.ago) } + let(:post) { FactoryGirl.create(:post, created_at: 1.day.ago) } it "sets recent activity to post time" do post.recent_activity.to_i.should eq post.created_at.to_i end it "sets recent activity to comment time" do - @comment = FactoryGirl.create(:comment, :post => post, - :created_at => 1.hour.ago) + @comment = FactoryGirl.create(:comment, post: post, + created_at: 1.hour.ago) post.recent_activity.to_i.should eq @comment.created_at.to_i end it "shiny new post is recently active" do # create a shiny new post - @post2 = FactoryGirl.create(:post, :created_at => 1.minute.ago) + @post2 = FactoryGirl.create(:post, created_at: 1.minute.ago) Post.recently_active.first.should eq @post2 end it "new comment on old post is recently active" do # now comment on an older post - @comment2 = FactoryGirl.create(:comment, :post => post, :created_at => 1.second.ago) + @comment2 = FactoryGirl.create(:comment, post: post, created_at: 1.second.ago) Post.recently_active.first.should eq post end end @@ -101,12 +101,12 @@ describe Post do it "sends a notification when a member is mentioned" do expect { - FactoryGirl.create(:post, :author => member, :body => "Hey @" << member2.login_name) + FactoryGirl.create(:post, author: member, body: "Hey @" << member2.login_name) }.to change(Notification, :count).by(1) end it "sets the notification field" do - @p = FactoryGirl.create(:post, :author => member, :body => "Hey @" << member2.login_name) + @p = FactoryGirl.create(:post, author: member, body: "Hey @" << member2.login_name) @n = Notification.first @n.sender.should eq member @n.recipient.should eq member2 @@ -117,13 +117,13 @@ describe Post do it "sends notifications to all members mentioned" do @member3 = FactoryGirl.create(:member) expect { - FactoryGirl.create(:post, :author => member, :body => "Hey @" << member2.login_name << " & @" << @member3.login_name) + FactoryGirl.create(:post, author: member, body: "Hey @" << member2.login_name << " & @" << @member3.login_name) }.to change(Notification, :count).by(2) end it "doesn't send notifications if you mention yourself" do expect { - FactoryGirl.create(:post, :author => member, :body => "@" << member.login_name) + FactoryGirl.create(:post, author: member, body: "@" << member.login_name) }.to change(Notification, :count).by(0) end end @@ -132,7 +132,7 @@ describe Post do let!(:tomato) { FactoryGirl.create(:tomato) } let!(:maize) { FactoryGirl.create(:maize) } let!(:chard) { FactoryGirl.create(:chard) } - let!(:post) { FactoryGirl.create(:post, :body => "[maize](crop)[tomato](crop)[tomato](crop)") } + let!(:post) { FactoryGirl.create(:post, body: "[maize](crop)[tomato](crop)[tomato](crop)") } it "should be generated" do expect(tomato.posts).to eq [post] @@ -144,7 +144,7 @@ describe Post do end it "should be updated when post was modified" do - post.update_attributes(:body => "[chard](crop)") + post.update_attributes(body: "[chard](crop)") expect(post.crops).to eq [chard] expect(chard.posts).to eq [post] diff --git a/spec/models/seed_spec.rb b/spec/models/seed_spec.rb index 65008adcc..58ae5f906 100644 --- a/spec/models/seed_spec.rb +++ b/spec/models/seed_spec.rb @@ -15,24 +15,24 @@ describe Seed do context 'quantity' do it 'allows integer quantities' do - @seed = FactoryGirl.build(:seed, :quantity => 99) + @seed = FactoryGirl.build(:seed, quantity: 99) @seed.should be_valid end it "doesn't allow decimal quantities" do - @seed = FactoryGirl.build(:seed, :quantity => 99.9) + @seed = FactoryGirl.build(:seed, quantity: 99.9) @seed.should_not be_valid end it "doesn't allow non-numeric quantities" do - @seed = FactoryGirl.build(:seed, :quantity => 'foo') + @seed = FactoryGirl.build(:seed, quantity: 'foo') @seed.should_not be_valid end it "allows blank quantities" do - @seed = FactoryGirl.build(:seed, :quantity => nil) + @seed = FactoryGirl.build(:seed, quantity: nil) @seed.should be_valid - @seed = FactoryGirl.build(:seed, :quantity => '') + @seed = FactoryGirl.build(:seed, quantity: '') @seed.should be_valid end end @@ -40,32 +40,32 @@ describe Seed do context 'tradable' do it 'all valid tradable_to values should work' do ['nowhere', 'locally', 'nationally', 'internationally'].each do |t| - @seed = FactoryGirl.build(:seed, :tradable_to => t) + @seed = FactoryGirl.build(:seed, tradable_to: t) @seed.should be_valid end end it 'should refuse invalid tradable_to values' do - @seed = FactoryGirl.build(:seed, :tradable_to => 'not valid') + @seed = FactoryGirl.build(:seed, tradable_to: 'not valid') @seed.should_not be_valid @seed.errors[:tradable_to].should include("You may only trade seed nowhere, locally, nationally, or internationally") end it 'should not allow nil or blank values' do - @seed = FactoryGirl.build(:seed, :tradable_to => nil) + @seed = FactoryGirl.build(:seed, tradable_to: nil) @seed.should_not be_valid - @seed = FactoryGirl.build(:seed, :tradable_to => '') + @seed = FactoryGirl.build(:seed, tradable_to: '') @seed.should_not be_valid end it 'tradable? gives the right answers' do - @seed = FactoryGirl.create(:seed, :tradable_to => 'nowhere') + @seed = FactoryGirl.create(:seed, tradable_to: 'nowhere') @seed.tradable?.should eq false - @seed = FactoryGirl.create(:seed, :tradable_to => 'locally') + @seed = FactoryGirl.create(:seed, tradable_to: 'locally') @seed.tradable?.should eq true - @seed = FactoryGirl.create(:seed, :tradable_to => 'nationally') + @seed = FactoryGirl.create(:seed, tradable_to: 'nationally') @seed.tradable?.should eq true - @seed = FactoryGirl.create(:seed, :tradable_to => 'internationally') + @seed = FactoryGirl.create(:seed, tradable_to: 'internationally') @seed.tradable?.should eq true end @@ -90,7 +90,7 @@ describe Seed do it 'all valid organic values should work' do ['certified organic', 'non-certified organic', 'conventional/non-organic', 'unknown'].each do |t| - @seed = FactoryGirl.build(:seed, :organic => t) + @seed = FactoryGirl.build(:seed, organic: t) @seed.should be_valid end end @@ -98,14 +98,14 @@ describe Seed do it 'all valid GMO values should work' do ['certified GMO-free', 'non-certified GMO-free', 'GMO', 'unknown'].each do |t| - @seed = FactoryGirl.build(:seed, :gmo => t) + @seed = FactoryGirl.build(:seed, gmo: t) @seed.should be_valid end end it 'all valid heirloom values should work' do %w(heirloom hybrid unknown).each do |t| - @seed = FactoryGirl.build(:seed, :heirloom => t) + @seed = FactoryGirl.build(:seed, heirloom: t) @seed.should be_valid end end @@ -137,8 +137,8 @@ describe Seed do # 2) the owner must have a location set @located_member = FactoryGirl.create(:london_member) - @seed1 = FactoryGirl.create(:tradable_seed, :owner => @located_member) - @seed2 = FactoryGirl.create(:seed, :owner => @located_member) + @seed1 = FactoryGirl.create(:tradable_seed, owner: @located_member) + @seed2 = FactoryGirl.create(:seed, owner: @located_member) @seed3 = FactoryGirl.create(:tradable_seed) @seed4 = FactoryGirl.create(:seed) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 4d8a72a98..a30142f36 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -88,8 +88,8 @@ RSpec.configure do |config| # controller specs require this to work with Devise # see https://github.com/plataformatec/devise/wiki/How-To%3a-Controllers-and-Views-tests-with-Rails-3-%28and-rspec%29 - config.include Devise::TestHelpers, :type => :controller - config.extend ControllerMacros, :type => :controller + config.include Devise::TestHelpers, type: :controller + config.extend ControllerMacros, type: :controller # Allow just create(:factory) instead of needing to specify FactoryGirl.create(:factory) config.include FactoryGirl::Syntax::Methods diff --git a/spec/routing/account_types_routing_spec.rb b/spec/routing/account_types_routing_spec.rb index 440c16956..83dba34a5 100644 --- a/spec/routing/account_types_routing_spec.rb +++ b/spec/routing/account_types_routing_spec.rb @@ -12,11 +12,11 @@ describe AccountTypesController do end it "routes to #show" do - get("/account_types/1").should route_to("account_types#show", :id => "1") + get("/account_types/1").should route_to("account_types#show", id: "1") end it "routes to #edit" do - get("/account_types/1/edit").should route_to("account_types#edit", :id => "1") + get("/account_types/1/edit").should route_to("account_types#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe AccountTypesController do end it "routes to #update" do - put("/account_types/1").should route_to("account_types#update", :id => "1") + put("/account_types/1").should route_to("account_types#update", id: "1") end it "routes to #destroy" do - delete("/account_types/1").should route_to("account_types#destroy", :id => "1") + delete("/account_types/1").should route_to("account_types#destroy", id: "1") end end diff --git a/spec/routing/authentications_routing_spec.rb b/spec/routing/authentications_routing_spec.rb index 5d907428f..75f86fd49 100644 --- a/spec/routing/authentications_routing_spec.rb +++ b/spec/routing/authentications_routing_spec.rb @@ -7,7 +7,7 @@ describe AuthenticationsController do end it "routes to #destroy" do - delete("/authentications/1").should route_to("authentications#destroy", :id => "1") + delete("/authentications/1").should route_to("authentications#destroy", id: "1") end end diff --git a/spec/routing/comments_routing_spec.rb b/spec/routing/comments_routing_spec.rb index 4a0fe8026..b5466af43 100644 --- a/spec/routing/comments_routing_spec.rb +++ b/spec/routing/comments_routing_spec.rb @@ -12,11 +12,11 @@ describe CommentsController do end it "routes to #show" do - get("/comments/1").should route_to("comments#show", :id => "1") + get("/comments/1").should route_to("comments#show", id: "1") end it "routes to #edit" do - get("/comments/1/edit").should route_to("comments#edit", :id => "1") + get("/comments/1/edit").should route_to("comments#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe CommentsController do end it "routes to #update" do - put("/comments/1").should route_to("comments#update", :id => "1") + put("/comments/1").should route_to("comments#update", id: "1") end it "routes to #destroy" do - delete("/comments/1").should route_to("comments#destroy", :id => "1") + delete("/comments/1").should route_to("comments#destroy", id: "1") end end diff --git a/spec/routing/crops_routing_spec.rb b/spec/routing/crops_routing_spec.rb index 1e1fe4aac..95985917f 100644 --- a/spec/routing/crops_routing_spec.rb +++ b/spec/routing/crops_routing_spec.rb @@ -12,11 +12,11 @@ describe CropsController do end it "routes to #show" do - get("/crops/1").should route_to("crops#show", :id => "1") + get("/crops/1").should route_to("crops#show", id: "1") end it "routes to #edit" do - get("/crops/1/edit").should route_to("crops#edit", :id => "1") + get("/crops/1/edit").should route_to("crops#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe CropsController do end it "routes to #update" do - put("/crops/1").should route_to("crops#update", :id => "1") + put("/crops/1").should route_to("crops#update", id: "1") end it "routes to #destroy" do - delete("/crops/1").should route_to("crops#destroy", :id => "1") + delete("/crops/1").should route_to("crops#destroy", id: "1") end end diff --git a/spec/routing/follows_routing_spec.rb b/spec/routing/follows_routing_spec.rb index d4259e024..4158502c7 100644 --- a/spec/routing/follows_routing_spec.rb +++ b/spec/routing/follows_routing_spec.rb @@ -8,7 +8,7 @@ describe FollowsController do end it "routes to #destroy" do - delete("/follows/1").should route_to("follows#destroy", :id => "1") + delete("/follows/1").should route_to("follows#destroy", id: "1") end end diff --git a/spec/routing/forums_routing_spec.rb b/spec/routing/forums_routing_spec.rb index 4bd7d6097..12730c556 100644 --- a/spec/routing/forums_routing_spec.rb +++ b/spec/routing/forums_routing_spec.rb @@ -12,11 +12,11 @@ describe ForumsController do end it "routes to #show" do - get("/forums/1").should route_to("forums#show", :id => "1") + get("/forums/1").should route_to("forums#show", id: "1") end it "routes to #edit" do - get("/forums/1/edit").should route_to("forums#edit", :id => "1") + get("/forums/1/edit").should route_to("forums#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe ForumsController do end it "routes to #update" do - put("/forums/1").should route_to("forums#update", :id => "1") + put("/forums/1").should route_to("forums#update", id: "1") end it "routes to #destroy" do - delete("/forums/1").should route_to("forums#destroy", :id => "1") + delete("/forums/1").should route_to("forums#destroy", id: "1") end end diff --git a/spec/routing/gardens_routing_spec.rb b/spec/routing/gardens_routing_spec.rb index 1c627e091..5270195ec 100644 --- a/spec/routing/gardens_routing_spec.rb +++ b/spec/routing/gardens_routing_spec.rb @@ -12,11 +12,11 @@ describe GardensController do end it "routes to #show" do - get("/gardens/1").should route_to("gardens#show", :id => "1") + get("/gardens/1").should route_to("gardens#show", id: "1") end it "routes to #edit" do - get("/gardens/1/edit").should route_to("gardens#edit", :id => "1") + get("/gardens/1/edit").should route_to("gardens#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe GardensController do end it "routes to #update" do - put("/gardens/1").should route_to("gardens#update", :id => "1") + put("/gardens/1").should route_to("gardens#update", id: "1") end it "routes to #destroy" do - delete("/gardens/1").should route_to("gardens#destroy", :id => "1") + delete("/gardens/1").should route_to("gardens#destroy", id: "1") end end diff --git a/spec/routing/harvests_routing_spec.rb b/spec/routing/harvests_routing_spec.rb index 8b34d920a..4d532bcfc 100644 --- a/spec/routing/harvests_routing_spec.rb +++ b/spec/routing/harvests_routing_spec.rb @@ -12,11 +12,11 @@ describe HarvestsController do end it "routes to #show" do - get("/harvests/1").should route_to("harvests#show", :id => "1") + get("/harvests/1").should route_to("harvests#show", id: "1") end it "routes to #edit" do - get("/harvests/1/edit").should route_to("harvests#edit", :id => "1") + get("/harvests/1/edit").should route_to("harvests#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe HarvestsController do end it "routes to #update" do - put("/harvests/1").should route_to("harvests#update", :id => "1") + put("/harvests/1").should route_to("harvests#update", id: "1") end it "routes to #destroy" do - delete("/harvests/1").should route_to("harvests#destroy", :id => "1") + delete("/harvests/1").should route_to("harvests#destroy", id: "1") end end diff --git a/spec/routing/notifications_routing_spec.rb b/spec/routing/notifications_routing_spec.rb index 35f54689f..d3c2b9f61 100644 --- a/spec/routing/notifications_routing_spec.rb +++ b/spec/routing/notifications_routing_spec.rb @@ -12,11 +12,11 @@ describe NotificationsController do end it "routes to #show" do - get("/notifications/1").should route_to("notifications#show", :id => "1") + get("/notifications/1").should route_to("notifications#show", id: "1") end it "routes to #edit" do - get("/notifications/1/edit").should route_to("notifications#edit", :id => "1") + get("/notifications/1/edit").should route_to("notifications#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe NotificationsController do end it "routes to #update" do - put("/notifications/1").should route_to("notifications#update", :id => "1") + put("/notifications/1").should route_to("notifications#update", id: "1") end it "routes to #destroy" do - delete("/notifications/1").should route_to("notifications#destroy", :id => "1") + delete("/notifications/1").should route_to("notifications#destroy", id: "1") end end diff --git a/spec/routing/order_items_routing_spec.rb b/spec/routing/order_items_routing_spec.rb index 858a873ad..6562e3a17 100644 --- a/spec/routing/order_items_routing_spec.rb +++ b/spec/routing/order_items_routing_spec.rb @@ -12,11 +12,11 @@ describe OrderItemsController do end it "routes to #show" do - get("/order_items/1").should route_to("order_items#show", :id => "1") + get("/order_items/1").should route_to("order_items#show", id: "1") end it "routes to #edit" do - get("/order_items/1/edit").should route_to("order_items#edit", :id => "1") + get("/order_items/1/edit").should route_to("order_items#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe OrderItemsController do end it "routes to #update" do - put("/order_items/1").should route_to("order_items#update", :id => "1") + put("/order_items/1").should route_to("order_items#update", id: "1") end it "routes to #destroy" do - delete("/order_items/1").should route_to("order_items#destroy", :id => "1") + delete("/order_items/1").should route_to("order_items#destroy", id: "1") end end diff --git a/spec/routing/orders_routing_spec.rb b/spec/routing/orders_routing_spec.rb index 7fc9735ee..61410745e 100644 --- a/spec/routing/orders_routing_spec.rb +++ b/spec/routing/orders_routing_spec.rb @@ -12,11 +12,11 @@ describe OrdersController do end it "routes to #show" do - get("/orders/1").should route_to("orders#show", :id => "1") + get("/orders/1").should route_to("orders#show", id: "1") end it "routes to #edit" do - get("/orders/1/edit").should route_to("orders#edit", :id => "1") + get("/orders/1/edit").should route_to("orders#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe OrdersController do end it "routes to #update" do - put("/orders/1").should route_to("orders#update", :id => "1") + put("/orders/1").should route_to("orders#update", id: "1") end it "routes to #destroy" do - delete("/orders/1").should route_to("orders#destroy", :id => "1") + delete("/orders/1").should route_to("orders#destroy", id: "1") end end diff --git a/spec/routing/photos_routing_spec.rb b/spec/routing/photos_routing_spec.rb index 5bdfeca07..fb96758c2 100644 --- a/spec/routing/photos_routing_spec.rb +++ b/spec/routing/photos_routing_spec.rb @@ -12,11 +12,11 @@ describe PhotosController do end it "routes to #show" do - get("/photos/1").should route_to("photos#show", :id => "1") + get("/photos/1").should route_to("photos#show", id: "1") end it "routes to #edit" do - get("/photos/1/edit").should route_to("photos#edit", :id => "1") + get("/photos/1/edit").should route_to("photos#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe PhotosController do end it "routes to #update" do - put("/photos/1").should route_to("photos#update", :id => "1") + put("/photos/1").should route_to("photos#update", id: "1") end it "routes to #destroy" do - delete("/photos/1").should route_to("photos#destroy", :id => "1") + delete("/photos/1").should route_to("photos#destroy", id: "1") end end diff --git a/spec/routing/plant_parts_routing_spec.rb b/spec/routing/plant_parts_routing_spec.rb index 54d02caa1..4a4137cd6 100644 --- a/spec/routing/plant_parts_routing_spec.rb +++ b/spec/routing/plant_parts_routing_spec.rb @@ -12,11 +12,11 @@ describe PlantPartsController do end it "routes to #show" do - get("/plant_parts/1").should route_to("plant_parts#show", :id => "1") + get("/plant_parts/1").should route_to("plant_parts#show", id: "1") end it "routes to #edit" do - get("/plant_parts/1/edit").should route_to("plant_parts#edit", :id => "1") + get("/plant_parts/1/edit").should route_to("plant_parts#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe PlantPartsController do end it "routes to #update" do - put("/plant_parts/1").should route_to("plant_parts#update", :id => "1") + put("/plant_parts/1").should route_to("plant_parts#update", id: "1") end it "routes to #destroy" do - delete("/plant_parts/1").should route_to("plant_parts#destroy", :id => "1") + delete("/plant_parts/1").should route_to("plant_parts#destroy", id: "1") end end diff --git a/spec/routing/plantings_routing_spec.rb b/spec/routing/plantings_routing_spec.rb index bf3e1e8b8..1be8416d4 100644 --- a/spec/routing/plantings_routing_spec.rb +++ b/spec/routing/plantings_routing_spec.rb @@ -12,11 +12,11 @@ describe PlantingsController do end it "routes to #show" do - get("/plantings/1").should route_to("plantings#show", :id => "1") + get("/plantings/1").should route_to("plantings#show", id: "1") end it "routes to #edit" do - get("/plantings/1/edit").should route_to("plantings#edit", :id => "1") + get("/plantings/1/edit").should route_to("plantings#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe PlantingsController do end it "routes to #update" do - put("/plantings/1").should route_to("plantings#update", :id => "1") + put("/plantings/1").should route_to("plantings#update", id: "1") end it "routes to #destroy" do - delete("/plantings/1").should route_to("plantings#destroy", :id => "1") + delete("/plantings/1").should route_to("plantings#destroy", id: "1") end end diff --git a/spec/routing/products_routing_spec.rb b/spec/routing/products_routing_spec.rb index a9c2fa004..189bbe59a 100644 --- a/spec/routing/products_routing_spec.rb +++ b/spec/routing/products_routing_spec.rb @@ -12,11 +12,11 @@ describe ProductsController do end it "routes to #show" do - get("/products/1").should route_to("products#show", :id => "1") + get("/products/1").should route_to("products#show", id: "1") end it "routes to #edit" do - get("/products/1/edit").should route_to("products#edit", :id => "1") + get("/products/1/edit").should route_to("products#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe ProductsController do end it "routes to #update" do - put("/products/1").should route_to("products#update", :id => "1") + put("/products/1").should route_to("products#update", id: "1") end it "routes to #destroy" do - delete("/products/1").should route_to("products#destroy", :id => "1") + delete("/products/1").should route_to("products#destroy", id: "1") end end diff --git a/spec/routing/roles_routing_spec.rb b/spec/routing/roles_routing_spec.rb index 0a7900f9d..752bd7c49 100644 --- a/spec/routing/roles_routing_spec.rb +++ b/spec/routing/roles_routing_spec.rb @@ -12,11 +12,11 @@ describe RolesController do end it "routes to #show" do - get("/roles/1").should route_to("roles#show", :id => "1") + get("/roles/1").should route_to("roles#show", id: "1") end it "routes to #edit" do - get("/roles/1/edit").should route_to("roles#edit", :id => "1") + get("/roles/1/edit").should route_to("roles#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe RolesController do end it "routes to #update" do - put("/roles/1").should route_to("roles#update", :id => "1") + put("/roles/1").should route_to("roles#update", id: "1") end it "routes to #destroy" do - delete("/roles/1").should route_to("roles#destroy", :id => "1") + delete("/roles/1").should route_to("roles#destroy", id: "1") end end diff --git a/spec/routing/scientific_names_routing_spec.rb b/spec/routing/scientific_names_routing_spec.rb index 00c049289..f5bfa780e 100644 --- a/spec/routing/scientific_names_routing_spec.rb +++ b/spec/routing/scientific_names_routing_spec.rb @@ -12,11 +12,11 @@ describe ScientificNamesController do end it "routes to #show" do - get("/scientific_names/1").should route_to("scientific_names#show", :id => "1") + get("/scientific_names/1").should route_to("scientific_names#show", id: "1") end it "routes to #edit" do - get("/scientific_names/1/edit").should route_to("scientific_names#edit", :id => "1") + get("/scientific_names/1/edit").should route_to("scientific_names#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe ScientificNamesController do end it "routes to #update" do - put("/scientific_names/1").should route_to("scientific_names#update", :id => "1") + put("/scientific_names/1").should route_to("scientific_names#update", id: "1") end it "routes to #destroy" do - delete("/scientific_names/1").should route_to("scientific_names#destroy", :id => "1") + delete("/scientific_names/1").should route_to("scientific_names#destroy", id: "1") end end diff --git a/spec/routing/seeds_routing_spec.rb b/spec/routing/seeds_routing_spec.rb index 4fe46774a..5ac7ae02c 100644 --- a/spec/routing/seeds_routing_spec.rb +++ b/spec/routing/seeds_routing_spec.rb @@ -12,11 +12,11 @@ describe SeedsController do end it "routes to #show" do - get("/seeds/1").should route_to("seeds#show", :id => "1") + get("/seeds/1").should route_to("seeds#show", id: "1") end it "routes to #edit" do - get("/seeds/1/edit").should route_to("seeds#edit", :id => "1") + get("/seeds/1/edit").should route_to("seeds#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe SeedsController do end it "routes to #update" do - put("/seeds/1").should route_to("seeds#update", :id => "1") + put("/seeds/1").should route_to("seeds#update", id: "1") end it "routes to #destroy" do - delete("/seeds/1").should route_to("seeds#destroy", :id => "1") + delete("/seeds/1").should route_to("seeds#destroy", id: "1") end end diff --git a/spec/routing/updates_routing_spec.rb b/spec/routing/updates_routing_spec.rb index 9ff2b5ccd..32be13b86 100644 --- a/spec/routing/updates_routing_spec.rb +++ b/spec/routing/updates_routing_spec.rb @@ -12,11 +12,11 @@ describe PostsController do end it "routes to #show" do - get("/posts/1").should route_to("posts#show", :id => "1") + get("/posts/1").should route_to("posts#show", id: "1") end it "routes to #edit" do - get("/posts/1/edit").should route_to("posts#edit", :id => "1") + get("/posts/1/edit").should route_to("posts#edit", id: "1") end it "routes to #create" do @@ -24,11 +24,11 @@ describe PostsController do end it "routes to #update" do - put("/posts/1").should route_to("posts#update", :id => "1") + put("/posts/1").should route_to("posts#update", id: "1") end it "routes to #destroy" do - delete("/posts/1").should route_to("posts#destroy", :id => "1") + delete("/posts/1").should route_to("posts#destroy", id: "1") end end diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index b3e908378..051579ea7 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -8,7 +8,7 @@ RSpec.configure do |config| DatabaseCleaner.strategy = :transaction end - config.before(:each, :js => true) do + config.before(:each, js: true) do DatabaseCleaner.strategy = :truncation end diff --git a/spec/support/devise.rb b/spec/support/devise.rb index 5d898b4d3..5fffd6c3f 100644 --- a/spec/support/devise.rb +++ b/spec/support/devise.rb @@ -1,4 +1,4 @@ RSpec.configure do |config| - config.include Devise::TestHelpers, :type => :controller - config.include Devise::TestHelpers, :type => :view + config.include Devise::TestHelpers, type: :controller + config.include Devise::TestHelpers, type: :view end diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index 81b781d18..b4da3b755 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -1,7 +1,7 @@ module FeatureHelpers def fill_autocomplete(field, options={}) - fill_in field, :with => options[:with] + fill_in field, with: options[:with] page.execute_script %Q{ $('##{field}').trigger('focus'); } page.execute_script %Q{ $('##{field}').trigger('keydown'); } @@ -16,5 +16,5 @@ module FeatureHelpers end RSpec.configure do |config| - config.include FeatureHelpers, :type => :feature + config.include FeatureHelpers, type: :feature end \ No newline at end of file diff --git a/spec/views/about/contact_spec.rb b/spec/views/about/contact_spec.rb index ce5b5afec..695be51b4 100644 --- a/spec/views/about/contact_spec.rb +++ b/spec/views/about/contact_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'about/contact.html.haml', :type => "view" do +describe 'about/contact.html.haml', type: "view" do before(:each) do render end diff --git a/spec/views/account_types/edit.html.haml_spec.rb b/spec/views/account_types/edit.html.haml_spec.rb index e8aeae7c0..f8fa80cc3 100644 --- a/spec/views/account_types/edit.html.haml_spec.rb +++ b/spec/views/account_types/edit.html.haml_spec.rb @@ -19,9 +19,9 @@ require 'rails_helper' describe "account_types/edit" do before(:each) do @account_type = assign(:account_type, stub_model(AccountType, - :name => "MyString", - :is_paid => false, - :is_permanent_paid => false + name: "MyString", + is_paid: false, + is_permanent_paid: false )) end @@ -29,10 +29,10 @@ describe "account_types/edit" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => account_types_path(@account_type), :method => "post" do - assert_select "input#account_type_name", :name => "account_type[name]" - assert_select "input#account_type_is_paid", :name => "account_type[is_paid]" - assert_select "input#account_type_is_permanent_paid", :name => "account_type[is_permanent_paid]" + assert_select "form", action: account_types_path(@account_type), method: "post" do + assert_select "input#account_type_name", name: "account_type[name]" + assert_select "input#account_type_is_paid", name: "account_type[is_paid]" + assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" end end end diff --git a/spec/views/account_types/index.html.haml_spec.rb b/spec/views/account_types/index.html.haml_spec.rb index aed40b2af..76a83d269 100644 --- a/spec/views/account_types/index.html.haml_spec.rb +++ b/spec/views/account_types/index.html.haml_spec.rb @@ -25,6 +25,6 @@ describe "account_types/index" do it "renders a list of account_types" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", :text => @type.name.to_s, :count => 2 + assert_select "tr>td", text: @type.name.to_s, count: 2 end end diff --git a/spec/views/account_types/new.html.haml_spec.rb b/spec/views/account_types/new.html.haml_spec.rb index 1fd496b55..8ec9fc1ff 100644 --- a/spec/views/account_types/new.html.haml_spec.rb +++ b/spec/views/account_types/new.html.haml_spec.rb @@ -19,9 +19,9 @@ require 'rails_helper' describe "account_types/new" do before(:each) do assign(:account_type, stub_model(AccountType, - :name => "MyString", - :is_paid => false, - :is_permanent_paid => false + name: "MyString", + is_paid: false, + is_permanent_paid: false ).as_new_record) end @@ -29,10 +29,10 @@ describe "account_types/new" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => account_types_path, :method => "post" do - assert_select "input#account_type_name", :name => "account_type[name]" - assert_select "input#account_type_is_paid", :name => "account_type[is_paid]" - assert_select "input#account_type_is_permanent_paid", :name => "account_type[is_permanent_paid]" + assert_select "form", action: account_types_path, method: "post" do + assert_select "input#account_type_name", name: "account_type[name]" + assert_select "input#account_type_is_paid", name: "account_type[is_paid]" + assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" end end end diff --git a/spec/views/account_types/show.html.haml_spec.rb b/spec/views/account_types/show.html.haml_spec.rb index 84861f8a3..bfbd50243 100644 --- a/spec/views/account_types/show.html.haml_spec.rb +++ b/spec/views/account_types/show.html.haml_spec.rb @@ -19,9 +19,9 @@ require 'rails_helper' describe "account_types/show" do before(:each) do @account_type = assign(:account_type, stub_model(AccountType, - :name => "Name", - :is_paid => false, - :is_permanent_paid => false + name: "Name", + is_paid: false, + is_permanent_paid: false )) end diff --git a/spec/views/accounts/edit.html.haml_spec.rb b/spec/views/accounts/edit.html.haml_spec.rb index 522707304..2f265658f 100644 --- a/spec/views/accounts/edit.html.haml_spec.rb +++ b/spec/views/accounts/edit.html.haml_spec.rb @@ -26,9 +26,9 @@ describe "accounts/edit" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => accounts_path(@account), :method => "post" do - assert_select "input#account_member_id", :name => "account[member_id]" - assert_select "input#account_account_type", :name => "account[account_type]" + assert_select "form", action: accounts_path(@account), method: "post" do + assert_select "input#account_member_id", name: "account[member_id]" + assert_select "input#account_account_type", name: "account[account_type]" end end end diff --git a/spec/views/accounts/index.html.haml_spec.rb b/spec/views/accounts/index.html.haml_spec.rb index 98802ad6d..60b2cf6f6 100644 --- a/spec/views/accounts/index.html.haml_spec.rb +++ b/spec/views/accounts/index.html.haml_spec.rb @@ -26,6 +26,6 @@ describe "accounts/index" do it "renders a list of accounts" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", :text => @account.member_id.to_s, :count => 2 + assert_select "tr>td", text: @account.member_id.to_s, count: 2 end end diff --git a/spec/views/accounts/new.html.haml_spec.rb b/spec/views/accounts/new.html.haml_spec.rb index 2cf2dcef7..f51649226 100644 --- a/spec/views/accounts/new.html.haml_spec.rb +++ b/spec/views/accounts/new.html.haml_spec.rb @@ -26,9 +26,9 @@ describe "accounts/new" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => accounts_path, :method => "post" do - assert_select "input#account_member_id", :name => "account[member_id]" - assert_select "input#account_account_type", :name => "account[account_type]" + assert_select "form", action: accounts_path, method: "post" do + assert_select "input#account_member_id", name: "account[member_id]" + assert_select "input#account_account_type", name: "account[account_type]" end end end diff --git a/spec/views/admin/index_spec.rb b/spec/views/admin/index_spec.rb index e82f7b641..79ac5d965 100644 --- a/spec/views/admin/index_spec.rb +++ b/spec/views/admin/index_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'admin/index.html.haml', :type => "view" do +describe 'admin/index.html.haml', type: "view" do before(:each) do @member = FactoryGirl.create(:admin_member) sign_in @member @@ -25,10 +25,10 @@ describe 'admin/index.html.haml', :type => "view" do end it "includes links to manage various things" do - assert_select "a", :href => account_types_path - assert_select "a", :href => products_path - assert_select "a", :href => roles_path - assert_select "a", :href => forums_path + assert_select "a", href: account_types_path + assert_select "a", href: products_path + assert_select "a", href: roles_path + assert_select "a", href: forums_path end it "has a link to newsletter subscribers" do diff --git a/spec/views/admin/newsletter_spec.rb b/spec/views/admin/newsletter_spec.rb index 6ea4abeb0..55f02d0fa 100644 --- a/spec/views/admin/newsletter_spec.rb +++ b/spec/views/admin/newsletter_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'admin/newsletter.html.haml', :type => "view" do +describe 'admin/newsletter.html.haml', type: "view" do before(:each) do @member = FactoryGirl.create(:admin_member) sign_in @member diff --git a/spec/views/admin/orders/index_spec.rb b/spec/views/admin/orders/index_spec.rb index 00fbd811e..55d55773d 100644 --- a/spec/views/admin/orders/index_spec.rb +++ b/spec/views/admin/orders/index_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'admin/orders/index.html.haml', :type => "view" do +describe 'admin/orders/index.html.haml', type: "view" do before(:each) do @member = FactoryGirl.create(:admin_member) sign_in @member @@ -31,6 +31,6 @@ describe 'admin/orders/index.html.haml', :type => "view" do end it "lets you search by referral code" do - assert_select "option[value=referral_code]", :text => "Referral code" + assert_select "option[value=referral_code]", text: "Referral code" end end diff --git a/spec/views/comments/edit.html.haml_spec.rb b/spec/views/comments/edit.html.haml_spec.rb index a3ba59479..d6e7ccb2a 100644 --- a/spec/views/comments/edit.html.haml_spec.rb +++ b/spec/views/comments/edit.html.haml_spec.rb @@ -26,8 +26,8 @@ describe "comments/edit" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => comments_path(@comment), :method => "post" do - assert_select "textarea#comment_body", :name => "comment[body]" + assert_select "form", action: comments_path(@comment), method: "post" do + assert_select "textarea#comment_body", name: "comment[body]" end end end diff --git a/spec/views/comments/index.html.haml_spec.rb b/spec/views/comments/index.html.haml_spec.rb index 2c237da3a..4b8cbf72f 100644 --- a/spec/views/comments/index.html.haml_spec.rb +++ b/spec/views/comments/index.html.haml_spec.rb @@ -25,7 +25,7 @@ describe "comments/index" do comments = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| pager.replace([ FactoryGirl.create(:comment), - FactoryGirl.create(:comment, :body => 'ROFL') + FactoryGirl.create(:comment, body: 'ROFL') ]) end assign(:comments, comments) @@ -39,6 +39,6 @@ describe "comments/index" do end it "contains an RSS feed link" do - assert_select "a", :href => comments_path(:format => 'rss') + assert_select "a", href: comments_path(format: 'rss') end end diff --git a/spec/views/comments/index.rss.haml_spec.rb b/spec/views/comments/index.rss.haml_spec.rb index 58c07a6c8..9c61e9f2d 100644 --- a/spec/views/comments/index.rss.haml_spec.rb +++ b/spec/views/comments/index.rss.haml_spec.rb @@ -22,8 +22,8 @@ describe 'comments/index.rss.haml' do @author = FactoryGirl.create(:member) @post = FactoryGirl.create(:post) assign(:comments, [ - FactoryGirl.create(:comment, :author => @author, :post => @post), - FactoryGirl.create(:comment, :author => @author, :post => @post) + FactoryGirl.create(:comment, author: @author, post: @post), + FactoryGirl.create(:comment, author: @author, post: @post) ]) render end diff --git a/spec/views/comments/new.html.haml_spec.rb b/spec/views/comments/new.html.haml_spec.rb index 981211c8d..d86d304cf 100644 --- a/spec/views/comments/new.html.haml_spec.rb +++ b/spec/views/comments/new.html.haml_spec.rb @@ -20,7 +20,7 @@ describe "comments/new" do before(:each) do controller.stub(:current_user) { nil } @post = FactoryGirl.create(:post) - @comment = FactoryGirl.create(:comment, :post => @post) + @comment = FactoryGirl.create(:comment, post: @post) assign(:comment, @comment) assign(:comments, [@comment]) render @@ -39,8 +39,8 @@ describe "comments/new" do end it "renders new comment form" do - assert_select "form", :action => comments_path, :method => "post" do - assert_select "textarea#comment_body", :name => "comment[body]" + assert_select "form", action: comments_path, method: "post" do + assert_select "textarea#comment_body", name: "comment[body]" end end diff --git a/spec/views/crops/_grown_for.html.haml_spec.rb b/spec/views/crops/_grown_for.html.haml_spec.rb index d77e6ee29..10a36aff9 100644 --- a/spec/views/crops/_grown_for.html.haml_spec.rb +++ b/spec/views/crops/_grown_for.html.haml_spec.rb @@ -21,14 +21,14 @@ describe "crops/_grown_for" do @crop = FactoryGirl.create(:crop) @pp = FactoryGirl.create(:plant_part) @harvest = FactoryGirl.create(:harvest, - :crop => @crop, - :plant_part => @pp + crop: @crop, + plant_part: @pp ) end it 'shows plant parts' do - render :partial => 'crops/grown_for', :locals => { :crop => @crop } + render partial: 'crops/grown_for', locals: { crop: @crop } rendered.should have_content @pp.name - assert_select "a", :href => plant_part_path(@pp) + assert_select "a", href: plant_part_path(@pp) end end diff --git a/spec/views/crops/_planting_advice.html.haml_spec.rb b/spec/views/crops/_planting_advice.html.haml_spec.rb index c902a7827..77e7e1b38 100644 --- a/spec/views/crops/_planting_advice.html.haml_spec.rb +++ b/spec/views/crops/_planting_advice.html.haml_spec.rb @@ -20,31 +20,31 @@ describe "crops/_planting_advice" do before(:each) do @owner = FactoryGirl.create(:member) @crop = FactoryGirl.create(:crop) - @garden = FactoryGirl.create(:garden, :owner => @owner) + @garden = FactoryGirl.create(:garden, owner: @owner) @planting = FactoryGirl.create(:planting, - :garden => @garden, - :crop => @crop + garden: @garden, + crop: @crop ) end context "sunniness" do it "doesn't show sunniness if none are set" do - render :partial => 'crops/planting_advice', :locals => { :crop => @crop } + render partial: 'crops/planting_advice', locals: { crop: @crop } rendered.should have_content "Plant in: not known." end it "shows sunniness frequencies" do - FactoryGirl.create(:sunny_planting, :crop => @crop) - render :partial => 'crops/planting_advice', :locals => { :crop => @crop } + FactoryGirl.create(:sunny_planting, crop: @crop) + render partial: 'crops/planting_advice', locals: { crop: @crop } rendered.should have_content "Plant in:" rendered.should have_content "sun (1)" end it "shows multiple sunniness frequencies" do - FactoryGirl.create(:sunny_planting, :crop => @crop) - FactoryGirl.create(:sunny_planting, :crop => @crop) - FactoryGirl.create(:shady_planting, :crop => @crop) - render :partial => 'crops/planting_advice', :locals => { :crop => @crop } + FactoryGirl.create(:sunny_planting, crop: @crop) + FactoryGirl.create(:sunny_planting, crop: @crop) + FactoryGirl.create(:shady_planting, crop: @crop) + render partial: 'crops/planting_advice', locals: { crop: @crop } rendered.should have_content "Plant in:" rendered.should have_content "sun (2), shade (1)" end @@ -54,22 +54,22 @@ describe "crops/_planting_advice" do context "planted from" do it "doesn't show planted_from if none are set" do - render :partial => 'crops/planting_advice', :locals => { :crop => @crop } + render partial: 'crops/planting_advice', locals: { crop: @crop } rendered.should have_content "Plant from: not known." end it "shows planted_from frequencies" do - FactoryGirl.create(:seed_planting, :crop => @crop) - render :partial => 'crops/planting_advice', :locals => { :crop => @crop } + FactoryGirl.create(:seed_planting, crop: @crop) + render partial: 'crops/planting_advice', locals: { crop: @crop } rendered.should have_content "Plant from:" rendered.should have_content "seed (1)" end it "shows multiple planted_from frequencies" do - FactoryGirl.create(:seed_planting, :crop => @crop) - FactoryGirl.create(:seed_planting, :crop => @crop) - FactoryGirl.create(:cutting_planting, :crop => @crop) - render :partial => 'crops/planting_advice', :locals => { :crop => @crop } + FactoryGirl.create(:seed_planting, crop: @crop) + FactoryGirl.create(:seed_planting, crop: @crop) + FactoryGirl.create(:cutting_planting, crop: @crop) + render partial: 'crops/planting_advice', locals: { crop: @crop } rendered.should have_content "Plant from:" rendered.should have_content "seed (2), cutting (1)" end diff --git a/spec/views/crops/_popover.html.haml_spec.rb b/spec/views/crops/_popover.html.haml_spec.rb index a98cc6e10..3ef9660f6 100644 --- a/spec/views/crops/_popover.html.haml_spec.rb +++ b/spec/views/crops/_popover.html.haml_spec.rb @@ -19,10 +19,10 @@ require 'rails_helper' describe "crops/_popover" do before(:each) do @tomato = FactoryGirl.create(:tomato) - @sn = FactoryGirl.create(:solanum_lycopersicum, :crop => @tomato) - @planting = FactoryGirl.create(:planting, :crop => @tomato) + @sn = FactoryGirl.create(:solanum_lycopersicum, crop: @tomato) + @planting = FactoryGirl.create(:planting, crop: @tomato) @tomato.reload # to pick up latest plantings_count - render :partial => 'crops/popover', :locals => { :crop => @tomato } + render partial: 'crops/popover', locals: { crop: @tomato } end it 'has a scientific name' do diff --git a/spec/views/crops/hierarchy.html.haml_spec.rb b/spec/views/crops/hierarchy.html.haml_spec.rb index 9cef87105..32bfc4248 100644 --- a/spec/views/crops/hierarchy.html.haml_spec.rb +++ b/spec/views/crops/hierarchy.html.haml_spec.rb @@ -20,12 +20,12 @@ describe "crops/hierarchy" do before(:each) do controller.stub(:current_user) { nil } @tomato = FactoryGirl.create(:tomato) - @roma = FactoryGirl.create(:crop, :name => 'Roma tomato', :parent => @tomato) + @roma = FactoryGirl.create(:crop, name: 'Roma tomato', parent: @tomato) assign(:crops, [@tomato, @roma]) render end it "shows crop hierarchy" do - assert_select "ul>li>ul>li", :text => @roma.name + assert_select "ul>li>ul>li", text: @roma.name end end diff --git a/spec/views/crops/index.html.haml_spec.rb b/spec/views/crops/index.html.haml_spec.rb index 096f1632e..0a779241d 100644 --- a/spec/views/crops/index.html.haml_spec.rb +++ b/spec/views/crops/index.html.haml_spec.rb @@ -32,16 +32,16 @@ describe "crops/index" do end it "shows photos where available" do - @planting = FactoryGirl.create(:planting, :crop => @tomato) + @planting = FactoryGirl.create(:planting, crop: @tomato) @photo = FactoryGirl.create(:photo) @planting.photos << @photo render - assert_select "img", :src => @photo.thumbnail_url + assert_select "img", src: @photo.thumbnail_url end it "linkifies crop images" do render - assert_select "img", :src => :tomato + assert_select "img", src: :tomato end context "logged in and crop wrangler" do @@ -61,9 +61,9 @@ describe "crops/index" do it "offers data downloads" do render rendered.should have_content "The data on this page is available in the following formats:" - assert_select "a", :href => crops_path(:format => 'csv') - assert_select "a", :href => crops_path(:format => 'json') - assert_select "a", :href => crops_path(:format => 'rss') + assert_select "a", href: crops_path(format: 'csv') + assert_select "a", href: crops_path(format: 'json') + assert_select "a", href: crops_path(format: 'rss') end end end diff --git a/spec/views/crops/wrangle.html.haml_spec.rb b/spec/views/crops/wrangle.html.haml_spec.rb index c0a29b4cd..e4f41b8c8 100644 --- a/spec/views/crops/wrangle.html.haml_spec.rb +++ b/spec/views/crops/wrangle.html.haml_spec.rb @@ -40,13 +40,13 @@ describe "crops/wrangle" do it 'has a link to add a crop' do render - assert_select "a", :href => new_crop_path + assert_select "a", href: new_crop_path end it "renders a list of crops" do render - assert_select "a", :text => @maize.name - assert_select "a", :text => @tomato.name + assert_select "a", text: @maize.name + assert_select "a", text: @tomato.name end end diff --git a/spec/views/devise/confirmations/new_spec.rb b/spec/views/devise/confirmations/new_spec.rb index 1e1555db3..8d567d793 100644 --- a/spec/views/devise/confirmations/new_spec.rb +++ b/spec/views/devise/confirmations/new_spec.rb @@ -1,4 +1,4 @@ -describe 'devise/confirmations/new.html.haml', :type => "view" do +describe 'devise/confirmations/new.html.haml', type: "view" do before(:each) do @view.stub(:resource).and_return(Member.new) diff --git a/spec/views/devise/mailer/confirmation_instructions_spec.rb b/spec/views/devise/mailer/confirmation_instructions_spec.rb index d1805f2f9..6f60268e4 100644 --- a/spec/views/devise/mailer/confirmation_instructions_spec.rb +++ b/spec/views/devise/mailer/confirmation_instructions_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'devise/mailer/confirmation_instructions.html.haml', :type => "view" do +describe 'devise/mailer/confirmation_instructions.html.haml', type: "view" do context "logged in" do before(:each) do diff --git a/spec/views/devise/mailer/reset_password_instructions_spec.rb b/spec/views/devise/mailer/reset_password_instructions_spec.rb index 28c76144f..91c46a696 100644 --- a/spec/views/devise/mailer/reset_password_instructions_spec.rb +++ b/spec/views/devise/mailer/reset_password_instructions_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'devise/mailer/reset_password_instructions.html.haml', :type => "view" do +describe 'devise/mailer/reset_password_instructions.html.haml', type: "view" do context "logged in" do before(:each) do diff --git a/spec/views/devise/mailer/unlock_instructions_spec.rb b/spec/views/devise/mailer/unlock_instructions_spec.rb index 5112da12c..5c90260c5 100644 --- a/spec/views/devise/mailer/unlock_instructions_spec.rb +++ b/spec/views/devise/mailer/unlock_instructions_spec.rb @@ -15,7 +15,7 @@ require 'rails_helper' -describe 'devise/mailer/unlock_instructions.html.haml', :type => "view" do +describe 'devise/mailer/unlock_instructions.html.haml', type: "view" do context "logged in" do before(:each) do @resource = FactoryGirl.create(:member) diff --git a/spec/views/devise/registrations/edit_spec.rb b/spec/views/devise/registrations/edit_spec.rb index 50f44d6e7..8fb096255 100644 --- a/spec/views/devise/registrations/edit_spec.rb +++ b/spec/views/devise/registrations/edit_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'devise/registrations/edit.html.haml', :type => "view" do +describe 'devise/registrations/edit.html.haml', type: "view" do context "logged in" do before(:each) do @@ -58,11 +58,11 @@ describe 'devise/registrations/edit.html.haml', :type => "view" do end it "contains a gravatar icon" do - assert_select "img", :src => /gravatar\.com\/avatar/ + assert_select "img", src: /gravatar\.com\/avatar/ end it 'contains a link to gravatar.com' do - assert_select "a", :href => /gravatar\.com/ + assert_select "a", href: /gravatar\.com/ end it 'shows bio field' do @@ -84,15 +84,15 @@ describe 'devise/registrations/edit.html.haml', :type => "view" do end context 'connected to twitter' do before(:each) do - @twitter_auth = FactoryGirl.create(:authentication, :member => @member) + @twitter_auth = FactoryGirl.create(:authentication, member: @member) render end it 'has a link to twitter profile' do - assert_select "a", :href => "http://twitter.com/#{@twitter_auth.name}" + assert_select "a", href: "http://twitter.com/#{@twitter_auth.name}" end it 'has a link to disconnect' do render - assert_select "a", :href => @twitter_auth, :text => "Disconnect" + assert_select "a", href: @twitter_auth, text: "Disconnect" end end @@ -104,15 +104,15 @@ describe 'devise/registrations/edit.html.haml', :type => "view" do end context 'connected to flickr' do before(:each) do - @flickr_auth = FactoryGirl.create(:flickr_authentication, :member => @member) + @flickr_auth = FactoryGirl.create(:flickr_authentication, member: @member) render end it 'has a link to flickr photostream' do - assert_select "a", :href => "http://flickr.com/photos/#{@flickr_auth.uid}" + assert_select "a", href: "http://flickr.com/photos/#{@flickr_auth.uid}" end it 'has a link to disconnect' do render - assert_select "a", :href => @flickr_auth, :text => "Disconnect" + assert_select "a", href: @flickr_auth, text: "Disconnect" end end diff --git a/spec/views/devise/registrations/new_spec.rb b/spec/views/devise/registrations/new_spec.rb index 8a63d0884..5d6d8ac5a 100644 --- a/spec/views/devise/registrations/new_spec.rb +++ b/spec/views/devise/registrations/new_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'devise/registrations/new.html.haml', :type => "view" do +describe 'devise/registrations/new.html.haml', type: "view" do context "logged in" do before(:each) do diff --git a/spec/views/devise/sessions/new_spec.rb b/spec/views/devise/sessions/new_spec.rb index 418b53d56..674e92978 100644 --- a/spec/views/devise/sessions/new_spec.rb +++ b/spec/views/devise/sessions/new_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'devise/sessions/new.html.haml', :type => "view" do +describe 'devise/sessions/new.html.haml', type: "view" do context "logged in" do before(:each) do diff --git a/spec/views/devise/shared/_links_spec.rb b/spec/views/devise/shared/_links_spec.rb index 41f9b45ef..7e71bbc12 100644 --- a/spec/views/devise/shared/_links_spec.rb +++ b/spec/views/devise/shared/_links_spec.rb @@ -1,28 +1,26 @@ -describe 'devise/shared/_links.haml', :type => "view" do +describe 'devise/shared/_links.haml', type: "view" do def devise_mapping(register, recover, confirm, lock, oauth) dm = double("mappings") - dm.stub(:registerable? => register) - dm.stub(:recoverable? => recover) - dm.stub(:confirmable? => confirm) - dm.stub(:lockable? => lock) - dm.stub(:omniauthable? => oauth) + dm.stub(registerable?: register) + dm.stub(recoverable?: recover) + dm.stub(confirmable?: confirm) + dm.stub(lockable?: lock) + dm.stub(omniauthable?: oauth) return dm end 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/devise/unlocks/new_spec.rb b/spec/views/devise/unlocks/new_spec.rb index 4a060d78f..e145900e4 100644 --- a/spec/views/devise/unlocks/new_spec.rb +++ b/spec/views/devise/unlocks/new_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'devise/unlocks/new.html.haml', :type => "view" do +describe 'devise/unlocks/new.html.haml', type: "view" do context "logged in" do before(:each) do diff --git a/spec/views/forums/edit.html.haml_spec.rb b/spec/views/forums/edit.html.haml_spec.rb index 762a6d806..e3c874519 100644 --- a/spec/views/forums/edit.html.haml_spec.rb +++ b/spec/views/forums/edit.html.haml_spec.rb @@ -19,9 +19,9 @@ require 'rails_helper' describe "forums/edit" do before(:each) do @forum = assign(:forum, stub_model(Forum, - :name => "MyString", - :description => "MyText", - :owner_id => 1 + name: "MyString", + description: "MyText", + owner_id: 1 )) end @@ -29,10 +29,10 @@ describe "forums/edit" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => forums_path(@forum), :method => "post" do - assert_select "input#forum_name", :name => "forum[name]" - assert_select "textarea#forum_description", :name => "forum[description]" - assert_select "select#forum_owner_id", :name => "forum[owner_id]" + assert_select "form", action: forums_path(@forum), method: "post" do + assert_select "input#forum_name", name: "forum[name]" + assert_select "textarea#forum_description", name: "forum[description]" + assert_select "select#forum_owner_id", name: "forum[owner_id]" end end end diff --git a/spec/views/forums/index.html.haml_spec.rb b/spec/views/forums/index.html.haml_spec.rb index 07da3cf4f..dc1bdba58 100644 --- a/spec/views/forums/index.html.haml_spec.rb +++ b/spec/views/forums/index.html.haml_spec.rb @@ -27,7 +27,7 @@ describe "forums/index" do it "renders a list of forums" do render - assert_select "h2", :text => @forum1.name, :count => 2 + assert_select "h2", text: @forum1.name, count: 2 end it "doesn't display posts for empty forums" do @@ -37,8 +37,8 @@ describe "forums/index" do context "posts" do before(:each) do - @post = FactoryGirl.create(:forum_post, :forum => @forum1) - @comment = FactoryGirl.create(:comment, :post => @post) + @post = FactoryGirl.create(:forum_post, forum: @forum1) + @comment = FactoryGirl.create(:comment, post: @post) render end @@ -49,7 +49,7 @@ describe "forums/index" do end it "displays comment count" do - assert_select "td", :text => "1" + assert_select "td", text: "1" end end diff --git a/spec/views/forums/new.html.haml_spec.rb b/spec/views/forums/new.html.haml_spec.rb index 5785b1b21..59988ae90 100644 --- a/spec/views/forums/new.html.haml_spec.rb +++ b/spec/views/forums/new.html.haml_spec.rb @@ -23,10 +23,10 @@ describe "forums/new" do end it "renders new forum form" do - assert_select "form", :action => forums_path, :method => "post" do - assert_select "input#forum_name", :name => "forum[name]" - assert_select "textarea#forum_description", :name => "forum[description]" - assert_select "select#forum_owner_id", :name => "forum[owner_id]" + assert_select "form", action: forums_path, method: "post" do + assert_select "input#forum_name", name: "forum[name]" + assert_select "textarea#forum_description", name: "forum[description]" + assert_select "select#forum_owner_id", name: "forum[owner_id]" end end end diff --git a/spec/views/forums/show.html.haml_spec.rb b/spec/views/forums/show.html.haml_spec.rb index 119e411f6..a012c248e 100644 --- a/spec/views/forums/show.html.haml_spec.rb +++ b/spec/views/forums/show.html.haml_spec.rb @@ -35,7 +35,7 @@ describe "forums/show" do it 'links to new post with the forum id' do render - assert_select "a[href=#{new_post_path(:forum_id => @forum.id)}]" + assert_select "a[href=#{new_post_path(forum_id: @forum.id)}]" end it 'has no posts' do @@ -44,7 +44,7 @@ describe "forums/show" do end it 'shows posts' do - @post = FactoryGirl.create(:post, :forum => @forum) + @post = FactoryGirl.create(:post, forum: @forum) render assert_select "table" rendered.should have_content @post.subject diff --git a/spec/views/gardens/edit.html.haml_spec.rb b/spec/views/gardens/edit.html.haml_spec.rb index 3900dad35..959600d77 100644 --- a/spec/views/gardens/edit.html.haml_spec.rb +++ b/spec/views/gardens/edit.html.haml_spec.rb @@ -23,7 +23,7 @@ describe "gardens/edit" do @owner = FactoryGirl.create(:member) sign_in @owner controller.stub(:current_user) { @owner } - @garden = assign(:garden, FactoryGirl.create(:garden, :owner => @owner)) + @garden = assign(:garden, FactoryGirl.create(:garden, owner: @owner)) render end @@ -31,13 +31,13 @@ describe "gardens/edit" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => gardens_path(@garden), :method => "post" do - assert_select "input#garden_name", :name => "garden[name]" - assert_select "textarea#garden_description", :name => "garden[description]" - assert_select "input#garden_location", :name => "garden[location]" - assert_select "input#garden_area", :name => "garden[area]" - assert_select "select#garden_area_unit", :name => "garden[area_unit]" - assert_select "input#garden_active", :name => "garden[active]" + assert_select "form", action: gardens_path(@garden), method: "post" do + assert_select "input#garden_name", name: "garden[name]" + assert_select "textarea#garden_description", name: "garden[description]" + assert_select "input#garden_location", name: "garden[location]" + assert_select "input#garden_area", name: "garden[area]" + assert_select "select#garden_area_unit", name: "garden[area_unit]" + assert_select "input#garden_active", name: "garden[active]" end end end diff --git a/spec/views/gardens/new.html.haml_spec.rb b/spec/views/gardens/new.html.haml_spec.rb index 056079f89..84b689eb0 100644 --- a/spec/views/gardens/new.html.haml_spec.rb +++ b/spec/views/gardens/new.html.haml_spec.rb @@ -21,19 +21,19 @@ describe "gardens/new" do @member = FactoryGirl.create(:member) sign_in @member controller.stub(:current_user) { @member } - @garden = FactoryGirl.create(:garden, :owner => @member) + @garden = FactoryGirl.create(:garden, owner: @member) assign(:garden, @garden) render end it "renders new garden form" do - assert_select "form", :action => gardens_path, :method => "post" do - assert_select "input#garden_name", :name => "garden[name]" - assert_select "textarea#garden_description", :name => "garden[description]" - assert_select "input#garden_location", :name => "garden[location]" - assert_select "input#garden_area", :name => "garden[area]" - assert_select "select#garden_area_unit", :name => "garden[area_unit]" - assert_select "input#garden_active", :name => "garden[active]" + assert_select "form", action: gardens_path, method: "post" do + assert_select "input#garden_name", name: "garden[name]" + assert_select "textarea#garden_description", name: "garden[description]" + assert_select "input#garden_location", name: "garden[location]" + assert_select "input#garden_area", name: "garden[area]" + assert_select "select#garden_area_unit", name: "garden[area_unit]" + assert_select "input#garden_active", name: "garden[active]" end end end diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 7c4f2c143..3753e075e 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -20,8 +20,8 @@ describe "gardens/show" do before(:each) do @owner = FactoryGirl.create(:member) controller.stub(:current_user) { @owner } - @garden = FactoryGirl.create(:garden, :owner => @owner) - @planting = FactoryGirl.create(:planting, :garden => @garden) + @garden = FactoryGirl.create(:garden, owner: @owner) + @planting = FactoryGirl.create(:planting, garden: @garden) assign(:garden, @garden) render end diff --git a/spec/views/harvests/edit.html.haml_spec.rb b/spec/views/harvests/edit.html.haml_spec.rb index f7c175667..f318e3a79 100644 --- a/spec/views/harvests/edit.html.haml_spec.rb +++ b/spec/views/harvests/edit.html.haml_spec.rb @@ -23,15 +23,15 @@ describe "harvests/edit" do end it "renders new harvest form" do - assert_select "form", :action => harvests_path, :method => "post" do - assert_select "input#crop", :class => "ui-autocomplete-input" - assert_select "input#harvest_crop_id", :name => "harvest[crop_id]" - assert_select "select#harvest_plant_part_id", :name => "harvest[plant_part_id]" - assert_select "input#harvest_quantity", :name => "harvest[quantity]" - assert_select "input#harvest_weight_quantity", :name => "harvest[quantity]" - assert_select "select#harvest_unit", :name => "harvest[unit]" - assert_select "select#harvest_weight_unit", :name => "harvest[unit]" - assert_select "textarea#harvest_description", :name => "harvest[description]" + assert_select "form", action: harvests_path, method: "post" do + assert_select "input#crop", class: "ui-autocomplete-input" + assert_select "input#harvest_crop_id", name: "harvest[crop_id]" + assert_select "select#harvest_plant_part_id", name: "harvest[plant_part_id]" + assert_select "input#harvest_quantity", name: "harvest[quantity]" + assert_select "input#harvest_weight_quantity", name: "harvest[quantity]" + assert_select "select#harvest_unit", name: "harvest[unit]" + assert_select "select#harvest_weight_unit", name: "harvest[unit]" + assert_select "textarea#harvest_description", name: "harvest[description]" end end end diff --git a/spec/views/harvests/index.html.haml_spec.rb b/spec/views/harvests/index.html.haml_spec.rb index 0c2dfe5bb..923b3fb39 100644 --- a/spec/views/harvests/index.html.haml_spec.rb +++ b/spec/views/harvests/index.html.haml_spec.rb @@ -29,13 +29,13 @@ describe "harvests/index" do harvests = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| pager.replace([ FactoryGirl.create(:harvest, - :crop => @tomato, - :owner => @member + crop: @tomato, + owner: @member ), FactoryGirl.create(:harvest, - :crop => @maize, - :plant_part => @pp, - :owner => @member + crop: @maize, + plant_part: @pp, + owner: @member ) ]) end @@ -46,8 +46,8 @@ describe "harvests/index" do it "provides data links" do render rendered.should have_content "The data on this page is available in the following formats:" - assert_select "a", :href => harvests_path(:format => 'csv') - assert_select "a", :href => harvests_path(:format => 'json') + assert_select "a", href: harvests_path(format: 'csv') + assert_select "a", href: harvests_path(format: 'json') end it "displays member's name in title" do diff --git a/spec/views/harvests/new.html.haml_spec.rb b/spec/views/harvests/new.html.haml_spec.rb index 015b94dda..20a908310 100644 --- a/spec/views/harvests/new.html.haml_spec.rb +++ b/spec/views/harvests/new.html.haml_spec.rb @@ -23,16 +23,16 @@ describe "harvests/new" do end it "renders new harvest form" do - assert_select "form", :action => harvests_path, :method => "post" do - assert_select "input#crop", :class => "ui-autocomplete-input" - assert_select "input#harvest_crop_id", :name => "harvest[crop_id]" - assert_select "select#harvest_plant_part_id", :name => "harvest[plant_part_id]" + assert_select "form", action: harvests_path, method: "post" do + assert_select "input#crop", class: "ui-autocomplete-input" + assert_select "input#harvest_crop_id", name: "harvest[crop_id]" + assert_select "select#harvest_plant_part_id", name: "harvest[plant_part_id]" # some browsers interpret without a step as "integer" - assert_select "input#harvest_quantity[step=any]", :name => "harvest[quantity]" - assert_select "input#harvest_weight_quantity[step=any]", :name => "harvest[quantity]" - assert_select "select#harvest_unit", :name => "harvest[unit]" - assert_select "select#harvest_weight_unit", :name => "harvest[unit]" - assert_select "textarea#harvest_description", :name => "harvest[description]" + assert_select "input#harvest_quantity[step=any]", name: "harvest[quantity]" + assert_select "input#harvest_weight_quantity[step=any]", name: "harvest[quantity]" + assert_select "select#harvest_unit", name: "harvest[unit]" + assert_select "select#harvest_weight_unit", name: "harvest[unit]" + assert_select "textarea#harvest_description", name: "harvest[description]" end end end diff --git a/spec/views/harvests/show.html.haml_spec.rb b/spec/views/harvests/show.html.haml_spec.rb index 56d69b608..91014941b 100644 --- a/spec/views/harvests/show.html.haml_spec.rb +++ b/spec/views/harvests/show.html.haml_spec.rb @@ -20,7 +20,7 @@ describe "harvests/show" do before(:each) do controller.stub(:current_user) { nil } @crop = FactoryGirl.create(:tomato) - @harvest = assign(:harvest, FactoryGirl.create(:harvest, :crop => @crop)) + @harvest = assign(:harvest, FactoryGirl.create(:harvest, crop: @crop)) render end diff --git a/spec/views/home/_blurb.html.haml_spec.rb b/spec/views/home/_blurb.html.haml_spec.rb index e61f2be63..94e7550d1 100644 --- a/spec/views/home/_blurb.html.haml_spec.rb +++ b/spec/views/home/_blurb.html.haml_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'home/_blurb.html.haml', :type => "view" do +describe 'home/_blurb.html.haml', type: "view" do context 'signed out' do before :each do controller.stub(:current_user) { nil } @@ -29,12 +29,12 @@ describe 'home/_blurb.html.haml', :type => "view" do it 'has signup section' do assert_select "div.signup" - assert_select "a", :href => new_member_registration_path + assert_select "a", href: new_member_registration_path end it 'has a link to sign in' do rendered.should have_content "Or sign in if you already have an account" - assert_select "a", :href => new_member_session_path + assert_select "a", href: new_member_session_path end end diff --git a/spec/views/home/_crops.html.haml_spec.rb b/spec/views/home/_crops.html.haml_spec.rb index c82066b57..08b0cba01 100644 --- a/spec/views/home/_crops.html.haml_spec.rb +++ b/spec/views/home/_crops.html.haml_spec.rb @@ -16,12 +16,12 @@ require 'rails_helper' -describe 'home/_crops.html.haml', :type => "view" do +describe 'home/_crops.html.haml', type: "view" do before(:each) do # we need to set up an "interesting" crop @crop = FactoryGirl.create(:crop) (1..3).each do - @planting = FactoryGirl.create(:planting, :crop => @crop) + @planting = FactoryGirl.create(:planting, crop: @crop) end @photo = FactoryGirl.create(:photo) (1..3).each do @@ -31,20 +31,20 @@ describe 'home/_crops.html.haml', :type => "view" do end it 'shows crops section' do - assert_select 'h2', :text => 'Some of our crops' + assert_select 'h2', text: 'Some of our crops' assert_select "a[href=#{crop_path(@crop)}]" end it 'shows plantings section' do - assert_select 'h2', :text => 'Recently planted' + assert_select 'h2', text: 'Recently planted' rendered.should have_content @planting.location end it 'shows recently added crops' do - assert_select 'h2', :text => 'Recently planted' + assert_select 'h2', text: 'Recently planted' end it 'includes a link to all crops' do - assert_select "a[href=#{crops_path}]", :text => /View all crops/ + assert_select "a[href=#{crops_path}]", text: /View all crops/ end end diff --git a/spec/views/home/_members.html.haml_spec.rb b/spec/views/home/_members.html.haml_spec.rb index 5bda606ed..f208c1bde 100644 --- a/spec/views/home/_members.html.haml_spec.rb +++ b/spec/views/home/_members.html.haml_spec.rb @@ -16,13 +16,13 @@ require 'rails_helper' -describe 'home/_members.html.haml', :type => "view" do +describe 'home/_members.html.haml', type: "view" do before(:each) do @member = FactoryGirl.create(:london_member) @member.updated_at = 2.days.ago assign(:members, [@member]) - @planting = FactoryGirl.create(:planting, :owner => @member) + @planting = FactoryGirl.create(:planting, owner: @member) render end diff --git a/spec/views/home/_seeds.html.haml_spec.rb b/spec/views/home/_seeds.html.haml_spec.rb index 148cc2ea0..6cbd276f7 100644 --- a/spec/views/home/_seeds.html.haml_spec.rb +++ b/spec/views/home/_seeds.html.haml_spec.rb @@ -16,10 +16,10 @@ require 'rails_helper' -describe 'home/_seeds.html.haml', :type => "view" do +describe 'home/_seeds.html.haml', type: "view" do before(:each) do @owner = FactoryGirl.create(:london_member) - @seed = FactoryGirl.create(:tradable_seed, :owner => @owner) + @seed = FactoryGirl.create(:tradable_seed, owner: @owner) render end @@ -29,10 +29,10 @@ describe 'home/_seeds.html.haml', :type => "view" do it 'lists seeds' do assert_select "table" - assert_select 'a', :href => crop_path(@seed.crop) - assert_select 'a', :href => crop_path(@seed.owner) + assert_select 'a', href: crop_path(@seed.crop) + assert_select 'a', href: crop_path(@seed.owner) assert_select 'td', @seed.tradable_to assert_select 'td', @seed.owner.location - assert_select 'a', :href => seed_path(@seed) + assert_select 'a', href: seed_path(@seed) end end diff --git a/spec/views/home/_stats.html.haml_spec.rb b/spec/views/home/_stats.html.haml_spec.rb index f1a78b62c..0eeaf66f8 100644 --- a/spec/views/home/_stats.html.haml_spec.rb +++ b/spec/views/home/_stats.html.haml_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'home/_stats.html.haml', :type => "view" do +describe 'home/_stats.html.haml', type: "view" do it 'has activity stats' do render rendered.should have_content "So far, 0 members have planted 0 crops" diff --git a/spec/views/home/index_spec.rb b/spec/views/home/index_spec.rb index 5d45dcb2d..84dd65bde 100644 --- a/spec/views/home/index_spec.rb +++ b/spec/views/home/index_spec.rb @@ -16,16 +16,16 @@ require 'rails_helper' -describe 'home/index.html.haml', :type => "view" do +describe 'home/index.html.haml', type: "view" do before(:each) do @member = FactoryGirl.create(:london_member) @member.updated_at = 2.days.ago assign(:interesting_members, [@member]) - @post = FactoryGirl.create(:post, :author => @member) + @post = FactoryGirl.create(:post, author: @member) assign(:posts, [@post]) - @planting = FactoryGirl.create(:planting, :owner => @member) + @planting = FactoryGirl.create(:planting, owner: @member) assign(:plantings, [@planting]) @crop = FactoryGirl.create(:crop) diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb index 94930bc31..cd531dc71 100644 --- a/spec/views/layouts/_header_spec.rb +++ b/spec/views/layouts/_header_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'layouts/_header.html.haml', :type => "view" do +describe 'layouts/_header.html.haml', type: "view" do context "when not logged in" do before(:each) do controller.stub(:current_user) { nil } @@ -24,7 +24,7 @@ describe 'layouts/_header.html.haml', :type => "view" do end it 'shows the brand logo in the navbar' do - assert_select("img[src='/assets/growstuff-brand.png']", :href => root_path) + assert_select("img[src='/assets/growstuff-brand.png']", href: root_path) end it 'should have signup/signin links' do @@ -81,16 +81,16 @@ describe 'layouts/_header.html.haml', :type => "view" do rendered.should have_content "#{@member.login_name}" end it "should show link to member's gardens" do - assert_select("a[href=#{gardens_by_owner_path(:owner => @member.slug)}]", "Gardens") + assert_select("a[href=#{gardens_by_owner_path(owner: @member.slug)}]", "Gardens") end it "should show link to member's plantings" do - assert_select("a[href=#{plantings_by_owner_path(:owner => @member.slug)}]", "Plantings") + assert_select("a[href=#{plantings_by_owner_path(owner: @member.slug)}]", "Plantings") end it "should show link to member's seeds" do - assert_select("a[href=#{seeds_by_owner_path(:owner => @member.slug)}]", "Seeds") + assert_select("a[href=#{seeds_by_owner_path(owner: @member.slug)}]", "Seeds") end it "should show link to member's posts" do - assert_select("a[href=#{posts_by_author_path(:author => @member.slug)}]", "Posts") + assert_select("a[href=#{posts_by_author_path(author: @member.slug)}]", "Posts") end end @@ -105,7 +105,7 @@ describe 'layouts/_header.html.haml', :type => "view" do context 'has notifications' do it 'should show inbox count' do - FactoryGirl.create(:notification, :recipient => @member) + FactoryGirl.create(:notification, recipient: @member) render rendered.should have_content 'Inbox (1)' end diff --git a/spec/views/layouts/_meta_spec.rb b/spec/views/layouts/_meta_spec.rb index a181a4414..8b27d7a8b 100644 --- a/spec/views/layouts/_meta_spec.rb +++ b/spec/views/layouts/_meta_spec.rb @@ -16,23 +16,23 @@ require 'rails_helper' -describe 'layouts/_meta.html.haml', :type => "view" do +describe 'layouts/_meta.html.haml', type: "view" do before(:each) do render end it 'should have a Posts RSS feed' do - posts_rss = url_for(:controller => 'posts', :format => 'rss', :only_path => false) + posts_rss = url_for(controller: 'posts', format: 'rss', only_path: false) assert_select "head>link[href=#{posts_rss}]" end it 'should have a Crops RSS feed' do - crops_rss = url_for(:controller => 'crops', :format => 'rss', :only_path => false) + crops_rss = url_for(controller: 'crops', format: 'rss', only_path: false) assert_select "head>link[href=#{crops_rss}]" end it 'should have a Plantings RSS feed' do - plantings_rss = url_for(:controller => 'plantings', :format => 'rss', :only_path => false) + plantings_rss = url_for(controller: 'plantings', format: 'rss', only_path: false) assert_select "head>link[href=#{plantings_rss}]" end diff --git a/spec/views/layouts/application_spec.rb b/spec/views/layouts/application_spec.rb index 0679af903..af710ce6f 100644 --- a/spec/views/layouts/application_spec.rb +++ b/spec/views/layouts/application_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'layouts/application.html.haml', :type => "view" do +describe 'layouts/application.html.haml', type: "view" do before(:each) do controller.stub(:current_user) { nil } end @@ -24,7 +24,7 @@ describe 'layouts/application.html.haml', :type => "view" do it 'includes the analytics code' do Growstuff::Application.config.analytics_code = '' render - assert_select "script", :text => 'alert("foo!")' + assert_select "script", text: 'alert("foo!")' rendered.should_not have_content 'script' end diff --git a/spec/views/members/_location.html.haml_spec.rb b/spec/views/members/_location.html.haml_spec.rb index 5c4b229a3..43fb66285 100644 --- a/spec/views/members/_location.html.haml_spec.rb +++ b/spec/views/members/_location.html.haml_spec.rb @@ -20,7 +20,7 @@ describe "members/_location" do context "member with location" do before(:each) do @member = FactoryGirl.create(:london_member) - render :partial => 'members/location', :locals => { :member => @member } + render partial: 'members/location', locals: { member: @member } end it 'shows location if available' do @@ -28,14 +28,14 @@ describe "members/_location" do end it "links to the places page" do - assert_select "a", :href => place_path(@member.location) + assert_select "a", href: place_path(@member.location) end end context "member with no location" do before(:each) do @member = FactoryGirl.create(:member) - render :partial => 'members/location', :locals => { :member => @member } + render partial: 'members/location', locals: { member: @member } end it 'shows unknown location' do diff --git a/spec/views/members/index.html.haml_spec.rb b/spec/views/members/index.html.haml_spec.rb index 3c864d415..ee1537b77 100644 --- a/spec/views/members/index.html.haml_spec.rb +++ b/spec/views/members/index.html.haml_spec.rb @@ -31,7 +31,7 @@ describe "members/index" do end it "contains two gravatar icons" do - assert_select "img", :src => /gravatar\.com\/avatar/, :count => 2 + assert_select "img", src: /gravatar\.com\/avatar/, count: 2 end it 'contains member locations' do diff --git a/spec/views/members/show.rss.haml_spec.rb b/spec/views/members/show.rss.haml_spec.rb index e4aab16a7..dcfa0b7b6 100644 --- a/spec/views/members/show.rss.haml_spec.rb +++ b/spec/views/members/show.rss.haml_spec.rb @@ -16,11 +16,11 @@ require 'rails_helper' -describe 'members/show.rss.haml', :type => "view" do +describe 'members/show.rss.haml', type: "view" do before(:each) do @member = assign(:member, FactoryGirl.create(:member)) - @post1 = FactoryGirl.create(:post, :id => 1, :author => @member) - @post2 = FactoryGirl.create(:markdown_post, :id => 2, :author => @member) + @post1 = FactoryGirl.create(:post, id: 1, author: @member) + @post2 = FactoryGirl.create(:markdown_post, id: 2, author: @member) assign(:posts, [@post1, @post2]) render end diff --git a/spec/views/notifications/index.html.haml_spec.rb b/spec/views/notifications/index.html.haml_spec.rb index 362037cce..a7ec6a696 100644 --- a/spec/views/notifications/index.html.haml_spec.rb +++ b/spec/views/notifications/index.html.haml_spec.rb @@ -24,8 +24,8 @@ describe "notifications/index" do context "ordinary notifications" do before(:each) do - @notification = FactoryGirl.create(:notification, :sender => @member, - :recipient => @member) + @notification = FactoryGirl.create(:notification, sender: @member, + recipient: @member) assign(:notifications, Kaminari.paginate_array([ @notification, @notification ]).page(1)) render end @@ -33,19 +33,19 @@ describe "notifications/index" do it "renders a list of notifications" do assert_select "table" - assert_select "tr>td", :text => @notification.sender.to_s, :count => 2 - assert_select "tr>td", :text => @notification.subject, :count => 2 + assert_select "tr>td", text: @notification.sender.to_s, count: 2 + assert_select "tr>td", text: @notification.subject, count: 2 end it "links to sender's profile" do - assert_select "a", :href => member_path(@notification.sender) + assert_select "a", href: member_path(@notification.sender) end end context "no subject" do it "shows (no subject)" do @notification = FactoryGirl.create(:notification, - :sender => @member, :recipient => @member, :subject => nil) + sender: @member, recipient: @member, subject: nil) assign(:notifications, Kaminari.paginate_array([@notification]).page(1)) render rendered.should have_content "(no subject)" @@ -55,7 +55,7 @@ describe "notifications/index" do context "whitespace-only subject" do it "shows (no subject)" do @notification = FactoryGirl.create(:notification, - :sender => @member, :recipient => @member, :subject => " ") + sender: @member, recipient: @member, subject: " ") assign(:notifications, Kaminari.paginate_array([@notification]).page(1)) render rendered.should have_content "(no subject)" diff --git a/spec/views/notifications/new.html.haml_spec.rb b/spec/views/notifications/new.html.haml_spec.rb index 2ec73bca3..b2e6cd125 100644 --- a/spec/views/notifications/new.html.haml_spec.rb +++ b/spec/views/notifications/new.html.haml_spec.rb @@ -20,16 +20,16 @@ describe "notifications/new" do before(:each) do @recipient = FactoryGirl.create(:member) @sender = FactoryGirl.create(:member) - assign(:notification, FactoryGirl.create(:notification, :recipient_id => @recipient.id, :sender_id => @sender.id)) + assign(:notification, FactoryGirl.create(:notification, recipient_id: @recipient.id, sender_id: @sender.id)) sign_in @sender controller.stub(:current_user) { @sender} end it "renders new message form" do render - assert_select "form", :action => notifications_path, :method => "notification" do - assert_select "input#notification_subject", :name => "notification[subject]" - assert_select "textarea#notification_body", :name => "notification[body]" + assert_select "form", action: notifications_path, method: "notification" do + assert_select "input#notification_subject", name: "notification[subject]" + assert_select "textarea#notification_body", name: "notification[body]" end end @@ -40,18 +40,18 @@ describe "notifications/new" do it "puts the recipient in a hidden field" do render - assert_select "input#notification_recipient_id[type=hidden]", :name => "notification[recipient_id]" + assert_select "input#notification_recipient_id[type=hidden]", name: "notification[recipient_id]" end it "fills in the subject if provided" do assign(:subject, 'Foo') render - assert_select "input#notification_subject", :value => "Foo" + assert_select "input#notification_subject", value: "Foo" end it "leaves the subject empty if not provided" do render - assert_select "input#notification_subject", :value => "" + assert_select "input#notification_subject", value: "" end it "Tells you to write your message here" do diff --git a/spec/views/notifications/show.html.haml_spec.rb b/spec/views/notifications/show.html.haml_spec.rb index 4e9f27dbf..42b732ad5 100644 --- a/spec/views/notifications/show.html.haml_spec.rb +++ b/spec/views/notifications/show.html.haml_spec.rb @@ -19,7 +19,7 @@ require 'rails_helper' describe "notifications/show" do before(:each) do @member = FactoryGirl.create(:member) - @notification = FactoryGirl.create(:notification, :recipient => @member) + @notification = FactoryGirl.create(:notification, recipient: @member) assign(:notification, @notification) @reply_link = assign(:reply_link, new_notification_path) controller.stub(:current_user) { @member } diff --git a/spec/views/notifier/notify.html.haml_spec.rb b/spec/views/notifier/notify.html.haml_spec.rb index 787470805..1a4a607bc 100644 --- a/spec/views/notifier/notify.html.haml_spec.rb +++ b/spec/views/notifier/notify.html.haml_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'notifier/notify.html.haml', :type => "view" do +describe 'notifier/notify.html.haml', type: "view" do before(:each) do @notification = FactoryGirl.create(:notification) @@ -36,7 +36,7 @@ describe 'notifier/notify.html.haml', :type => "view" do end it 'should include a reply link' do - assert_select "a[href=#{@reply_link}]", :text => /Reply/ + assert_select "a[href=#{@reply_link}]", text: /Reply/ end it 'should contain a link to your inbox' do @@ -45,8 +45,8 @@ describe 'notifier/notify.html.haml', :type => "view" do it 'should have fully qualified URLs' do # lots of lovely fully qualified URLs - assert_select "a[href^=http]", { :minimum => 4 } + assert_select "a[href^=http]", { minimum: 4 } # no relative URLs starting with / - assert_select "a[href^=/]", { :count => 0 } + assert_select "a[href^=/]", { count: 0 } end end diff --git a/spec/views/orders/index.html.haml_spec.rb b/spec/views/orders/index.html.haml_spec.rb index 1ca2889e0..3efdce690 100644 --- a/spec/views/orders/index.html.haml_spec.rb +++ b/spec/views/orders/index.html.haml_spec.rb @@ -20,8 +20,8 @@ describe "orders/index" do before(:each) do @member = FactoryGirl.create(:member) sign_in @member - @order1 = FactoryGirl.create(:order, :member => @member) - @order2 = FactoryGirl.create(:completed_order, :member => @member) + @order1 = FactoryGirl.create(:order, member: @member) + @order2 = FactoryGirl.create(:completed_order, member: @member) assign(:orders, [ @order1, @order2 ]) end @@ -33,7 +33,7 @@ describe "orders/index" do it "renders a list of orders" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", :text => @order1.id - assert_select "tr>td", :text => @order2.id + assert_select "tr>td", text: @order1.id + assert_select "tr>td", text: @order2.id end end diff --git a/spec/views/orders/show.html.haml_spec.rb b/spec/views/orders/show.html.haml_spec.rb index 3779795e6..c4a2de1cf 100644 --- a/spec/views/orders/show.html.haml_spec.rb +++ b/spec/views/orders/show.html.haml_spec.rb @@ -26,11 +26,11 @@ describe "orders/show" do context "current order" do before(:each) do - @order = assign(:order, FactoryGirl.create(:order, :member => @member)) + @order = assign(:order, FactoryGirl.create(:order, member: @member)) @order_item = FactoryGirl.create(:order_item, - :order => @order, - :quantity => 2, - :price => 9900 + order: @order, + quantity: 2, + price: 9900 ) render end @@ -40,7 +40,7 @@ describe "orders/show" do end it "shows order items in a table" do - assert_select "table>tr>th", :text => "Product" + assert_select "table>tr>th", text: "Product" end it "shows the total" do @@ -62,27 +62,27 @@ describe "orders/show" do end it "shows a delete order button" do - assert_select "a", :text => "Delete this order" + assert_select "a", text: "Delete this order" end end context "completed order" do before(:each) do - @order = assign(:order, FactoryGirl.create(:completed_order, :member => @member)) + @order = assign(:order, FactoryGirl.create(:completed_order, member: @member)) @order_item = FactoryGirl.create(:order_item, - :order => @order, - :quantity => 2, - :price => 9900 + order: @order, + quantity: 2, + price: 9900 ) render end it "doesn't show a checkout button" do - assert_select "a", :text => "Checkout", :count => 0 + assert_select "a", text: "Checkout", count: 0 end it "doesn't show delete order button" do - assert_select "a", :text => "Delete this order", :count => 0 + assert_select "a", text: "Delete this order", count: 0 end end diff --git a/spec/views/photos/edit.html.haml_spec.rb b/spec/views/photos/edit.html.haml_spec.rb index a13aea7c6..6df82b418 100644 --- a/spec/views/photos/edit.html.haml_spec.rb +++ b/spec/views/photos/edit.html.haml_spec.rb @@ -19,10 +19,10 @@ require 'rails_helper' describe "photos/edit" do before(:each) do @photo = assign(:photo, stub_model(Photo, - :owner_id => 1, - :flickr_photo_id => 1, - :thumbnail_url => "MyString", - :fullsize_url => "MyString" + owner_id: 1, + flickr_photo_id: 1, + thumbnail_url: "MyString", + fullsize_url: "MyString" )) end diff --git a/spec/views/photos/index.html.haml_spec.rb b/spec/views/photos/index.html.haml_spec.rb index 866302895..1741d9aa3 100644 --- a/spec/views/photos/index.html.haml_spec.rb +++ b/spec/views/photos/index.html.haml_spec.rb @@ -32,7 +32,7 @@ describe "photos/index" do it "renders a gallery of photos" do render - assert_select ".thumbnail", :count => 2 - assert_select "img", :count => 2 + assert_select ".thumbnail", count: 2 + assert_select "img", count: 2 end end diff --git a/spec/views/photos/new.html.haml_spec.rb b/spec/views/photos/new.html.haml_spec.rb index 3c2321aef..46489e87e 100644 --- a/spec/views/photos/new.html.haml_spec.rb +++ b/spec/views/photos/new.html.haml_spec.rb @@ -27,7 +27,7 @@ describe "photos/new" do pager.replace([]) end assign(:photos, photos) - assign(:flickr_auth, FactoryGirl.create(:flickr_authentication, :member => @member)) + assign(:flickr_auth, FactoryGirl.create(:flickr_authentication, member: @member)) end context "user has no photosets" do diff --git a/spec/views/photos/show.html.haml_spec.rb b/spec/views/photos/show.html.haml_spec.rb index 941badb66..a7e014eac 100644 --- a/spec/views/photos/show.html.haml_spec.rb +++ b/spec/views/photos/show.html.haml_spec.rb @@ -24,7 +24,7 @@ describe "photos/show" do context "CC-licensed photo" do before(:each) do - @photo = assign(:photo, FactoryGirl.create(:photo, :owner => @member)) + @photo = assign(:photo, FactoryGirl.create(:photo, owner: @member)) render end @@ -33,16 +33,16 @@ describe "photos/show" do end it "links to the owner's profile" do - assert_select "a", :href => @photo.owner + assert_select "a", href: @photo.owner end it "links to the CC license" do - assert_select "a", :href => @photo.license_url, - :text => @photo.license_name + assert_select "a", href: @photo.license_url, + text: @photo.license_name end it "shows a link to the original image" do - assert_select "a", :href => @photo.link_url, :text => "View on Flickr" + assert_select "a", href: @photo.link_url, text: "View on Flickr" end it "has a delete button" do diff --git a/spec/views/places/_map_attribution.html.haml_spec.rb b/spec/views/places/_map_attribution.html.haml_spec.rb index e2bc7e5b0..cbb305ed6 100644 --- a/spec/views/places/_map_attribution.html.haml_spec.rb +++ b/spec/views/places/_map_attribution.html.haml_spec.rb @@ -16,22 +16,22 @@ require 'rails_helper' -describe "places/_map_attribution.html.haml", :type => :view do +describe "places/_map_attribution.html.haml", type: :view do before(:each) do render end it "links to OpenStreetMap" do - assert_select "a", :href => "http://openstreetmap.org", - :text => "OpenStreetMap" + assert_select "a", href: "http://openstreetmap.org", + text: "OpenStreetMap" end it "links to the ODbL" do - assert_select "a", :href => "http://www.openstreetmap.org/copyright", - :text => "ODbL" + assert_select "a", href: "http://www.openstreetmap.org/copyright", + text: "ODbL" end it "links to CloudMade" do - assert_select "a", :href => "http://cloudmade.com", :text => "CloudMade" + assert_select "a", href: "http://cloudmade.com", text: "CloudMade" end end diff --git a/spec/views/places/show.html.haml_spec.rb b/spec/views/places/show.html.haml_spec.rb index 13884eb3b..7cfa2c16c 100644 --- a/spec/views/places/show.html.haml_spec.rb +++ b/spec/views/places/show.html.haml_spec.rb @@ -31,7 +31,7 @@ describe "places/show" do end it "shows the selected place in the textbox" do - assert_select "#new_place", :value => @place + assert_select "#new_place", value: @place end it "shows the names of nearby members" do diff --git a/spec/views/plant_parts/edit.html.haml_spec.rb b/spec/views/plant_parts/edit.html.haml_spec.rb index fc25b711b..1f92923d8 100644 --- a/spec/views/plant_parts/edit.html.haml_spec.rb +++ b/spec/views/plant_parts/edit.html.haml_spec.rb @@ -19,7 +19,7 @@ require 'rails_helper' describe "plant_parts/edit" do before(:each) do @plant_part = assign(:plant_part, stub_model(PlantPart, - :name => "MyString" + name: "MyString" )) end @@ -27,8 +27,8 @@ describe "plant_parts/edit" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => plant_parts_path(@plant_part), :method => "post" do - assert_select "input#plant_part_name", :name => "plant_part[name]" + assert_select "form", action: plant_parts_path(@plant_part), method: "post" do + assert_select "input#plant_part_name", name: "plant_part[name]" end end end diff --git a/spec/views/plant_parts/index.html.haml_spec.rb b/spec/views/plant_parts/index.html.haml_spec.rb index 256810ac3..1fe26abba 100644 --- a/spec/views/plant_parts/index.html.haml_spec.rb +++ b/spec/views/plant_parts/index.html.haml_spec.rb @@ -26,7 +26,7 @@ describe "plant_parts/index" do it "renders a list of plant_parts" do render rendered.should have_content @pp.name - assert_select "a", :href => plant_part_path(@pp) + assert_select "a", href: plant_part_path(@pp) end end diff --git a/spec/views/plant_parts/new.html.haml_spec.rb b/spec/views/plant_parts/new.html.haml_spec.rb index 64b572ef7..213eee57a 100644 --- a/spec/views/plant_parts/new.html.haml_spec.rb +++ b/spec/views/plant_parts/new.html.haml_spec.rb @@ -19,7 +19,7 @@ require 'rails_helper' describe "plant_parts/new" do before(:each) do assign(:plant_part, stub_model(PlantPart, - :name => "MyString" + name: "MyString" ).as_new_record) end @@ -27,8 +27,8 @@ describe "plant_parts/new" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => plant_parts_path, :method => "post" do - assert_select "input#plant_part_name", :name => "plant_part[name]" + assert_select "form", action: plant_parts_path, method: "post" do + assert_select "input#plant_part_name", name: "plant_part[name]" end end end diff --git a/spec/views/plant_parts/show.html.haml_spec.rb b/spec/views/plant_parts/show.html.haml_spec.rb index fa839419f..7c23b9bb9 100644 --- a/spec/views/plant_parts/show.html.haml_spec.rb +++ b/spec/views/plant_parts/show.html.haml_spec.rb @@ -20,7 +20,7 @@ describe "plant_parts/show" do before(:each) do controller.stub(:current_user) { nil } @pp = FactoryGirl.create(:plant_part) - @harvest = FactoryGirl.create(:harvest, :plant_part => @pp) + @harvest = FactoryGirl.create(:harvest, plant_part: @pp) assign(:plant_part, @pp) end @@ -28,7 +28,7 @@ describe "plant_parts/show" do render @pp.crops.each do |c| rendered.should have_content c.name - assert_select "a", :href => crop_path(c) + assert_select "a", href: crop_path(c) end end end diff --git a/spec/views/plantings/_form.html.haml_spec.rb b/spec/views/plantings/_form.html.haml_spec.rb index f65fd82eb..a8565dfda 100644 --- a/spec/views/plantings/_form.html.haml_spec.rb +++ b/spec/views/plantings/_form.html.haml_spec.rb @@ -20,15 +20,15 @@ describe "plantings/_form" do before(:each) do controller.stub(:current_user) { nil } @member = FactoryGirl.create(:member) - @garden = FactoryGirl.create(:garden, :owner => @member) + @garden = FactoryGirl.create(:garden, owner: @member) @uppercase = FactoryGirl.create(:uppercasecrop) @lowercase = FactoryGirl.create(:lowercasecrop) @crop = @lowercase # needed to render the form @planting = FactoryGirl.create(:planting, - :garden => @garden, - :crop => @crop, - :planted_at => Date.new(2013, 03, 01) + garden: @garden, + crop: @crop, + planted_at: Date.new(2013, 03, 01) ) render end diff --git a/spec/views/plantings/edit.html.haml_spec.rb b/spec/views/plantings/edit.html.haml_spec.rb index f0af66587..b71b34d2a 100644 --- a/spec/views/plantings/edit.html.haml_spec.rb +++ b/spec/views/plantings/edit.html.haml_spec.rb @@ -19,8 +19,8 @@ require 'rails_helper' describe "plantings/edit" do before(:each) do @member = FactoryGirl.create(:member, - :login_name => 'right', - :email => 'right@example.com' + login_name: 'right', + email: 'right@example.com' ) # creating two crops to make sure that the correct one is selected @@ -29,11 +29,11 @@ describe "plantings/edit" do @maize = FactoryGirl.create(:maize) # and likewise for gardens - @garden = FactoryGirl.create(:garden_z, :owner => @member) - @garden2 = FactoryGirl.create(:garden_a, :owner => @member) + @garden = FactoryGirl.create(:garden_z, owner: @member) + @garden2 = FactoryGirl.create(:garden_a, owner: @member) @planting = assign(:planting, - FactoryGirl.create(:planting, :garden => @garden, :crop => @tomato) + FactoryGirl.create(:planting, garden: @garden, crop: @tomato) ) end @@ -46,16 +46,16 @@ describe "plantings/edit" do end it "renders the edit planting form" do - assert_select "form", :action => plantings_path(@planting), :method => "post" do - assert_select "input#planting_quantity", :name => "planting[quantity]" - assert_select "textarea#planting_description", :name => "planting[description]" - assert_select "select#planting_sunniness", :name => "planting[sunniness]" - assert_select "select#planting_planted_from", :name => "planting[planted_from]" + assert_select "form", action: plantings_path(@planting), method: "post" do + assert_select "input#planting_quantity", name: "planting[quantity]" + assert_select "textarea#planting_description", name: "planting[description]" + assert_select "select#planting_sunniness", name: "planting[sunniness]" + assert_select "select#planting_planted_from", name: "planting[planted_from]" end end it 'includes helpful links for crops and gardens' do - assert_select "a[href=#{new_garden_path}]", :text => "Add a garden." + assert_select "a[href=#{new_garden_path}]", text: "Add a garden." end it "chooses the right crop" do @@ -64,7 +64,7 @@ describe "plantings/edit" do it "chooses the right garden" do assert_select "select#planting_garden_id", - :html => /option selected="selected" value="#{@garden.id}"/ + html: /option selected="selected" value="#{@garden.id}"/ end end diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index 9c890caf4..928735dde 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -20,7 +20,7 @@ describe "plantings/index" do before(:each) do controller.stub(:current_user) { nil } @member = FactoryGirl.create(:member) - @garden = FactoryGirl.create(:garden, :owner => @member) + @garden = FactoryGirl.create(:garden, owner: @member) @tomato = FactoryGirl.create(:tomato) @maize = FactoryGirl.create(:maize) page = 1 @@ -29,22 +29,22 @@ describe "plantings/index" do plantings = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| pager.replace([ FactoryGirl.create(:planting, - :garden => @garden, - :crop => @tomato, - :owner => @member + garden: @garden, + crop: @tomato, + owner: @member ), FactoryGirl.create(:planting, - :garden => @garden, - :crop => @maize, - :description => '', - :planted_at => Time.local(2013, 1, 13) + garden: @garden, + crop: @maize, + description: '', + planted_at: Time.local(2013, 1, 13) ), FactoryGirl.create(:planting, - :garden => @garden, - :crop => @tomato, - :planted_at => Time.local(2013, 1, 13), - :finished_at => Time.local(2013, 1, 20), - :finished => true + garden: @garden, + crop: @tomato, + planted_at: Time.local(2013, 1, 13), + finished_at: Time.local(2013, 1, 20), + finished: true ) ]) end @@ -70,9 +70,9 @@ describe "plantings/index" do it "provides data links" do render rendered.should have_content "The data on this page is available in the following formats:" - assert_select "a", :href => plantings_path(:format => 'csv') - assert_select "a", :href => plantings_path(:format => 'json') - assert_select "a", :href => plantings_path(:format => 'rss') + assert_select "a", href: plantings_path(format: 'csv') + assert_select "a", href: plantings_path(format: 'json') + assert_select "a", href: plantings_path(format: 'rss') end it "displays member's name in title" do diff --git a/spec/views/plantings/new.html.haml_spec.rb b/spec/views/plantings/new.html.haml_spec.rb index 0227a0f79..cd3a95445 100644 --- a/spec/views/plantings/new.html.haml_spec.rb +++ b/spec/views/plantings/new.html.haml_spec.rb @@ -22,14 +22,14 @@ describe "plantings/new" do controller.stub(:current_user) { @member } # create gardens and crops to populate dropdowns - @garden_a = FactoryGirl.create(:garden, :owner => @member) - @garden_z = FactoryGirl.create(:garden, :owner => @member) + @garden_a = FactoryGirl.create(:garden, owner: @member) + @garden_z = FactoryGirl.create(:garden, owner: @member) @crop1 = FactoryGirl.create(:tomato) @crop2 = FactoryGirl.create(:maize) assign(:planting, FactoryGirl.create(:planting, - :garden => @garden_a, - :crop => @crop2 + garden: @garden_a, + crop: @crop2 )) end @@ -44,24 +44,24 @@ describe "plantings/new" do end it "renders new planting form" do - assert_select "form", :action => plantings_path, :method => "post" do - assert_select "select#planting_garden_id", :name => "planting[garden_id]" - assert_select "input#crop", :class => "ui-autocomplete-input" - assert_select "input#planting_crop_id", :name => "planting[crop_id]" - assert_select "input#planting_quantity", :name => "planting[quantity]" - assert_select "textarea#planting_description", :name => "planting[description]" - assert_select "select#planting_sunniness", :name => "planting[sunniness]" - assert_select "select#planting_planted_from", :name => "planting[planted_from]" + assert_select "form", action: plantings_path, method: "post" do + assert_select "select#planting_garden_id", name: "planting[garden_id]" + assert_select "input#crop", class: "ui-autocomplete-input" + assert_select "input#planting_crop_id", name: "planting[crop_id]" + assert_select "input#planting_quantity", name: "planting[quantity]" + assert_select "textarea#planting_description", name: "planting[description]" + assert_select "select#planting_sunniness", name: "planting[sunniness]" + assert_select "select#planting_planted_from", name: "planting[planted_from]" end end it 'includes helpful links for crops and gardens' do - assert_select "a[href=#{new_garden_path}]", :text => "Add a garden." + assert_select "a[href=#{new_garden_path}]", text: "Add a garden." end it "selects a garden given in a param" do assert_select "select#planting_garden_id", - :html => /option selected="selected" value="#{@garden_z.id}"/ + html: /option selected="selected" value="#{@garden_z.id}"/ end end end diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb index d0eed00ac..79faf1d1d 100644 --- a/spec/views/plantings/show.html.haml_spec.rb +++ b/spec/views/plantings/show.html.haml_spec.rb @@ -18,11 +18,11 @@ require 'rails_helper' describe "plantings/show" do def create_planting_for(member) - @garden = FactoryGirl.create(:garden, :owner => @member) + @garden = FactoryGirl.create(:garden, owner: @member) @crop = FactoryGirl.create(:tomato) @planting = assign(:planting, - FactoryGirl.create(:planting, :garden => @garden, :crop => @crop, - :planted_from => 'cutting') + FactoryGirl.create(:planting, garden: @garden, crop: @crop, + planted_from: 'cutting') ) end @@ -67,7 +67,7 @@ describe "plantings/show" do end it "shows photos" do - @photo = FactoryGirl.create(:photo, :owner => @member) + @photo = FactoryGirl.create(:photo, owner: @member) @p.photos << @photo render assert_select "img[src=#{@photo.thumbnail_url}]" diff --git a/spec/views/policy/community_spec.rb b/spec/views/policy/community_spec.rb index df7c828fb..a56139aad 100644 --- a/spec/views/policy/community_spec.rb +++ b/spec/views/policy/community_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'policy/community.html.haml', :type => "view" do +describe 'policy/community.html.haml', type: "view" do before(:each) do render end diff --git a/spec/views/policy/tos_spec.rb b/spec/views/policy/tos_spec.rb index 56f08e928..baac388da 100644 --- a/spec/views/policy/tos_spec.rb +++ b/spec/views/policy/tos_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'policy/tos.html.haml', :type => "view" do +describe 'policy/tos.html.haml', type: "view" do before(:each) do render end diff --git a/spec/views/posts/_single.html.haml_spec.rb b/spec/views/posts/_single.html.haml_spec.rb index 284542965..75a57b99c 100644 --- a/spec/views/posts/_single.html.haml_spec.rb +++ b/spec/views/posts/_single.html.haml_spec.rb @@ -19,7 +19,7 @@ require 'rails_helper' describe "posts/_single" do def render_post() - render :partial => "single", :locals => { :post => @post } + render partial: "single", locals: { post: @post } end before(:each) do @@ -37,7 +37,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 @@ -50,7 +50,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 @@ -63,7 +63,7 @@ describe "posts/_single" do @member = FactoryGirl.create(:member) sign_in @member controller.stub(:current_user) { @member } - @post = FactoryGirl.create(:post, :author => @member) + @post = FactoryGirl.create(:post, author: @member) render_post end @@ -84,7 +84,7 @@ describe "posts/_single" do context "when there is 1 comment" do before(:each) do - @comment = FactoryGirl.create(:comment, :post => @post) + @comment = FactoryGirl.create(:comment, post: @post) render_post end @@ -95,8 +95,8 @@ describe "posts/_single" do context "when there are 2 comments" do before(:each) do - @comment = FactoryGirl.create(:comment, :post => @post) - @comment2 = FactoryGirl.create(:comment, :post => @post) + @comment = FactoryGirl.create(:comment, post: @post) + @comment2 = FactoryGirl.create(:comment, post: @post) render_post end @@ -110,9 +110,9 @@ describe "posts/_single" do @member = FactoryGirl.create(:member) sign_in @member controller.stub(:current_user) { @member } - @comment = FactoryGirl.create(:comment, :post => @post) - render :partial => "single", :locals => { - :post => @post, :hide_comments => true + @comment = FactoryGirl.create(:comment, post: @post) + render partial: "single", locals: { + post: @post, hide_comments: true } end @@ -125,7 +125,7 @@ describe "posts/_single" do end it "does not contain 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 diff --git a/spec/views/posts/edit.html.haml_spec.rb b/spec/views/posts/edit.html.haml_spec.rb index 12fd02c27..e0a557db6 100644 --- a/spec/views/posts/edit.html.haml_spec.rb +++ b/spec/views/posts/edit.html.haml_spec.rb @@ -20,7 +20,7 @@ describe "posts/edit" do before(:each) do controller.stub(:current_user) { nil } @author = FactoryGirl.create(:member) - @post = assign(:post, FactoryGirl.create(:post, :author => @author)) + @post = assign(:post, FactoryGirl.create(:post, author: @author)) end context "logged in" do @@ -30,9 +30,9 @@ describe "posts/edit" do end it "renders the edit post form" do - assert_select "form", :action => posts_path(@post), :method => "post" do - assert_select "input#post_subject", :name => "post[subject]" - assert_select "textarea#post_body", :name => "post[body]" + assert_select "form", action: posts_path(@post), method: "post" do + assert_select "input#post_subject", name: "post[subject]" + assert_select "textarea#post_body", name: "post[body]" end end @@ -48,8 +48,8 @@ describe "posts/edit" do before(:each) do @forum = assign(:forum, FactoryGirl.create(:forum)) assign(:post, FactoryGirl.create( :post, - :forum => @forum, - :author => @author + forum: @forum, + author: @author )) render end diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb index 2f2f42d78..1290cc2c7 100644 --- a/spec/views/posts/index.html.haml_spec.rb +++ b/spec/views/posts/index.html.haml_spec.rb @@ -25,8 +25,8 @@ describe "posts/index" do total_entries = 2 posts = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| pager.replace([ - FactoryGirl.create(:post, :author => @author), - FactoryGirl.create(:post, :author => @author) + FactoryGirl.create(:post, author: @author), + FactoryGirl.create(:post, author: @author) ]) end assign(:posts, posts) @@ -34,18 +34,18 @@ describe "posts/index" do end it "renders a list of posts" do - assert_select "div.post", :count => 2 - assert_select "h3", :text => "A Post".to_s, :count => 2 + assert_select "div.post", count: 2 + assert_select "h3", text: "A Post".to_s, count: 2 assert_select "div.post-body", - :text => "This is some text.".to_s, :count => 2 + text: "This is some text.".to_s, count: 2 end it "contains two gravatar icons" do - assert_select "img", :src => /gravatar\.com\/avatar/, :count => 2 + assert_select "img", src: /gravatar\.com\/avatar/, count: 2 end it "contains RSS feed links for posts and comments" do - assert_select "a", :href => posts_path(:format => 'rss') - assert_select "a", :href => comments_path(:format => 'rss') + assert_select "a", href: posts_path(format: 'rss') + assert_select "a", href: comments_path(format: 'rss') end end diff --git a/spec/views/posts/index.rss.haml_spec.rb b/spec/views/posts/index.rss.haml_spec.rb index b29dae565..496311efc 100644 --- a/spec/views/posts/index.rss.haml_spec.rb +++ b/spec/views/posts/index.rss.haml_spec.rb @@ -16,12 +16,12 @@ require 'rails_helper' -describe 'posts/index.rss.haml', :type => "view" do +describe 'posts/index.rss.haml', type: "view" do before(:each) do controller.stub(:current_user) { nil } author = FactoryGirl.create(:member) - @post1 = FactoryGirl.create(:post, :id => 1, :author => author) - @post2 = FactoryGirl.create(:post, :id => 2, :author => author) + @post1 = FactoryGirl.create(:post, id: 1, author: author) + @post2 = FactoryGirl.create(:post, id: 2, author: author) assign(:posts, [@post1, @post2]) render end diff --git a/spec/views/posts/new.html.haml_spec.rb b/spec/views/posts/new.html.haml_spec.rb index 8b0da615e..e9d26ba5e 100644 --- a/spec/views/posts/new.html.haml_spec.rb +++ b/spec/views/posts/new.html.haml_spec.rb @@ -19,7 +19,7 @@ require 'rails_helper' describe "posts/new" do before(:each) do @author = FactoryGirl.create(:member) - assign(:post, FactoryGirl.create(:post, :author => @author)) + assign(:post, FactoryGirl.create(:post, author: @author)) # assign(:forum, Forum.new) sign_in @author controller.stub(:current_user) { @author } @@ -27,9 +27,9 @@ describe "posts/new" do it "renders new post form" do render - assert_select "form", :action => posts_path, :method => "post" do - assert_select "input#post_subject", :name => "post[subject]" - assert_select "textarea#post_body", :name => "post[body]" + assert_select "form", action: posts_path, method: "post" do + assert_select "input#post_subject", name: "post[subject]" + assert_select "textarea#post_body", name: "post[body]" end end @@ -51,7 +51,7 @@ describe "posts/new" do context "forum specified" do before(:each) do @forum = assign(:forum, FactoryGirl.create(:forum)) - assign(:post, FactoryGirl.create(:post, :forum => @forum)) + assign(:post, FactoryGirl.create(:post, forum: @forum)) render end diff --git a/spec/views/posts/show.html.haml_spec.rb b/spec/views/posts/show.html.haml_spec.rb index 13faf053d..e95d888b8 100644 --- a/spec/views/posts/show.html.haml_spec.rb +++ b/spec/views/posts/show.html.haml_spec.rb @@ -24,7 +24,7 @@ describe "posts/show" do it "renders the post" do @post = assign(:post, - FactoryGirl.create(:post, :author => @author)) + FactoryGirl.create(:post, author: @author)) render # show the name of the member who posted the post rendered.should match(/member\d+/) @@ -37,14 +37,14 @@ describe "posts/show" do it "should parse markdown into html" do @post = assign(:post, - FactoryGirl.create(:markdown_post, :author => @author)) + FactoryGirl.create(:markdown_post, author: @author)) render assert_select "strong", "strong" end it "shouldn't let html through in body" do @post = assign(:post, - FactoryGirl.create(:html_post, :author => @author)) + FactoryGirl.create(:html_post, author: @author)) render rendered.should match(/EVIL/) rendered.should_not match(/a href="http:\/\/evil.com"/) @@ -52,7 +52,7 @@ describe "posts/show" do it 'has an anchor to the comments' do @post = assign(:post, - FactoryGirl.create(:post, :author => @author)) + FactoryGirl.create(:post, author: @author)) render assert_select 'a[name=comments]' end @@ -60,8 +60,8 @@ describe "posts/show" do context "when there is one comment" do before(:each) do @post = assign(:post, - FactoryGirl.create(:html_post, :author => @author)) - @comment = FactoryGirl.create(:comment, :post => @post) + FactoryGirl.create(:html_post, author: @author)) + @comment = FactoryGirl.create(:comment, post: @post) @comments = @post.comments render end @@ -82,14 +82,14 @@ describe "posts/show" do context "when there is more than one comment" do before(:each) do @post = assign(:post, - FactoryGirl.create(:html_post, :author => @author)) - @comment1 = FactoryGirl.create(:comment, :post => @post, :body => "F1rst!!!", - :created_at => Date.new(2010, 5, 17)) - @comment3 = FactoryGirl.create(:comment, :post => @post, :body => "Th1rd!!!", - :created_at => Date.new(2012, 5, 17)) - @comment4 = FactoryGirl.create(:comment, :post => @post, :body => "F0urth!!!") - @comment2 = FactoryGirl.create(:comment, :post => @post, :body => "S3c0nd!!1!", - :created_at => Date.new(2011, 5, 17)) + FactoryGirl.create(:html_post, author: @author)) + @comment1 = FactoryGirl.create(:comment, post: @post, body: "F1rst!!!", + created_at: Date.new(2010, 5, 17)) + @comment3 = FactoryGirl.create(:comment, post: @post, body: "Th1rd!!!", + created_at: Date.new(2012, 5, 17)) + @comment4 = FactoryGirl.create(:comment, post: @post, body: "F0urth!!!") + @comment2 = FactoryGirl.create(:comment, post: @post, body: "S3c0nd!!1!", + created_at: Date.new(2011, 5, 17)) @comments = @post.comments render end @@ -102,7 +102,7 @@ describe "posts/show" do context "forum post" do it "shows forum name" do @post = assign(:post, - FactoryGirl.create(:forum_post, :author => @author)) + FactoryGirl.create(:forum_post, author: @author)) render rendered.should have_content "in #{@post.forum.name}" end @@ -113,12 +113,12 @@ describe "posts/show" do sign_in @author controller.stub(:current_user) { @author } @post = assign(:post, - FactoryGirl.create(:post, :author => @author)) + FactoryGirl.create(:post, author: @author)) render 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 diff --git a/spec/views/posts/show.rss.haml_spec.rb b/spec/views/posts/show.rss.haml_spec.rb index 08d6da814..abe9b81f4 100644 --- a/spec/views/posts/show.rss.haml_spec.rb +++ b/spec/views/posts/show.rss.haml_spec.rb @@ -21,8 +21,8 @@ describe 'posts/show.rss.haml' do controller.stub(:current_user) { nil } @author = FactoryGirl.create(:member) @post = FactoryGirl.create(:post) - FactoryGirl.create(:comment, :author => @author, :post => @post) - FactoryGirl.create(:comment, :author => @author, :post => @post) + FactoryGirl.create(:comment, author: @author, post: @post) + FactoryGirl.create(:comment, author: @author, post: @post) assign(:post, @post) render end diff --git a/spec/views/products/edit.html.haml_spec.rb b/spec/views/products/edit.html.haml_spec.rb index 4574064a7..107a32284 100644 --- a/spec/views/products/edit.html.haml_spec.rb +++ b/spec/views/products/edit.html.haml_spec.rb @@ -19,9 +19,9 @@ require 'rails_helper' describe "products/edit" do before(:each) do @product = assign(:product, stub_model(Product, - :name => "MyString", - :description => "MyString", - :min_price => "9.99" + name: "MyString", + description: "MyString", + min_price: "9.99" )) end @@ -29,11 +29,11 @@ describe "products/edit" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => products_path(@product), :method => "post" do - assert_select "input#product_name", :name => "product[name]" - assert_select "textarea#product_description", :name => "product[description]" - assert_select "input#product_min_price", :name => "product[min_price]" - assert_select "input#product_recommended_price", :name => "product[recommended_price]" + assert_select "form", action: products_path(@product), method: "post" do + assert_select "input#product_name", name: "product[name]" + assert_select "textarea#product_description", name: "product[description]" + assert_select "input#product_min_price", name: "product[min_price]" + assert_select "input#product_recommended_price", name: "product[recommended_price]" end end end diff --git a/spec/views/products/index.html.haml_spec.rb b/spec/views/products/index.html.haml_spec.rb index dcd85623d..7fdaa0d20 100644 --- a/spec/views/products/index.html.haml_spec.rb +++ b/spec/views/products/index.html.haml_spec.rb @@ -25,8 +25,8 @@ describe "products/index" do it "renders a list of products" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", :text => @product.name, :count => 2 - assert_select "tr>td", :text => @product.description, :count => 2 - assert_select "tr>td", :text => @product.min_price, :count => 2 + assert_select "tr>td", text: @product.name, count: 2 + assert_select "tr>td", text: @product.description, count: 2 + assert_select "tr>td", text: @product.min_price, count: 2 end end diff --git a/spec/views/products/new.html.haml_spec.rb b/spec/views/products/new.html.haml_spec.rb index 08986cacf..db20a5c95 100644 --- a/spec/views/products/new.html.haml_spec.rb +++ b/spec/views/products/new.html.haml_spec.rb @@ -19,9 +19,9 @@ require 'rails_helper' describe "products/new" do before(:each) do assign(:product, stub_model(Product, - :name => "MyString", - :description => "MyString", - :min_price => "9.99" + name: "MyString", + description: "MyString", + min_price: "9.99" ).as_new_record) end @@ -29,13 +29,13 @@ describe "products/new" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => products_path, :method => "post" do - assert_select "input#product_name", :name => "product[name]" - assert_select "textarea#product_description", :name => "product[description]" - assert_select "input#product_min_price", :name => "product[min_price]" - assert_select "input#product_recommended_price", :name => "product[recommended_price]" - assert_select "select#product_account_type_id", :name => "product[account_type_id]" - assert_select "input#product_paid_months", :name => "product[paid_months]" + assert_select "form", action: products_path, method: "post" do + assert_select "input#product_name", name: "product[name]" + assert_select "textarea#product_description", name: "product[description]" + assert_select "input#product_min_price", name: "product[min_price]" + assert_select "input#product_recommended_price", name: "product[recommended_price]" + assert_select "select#product_account_type_id", name: "product[account_type_id]" + assert_select "input#product_paid_months", name: "product[paid_months]" end end end diff --git a/spec/views/roles/edit.html.haml_spec.rb b/spec/views/roles/edit.html.haml_spec.rb index e4b927471..a4026f63e 100644 --- a/spec/views/roles/edit.html.haml_spec.rb +++ b/spec/views/roles/edit.html.haml_spec.rb @@ -19,8 +19,8 @@ require 'rails_helper' describe "roles/edit" do before(:each) do @role = assign(:role, stub_model(Role, - :name => "MyString", - :description => "MyText" + name: "MyString", + description: "MyText" )) end @@ -28,9 +28,9 @@ describe "roles/edit" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => roles_path(@role), :method => "post" do - assert_select "input#role_name", :name => "role[name]" - assert_select "textarea#role_description", :name => "role[description]" + assert_select "form", action: roles_path(@role), method: "post" do + assert_select "input#role_name", name: "role[name]" + assert_select "textarea#role_description", name: "role[description]" end end end diff --git a/spec/views/roles/index.html.haml_spec.rb b/spec/views/roles/index.html.haml_spec.rb index 6e821daff..fe8e40333 100644 --- a/spec/views/roles/index.html.haml_spec.rb +++ b/spec/views/roles/index.html.haml_spec.rb @@ -21,12 +21,12 @@ describe "roles/index" do controller.stub(:current_user) { nil } assign(:roles, [ stub_model(Role, - :name => "Name", - :description => "MyText" + name: "Name", + description: "MyText" ), stub_model(Role, - :name => "Name", - :description => "MyText" + name: "Name", + description: "MyText" ) ]) end @@ -34,7 +34,7 @@ describe "roles/index" do it "renders a list of roles" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", :text => "Name".to_s, :count => 2 - assert_select "tr>td", :text => "MyText".to_s, :count => 2 + assert_select "tr>td", text: "Name".to_s, count: 2 + assert_select "tr>td", text: "MyText".to_s, count: 2 end end diff --git a/spec/views/roles/new.html.haml_spec.rb b/spec/views/roles/new.html.haml_spec.rb index 3073f7f35..01dcd4c60 100644 --- a/spec/views/roles/new.html.haml_spec.rb +++ b/spec/views/roles/new.html.haml_spec.rb @@ -19,8 +19,8 @@ require 'rails_helper' describe "roles/new" do before(:each) do assign(:role, stub_model(Role, - :name => "MyString", - :description => "MyText" + name: "MyString", + description: "MyText" ).as_new_record) end @@ -28,9 +28,9 @@ describe "roles/new" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => roles_path, :method => "post" do - assert_select "input#role_name", :name => "role[name]" - assert_select "textarea#role_description", :name => "role[description]" + assert_select "form", action: roles_path, method: "post" do + assert_select "input#role_name", name: "role[name]" + assert_select "textarea#role_description", name: "role[description]" end end end diff --git a/spec/views/roles/show.html.haml_spec.rb b/spec/views/roles/show.html.haml_spec.rb index 889535194..cc0eb506e 100644 --- a/spec/views/roles/show.html.haml_spec.rb +++ b/spec/views/roles/show.html.haml_spec.rb @@ -19,8 +19,8 @@ require 'rails_helper' describe "roles/show" do before(:each) do @role = assign(:role, stub_model(Role, - :name => "Name", - :description => "MyText" + name: "Name", + description: "MyText" )) end diff --git a/spec/views/scientific_names/edit.html.haml_spec.rb b/spec/views/scientific_names/edit.html.haml_spec.rb index f85bab335..09ff5125b 100644 --- a/spec/views/scientific_names/edit.html.haml_spec.rb +++ b/spec/views/scientific_names/edit.html.haml_spec.rb @@ -33,9 +33,9 @@ describe "scientific_names/edit" do end it "renders the edit scientific_name form" do - assert_select "form", :action => scientific_names_path(@scientific_name), :method => "post" do - assert_select "input#scientific_name_scientific_name", :name => "scientific_name[scientific_name]" - assert_select "select#scientific_name_crop_id", :name => "scientific_name[crop_id]" + assert_select "form", action: scientific_names_path(@scientific_name), method: "post" do + assert_select "input#scientific_name_scientific_name", name: "scientific_name[scientific_name]" + assert_select "select#scientific_name_crop_id", name: "scientific_name[crop_id]" end end end diff --git a/spec/views/scientific_names/index.html.haml_spec.rb b/spec/views/scientific_names/index.html.haml_spec.rb index 2fb36e99d..ea89ae101 100644 --- a/spec/views/scientific_names/index.html.haml_spec.rb +++ b/spec/views/scientific_names/index.html.haml_spec.rb @@ -27,8 +27,8 @@ describe "scientific_names/index" do it "renders a list of scientific_names" do render - assert_select "tr>td", :text => "Zea mays".to_s - assert_select "tr>td", :text => "Solanum lycopersicum".to_s + assert_select "tr>td", text: "Zea mays".to_s + assert_select "tr>td", text: "Solanum lycopersicum".to_s end it "doesn't show edit/destroy links" do diff --git a/spec/views/scientific_names/new.html.haml_spec.rb b/spec/views/scientific_names/new.html.haml_spec.rb index 2ca9f68c0..a8ad3f615 100644 --- a/spec/views/scientific_names/new.html.haml_spec.rb +++ b/spec/views/scientific_names/new.html.haml_spec.rb @@ -32,9 +32,9 @@ describe "scientific_names/new" do it "renders new scientific_name form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => scientific_names_path, :method => "post" do - assert_select "input#scientific_name_scientific_name", :name => "scientific_name[scientific_name]" - assert_select "select#scientific_name_crop_id", :name => "scientific_name[crop_id]" + assert_select "form", action: scientific_names_path, method: "post" do + assert_select "input#scientific_name_scientific_name", name: "scientific_name[scientific_name]" + assert_select "select#scientific_name_crop_id", name: "scientific_name[crop_id]" end end diff --git a/spec/views/seeds/edit.html.haml_spec.rb b/spec/views/seeds/edit.html.haml_spec.rb index 9bdcf9447..1c9911afa 100644 --- a/spec/views/seeds/edit.html.haml_spec.rb +++ b/spec/views/seeds/edit.html.haml_spec.rb @@ -21,26 +21,26 @@ describe "seeds/edit" do @member = FactoryGirl.create(:member) sign_in @member controller.stub(:current_user) { @member } - @seed = FactoryGirl.create(:seed, :owner => @member) + @seed = FactoryGirl.create(:seed, owner: @member) end it "renders the edit seed form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => seeds_path(@seed), :method => "post" do - assert_select "input#crop", :class => "ui-autocomplete-input" - assert_select "input#seed_crop_id", :name => "seed[crop_id]" - assert_select "textarea#seed_description", :name => "seed[description]" - assert_select "input#seed_quantity", :name => "seed[quantity]" - assert_select "select#seed_tradable_to", :name => "seed[tradable_to]" + assert_select "form", action: seeds_path(@seed), method: "post" do + assert_select "input#crop", class: "ui-autocomplete-input" + assert_select "input#seed_crop_id", name: "seed[crop_id]" + assert_select "textarea#seed_description", name: "seed[description]" + assert_select "input#seed_quantity", name: "seed[quantity]" + assert_select "select#seed_tradable_to", name: "seed[tradable_to]" end end it "doesn't revert tradable_to to nowhere" do - @seed = FactoryGirl.create(:tradable_seed, :owner => @member) + @seed = FactoryGirl.create(:tradable_seed, owner: @member) @seed.tradable_to.should_not eq "nowhere" render - assert_select "option[selected=selected]", :text => @seed.tradable_to + assert_select "option[selected=selected]", text: @seed.tradable_to end end diff --git a/spec/views/seeds/new.html.haml_spec.rb b/spec/views/seeds/new.html.haml_spec.rb index 82bc32bd4..2f20412fa 100644 --- a/spec/views/seeds/new.html.haml_spec.rb +++ b/spec/views/seeds/new.html.haml_spec.rb @@ -21,25 +21,25 @@ describe "seeds/new" do @member = FactoryGirl.create(:member) sign_in @member controller.stub(:current_user) { @member } - @seed1 = FactoryGirl.create(:seed, :owner => @member) + @seed1 = FactoryGirl.create(:seed, owner: @member) assign(:seed, @seed1) end it "renders new seed form" do render - assert_select "form", :action => seeds_path, :method => "post" do - assert_select "input#crop", :class => "ui-autocomplete-input" - assert_select "input#seed_crop_id", :name => "seed[crop_id]" - assert_select "textarea#seed_description", :name => "seed[description]" - assert_select "input#seed_quantity", :name => "seed[quantity]" - assert_select "select#seed_tradable_to", :name => "seed[tradable_to]" + assert_select "form", action: seeds_path, method: "post" do + assert_select "input#crop", class: "ui-autocomplete-input" + assert_select "input#seed_crop_id", name: "seed[crop_id]" + assert_select "textarea#seed_description", name: "seed[description]" + assert_select "input#seed_quantity", name: "seed[quantity]" + assert_select "select#seed_tradable_to", name: "seed[tradable_to]" end end it 'reminds you to set your location' do render rendered.should have_content "Don't forget to set your location." - assert_select "a", :text => "set your location" + assert_select "a", text: "set your location" end context 'member has location' do @@ -47,19 +47,19 @@ describe "seeds/new" do @member = FactoryGirl.create(:london_member) sign_in @member controller.stub(:current_user) { @member } - @seed1 = FactoryGirl.create(:seed, :owner => @member) + @seed1 = FactoryGirl.create(:seed, owner: @member) assign(:seed, @seed1) end it 'shows the location' do render rendered.should have_content "from #{@member.location}." - assert_select 'a', :href => place_path(@member.location) + assert_select 'a', href: place_path(@member.location) end it 'links to change location' do render - assert_select "a", :text => "Change your location." + assert_select "a", text: "Change your location." end end diff --git a/spec/views/seeds/show.html.haml_spec.rb b/spec/views/seeds/show.html.haml_spec.rb index 660eadfb9..db2bae6ce 100644 --- a/spec/views/seeds/show.html.haml_spec.rb +++ b/spec/views/seeds/show.html.haml_spec.rb @@ -32,7 +32,7 @@ describe "seeds/show" do before(:each) do @owner = FactoryGirl.create(:london_member) assign(:seed, FactoryGirl.create(:tradable_seed, - :owner => @owner)) + owner: @owner)) # note current_member is not the owner of this seed @member = FactoryGirl.create(:member) sign_in @member @@ -47,7 +47,7 @@ describe "seeds/show" do it "shows location of seed owner" do render rendered.should have_content @owner.location - assert_select 'a', :href => place_path(@owner.location) + assert_select 'a', href: place_path(@owner.location) end context 'with no location' do @@ -55,7 +55,7 @@ describe "seeds/show" do @owner = FactoryGirl.create(:member) # no location sign_in @owner controller.stub(:current_user) { @owner } - assign(:seed, FactoryGirl.create(:tradable_seed, :owner => @owner)) + assign(:seed, FactoryGirl.create(:tradable_seed, owner: @owner)) end it 'says "from unspecified location"' do @@ -65,7 +65,7 @@ describe "seeds/show" do it "links to profile to set location" do render - assert_select "a[href=#{url_for(edit_member_registration_path)}]", :text => "Set Location" + assert_select "a[href=#{url_for(edit_member_registration_path)}]", text: "Set Location" end end diff --git a/spec/views/shop/index_spec.rb b/spec/views/shop/index_spec.rb index f6a4131ce..df1f74920 100644 --- a/spec/views/shop/index_spec.rb +++ b/spec/views/shop/index_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'shop/index.html.haml', :type => "view" do +describe 'shop/index.html.haml', type: "view" do before(:each) do @product1 = FactoryGirl.create(:product) @product2 = FactoryGirl.create(:product_with_recommended_price) @@ -32,7 +32,7 @@ describe 'shop/index.html.haml', :type => "view" do end it 'shows products' do - assert_select("h2", :text => @product1.name) + assert_select("h2", text: @product1.name) end it 'shows prices in configured currency' do @@ -54,11 +54,11 @@ describe 'shop/index.html.haml', :type => "view" do end it 'displays the order form' do - assert_select "form", :count => 2 + assert_select "form", count: 2 end it 'renders markdown in product descriptions' do - assert_select "em", :text => 'hurrah', :count => 2 + assert_select "em", text: 'hurrah', count: 2 end end diff --git a/spec/views/support/index_spec.rb b/spec/views/support/index_spec.rb index 5d9ce615d..3749bbf6d 100644 --- a/spec/views/support/index_spec.rb +++ b/spec/views/support/index_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' -describe 'support/index.html.haml', :type => "view" do +describe 'support/index.html.haml', type: "view" do before(:each) do render end