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 = '
' 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