diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4e0d899c7..769bcb9b6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-offense-counts` -# on 2017-12-06 11:20:15 +1300 using RuboCop version 0.49.1. +# on 2018-02-05 14:37:22 +1300 using RuboCop version 0.49.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -39,7 +39,6 @@ Rails/SkipsModelValidations: # SupportedStyles: strict, flexible Rails/TimeZone: Exclude: - - 'spec/controllers/accounts_controller_spec.rb' - 'spec/factories/member.rb' - 'spec/factories/post.rb' - 'spec/models/post_spec.rb' @@ -60,7 +59,6 @@ Style/AsciiComments: # SupportedStyles: nested, compact Style/ClassAndModuleChildren: Exclude: - - 'app/controllers/admin/orders_controller.rb' - 'lib/actions/oauth_signup_action.rb' - 'lib/haml/filters/escaped_markdown.rb' @@ -68,24 +66,11 @@ Style/IdenticalConditionalBranches: Exclude: - 'app/controllers/follows_controller.rb' -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: line_count_dependent, lambda, literal -Style/Lambda: - Exclude: - - 'spec/controllers/member_controller_spec.rb' - - 'spec/models/photo_spec.rb' - # Cop supports --auto-correct. Style/MultilineIfModifier: Exclude: - 'spec/rails_helper.rb' -# Cop supports --auto-correct. -Style/MutableConstant: - Exclude: - - 'app/models/planting.rb' - # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles. # SupportedStyles: predicate, comparison @@ -96,11 +81,6 @@ Style/NumericPredicate: - 'app/helpers/plantings_helper.rb' - 'lib/tasks/growstuff.rake' -# Cop supports --auto-correct. -Style/ParallelAssignment: - Exclude: - - 'app/mailers/notifier.rb' - # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. # SupportedStyles: slashes, percent_r, mixed diff --git a/Gemfile b/Gemfile index 4e6dc5797..f49aaa60d 100644 --- a/Gemfile +++ b/Gemfile @@ -48,7 +48,6 @@ gem 'bootstrap-kaminari-views' # bootstrap views for kaminari gem 'kaminari' # pagination gem 'active_utils' -gem 'activemerchant' gem 'sidekiq' # Markdown formatting for updates etc @@ -78,7 +77,7 @@ gem 'omniauth-facebook' gem 'omniauth-flickr', '>= 0.0.15' gem 'omniauth-twitter' -gem 'chartkick' +gem "chartkick" # client for Elasticsearch. Elasticsearch is a flexible # and powerful, distributed, real-time search and analytics engine. @@ -87,15 +86,15 @@ gem 'chartkick' # Project does not use semver, so we want to be in sync with the version of # elasticsearch we use # See https://github.com/elastic/elasticsearch-ruby#compatibility -gem 'elasticsearch-api', '~> 2.0.0' -gem 'elasticsearch-model' -gem 'elasticsearch-rails' -gem 'hashie', '>= 3.5.3' +gem "elasticsearch-api", "~> 2.0.0" +gem "elasticsearch-model" +gem "elasticsearch-rails" +gem "hashie", ">= 3.5.3" gem 'rake', '>= 10.0.0' # locale based flash notices for controllers -gem 'responders' +gem "responders" # allows soft delete. Used for members. gem 'acts_as_paranoid', '~> 0.5.0' @@ -125,7 +124,6 @@ group :development do end group :development, :test do - gem 'active_merchant-paypal-bogus-gateway' gem 'bullet' # performance tuning by finding unnecesary queries gem 'byebug' # debugging gem 'capybara' # integration tests diff --git a/Gemfile.lock b/Gemfile.lock index 2101269a0..a2bd0a4ed 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -26,19 +26,12 @@ GEM addressable active_median (0.1.4) activerecord - active_merchant-paypal-bogus-gateway (0.1.0) - activemerchant active_utils (3.3.9) activesupport (>= 3.2, < 5.2.0) i18n activejob (4.2.10) activesupport (= 4.2.10) globalid (>= 0.3.0) - activemerchant (1.77.0) - activesupport (>= 3.2.14, < 6.x) - builder (>= 2.1.2, < 4.0.0) - i18n (>= 0.6.9) - nokogiri (~> 1.4) activemodel (4.2.10) activesupport (= 4.2.10) builder (~> 3.1) @@ -549,9 +542,7 @@ PLATFORMS DEPENDENCIES active_median - active_merchant-paypal-bogus-gateway active_utils - activemerchant acts_as_paranoid (~> 0.5.0) better_errors (~> 2.2.0) binding_of_caller @@ -636,7 +627,6 @@ DEPENDENCIES will_paginate xmlrpc - RUBY VERSION ruby 2.4.1p111 diff --git a/Guardfile b/Guardfile index dabd4b9d5..4b5f3ccb5 100644 --- a/Guardfile +++ b/Guardfile @@ -3,11 +3,11 @@ guard :rspec, failed_mode: :keep do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/libs/#{m[1]}_spec.rb" } - watch('spec/spec_helper.rb') { 'spec' } + watch('spec/spec_helper.rb') { "spec" } # Rails example watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } - watch(%r{^spec/support/(.+)\.rb$}) { 'spec' } - watch('config/routes.rb') { 'spec/routing' } + watch(%r{^spec/support/(.+)\.rb$}) { "spec" } + watch('config/routes.rb') { "spec/routing" } end diff --git a/app/controllers/account_types_controller.rb b/app/controllers/account_types_controller.rb deleted file mode 100644 index f86892346..000000000 --- a/app/controllers/account_types_controller.rb +++ /dev/null @@ -1,53 +0,0 @@ -class AccountTypesController < ApplicationController - before_action :authenticate_member! - load_and_authorize_resource - respond_to :html - - # GET /account_types - def index - @account_types = AccountType.all.order(:name) - respond_with(@account_types) - end - - # GET /account_types/1 - def show - respond_with(@account_types) - end - - # GET /account_types/new - def new - @account_type = AccountType.new - respond_with(@account_type) - end - - # GET /account_types/1/edit - def edit - respond_with(@account_type) - end - - # POST /account_types - def create - @account_type = AccountType.new(account_type_params) - flash[:notice] = I18n.t('account_types.created') if @account_type.save - respond_with(@account_type) - end - - # PUT /account_types/1 - def update - flash[:notice] = I18n.t('account_types.updated') if @account_type.update(account_type_params) - respond_with(@account_type) - end - - # DELETE /account_types/1 - def destroy - @account_type.destroy - flash[:notice] = I18n.t('account_types.deleted') - respond_with(@account_type) - end - - private - - def account_type_params - params.require(:account_type).permit(:is_paid, :is_permanent_paid, :name) - end -end diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb deleted file mode 100644 index 040092aba..000000000 --- a/app/controllers/accounts_controller.rb +++ /dev/null @@ -1,31 +0,0 @@ -class AccountsController < ApplicationController - before_action :authenticate_member! - load_and_authorize_resource - respond_to :html - - # GET /accounts - def index - @accounts = Account.all.order(created_at: :desc) - respond_with(@accounts) - end - - # GET /accounts/1 - def show - respond_with(@account) - end - - # GET /accounts/1/edit - def edit; end - - # PUT /accounts/1 - def update - flash[:notice] = I18n.t('account.update') if @account.update(params[:account]) - respond_with(@account) - end - - private - - def account_params - params.require(:account).permit(:account_type_id, :member_id, :paid_until) - end -end diff --git a/app/controllers/admin/orders_controller.rb b/app/controllers/admin/orders_controller.rb deleted file mode 100644 index d4f727ec0..000000000 --- a/app/controllers/admin/orders_controller.rb +++ /dev/null @@ -1,23 +0,0 @@ -module Admin - class OrdersController < ApplicationController - def index - authorize! :manage, :all - respond_to do |format| - format.html # index.html.haml - end - end - - def search - authorize! :manage, :all - @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]}" - end - - respond_to do |format| - format.html # index.html.haml - end - end - end -end diff --git a/app/controllers/alternate_names_controller.rb b/app/controllers/alternate_names_controller.rb index e06a07b5a..0f1471a8c 100644 --- a/app/controllers/alternate_names_controller.rb +++ b/app/controllers/alternate_names_controller.rb @@ -30,7 +30,7 @@ class AlternateNamesController < ApplicationController if @alternate_name.save redirect_to @alternate_name.crop, notice: 'Alternate name was successfully created.' else - render action: 'new' + render action: "new" end end @@ -40,7 +40,7 @@ class AlternateNamesController < ApplicationController if @alternate_name.update(alternate_name_params) redirect_to @alternate_name.crop, notice: 'Alternate name was successfully updated.' else - render action: 'edit' + render action: "edit" end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7b5a0bf32..3e6221d06 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -7,12 +7,12 @@ class ApplicationController < ActionController::Base before_action :set_locale def store_location - unless request.path.in?(['/members/sign_in', - '/members/sign_up', - '/members/password/new', - '/members/password/edit', - '/members/confirmation', - '/members/sign_out']) || request.xhr? + unless request.path.in?(["/members/sign_in", + "/members/sign_up", + "/members/password/new", + "/members/password/edit", + "/members/confirmation", + "/members/sign_out"]) || request.xhr? store_location_for(:member, request.fullpath) end end @@ -77,6 +77,6 @@ class ApplicationController < ActionController::Base end def expire_homepage - expire_fragment('homepage_stats') + expire_fragment("homepage_stats") end end diff --git a/app/controllers/authentications_controller.rb b/app/controllers/authentications_controller.rb index 7c603eb6a..fc18ff4d7 100644 --- a/app/controllers/authentications_controller.rb +++ b/app/controllers/authentications_controller.rb @@ -22,9 +22,9 @@ class AuthenticationsController < ApplicationController name: name ) - flash[:notice] = 'Authentication successful.' + flash[:notice] = "Authentication successful." else - flash[:notice] = 'Authentication failed.' + flash[:notice] = "Authentication failed." end redirect_to request.env['omniauth.origin'] || edit_member_registration_path end diff --git a/app/controllers/charts/crops_controller.rb b/app/controllers/charts/crops_controller.rb index 17c774c14..b5fe3d4a7 100644 --- a/app/controllers/charts/crops_controller.rb +++ b/app/controllers/charts/crops_controller.rb @@ -14,7 +14,7 @@ module Charts @crop = Crop.find(params[:crop_id]) render json: Harvest.joins(:plant_part) .where(crop: @crop) - .group('plant_parts.name').count(:id) + .group("plant_parts.name").count(:id) end private diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index e6ff7c7e0..361e28031 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -23,9 +23,9 @@ class CropsController < ApplicationController def wrangle @approval_status = params[:approval_status] @crops = case @approval_status - when 'pending' + when "pending" Crop.pending_approval - when 'rejected' + when "rejected" Crop.rejected else Crop.recent @@ -78,7 +78,7 @@ class CropsController < ApplicationController @crop.creator = current_member else @crop.requester = current_member - @crop.approval_status = 'pending' + @crop.approval_status = "pending" end notify_wranglers if Crop.transaction { @crop.save && save_crop_names } @@ -89,13 +89,13 @@ class CropsController < ApplicationController def update previous_status = @crop.approval_status - @crop.creator = current_member if previous_status == 'pending' + @crop.creator = current_member if previous_status == "pending" if @crop.update(crop_params) recreate_names('alt_name', 'alternate') recreate_names('sci_name', 'scientific') - notifier.deliver_now! if previous_status == 'pending' + notifier.deliver_now! if previous_status == "pending" end respond_with @crop @@ -110,9 +110,9 @@ class CropsController < ApplicationController def notifier case @crop.approval_status - when 'approved' + when "approved" Notifier.crop_request_approved(@crop.requester, @crop) - when 'rejected' + when "rejected" Notifier.crop_request_rejected(@crop.requester, @crop) end end @@ -185,7 +185,7 @@ class CropsController < ApplicationController def crops q = Crop.approved.includes(:scientific_names, plantings: :photos) q = q.popular unless @sort == 'alpha' - q.order('LOWER(crops.name)').includes(:photos).paginate(page: params[:page]) + q.order("LOWER(crops.name)").includes(:photos).paginate(page: params[:page]) end def requested_crops diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index 80341035f..2c4b2daab 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -11,7 +11,7 @@ class FollowsController < ApplicationController flash[:notice] = "Followed #{@follow.followed.login_name}" redirect_to :back else - flash[:error] = 'Already following or error while following.' + flash[:error] = "Already following or error while following." redirect_to :back end end diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index d5a8506d7..5f7c5dac9 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -26,7 +26,7 @@ class LikesController < ApplicationController { id: like.likeable.id, liked_by_member: liked_by_member, - description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, 'like'), + description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like"), url: like_path(like, format: :json) } end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index e435ef08a..c346eb8e3 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -49,8 +49,8 @@ class MembersController < ApplicationController end EMAIL_TYPE_STRING = { - send_notification_email: 'direct message notifications', - send_planting_reminder: 'planting reminders' + send_notification_email: "direct message notifications", + send_planting_reminder: "planting reminders" }.freeze def unsubscribe diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 61dbea6dd..7c3c1f322 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -21,7 +21,7 @@ class NotificationsController < ApplicationController def new @notification = Notification.new @recipient = Member.find_by(id: params[:recipient_id]) - @subject = params[:subject] || '' + @subject = params[:subject] || "" end # GET /notifications/1/reply @@ -53,7 +53,7 @@ class NotificationsController < ApplicationController if @notification.save redirect_to notifications_path, notice: 'Message was successfully sent.' else - render action: 'new' + render action: "new" end end diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index c70da1443..3d642cd3d 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -12,8 +12,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController end def failure - flash[:alert] = 'Authentication failed.' - redirect_to request.env['omniauth.origin'] || '/' + flash[:alert] = "Authentication failed." + redirect_to request.env['omniauth.origin'] || "/" end private @@ -30,9 +30,9 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController @authentication = action.establish_authentication(auth, member) if action.member_created? - raise 'Invalid provider' unless %w(facebook twitter flickr).index(auth['provider'].to_s) + raise "Invalid provider" unless %w(facebook twitter flickr).index(auth['provider'].to_s) - session["devise.#{auth['provider']}_data"] = request.env['omniauth.auth'] + session["devise.#{auth['provider']}_data"] = request.env["omniauth.auth"] sign_in member redirect_to finish_signup_url(member) else diff --git a/app/controllers/order_items_controller.rb b/app/controllers/order_items_controller.rb deleted file mode 100644 index 9c3e79dae..000000000 --- a/app/controllers/order_items_controller.rb +++ /dev/null @@ -1,36 +0,0 @@ -class OrderItemsController < ApplicationController - before_action :authenticate_member! - load_and_authorize_resource - respond_to :html - responders :flash - - # POST /order_items - def create - if params[:order_item][:price] - 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) - - if @order_item.save - redirect_to @order_item.order, notice: 'Added item to your order.' - else - redirect_to shop_path, alert: errors - end - end - - private - - def errors - if @order_item.errors.empty? - 'There was a problem with your order.' - else - @order_item.errors.full_messages.to_sentence - end - end - - def order_item_params - params.require(:order_item).permit(:order_id, :price, :product_id, :quantity) - end -end diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb deleted file mode 100644 index 0929d3948..000000000 --- a/app/controllers/orders_controller.rb +++ /dev/null @@ -1,90 +0,0 @@ -class OrdersController < ApplicationController - before_action :authenticate_member! - load_and_authorize_resource - - # GET /orders - def index - @orders = Order.by_member(current_member) - - respond_to do |format| - format.html # index.html.erb - end - end - - # GET /orders/1 - def show - respond_to do |format| - format.html # show.html.erb - end - end - - # GET /orders/new - def new - @order = Order.new - - respond_to do |format| - format.html # new.html.erb - end - end - - # checkout with PayPal - def checkout - respond_to do |format| - 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 - ) - format.html { redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token) } - else - format.html { render action: 'show' } - end - end - end - - def complete - 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] - ) - if purchase.success? - @order.completed_at = Time.zone.now - @order.record_paypal_details(params[:token]) - else - flash[:alert] = 'Could not complete your order. Please notify support.' - end - else - flash[:alert] = "PayPal didn't return a token or payer_id for your order. Please notify support." - end - - @order.update_account # apply paid account benefits, etc. - - respond_to do |format| - format.html # new.html.erb - end - end - - def cancel - respond_to do |format| - format.html { redirect_to shop_url, notice: 'Order was cancelled.' } - end - end - - # DELETE /orders/1 - def destroy - @order.destroy - - respond_to do |format| - format.html { redirect_to shop_url, notice: 'Order was deleted.' } - end - end -end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index ec270b2a6..9ffb98af8 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,6 +1,6 @@ class PagesController < ApplicationController def letsencrypt # use your code here, not mine - render text: 'y9KNck8wqkoQLnlr2RgA2TVwWtyYb4PeY_hzGNx0Tfs.dlIPqFhMDCLyQEccczY3roHZ1UWu6UqVeyb9mkRxheU' + render text: "y9KNck8wqkoQLnlr2RgA2TVwWtyYb4PeY_hzGNx0Tfs.dlIPqFhMDCLyQEccczY3roHZ1UWu6UqVeyb9mkRxheU" end end diff --git a/app/controllers/photo_associations_controller.rb b/app/controllers/photo_associations_controller.rb index 35ef97632..126aaf9b3 100644 --- a/app/controllers/photo_associations_controller.rb +++ b/app/controllers/photo_associations_controller.rb @@ -3,7 +3,7 @@ class PhotoAssociationsController < ApplicationController respond_to :json, :html def destroy - raise 'Photos not supported' unless Photo::PHOTO_CAPABLE.include? item_class + raise "Photos not supported" unless Photo::PHOTO_CAPABLE.include? item_class @photo = Photo.find_by!(id: params[:photo_id], owner: current_member) @item = Photographing.item(item_id, item_class) @item.photos.delete(@photo) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 3757894a8..57b10e5d8 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -75,10 +75,10 @@ class PhotosController < ApplicationController # Item with photos attached def item_to_link_to - raise 'No item id provided' if item_id.nil? - raise 'No item type provided' if item_type.nil? + raise "No item id provided" if item_id.nil? + raise "No item type provided" if item_type.nil? item_class = item_type.capitalize - raise 'Photos not supported' unless Photo::PHOTO_CAPABLE.include? item_class + raise "Photos not supported" unless Photo::PHOTO_CAPABLE.include? item_class item_class.constantize.find_by!(id: params[:id], owner_id: current_member.id) end diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb deleted file mode 100644 index 8e0a1fb08..000000000 --- a/app/controllers/products_controller.rb +++ /dev/null @@ -1,46 +0,0 @@ -class ProductsController < ApplicationController - before_action :authenticate_member! - load_and_authorize_resource - respond_to :html - responders :flash - - def index - @products = Product.all.order(:name) - respond_with @products - end - - def show - respond_with @product - end - - def new - @product = Product.new - respond_with @product - end - - def edit - respond_with @product - end - - def create - @product = Product.create(product_params) - respond_with @product - end - - def update - @product.update(product_params) - respond_with @product - end - - def destroy - @product.destroy - respond_with @product - end - - private - - def product_params - params.require(:product).permit(:description, :min_price, :recommended_price, :name, - :account_type_id, :paid_months) - end -end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index a83d6b466..72e92b9fd 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -5,7 +5,7 @@ class RegistrationsController < Devise::RegistrationsController @twitter_auth = current_member.auth('twitter') @flickr_auth = current_member.auth('flickr') @facebook_auth = current_member.auth('facebook') - render 'edit' + render "edit" end # we need this subclassed method so that Devise doesn't force people to @@ -32,7 +32,7 @@ class RegistrationsController < Devise::RegistrationsController sign_in @member, bypass: true redirect_to edit_member_registration_path else - render 'edit' + render "edit" end end @@ -40,7 +40,7 @@ class RegistrationsController < Devise::RegistrationsController if @member.destroy_with_password(params.require(:member)[:current_password]) redirect_to root_path else - render 'edit' + render "edit" end end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index ee1fddc3c..6106e0c75 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -4,7 +4,7 @@ class SessionsController < Devise::SessionsController def create super do |_resource| if Crop.pending_approval.present? && current_member.role?(:crop_wrangler) - flash[:alert] = 'There are crops waiting to be wrangled.' + flash[:alert] = "There are crops waiting to be wrangled." end end end diff --git a/app/controllers/shop_controller.rb b/app/controllers/shop_controller.rb deleted file mode 100644 index 964511e50..000000000 --- a/app/controllers/shop_controller.rb +++ /dev/null @@ -1,19 +0,0 @@ -class ShopController < ApplicationController - respond_to :html - def index - @products = Product.all - @order_item = OrderItem.new - - # this is (hopefully) part of a short-term hack to prevent people from - # ordering multiple subscriptions, which would be very confusing to deal - # with. We check whether they have an order already in progress, and if - # so, point that out to them and encourage them to checkout, rather than - # letting them add more stuff to their order. - - @order = nil - @most_recent_item = nil - return unless current_member - @order = current_member.current_order - @most_recent_item = @order.order_items.first if @order - end -end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6076d98ef..639d27686 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -18,7 +18,7 @@ module ApplicationHelper currency = Growstuff::Application.config.currency link = "http://www.wolframalpha.com/input/?i=#{pid}+#{currency}" - link_to '(convert)', link, target: '_blank', rel: 'noopener noreferrer' + link_to "(convert)", link, target: "_blank", rel: "noopener noreferrer" end def build_alert_classes(alert_type = :info) @@ -37,7 +37,7 @@ module ApplicationHelper end # Produces a cache key for uniquely identifying cached fragments. - def cache_key_for(klass, identifier = 'all') + def cache_key_for(klass, identifier = "all") count = klass.count max_updated_at = klass.maximum(:updated_at).try(:utc).try(:to_s, :number) "#{klass.name.downcase.pluralize}/#{identifier}-#{count}-#{max_updated_at}" @@ -102,7 +102,7 @@ module ApplicationHelper elsif planting t(".title.planting_#{type}", planting: planting.to_s) else - t('.title.default') + t(".title.default") end end diff --git a/app/helpers/crops_helper.rb b/app/helpers/crops_helper.rb index c96ff8fa1..b99d687aa 100644 --- a/app/helpers/crops_helper.rb +++ b/app/helpers/crops_helper.rb @@ -13,7 +13,7 @@ module CropsHelper if total_quantity != 0 "You have #{total_quantity} #{Seed.model_name.human(count: total_quantity)} of this crop." else - 'You have an unknown quantity of seeds of this crop.' + "You have an unknown quantity of seeds of this crop." end end diff --git a/app/helpers/gardens_helper.rb b/app/helpers/gardens_helper.rb index cfbf90024..a72505558 100644 --- a/app/helpers/gardens_helper.rb +++ b/app/helpers/gardens_helper.rb @@ -1,10 +1,10 @@ module GardensHelper def display_garden_description(garden) if garden.description.nil? - 'no description provided.' + "no description provided." else truncate(garden.description, length: 130, separator: ' ', omission: '... ') do - link_to 'Read more', garden_path(garden) + link_to "Read more", garden_path(garden) end end end @@ -19,12 +19,12 @@ module GardensHelper def display_garden_plantings(plantings) if plantings.blank? - 'None' + "None" else output = '" expect(result).to eq output end - it 'has 2 plantings' do + it "has 2 plantings" do plantings = [] crop1 = FactoryBot.create(:crop) @@ -61,17 +61,17 @@ describe GardensHelper do result = helper.display_garden_plantings(plantings.first(2)) output = '' + output += "" expect(result).to eq output end - it 'has 3 plantings' do + it "has 3 plantings" do plantings = [] crop1 = FactoryBot.create(:crop) @@ -86,13 +86,13 @@ describe GardensHelper do result = helper.display_garden_plantings(plantings.first(2)) output = '' + output += "" expect(result).to eq output end end diff --git a/spec/helpers/harvests_helper_spec.rb b/spec/helpers/harvests_helper_spec.rb index a234bc260..1ba63810d 100644 --- a/spec/helpers/harvests_helper_spec.rb +++ b/spec/helpers/harvests_helper_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' describe HarvestsHelper do - describe 'display_quantity' do - it 'blank' do + describe "display_quantity" do + it "blank" do harvest = FactoryBot.create(:harvest, quantity: nil, weight_quantity: nil) diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 8281b3712..a00dabff3 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' describe NotificationsHelper do - describe 'reply_link' do + describe "reply_link" do let(:member) { FactoryBot.create(:member) } - it 'replies to PMs with PMs' do + it "replies to PMs with PMs" do notification = FactoryBot.create(:notification, recipient_id: member.id, post_id: nil) link = helper.reply_link(notification) link.should_not be_nil link.should eq reply_notification_url(notification) end - it 'replies to post comments with post comments' do + it "replies to post comments with post comments" do notification = FactoryBot.create(:notification, recipient_id: member.id) link = helper.reply_link(notification) diff --git a/spec/helpers/plantings_helper_spec.rb b/spec/helpers/plantings_helper_spec.rb index acde7469f..3af084d5a 100644 --- a/spec/helpers/plantings_helper_spec.rb +++ b/spec/helpers/plantings_helper_spec.rb @@ -1,64 +1,64 @@ require 'rails_helper' describe PlantingsHelper do - describe 'display_planting' do + describe "display_planting" do let!(:member) { FactoryBot.build(:member, login_name: 'crop_lady') } - it 'does not have a quantity nor a planted from value provided' do + it "does not have a quantity nor a planted from value provided" do planting = FactoryBot.build(:planting, quantity: nil, planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady.' + expect(result).to eq "crop_lady." end - it 'does not have a quantity provided' do + it "does not have a quantity provided" do planting = FactoryBot.build(:planting, quantity: nil, planted_from: 'seed', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted seeds.' + expect(result).to eq "crop_lady planted seeds." end - context 'when quantity is greater than 1' do - it 'does not have a planted from value provided' do + context "when quantity is greater than 1" do + it "does not have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 10, planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 10 units.' + expect(result).to eq "crop_lady planted 10 units." end - it 'does have a planted from value provided' do + it "does have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 5, planted_from: 'seed', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 5 seeds.' + expect(result).to eq "crop_lady planted 5 seeds." end end - context 'when quantity is 1' do - it 'does not have a planted from value provided' do + context "when quantity is 1" do + it "does not have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 1, planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 1 unit.' + expect(result).to eq "crop_lady planted 1 unit." end - it 'does have a planted from value provided' do + it "does have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 1, planted_from: 'seed', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 1 seed.' + expect(result).to eq "crop_lady planted 1 seed." end end end diff --git a/spec/helpers/seeds_helper_spec.rb b/spec/helpers/seeds_helper_spec.rb index 837e1368a..3d559058e 100644 --- a/spec/helpers/seeds_helper_spec.rb +++ b/spec/helpers/seeds_helper_spec.rb @@ -1,33 +1,33 @@ require 'rails_helper' describe SeedsHelper do - describe 'seed description' do - it 'is missing' do + describe "seed description" do + it "is missing" do seed = FactoryBot.create(:seed, description: nil) result = helper.display_seed_description(seed) - expect(result).to eq 'no description provided.' + expect(result).to eq "no description provided." end - it 'is less than 130 characters long' do + it "is less than 130 characters long" do seed = FactoryBot.create(:seed, description: 'a' * 20) result = helper.display_seed_description(seed) expect(result).to eq 'a' * 20 end - it 'is 130 characters long' do + it "is 130 characters long" do seed = FactoryBot.create(:seed, description: 'a' * 130) result = helper.display_seed_description(seed) expect(result).to eq 'a' * 130 end - it 'is more than 130 characters long' do + it "is more than 130 characters long" do seed = FactoryBot.create(:seed, description: 'a' * 140) result = helper.display_seed_description(seed) - expect(result).to eq 'a' * 126 + '...' + ' ' + link_to('Read more', seed_path(seed)) + expect(result).to eq 'a' * 126 + '...' + ' ' + link_to("Read more", seed_path(seed)) end end end diff --git a/spec/lib/actions/oauth_signup_action_spec.rb b/spec/lib/actions/oauth_signup_action_spec.rb index a6f7958b1..1710428a4 100644 --- a/spec/lib/actions/oauth_signup_action_spec.rb +++ b/spec/lib/actions/oauth_signup_action_spec.rb @@ -17,8 +17,8 @@ describe 'Growstuff::OauthSignupAction' do 'image' => 'http://findicons.com/files/icons/1072/face_avatars/300/i04.png' }, 'credentials' => { - 'token' => 'token', - 'secret' => 'donttell' + 'token' => "token", + 'secret' => "donttell" }) end diff --git a/spec/lib/haml/filters/escaped_markdown_spec.rb b/spec/lib/haml/filters/escaped_markdown_spec.rb index 4677f596c..415751293 100644 --- a/spec/lib/haml/filters/escaped_markdown_spec.rb +++ b/spec/lib/haml/filters/escaped_markdown_spec.rb @@ -10,8 +10,8 @@ describe 'Haml::Filters::Escaped_Markdown' do end it 'converts Markdown to escaped HTML' do - rendered = Haml::Filters::EscapedMarkdown.render('**foo**') - rendered.should == '<p><strong>foo</strong></p>' + rendered = Haml::Filters::EscapedMarkdown.render("**foo**") + rendered.should == "<p><strong>foo</strong></p>" end it 'converts quick crop links' do diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb index 6c92c5e6d..03ad3b0e1 100644 --- a/spec/lib/haml/filters/growstuff_markdown_spec.rb +++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb @@ -35,17 +35,17 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "doesn't convert nonexistent crops" do - rendered = Haml::Filters::GrowstuffMarkdown.render(input_link('not a crop')) + rendered = Haml::Filters::GrowstuffMarkdown.render(input_link("not a crop")) expect(rendered).to match(/not a crop/) end it "doesn't convert escaped crop links" do @crop = FactoryBot.create(:crop) - rendered = Haml::Filters::GrowstuffMarkdown.render('\\' << input_link(@crop.name)) + rendered = Haml::Filters::GrowstuffMarkdown.render("\\" << input_link(@crop.name)) expect(rendered).to match(/\[#{@crop.name}\]\(crop\)/) end - it 'handles multiple crop links' do + it "handles multiple crop links" do tomato = FactoryBot.create(:tomato) maize = FactoryBot.create(:maize) string = "#{input_link(tomato)} #{input_link(maize)}" @@ -53,24 +53,24 @@ describe 'Haml::Filters::Growstuff_Markdown' do expect(rendered).to match(/#{output_link(tomato)} #{output_link(maize)}/) end - it 'converts normal markdown' do - string = '**foo**' + it "converts normal markdown" do + string = "**foo**" rendered = Haml::Filters::GrowstuffMarkdown.render(string) expect(rendered).to match(/foo<\/strong>/) end - it 'finds crops case insensitively' do + it "finds crops case insensitively" do @crop = FactoryBot.create(:crop, name: 'tomato') rendered = Haml::Filters::GrowstuffMarkdown.render(input_link('ToMaTo')) expect(rendered).to match(/#{output_link(@crop, 'ToMaTo')}/) end - it 'fixes PT bug #78615258 (Markdown rendering bug with URLs and crops in same text)' do + it "fixes PT bug #78615258 (Markdown rendering bug with URLs and crops in same text)" do tomato = FactoryBot.create(:tomato) - string = '[test](http://example.com) [tomato](crop)' + string = "[test](http://example.com) [tomato](crop)" rendered = Haml::Filters::GrowstuffMarkdown.render(string) expect(rendered).to match(/#{output_link(tomato)}/) - expect(rendered).to match 'test' + expect(rendered).to match "test" end it 'converts quick member links' do @@ -80,13 +80,13 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "doesn't convert nonexistent members" do - rendered = Haml::Filters::GrowstuffMarkdown.render(input_member_link('not a member')) + rendered = Haml::Filters::GrowstuffMarkdown.render(input_member_link("not a member")) expect(rendered).to include('not a member') end it "doesn't convert escaped members" do @member = FactoryBot.create(:member) - rendered = Haml::Filters::GrowstuffMarkdown.render('\\' << input_member_link(@member.login_name)) + rendered = Haml::Filters::GrowstuffMarkdown.render("\\" << input_member_link(@member.login_name)) expect(rendered).to match(/\[#{@member.login_name}\]\(member\)/) end @@ -97,7 +97,7 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "doesn't convert invalid @ members" do - rendered = Haml::Filters::GrowstuffMarkdown.render('@notamember') + rendered = Haml::Filters::GrowstuffMarkdown.render("@notamember") expect(rendered).to include('@notamember') end diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 344b26e7f..e50682700 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -1,7 +1,7 @@ -require 'rails_helper' +require "rails_helper" describe Notifier do - describe 'notifications' do + describe "notifications" do let(:notification) { FactoryBot.create(:notification) } let(:mail) { Notifier.notify(notification) } @@ -18,12 +18,12 @@ describe Notifier do end end - describe 'planting reminders' do + describe "planting reminders" do let(:member) { FactoryBot.create(:member) } let(:mail) { Notifier.planting_reminder(member) } it 'sets the subject correctly' do - mail.subject.should == 'What have you planted lately?' + mail.subject.should == "What have you planted lately?" end it 'comes from noreply@growstuff.org' do @@ -43,7 +43,7 @@ describe Notifier do end end - describe 'new crop request' do + describe "new crop request" do let(:member) { FactoryBot.create(:crop_wrangling_member) } let(:crop) { FactoryBot.create(:crop_request) } let(:mail) { Notifier.new_crop_request(member, crop) } @@ -65,13 +65,13 @@ describe Notifier do end end - describe 'crop approved' do + describe "crop approved" do let(:member) { FactoryBot.create(:member) } let(:crop) { FactoryBot.create(:crop) } let(:mail) { Notifier.crop_request_approved(member, crop) } it 'sets the subject correctly' do - expect(mail.subject).to eq 'Magic bean has been approved' + expect(mail.subject).to eq "Magic bean has been approved" end it 'comes from noreply@growstuff.org' do @@ -93,13 +93,13 @@ describe Notifier do end end - describe 'crop rejected' do + describe "crop rejected" do let(:member) { FactoryBot.create(:member) } let(:crop) { FactoryBot.create(:rejected_crop) } let(:mail) { Notifier.crop_request_rejected(member, crop) } it 'sets the subject correctly' do - expect(mail.subject).to eq 'Fail bean has been rejected' + expect(mail.subject).to eq "Fail bean has been rejected" end it 'comes from noreply@growstuff.org' do @@ -115,7 +115,7 @@ describe Notifier do end it 'includes the reason for rejection' do - expect(mail.body.encoded).to match 'Totally fake' + expect(mail.body.encoded).to match "Totally fake" end end end diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index d69b0ba57..e95dfbdc6 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -5,7 +5,7 @@ describe Ability do let(:member) { FactoryBot.create(:member) } let(:ability) { Ability.new(member) } - context 'notifications' do + context "notifications" do it 'member can view their own notifications' do notification = FactoryBot.create(:notification, recipient: member) ability.should be_able_to(:read, notification) @@ -22,7 +22,7 @@ describe Ability do recipient: member, sender: member)) end - it 'member can send messages to someone else' do + it "member can send messages to someone else" do ability.should be_able_to(:create, FactoryBot.create(:notification, recipient: FactoryBot.create(:member), @@ -30,247 +30,52 @@ describe Ability do end end - context 'crop wrangling' do + context "crop wrangling" do let(:crop) { FactoryBot.create(:crop) } - context 'standard member' do + context "standard member" do it "can't manage crops" do ability.should_not be_able_to(:update, crop) ability.should_not be_able_to(:destroy, crop) end - it 'can request crops' do + it "can request crops" do ability.should be_able_to(:create, Crop) end - it 'can read crops' do + it "can read crops" do ability.should be_able_to(:read, crop) end end - context 'crop wrangler' do + context "crop wrangler" do let(:role) { FactoryBot.create(:crop_wrangler) } before(:each) do member.roles << role end - it 'has crop_wrangler role' do + it "has crop_wrangler role" do member.role?(:crop_wrangler).should be true end - it 'can create crops' do + it "can create crops" do ability.should be_able_to(:create, Crop) end - it 'can update crops' do + it "can update crops" do ability.should be_able_to(:update, crop) end - it 'can destroy crops' do + it "can destroy crops" do ability.should be_able_to(:destroy, crop) end end end - context 'products' do - let(:product) { FactoryBot.create(:product) } - - context 'standard member' do - it "can't read or manage products" do - ability.should_not be_able_to(:read, product) - ability.should_not be_able_to(:create, Product) - ability.should_not be_able_to(:update, product) - ability.should_not be_able_to(:destroy, product) - end - end - - context 'admin' do - let(:role) { FactoryBot.create(:admin) } - - before do - member.roles << role - end - - it 'has admin role' do - member.role?(:admin).should be true - end - - it 'can read products' do - ability.should be_able_to(:read, product) - end - it 'can create products' do - ability.should be_able_to(:create, Product) - end - it 'can update products' do - ability.should be_able_to(:update, product) - end - it 'can destroy products' do - ability.should be_able_to(:destroy, product) - end - end - end - - context 'orders' do - let(:order) { FactoryBot.create(:order, member: member) } - let(:strangers_order) do - FactoryBot.create(:order, - member: FactoryBot.create(:member)) - end - let(:completed_order) do - FactoryBot.create(:completed_order, - member: member) - end - let(:order_item) { FactoryBot.create(:order_item, order: order) } - let(:strangers_order_item) do - FactoryBot.create(:order_item, - order: strangers_order) - end - let(:completed_order_item) do - FactoryBot.create(:order_item, - order: completed_order) - end - - context 'standard member' do - it 'can read their own orders' do - ability.should be_able_to(:read, order) - ability.should be_able_to(:read, completed_order) - end - - it "can't read other people's orders" do - ability.should_not be_able_to(:read, strangers_order) - end - - it 'can create a new order' do - ability.should be_able_to(:create, Order) - end - - it 'can complete their own current order' do - ability.should be_able_to(:complete, order) - end - - it "can't complete someone else's order" do - ability.should_not be_able_to(:complete, strangers_order) - end - - it "can't complete a completed order" do - ability.should_not be_able_to(:complete, completed_order) - end - - it 'can delete a current order' do - ability.should be_able_to(:destroy, order) - end - - it "can't delete someone else's order" do - ability.should_not be_able_to(:destroy, strangers_order) - end - - it "can't delete a completed order" do - ability.should_not be_able_to(:destroy, completed_order) - end - - it "can't read their own order items" do - ability.should_not be_able_to(:read, order_item) - ability.should_not be_able_to(:read, completed_order_item) - end - - it "can't read other people's order items" do - ability.should_not be_able_to(:read, strangers_order_item) - end - - it 'can create a new order item' do - ability.should be_able_to(:create, OrderItem) - end - - it "can't update their own order items" do - ability.should_not be_able_to(:update, order_item) - end - - it "can't update other people's order items" do - ability.should_not be_able_to(:update, strangers_order_item) - end - - it "can't updated items in completed orders" do - ability.should_not be_able_to(:update, completed_order_item) - end - - it "can't delete their own order item" do - ability.should_not be_able_to(:destroy, order_item) - end - - it "can't delete someone else's order item" do - ability.should_not be_able_to(:destroy, strangers_order_item) - end - - it "can't delete items from completed orders" do - ability.should_not be_able_to(:destroy, completed_order_item) - end - end - - context 'admin' do - let(:role) { FactoryBot.create(:admin) } - - before do - member.roles << role - end - - it 'has admin role' do - member.role?(:admin).should be true - end - - it 'can read orders' do - ability.should be_able_to(:read, order) - end - - it 'cannot create orders' do - ability.should_not be_able_to(:create, order) - end - - it 'cannot complete orders' do - ability.should_not be_able_to(:complete, order) - end - - it 'cannot delete orders' do - ability.should_not be_able_to(:destroy, order) - end - end - end - - context 'account details' do - let(:account) { member.account } - - context 'ordinary member' do - it "can't read account details" do - ability.should_not be_able_to(:read, account) - end - it "can't manage account details" do - ability.should_not be_able_to(:create, Account) - ability.should_not be_able_to(:update, account) - ability.should_not be_able_to(:destroy, account) - end - end - - context 'admin' do - let(:role) { FactoryBot.create(:admin) } - - before do - member.roles << role - end - - it 'can read account details' do - ability.should be_able_to(:read, account) - end - it 'can manage account details' do - ability.should be_able_to(:create, Account) - ability.should be_able_to(:update, account) - ability.should be_able_to(:destroy, account) - end - end - end - context 'plant parts' do let(:plant_part) { FactoryBot.create(:plant_part) } context 'ordinary member' do - it 'can read plant parts' do + it "can read plant parts" do ability.should be_able_to(:read, plant_part) end it "can't manage plant parts" do @@ -287,15 +92,15 @@ describe Ability do member.roles << role end - it 'can read plant_part details' do + it "can read plant_part details" do ability.should be_able_to(:read, plant_part) end - it 'can manage plant_part details' do + it "can manage plant_part details" do ability.should be_able_to(:create, PlantPart) ability.should be_able_to(:update, plant_part) end - it 'can delete an unused plant part' do + it "can delete an unused plant part" do ability.should be_able_to(:destroy, plant_part) end diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb deleted file mode 100644 index 915750eaa..000000000 --- a/spec/models/account_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'rails_helper' - -describe Account do - let(:member) { FactoryBot.create(:member) } - - it 'auto-creates an account detail record when a member is created' do - member.account.should be_an_instance_of Account - end - - it "won't let you create two account details for the same member" do - @details = Account.new(member_id: member.id) - @details.should_not be_valid - end - - it "formats the 'paid until' date nicely" do - member.account.account_type = FactoryBot.create(:account_type) - member.account.paid_until_string.should eq nil - - member.account.account_type = FactoryBot.create(:permanent_paid_account_type) - member.account.paid_until_string.should eq 'forever' - - member.account.account_type = FactoryBot.create(:paid_account_type) - @time = Time.zone.now - member.account.paid_until = @time - member.account.paid_until_string.should eq @time.to_s - end -end diff --git a/spec/models/account_type_spec.rb b/spec/models/account_type_spec.rb deleted file mode 100644 index c65c113ba..000000000 --- a/spec/models/account_type_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -describe AccountType do -end diff --git a/spec/models/alternate_name_spec.rb b/spec/models/alternate_name_spec.rb index 64e483446..f358a9fca 100644 --- a/spec/models/alternate_name_spec.rb +++ b/spec/models/alternate_name_spec.rb @@ -10,7 +10,7 @@ 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', + name: "really alternative tomato", crop_id: crop.id, creator_id: an.creator.id ) diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 593d0da1b..bc90ee8ba 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -1,28 +1,28 @@ require 'rails_helper' describe Comment do - context 'basic' do + context "basic" do let(:comment) { FactoryBot.create(:comment) } - it 'belongs to a post' do + it "belongs to a post" do comment.post.should be_an_instance_of Post end - it 'belongs to an author' do + it "belongs to an author" do comment.author.should be_an_instance_of Member end end - context 'notifications' do + context "notifications" do let(:comment) { FactoryBot.create(:comment) } - it 'sends a notification when a comment is posted' do + it "sends a notification when a comment is posted" do expect do FactoryBot.create(:comment) end.to change(Notification, :count).by(1) end - it 'sets the notification fields' do + it "sets the notification fields" do @c = FactoryBot.create(:comment) @n = Notification.first @n.sender.should eq @c.author @@ -41,7 +41,7 @@ describe Comment do end end - context 'ordering' do + context "ordering" do before(:each) do @m = FactoryBot.create(:member) @p = FactoryBot.create(:post, author: @m) diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 254573e80..3f49a249d 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -11,8 +11,8 @@ describe Crop do it 'should be fetchable from the database' do crop.save @crop2 = Crop.find_by(name: 'tomato') - @crop2.en_wikipedia_url.should eq('http://en.wikipedia.org/wiki/Tomato') - @crop2.slug.should eq('tomato') + @crop2.en_wikipedia_url.should eq("http://en.wikipedia.org/wiki/Tomato") + @crop2.slug.should eq("tomato") end it 'should stringify as the system name' do @@ -54,7 +54,7 @@ describe Crop do FactoryBot.create_list(:planting, 3, crop: tomato) end - it 'sorts by most plantings' do + it "sorts by most plantings" do Crop.popular.first.should eq maize FactoryBot.create_list(:planting, 10, crop: tomato) Crop.popular.first.should eq tomato @@ -77,7 +77,7 @@ describe Crop do @crop.plantings.size.should eq 1 end - context 'wikipedia url' do + context "wikipedia url" do subject { FactoryBot.build(:tomato, en_wikipedia_url: wikipedia_url) } context 'not a url' do @@ -116,7 +116,7 @@ describe Crop do it { expect(subject).not_to be_valid } end - context 'with script tags in url' do + context "with script tags in url" do let(:wikipedia_url) { 'http://en.wikipedia.org/wiki/SomePage' } it { expect(subject).not_to be_valid } @@ -331,13 +331,13 @@ describe Crop do let(:pp1) { FactoryBot.create(:plant_part) } let(:pp2) { FactoryBot.create(:plant_part) } - context 'harvests' do + context "harvests" do let(:h1) { FactoryBot.create(:harvest, crop: maize, plant_part: pp1) } let(:h2) { FactoryBot.create(:harvest, crop: maize, plant_part: pp2) } let!(:crop) { FactoryBot.create(:crop) } let!(:harvest) { FactoryBot.create(:harvest, crop: crop) } - it 'has harvests' do + it "has harvests" do expect(crop.harvests).to eq [harvest] end end @@ -350,21 +350,21 @@ describe Crop do @maize.plant_parts.should eq [@pp1] end - context 'search', :elasticsearch do + context "search", :elasticsearch do let(:mushroom) { FactoryBot.create(:crop, name: 'mushroom') } before { sync_elasticsearch([mushroom]) } - it 'finds exact matches' do + it "finds exact matches" do Crop.search('mushroom').should eq [mushroom] end - it 'finds approximate matches' do + it "finds approximate matches" do Crop.search('mush').should eq [mushroom] end it "doesn't find non-matches" do Crop.search('mush').should_not include @crop end - it 'searches case insensitively' do + it "searches case insensitively" do Crop.search('mUsH').should include mushroom end it "doesn't find 'rejected' crop" do @@ -379,141 +379,141 @@ describe Crop do end end - context 'csv loading' do + context "csv loading" do before(:each) do # don't use 'let' for this -- we need to actually create it, # regardless of whether it's used. @cropbot = FactoryBot.create(:cropbot) end - context 'scientific names' do - it 'adds a scientific name to a crop that has none' do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Foo bar'] + context "scientific names" do + it "adds a scientific name to a crop that has none" do + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Foo bar"] tomato = CsvImporter.new.import_crop(row) expect(tomato.scientific_names.size).to eq 1 - expect(tomato.default_scientific_name).to eq 'Foo bar' + expect(tomato.default_scientific_name).to eq "Foo bar" end - it 'picks up scientific name from parent crop if available' do + it "picks up scientific name from parent crop if available" do parent = CsvImporter.new.import_crop( - ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Parentis cropis'] + ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Parentis cropis"] ) tomato = CsvImporter.new.import_crop( - ['Tomato', 'http://en.wikipedia.org/wiki/Parent', 'parent'] + ["Tomato", "http://en.wikipedia.org/wiki/Parent", "parent"] ) expect(tomato.parent).to eq parent - expect(tomato.parent.default_scientific_name).to eq 'Parentis cropis' - expect(tomato.default_scientific_name).to eq 'Parentis cropis' + expect(tomato.parent.default_scientific_name).to eq "Parentis cropis" + expect(tomato.default_scientific_name).to eq "Parentis cropis" end it "doesn't add a duplicate scientific name" do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Foo bar, Foo bar'] + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Foo bar, Foo bar"] tomato = CsvImporter.new.import_crop(row) expect(tomato.scientific_names.size).to eq 1 end it "doesn't add a duplicate scientific name from parent" do CsvImporter.new.import_crop( - ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Parentis cropis'] + ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Parentis cropis"] ) tomato = CsvImporter.new.import_crop( - ['Tomato', 'http://en.wikipedia.org/wiki/Parent', 'parent', 'Parentis cropis'] + ["Tomato", "http://en.wikipedia.org/wiki/Parent", "parent", "Parentis cropis"] ) expect(tomato.scientific_names.size).to eq 1 end - it 'loads a crop with multiple scientific names' do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Foo,Bar'] + it "loads a crop with multiple scientific names" do + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Foo,Bar"] tomato = CsvImporter.new.import_crop(row) - expect(tomato.scientific_names[0].name).to eq 'Foo' - expect(tomato.scientific_names[1].name).to eq 'Bar' + expect(tomato.scientific_names[0].name).to eq "Foo" + expect(tomato.scientific_names[1].name).to eq "Bar" end - it 'loads multiple scientific names with variant spacing' do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Baz, Quux'] + it "loads multiple scientific names with variant spacing" do + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Baz, Quux"] tomato = CsvImporter.new.import_crop(row) expect(tomato.scientific_names.size).to eq 2 - expect(tomato.scientific_names[0].name).to eq 'Baz' - expect(tomato.scientific_names[1].name).to eq 'Quux' + expect(tomato.scientific_names[0].name).to eq "Baz" + expect(tomato.scientific_names[1].name).to eq "Quux" end end # scientific names - context 'alternate names' do - it 'loads an alternate name' do - row = ['tomato', 'http://en.wikipedia.org/wiki/Parent', '', '', 'Foo'] + context "alternate names" do + it "loads an alternate name" do + row = ["tomato", "http://en.wikipedia.org/wiki/Parent", "", "", "Foo"] tomato = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 1 - expect(tomato.alternate_names.last.name).to eq 'Foo' + expect(tomato.alternate_names.last.name).to eq "Foo" end - it 'adds multiple alternate names' do - row = ['tomato', 'http://en.wikipedia.org/wiki/Parent', '', '', 'Foo, Bar'] + it "adds multiple alternate names" do + row = ["tomato", "http://en.wikipedia.org/wiki/Parent", "", "", "Foo, Bar"] tomato = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 2 - expect(tomato.alternate_names[0].name).to eq 'Foo' - expect(tomato.alternate_names[1].name).to eq 'Bar' + expect(tomato.alternate_names[0].name).to eq "Foo" + expect(tomato.alternate_names[1].name).to eq "Bar" end - it 'adds multiple alt names with variant spacing' do - row = ['tomato', 'http://en.wikipedia.org/wiki/Parent', '', '', 'Foo,Bar,Baz, Quux'] + it "adds multiple alt names with variant spacing" do + row = ["tomato", "http://en.wikipedia.org/wiki/Parent", "", "", "Foo,Bar,Baz, Quux"] tomato = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 4 - expect(tomato.alternate_names[0].name).to eq 'Foo' - expect(tomato.alternate_names[1].name).to eq 'Bar' - expect(tomato.alternate_names[2].name).to eq 'Baz' - expect(tomato.alternate_names[3].name).to eq 'Quux' + expect(tomato.alternate_names[0].name).to eq "Foo" + expect(tomato.alternate_names[1].name).to eq "Bar" + expect(tomato.alternate_names[2].name).to eq "Baz" + expect(tomato.alternate_names[3].name).to eq "Quux" end - it 'Adds a duplicate alternate name for second crop' do - row = ['tomato', 'http://en.wikipedia.org/wiki/tomato', '', '', 'Foo'] + it "Adds a duplicate alternate name for second crop" do + row = ["tomato", "http://en.wikipedia.org/wiki/tomato", "", "", "Foo"] tomato = CsvImporter.new.import_crop(row) - row = ['tomoto', 'http://en.wikipedia.org/wiki/tomoto', '', '', 'Foo'] + row = ["tomoto", "http://en.wikipedia.org/wiki/tomoto", "", "", "Foo"] tomoto = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 1 expect(tomoto.alternate_names.size).to eq 1 end end # alternate names - it 'loads the simplest possible crop' do - tomato_row = ['tomato', 'http://en.wikipedia.org/wiki/Tomato'] + it "loads the simplest possible crop" do + tomato_row = ["tomato", "http://en.wikipedia.org/wiki/Tomato"] tomato = CsvImporter.new.import_crop(tomato_row) - expect(tomato.name).to eq 'tomato' + expect(tomato.name).to eq "tomato" expect(tomato.en_wikipedia_url).to eq 'http://en.wikipedia.org/wiki/Tomato' expect(tomato.creator).to eq @cropbot end - it 'loads a crop with a scientific name' do - tomato_row = ['tomato', 'http://en.wikipedia.org/wiki/Tomato', '', 'Solanum lycopersicum'] + it "loads a crop with a scientific name" do + tomato_row = ["tomato", "http://en.wikipedia.org/wiki/Tomato", "", "Solanum lycopersicum"] tomato = CsvImporter.new.import_crop(tomato_row) - expect(tomato.name).to eq 'tomato' + expect(tomato.name).to eq "tomato" expect(tomato.scientific_names.size).to eq 1 - expect(tomato.scientific_names.last.name).to eq 'Solanum lycopersicum' + expect(tomato.scientific_names.last.name).to eq "Solanum lycopersicum" end - it 'loads a crop with an alternate name' do + it "loads a crop with an alternate name" do crop = CsvImporter.new.import_crop( - ['tomato', 'http://en.wikipedia.org/wiki/Tomato', nil, nil, 'Foo'] + ["tomato", "http://en.wikipedia.org/wiki/Tomato", nil, nil, "Foo"] ) - expect(crop.name).to eq 'tomato' + expect(crop.name).to eq "tomato" expect(crop.alternate_names.size).to eq 1 - expect(crop.alternate_names.last.name).to eq 'Foo' + expect(crop.alternate_names.last.name).to eq "Foo" end - it 'loads a crop with a parent' do + it "loads a crop with a parent" do parent = FactoryBot.create(:crop, name: 'parent') crop = CsvImporter.new.import_crop( - ['tomato', 'http://en.wikipedia.org/wiki/Tomato', 'parent'] + ["tomato", "http://en.wikipedia.org/wiki/Tomato", "parent"] ) expect(crop.parent).to eq parent end - it 'loads a crop with a missing parent' do - tomato_row = 'tomato,http://en.wikipedia.org/wiki/Tomato,parent' + it "loads a crop with a missing parent" do + tomato_row = "tomato,http://en.wikipedia.org/wiki/Tomato,parent" CSV.parse(tomato_row) do |row| CsvImporter.new.import_crop(row) @@ -524,40 +524,40 @@ describe Crop do end it "doesn't add unnecessary duplicate crops" do - tomato_row = 'tomato,http://en.wikipedia.org/wiki/Tomato,,Solanum lycopersicum' + tomato_row = "tomato,http://en.wikipedia.org/wiki/Tomato,,Solanum lycopersicum" CSV.parse(tomato_row) do |row| CsvImporter.new.import_crop(row) end loaded = Crop.last - expect(loaded.name).to eq 'tomato' + expect(loaded.name).to eq "tomato" expect(loaded.en_wikipedia_url).to eq 'http://en.wikipedia.org/wiki/Tomato' expect(loaded.creator).to eq @cropbot end end - context 'crop-post association' do + context "crop-post association" do let!(:tomato) { FactoryBot.create(:tomato) } let!(:maize) { FactoryBot.create(:maize) } - let!(:post) { FactoryBot.create(:post, body: '[maize](crop)[tomato](crop)[tomato](crop)') } + let!(:post) { FactoryBot.create(:post, body: "[maize](crop)[tomato](crop)[tomato](crop)") } - describe 'destroying a crop' do + describe "destroying a crop" do before do tomato.destroy end - it 'should delete the association between post and the crop(tomato)' do + it "should delete the association between post and the crop(tomato)" do expect(Post.find(post.id).crops).to eq [maize] end - it 'should not delete the posts' do + it "should not delete the posts" do expect(Post.find(post.id)).not_to eq nil end end end - context 'crop rejections' do + context "crop rejections" do let!(:rejected_reason) do FactoryBot.create(:crop, name: 'tomato', approval_status: 'rejected', @@ -570,13 +570,13 @@ describe Crop do rejection_notes: 'blah blah blah') end - describe 'rejecting a crop' do - it 'should give reason if a default option' do - expect(rejected_reason.rejection_explanation).to eq 'not edible' + describe "rejecting a crop" do + it "should give reason if a default option" do + expect(rejected_reason.rejection_explanation).to eq "not edible" end - it 'should show rejection notes if reason was other' do - expect(rejected_other.rejection_explanation).to eq 'blah blah blah' + it "should show rejection notes if reason was other" do + expect(rejected_other.rejection_explanation).to eq "blah blah blah" end end end diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb index 139695a2f..bd61fe2ee 100644 --- a/spec/models/follow_spec.rb +++ b/spec/models/follow_spec.rb @@ -6,34 +6,34 @@ describe Follow do @member2 = FactoryBot.create(:member) end - it 'sends a notification when a follow is created' do + it "sends a notification when a follow is created" do expect do Follow.create(follower_id: @member1.id, followed_id: @member2.id) end.to change(Notification, :count).by(1) end - it 'does not delete any members when follow is deleted' do + it "does not delete any members when follow is deleted" do expect do follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id) follow.destroy end.not_to change(Member, :count) end - context 'when follow is created' do + context "when follow is created" do before(:each) do @follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id) end - it 'should not duplicate follows' do + it "should not duplicate follows" do 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 + it "should list users in following/follower collections when follow is created" do expect(@member1.followed).to include(@member2) expect(@member2.followers).to include(@member1) end - it 'should no longer list users in following/follower collections when follow is deleted' do + it "should no longer list users in following/follower collections when follow is deleted" do @follow.destroy expect(@member1.followed).not_to include(@member2) expect(@member2.followers).not_to include(@member1) diff --git a/spec/models/forum_spec.rb b/spec/models/forum_spec.rb index c0d4d47f5..310c36842 100644 --- a/spec/models/forum_spec.rb +++ b/spec/models/forum_spec.rb @@ -3,11 +3,11 @@ require 'rails_helper' describe Forum do let(:forum) { FactoryBot.create(:forum) } - it 'belongs to an owner' do + it "belongs to an owner" do forum.owner.should be_an_instance_of Member end - it 'stringifies nicely' do + it "stringifies nicely" do forum.to_s.should eq forum.name end @@ -15,7 +15,7 @@ describe Forum do forum.slug.should eq 'permaculture' end - it 'has many posts' do + it "has many posts" do @post1 = FactoryBot.create(:forum_post, forum: forum) @post2 = FactoryBot.create(:forum_post, forum: forum) forum.posts.size.should == 2 diff --git a/spec/models/garden_spec.rb b/spec/models/garden_spec.rb index ec7d5fae2..f8e5a3311 100644 --- a/spec/models/garden_spec.rb +++ b/spec/models/garden_spec.rb @@ -4,12 +4,12 @@ describe Garden do let(:owner) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: owner) } - it 'should have a slug' do + it "should have a slug" do garden.slug.should match(/member\d+-springfield-community-garden/) end - it 'should have a description' do - garden.description.should == 'This is a **totally** cool garden' + it "should have a description" do + garden.description.should == "This is a **totally** cool garden" end it "doesn't allow a nil name" do @@ -18,27 +18,27 @@ describe Garden do end it "doesn't allow a blank name" do - garden = FactoryBot.build(:garden, name: '') + garden = FactoryBot.build(:garden, name: "") garden.should_not be_valid end - it 'allows numbers' do - garden = FactoryBot.build(:garden, name: '100 vines of 2 kamo-kamo') + it "allows numbers" do + garden = FactoryBot.build(:garden, name: "100 vines of 2 kamo-kamo") garden.should_not be_valid end - it 'allows brackets' do - garden = FactoryBot.build(:garden, name: 'Garden (second)') + it "allows brackets" do + garden = FactoryBot.build(:garden, name: "Garden (second)") garden.should be_valid end - it 'allows macrons' do - garden = FactoryBot.build(:garden, name: 'Kūmara and pūha patch') + it "allows macrons" do + garden = FactoryBot.build(:garden, name: "Kūmara and pūha patch") garden.should_not be_valid end it "doesn't allow a name with only spaces" do - garden = FactoryBot.build(:garden, name: ' ') + garden = FactoryBot.build(:garden, name: " ") garden.should_not be_valid end @@ -47,15 +47,15 @@ describe Garden do garden.should_not be_valid end - it 'should have an owner' do + it "should have an owner" do garden.owner.should be_an_instance_of Member end - it 'should stringify as its name' do + it "should stringify as its name" do garden.to_s.should == garden.name end - context 'featured plantings' do + context "featured plantings" do let(:tomato) { FactoryBot.create(:tomato) } let(:maize) { FactoryBot.create(:maize) } let(:chard) { FactoryBot.create(:chard) } @@ -63,14 +63,14 @@ describe Garden do let(:pear) { FactoryBot.create(:pear) } let(:walnut) { FactoryBot.create(:walnut) } - it 'should fetch < 4 featured plantings if insufficient exist' do + it "should fetch < 4 featured plantings if insufficient exist" do @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) garden.featured_plantings.should eq [@p2, @p1] end - it 'should fetch most recent 4 featured plantings' do + it "should fetch most recent 4 featured plantings" do @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) @@ -80,7 +80,7 @@ describe Garden do garden.featured_plantings.should eq [@p5, @p4, @p3, @p2] end - it 'should skip repeated plantings' do + it "should skip repeated plantings" do @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) @@ -93,7 +93,7 @@ describe Garden do end end - it 'destroys plantings when deleted' do + it "destroys plantings when deleted" do garden = FactoryBot.create(:garden, owner: owner) @planting1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) @planting2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) @@ -135,7 +135,7 @@ describe Garden do end it "doesn't allow non-numeric quantities" do - garden = FactoryBot.build(:garden, area: '99a') + garden = FactoryBot.build(:garden, area: "99a") garden.should_not be_valid end end @@ -151,7 +151,7 @@ describe Garden do it 'should refuse invalid unit values' do garden = FactoryBot.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') + 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 @@ -175,7 +175,7 @@ describe Garden do end end - it 'marks plantings as finished when garden is inactive' do + it "marks plantings as finished when garden is inactive" do garden = FactoryBot.create(:garden) p1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) p2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) diff --git a/spec/models/harvest_spec.rb b/spec/models/harvest_spec.rb index da6f06aa8..1944c6365 100644 --- a/spec/models/harvest_spec.rb +++ b/spec/models/harvest_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' describe Harvest do - it 'has an owner' do + it "has an owner" do harvest = FactoryBot.create(:harvest) harvest.owner.should be_an_instance_of Member end - it 'has a crop' do + it "has a crop" do harvest = FactoryBot.create(:harvest) harvest.crop.should be_an_instance_of Crop end @@ -38,7 +38,7 @@ describe Harvest do end it "doesn't allow non-numeric quantities" do - @harvest = FactoryBot.build(:harvest, quantity: '99a') + @harvest = FactoryBot.build(:harvest, quantity: "99a") @harvest.should_not be_valid end end @@ -55,7 +55,7 @@ describe Harvest do it 'should refuse invalid unit values' do @harvest = FactoryBot.build(:harvest, unit: 'not valid') @harvest.should_not be_valid - @harvest.errors[:unit].should include('not valid is not a valid unit') + @harvest.errors[:unit].should include("not valid is not a valid unit") end it 'sets unit to blank if quantity is blank' do @@ -92,7 +92,7 @@ describe Harvest do end it "doesn't allow non-numeric weight quantities" do - @harvest = FactoryBot.build(:harvest, weight_quantity: '99a') + @harvest = FactoryBot.build(:harvest, weight_quantity: "99a") @harvest.should_not be_valid end end @@ -108,7 +108,7 @@ describe Harvest do it 'should refuse invalid weight unit values' do @harvest = FactoryBot.build(:harvest, weight_unit: 'not valid') @harvest.should_not be_valid - @harvest.errors[:weight_unit].should include('not valid is not a valid unit') + @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 @@ -118,21 +118,21 @@ describe Harvest do end end - context 'standardized weights' do + context "standardized weights" do it 'converts from pounds' do - @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: 'lb') + @harvest = FactoryBot.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 = FactoryBot.create(:harvest, weight_quantity: 16, weight_unit: 'oz') + @harvest = FactoryBot.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 = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: 'kg') + @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: "kg") @harvest.should be_valid @harvest.reload.si_weight.should eq 2.0 end @@ -146,79 +146,79 @@ describe Harvest do end end - context 'stringification' do - let(:crop) { FactoryBot.create(:crop, name: 'apricot') } + context "stringification" do + let(:crop) { FactoryBot.create(:crop, name: "apricot") } - it 'apricots' do + it "apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: nil, unit: nil, weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq 'apricots' + @h.to_s.should eq "apricots" end - it '1 individual apricot' do + it "1 individual apricot" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 1, unit: 'individual', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '1 individual apricot' + @h.to_s.should eq "1 individual apricot" end - it '10 individual apricots' do + it "10 individual apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 10, unit: 'individual', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '10 individual apricots' + @h.to_s.should eq "10 individual apricots" end - it '1 bushel of apricots' do + it "1 bushel of apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 1, unit: 'bushel', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '1 bushel of apricots' + @h.to_s.should eq "1 bushel of apricots" end - it '1.5 bushels of apricots' do + it "1.5 bushels of apricots" do @h = FactoryBot.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' + @h.to_s.should eq "1.5 bushels of apricots" end - it '10 bushels of apricots' do + it "10 bushels of apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 10, unit: 'bushel', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '10 bushels of apricots' + @h.to_s.should eq "10 bushels of apricots" end - it 'apricots weighing 1.2 kg' do + it "apricots weighing 1.2 kg" do @h = FactoryBot.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' + @h.to_s.should eq "apricots weighing 1.2 kg" end - it '10 bushels of apricots weighing 100 kg' do + it "10 bushels of apricots weighing 100 kg" do @h = FactoryBot.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' + @h.to_s.should eq "10 bushels of apricots weighing 100 kg" end end diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index 7bdee1fee..01d793ded 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -24,15 +24,6 @@ describe 'member' do member.gardens.size.should == 1 end - it 'should have a accounts entry' do - member.account.should be_an_instance_of Account - end - - it 'should have a default-type account by default' do - member.account.account_type.name.should eq Growstuff::Application.config.default_account_type - member.paid?.should be(false) - end - it "doesn't show email by default" do member.show_email.should be(false) end @@ -48,7 +39,7 @@ describe 'member' do end it 'should be able to fetch gardens' do - member.gardens.first.name.should eq 'Garden' + member.gardens.first.name.should eq "Garden" end it 'has many plantings' do @@ -56,19 +47,19 @@ describe 'member' do member.plantings.size.should eq 1 end - it 'has many comments' do + it "has many comments" do FactoryBot.create(:comment, author: member) FactoryBot.create(:comment, author: member) member.comments.size.should == 2 end - it 'has many forums' do + it "has many forums" do FactoryBot.create(:forum, owner: member) FactoryBot.create(:forum, owner: member) member.forums.size.should == 2 end - it 'has many likes' do + it "has many likes" do @post1 = FactoryBot.create(:post, author: member) @post2 = FactoryBot.create(:post, author: member) @like1 = FactoryBot.create(:like, member: member, likeable: @post1) @@ -118,24 +109,24 @@ describe 'member' do end context 'same :login_name' do - it 'should not allow two members with the same login_name' do - FactoryBot.create(:member, login_name: 'bob') - member = FactoryBot.build(:member, login_name: 'bob') + it "should not allow two members with the same login_name" do + FactoryBot.create(:member, login_name: "bob") + member = FactoryBot.build(:member, login_name: "bob") member.should_not be_valid - member.errors[:login_name].should include('has already been taken') + member.errors[:login_name].should include("has already been taken") end - it 'tests uniqueness case-insensitively' do - FactoryBot.create(:member, login_name: 'bob') - member = FactoryBot.build(:member, login_name: 'BoB') + it "tests uniqueness case-insensitively" do + FactoryBot.create(:member, login_name: "bob") + member = FactoryBot.build(:member, login_name: "BoB") member.should_not be_valid - member.errors[:login_name].should include('has already been taken') + member.errors[:login_name].should include("has already been taken") end end context 'case sensitivity' do it 'preserves case of login name' do - FactoryBot.create(:member, login_name: 'BOB') + FactoryBot.create(:member, login_name: "BOB") Member.find('bob').login_name.should eq 'BOB' end end @@ -144,40 +135,40 @@ describe 'member' do it "doesn't allow short names" do member = FactoryBot.build(:invalid_member_shortname) member.should_not be_valid - member.errors[:login_name].should include('should be between 2 and 25 characters long') + member.errors[:login_name].should include("should be between 2 and 25 characters long") end it "doesn't allow really long names" do member = FactoryBot.build(:invalid_member_longname) member.should_not be_valid - member.errors[:login_name].should include('should be between 2 and 25 characters long') + member.errors[:login_name].should include("should be between 2 and 25 characters long") end it "doesn't allow spaces in names" do member = FactoryBot.build(:invalid_member_spaces) member.should_not be_valid - member.errors[:login_name].should include('may only include letters, numbers, or underscores') + member.errors[:login_name].should include("may only include letters, numbers, or underscores") end it "doesn't allow other chars in names" do member = FactoryBot.build(:invalid_member_badchars) member.should_not be_valid - member.errors[:login_name].should include('may only include letters, numbers, or underscores') + member.errors[:login_name].should include("may only include letters, numbers, or underscores") end it "doesn't allow reserved names" do member = FactoryBot.build(:invalid_member_badname) member.should_not be_valid - member.errors[:login_name].should include('name is reserved') + member.errors[:login_name].should include("name is reserved") end end context 'valid login names' do - it 'allows plain alphanumeric chars in names' do + it "allows plain alphanumeric chars in names" do member = FactoryBot.build(:valid_member_alphanumeric) member.should be_valid end - it 'allows uppercase chars in names' do + it "allows uppercase chars in names" do member = FactoryBot.build(:valid_member_uppercase) member.should be_valid end - it 'allows underscores in names' do + it "allows underscores in names" do member = FactoryBot.build(:valid_member_underscore) member.should be_valid end @@ -203,7 +194,7 @@ describe 'member' do it 'converts role names properly' do # need to make sure spaces get turned to underscores - role = FactoryBot.create(:role, name: 'a b c') + role = FactoryBot.create(:role, name: "a b c") member.roles << role member.role?(:a_b_c).should eq true end @@ -294,89 +285,6 @@ describe 'member' do end end - context 'orders' do - it 'finds the current order' do - member = FactoryBot.create(:member) - FactoryBot.create(:completed_order, member: member) - order2 = FactoryBot.create(:order, member: member) - member.current_order.should eq order2 - end - - it "copes if there's no current order" do - member = FactoryBot.create(:member) - FactoryBot.create(:completed_order, member: member) - FactoryBot.create(:completed_order, member: member) - member.current_order.should be_nil - end - end - - context 'paid accounts' do - let(:member) { FactoryBot.create(:member) } - - it 'recognises a permanent paid account' do - account_type = FactoryBot.create(:account_type, - is_paid: true, is_permanent_paid: true) - member.account.account_type = account_type - member.paid?.should be(true) - end - - it 'recognises a current paid account' do - account_type = FactoryBot.create(:account_type, - is_paid: true, is_permanent_paid: false) - member.account.account_type = account_type - member.account.paid_until = Time.zone.now + 1.month - member.paid?.should be(true) - end - - it 'recognises an expired paid account' do - account_type = FactoryBot.create(:account_type, - is_paid: true, is_permanent_paid: false) - member.account.account_type = account_type - member.account.paid_until = Time.zone.now - 1.minute - member.paid?.should be(false) - end - - it 'recognises a free account' do - account_type = FactoryBot.create(:account_type, - is_paid: false, is_permanent_paid: false) - member.account.account_type = account_type - member.paid?.should be(false) - end - - it 'recognises a free account even with paid_until set' do - account_type = FactoryBot.create(:account_type, - is_paid: false, is_permanent_paid: false) - member.account.account_type = account_type - member.account.paid_until = Time.zone.now + 1.month - member.paid?.should be(false) - end - end - - context 'update account' do - let(:product) do - FactoryBot.create(:product, - paid_months: 3) - end - let(:member) { FactoryBot.create(:member) } - - it 'sets account_type' do - member.update_account_after_purchase(product) - member.account.account_type.should eq product.account_type - end - - it 'sets paid_until' do - member.account.paid_until = nil # blank for now, as if never paid before - member.update_account_after_purchase(product) - - # stringify to avoid millisecond problems... - member.account.paid_until.to_s.should eq((Time.zone.now + 3.months).to_s) - - # and again to make sure it works for currently paid accounts - member.update_account_after_purchase(product) - member.account.paid_until.to_s.should eq((Time.zone.now + 3.months + 3.months).to_s) - end - end - context 'harvests' do it 'has harvests' do member = FactoryBot.create(:member) @@ -417,7 +325,7 @@ describe 'member' do context 'subscriptions' do let(:member) { FactoryBot.create(:member) } - let(:gb) { instance_double('Gibbon::API.new') } + let(:gb) { instance_double("Gibbon::API.new") } it 'subscribes to the newsletter' do expect(gb).to receive_message_chain('lists.subscribe') @@ -444,12 +352,12 @@ describe 'member' do it { expect(Member.interesting).not_to include(member) } it { expect(Member.has_plantings).not_to include(member) } end - it 'unsubscribes from mailing list' do + it "unsubscribes from mailing list" do expect(member).to receive(:newsletter_unsubscribe).and_return(true) member.destroy end - context 'deleted admin member' do + context "deleted admin member" do let(:member) { FactoryBot.create(:admin_member) } before { member.destroy } @@ -457,7 +365,7 @@ describe 'member' do context 'crop creator' do let!(:crop) { FactoryBot.create(:crop, creator: member) } - it 'leaves crops behind, reassigned to cropbot' do + it "leaves crops behind, reassigned to cropbot" do expect(Crop.all).to include(crop) end end @@ -465,7 +373,7 @@ describe 'member' do context 'forum owners' do let!(:forum) { FactoryBot.create(:forum, owner: member) } - it 'leaves forums behind, reassigned to ex_admin' do + it "leaves forums behind, reassigned to ex_admin" do expect(forum.owner).to eq(member) end end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 96d390215..4f04573d5 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -3,19 +3,19 @@ require 'rails_helper' describe Notification do let(:notification) { FactoryBot.create(:notification) } - it 'belongs to a post' do + it "belongs to a post" do notification.post.should be_an_instance_of Post end - it 'belongs to a recipient' do + it "belongs to a recipient" do notification.recipient.should be_an_instance_of Member end - it 'belongs to a sender' do + it "belongs to a sender" do notification.sender.should be_an_instance_of Member end - it 'has a scope for unread' do + it "has a scope for unread" do Notification.unread.should eq [notification] @n2 = FactoryBot.create(:notification, read: true) Notification.unread.should eq [notification] @@ -24,13 +24,13 @@ describe Notification do Notification.unread.should include notification end - it 'counts unread' do + it "counts unread" do @who = notification.recipient @n2 = FactoryBot.create(:notification, recipient: @who, read: false) @who.notifications.unread_count.should eq 2 end - it 'sends email if asked' do + it "sends email if asked" do @notification2 = FactoryBot.create(:notification) @notification2.send_email ActionMailer::Base.deliveries.last.to.should == [@notification2.recipient.email] @@ -42,18 +42,18 @@ describe Notification do ActionMailer::Base.deliveries.last.to.should_not == [notification.recipient.email] end - it 'sends email on creation' do + it "sends email on creation" do @notification2 = FactoryBot.create(:notification) ActionMailer::Base.deliveries.last.to.should == [@notification2.recipient.email] end - it 'replaces missing subjects with (no subject)' do + it "replaces missing subjects with (no subject)" do notification = FactoryBot.create(:notification, subject: nil) - notification.subject.should == '(no subject)' + notification.subject.should == "(no subject)" end - it 'replaces whitespace-only subjects with (no subject)' do - notification = FactoryBot.create(:notification, subject: ' ') - notification.subject.should == '(no subject)' + it "replaces whitespace-only subjects with (no subject)" do + notification = FactoryBot.create(:notification, subject: " ") + notification.subject.should == "(no subject)" end end diff --git a/spec/models/order_item_spec.rb b/spec/models/order_item_spec.rb deleted file mode 100644 index 1d9835d7d..000000000 --- a/spec/models/order_item_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'rails_helper' - -describe OrderItem do - let(:order_item) { FactoryBot.create(:order_item) } - - it 'has an order and a product' do - order_item.order.should be_an_instance_of Order - order_item.product.should be_an_instance_of Product - end - - it 'validates price > product.min_price' do - @product = FactoryBot.create(:product) - order_item = FactoryBot.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 = FactoryBot.create(:product) - @order = FactoryBot.create(:order) - order_item = FactoryBot.build(:order_item, order: @order) - order_item.should be_valid - order_item.save - @order_item2 = FactoryBot.build(:order_item, order: @order) - @order_item2.should_not be_valid - end -end diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb deleted file mode 100644 index 87ae130a9..000000000 --- a/spec/models/order_spec.rb +++ /dev/null @@ -1,133 +0,0 @@ -require 'rails_helper' - -describe Order do - before(:each) do - @order = FactoryBot.create(:order) - @product = FactoryBot.create(:product) - @order_item = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id) - end - - describe '#by_member_id' do - before do - @member1 = FactoryBot.create(:member) - @member2 = FactoryBot.create(:member) - @order1 = Order.create!(member_id: @member1.id) - @order2 = Order.create!(member_id: @member2.id) - end - - it 'only returns orders belonging to member' do - Order.by_member(@member1).should eq [@order1] - end - end - - it 'has order_items' do - @order.order_items.first.should eq @order_item - end - - it 'updates the account details' do - @member = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @account_type = FactoryBot.create(:account_type, name: 'paid') - @product = FactoryBot.create(:product, - account_type: @account_type, - paid_months: 3) - @order_item = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id) - - @member.account.paid_until.should be_nil - - @order.update_account - - @member.account.account_type.should eq @account_type - @member.account.paid_until.should_not be_nil - end - - it 'totals the amount due' do - @member = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @product = FactoryBot.create(:product, - min_price: 1000) - # we force an order to only have one item at present. Add more if wanted - # later. - @order_item1 = FactoryBot.create(:order_item, - 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 = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @product = FactoryBot.create(:product, - min_price: 1000) - # we force an order to only have one item at present. Add more if wanted - # later. - @order_item1 = FactoryBot.create(:order_item, - 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 = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @product = FactoryBot.create(:product, - name: 'foo', - min_price: 1000) - # we force an order to only have one item at present. Add more if wanted - # later. - @order_item1 = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id, price: 1111, quantity: 1) - - @order.activemerchant_items.should eq [{ - name: 'foo', - quantity: 1, - amount: 1111 - }] - end - - context 'referral codes' do - it 'has a referral code' do - referred_order = FactoryBot.create(:referred_order) - referred_order.referral_code.should_not be nil - end - - it 'validates referral codes' do - referred_order = FactoryBot.build(:order, referral_code: 'CAMP_AIGN1?') - referred_order.should_not be_valid - end - - it 'cleans up messy referral codes' do - referred_order = FactoryBot.create(:order, referral_code: 'CaMpAiGn 1 ') - referred_order.referral_code.should eq 'CAMPAIGN1' - end - end - - context 'search' do - it 'finds orders by member' do - order = FactoryBot.create(:order) - Order.search(by: 'member', for: order.member.login_name).should eq [order] - end - - it 'finds orders by order_id' do - order = FactoryBot.create(:order) - Order.search(by: 'order_id', for: order.id).should eq [order] - end - - it 'finds orders by paypal_token' do - order = FactoryBot.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 = FactoryBot.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 = FactoryBot.create(:order, referral_code: 'baz') - Order.search(by: 'referral_code', for: 'baz').should eq [order] - end - end -end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 4400f7d2f..5f07a3e29 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -9,7 +9,7 @@ describe Photo do let(:harvest) { FactoryBot.create(:harvest) } let(:garden) { FactoryBot.create(:garden) } - context 'adds photos' do + context "adds photos" do it 'to a planting' do planting.photos << photo expect(planting.photos.size).to eq 1 @@ -29,7 +29,7 @@ describe Photo do end end - context 'removing photos' do + context "removing photos" do it 'from a planting' do planting.photos << photo photo.destroy @@ -48,7 +48,7 @@ describe Photo do expect(garden.photos.size).to eq 0 end - it 'automatically if unused' do + it "automatically if unused" do photo.destroy_if_unused expect(-> { photo.reload }).to raise_error ActiveRecord::RecordNotFound end diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index 266b75ed7..60a95c245 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -162,11 +162,11 @@ describe Planting do planting.owner.should be_an_instance_of Member end - it 'generates a location' do + it "generates a location" do planting.location.should eq "#{garden_owner.login_name}'s #{garden.name}" end - it 'should have a slug' do + it "should have a slug" do planting.slug.should match(/^member\d+-springfield-community-garden-tomato$/) end @@ -176,15 +176,15 @@ describe Planting do end describe '#planted?' do - it 'should be false for future plantings' do + it "should be false for future plantings" do planting = FactoryBot.create :planting, planted_at: Time.zone.today + 1 expect(planting.planted?).to eq(false) end - it 'should be false for never planted' do + it "should be false for never planted" do planting = FactoryBot.create :planting, planted_at: nil expect(planting.planted?).to eq(false) end - it 'should be true for past plantings' do + it "should be true for past plantings" do planting = FactoryBot.create :planting, planted_at: Time.zone.today - 1 expect(planting.planted?).to eq(true) end @@ -224,7 +224,7 @@ describe Planting do @planting.should_not be_valid end - it 'allows blank quantities' do + it "allows blank quantities" do @planting = FactoryBot.build(:planting, quantity: nil) @planting.should be_valid @planting = FactoryBot.build(:planting, quantity: '') @@ -249,7 +249,7 @@ describe Planting do it 'should refuse invalid sunniness values' do @planting = FactoryBot.build(:planting, sunniness: 'not valid') @planting.should_not be_valid - @planting.errors[:sunniness].should include('not valid is not a valid sunniness value') + @planting.errors[:sunniness].should include("not valid is not a valid sunniness value") end end @@ -271,7 +271,7 @@ describe Planting do it 'should refuse invalid planted_from values' do @planting = FactoryBot.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') + @planting.errors[:planted_from].should include("not valid is not a valid planting method") end end @@ -336,7 +336,7 @@ describe Planting do end end - context 'default arguments' do + context "default arguments" do it 'ignores plantings without photos' do # first, an interesting planting @planting = FactoryBot.create(:planting) @@ -370,8 +370,8 @@ describe Planting do end end - context 'with howmany argument' do - it 'only returns the number asked for' do + context "with howmany argument" do + it "only returns the number asked for" do @plantings = FactoryBot.create_list(:planting, 10) @plantings.each do |p| p.photos << FactoryBot.create(:photo, owner: planting.owner) @@ -381,7 +381,7 @@ describe Planting do end end # interesting plantings - context 'finished' do + context "finished" do it 'has finished fields' do @planting = FactoryBot.create(:finished_planting) @planting.finished.should be true @@ -402,7 +402,7 @@ describe Planting do Planting.current.should_not include @f end - context 'finished date validation' do + context "finished date validation" do it 'requires finished date after planting date' do @f = FactoryBot.build(:finished_planting, planted_at: '2014-01-01', finished_at: '2013-01-01') @f.should_not be_valid diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 4eb8d6ad6..98880ce2b 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -3,33 +3,33 @@ require 'rails_helper' describe Post do let(:member) { FactoryBot.create(:member) } - it_behaves_like 'it is likeable' + it_behaves_like "it is likeable" - it 'should have a slug' do + it "should have a slug" do post = FactoryBot.create(:post, author: member) time = post.created_at - datestr = time.strftime('%Y%m%d') + datestr = time.strftime("%Y%m%d") # 2 digit day and month, full-length years # Counting digits using Math.log is not precise enough! datestr.size.should eq(4 + time.year.to_s.size) post.slug.should eq("#{member.login_name}-#{datestr}-a-post") end - it 'has many comments' do + it "has many comments" do post = FactoryBot.create(:post, author: member) FactoryBot.create(:comment, post: post) FactoryBot.create(:comment, post: post) post.comments.size.should == 2 end - it 'supports counting comments' do + it "supports counting comments" do post = FactoryBot.create(:post, author: member) FactoryBot.create(:comment, post: post) FactoryBot.create(:comment, post: post) post.comment_count.should == 2 end - it 'destroys comments when deleted' do + it "destroys comments when deleted" do post = FactoryBot.create(:post, author: member) FactoryBot.create(:comment, post: post) FactoryBot.create(:comment, post: post) @@ -39,7 +39,7 @@ describe Post do Comment.count.should eq(all - 2) end - it 'belongs to a forum' do + it "belongs to a forum" do post = FactoryBot.create(:forum_post) post.forum.should be_an_instance_of Forum end @@ -50,40 +50,40 @@ describe Post do end it "doesn't allow a blank subject" do - post = FactoryBot.build(:post, subject: '') + post = FactoryBot.build(:post, subject: "") post.should_not be_valid end it "doesn't allow a subject with only spaces" do - post = FactoryBot.build(:post, subject: ' ') + post = FactoryBot.build(:post, subject: " ") post.should_not be_valid end - context 'recent activity' do + context "recent activity" do before do Time.stub(now: Time.now) end let!(:post) { FactoryBot.create(:post, created_at: 1.day.ago) } - it 'sets recent activity to post time' do + 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 + it "sets recent activity to comment time" do comment = FactoryBot.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 + it "shiny new post is recently active" do # create a shiny new post post2 = FactoryBot.create(:post, created_at: 1.minute.ago) Post.recently_active.first.should eq post2 Post.recently_active.second.should eq post end - it 'new comment on old post is recently active' do + it "new comment on old post is recently active" do # now comment on an older post post2 = FactoryBot.create(:post, created_at: 1.minute.ago) FactoryBot.create(:comment, post: post, created_at: 1.second.ago) @@ -92,22 +92,22 @@ describe Post do end end - context 'notifications' do + context "notifications" do let(:member2) { FactoryBot.create(:member) } - it 'sends a notification when a member is mentioned using @-syntax' do + it "sends a notification when a member is mentioned using @-syntax" do expect do FactoryBot.create(:post, author: member, body: "Hey @#{member2}") end.to change(Notification, :count).by(1) end - it 'sends a notification when a member is mentioned using [](member) syntax' do + it "sends a notification when a member is mentioned using [](member) syntax" do expect do FactoryBot.create(:post, author: member, body: "Hey [#{member2}](member)") end.to change(Notification, :count).by(1) end - it 'sets the notification field' do + it "sets the notification field" do p = FactoryBot.create(:post, author: member, body: "Hey @#{member2}") n = Notification.first n.sender.should eq member @@ -116,7 +116,7 @@ describe Post do n.body.should eq p.body end - it 'sends notifications to all members mentioned' do + it "sends notifications to all members mentioned" do member3 = FactoryBot.create(:member) expect do FactoryBot.create(:post, author: member, body: "Hey @#{member2} & @#{member3}") @@ -130,23 +130,23 @@ describe Post do end end - context 'crop-post association' do + context "crop-post association" do let!(:tomato) { FactoryBot.create(:tomato) } let!(:maize) { FactoryBot.create(:maize) } let!(:chard) { FactoryBot.create(:chard) } - let!(:post) { FactoryBot.create(:post, body: '[maize](crop)[tomato](crop)[tomato](crop)') } + let!(:post) { FactoryBot.create(:post, body: "[maize](crop)[tomato](crop)[tomato](crop)") } - it 'should be generated' do + it "should be generated" do expect(tomato.posts).to eq [post] expect(maize.posts).to eq [post] end - it 'should not duplicate' do + it "should not duplicate" do expect(post.crops) =~ [tomato, maize] end - it 'should be updated when post was modified' do - post.update_attributes(body: '[chard](crop)') + it "should be updated when post was modified" do + post.update_attributes(body: "[chard](crop)") expect(post.crops).to eq [chard] expect(chard.posts).to eq [post] @@ -154,17 +154,17 @@ describe Post do expect(maize.posts).to eq [] end - describe 'destroying the post' do + describe "destroying the post" do before do post.destroy end - it 'should delete the association' do + it "should delete the association" do expect(Crop.find(tomato.id).posts).to eq [] expect(Crop.find(maize.id).posts).to eq [] end - it 'should not delete the crops' do + it "should not delete the crops" do expect(Crop.find(tomato.id)).not_to eq nil expect(Crop.find(maize.id)).not_to eq nil end diff --git a/spec/models/product_spec.rb b/spec/models/product_spec.rb deleted file mode 100644 index 1ff0ba516..000000000 --- a/spec/models/product_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'rails_helper' - -describe Product do - it 'stringifies using the name' do - @product = FactoryBot.create(:product) - @product.to_s.should eq @product.name - end -end diff --git a/spec/models/seed_spec.rb b/spec/models/seed_spec.rb index 020e37741..e45d0e240 100644 --- a/spec/models/seed_spec.rb +++ b/spec/models/seed_spec.rb @@ -7,7 +7,7 @@ describe Seed do seed.save.should be(true) end - it 'should have a slug' do + it "should have a slug" do seed.save seed.slug.should match(/member\d+-magic-bean/) end @@ -28,7 +28,7 @@ describe Seed do @seed.should_not be_valid end - it 'allows blank quantities' do + it "allows blank quantities" do @seed = FactoryBot.build(:seed, quantity: nil) @seed.should be_valid @seed = FactoryBot.build(:seed, quantity: '') @@ -48,8 +48,8 @@ describe Seed do @seed = FactoryBot.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' + "You may only trade seed nowhere, locally, "\ + "nationally, or internationally" ) end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index dfced9e4b..e28dd6e24 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,5 +1,5 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' -ENV['RAILS_ENV'] ||= 'test' +ENV["RAILS_ENV"] ||= 'test' require 'simplecov' require 'coveralls' @@ -17,7 +17,7 @@ SimpleCov.start :rails do end require 'spec_helper' -require File.expand_path('../../config/environment', __FILE__) +require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! Rails.application.eager_load! @@ -58,8 +58,8 @@ include Warden::Test::Helpers # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. # -Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } -Dir[Rails.root.join('spec/features/shared_examples/**/*.rb')].each { |f| require f } +Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } +Dir[Rails.root.join("spec/features/shared_examples/**/*.rb")].each { |f| require f } # Checks for pending migrations before tests are run. # If you are not using ActiveRecord, you can remove this line. diff --git a/spec/requests/api/v1/crop_request_spec.rb b/spec/requests/api/v1/crop_request_spec.rb index 936d1a7a6..6a392eb74 100644 --- a/spec/requests/api/v1/crop_request_spec.rb +++ b/spec/requests/api/v1/crop_request_spec.rb @@ -5,53 +5,53 @@ RSpec.describe 'Plantings', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:crop) { FactoryBot.create :crop } let(:crop_encoded_as_json_api) do - { 'id' => crop.id.to_s, - 'type' => 'crops', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'plantings' => plantings_as_json_api, - 'parent' => parent_as_json_api, - 'photos' => photos_as_json_api, - 'harvests' => harvests_as_json_api + { "id" => crop.id.to_s, + "type" => "crops", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "plantings" => plantings_as_json_api, + "parent" => parent_as_json_api, + "photos" => photos_as_json_api, + "harvests" => harvests_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/crops/#{crop.id}" } let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:parent_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/parent", - 'related' => "#{resource_url}/parent" } } + { "links" => + { "self" => "#{resource_url}/relationships/parent", + "related" => "#{resource_url}/parent" } } end let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:attributes) do { - 'name' => crop.name, - 'en-wikipedia-url' => crop.en_wikipedia_url, - 'perennial' => false, - 'median-lifespan' => nil, - 'median-days-to-first-harvest' => nil, - 'median-days-to-last-harvest' => nil + "name" => crop.name, + "en-wikipedia-url" => crop.en_wikipedia_url, + "perennial" => false, + "median-lifespan" => nil, + "median-days-to-first-harvest" => nil, + "median-days-to-last-harvest" => nil } end @@ -63,25 +63,25 @@ RSpec.describe 'Plantings', type: :request do describe '#show' do before { get "/api/v1/crops/#{crop.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('plantings' => plantings_as_json_api) } - it { expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) } - it { expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) } - it { expect(subject['data']['relationships']).to include('parent' => parent_as_json_api) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("parent" => parent_as_json_api) } it { expect(subject['data']).to eq(crop_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/crops', { 'crop' => { 'name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/crops/#{crop.id}", { 'crop' => { 'name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/crops/#{crop.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/gardens_request_spec.rb b/spec/requests/api/v1/gardens_request_spec.rb index 234606bcd..d6005e286 100644 --- a/spec/requests/api/v1/gardens_request_spec.rb +++ b/spec/requests/api/v1/gardens_request_spec.rb @@ -5,36 +5,36 @@ RSpec.describe 'Gardens', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:garden) { FactoryBot.create :garden } let(:garden_encoded_as_json_api) do - { 'id' => garden.id.to_s, - 'type' => 'gardens', - 'links' => { 'self' => resource_url }, - 'attributes' => { 'name' => garden.name }, - 'relationships' => + { "id" => garden.id.to_s, + "type" => "gardens", + "links" => { "self" => resource_url }, + "attributes" => { "name" => garden.name }, + "relationships" => { - 'owner' => owner_as_json_api, - 'plantings' => plantings_as_json_api, - 'photos' => photos_as_json_api + "owner" => owner_as_json_api, + "plantings" => plantings_as_json_api, + "photos" => photos_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/gardens/#{garden.id}" } let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end scenario '#index' do @@ -49,16 +49,16 @@ RSpec.describe 'Gardens', type: :request do scenario '#create' do post '/api/v1/gardens', { 'garden' => { 'name' => 'can i make this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#update' do post "/api/v1/gardens/#{garden.id}", { 'garden' => { 'name' => 'can i modify this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#delete' do delete "/api/v1/gardens/#{garden.id}", {}, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end end diff --git a/spec/requests/api/v1/harvest_request_spec.rb b/spec/requests/api/v1/harvest_request_spec.rb index b685b2990..af2d4201e 100644 --- a/spec/requests/api/v1/harvest_request_spec.rb +++ b/spec/requests/api/v1/harvest_request_spec.rb @@ -5,54 +5,54 @@ RSpec.describe 'Harvests', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:harvest) { FactoryBot.create :harvest } let(:harvest_encoded_as_json_api) do - { 'id' => harvest.id.to_s, - 'type' => 'harvests', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'crop' => crop_as_json_api, - 'planting' => planting_as_json_api, - 'owner' => owner_as_json_api, - 'photos' => photos_as_json_api + { "id" => harvest.id.to_s, + "type" => "harvests", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "crop" => crop_as_json_api, + "planting" => planting_as_json_api, + "owner" => owner_as_json_api, + "photos" => photos_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/harvests/#{harvest.id}" } let(:crop_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/crop", - 'related' => "#{resource_url}/crop" } } + "related" => "#{resource_url}/crop" } } end let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:planting_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/planting", - 'related' => "#{resource_url}/planting" } } + "related" => "#{resource_url}/planting" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:attributes) do { - 'harvested-at' => '2015-09-17', - 'description' => harvest.description, - 'unit' => harvest.unit, - 'weight-quantity' => harvest.weight_quantity.to_s, - 'weight-unit' => harvest.weight_unit, - 'si-weight' => harvest.si_weight + "harvested-at" => "2015-09-17", + "description" => harvest.description, + "unit" => harvest.unit, + "weight-quantity" => harvest.weight_quantity.to_s, + "weight-unit" => harvest.weight_unit, + "si-weight" => harvest.si_weight } end @@ -64,25 +64,25 @@ RSpec.describe 'Harvests', type: :request do describe '#show' do before { get "/api/v1/harvests/#{harvest.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('planting' => planting_as_json_api) } - it { expect(subject['data']['relationships']).to include('crop' => crop_as_json_api) } - it { expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) } - it { expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include("planting" => planting_as_json_api) } + it { expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } it { expect(subject['data']).to eq(harvest_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/harvests', { 'harvest' => { 'description' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/harvests/#{harvest.id}", { 'harvest' => { 'description' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/harvests/#{harvest.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/member_request_spec.rb b/spec/requests/api/v1/member_request_spec.rb index 2e9977132..6067e59b6 100644 --- a/spec/requests/api/v1/member_request_spec.rb +++ b/spec/requests/api/v1/member_request_spec.rb @@ -5,54 +5,54 @@ RSpec.describe 'Members', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:member) { FactoryBot.create :member } let(:member_encoded_as_json_api) do - { 'id' => member.id.to_s, - 'type' => 'members', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'gardens' => gardens_as_json_api, - 'harvests' => harvests_as_json_api, - 'photos' => photos_as_json_api, - 'plantings' => plantings_as_json_api, - 'seeds' => seeds_as_json_api + { "id" => member.id.to_s, + "type" => "members", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "gardens" => gardens_as_json_api, + "harvests" => harvests_as_json_api, + "photos" => photos_as_json_api, + "plantings" => plantings_as_json_api, + "seeds" => seeds_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/members/#{member.id}" } let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:seeds_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/seeds", - 'related' => "#{resource_url}/seeds" } } + { "links" => + { "self" => "#{resource_url}/relationships/seeds", + "related" => "#{resource_url}/seeds" } } end let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:gardens_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/gardens", - 'related' => "#{resource_url}/gardens" } } + { "links" => + { "self" => "#{resource_url}/relationships/gardens", + "related" => "#{resource_url}/gardens" } } end let(:attributes) do { - 'login-name' => member.login_name + "login-name" => member.login_name } end @@ -63,26 +63,26 @@ RSpec.describe 'Members', type: :request do describe '#show' do before { get "/api/v1/members/#{member.id}", {}, headers } - it { expect(subject['data']['relationships']).to include('gardens' => gardens_as_json_api) } - it { expect(subject['data']['relationships']).to include('plantings' => plantings_as_json_api) } - it { expect(subject['data']['relationships']).to include('seeds' => seeds_as_json_api) } - it { expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) } - it { expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("gardens" => gardens_as_json_api) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("seeds" => seeds_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } it { expect(subject['data']).to eq(member_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/members', { 'member' => { 'login_name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/members/#{member.id}", { 'member' => { 'login_name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/members/#{member.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/photos_request_spec.rb b/spec/requests/api/v1/photos_request_spec.rb index 6f5c1434b..e9e584a60 100644 --- a/spec/requests/api/v1/photos_request_spec.rb +++ b/spec/requests/api/v1/photos_request_spec.rb @@ -5,52 +5,52 @@ RSpec.describe 'Photos', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:photo) { FactoryBot.create :photo } let(:photo_encoded_as_json_api) do - { 'id' => photo.id.to_s, - 'type' => 'photos', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'owner' => owner_as_json_api, - 'plantings' => plantings_as_json_api, - 'harvests' => harvests_as_json_api, - 'gardens' => gardens_as_json_api + { "id" => photo.id.to_s, + "type" => "photos", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "owner" => owner_as_json_api, + "plantings" => plantings_as_json_api, + "harvests" => harvests_as_json_api, + "gardens" => gardens_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/photos/#{photo.id}" } let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:gardens_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/gardens", - 'related' => "#{resource_url}/gardens" } } + { "links" => + { "self" => "#{resource_url}/relationships/gardens", + "related" => "#{resource_url}/gardens" } } end let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:attributes) do { - 'thumbnail-url' => photo.thumbnail_url, - 'fullsize-url' => photo.fullsize_url, - 'link-url' => photo.link_url, - 'license-name' => photo.license_name, - 'title' => photo.title + "thumbnail-url" => photo.thumbnail_url, + "fullsize-url" => photo.fullsize_url, + "link-url" => photo.link_url, + "license-name" => photo.license_name, + "title" => photo.title } end @@ -62,24 +62,24 @@ RSpec.describe 'Photos', type: :request do describe '#show' do before { get "/api/v1/photos/#{photo.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('plantings' => plantings_as_json_api) } - it { expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) } - it { expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } it { expect(subject['data']).to eq(photo_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/photos', { 'photo' => { 'name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/photos/#{photo.id}", { 'photo' => { 'name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/photos/#{photo.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/plantings_request_spec.rb b/spec/requests/api/v1/plantings_request_spec.rb index 02a7be3f4..4e96cefb4 100644 --- a/spec/requests/api/v1/plantings_request_spec.rb +++ b/spec/requests/api/v1/plantings_request_spec.rb @@ -5,65 +5,65 @@ RSpec.describe 'Plantings', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:planting) { FactoryBot.create :planting } let(:planting_encoded_as_json_api) do - { 'id' => planting.id.to_s, - 'type' => 'plantings', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'garden' => garden_as_json_api, - 'crop' => crop_as_json_api, - 'owner' => owner_as_json_api, - 'photos' => photos_as_json_api, - 'harvests' => harvests_as_json_api + { "id" => planting.id.to_s, + "type" => "plantings", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "garden" => garden_as_json_api, + "crop" => crop_as_json_api, + "owner" => owner_as_json_api, + "photos" => photos_as_json_api, + "harvests" => harvests_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/plantings/#{planting.id}" } let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:crop_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/crop", - 'related' => "#{resource_url}/crop" } } + "related" => "#{resource_url}/crop" } } end let(:garden_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/garden", - 'related' => "#{resource_url}/garden" } } + { "links" => + { "self" => "#{resource_url}/relationships/garden", + "related" => "#{resource_url}/garden" } } end let(:attributes) do { - 'planted-at' => '2014-07-30', - 'finished-at' => nil, - 'finished' => false, - 'quantity' => 33, - 'description' => planting.description, - 'sunniness' => nil, - 'planted-from' => nil, - 'expected-lifespan' => nil, - 'finish-predicted-at' => nil, - 'percentage-grown' => nil, - 'first-harvest-date' => nil, - 'last-harvest-date' => nil + "planted-at" => "2014-07-30", + "finished-at" => nil, + "finished" => false, + "quantity" => 33, + "description" => planting.description, + "sunniness" => nil, + "planted-from" => nil, + "expected-lifespan" => nil, + "finish-predicted-at" => nil, + "percentage-grown" => nil, + "first-harvest-date" => nil, + "last-harvest-date" => nil } end @@ -74,26 +74,26 @@ RSpec.describe 'Plantings', type: :request do scenario '#show' do get "/api/v1/plantings/#{planting.id}", {}, headers - expect(subject['data']['relationships']).to include('garden' => garden_as_json_api) - expect(subject['data']['relationships']).to include('crop' => crop_as_json_api) - expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) - expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) - expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) + expect(subject['data']['relationships']).to include("garden" => garden_as_json_api) + expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) + expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) + expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) + expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) expect(subject['data']).to eq(planting_encoded_as_json_api) end scenario '#create' do post '/api/v1/plantings', { 'planting' => { 'description' => 'can i make this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#update' do post "/api/v1/plantings/#{planting.id}", { 'planting' => { 'description' => 'can i modify this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#delete' do delete "/api/v1/plantings/#{planting.id}", {}, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end end diff --git a/spec/requests/api/v1/seeds_request_spec.rb b/spec/requests/api/v1/seeds_request_spec.rb index 733ab7e22..f518e91de 100644 --- a/spec/requests/api/v1/seeds_request_spec.rb +++ b/spec/requests/api/v1/seeds_request_spec.rb @@ -5,41 +5,41 @@ RSpec.describe 'Photos', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:seed) { FactoryBot.create :seed } let(:seed_encoded_as_json_api) do - { 'id' => seed.id.to_s, - 'type' => 'seeds', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'owner' => owner_as_json_api, - 'crop' => crop_as_json_api + { "id" => seed.id.to_s, + "type" => "seeds", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "owner" => owner_as_json_api, + "crop" => crop_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/seeds/#{seed.id}" } let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:crop_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/crop", - 'related' => "#{resource_url}/crop" } } + { "links" => + { "self" => "#{resource_url}/relationships/crop", + "related" => "#{resource_url}/crop" } } end let(:attributes) do { - 'description' => seed.description, - 'quantity' => seed.quantity, - 'plant-before' => '2013-07-15', - 'tradable-to' => seed.tradable_to, - 'days-until-maturity-min' => seed.days_until_maturity_min, - 'days-until-maturity-max' => seed.days_until_maturity_max, - 'organic' => seed.organic, - 'gmo' => seed.gmo, - 'heirloom' => seed.heirloom + "description" => seed.description, + "quantity" => seed.quantity, + "plant-before" => "2013-07-15", + "tradable-to" => seed.tradable_to, + "days-until-maturity-min" => seed.days_until_maturity_min, + "days-until-maturity-max" => seed.days_until_maturity_max, + "organic" => seed.organic, + "gmo" => seed.gmo, + "heirloom" => seed.heirloom } end @@ -51,23 +51,23 @@ RSpec.describe 'Photos', type: :request do describe '#show' do before { get "/api/v1/seeds/#{seed.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) } - it { expect(subject['data']['relationships']).to include('crop' => crop_as_json_api) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) } it { expect(subject['data']).to eq(seed_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/seeds', { 'seed' => { 'name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/seeds/#{seed.id}", { 'seed' => { 'name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/seeds/#{seed.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/authentications_spec.rb b/spec/requests/authentications_spec.rb index 45b7754b9..6cc612f44 100644 --- a/spec/requests/authentications_spec.rb +++ b/spec/requests/authentications_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Authentications' do - describe 'GET /authentications' do +describe "Authentications" do + describe "GET /authentications" do end end diff --git a/spec/requests/comments_spec.rb b/spec/requests/comments_spec.rb index 6e5544657..c9b2ba9dc 100644 --- a/spec/requests/comments_spec.rb +++ b/spec/requests/comments_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Comments' do - describe 'GET /comments' do - it 'works! (now write some real specs)' do +describe "Comments" do + describe "GET /comments" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get comments_path response.status.should be(200) diff --git a/spec/requests/forums_spec.rb b/spec/requests/forums_spec.rb index 34a86ea66..ff7cb283d 100644 --- a/spec/requests/forums_spec.rb +++ b/spec/requests/forums_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Forums' do - describe 'GET /forums' do - it 'works! (now write some real specs)' do +describe "Forums" do + describe "GET /forums" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get forums_path response.status.should be(200) diff --git a/spec/requests/gardens_spec.rb b/spec/requests/gardens_spec.rb index 74a9931fb..91a8dc8b7 100644 --- a/spec/requests/gardens_spec.rb +++ b/spec/requests/gardens_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Gardens' do - describe 'GET /gardens' do - it 'works! (now write some real specs)' do +describe "Gardens" do + describe "GET /gardens" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get gardens_path response.status.should be(200) diff --git a/spec/requests/harvests_spec.rb b/spec/requests/harvests_spec.rb index 17785af18..f3774b3c0 100644 --- a/spec/requests/harvests_spec.rb +++ b/spec/requests/harvests_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Harvests' do - describe 'GET /harvests' do - it 'works! (now write some real specs)' do +describe "Harvests" do + describe "GET /harvests" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get harvests_path response.status.should be(200) diff --git a/spec/requests/notifications_spec.rb b/spec/requests/notifications_spec.rb index b5879f678..85afbdd9f 100644 --- a/spec/requests/notifications_spec.rb +++ b/spec/requests/notifications_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Notifications' do - describe 'GET /notifications' do - it 'works! (now write some real specs)' do +describe "Notifications" do + describe "GET /notifications" do + it "works! (now write some real specs)" do get notifications_path # can't see notifications because not logged in # therefore redirect to homepage diff --git a/spec/requests/photos_spec.rb b/spec/requests/photos_spec.rb index a3d39871c..b937ded3d 100644 --- a/spec/requests/photos_spec.rb +++ b/spec/requests/photos_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Photos' do - describe 'GET /photos' do - it 'works! (now write some real specs)' do +describe "Photos" do + describe "GET /photos" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get photos_path response.status.should be(200) diff --git a/spec/requests/plant_parts_spec.rb b/spec/requests/plant_parts_spec.rb index c44e42599..1fc2150b2 100644 --- a/spec/requests/plant_parts_spec.rb +++ b/spec/requests/plant_parts_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'PlantParts' do - describe 'GET /plant_parts' do - it 'works! (now write some real specs)' do +describe "PlantParts" do + describe "GET /plant_parts" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get plant_parts_path response.status.should be(200) diff --git a/spec/requests/plantings_spec.rb b/spec/requests/plantings_spec.rb index e156f9589..cb66922e0 100644 --- a/spec/requests/plantings_spec.rb +++ b/spec/requests/plantings_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Plantings' do - describe 'GET /plantings' do - it 'works! (now write some real specs)' do +describe "Plantings" do + describe "GET /plantings" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get plantings_path response.status.should be(200) diff --git a/spec/requests/post_spec.rb b/spec/requests/post_spec.rb index a2e316c38..3bb479aa8 100644 --- a/spec/requests/post_spec.rb +++ b/spec/requests/post_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Posts' do - describe 'GET /posts' do - it 'works! (now write some real specs)' do +describe "Posts" do + describe "GET /posts" do + it "works! (now write some real specs)" do get posts_path response.status.should be(200) end diff --git a/spec/requests/scientific_names_spec.rb b/spec/requests/scientific_names_spec.rb index 02785b4ad..922f6f270 100644 --- a/spec/requests/scientific_names_spec.rb +++ b/spec/requests/scientific_names_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'ScientificNames' do - describe 'GET /scientific_names' do - it 'works! (now write some real specs)' do +describe "ScientificNames" do + describe "GET /scientific_names" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get scientific_names_path response.status.should be(200) diff --git a/spec/requests/seeds_spec.rb b/spec/requests/seeds_spec.rb index 08d3c0f18..8bc5aeccf 100644 --- a/spec/requests/seeds_spec.rb +++ b/spec/requests/seeds_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Seeds' do - describe 'GET /seeds' do - it 'works! (now write some real specs)' do +describe "Seeds" do + describe "GET /seeds" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get seeds_path response.status.should be(200) diff --git a/spec/routing/account_types_routing_spec.rb b/spec/routing/account_types_routing_spec.rb deleted file mode 100644 index 53ed9b4a3..000000000 --- a/spec/routing/account_types_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'rails_helper' - -describe AccountTypesController do - describe 'routing' do - it 'routes to #index' do - get('/account_types').should route_to('account_types#index') - end - - it 'routes to #new' do - get('/account_types/new').should route_to('account_types#new') - end - - it 'routes to #show' do - 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') - end - - it 'routes to #create' do - post('/account_types').should route_to('account_types#create') - end - - it 'routes to #update' do - 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') - end - end -end diff --git a/spec/routing/authentications_routing_spec.rb b/spec/routing/authentications_routing_spec.rb index 39d814011..0601b9924 100644 --- a/spec/routing/authentications_routing_spec.rb +++ b/spec/routing/authentications_routing_spec.rb @@ -1,13 +1,13 @@ -require 'rails_helper' +require "rails_helper" describe AuthenticationsController do - describe 'routing' do - it 'routes to #create' do - post('/authentications').should route_to('authentications#create') + describe "routing" do + it "routes to #create" do + post("/authentications").should route_to("authentications#create") end - it 'routes to #destroy' do - delete('/authentications/1').should route_to('authentications#destroy', id: '1') + it "routes to #destroy" do + delete("/authentications/1").should route_to("authentications#destroy", id: "1") end end end diff --git a/spec/routing/comments_routing_spec.rb b/spec/routing/comments_routing_spec.rb index 8f9363dcc..5390ab066 100644 --- a/spec/routing/comments_routing_spec.rb +++ b/spec/routing/comments_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe CommentsController do - describe 'routing' do - it 'routes to #index' do - get('/comments').should route_to('comments#index') + describe "routing" do + it "routes to #index" do + get("/comments").should route_to("comments#index") end - it 'routes to #new' do - get('/comments/new').should route_to('comments#new') + it "routes to #new" do + get("/comments/new").should route_to("comments#new") end - it 'routes to #show' do - get('/comments/1').should route_to('comments#show', id: '1') + it "routes to #show" do + 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') + it "routes to #edit" do + get("/comments/1/edit").should route_to("comments#edit", id: "1") end - it 'routes to #create' do - post('/comments').should route_to('comments#create') + it "routes to #create" do + post("/comments").should route_to("comments#create") end - it 'routes to #update' do - put('/comments/1').should route_to('comments#update', id: '1') + it "routes to #update" do + 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') + it "routes to #destroy" do + delete("/comments/1").should route_to("comments#destroy", id: "1") end end end diff --git a/spec/routing/crops_routing_spec.rb b/spec/routing/crops_routing_spec.rb index 644bad3d6..97c1a874c 100644 --- a/spec/routing/crops_routing_spec.rb +++ b/spec/routing/crops_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe CropsController do - describe 'routing' do - it 'routes to #index' do - get('/crops').should route_to('crops#index') + describe "routing" do + it "routes to #index" do + get("/crops").should route_to("crops#index") end - it 'routes to #new' do - get('/crops/new').should route_to('crops#new') + it "routes to #new" do + get("/crops/new").should route_to("crops#new") end - it 'routes to #show' do - get('/crops/1').should route_to('crops#show', id: '1') + it "routes to #show" do + 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') + it "routes to #edit" do + get("/crops/1/edit").should route_to("crops#edit", id: "1") end - it 'routes to #create' do - post('/crops').should route_to('crops#create') + it "routes to #create" do + post("/crops").should route_to("crops#create") end - it 'routes to #update' do - put('/crops/1').should route_to('crops#update', id: '1') + it "routes to #update" do + 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') + it "routes to #destroy" do + delete("/crops/1").should route_to("crops#destroy", id: "1") end end end diff --git a/spec/routing/follows_routing_spec.rb b/spec/routing/follows_routing_spec.rb index 06aaa6b76..ddb01e00c 100644 --- a/spec/routing/follows_routing_spec.rb +++ b/spec/routing/follows_routing_spec.rb @@ -1,13 +1,13 @@ -require 'spec_helper' +require "spec_helper" describe FollowsController do - describe 'routing' do - it 'routes to #create' do - post('/follows').should route_to('follows#create') + describe "routing" do + it "routes to #create" do + post("/follows").should route_to("follows#create") end - it 'routes to #destroy' do - delete('/follows/1').should route_to('follows#destroy', id: '1') + it "routes to #destroy" do + delete("/follows/1").should route_to("follows#destroy", id: "1") end end end diff --git a/spec/routing/forums_routing_spec.rb b/spec/routing/forums_routing_spec.rb index ca229917f..9ce6f427b 100644 --- a/spec/routing/forums_routing_spec.rb +++ b/spec/routing/forums_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe ForumsController do - describe 'routing' do - it 'routes to #index' do - get('/forums').should route_to('forums#index') + describe "routing" do + it "routes to #index" do + get("/forums").should route_to("forums#index") end - it 'routes to #new' do - get('/forums/new').should route_to('forums#new') + it "routes to #new" do + get("/forums/new").should route_to("forums#new") end - it 'routes to #show' do - get('/forums/1').should route_to('forums#show', id: '1') + it "routes to #show" do + 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') + it "routes to #edit" do + get("/forums/1/edit").should route_to("forums#edit", id: "1") end - it 'routes to #create' do - post('/forums').should route_to('forums#create') + it "routes to #create" do + post("/forums").should route_to("forums#create") end - it 'routes to #update' do - put('/forums/1').should route_to('forums#update', id: '1') + it "routes to #update" do + 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') + it "routes to #destroy" do + delete("/forums/1").should route_to("forums#destroy", id: "1") end end end diff --git a/spec/routing/gardens_routing_spec.rb b/spec/routing/gardens_routing_spec.rb index 8ec871b3b..6888f099f 100644 --- a/spec/routing/gardens_routing_spec.rb +++ b/spec/routing/gardens_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe GardensController do - describe 'routing' do - it 'routes to #index' do - get('/gardens').should route_to('gardens#index') + describe "routing" do + it "routes to #index" do + get("/gardens").should route_to("gardens#index") end - it 'routes to #new' do - get('/gardens/new').should route_to('gardens#new') + it "routes to #new" do + get("/gardens/new").should route_to("gardens#new") end - it 'routes to #show' do - get('/gardens/1').should route_to('gardens#show', id: '1') + it "routes to #show" do + 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') + it "routes to #edit" do + get("/gardens/1/edit").should route_to("gardens#edit", id: "1") end - it 'routes to #create' do - post('/gardens').should route_to('gardens#create') + it "routes to #create" do + post("/gardens").should route_to("gardens#create") end - it 'routes to #update' do - put('/gardens/1').should route_to('gardens#update', id: '1') + it "routes to #update" do + 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') + it "routes to #destroy" do + delete("/gardens/1").should route_to("gardens#destroy", id: "1") end end end diff --git a/spec/routing/harvests_routing_spec.rb b/spec/routing/harvests_routing_spec.rb index 41ad0c187..c6890df15 100644 --- a/spec/routing/harvests_routing_spec.rb +++ b/spec/routing/harvests_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe HarvestsController do - describe 'routing' do - it 'routes to #index' do - get('/harvests').should route_to('harvests#index') + describe "routing" do + it "routes to #index" do + get("/harvests").should route_to("harvests#index") end - it 'routes to #new' do - get('/harvests/new').should route_to('harvests#new') + it "routes to #new" do + get("/harvests/new").should route_to("harvests#new") end - it 'routes to #show' do - get('/harvests/1').should route_to('harvests#show', id: '1') + it "routes to #show" do + 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') + it "routes to #edit" do + get("/harvests/1/edit").should route_to("harvests#edit", id: "1") end - it 'routes to #create' do - post('/harvests').should route_to('harvests#create') + it "routes to #create" do + post("/harvests").should route_to("harvests#create") end - it 'routes to #update' do - put('/harvests/1').should route_to('harvests#update', id: '1') + it "routes to #update" do + 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') + it "routes to #destroy" do + delete("/harvests/1").should route_to("harvests#destroy", id: "1") end end end diff --git a/spec/routing/notifications_routing_spec.rb b/spec/routing/notifications_routing_spec.rb index 8b0628575..bb7335e1b 100644 --- a/spec/routing/notifications_routing_spec.rb +++ b/spec/routing/notifications_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe NotificationsController do - describe 'routing' do - it 'routes to #index' do - get('/notifications').should route_to('notifications#index') + describe "routing" do + it "routes to #index" do + get("/notifications").should route_to("notifications#index") end - it 'routes to #new' do - get('/notifications/new').should route_to('notifications#new') + it "routes to #new" do + get("/notifications/new").should route_to("notifications#new") end - it 'routes to #show' do - get('/notifications/1').should route_to('notifications#show', id: '1') + it "routes to #show" do + 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') + it "routes to #edit" do + get("/notifications/1/edit").should route_to("notifications#edit", id: "1") end - it 'routes to #create' do - post('/notifications').should route_to('notifications#create') + it "routes to #create" do + post("/notifications").should route_to("notifications#create") end - it 'routes to #update' do - put('/notifications/1').should route_to('notifications#update', id: '1') + it "routes to #update" do + 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') + it "routes to #destroy" do + delete("/notifications/1").should route_to("notifications#destroy", id: "1") end end end diff --git a/spec/routing/order_items_routing_spec.rb b/spec/routing/order_items_routing_spec.rb deleted file mode 100644 index 095842d7f..000000000 --- a/spec/routing/order_items_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'rails_helper' - -describe OrderItemsController do - describe 'routing' do - it 'routes to #index' do - get('/order_items').should route_to('order_items#index') - end - - it 'routes to #new' do - get('/order_items/new').should route_to('order_items#new') - end - - it 'routes to #show' do - 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') - end - - it 'routes to #create' do - post('/order_items').should route_to('order_items#create') - end - - it 'routes to #update' do - 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') - end - end -end diff --git a/spec/routing/orders_routing_spec.rb b/spec/routing/orders_routing_spec.rb deleted file mode 100644 index 4c7d925c5..000000000 --- a/spec/routing/orders_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'rails_helper' - -describe OrdersController do - describe 'routing' do - it 'routes to #index' do - get('/orders').should route_to('orders#index') - end - - it 'routes to #new' do - get('/orders/new').should route_to('orders#new') - end - - it 'routes to #show' do - 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') - end - - it 'routes to #create' do - post('/orders').should route_to('orders#create') - end - - it 'routes to #update' do - 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') - end - end -end diff --git a/spec/routing/photos_routing_spec.rb b/spec/routing/photos_routing_spec.rb index 1337de4b2..a645d0a60 100644 --- a/spec/routing/photos_routing_spec.rb +++ b/spec/routing/photos_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PhotosController do - describe 'routing' do - it 'routes to #index' do - get('/photos').should route_to('photos#index') + describe "routing" do + it "routes to #index" do + get("/photos").should route_to("photos#index") end - it 'routes to #new' do - get('/photos/new').should route_to('photos#new') + it "routes to #new" do + get("/photos/new").should route_to("photos#new") end - it 'routes to #show' do - get('/photos/1').should route_to('photos#show', id: '1') + it "routes to #show" do + 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') + it "routes to #edit" do + get("/photos/1/edit").should route_to("photos#edit", id: "1") end - it 'routes to #create' do - post('/photos').should route_to('photos#create') + it "routes to #create" do + post("/photos").should route_to("photos#create") end - it 'routes to #update' do - put('/photos/1').should route_to('photos#update', id: '1') + it "routes to #update" do + 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') + it "routes to #destroy" do + delete("/photos/1").should route_to("photos#destroy", id: "1") end end end diff --git a/spec/routing/plant_parts_routing_spec.rb b/spec/routing/plant_parts_routing_spec.rb index 2a00948bc..966047f3f 100644 --- a/spec/routing/plant_parts_routing_spec.rb +++ b/spec/routing/plant_parts_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PlantPartsController do - describe 'routing' do - it 'routes to #index' do - get('/plant_parts').should route_to('plant_parts#index') + describe "routing" do + it "routes to #index" do + get("/plant_parts").should route_to("plant_parts#index") end - it 'routes to #new' do - get('/plant_parts/new').should route_to('plant_parts#new') + it "routes to #new" do + get("/plant_parts/new").should route_to("plant_parts#new") end - it 'routes to #show' do - get('/plant_parts/1').should route_to('plant_parts#show', id: '1') + it "routes to #show" do + 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') + it "routes to #edit" do + get("/plant_parts/1/edit").should route_to("plant_parts#edit", id: "1") end - it 'routes to #create' do - post('/plant_parts').should route_to('plant_parts#create') + it "routes to #create" do + post("/plant_parts").should route_to("plant_parts#create") end - it 'routes to #update' do - put('/plant_parts/1').should route_to('plant_parts#update', id: '1') + it "routes to #update" do + 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') + it "routes to #destroy" do + delete("/plant_parts/1").should route_to("plant_parts#destroy", id: "1") end end end diff --git a/spec/routing/plantings_routing_spec.rb b/spec/routing/plantings_routing_spec.rb index 4098d7703..473fe827e 100644 --- a/spec/routing/plantings_routing_spec.rb +++ b/spec/routing/plantings_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PlantingsController do - describe 'routing' do - it 'routes to #index' do - get('/plantings').should route_to('plantings#index') + describe "routing" do + it "routes to #index" do + get("/plantings").should route_to("plantings#index") end - it 'routes to #new' do - get('/plantings/new').should route_to('plantings#new') + it "routes to #new" do + get("/plantings/new").should route_to("plantings#new") end - it 'routes to #show' do - get('/plantings/1').should route_to('plantings#show', id: '1') + it "routes to #show" do + 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') + it "routes to #edit" do + get("/plantings/1/edit").should route_to("plantings#edit", id: "1") end - it 'routes to #create' do - post('/plantings').should route_to('plantings#create') + it "routes to #create" do + post("/plantings").should route_to("plantings#create") end - it 'routes to #update' do - put('/plantings/1').should route_to('plantings#update', id: '1') + it "routes to #update" do + 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') + it "routes to #destroy" do + delete("/plantings/1").should route_to("plantings#destroy", id: "1") end end end diff --git a/spec/routing/products_routing_spec.rb b/spec/routing/products_routing_spec.rb deleted file mode 100644 index c19642a21..000000000 --- a/spec/routing/products_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'rails_helper' - -describe ProductsController do - describe 'routing' do - it 'routes to #index' do - get('/products').should route_to('products#index') - end - - it 'routes to #new' do - get('/products/new').should route_to('products#new') - end - - it 'routes to #show' do - 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') - end - - it 'routes to #create' do - post('/products').should route_to('products#create') - end - - it 'routes to #update' do - 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') - end - end -end diff --git a/spec/routing/roles_routing_spec.rb b/spec/routing/roles_routing_spec.rb index 589c40dd8..7b6469efb 100644 --- a/spec/routing/roles_routing_spec.rb +++ b/spec/routing/roles_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe RolesController do - describe 'routing' do - it 'routes to #index' do - get('/roles').should route_to('roles#index') + describe "routing" do + it "routes to #index" do + get("/roles").should route_to("roles#index") end - it 'routes to #new' do - get('/roles/new').should route_to('roles#new') + it "routes to #new" do + get("/roles/new").should route_to("roles#new") end - it 'routes to #show' do - get('/roles/1').should route_to('roles#show', id: '1') + it "routes to #show" do + 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') + it "routes to #edit" do + get("/roles/1/edit").should route_to("roles#edit", id: "1") end - it 'routes to #create' do - post('/roles').should route_to('roles#create') + it "routes to #create" do + post("/roles").should route_to("roles#create") end - it 'routes to #update' do - put('/roles/1').should route_to('roles#update', id: '1') + it "routes to #update" do + 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') + it "routes to #destroy" do + delete("/roles/1").should route_to("roles#destroy", id: "1") end end end diff --git a/spec/routing/scientific_names_routing_spec.rb b/spec/routing/scientific_names_routing_spec.rb index 5020404ea..7bbbfa764 100644 --- a/spec/routing/scientific_names_routing_spec.rb +++ b/spec/routing/scientific_names_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe ScientificNamesController do - describe 'routing' do - it 'routes to #index' do - get('/scientific_names').should route_to('scientific_names#index') + describe "routing" do + it "routes to #index" do + get("/scientific_names").should route_to("scientific_names#index") end - it 'routes to #new' do - get('/scientific_names/new').should route_to('scientific_names#new') + it "routes to #new" do + get("/scientific_names/new").should route_to("scientific_names#new") end - it 'routes to #show' do - get('/scientific_names/1').should route_to('scientific_names#show', id: '1') + it "routes to #show" do + 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') + it "routes to #edit" do + get("/scientific_names/1/edit").should route_to("scientific_names#edit", id: "1") end - it 'routes to #create' do - post('/scientific_names').should route_to('scientific_names#create') + it "routes to #create" do + post("/scientific_names").should route_to("scientific_names#create") end - it 'routes to #update' do - put('/scientific_names/1').should route_to('scientific_names#update', id: '1') + it "routes to #update" do + 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') + it "routes to #destroy" do + delete("/scientific_names/1").should route_to("scientific_names#destroy", id: "1") end end end diff --git a/spec/routing/seeds_routing_spec.rb b/spec/routing/seeds_routing_spec.rb index ad8615cc4..74f4aff64 100644 --- a/spec/routing/seeds_routing_spec.rb +++ b/spec/routing/seeds_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe SeedsController do - describe 'routing' do - it 'routes to #index' do - get('/seeds').should route_to('seeds#index') + describe "routing" do + it "routes to #index" do + get("/seeds").should route_to("seeds#index") end - it 'routes to #new' do - get('/seeds/new').should route_to('seeds#new') + it "routes to #new" do + get("/seeds/new").should route_to("seeds#new") end - it 'routes to #show' do - get('/seeds/1').should route_to('seeds#show', id: '1') + it "routes to #show" do + 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') + it "routes to #edit" do + get("/seeds/1/edit").should route_to("seeds#edit", id: "1") end - it 'routes to #create' do - post('/seeds').should route_to('seeds#create') + it "routes to #create" do + post("/seeds").should route_to("seeds#create") end - it 'routes to #update' do - put('/seeds/1').should route_to('seeds#update', id: '1') + it "routes to #update" do + 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') + it "routes to #destroy" do + delete("/seeds/1").should route_to("seeds#destroy", id: "1") end end end diff --git a/spec/routing/updates_routing_spec.rb b/spec/routing/updates_routing_spec.rb index 1b3c8ea59..966647515 100644 --- a/spec/routing/updates_routing_spec.rb +++ b/spec/routing/updates_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PostsController do - describe 'routing' do - it 'routes to #index' do - get('/posts').should route_to('posts#index') + describe "routing" do + it "routes to #index" do + get("/posts").should route_to("posts#index") end - it 'routes to #new' do - get('/posts/new').should route_to('posts#new') + it "routes to #new" do + get("/posts/new").should route_to("posts#new") end - it 'routes to #show' do - get('/posts/1').should route_to('posts#show', id: '1') + it "routes to #show" do + 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') + it "routes to #edit" do + get("/posts/1/edit").should route_to("posts#edit", id: "1") end - it 'routes to #create' do - post('/posts').should route_to('posts#create') + it "routes to #create" do + post("/posts").should route_to("posts#create") end - it 'routes to #update' do - put('/posts/1').should route_to('posts#update', id: '1') + it "routes to #update" do + 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') + it "routes to #destroy" do + delete("/posts/1").should route_to("posts#destroy", id: "1") end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 300bca74d..9a0b542df 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -87,5 +87,5 @@ RSpec.configure do |config| Kernel.srand config.seed # Remember which tests failed, so you can run rspec with the `--only-failures` flag. - config.example_status_persistence_file_path = 'tmp/examples.txt' + config.example_status_persistence_file_path = "tmp/examples.txt" end diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb index b8236e95f..354c64069 100644 --- a/spec/support/controller_macros.rb +++ b/spec/support/controller_macros.rb @@ -3,7 +3,7 @@ module ControllerMacros def login_member(member_factory = :member) let(:member) { FactoryBot.create(member_factory || :member) } before(:each) do - @request.env['devise.mapping'] = Devise.mappings[:member] + @request.env["devise.mapping"] = Devise.mappings[:member] sign_in member end end diff --git a/spec/support/elasticsearch_helpers.rb b/spec/support/elasticsearch_helpers.rb index 5b73b5b0c..aaa4fd689 100644 --- a/spec/support/elasticsearch_helpers.rb +++ b/spec/support/elasticsearch_helpers.rb @@ -1,6 +1,6 @@ module ElasticsearchHelpers def sync_elasticsearch(crops) - return unless ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' + return unless ENV['GROWSTUFF_ELASTICSEARCH'] == "true" crops.each { |crop| crop.__elasticsearch__.index_document } Crop.__elasticsearch__.refresh_index! end @@ -10,6 +10,6 @@ RSpec.configure do |config| config.include ElasticsearchHelpers config.before(:all, elasticsearch: true) do - Crop.__elasticsearch__.create_index! force: true if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' + Crop.__elasticsearch__.create_index! force: true if ENV['GROWSTUFF_ELASTICSEARCH'] == "true" end end diff --git a/spec/support/is_likeable.rb b/spec/support/is_likeable.rb index fb24eaa02..e1a590b30 100644 --- a/spec/support/is_likeable.rb +++ b/spec/support/is_likeable.rb @@ -1,4 +1,4 @@ -shared_examples 'it is likeable' do +shared_examples "it is likeable" do before(:each) do # Possibly a horrible hack. # Will fail if factory name does not match the model name.. @@ -9,7 +9,7 @@ shared_examples 'it is likeable' do @like2 = FactoryBot.create(:like, member: @member2, likeable: @likeable) end - it 'has many likes' do + it "has many likes" do expect(@likeable.likes.length).to eq 2 end diff --git a/spec/views/account_types/edit.html.haml_spec.rb b/spec/views/account_types/edit.html.haml_spec.rb deleted file mode 100644 index e8f934358..000000000 --- a/spec/views/account_types/edit.html.haml_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -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)) - end - - it 'renders the edit account_type form' 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]' - 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 deleted file mode 100644 index 94f19d072..000000000 --- a/spec/views/account_types/index.html.haml_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'rails_helper' - -describe 'account_types/index' do - before(:each) do - @type = FactoryBot.create(:account_type) - assign(:account_types, [@type, @type]) - end - - 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 - end -end diff --git a/spec/views/account_types/new.html.haml_spec.rb b/spec/views/account_types/new.html.haml_spec.rb deleted file mode 100644 index db7cec061..000000000 --- a/spec/views/account_types/new.html.haml_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -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).as_new_record) - end - - it 'renders new account_type form' 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]' - 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 deleted file mode 100644 index 6bb888f1a..000000000 --- a/spec/views/account_types/show.html.haml_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -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)) - end - - it 'renders attributes in

' do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should match(/Name/) - rendered.should match(/false/) - rendered.should match(/false/) - end -end diff --git a/spec/views/accounts/edit.html.haml_spec.rb b/spec/views/accounts/edit.html.haml_spec.rb deleted file mode 100644 index d77edd8c8..000000000 --- a/spec/views/accounts/edit.html.haml_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -describe 'accounts/edit' do - before(:each) do - @member = FactoryBot.create(:member) - @account = assign(:account, @member.account) - end - - it 'renders the edit account form' 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]' - end - end -end diff --git a/spec/views/accounts/index.html.haml_spec.rb b/spec/views/accounts/index.html.haml_spec.rb deleted file mode 100644 index 7e54347fb..000000000 --- a/spec/views/accounts/index.html.haml_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -describe 'accounts/index' do - before(:each) do - @member = FactoryBot.create(:member) - @account = @member.account - assign(:accounts, [@account, @account]) - end - - 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 - end -end diff --git a/spec/views/accounts/new.html.haml_spec.rb b/spec/views/accounts/new.html.haml_spec.rb deleted file mode 100644 index 5bc6ba812..000000000 --- a/spec/views/accounts/new.html.haml_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -describe 'accounts/new' do - before(:each) do - @member = FactoryBot.create(:member) - assign(:account, @member.account) - end - - it 'renders new account form' 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]' - end - end -end diff --git a/spec/views/accounts/show.html.haml_spec.rb b/spec/views/accounts/show.html.haml_spec.rb deleted file mode 100644 index b852b12d1..000000000 --- a/spec/views/accounts/show.html.haml_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'rails_helper' - -describe 'accounts/show' do - before(:each) do - @member = FactoryBot.create(:member) - @account = assign(:account, @member.account) - end - - it 'renders attributes in

' do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should have_content @account.member_id.to_s - rendered.should have_content 'Free' - rendered.should have_content @account.paid_until.to_s - end -end diff --git a/spec/views/admin/index_spec.rb b/spec/views/admin/index_spec.rb index 442a0c36c..cc8b145d3 100644 --- a/spec/views/admin/index_spec.rb +++ b/spec/views/admin/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'admin/index.html.haml', type: 'view' do +describe 'admin/index.html.haml', type: "view" do before(:each) do @member = FactoryBot.create(:admin_member) sign_in @member @@ -8,14 +8,12 @@ describe 'admin/index.html.haml', type: 'view' do render 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 + it "includes links to manage various things" do + assert_select "a", href: roles_path + assert_select "a", href: forums_path end - it 'has a link to newsletter subscribers' do - rendered.should have_content 'Newsletter subscribers' + it "has a link to newsletter subscribers" do + rendered.should have_content "Newsletter subscribers" end end diff --git a/spec/views/admin/newsletter_spec.rb b/spec/views/admin/newsletter_spec.rb index 8faca4e18..384833034 100644 --- a/spec/views/admin/newsletter_spec.rb +++ b/spec/views/admin/newsletter_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'admin/newsletter.html.haml', type: 'view' do +describe 'admin/newsletter.html.haml', type: "view" do before(:each) do @member = FactoryBot.create(:admin_member) sign_in @member @@ -10,7 +10,7 @@ describe 'admin/newsletter.html.haml', type: 'view' do render end - it 'lists newsletter subscribers by email' do + it "lists newsletter subscribers by email" do rendered.should have_content @subscriber.email end end diff --git a/spec/views/admin/orders/index_spec.rb b/spec/views/admin/orders/index_spec.rb deleted file mode 100644 index 905b6a3ff..000000000 --- a/spec/views/admin/orders/index_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'rails_helper' - -describe 'admin/orders/index.html.haml', type: 'view' do - before(:each) do - @member = FactoryBot.create(:admin_member) - sign_in @member - controller.stub(:current_user) { @member } - render - end - - it 'includes a search form for orders' do - assert_select 'form' - assert_select 'input#search_text' - assert_select 'select#search_by' - end - - it 'lets you search by referral code' do - 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 41a46858d..2ef7d480f 100644 --- a/spec/views/comments/edit.html.haml_spec.rb +++ b/spec/views/comments/edit.html.haml_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe 'comments/edit' do +describe "comments/edit" do before(:each) do controller.stub(:current_user) { nil } assign(:comment, FactoryBot.create(:comment)) end - it 'renders the edit comment form' do + it "renders the edit comment form" 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 3677782e2..91ed15a88 100644 --- a/spec/views/comments/index.html.haml_spec.rb +++ b/spec/views/comments/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'comments/index' do +describe "comments/index" do before(:each) do controller.stub(:current_user) { nil } page = 1 @@ -16,13 +16,13 @@ describe 'comments/index' do render end - it 'renders a list of comments' do + it "renders a list of comments" do render rendered.should have_content 'OMG LOL' rendered.should have_content 'ROFL' end - it 'contains an RSS feed link' do - assert_select 'a', href: comments_path(format: 'rss') + it "contains an RSS feed link" do + 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 6d0db9169..672658bac 100644 --- a/spec/views/comments/index.rss.haml_spec.rb +++ b/spec/views/comments/index.rss.haml_spec.rb @@ -13,7 +13,7 @@ describe 'comments/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content 'Recent comments on all posts' + rendered.should have_content "Recent comments on all posts" end it 'shows item title' do @@ -26,6 +26,6 @@ describe 'comments/index.rss.haml' do end it 'shows content of comments' do - rendered.should have_content 'OMG LOL' + rendered.should have_content "OMG LOL" end end diff --git a/spec/views/comments/new.html.haml_spec.rb b/spec/views/comments/new.html.haml_spec.rb index e5bdcfb39..e0533ea5b 100644 --- a/spec/views/comments/new.html.haml_spec.rb +++ b/spec/views/comments/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'comments/new' do +describe "comments/new" do before(:each) do controller.stub(:current_user) { nil } @post = FactoryBot.create(:post) @@ -10,21 +10,21 @@ describe 'comments/new' do render end - it 'shows the text of the post under discussion' do + it "shows the text of the post under discussion" do rendered.should have_content @post.body end - it 'shows previous comments' do + it "shows previous comments" do rendered.should have_content @comment.body end - it 'shows the correct comment count' do - rendered.should have_content '1 comment' + it "shows the correct comment count" do + rendered.should have_content "1 comment" end - it 'renders new comment form' do - assert_select 'form', action: comments_path, method: 'post' do - assert_select 'textarea#comment_body', name: 'comment[body]' + it "renders new comment form" do + assert_select "form", action: comments_path, method: "post" do + assert_select "textarea#comment_body", name: "comment[body]" end end diff --git a/spec/views/comments/show.html.haml_spec.rb b/spec/views/comments/show.html.haml_spec.rb index 91e045359..6315b4f69 100644 --- a/spec/views/comments/show.html.haml_spec.rb +++ b/spec/views/comments/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'comments/show' do +describe "comments/show" do before(:each) do controller.stub(:current_user) { nil } @comment = assign(:comment, FactoryBot.create(:comment)) render end - it 'renders the comment' do + it "renders the comment" do rendered.should have_content @comment.author.login_name rendered.should have_content @comment.body end diff --git a/spec/views/crops/_grown_for.html.haml_spec.rb b/spec/views/crops/_grown_for.html.haml_spec.rb index deb541bb4..c378c296c 100644 --- a/spec/views/crops/_grown_for.html.haml_spec.rb +++ b/spec/views/crops/_grown_for.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/_grown_for' do +describe "crops/_grown_for" do let(:crop) { FactoryBot.create(:crop) } let(:plant_path) { FactoryBot.create(:plant_part) } let!(:harvest) do @@ -12,6 +12,6 @@ describe 'crops/_grown_for' do it 'shows plant parts' do render partial: 'crops/grown_for', locals: { crop: crop } rendered.should have_content plant_path.name - assert_select 'a', href: plant_part_path(plant_path) + assert_select "a", href: plant_part_path(plant_path) 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 4cb5aa0a2..12064a1b8 100644 --- a/spec/views/crops/_planting_advice.html.haml_spec.rb +++ b/spec/views/crops/_planting_advice.html.haml_spec.rb @@ -1,62 +1,62 @@ require 'rails_helper' -describe 'crops/_planting_advice' do +describe "crops/_planting_advice" do subject { rendered } let(:planting) { FactoryBot.create(:planting) } - shared_examples 'render planting_advice' do + shared_examples "render planting_advice" do before { render 'crops/planting_advice', crop: planting.crop } end - describe 'sunniness' do - context 'with no sunniness set' do - include_examples 'render planting_advice' + describe "sunniness" do + context "with no sunniness set" do + include_examples "render planting_advice" it "doesn't show sunniness" do - is_expected.to have_content 'Plant in: not known.' + is_expected.to have_content "Plant in: not known." end end - context 'with sunniness frequencies' do + context "with sunniness frequencies" do before { FactoryBot.create(:sunny_planting, crop: planting.crop) } - include_examples 'render planting_advice' - it { is_expected.to have_content 'Plant in:' } - it { is_expected.to have_content 'sun (1)' } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant in:" } + it { is_expected.to have_content "sun (1)" } end - context 'with multiple sunniness frequencies' do + context "with multiple sunniness frequencies" do before do FactoryBot.create_list(:sunny_planting, 2, crop: planting.crop) FactoryBot.create(:shady_planting, crop: planting.crop) end - include_examples 'render planting_advice' - it { is_expected.to have_content 'Plant in:' } - it { is_expected.to have_content 'sun (2), shade (1)' } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant in:" } + it { is_expected.to have_content "sun (2), shade (1)" } end end - describe 'planted from' do - context 'when none are set' do - include_examples 'render planting_advice' + describe "planted from" do + context "when none are set" do + include_examples "render planting_advice" it "doesn't show planted_from " do - is_expected.to have_content 'Plant from: not known.' + is_expected.to have_content "Plant from: not known." end end - context 'with planted_from frequencies' do + context "with planted_from frequencies" do before { FactoryBot.create(:seed_planting, crop: planting.crop) } - include_examples 'render planting_advice' - it { is_expected.to have_content 'Plant from:' } - it { is_expected.to have_content 'seed (1)' } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant from:" } + it { is_expected.to have_content "seed (1)" } end - context 'with multiple planted_from frequencies' do + context "with multiple planted_from frequencies" do before do FactoryBot.create_list(:seed_planting, 2, crop: planting.crop) FactoryBot.create(:cutting_planting, crop: planting.crop) end - include_examples 'render planting_advice' - it { is_expected.to have_content 'Plant from:' } - it { is_expected.to have_content 'seed (2), cutting (1)' } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant from:" } + it { is_expected.to have_content "seed (2), cutting (1)" } end end end diff --git a/spec/views/crops/_popover.html.haml_spec.rb b/spec/views/crops/_popover.html.haml_spec.rb index e5f1f92ac..dde4a893f 100644 --- a/spec/views/crops/_popover.html.haml_spec.rb +++ b/spec/views/crops/_popover.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/_popover' do +describe "crops/_popover" do before(:each) do @tomato = FactoryBot.create(:tomato) @sn = FactoryBot.create(:solanum_lycopersicum, crop: @tomato) diff --git a/spec/views/crops/edit.html.haml_spec.rb b/spec/views/crops/edit.html.haml_spec.rb index eeadf603d..19fac21af 100644 --- a/spec/views/crops/edit.html.haml_spec.rb +++ b/spec/views/crops/edit.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/edit' do +describe "crops/edit" do before(:each) do controller.stub(:current_user) do FactoryBot.create(:crop_wrangling_member) @@ -13,7 +13,7 @@ describe 'crops/edit' do render end - it 'shows the creator' do + it "shows the creator" do rendered.should have_content "Added by #{@crop.creator} less than a minute ago." end end diff --git a/spec/views/crops/hierarchy.html.haml_spec.rb b/spec/views/crops/hierarchy.html.haml_spec.rb index 0740142bb..833bb2b98 100644 --- a/spec/views/crops/hierarchy.html.haml_spec.rb +++ b/spec/views/crops/hierarchy.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/hierarchy' do +describe "crops/hierarchy" do before(:each) do controller.stub(:current_user) { nil } @tomato = FactoryBot.create(:tomato) @@ -9,7 +9,7 @@ describe 'crops/hierarchy' do render end - it 'shows crop hierarchy' do - assert_select 'ul>li>ul>li', text: @roma.name + it "shows crop hierarchy" do + 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 ef7081444..9f2985035 100644 --- a/spec/views/crops/index.html.haml_spec.rb +++ b/spec/views/crops/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/index' do +describe "crops/index" do before(:each) do controller.stub(:current_user) { nil } page = 1 @@ -15,20 +15,20 @@ describe 'crops/index' do assign(:crops, crops) end - it 'shows photos where available' do + it "shows photos where available" do @planting = FactoryBot.create(:planting, crop: @tomato) @photo = FactoryBot.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 + it "linkifies crop images" do render - assert_select 'img', src: :tomato + assert_select "img", src: :tomato end - context 'logged in and crop wrangler' do + context "logged in and crop wrangler" do before(:each) do @member = FactoryBot.create(:crop_wrangling_member) sign_in @member @@ -36,18 +36,18 @@ describe 'crops/index' do render end - it 'shows a new crop link' do - rendered.should have_content 'New Crop' + it "shows a new crop link" do + rendered.should have_content "New Crop" end end - context 'downloads' do - it 'offers data downloads' do + context "downloads" 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') + 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') end end end diff --git a/spec/views/crops/index.rss.haml_spec.rb b/spec/views/crops/index.rss.haml_spec.rb index cb218b9cd..72a8bbdff 100644 --- a/spec/views/crops/index.rss.haml_spec.rb +++ b/spec/views/crops/index.rss.haml_spec.rb @@ -11,7 +11,7 @@ describe 'crops/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content 'Recently added crops' + rendered.should have_content "Recently added crops" end it 'shows names of crops' do diff --git a/spec/views/crops/new.html.haml_spec.rb b/spec/views/crops/new.html.haml_spec.rb index 229474cac..5ce7eefdc 100644 --- a/spec/views/crops/new.html.haml_spec.rb +++ b/spec/views/crops/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/new' do +describe "crops/new" do before(:each) do @crop = FactoryBot.create(:maize) 3.times do @@ -13,7 +13,7 @@ describe 'crops/new' do render end - it 'shows a link to crop wrangling guidelines' do - assert_select "a[href^='http://wiki.growstuff.org']", 'crop wrangling guide' + it "shows a link to crop wrangling guidelines" do + assert_select "a[href^='http://wiki.growstuff.org']", "crop wrangling guide" end end diff --git a/spec/views/crops/wrangle.html.haml_spec.rb b/spec/views/crops/wrangle.html.haml_spec.rb index d97eab036..085060570 100644 --- a/spec/views/crops/wrangle.html.haml_spec.rb +++ b/spec/views/crops/wrangle.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'crops/wrangle' do +describe "crops/wrangle" do before(:each) do @member = FactoryBot.create(:crop_wrangling_member) controller.stub(:current_user) { @member } @@ -18,18 +18,18 @@ describe 'crops/wrangle' do it 'contains handy links for wranglers' do render - rendered.should have_content 'Crop wrangler guidelines' - rendered.should have_content 'mailing list' + rendered.should have_content "Crop wrangler guidelines" + rendered.should have_content "mailing list" end 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 + 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 3dd70cd20..720822083 100644 --- a/spec/views/devise/confirmations/new_spec.rb +++ b/spec/views/devise/confirmations/new_spec.rb @@ -1,13 +1,13 @@ -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) - @view.stub(:resource_name).and_return('member') + @view.stub(:resource_name).and_return("member") @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render end it 'should contain a login field' do - rendered.should have_content 'Enter either your login name or your email address' + rendered.should have_content "Enter either your login name or your email address" end end diff --git a/spec/views/devise/mailer/confirmation_instructions_spec.rb b/spec/views/devise/mailer/confirmation_instructions_spec.rb index b2dcf645a..d2cce98c4 100644 --- a/spec/views/devise/mailer/confirmation_instructions_spec.rb +++ b/spec/views/devise/mailer/confirmation_instructions_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe 'devise/mailer/confirmation_instructions.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/mailer/confirmation_instructions.html.haml', type: "view" do + context "logged in" do before(:each) do @resource = FactoryBot.create(:member) render diff --git a/spec/views/devise/mailer/reset_password_instructions_spec.rb b/spec/views/devise/mailer/reset_password_instructions_spec.rb index d64dbc30d..fc2ad1bbe 100644 --- a/spec/views/devise/mailer/reset_password_instructions_spec.rb +++ b/spec/views/devise/mailer/reset_password_instructions_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'devise/mailer/reset_password_instructions.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/mailer/reset_password_instructions.html.haml', type: "view" do + context "logged in" do before(:each) do @resource = mock_model(Member) - @resource.stub(:email).and_return('example@example.com') - @resource.stub(:reset_password_token).and_return('joe') + @resource.stub(:email).and_return("example@example.com") + @resource.stub(:reset_password_token).and_return("joe") render end diff --git a/spec/views/devise/mailer/unlock_instructions_spec.rb b/spec/views/devise/mailer/unlock_instructions_spec.rb index bafbb484c..633545cf3 100644 --- a/spec/views/devise/mailer/unlock_instructions_spec.rb +++ b/spec/views/devise/mailer/unlock_instructions_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe 'devise/mailer/unlock_instructions.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/mailer/unlock_instructions.html.haml', type: "view" do + context "logged in" do before(:each) do @resource = FactoryBot.create(:member) render end it "should explain what's happened" do - rendered.should have_content 'account has been locked' + rendered.should have_content "account has been locked" end - it 'should have an unlock link' do - rendered.should have_content 'Unlock my account' + it "should have an unlock link" do + rendered.should have_content "Unlock my account" end end end diff --git a/spec/views/devise/registrations/edit_spec.rb b/spec/views/devise/registrations/edit_spec.rb index 52999595f..3d9dae906 100644 --- a/spec/views/devise/registrations/edit_spec.rb +++ b/spec/views/devise/registrations/edit_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'devise/registrations/edit.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/registrations/edit.html.haml', type: "view" do + context "logged in" do before(:each) do controller.stub(:current_user) { nil } @member = FactoryBot.create(:member) controller.stub(:current_member) { @member } @view.stub(:resource).and_return(@member) - @view.stub(:resource_name).and_return('member') + @view.stub(:resource_name).and_return("member") @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) end @@ -23,11 +23,11 @@ describe 'devise/registrations/edit.html.haml', type: 'view' do end it 'has a checkbox for email notifications' do - assert_select 'input[id=member_send_notification_email][type=checkbox]' + assert_select "input[id=member_send_notification_email][type=checkbox]" end it 'has a checkbox for newsletter subscription' do - assert_select 'input[id=member_newsletter][type=checkbox]' + assert_select "input[id=member_newsletter][type=checkbox]" end end @@ -37,23 +37,23 @@ describe 'devise/registrations/edit.html.haml', type: 'view' do end it 'shows show_email checkbox' do - assert_select 'input[id=member_show_email][type=checkbox]' + assert_select "input[id=member_show_email][type=checkbox]" end - it 'contains a gravatar icon' do - assert_select 'img', src: /gravatar\.com\/avatar/ + it "contains a gravatar icon" do + 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 - assert_select 'textarea[id=member_bio]' + assert_select "textarea[id=member_bio]" end it 'shows location field' do - assert_select 'input[id=member_location][type=text]' + assert_select "input[id=member_location][type=text]" end end @@ -61,7 +61,7 @@ describe 'devise/registrations/edit.html.haml', type: 'view' do context 'not connected to twitter' do it 'has a link to connect' do render - assert_select 'a', 'Connect to Twitter' + assert_select "a", "Connect to Twitter" end end context 'connected to twitter' do @@ -70,18 +70,18 @@ describe 'devise/registrations/edit.html.haml', type: 'view' do 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 context 'not connected to flickr' do it 'has a link to connect' do render - assert_select 'a', 'Connect to Flickr' + assert_select "a", "Connect to Flickr" end end context 'connected to flickr' do @@ -90,11 +90,11 @@ describe 'devise/registrations/edit.html.haml', type: 'view' do 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 end diff --git a/spec/views/devise/registrations/new_spec.rb b/spec/views/devise/registrations/new_spec.rb index 3424fbef9..48805b806 100644 --- a/spec/views/devise/registrations/new_spec.rb +++ b/spec/views/devise/registrations/new_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'devise/registrations/new.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/registrations/new.html.haml', type: "view" do + context "logged in" do before(:each) do @view.stub(:resource).and_return(Member.new) - @view.stub(:resource_name).and_return('member') + @view.stub(:resource_name).and_return("member") @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render @@ -15,7 +15,7 @@ describe 'devise/registrations/new.html.haml', type: 'view' do end it 'has a checkbox for newsletter subscription' do - assert_select 'input[id=member_newsletter][type=checkbox]' + assert_select "input[id=member_newsletter][type=checkbox]" end end end diff --git a/spec/views/devise/sessions/new_spec.rb b/spec/views/devise/sessions/new_spec.rb index 9d83e51b3..dfe91af2a 100644 --- a/spec/views/devise/sessions/new_spec.rb +++ b/spec/views/devise/sessions/new_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'devise/sessions/new.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/sessions/new.html.haml', type: "view" do + context "logged in" do before(:each) do @view.stub(:resource).and_return(Member.new) - @view.stub(:resource_name).and_return('member') + @view.stub(:resource_name).and_return("member") @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render diff --git a/spec/views/devise/shared/_links_spec.rb b/spec/views/devise/shared/_links_spec.rb index 63f2fd52d..39147113f 100644 --- a/spec/views/devise/shared/_links_spec.rb +++ b/spec/views/devise/shared/_links_spec.rb @@ -1,6 +1,6 @@ -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 = double("mappings") dm.stub(registerable?: register) dm.stub(recoverable?: recover) dm.stub(confirmable?: confirm) @@ -10,15 +10,15 @@ describe 'devise/shared/_links.haml', type: 'view' do 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(: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)) 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(:controller_name).and_return("sessions") + @view.stub(:resource_name).and_return("member") @view.stub(devise_mapping: devise_mapping(false, false, false, false, false)) render end diff --git a/spec/views/devise/unlocks/new_spec.rb b/spec/views/devise/unlocks/new_spec.rb index 5fd755cce..60d056d72 100644 --- a/spec/views/devise/unlocks/new_spec.rb +++ b/spec/views/devise/unlocks/new_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'devise/unlocks/new.html.haml', type: 'view' do - context 'logged in' do +describe 'devise/unlocks/new.html.haml', type: "view" do + context "logged in" do before(:each) do @view.stub(:resource).and_return(Member.new) - @view.stub(:resource_name).and_return('member') + @view.stub(:resource_name).and_return("member") @view.stub(:resource_class).and_return(Member) @view.stub(:devise_mapping).and_return(Devise.mappings[:member]) render diff --git a/spec/views/forums/edit.html.haml_spec.rb b/spec/views/forums/edit.html.haml_spec.rb index 152a34418..44151170a 100644 --- a/spec/views/forums/edit.html.haml_spec.rb +++ b/spec/views/forums/edit.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe 'forums/edit' do +describe "forums/edit" do before(:each) do @forum = assign(:forum, stub_model(Forum, - name: 'MyString', - description: 'MyText', + name: "MyString", + description: "MyText", owner_id: 1)) end - it 'renders the edit forum form' do + it "renders the edit forum form" 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 279a365fc..02b265e85 100644 --- a/spec/views/forums/index.html.haml_spec.rb +++ b/spec/views/forums/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'forums/index' do +describe "forums/index" do before(:each) do @admin = FactoryBot.create(:admin_member) controller.stub(:current_user) { @admin } @@ -9,31 +9,31 @@ describe 'forums/index' do assign(:forums, [@forum1, @forum2]) end - it 'renders a list of forums' 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 render - assert_select 'table', false + assert_select "table", false end - context 'posts' do + context "posts" do before(:each) do @post = FactoryBot.create(:forum_post, forum: @forum1) @comment = FactoryBot.create(:comment, post: @post) render end - it 'displays posts' do - assert_select 'table' + it "displays posts" do + assert_select "table" rendered.should have_content @post.subject rendered.should have_content Time.zone.today.to_s(:short) end - it 'displays comment count' do - assert_select 'td', text: '1' + it "displays comment count" do + assert_select "td", text: "1" end end end diff --git a/spec/views/forums/new.html.haml_spec.rb b/spec/views/forums/new.html.haml_spec.rb index 58278ee18..72cd7ae45 100644 --- a/spec/views/forums/new.html.haml_spec.rb +++ b/spec/views/forums/new.html.haml_spec.rb @@ -1,16 +1,16 @@ require 'rails_helper' -describe 'forums/new' do +describe "forums/new" do before(:each) do @forum = assign(:forum, FactoryBot.create(:forum)) render 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]' + 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]" end end end diff --git a/spec/views/forums/show.html.haml_spec.rb b/spec/views/forums/show.html.haml_spec.rb index 6e67b8c59..08892df58 100644 --- a/spec/views/forums/show.html.haml_spec.rb +++ b/spec/views/forums/show.html.haml_spec.rb @@ -1,20 +1,20 @@ require 'rails_helper' -describe 'forums/show' do +describe "forums/show" do before(:each) do controller.stub(:current_user) { nil } @forum = assign(:forum, FactoryBot.create(:forum)) end - it 'renders attributes' do + it "renders attributes" do render - rendered.should have_content 'Everything about permaculture' + rendered.should have_content "Everything about permaculture" rendered.should have_content @forum.owner.to_s end - it 'parses markdown description into html' do + it "parses markdown description into html" do render - assert_select 'em', 'Everything' + assert_select "em", "Everything" end it 'links to new post with the forum id' do @@ -24,13 +24,13 @@ describe 'forums/show' do it 'has no posts' do render - rendered.should have_content 'No posts yet.' + rendered.should have_content "No posts yet." end it 'shows posts' do @post = FactoryBot.create(:post, forum: @forum) render - assert_select 'table' + assert_select "table" rendered.should have_content @post.subject rendered.should have_content @post.author.to_s end diff --git a/spec/views/gardens/edit.html.haml_spec.rb b/spec/views/gardens/edit.html.haml_spec.rb index c725af57e..1326f1544 100644 --- a/spec/views/gardens/edit.html.haml_spec.rb +++ b/spec/views/gardens/edit.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe 'gardens/edit' do - context 'logged in' do +describe "gardens/edit" do + context "logged in" do before(:each) do @owner = FactoryBot.create(:member) sign_in @owner @@ -10,17 +10,17 @@ describe 'gardens/edit' do render end - it 'renders the edit garden form' do + it "renders the edit garden form" 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 39b659b7e..7346997dc 100644 --- a/spec/views/gardens/new.html.haml_spec.rb +++ b/spec/views/gardens/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'gardens/new' do +describe "gardens/new" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -10,14 +10,14 @@ describe 'gardens/new' do 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]' + 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]" end end end diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index fa03c5856..7130e2e4f 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'gardens/show' do +describe "gardens/show" do before(:each) do @owner = FactoryBot.create(:member) controller.stub(:current_user) { @owner } @@ -21,11 +21,11 @@ describe 'gardens/show' do end it 'should show the description' do - rendered.should have_content 'totally cool garden' + rendered.should have_content "totally cool garden" end it 'renders markdown in the description' do - assert_select 'strong', 'totally' + assert_select "strong", "totally" end it 'should show plantings on the garden page' do @@ -33,7 +33,7 @@ describe 'gardens/show' do end it "doesn't show the note about random plantings" do - rendered.should_not have_content 'Note: these are a random selection' + rendered.should_not have_content "Note: these are a random selection" end context 'signed in' do @@ -47,14 +47,14 @@ describe 'gardens/show' do end it "shows a 'plant something' button" do - rendered.should have_content 'Plant something' + rendered.should have_content "Plant something" end it "shows an 'add photo' button" do - rendered.should have_content 'Add photo' + rendered.should have_content "Add photo" end - it 'links to the right crop in the planting link' do + it "links to the right crop in the planting link" do assert_select("a[href='#{new_planting_path}?garden_id=#{@garden.id}']") end end diff --git a/spec/views/harvests/edit.html.haml_spec.rb b/spec/views/harvests/edit.html.haml_spec.rb index 6d4c55b7e..1193b4284 100644 --- a/spec/views/harvests/edit.html.haml_spec.rb +++ b/spec/views/harvests/edit.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe 'harvests/edit' do +describe "harvests/edit" do before(:each) do assign(:harvest, FactoryBot.create(:harvest)) render 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]' + 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]" end end end diff --git a/spec/views/harvests/index.html.haml_spec.rb b/spec/views/harvests/index.html.haml_spec.rb index 62ef81d15..fe205cda6 100644 --- a/spec/views/harvests/index.html.haml_spec.rb +++ b/spec/views/harvests/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'harvests/index' do +describe "harvests/index" do before(:each) do controller.stub(:current_user) { nil } @member = FactoryBot.create(:member) @@ -25,11 +25,11 @@ describe 'harvests/index' do render end - it 'provides data links' 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') + 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') 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 4e6050625..d79055a38 100644 --- a/spec/views/harvests/new.html.haml_spec.rb +++ b/spec/views/harvests/new.html.haml_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -describe 'harvests/new' do +describe "harvests/new" do before(:each) do assign(:harvest, FactoryBot.create(:harvest)) render 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]' + 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]" # 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 a182b5269..4aec453ff 100644 --- a/spec/views/harvests/show.html.haml_spec.rb +++ b/spec/views/harvests/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'harvests/show' do +describe "harvests/show" do subject { render } let!(:harvest) { FactoryBot.create(:harvest) } @@ -11,7 +11,7 @@ describe 'harvests/show' do render end - describe 'renders attributes' do + describe "renders attributes" do it { is_expected.to have_content harvest.crop.name } it { is_expected.to have_content harvest.harvested_at.to_s } it { is_expected.to have_content harvest.plant_part.to_s } diff --git a/spec/views/home/_blurb.html.haml_spec.rb b/spec/views/home/_blurb.html.haml_spec.rb index 5e661b19d..47244a445 100644 --- a/spec/views/home/_blurb.html.haml_spec.rb +++ b/spec/views/home/_blurb.html.haml_spec.rb @@ -1,6 +1,6 @@ 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 } @@ -12,13 +12,13 @@ describe 'home/_blurb.html.haml', type: 'view' do end it 'has signup section' do - assert_select 'div.signup' - assert_select 'a', href: new_member_registration_path + assert_select "div.signup" + 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 + rendered.should have_content "Or sign in if you already have an account" + assert_select "a", href: new_member_session_path end end end diff --git a/spec/views/home/_crops.html.haml_spec.rb b/spec/views/home/_crops.html.haml_spec.rb index 37dcbd05b..3ed655438 100644 --- a/spec/views/home/_crops.html.haml_spec.rb +++ b/spec/views/home/_crops.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/_crops.html.haml', type: 'view' do +describe 'home/_crops.html.haml', type: "view" do let!(:crop) { FactoryBot.create(:crop, plantings: FactoryBot.create_list(:planting, 3)) } let!(:photo) { FactoryBot.create(:photo, plantings: [crop.plantings.first]) } let(:planting) { crop.plantings.first } diff --git a/spec/views/home/_members.html.haml_spec.rb b/spec/views/home/_members.html.haml_spec.rb index 3d75ea692..76aa434b6 100644 --- a/spec/views/home/_members.html.haml_spec.rb +++ b/spec/views/home/_members.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/_members.html.haml', type: 'view' do +describe 'home/_members.html.haml', type: "view" do before(:each) do @member = FactoryBot.create(:london_member) @member.updated_at = 2.days.ago @@ -11,7 +11,7 @@ describe 'home/_members.html.haml', type: 'view' do end it 'Has a heading' do - rendered.should have_content 'Some of our members' + rendered.should have_content "Some of our members" end it 'Shows members' do diff --git a/spec/views/home/_seeds.html.haml_spec.rb b/spec/views/home/_seeds.html.haml_spec.rb index a551e97f8..7b8d6156c 100644 --- a/spec/views/home/_seeds.html.haml_spec.rb +++ b/spec/views/home/_seeds.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/_seeds.html.haml', type: 'view' do +describe 'home/_seeds.html.haml', type: "view" do before(:each) do @owner = FactoryBot.create(:london_member) @seed = FactoryBot.create(:tradable_seed, owner: @owner) diff --git a/spec/views/home/_stats.html.haml_spec.rb b/spec/views/home/_stats.html.haml_spec.rb index dc5a0e8a5..a9979190c 100644 --- a/spec/views/home/_stats.html.haml_spec.rb +++ b/spec/views/home/_stats.html.haml_spec.rb @@ -1,8 +1,8 @@ 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' + rendered.should have_content "So far, 0 members have planted 0 crops" end end diff --git a/spec/views/home/index_spec.rb b/spec/views/home/index_spec.rb index 5eeae7ff4..5e11882fd 100644 --- a/spec/views/home/index_spec.rb +++ b/spec/views/home/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'home/index.html.haml', type: 'view' do +describe 'home/index.html.haml', type: "view" do before(:each) do @member = FactoryBot.create(:london_member) @member.updated_at = 2.days.ago diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb index 60f27ca80..5060fc30d 100644 --- a/spec/views/layouts/_header_spec.rb +++ b/spec/views/layouts/_header_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -describe 'layouts/_header.html.haml', type: 'view' do - context 'when not logged in' do +describe 'layouts/_header.html.haml', type: "view" do + context "when not logged in" do before(:each) do controller.stub(:current_user) { nil } render end it 'shows the brand logo in the navbar' do - assert_select('a.navbar-brand img[src]', href: root_path) + assert_select("a.navbar-brand img[src]", href: root_path) end it 'should have signup/signin links' do @@ -17,19 +17,19 @@ describe 'layouts/_header.html.haml', type: 'view' do end it 'has a Crops link' do - rendered.should have_content 'Crops' + rendered.should have_content "Crops" end it 'has a Seeds link' do - rendered.should have_content 'Seeds' + rendered.should have_content "Seeds" end it 'has a Places link' do - rendered.should have_content 'Community Map' + rendered.should have_content "Community Map" end it 'has a Community section' do - rendered.should have_content 'Community' + rendered.should have_content "Community" end it 'links to members' do @@ -46,11 +46,11 @@ describe 'layouts/_header.html.haml', type: 'view' do it 'has a crop search' do assert_select("form[action='#{crops_search_path}']") - assert_select('input#term') + assert_select("input#term") end end - context 'logged in' do + context "logged in" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -58,21 +58,21 @@ describe 'layouts/_header.html.haml', type: 'view' do render end - context 'login name' do + context "login name" do it 'should have member login name' do rendered.should have_content @member.login_name.to_s 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 diff --git a/spec/views/layouts/_meta_spec.rb b/spec/views/layouts/_meta_spec.rb index 42d4704ad..151c6fe19 100644 --- a/spec/views/layouts/_meta_spec.rb +++ b/spec/views/layouts/_meta_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'layouts/_meta.html.haml', type: 'view' do +describe 'layouts/_meta.html.haml', type: "view" do before(:each) do render end @@ -21,6 +21,6 @@ describe 'layouts/_meta.html.haml', type: 'view' do end it 'should have a title' do - assert_select 'head>title' + assert_select "head>title" end end diff --git a/spec/views/layouts/application_spec.rb b/spec/views/layouts/application_spec.rb index 265a0b572..f094ae2c2 100644 --- a/spec/views/layouts/application_spec.rb +++ b/spec/views/layouts/application_spec.rb @@ -1,6 +1,6 @@ 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 @@ -8,7 +8,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 end diff --git a/spec/views/members/_location.html.haml_spec.rb b/spec/views/members/_location.html.haml_spec.rb index d15d69538..50d7b675f 100644 --- a/spec/views/members/_location.html.haml_spec.rb +++ b/spec/views/members/_location.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe 'members/_location' do - context 'member with location' do +describe "members/_location" do + context "member with location" do let(:member) { FactoryBot.create(:london_member) } before(:each) { render partial: 'members/location', locals: { member: member } } @@ -10,23 +10,23 @@ describe 'members/_location' do expect(rendered).to have_content member.location end - it 'links to the places page' do - assert_select 'a', href: place_path(member.location) + it "links to the places page" do + assert_select "a", href: place_path(member.location) end end - context 'member with no location' do + context "member with no location" do before(:each) do member = FactoryBot.create(:member) render partial: 'members/location', locals: { member: member } end it 'shows unknown location' do - expect(rendered).to have_content 'unknown location' + expect(rendered).to have_content "unknown location" end it "doesn't link anywhere" do - assert_select 'a', false + assert_select "a", false end end end diff --git a/spec/views/members/index.html.haml_spec.rb b/spec/views/members/index.html.haml_spec.rb index 24308bd0e..87dd3a285 100644 --- a/spec/views/members/index.html.haml_spec.rb +++ b/spec/views/members/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'members/index' do +describe "members/index" do let(:member) { FactoryBot.create(:london_member) } before(:each) do @@ -15,8 +15,8 @@ describe 'members/index' do render end - it 'contains two gravatar icons' do - assert_select 'img', src: /gravatar\.com\/avatar/, count: 2 + it "contains two gravatar icons" do + 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 79ea04078..23366a9a8 100644 --- a/spec/views/members/show.rss.haml_spec.rb +++ b/spec/views/members/show.rss.haml_spec.rb @@ -1,6 +1,6 @@ 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, FactoryBot.create(:member)) @post1 = FactoryBot.create(:post, id: 1, author: @member) @@ -16,13 +16,13 @@ describe 'members/show.rss.haml', type: 'view' do end it 'shows content of posts' do - is_expected.to have_content 'This is some text.' + is_expected.to have_content "This is some text." end it 'renders post bodies to HTML and XML-escapes them' do # The variable "rendered" has been entity-replaced and tag-stripped # The literal string output contains "<strong>" etc. - is_expected.to have_content 'strong' + is_expected.to have_content "strong" end it 'gives the author in the item title' do diff --git a/spec/views/notifications/index.html.haml_spec.rb b/spec/views/notifications/index.html.haml_spec.rb index 76d96f3eb..2c8195069 100644 --- a/spec/views/notifications/index.html.haml_spec.rb +++ b/spec/views/notifications/index.html.haml_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -describe 'notifications/index' do +describe "notifications/index" do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } end - context 'ordinary notifications' do + context "ordinary notifications" do before(:each) do @notification = FactoryBot.create(:notification, sender: @member, recipient: @member) @@ -14,34 +14,34 @@ describe 'notifications/index' do render end - 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 + 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 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 + context "no subject" do + it "shows (no subject)" do @notification = FactoryBot.create(:notification, sender: @member, recipient: @member, subject: nil) assign(:notifications, Kaminari.paginate_array([@notification]).page(1)) render - rendered.should have_content '(no subject)' + rendered.should have_content "(no subject)" end end - context 'whitespace-only subject' do - it 'shows (no subject)' do + context "whitespace-only subject" do + it "shows (no subject)" do @notification = FactoryBot.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)' + rendered.should have_content "(no subject)" end end end diff --git a/spec/views/notifications/new.html.haml_spec.rb b/spec/views/notifications/new.html.haml_spec.rb index 091e13cc1..a7f030f47 100644 --- a/spec/views/notifications/new.html.haml_spec.rb +++ b/spec/views/notifications/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'notifications/new' do +describe "notifications/new" do before(:each) do @recipient = FactoryBot.create(:member) @sender = FactoryBot.create(:member) @@ -9,38 +9,38 @@ describe 'notifications/new' do controller.stub(:current_user) { @sender } end - it 'renders new message form' do + 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 - it 'tells you who the recipient is' do + it "tells you who the recipient is" do render rendered.should have_content @recipient.login_name end - it 'puts the recipient in a hidden field' 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 + 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 + 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 + it "Tells you to write your message here" do render - rendered.should have_content 'Type your message here' + rendered.should have_content "Type your message here" end it 'shows markdown help' do diff --git a/spec/views/notifications/show.html.haml_spec.rb b/spec/views/notifications/show.html.haml_spec.rb index 1376f7c18..14db0448c 100644 --- a/spec/views/notifications/show.html.haml_spec.rb +++ b/spec/views/notifications/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'notifications/show' do +describe "notifications/show" do before(:each) do @member = FactoryBot.create(:member) @notification = FactoryBot.create(:notification, recipient: @member) @@ -10,16 +10,16 @@ describe 'notifications/show' do render end - it 'renders attributes' do + it "renders attributes" do rendered.should have_content @notification.sender.to_s rendered.should have_content @notification.body.to_s end - it 'includes a delete button' do - assert_select 'a', 'Delete' + it "includes a delete button" do + assert_select "a", "Delete" end - it 'includes a reply button' do - assert_select 'a', { href: @reply_link }, 'Reply' + it "includes a reply button" do + assert_select "a", { href: @reply_link }, "Reply" end end diff --git a/spec/views/notifier/notify.html.haml_spec.rb b/spec/views/notifier/notify.html.haml_spec.rb index 2979e6985..913ea10d2 100644 --- a/spec/views/notifier/notify.html.haml_spec.rb +++ b/spec/views/notifier/notify.html.haml_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe 'notifier/notify.html.haml', type: 'view' do +describe 'notifier/notify.html.haml', type: "view" do before(:each) do @notification = FactoryBot.create(:notification) - @reply_link = 'http://example.com' - @signed_message = 'EncryptedMessage' + @reply_link = "http://example.com" + @signed_message = "EncryptedMessage" assign(:reply_link, @reply_link) render end diff --git a/spec/views/orders/index.html.haml_spec.rb b/spec/views/orders/index.html.haml_spec.rb deleted file mode 100644 index 9660b44fb..000000000 --- a/spec/views/orders/index.html.haml_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rails_helper' - -describe 'orders/index' do - before(:each) do - @member = FactoryBot.create(:member) - sign_in @member - @order1 = FactoryBot.create(:order, member: @member) - @order2 = FactoryBot.create(:completed_order, member: @member) - assign(:orders, [@order1, @order2]) - end - - it 'shows your current account status' do - render - rendered.should have_content 'Your current account status' - end - - 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 a/@href', text: "/orders/#{@order1.id}" - assert_select 'tr>td a/@href', text: "/orders/#{@order2.id}" - end -end diff --git a/spec/views/orders/show.html.haml_spec.rb b/spec/views/orders/show.html.haml_spec.rb deleted file mode 100644 index 233616b9e..000000000 --- a/spec/views/orders/show.html.haml_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'rails_helper' - -describe 'orders/show' do - before(:each) do - @member = FactoryBot.create(:member) - sign_in @member - controller.stub(:current_user) { @member } - end - - context 'current order' do - before(:each) do - @order = assign(:order, FactoryBot.create(:order, member: @member)) - @order_item = FactoryBot.create(:order_item, - order: @order, - quantity: 2, - price: 9900) - render - end - - it 'displays order number' do - rendered.should have_content 'Order number' - end - - it 'shows order items in a table' do - assert_select 'table>tr>th', text: 'Product' - end - - it 'shows the total' do - rendered.should have_content 'Total:' - assert_select 'strong', /198.00/ - end - - it 'shows a foreign exchange link for the total' do - currency = Growstuff::Application.config.currency - assert_select("a[href='http://www.wolframalpha.com/input/?i=198.00+#{currency}']") - end - - it 'asks for a referral code' do - assert_select "input[id='referral_code']" - end - - it 'shows a checkout button' do - assert_select "input[value='Checkout with PayPal']" - end - - it 'shows a delete order button' do - assert_select 'a', text: 'Delete this order' - end - end - - context 'completed order' do - before(:each) do - @order = assign(:order, FactoryBot.create(:completed_order, member: @member)) - @order_item = FactoryBot.create(:order_item, - order: @order, - quantity: 2, - price: 9900) - render - end - - it "doesn't show a checkout button" do - 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 - end - end -end diff --git a/spec/views/photos/edit.html.haml_spec.rb b/spec/views/photos/edit.html.haml_spec.rb index 7376ad759..a52b51a79 100644 --- a/spec/views/photos/edit.html.haml_spec.rb +++ b/spec/views/photos/edit.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'photos/edit' do +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')) + thumbnail_url: "MyString", + fullsize_url: "MyString")) end end diff --git a/spec/views/photos/index.html.haml_spec.rb b/spec/views/photos/index.html.haml_spec.rb index b99eb8309..b603de1e6 100644 --- a/spec/views/photos/index.html.haml_spec.rb +++ b/spec/views/photos/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'photos/index' do +describe "photos/index" do before(:each) do page = 1 per_page = 2 @@ -14,9 +14,9 @@ describe 'photos/index' do assign(:photos, photos) end - it 'renders a gallery of photos' 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 3ae91e1a3..e4f24f9e4 100644 --- a/spec/views/photos/new.html.haml_spec.rb +++ b/spec/views/photos/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'photos/new' do +describe "photos/new" do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } @@ -14,27 +14,27 @@ describe 'photos/new' do assign(:flickr_auth, FactoryBot.create(:flickr_authentication, member: @member)) end - context 'user has no photosets' do + context "user has no photosets" do it "doesn't show a dropdown with sets from Flickr" do render - assert_select 'select#set', false + assert_select "select#set", false end end - context 'user has photosets' do + context "user has photosets" do before(:each) do - assign(:sets, 'foo' => 'bar') # Hash of names => IDs + assign(:sets, "foo" => "bar") # Hash of names => IDs end - it 'shows a dropdown with sets from Flickr' do + it "shows a dropdown with sets from Flickr" do render - assert_select 'select#set' + assert_select "select#set" end - it 'shows the current photoset' do - assign(:current_set, 'bar') # the ID of the set + it "shows the current photoset" do + assign(:current_set, "bar") # the ID of the set render - assert_select 'h2', 'foo' # the name of the set + assert_select "h2", "foo" # the name of the set end end end diff --git a/spec/views/photos/show.html.haml_spec.rb b/spec/views/photos/show.html.haml_spec.rb index ce60a0b47..cecb0008b 100644 --- a/spec/views/photos/show.html.haml_spec.rb +++ b/spec/views/photos/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'photos/show' do +describe "photos/show" do let(:photo) { FactoryBot.create :photo, owner: member } before { @photo = photo } @@ -11,70 +11,70 @@ describe 'photos/show' do let(:seed) { FactoryBot.create :seed, owner: member } let(:garden) { FactoryBot.create :garden, owner: member } - shared_examples 'photo data renders' do - it 'shows the image' do + shared_examples "photo data renders" do + it "shows the image" do assert_select "img[src='#{@photo.fullsize_url}']" end it "links to the owner's profile" do - assert_select 'a', href: @photo.owner + assert_select "a", href: @photo.owner end - it 'shows a link to the original image' do - assert_select 'a', href: @photo.link_url, text: 'View on Flickr' + it "shows a link to the original image" do + assert_select "a", href: @photo.link_url, text: "View on Flickr" end - it 'links to harvest' do - assert_select 'a', href: harvest_path(harvest) + it "links to harvest" do + assert_select "a", href: harvest_path(harvest) end - it 'links to planting' do - assert_select 'a', href: planting_path(planting) + it "links to planting" do + assert_select "a", href: planting_path(planting) end - it 'links to garden' do - assert_select 'a', href: garden_path(garden) + it "links to garden" do + assert_select "a", href: garden_path(garden) end - it 'links to seeds' do - assert_select 'a', href: seed_path(seed) + it "links to seeds" do + assert_select "a", href: seed_path(seed) end end - shared_examples 'No links to change data' do - it 'does not have a delete button' do + shared_examples "No links to change data" do + it "does not have a delete button" do assert_select "a[href='#{photo_path(@photo)}']", false end end - context 'signed in as owner' do + context "signed in as owner" do before(:each) do controller.stub(:current_user) { member } render end - include_examples 'photo data renders' + include_examples "photo data renders" - it 'has a delete button' do + it "has a delete button" do assert_select "a[href='#{photo_path(@photo)}']" end end - context 'signed in as another member' do + context "signed in as another member" do before(:each) do controller.stub(:current_user) { FactoryBot.create :member } render end - include_examples 'photo data renders' - include_examples 'No links to change data' + include_examples "photo data renders" + include_examples "No links to change data" end - context 'not signed in' do + context "not signed in" do before(:each) do controller.stub(:current_user) { nil } render end - include_examples 'photo data renders' - include_examples 'No links to change data' + include_examples "photo data renders" + include_examples "No links to change data" end - context 'CC-licensed photo' do + context "CC-licensed photo" do before(:each) do controller.stub(:current_user) { nil } # @photo = assign(:photo, FactoryBot.create(:photo, owner: @member)) @@ -84,13 +84,13 @@ describe 'photos/show' do @photo.gardens << garden render end - it 'links to the CC license' do - assert_select 'a', href: @photo.license_url, + it "links to the CC license" do + assert_select "a", href: @photo.license_url, text: @photo.license_name end end - context 'unlicensed photo' do + context "unlicensed photo" do before(:each) do controller.stub(:current_user) { nil } @photo = assign(:photo, FactoryBot.create(:unlicensed_photo)) @@ -98,7 +98,7 @@ describe 'photos/show' do end it "contains the phrase 'All rights reserved'" do - rendered.should have_content 'All rights reserved' + rendered.should have_content "All rights reserved" end end end diff --git a/spec/views/places/_map_attribution.html.haml_spec.rb b/spec/views/places/_map_attribution.html.haml_spec.rb index 62022a303..7082290c8 100644 --- a/spec/views/places/_map_attribution.html.haml_spec.rb +++ b/spec/views/places/_map_attribution.html.haml_spec.rb @@ -1,21 +1,21 @@ 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' + it "links to OpenStreetMap" do + 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' + it "links to the ODbL" do + 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' + it "links to CloudMade" do + assert_select "a", href: "http://cloudmade.com", text: "CloudMade" end end diff --git a/spec/views/places/index.html.haml_spec.rb b/spec/views/places/index.html.haml_spec.rb index 3639719d2..f3a3661ae 100644 --- a/spec/views/places/index.html.haml_spec.rb +++ b/spec/views/places/index.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'places/index' do +describe "places/index" do before(:each) do render end - it 'shows a map' do - assert_select 'div#placesmap' + it "shows a map" do + assert_select "div#placesmap" end end diff --git a/spec/views/places/show.html.haml_spec.rb b/spec/views/places/show.html.haml_spec.rb index 463134684..635d06ab9 100644 --- a/spec/views/places/show.html.haml_spec.rb +++ b/spec/views/places/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'places/show' do +describe "places/show" do before(:each) do @member = FactoryBot.create(:london_member) @nearby_members = [FactoryBot.create(:member)] @@ -10,15 +10,15 @@ describe 'places/show' do render end - it 'shows the selected place' do + it "shows the selected place" do view.content_for(:title).should match @place end - it 'shows the selected place in the textbox' do - assert_select '#new_place', value: @place + it "shows the selected place in the textbox" do + assert_select "#new_place", value: @place end - it 'shows the names of nearby members' do + it "shows the names of nearby members" do @nearby_members.each do |m| rendered.should have_content m.login_name end diff --git a/spec/views/plant_parts/edit.html.haml_spec.rb b/spec/views/plant_parts/edit.html.haml_spec.rb index 33dab3bc8..683dd6ab0 100644 --- a/spec/views/plant_parts/edit.html.haml_spec.rb +++ b/spec/views/plant_parts/edit.html.haml_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe 'plant_parts/edit' do +describe "plant_parts/edit" do before(:each) do @plant_part = assign(:plant_part, stub_model(PlantPart, - name: 'MyString')) + name: "MyString")) end - it 'renders the edit plant_part form' do + it "renders the edit plant_part form" 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 ff1955637..65ecf2d63 100644 --- a/spec/views/plant_parts/index.html.haml_spec.rb +++ b/spec/views/plant_parts/index.html.haml_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -describe 'plant_parts/index' do +describe "plant_parts/index" do before(:each) do controller.stub(:current_user) { nil } @pp = FactoryBot.create(:plant_part) assign(:plant_parts, [@pp]) end - it 'renders a list of plant_parts' 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 476987a98..b1b3f12ae 100644 --- a/spec/views/plant_parts/new.html.haml_spec.rb +++ b/spec/views/plant_parts/new.html.haml_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -describe 'plant_parts/new' do +describe "plant_parts/new" do before(:each) do assign(:plant_part, stub_model(PlantPart, - name: 'MyString').as_new_record) + name: "MyString").as_new_record) end - it 'renders new plant_part form' do + it "renders new plant_part form" 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 a725121fa..b367a723b 100644 --- a/spec/views/plant_parts/show.html.haml_spec.rb +++ b/spec/views/plant_parts/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plant_parts/show' do +describe "plant_parts/show" do before(:each) do controller.stub(:current_user) { nil } @pp = FactoryBot.create(:plant_part) @@ -8,11 +8,11 @@ describe 'plant_parts/show' do assign(:plant_part, @pp) end - it 'renders a list of crops harvested for this part' do + it "renders a list of crops harvested for this part" 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 36e4aaeab..6371311ae 100644 --- a/spec/views/plantings/_form.html.haml_spec.rb +++ b/spec/views/plantings/_form.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plantings/_form' do +describe "plantings/_form" do before(:each) do @member = FactoryBot.create(:member) @garden = FactoryBot.create(:garden, owner: @member) @@ -18,7 +18,7 @@ describe 'plantings/_form' do render end - it 'has a free-form text field containing the planting date in ISO format' do + it "has a free-form text field containing the planting date in ISO format" do assert_select "input#planting_planted_at[type='text'][value='2013-03-01']" end end diff --git a/spec/views/plantings/edit.html.haml_spec.rb b/spec/views/plantings/edit.html.haml_spec.rb index 1de078e4a..b83af0028 100644 --- a/spec/views/plantings/edit.html.haml_spec.rb +++ b/spec/views/plantings/edit.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plantings/edit' do +describe "plantings/edit" do before(:each) do @member = FactoryBot.create(:member, login_name: 'right', @@ -19,32 +19,32 @@ describe 'plantings/edit' do FactoryBot.create(:planting, garden: @garden, crop: @tomato, owner: @member)) end - context 'logged in' do + context "logged in" do before(:each) do sign_in @member controller.stub(:current_user) { @member } render 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]' + 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]" 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 - assert_select 'input#crop[value=?]', 'tomato' + it "chooses the right crop" do + assert_select "input#crop[value=?]", "tomato" end - it 'chooses the right garden' do - assert_select 'select#planting_garden_id', + it "chooses the right garden" do + assert_select "select#planting_garden_id", html: /option 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 eed256f87..a3a713100 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plantings/index' do +describe "plantings/index" do let(:member) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: member) } let(:tomato) { FactoryBot.create(:tomato) } @@ -36,27 +36,27 @@ describe 'plantings/index' do render end - it 'renders a list of plantings' do + it "renders a list of plantings" do rendered.should have_content tomato.name rendered.should have_content maize.name rendered.should have_content member.login_name rendered.should have_content garden.name end - it 'displays planting time' do + it "displays planting time" do rendered.should have_content 'January 13, 2013' end - it 'displays finished time' do + it "displays finished time" do rendered.should have_content 'January 20, 2013' end - it 'provides data links' 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') + 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') end it "displays member's name in title" do diff --git a/spec/views/plantings/index.rss.haml_spec.rb b/spec/views/plantings/index.rss.haml_spec.rb index bed19f685..c4a394561 100644 --- a/spec/views/plantings/index.rss.haml_spec.rb +++ b/spec/views/plantings/index.rss.haml_spec.rb @@ -15,7 +15,7 @@ describe 'plantings/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content 'Recent plantings from all members' + rendered.should have_content "Recent plantings from all members" end it 'item title shows owner and location' do @@ -23,7 +23,7 @@ describe 'plantings/index.rss.haml' do end it 'shows formatted content of posts' do - rendered.should have_content 'This is a really good plant.' + rendered.should have_content "This is a really good plant." end it 'shows sunniness' do diff --git a/spec/views/plantings/new.html.haml_spec.rb b/spec/views/plantings/new.html.haml_spec.rb index 46971c706..6667a05ee 100644 --- a/spec/views/plantings/new.html.haml_spec.rb +++ b/spec/views/plantings/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plantings/new' do +describe "plantings/new" do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } @@ -17,7 +17,7 @@ describe 'plantings/new' do owner: @member)) end - context 'logged in' do + context "logged in" do before(:each) do sign_in @member assign(:planting, Planting.new) @@ -26,24 +26,24 @@ describe 'plantings/new' do render 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]' + 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]" 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', + it "selects a garden given in a param" do + assert_select "select#planting_garden_id", html: /option selected value="#{@garden_z.id}"/ end end diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb index 748ceee3d..899724ac7 100644 --- a/spec/views/plantings/show.html.haml_spec.rb +++ b/spec/views/plantings/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'plantings/show' do +describe "plantings/show" do let(:crop) { FactoryBot.create(:tomato) } let(:member) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: member) } @@ -19,7 +19,7 @@ describe 'plantings/show' do context 'sunniness' do let(:planting) { FactoryBot.create(:sunny_planting) } - it 'shows the sunniness' do + it "shows the sunniness" do render rendered.should have_content 'Sun or shade?' rendered.should have_content 'sun' @@ -29,7 +29,7 @@ describe 'plantings/show' do context 'planted from' do let(:planting) { FactoryBot.create(:cutting_planting) } - it 'shows planted_from' do + it "shows planted_from" do render rendered.should have_content 'Planted from:' rendered.should have_content 'cutting' @@ -43,41 +43,41 @@ describe 'plantings/show' do end end - it 'shows photos' do + it "shows photos" do photo = FactoryBot.create(:photo, owner: member) planting.photos << photo render assert_select "img[src='#{photo.thumbnail_url}']" end - it 'shows a link to add photos' do + it "shows a link to add photos" do render - rendered.should have_content 'Add photo' + rendered.should have_content "Add photo" end - context 'no location set' do + context "no location set" do before(:each) do render end - it 'renders the quantity planted' do + it "renders the quantity planted" do rendered.should match(/3/) end - it 'renders the description' do + it "renders the description" do rendered.should match(/This is a/) end - it 'renders markdown in the description' do - assert_select 'em', 'really' + it "renders markdown in the description" do + assert_select "em", "really" end it "doesn't contain a () if no location is set" do - rendered.should_not have_content '()' + rendered.should_not have_content "()" end end - context 'location set' do + context "location set" do before(:each) do planting.owner.update(location: 'Greenwich, UK') render diff --git a/spec/views/posts/_single.html.haml_spec.rb b/spec/views/posts/_single.html.haml_spec.rb index 9217d6729..a153995c5 100644 --- a/spec/views/posts/_single.html.haml_spec.rb +++ b/spec/views/posts/_single.html.haml_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'posts/_single' do +describe "posts/_single" do def render_post - render partial: 'single', locals: { post: @post } + render partial: "single", locals: { post: @post } end before(:each) do @@ -15,16 +15,16 @@ describe 'posts/_single' do render_post end - it 'contains a permanent link to post' do - assert_select "a[href='#{post_path @post}']", 'Permalink' + it "contains a permanent link to post" do + assert_select "a[href='#{post_path @post}']", "Permalink" 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 - context 'when logged in' do + context "when logged in" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -32,16 +32,16 @@ describe 'posts/_single' do render_post end - it 'contains link to new comment' do - assert_select('a', { href: new_comment_path(post_id: @post.id) }, 'Reply') + it "contains link to new comment" do + assert_select("a", { href: new_comment_path(post_id: @post.id) }, "Reply") end - it 'does not contain an edit link' do + it "does not contain an edit link" do assert_select "a[href='#{edit_post_path(@post)}']", false end end - context 'when logged in as post author' do + context "when logged in as post author" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -50,88 +50,88 @@ describe 'posts/_single' do render_post end - it 'contains an edit link' do - assert_select "a[href='#{edit_post_path(@post)}']", 'Edit' + it "contains an edit link" do + assert_select "a[href='#{edit_post_path(@post)}']", "Edit" end end - context 'when there are no comments' do + context "when there are no comments" do before(:each) do render_post end - it 'renders the number of comments' do - assert_select "a[href='#{post_path(@post)}\#comments']", '0 comments' + it "renders the number of comments" do + assert_select "a[href='#{post_path(@post)}\#comments']", "0 comments" end end - context 'when there is 1 comment' do + context "when there is 1 comment" do before(:each) do @comment = FactoryBot.create(:comment, post: @post) render_post end - it 'renders the number of comments' do - assert_select "a[href='#{post_path(@post)}\#comments']", '1 comment' + it "renders the number of comments" do + assert_select "a[href='#{post_path(@post)}\#comments']", "1 comment" end end - context 'when there are 2 comments' do + context "when there are 2 comments" do before(:each) do @comment = FactoryBot.create(:comment, post: @post) @comment2 = FactoryBot.create(:comment, post: @post) render_post end - it 'renders the number of comments' do - assert_select "a[href='#{post_path(@post)}\#comments']", '2 comments' + it "renders the number of comments" do + assert_select "a[href='#{post_path(@post)}\#comments']", "2 comments" end end - context 'when comments should be hidden' do + context "when comments should be hidden" do before(:each) do @member = FactoryBot.create(:member) sign_in @member controller.stub(:current_user) { @member } @comment = FactoryBot.create(:comment, post: @post) - render partial: 'single', locals: { + render partial: "single", locals: { post: @post, hide_comments: true } end - it 'renders no value of comments' do - rendered.should_not have_content '1 comment' + it "renders no value of comments" do + rendered.should_not have_content "1 comment" end - it 'does not contain link to post' do + it "does not contain link to post" do assert_select "a[href='#{post_path @post}']", false end - it 'does not contain link to new comment' do + it "does not contain link to new comment" do assert_select "a[href='#{new_comment_path(post_id: @post.id)}']", false end end - context 'when post has been edited' do + context "when post has been edited" do before(:each) do @member = FactoryBot.create(:member) sign_in @member controller.stub(:current_user) { @member } @post = FactoryBot.create(:post, author: @member) - @post.update(body: 'I am updated') + @post.update(body: "I am updated") render_post end - it 'shows edited at' do - rendered.should have_content 'edited at' + it "shows edited at" do + rendered.should have_content "edited at" end - it 'shows the updated time' do + it "shows the updated time" do rendered.should have_content @post.updated_at end end - context 'when comment has been edited' do + context "when comment has been edited" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -139,19 +139,19 @@ describe 'posts/_single' do @post = FactoryBot.create(:post, author: @member) @comment = FactoryBot.create(:comment, post: @post) @comment.update(body: "I've been updated") - render partial: 'comments/single', locals: { comment: @comment } + render partial: "comments/single", locals: { comment: @comment } end - it 'shows edited at time' do - rendered.should have_content 'edited at' + it "shows edited at time" do + rendered.should have_content "edited at" end - it 'shows updated time' do + it "shows updated time" do rendered.should have_content @comment.updated_at end end - context 'when post has not been edited' do + context "when post has not been edited" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -161,12 +161,12 @@ describe 'posts/_single' do render_post end - it 'does not show edited at' do + it "does not show edited at" do rendered.should_not have_content "edited at #{@post.updated_at}" end end - context 'when comment has not been edited' do + context "when comment has not been edited" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -174,10 +174,10 @@ describe 'posts/_single' do @post = FactoryBot.create(:post, author: @member) @comment = FactoryBot.create(:comment, post: @post) @comment.update(updated_at: @comment.created_at) - render partial: 'comments/single', locals: { comment: @comment } + render partial: "comments/single", locals: { comment: @comment } end - it 'does not show edited at' do + it "does not show edited at" do rendered.should_not have_content "edited at #{@comment.updated_at}" end end diff --git a/spec/views/posts/edit.html.haml_spec.rb b/spec/views/posts/edit.html.haml_spec.rb index 6867185c3..48d64a267 100644 --- a/spec/views/posts/edit.html.haml_spec.rb +++ b/spec/views/posts/edit.html.haml_spec.rb @@ -1,34 +1,34 @@ require 'rails_helper' -describe 'posts/edit' do +describe "posts/edit" do before(:each) do controller.stub(:current_user) { nil } @author = FactoryBot.create(:member) @post = assign(:post, FactoryBot.create(:post, author: @author)) end - context 'logged in' do + context "logged in" do before(:each) do sign_in @author render 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]' + 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]" end end it 'no hidden forum field' do - assert_select 'input#post_forum_id[type=hidden]', false + assert_select "input#post_forum_id[type=hidden]", false end it 'no forum mentioned' do - rendered.should_not have_content 'This post will be posted in the forum' + rendered.should_not have_content "This post will be posted in the forum" end - context 'forum specified' do + context "forum specified" do before(:each) do @forum = assign(:forum, FactoryBot.create(:forum)) assign(:post, FactoryBot.create(:post, diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb index ca924a855..eeebac8b6 100644 --- a/spec/views/posts/index.html.haml_spec.rb +++ b/spec/views/posts/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'posts/index' do +describe "posts/index" do before(:each) do controller.stub(:current_user) { nil } @author = FactoryBot.create(:member) @@ -17,19 +17,19 @@ describe 'posts/index' do render 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-body', - text: 'This is some text.'.to_s, count: 2 + 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-body", + 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 + it "contains two gravatar icons" do + 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') + 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') end end diff --git a/spec/views/posts/index.rss.haml_spec.rb b/spec/views/posts/index.rss.haml_spec.rb index 23fd0a4b8..3d4ec11f2 100644 --- a/spec/views/posts/index.rss.haml_spec.rb +++ b/spec/views/posts/index.rss.haml_spec.rb @@ -1,6 +1,6 @@ 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 = FactoryBot.create(:member) @@ -11,11 +11,11 @@ describe 'posts/index.rss.haml', type: 'view' do end it 'shows RSS feed title' do - rendered.should have_content 'Recent posts from all members' + rendered.should have_content "Recent posts from all members" end it 'shows content of posts' do - rendered.should have_content 'This is some text.' + rendered.should have_content "This is some text." end it 'gives the author in the item title' do diff --git a/spec/views/posts/new.html.haml_spec.rb b/spec/views/posts/new.html.haml_spec.rb index 37e251bea..fa344e55b 100644 --- a/spec/views/posts/new.html.haml_spec.rb +++ b/spec/views/posts/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'posts/new' do +describe "posts/new" do before(:each) do @author = FactoryBot.create(:member) assign(:post, FactoryBot.create(:post, author: @author)) @@ -9,22 +9,22 @@ describe 'posts/new' do controller.stub(:current_user) { @author } end - it 'renders new post form' 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 it 'no hidden forum field' do render - assert_select 'input#post_forum_id[type=hidden]', false + assert_select "input#post_forum_id[type=hidden]", false end it 'no forum mentioned' do render - rendered.should_not have_content 'This post will be posted in the forum' + rendered.should_not have_content "This post will be posted in the forum" end it "asks what's going on in your garden" do @@ -32,7 +32,7 @@ describe 'posts/new' do rendered.should have_content "What's going on in your food garden?" end - context 'forum specified' do + context "forum specified" do before(:each) do @forum = assign(:forum, FactoryBot.create(:forum)) assign(:post, FactoryBot.create(:post, forum: @forum)) diff --git a/spec/views/posts/show.html.haml_spec.rb b/spec/views/posts/show.html.haml_spec.rb index e29fb3f1b..ba6921e4e 100644 --- a/spec/views/posts/show.html.haml_spec.rb +++ b/spec/views/posts/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'posts/show' do +describe "posts/show" do subject { rendered } let(:author) { FactoryBot.create(:member) } @@ -11,7 +11,7 @@ describe 'posts/show' do describe 'render post' do before { render } - describe 'basic post' do + describe "basic post" do let(:post) { FactoryBot.create(:post, author: author) } # show the name of the member who posted the post @@ -23,17 +23,17 @@ describe 'posts/show' do it { is_expected.not_to have_text('An Update') } end - describe 'should parse markdown into html' do + describe "should parse markdown into html" do let(:post) { FactoryBot.create(:markdown_post, author: author) } - it { assert_select 'strong', 'strong' } + it { assert_select "strong", "strong" } end describe "shouldn't let html through in body" do let(:post) { FactoryBot.create(:post, author: author, body: 'EVIL') } it { is_expected.to have_content('EVIL') } - it { is_expected.not_to have_link('http://evil.com') } + it { is_expected.not_to have_link("http://evil.com") } end describe 'script tag in post body' do let(:post) { FactoryBot.create(:post, author: author, body: "") } @@ -53,7 +53,7 @@ describe 'posts/show' do end end - context 'when there is one comment' do + context "when there is one comment" do let(:post) { FactoryBot.create(:html_post, author: author) } let!(:comment) { FactoryBot.create(:comment, post: post) } @@ -63,10 +63,10 @@ describe 'posts/show' do end it 'shows comment count only 1' do - assert_select 'div.post_comments', false + assert_select "div.post_comments", false end - it 'shows comments' do + it "shows comments" do is_expected.to have_content comment.body end @@ -75,36 +75,36 @@ describe 'posts/show' do end end - context 'when there is more than one comment' do + context "when there is more than one comment" do let(:post) { FactoryBot.create(:html_post, author: author) } before(:each) do - @comment1 = FactoryBot.create(:comment, post: post, body: 'F1rst!!!', + @comment1 = FactoryBot.create(:comment, post: post, body: "F1rst!!!", created_at: Date.new(2010, 5, 17)) - @comment3 = FactoryBot.create(:comment, post: post, body: 'Th1rd!!!', + @comment3 = FactoryBot.create(:comment, post: post, body: "Th1rd!!!", created_at: Date.new(2012, 5, 17)) - @comment4 = FactoryBot.create(:comment, post: post, body: 'F0urth!!!') - @comment2 = FactoryBot.create(:comment, post: post, body: 'S3c0nd!!1!', + @comment4 = FactoryBot.create(:comment, post: post, body: "F0urth!!!") + @comment2 = FactoryBot.create(:comment, post: post, body: "S3c0nd!!1!", created_at: Date.new(2011, 5, 17)) @comments = post.comments render end - it 'shows the oldest comments first' do + it "shows the oldest comments first" do is_expected.to have_content(/#{@comment1.body}.*#{@comment2.body}.*#{@comment3.body}.*#{@comment4.body}/m) end end - context 'forum post' do + context "forum post" do let(:post) { FactoryBot.create(:forum_post, author: author) } before { render } - it 'shows forum name' do + it "shows forum name" do is_expected.to have_content "in #{post.forum.name}" end end - context 'signed in' do + context "signed in" do let(:post) { FactoryBot.create(:post, author: author) } before(:each) do @@ -114,7 +114,7 @@ describe 'posts/show' do end it 'shows a comment button' do - is_expected.to have_link 'Comment', href: new_comment_path(post_id: post.id) + is_expected.to have_link "Comment", href: new_comment_path(post_id: post.id) end end end diff --git a/spec/views/posts/show.rss.haml_spec.rb b/spec/views/posts/show.rss.haml_spec.rb index f952c6e70..c22c4196f 100644 --- a/spec/views/posts/show.rss.haml_spec.rb +++ b/spec/views/posts/show.rss.haml_spec.rb @@ -25,6 +25,6 @@ describe 'posts/show.rss.haml' do end it 'shows content of comments' do - rendered.should have_content 'OMG LOL' + rendered.should have_content "OMG LOL" end end diff --git a/spec/views/products/edit.html.haml_spec.rb b/spec/views/products/edit.html.haml_spec.rb deleted file mode 100644 index 568445d72..000000000 --- a/spec/views/products/edit.html.haml_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'rails_helper' - -describe 'products/edit' do - before(:each) do - @product = assign(:product, stub_model(Product, - name: 'MyString', - description: 'MyString', - min_price: '9.99')) - end - - it 'renders the edit product form' 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]' - end - end -end diff --git a/spec/views/products/index.html.haml_spec.rb b/spec/views/products/index.html.haml_spec.rb deleted file mode 100644 index c92e2dc02..000000000 --- a/spec/views/products/index.html.haml_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'rails_helper' - -describe 'products/index' do - before(:each) do - @product = FactoryBot.create(:product) - assign(:products, [@product, @product]) - end - - 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.to_s, count: 2 - end -end diff --git a/spec/views/products/new.html.haml_spec.rb b/spec/views/products/new.html.haml_spec.rb deleted file mode 100644 index f4b596eaf..000000000 --- a/spec/views/products/new.html.haml_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'rails_helper' - -describe 'products/new' do - before(:each) do - assign(:product, stub_model(Product, - name: 'MyString', - description: 'MyString', - min_price: '9.99').as_new_record) - end - - it 'renders new product form' 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]' - end - end -end diff --git a/spec/views/products/show.html.haml_spec.rb b/spec/views/products/show.html.haml_spec.rb deleted file mode 100644 index 243eae01b..000000000 --- a/spec/views/products/show.html.haml_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -describe 'products/show' do - before(:each) do - @product = assign(:product, FactoryBot.create(:product)) - end - - it 'renders attributes in

' do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should have_content @product.name - rendered.should have_content @product.min_price.to_s - rendered.should have_content @product.recommended_price.to_s - end -end diff --git a/spec/views/roles/edit.html.haml_spec.rb b/spec/views/roles/edit.html.haml_spec.rb index 28a5283f2..a86f67ceb 100644 --- a/spec/views/roles/edit.html.haml_spec.rb +++ b/spec/views/roles/edit.html.haml_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' -describe 'roles/edit' do +describe "roles/edit" do before(:each) do @role = assign(:role, stub_model(Role, - name: 'MyString', - description: 'MyText')) + name: "MyString", + description: "MyText")) end - it 'renders the edit role form' do + it "renders the edit role form" 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 232b750df..e4b28e9ba 100644 --- a/spec/views/roles/index.html.haml_spec.rb +++ b/spec/views/roles/index.html.haml_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -describe 'roles/index' do +describe "roles/index" do before(:each) 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 - it 'renders a list of roles' 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 d11424840..1cdce8c41 100644 --- a/spec/views/roles/new.html.haml_spec.rb +++ b/spec/views/roles/new.html.haml_spec.rb @@ -1,19 +1,19 @@ require 'rails_helper' -describe 'roles/new' do +describe "roles/new" do before(:each) do assign(:role, stub_model(Role, - name: 'MyString', - description: 'MyText').as_new_record) + name: "MyString", + description: "MyText").as_new_record) end - it 'renders new role form' do + it "renders new role form" 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 2d3ea832f..56f1cc4fb 100644 --- a/spec/views/roles/show.html.haml_spec.rb +++ b/spec/views/roles/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'roles/show' do +describe "roles/show" do before(:each) do @role = assign(:role, stub_model(Role, - name: 'Name', - description: 'MyText')) + name: "Name", + description: "MyText")) end - it 'renders attributes in

' do + it "renders attributes in

" do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should match(/Name/) diff --git a/spec/views/scientific_names/edit.html.haml_spec.rb b/spec/views/scientific_names/edit.html.haml_spec.rb index 081e5a548..ecaa2056f 100644 --- a/spec/views/scientific_names/edit.html.haml_spec.rb +++ b/spec/views/scientific_names/edit.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe 'scientific_names/edit' do - context 'logged in' do +describe "scientific_names/edit" do + context "logged in" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -11,14 +11,14 @@ describe 'scientific_names/edit' do render end - it 'shows the creator' do + it "shows the creator" do rendered.should have_content "Added by #{@scientific_name.creator} less than a minute ago." 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_name', name: 'scientific_name[scientific_name]' - assert_select 'select#scientific_name_crop_id', name: 'scientific_name[crop_id]' + 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_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 682b7078d..4d63ac9e1 100644 --- a/spec/views/scientific_names/index.html.haml_spec.rb +++ b/spec/views/scientific_names/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'scientific_names/index' do +describe "scientific_names/index" do before(:each) do controller.stub(:current_user) { nil } assign(:scientific_names, [ @@ -9,29 +9,29 @@ describe 'scientific_names/index' do ]) end - it 'renders a list of scientific_names' 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 render - rendered.should_not have_content 'Edit' - rendered.should_not have_content 'Delete' + rendered.should_not have_content "Edit" + rendered.should_not have_content "Delete" end - context 'logged in and crop wrangler' do + context "logged in and crop wrangler" do before(:each) do @member = FactoryBot.create(:crop_wrangling_member) sign_in @member controller.stub(:current_user) { @member } end - it 'shows edit/destroy links' do + it "shows edit/destroy links" do render - rendered.should have_content 'Edit' - rendered.should have_content 'Delete' + rendered.should have_content "Edit" + rendered.should have_content "Delete" end end end diff --git a/spec/views/scientific_names/new.html.haml_spec.rb b/spec/views/scientific_names/new.html.haml_spec.rb index a7ad30252..0cf5a4205 100644 --- a/spec/views/scientific_names/new.html.haml_spec.rb +++ b/spec/views/scientific_names/new.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'scientific_names/new' do +describe "scientific_names/new" do before(:each) do assign(:scientific_name, FactoryBot.create(:zea_mays)) end - context 'logged in' do + context "logged in" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -13,12 +13,12 @@ describe 'scientific_names/new' do render end - it 'renders new scientific_name form' 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_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_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/show.html.haml_spec.rb b/spec/views/scientific_names/show.html.haml_spec.rb index 85d3be9ba..b728df2b3 100644 --- a/spec/views/scientific_names/show.html.haml_spec.rb +++ b/spec/views/scientific_names/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'scientific_names/show' do +describe "scientific_names/show" do before(:each) do controller.stub(:current_user) { nil } @scientific_name = assign(:scientific_name, FactoryBot.create(:zea_mays)) end - it 'renders attributes in

' do + it "renders attributes in

" do render # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should match(/Zea mays/) diff --git a/spec/views/seeds/edit.html.haml_spec.rb b/spec/views/seeds/edit.html.haml_spec.rb index 14e604816..f450d7065 100644 --- a/spec/views/seeds/edit.html.haml_spec.rb +++ b/spec/views/seeds/edit.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'seeds/edit' do +describe "seeds/edit" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -8,23 +8,23 @@ describe 'seeds/edit' do @seed = FactoryBot.create(:seed, owner: @member) end - it 'renders the edit seed form' do + 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 = FactoryBot.create(:tradable_seed, owner: @member) - @seed.tradable_to.should_not eq 'nowhere' + @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/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb index bfb6e27c4..4df8e526c 100644 --- a/spec/views/seeds/index.rss.haml_spec.rb +++ b/spec/views/seeds/index.rss.haml_spec.rb @@ -14,7 +14,7 @@ describe 'seeds/index.rss.haml' do end it 'shows RSS feed title' do - rendered.should have_content 'Recent seeds from all members' + rendered.should have_content "Recent seeds from all members" end it 'has a useful item title' do diff --git a/spec/views/seeds/new.html.haml_spec.rb b/spec/views/seeds/new.html.haml_spec.rb index 0270d831c..5c5cf3ae4 100644 --- a/spec/views/seeds/new.html.haml_spec.rb +++ b/spec/views/seeds/new.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'seeds/new' do +describe "seeds/new" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -9,21 +9,21 @@ describe 'seeds/new' do assign(:seed, @seed1) end - it 'renders new seed form' do + 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 @@ -43,7 +43,7 @@ describe 'seeds/new' do it 'links to change location' do render - assert_select 'a', text: 'Change your location.' + assert_select "a", text: "Change your location." end end end diff --git a/spec/views/seeds/show.html.haml_spec.rb b/spec/views/seeds/show.html.haml_spec.rb index 854b87e2c..fd2848f97 100644 --- a/spec/views/seeds/show.html.haml_spec.rb +++ b/spec/views/seeds/show.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'seeds/show' do +describe "seeds/show" do before(:each) do controller.stub(:current_user) { nil } @seed = FactoryBot.create(:seed) @@ -8,12 +8,12 @@ describe 'seeds/show' do assign(:photos, @seed.photos.paginate(page: 1)) end - it 'renders attributes in

' do + it "renders attributes in

" do render rendered.should have_content @seed.crop.name end - context 'tradable' do + context "tradable" do before(:each) do @owner = FactoryBot.create(:london_member) assign(:seed, FactoryBot.create(:tradable_seed, @@ -24,12 +24,12 @@ describe 'seeds/show' do controller.stub(:current_user) { @member } end - it 'shows tradable attributes' do + it "shows tradable attributes" do render - rendered.should have_content 'Will trade: locally' + rendered.should have_content "Will trade: locally" end - it 'shows location of seed owner' do + it "shows location of seed owner" do render rendered.should have_content @owner.location assert_select 'a', href: place_path(@owner.location) @@ -45,18 +45,18 @@ describe 'seeds/show' do it 'says "from unspecified location"' do render - rendered.should have_content '(from unspecified location)' + rendered.should have_content "(from unspecified location)" end - it 'links to profile to set location' 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 - it 'shows button to send message' do + it "shows button to send message" do render - rendered.should have_content 'Request seeds' + rendered.should have_content "Request seeds" end end end diff --git a/spec/views/shop/index_spec.rb b/spec/views/shop/index_spec.rb deleted file mode 100644 index a23320f44..000000000 --- a/spec/views/shop/index_spec.rb +++ /dev/null @@ -1,82 +0,0 @@ -require 'rails_helper' - -describe 'shop/index.html.haml', type: 'view' do - before(:each) do - @product1 = FactoryBot.create(:product) - @product2 = FactoryBot.create(:product_with_recommended_price) - assign(:products, [@product1, @product2]) - assign(:order_item, OrderItem.new) - end - - context 'signed in' do - before(:each) do - @member = FactoryBot.create(:member) - controller.stub(:current_user) { @member } - render - end - - it 'shows products' do - assert_select('h2', text: @product1.name) - end - - it 'shows prices in configured currency' do - rendered.should have_content format('9.99 %s', Growstuff::Application.config.currency) - end - - it 'should contain an exchange rate link' do - currency = Growstuff::Application.config.currency - assert_select("a[href='http://www.wolframalpha.com/input/?i=9.99+#{currency}']") - end - - it 'shows recommended price for products that have it' do - rendered.should have_content format('12.00 %s', Growstuff::Application.config.currency) - end - - it 'should contain an exchange rate link for recommended price' do - currency = Growstuff::Application.config.currency - assert_select("a[href='http://www.wolframalpha.com/input/?i=12.00+#{currency}']") - end - - it 'displays the order form' do - assert_select 'form', count: 2 - end - - it 'renders markdown in product descriptions' do - assert_select 'em', text: 'hurrah', count: 2 - end - end - - context 'is paid' do - before(:each) do - @member = FactoryBot.create(:member) - @member.account.account_type = FactoryBot.create(:paid_account_type) - @member.account.paid_until = Time.zone.now + 1.year - controller.stub(:current_member) { @member } - end - - it 'recognises the paid member' do - @member.paid?.should be(true) - end - - it 'tells you you have a paid membership' do - render - rendered.should have_content 'You currently have a paid' - end - - it "doesn't show shop" do - render - assert_select 'form', false - end - end - - context 'signed out' do - before(:each) do - controller.stub(:current_user) { nil } - render - end - - it 'tells you to sign up/sign in' do - rendered.should have_content 'sign in or sign up' - end - end -end