From 7e1e2bef9133a8ed6a9dfc6921e242b00d1e21fa Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 13:40:29 +1300 Subject: [PATCH 1/6] Removing shop, products, accounts, orders --- .rubocop_todo.yml | 2 - app/controllers/account_types_controller.rb | 53 ----- app/controllers/accounts_controller.rb | 31 --- app/controllers/admin/orders_controller.rb | 23 --- app/controllers/order_items_controller.rb | 36 ---- app/controllers/orders_controller.rb | 90 -------- app/controllers/products_controller.rb | 46 ----- app/controllers/shop_controller.rb | 19 -- app/models/ability.rb | 25 --- app/models/account.rb | 23 --- app/models/account_type.rb | 13 -- app/models/member.rb | 35 +--- app/models/order.rb | 90 -------- app/models/order_item.rb | 12 -- app/models/product.rb | 15 -- app/views/account_types/_form.html.haml | 21 -- app/views/account_types/edit.html.haml | 7 - app/views/account_types/index.html.haml | 23 --- app/views/account_types/new.html.haml | 5 - app/views/account_types/show.html.haml | 17 -- app/views/accounts/_form.html.haml | 21 -- app/views/accounts/edit.html.haml | 7 - app/views/accounts/index.html.haml | 23 --- app/views/accounts/new.html.haml | 5 - app/views/accounts/show.html.haml | 15 -- app/views/admin/index.html.haml | 7 - app/views/admin/orders/_searchform.html.haml | 8 - app/views/admin/orders/index.html.haml | 3 - app/views/admin/orders/search.html.haml | 41 ---- app/views/layouts/_header.html.haml | 2 - app/views/members/_account.html.haml | 24 --- app/views/members/_roles.html.haml | 9 + app/views/members/show.html.haml | 4 +- app/views/orders/complete.html.haml | 45 ---- app/views/orders/index.html.haml | 44 ---- app/views/orders/show.html.haml | 84 -------- app/views/products/_form.html.haml | 32 --- app/views/products/edit.html.haml | 7 - app/views/products/index.html.haml | 29 --- app/views/products/new.html.haml | 5 - app/views/products/show.html.haml | 25 --- app/views/shared/_account_status.html.haml | 13 -- app/views/shop/index.html.haml | 83 -------- config/application.rb | 3 - config/locales/en.yml | 10 - config/routes.rb | 17 +- db/migrate/20180205000612_remove_shop.rb | 9 + db/schema.rb | 48 +---- db/seeds.rb | 50 ----- lib/tasks/growstuff.rake | 73 ------- .../account_types_controller_spec.rb | 31 --- spec/controllers/accounts_controller_spec.rb | 18 -- .../admin/orders_controller_spec.rb | 18 -- .../order_items_controller_spec.rb | 51 ----- spec/controllers/orders_controller_spec.rb | 53 ----- spec/controllers/products_controller_spec.rb | 17 -- spec/controllers/shop_controller_spec.rb | 36 ---- spec/factories/account_types.rb | 33 --- spec/factories/accounts.rb | 7 - spec/factories/order_items.rb | 10 - spec/factories/orders.rb | 14 -- spec/factories/products.rb | 15 -- spec/features/admin/account_types_spec.rb | 58 ------ spec/features/admin/products_spec.rb | 44 ---- spec/features/member_profile_spec.rb | 5 - spec/features/members/deletion_spec.rb | 11 - spec/models/ability_spec.rb | 195 ------------------ spec/models/account_spec.rb | 27 --- spec/models/account_type_spec.rb | 4 - spec/models/member_spec.rb | 92 --------- spec/models/order_item_spec.rb | 26 --- spec/models/order_spec.rb | 133 ------------ spec/models/product_spec.rb | 8 - spec/routing/account_types_routing_spec.rb | 33 --- spec/routing/order_items_routing_spec.rb | 33 --- spec/routing/orders_routing_spec.rb | 33 --- spec/routing/products_routing_spec.rb | 33 --- .../account_types/edit.html.haml_spec.rb | 21 -- .../account_types/index.html.haml_spec.rb | 14 -- .../views/account_types/new.html.haml_spec.rb | 21 -- .../account_types/show.html.haml_spec.rb | 18 -- spec/views/accounts/edit.html.haml_spec.rb | 18 -- spec/views/accounts/index.html.haml_spec.rb | 15 -- spec/views/accounts/new.html.haml_spec.rb | 18 -- spec/views/accounts/show.html.haml_spec.rb | 16 -- spec/views/admin/index_spec.rb | 2 - spec/views/admin/orders/index_spec.rb | 20 -- spec/views/orders/index.html.haml_spec.rb | 23 --- spec/views/orders/show.html.haml_spec.rb | 69 ------- spec/views/products/edit.html.haml_spec.rb | 22 -- spec/views/products/index.html.haml_spec.rb | 16 -- spec/views/products/new.html.haml_spec.rb | 24 --- spec/views/products/show.html.haml_spec.rb | 15 -- spec/views/shop/index_spec.rb | 82 -------- 94 files changed, 22 insertions(+), 2762 deletions(-) delete mode 100644 app/controllers/account_types_controller.rb delete mode 100644 app/controllers/accounts_controller.rb delete mode 100644 app/controllers/admin/orders_controller.rb delete mode 100644 app/controllers/order_items_controller.rb delete mode 100644 app/controllers/orders_controller.rb delete mode 100644 app/controllers/products_controller.rb delete mode 100644 app/controllers/shop_controller.rb delete mode 100644 app/models/account.rb delete mode 100644 app/models/account_type.rb delete mode 100644 app/models/order.rb delete mode 100644 app/models/order_item.rb delete mode 100644 app/models/product.rb delete mode 100644 app/views/account_types/_form.html.haml delete mode 100644 app/views/account_types/edit.html.haml delete mode 100644 app/views/account_types/index.html.haml delete mode 100644 app/views/account_types/new.html.haml delete mode 100644 app/views/account_types/show.html.haml delete mode 100644 app/views/accounts/_form.html.haml delete mode 100644 app/views/accounts/edit.html.haml delete mode 100644 app/views/accounts/index.html.haml delete mode 100644 app/views/accounts/new.html.haml delete mode 100644 app/views/accounts/show.html.haml delete mode 100644 app/views/admin/orders/_searchform.html.haml delete mode 100644 app/views/admin/orders/index.html.haml delete mode 100644 app/views/admin/orders/search.html.haml delete mode 100644 app/views/members/_account.html.haml create mode 100644 app/views/members/_roles.html.haml delete mode 100644 app/views/orders/complete.html.haml delete mode 100644 app/views/orders/index.html.haml delete mode 100644 app/views/orders/show.html.haml delete mode 100644 app/views/products/_form.html.haml delete mode 100644 app/views/products/edit.html.haml delete mode 100644 app/views/products/index.html.haml delete mode 100644 app/views/products/new.html.haml delete mode 100644 app/views/products/show.html.haml delete mode 100644 app/views/shared/_account_status.html.haml delete mode 100644 app/views/shop/index.html.haml create mode 100644 db/migrate/20180205000612_remove_shop.rb delete mode 100644 spec/controllers/account_types_controller_spec.rb delete mode 100644 spec/controllers/accounts_controller_spec.rb delete mode 100644 spec/controllers/admin/orders_controller_spec.rb delete mode 100644 spec/controllers/order_items_controller_spec.rb delete mode 100644 spec/controllers/orders_controller_spec.rb delete mode 100644 spec/controllers/products_controller_spec.rb delete mode 100644 spec/controllers/shop_controller_spec.rb delete mode 100644 spec/factories/account_types.rb delete mode 100644 spec/factories/accounts.rb delete mode 100644 spec/factories/order_items.rb delete mode 100644 spec/factories/orders.rb delete mode 100644 spec/factories/products.rb delete mode 100644 spec/features/admin/account_types_spec.rb delete mode 100644 spec/features/admin/products_spec.rb delete mode 100644 spec/models/account_spec.rb delete mode 100644 spec/models/account_type_spec.rb delete mode 100644 spec/models/order_item_spec.rb delete mode 100644 spec/models/order_spec.rb delete mode 100644 spec/models/product_spec.rb delete mode 100644 spec/routing/account_types_routing_spec.rb delete mode 100644 spec/routing/order_items_routing_spec.rb delete mode 100644 spec/routing/orders_routing_spec.rb delete mode 100644 spec/routing/products_routing_spec.rb delete mode 100644 spec/views/account_types/edit.html.haml_spec.rb delete mode 100644 spec/views/account_types/index.html.haml_spec.rb delete mode 100644 spec/views/account_types/new.html.haml_spec.rb delete mode 100644 spec/views/account_types/show.html.haml_spec.rb delete mode 100644 spec/views/accounts/edit.html.haml_spec.rb delete mode 100644 spec/views/accounts/index.html.haml_spec.rb delete mode 100644 spec/views/accounts/new.html.haml_spec.rb delete mode 100644 spec/views/accounts/show.html.haml_spec.rb delete mode 100644 spec/views/admin/orders/index_spec.rb delete mode 100644 spec/views/orders/index.html.haml_spec.rb delete mode 100644 spec/views/orders/show.html.haml_spec.rb delete mode 100644 spec/views/products/edit.html.haml_spec.rb delete mode 100644 spec/views/products/index.html.haml_spec.rb delete mode 100644 spec/views/products/new.html.haml_spec.rb delete mode 100644 spec/views/products/show.html.haml_spec.rb delete mode 100644 spec/views/shop/index_spec.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4e0d899c7..9c3ccad34 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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' 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/order_items_controller.rb b/app/controllers/order_items_controller.rb deleted file mode 100644 index 326cff21f..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 3bc9fe45c..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/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/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/models/ability.rb b/app/models/ability.rb index 283bf45cc..89a304257 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -24,14 +24,9 @@ class Ability # except these, which don't make sense if you're not logged in cannot :read, Notification cannot :read, Authentication - cannot :read, Order - cannot :read, OrderItem # and nobody should be able to view this except admins cannot :read, Role - cannot :read, Product - cannot :read, Account - cannot :read, AccountType # nobody should be able to view unapproved crops unless they # are wranglers or admins @@ -120,20 +115,6 @@ class Ability can :update, Seed, owner_id: member.id can :destroy, Seed, owner_id: member.id - # orders/shop/etc - can :create, Order - can :read, Order, member_id: member.id - can :complete, Order, member_id: member.id, completed_at: nil - can :checkout, Order, member_id: member.id, completed_at: nil - can :cancel, Order, member_id: member.id, completed_at: nil - can :destroy, Order, member_id: member.id, completed_at: nil - - can :create, OrderItem - # for now, let's not let people mess with individual order items - cannot :read, OrderItem, order: { member_id: member.id } - cannot :update, OrderItem, order: { member_id: member.id, completed_at: nil } - cannot :destroy, OrderItem, order: { member_id: member.id, completed_at: nil } - # following/unfollowing permissions can :create, Follow cannot :create, Follow, followed_id: member.id # can't follow yourself @@ -148,12 +129,6 @@ class Ability can :read, :all can :manage, :all - # can't change order history, because it's *history* - cannot :create, Order - cannot :complete, Order - cannot :destroy, Order - cannot :manage, OrderItem - # can't delete plant parts if they have harvests associated with them cannot :destroy, PlantPart can :destroy, PlantPart do |pp| diff --git a/app/models/account.rb b/app/models/account.rb deleted file mode 100644 index 646e9db78..000000000 --- a/app/models/account.rb +++ /dev/null @@ -1,23 +0,0 @@ -class Account < ActiveRecord::Base - belongs_to :member - belongs_to :account_type - - validates :member_id, uniqueness: { - message: 'already has account details associated with it' - } - - before_create do |account| - unless account.account_type - account.account_type = AccountType.find_or_create_by(name: - Growstuff::Application.config.default_account_type) - end - end - - def paid_until_string - if account_type.is_permanent_paid - "forever" - elsif account_type.is_paid - paid_until.to_s - end - end -end diff --git a/app/models/account_type.rb b/app/models/account_type.rb deleted file mode 100644 index 06416751a..000000000 --- a/app/models/account_type.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AccountType < ActiveRecord::Base - # - # Relationships - has_many :products - - # - # Validations - validates :name, presence: true, uniqueness: true - - def to_s - name - end -end diff --git a/app/models/member.rb b/app/models/member.rb index 9828a005c..e7601f43d 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -7,7 +7,7 @@ class Member < ActiveRecord::Base friendly_id :login_name, use: %i(slugged finders) # - # Relationshops + # Relationships has_many :posts, foreign_key: 'author_id' has_many :comments, foreign_key: 'author_id' has_many :forums, foreign_key: 'owner_id' @@ -19,9 +19,6 @@ class Member < ActiveRecord::Base has_many :notifications, foreign_key: 'recipient_id' has_many :sent_notifications, foreign_key: 'sender_id' has_many :authentications - has_many :orders - has_one :account - has_one :account_type, through: :account has_many :photos has_many :requested_crops, class_name: Crop, foreign_key: 'requester_id' has_many :likes, dependent: :destroy @@ -79,11 +76,9 @@ class Member < ActiveRecord::Base after_save :update_newsletter_subscription # Give each new member a default garden - # and an account record (for paid accounts etc) # we use find_or_create to avoid accidentally creating a second one, # which can happen sometimes especially with FactoryBot associations after_create { |member| Garden.create(name: "Garden", owner_id: member.id) } - after_create { |member| Account.find_or_create_by(member_id: member.id) } # allow login via either login_name or email address def self.find_first_by_auth_conditions(warden_conditions) @@ -101,34 +96,6 @@ class Member < ActiveRecord::Base roles.any? { |r| r.name.gsub(/\s+/, "_").underscore.to_sym == role_sym } end - def current_order - orders.find_by(completed_at: nil) - end - - # when purchasing a product that gives you a paid account, this method - # does all the messing around to actually make sure the account is - # updated correctly -- account type, paid until, etc. Usually this is - # called by order.update_account, which loops through all order items - # and does this for each one. - def update_account_after_purchase(product) - account.account_type = product.account_type if product.account_type - if product.paid_months - start_date = account.paid_until || Time.zone.now - account.paid_until = start_date + product.paid_months.months - end - account.save - end - - def paid? - if account.account_type.is_permanent_paid - true - elsif account.account_type.is_paid && account.paid_until >= Time.zone.now - true - else - false - end - end - def auth(provider) authentications.find_by(provider: provider) end diff --git a/app/models/order.rb b/app/models/order.rb deleted file mode 100644 index 53a309c35..000000000 --- a/app/models/order.rb +++ /dev/null @@ -1,90 +0,0 @@ -class Order < ActiveRecord::Base - # - # Relationships - belongs_to :member, with_deleted: true - has_many :order_items, dependent: :destroy - - # - # Validations - validates :referral_code, format: { - with: /\A[a-zA-Z0-9 ]*\z/, - message: "may only include letters and numbers" - } - - # - # Teiggers - before_save :standardize_referral_code - - # - # Scopes - scope :by_member, ->(member) { where(member: member) } - - # total price of an order - def total - sum = 0 - order_items.each do |i| - subtotal = i.price * i.quantity - sum += subtotal - end - sum - end - - # return items in the format ActiveMerchant/PayPal want them - def activemerchant_items - items = [] - order_items.each do |i| - items.push(name: i.product.name, - quantity: i.quantity, - amount: i.price) - end - items - end - - # record the paypal details for reference - def record_paypal_details(token) - self.paypal_express_token = token - details = EXPRESS_GATEWAY.details_for(token) - self.paypal_express_payer_id = details.payer_id - save - end - - # when an order is completed, we update the member's account to mark - # them as paid, or whatever, based on what products they ordered - def update_account - order_items.each do |i| - member.update_account_after_purchase(i.product) - end - end - - # removes whitespace and forces to uppercase (we're somewhat liberal - # in what we accept, but we clean it up anyway.) - def standardize_referral_code - self.referral_code = referral_code.upcase.gsub(/\s/, '') if referral_code - end - - # search orders (used by admin/orders) - # usage: Order.search({ :by => 'member', :for => 'Skud' }) - # can search by: member, order_id, paypal_token, paypal_payer_id, - def self.search(args = {}) - if args[:for] - case args[:by] - when "member" - member = Member.with_deleted.find_by(login_name: args[:for]) - return member.orders if member - when "order_id" - order = Order.find_by(id: args[:for]) - return [order] if order - when "paypal_token" - order = Order.find_by(paypal_express_token: args[:for]) - return [order] if order - when "paypal_payer_id" - order = Order.find_by(paypal_express_payer_id: args[:for]) - return [order] if order - when "referral_code" - # coerce to uppercase - return Order.where(referral_code: args[:for].upcase) - end - end - [] - end -end diff --git a/app/models/order_item.rb b/app/models/order_item.rb deleted file mode 100644 index 380fbff58..000000000 --- a/app/models/order_item.rb +++ /dev/null @@ -1,12 +0,0 @@ -class OrderItem < ActiveRecord::Base - belongs_to :order - belongs_to :product - - validate :price_must_be_greater_than_minimum - validates :order_id, uniqueness: { message: "may only have one item." } - - def price_must_be_greater_than_minimum - @product = Product.find(product_id) - errors.add(:price, "must be greater than the product's minimum value") if price < @product.min_price - end -end diff --git a/app/models/product.rb b/app/models/product.rb deleted file mode 100644 index 01b5a8902..000000000 --- a/app/models/product.rb +++ /dev/null @@ -1,15 +0,0 @@ -class Product < ActiveRecord::Base - # - # Relationships - belongs_to :account_type - has_and_belongs_to_many :orders # rubocop:disable Rails/HasAndBelongsToMany - - # - # Validations - validates :paid_months, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } - validates :min_price, presence: true - - def to_s - name - end -end diff --git a/app/views/account_types/_form.html.haml b/app/views/account_types/_form.html.haml deleted file mode 100644 index 5bfbb539a..000000000 --- a/app/views/account_types/_form.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -= form_for @account_type do |f| - - if @account_type.errors.any? - #error_explanation - %h2 - = pluralize(@account_type.errors.size, "error") - prohibited this account_type from being saved: - %ul - - @account_type.errors.full_messages.each do |msg| - %li= msg - - .field - = f.label :name - = f.text_field :name - .field - = f.label :is_paid - = f.check_box :is_paid - .field - = f.label :is_permanent_paid - = f.check_box :is_permanent_paid - .actions - = f.submit 'Save' diff --git a/app/views/account_types/edit.html.haml b/app/views/account_types/edit.html.haml deleted file mode 100644 index c994c4ff1..000000000 --- a/app/views/account_types/edit.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -- content_for :title, "Editing account type" - -= render 'form' - -= link_to 'Show', @account_type -\| -= link_to 'Back', account_types_path diff --git a/app/views/account_types/index.html.haml b/app/views/account_types/index.html.haml deleted file mode 100644 index 6af6d129d..000000000 --- a/app/views/account_types/index.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -- content_for :title, "Listing account types" - -%table - %tr - %th Name - %th Is paid - %th Is permanent paid - %th - %th - %th - - - @account_types.each do |account_type| - %tr - %td= account_type.name - %td= account_type.is_paid - %td= account_type.is_permanent_paid - %td= link_to 'Show', account_type - %td= link_to 'Edit', edit_account_type_path(account_type) - %td= link_to 'Destroy', account_type, method: :delete, data: { confirm: 'Are you sure?' } - -%br - -= link_to 'New Account type', new_account_type_path diff --git a/app/views/account_types/new.html.haml b/app/views/account_types/new.html.haml deleted file mode 100644 index 92d309715..000000000 --- a/app/views/account_types/new.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -- content_for :title, "New account type" - -= render 'form' - -= link_to 'Back', account_types_path diff --git a/app/views/account_types/show.html.haml b/app/views/account_types/show.html.haml deleted file mode 100644 index a3f7f690b..000000000 --- a/app/views/account_types/show.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -%p#notice= notice - -%p - %b Name: - = @account_type.name -%p - %b Is paid: - = @account_type.is_paid -%p - %b Is permanent paid: - = @account_type.is_permanent_paid - -= link_to 'Edit', edit_account_type_path(@account_type) -\| -= link_to 'Delete', @account_type, method: :delete, data: { confirm: 'Are you sure?' } -\| -= link_to 'Back', account_types_path diff --git a/app/views/accounts/_form.html.haml b/app/views/accounts/_form.html.haml deleted file mode 100644 index 410b717fa..000000000 --- a/app/views/accounts/_form.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -= form_for @account do |f| - - if @account.errors.any? - #error_explanation - %h2 - = pluralize(@account.errors.size, "error") - prohibited this account from being saved: - %ul - - @account.errors.full_messages.each do |msg| - %li= msg - - .field - = f.label :member_id - = f.number_field :member_id - .field - = f.label :account_type - = f.text_field :account_type - .field - = f.label :paid_until - = f.datetime_select :paid_until - .actions - = f.submit 'Save' diff --git a/app/views/accounts/edit.html.haml b/app/views/accounts/edit.html.haml deleted file mode 100644 index ef8d08801..000000000 --- a/app/views/accounts/edit.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -- content_for :title, "Editing account" - -= render 'form' - -= link_to 'Show', @account -\| -= link_to 'Back', accounts_path diff --git a/app/views/accounts/index.html.haml b/app/views/accounts/index.html.haml deleted file mode 100644 index 8d929dd0f..000000000 --- a/app/views/accounts/index.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -- content_for :title, "Listing accounts" - -%table - %tr - %th Member - %th Account type - %th Paid until - %th - %th - %th - - - @accounts.each do |account| - %tr - %td= account.member_id - %td= account.account_type - %td= account.paid_until - %td= link_to 'Show', account - %td= link_to 'Edit', edit_account_path(account) - %td= link_to 'Destroy', account, method: :delete, data: { confirm: 'Are you sure?' } - -%br - -= link_to 'New Account detail', new_account_path diff --git a/app/views/accounts/new.html.haml b/app/views/accounts/new.html.haml deleted file mode 100644 index 9430cc2ed..000000000 --- a/app/views/accounts/new.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -- content_for :title, "New account" - -= render 'form' - -= link_to 'Back', accounts_path diff --git a/app/views/accounts/show.html.haml b/app/views/accounts/show.html.haml deleted file mode 100644 index 5c5288674..000000000 --- a/app/views/accounts/show.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -%p#notice= notice - -%p - %b Member: - = @account.member_id -%p - %b Account type: - = @account.account_type.name -%p - %b Paid until: - = @account.paid_until - -= link_to 'Edit', edit_account_path(@account) -\| -= link_to 'Back', accounts_path diff --git a/app/views/admin/index.html.haml b/app/views/admin/index.html.haml index 294e16199..e7b164280 100644 --- a/app/views/admin/index.html.haml +++ b/app/views/admin/index.html.haml @@ -6,8 +6,6 @@ .col-md-4 %h2 Site admin %ul#site_admin - %li= link_to "Account types", account_types_path - %li= link_to "Products", products_path %li= link_to "Roles", roles_path %li= link_to "Forums", forums_path %li= link_to "CMS", comfy_admin_cms_path @@ -22,8 +20,3 @@ %ul %li= link_to "Newsletter subscribers", admin_newsletter_path %li= link_to "Members", admin_members_path - -.row - .col-md-12 - %h2 Orders - = render "admin/orders/searchform" diff --git a/app/views/admin/orders/_searchform.html.haml b/app/views/admin/orders/_searchform.html.haml deleted file mode 100644 index e0a4dc22c..000000000 --- a/app/views/admin/orders/_searchform.html.haml +++ /dev/null @@ -1,8 +0,0 @@ -= form_tag(url_for(controller: 'admin/orders', action: 'search'), method: :get, class: 'form-inline') do - = label_tag :distance, "Search orders:", class: 'control-label' - = text_field_tag :search_text - = select_tag :search_by, - options_for_select('Member': 'member', 'Referral code': 'referral_code', - 'Order ID': 'order_id', 'Paypal Token': 'paypal_token', - 'Paypal Payer ID': 'paypal_payer_id') - = submit_tag "Search", class: 'btn btn-primary' diff --git a/app/views/admin/orders/index.html.haml b/app/views/admin/orders/index.html.haml deleted file mode 100644 index e5f67f6c3..000000000 --- a/app/views/admin/orders/index.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -- content_for :title, 'Admin Orders' - -= render "admin/orders/searchform" diff --git a/app/views/admin/orders/search.html.haml b/app/views/admin/orders/search.html.haml deleted file mode 100644 index 23c93d01a..000000000 --- a/app/views/admin/orders/search.html.haml +++ /dev/null @@ -1,41 +0,0 @@ -- content_for :title, 'Search Orders' - -= render "admin/orders/searchform" - -- unless @orders.empty? - %h2 - Found - = pluralize(@orders.size, "result") - - %table.table.table-striped - %tr - %th Member - %th Order number - %th Date completed - %th Referral code - %th Items - %th - - - @orders.each do |order| - %tr - %td - = link_to order.member.login_name, order.member - = "(deleted)" if order.member.deleted_at - %td= order.id - %td - - if order.completed_at - = order.completed_at.to_s - - else - In progress - %td - = order.referral_code - %td - - unless order.order_items.empty? - - order.order_items.each do |o| - = o.quantity - x - = o.product.name - @ - = price_with_currency(o.price) - %br/ - %td= link_to 'Details', order, class: 'btn btn-default btn-xs' diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 3eb0d8ca0..d2b8fd01c 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -47,7 +47,6 @@ %li= link_to t('.browse_members'), members_path %li= link_to t('.posts'), posts_path %li= link_to t('.forums'), forums_path - %li= link_to t('.support_growstuff'), shop_path - if member_signed_in? %li.dropdown< @@ -64,7 +63,6 @@ %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) - %li= link_to t('.account'), orders_path %li - if current_member.notifications.unread_count.positive? = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), diff --git a/app/views/members/_account.html.haml b/app/views/members/_account.html.haml deleted file mode 100644 index cda792ace..000000000 --- a/app/views/members/_account.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -%h3 Account details - -%p - %strong Member since: - = member.created_at.to_s(:date) - -%p - %strong Account type: - = member.account_type - account - -%p - %strong Last Login: - = member.last_sign_in_at - -%p - %strong Member Roles: - %br - - if member.role? :admin - Administrator - - if member.role? :crop_wrangler - Crop Wrangler - - else - Member diff --git a/app/views/members/_roles.html.haml b/app/views/members/_roles.html.haml new file mode 100644 index 000000000..cbfd0b576 --- /dev/null +++ b/app/views/members/_roles.html.haml @@ -0,0 +1,9 @@ +%p + %strong Member Roles: + %br + - if member.role? :admin + Administrator + - if member.role? :crop_wrangler + Crop Wrangler + - unless (member.role?(:admin) || member.role?(:crop_wrangler)) + Member diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index f0214a52f..478574b3b 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -10,8 +10,6 @@ - content_for :buttonbar do - if can? :update, @member = link_to 'Edit profile', edit_member_registration_path, class: 'btn btn-default' - - if @member == current_member && !@member.paid? - = link_to "Upgrade account", shop_path, class: 'btn btn-default' - if can?(:create, Notification) && current_member != @member = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default' @@ -33,7 +31,7 @@ = render partial: "gardens", locals: { member: @member, gardens: @gardens } .col-md-3 = render partial: "avatar", locals: { member: @member } - = render partial: "account", locals: { member: @member } + = render partial: "roles", locals: { member: @member } = render partial: "stats", locals: { member: @member } = render partial: "contact", locals: { member: @member, twitter_auth: @twitter_auth, diff --git a/app/views/orders/complete.html.haml b/app/views/orders/complete.html.haml deleted file mode 100644 index e2f4b97ad..000000000 --- a/app/views/orders/complete.html.haml +++ /dev/null @@ -1,45 +0,0 @@ -- content_for :title, "Completed order" - -%p Thank you for your order. - -%p - %strong Completed at: - = @order.completed_at - -%p - %strong Order number: - = @order.id - -= render "shared/account_status" - -%h2 Order items - -%table.table.table-striped - %tr - %th Product - %th Price - %th Quantity - %th Subtotal - - total = 0 - - @order.order_items.each do |i| - %tr - %td= i.product.name - %td - = price_with_currency(i.price) - %td= i.quantity - %td - - subtotal = i.price * i.quantity - - total += subtotal - = price_with_currency(subtotal) - - %tr - %td - %td - %td - %strong Total: - %td - %strong - = price_with_currency(total) - -%p - = link_to "View other orders/order history", orders_path diff --git a/app/views/orders/index.html.haml b/app/views/orders/index.html.haml deleted file mode 100644 index b4741c44e..000000000 --- a/app/views/orders/index.html.haml +++ /dev/null @@ -1,44 +0,0 @@ -- content_for :title, "Your Account" - -= render "shared/account_status" - - -%h2 Orders - - -- if current_member.orders.present? - - %p - Your order history shows what you have bought via our - = succeed "." do - = link_to "shop", shop_path - - %table.table.table-striped - %tr - %th Order number - %th Date completed - %th Items - %th - - @orders.each do |order| - %tr - %td= order.id - %td - - if order.completed_at - = order.completed_at.to_s - - else - In progress - %td - - unless order.order_items.empty? - - order.order_items.each do |o| - = o.quantity - x - = o.product.name - @ - = price_with_currency(o.price) - %br/ - %td= link_to 'Details', order, class: 'btn btn-default btn-xs' -- else - %p - You have not made any orders. You can place an order via our - = succeed "." do - = link_to "shop", shop_path diff --git a/app/views/orders/show.html.haml b/app/views/orders/show.html.haml deleted file mode 100644 index 0998407f9..000000000 --- a/app/views/orders/show.html.haml +++ /dev/null @@ -1,84 +0,0 @@ -- content_for :title, @order.completed_at ? "Order details (##{@order.id})" : "Current order" - -%p - %strong Order number: - = @order.id - -%p - %strong Ordered by: - = link_to @order.member, @order.member - -%p - %strong Date begun: - = @order.created_at.to_s - -- if @order.completed_at - %p - %strong Date completed: - = @order.completed_at.to_s - -- if @order.referral_code - %p - %strong Referral code: - = @order.referral_code - -- if current_member.role? :admin - %p - %strong Paypal Express token: - = @order.paypal_express_token - %p - %strong Paypal Express payer ID: - = @order.paypal_express_payer_id - -%h2 Order items - -%table.table.table-striped - %tr - %th Product - %th Price - %th Quantity - %th Subtotal - - @order.order_items.each do |i| - %tr - %td= i.product.name - %td - = price_with_currency(i.price) - %td= i.quantity - %td - - subtotal = i.price * i.quantity - = price_with_currency(subtotal) - - %tr - %td - %td - %td - %strong Total: - %td - %strong - = price_with_currency(@order.total) - = forex_link(@order.total) - -- if @order.errors.any? - .alert - #error_explanation - %h3 - = pluralize(@order.errors.size, "error") - stopped you from checking out: - %ul - - @order.errors.full_messages.each do |msg| - %li= msg - -- if can?(:complete, @order) || can?(:destroy, @order) - = form_tag(checkout_order_path(@order), method: :get, class: 'form-inline') do - %p - - if can? :complete, @order - = label_tag :referral_code, "Do you have a referral code?" - = text_field_tag :referral_code, @order.referral_code, class: 'input-medium' - = submit_tag "Checkout with PayPal", class: 'btn btn-primary' - - if can? :destroy, @order - = link_to 'Delete this order', @order, method: :delete, - data: { confirm: 'Are you sure?' }, - class: 'btn btn-default' - = link_to "View other orders/order history", orders_path, class: 'btn btn-default' - -%p diff --git a/app/views/products/_form.html.haml b/app/views/products/_form.html.haml deleted file mode 100644 index a3aa8a2f0..000000000 --- a/app/views/products/_form.html.haml +++ /dev/null @@ -1,32 +0,0 @@ -= form_for @product do |f| - - if @product.errors.any? - #error_explanation - %h2 - = pluralize(@product.errors.size, "error") - prohibited this product from being saved: - %ul - - @product.errors.full_messages.each do |msg| - %li= msg - - .field - = f.label :name - = f.text_field :name, class: 'form-control' - .field - = f.label :description - = f.text_area :description, class: 'form-control' - .field - = f.label :min_price, "Minimum price (in cents)" - = f.text_field :min_price - .field - = f.label :recommended_price, "Recommended price (in cents)" - = f.text_field :recommended_price - .field - = f.label :account_type - = collection_select(:product, :account_type_id, AccountType.all, :id, - :name, selected: @product.account_type_id) - .field - = f.label :paid_months - = f.text_field :paid_months - .form-group - .actions - = f.submit 'Save' diff --git a/app/views/products/edit.html.haml b/app/views/products/edit.html.haml deleted file mode 100644 index 84ebcb870..000000000 --- a/app/views/products/edit.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -- content_for :title, "Editing product" - -= render 'form' - -= link_to 'Show', @product -\| -= link_to 'Back', products_path diff --git a/app/views/products/index.html.haml b/app/views/products/index.html.haml deleted file mode 100644 index 4945d130e..000000000 --- a/app/views/products/index.html.haml +++ /dev/null @@ -1,29 +0,0 @@ -- content_for :title, "Listing products" - -%table - %tr - %th Name - %th Description - %th Min price - %th Recommended price - %th Account type - %th Paid months - %th - %th - %th - - - @products.each do |product| - %tr - %td= product.name - %td= product.description - %td= product.min_price - %td= product.recommended_price - %td= product.account_type ? product.account_type.name : "" - %td= product.paid_months - %td= link_to 'Show', product - %td= link_to 'Edit', edit_product_path(product) - %td= link_to 'Destroy', product, method: :delete, data: { confirm: 'Are you sure?' } - -%br - -= link_to 'New Product', new_product_path diff --git a/app/views/products/new.html.haml b/app/views/products/new.html.haml deleted file mode 100644 index 57b944d9a..000000000 --- a/app/views/products/new.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -- content_for :title, "New product" - -= render 'form' - -= link_to 'Back', products_path diff --git a/app/views/products/show.html.haml b/app/views/products/show.html.haml deleted file mode 100644 index 61b35519f..000000000 --- a/app/views/products/show.html.haml +++ /dev/null @@ -1,25 +0,0 @@ -%p#notice= notice - -%p - %b Name: - = @product.name -%p - %b Description: - :growstuff_markdown - #{strip_tags(@product.description)} -%p - %b Min price: - = @product.min_price -%p - %b Recommended price: - = @product.recommended_price -%p - %b Account type: - = @product.account_type.name -%p - %b Paid months: - = @product.paid_months - -= link_to 'Edit', edit_product_path(@product) -\| -= link_to 'Back', products_path diff --git a/app/views/shared/_account_status.html.haml b/app/views/shared/_account_status.html.haml deleted file mode 100644 index a39870956..000000000 --- a/app/views/shared/_account_status.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -%h2 Your current account status - -%p - %strong Account type: - = current_member.account_type.name - -- if current_member.account.paid_until_string - %p - %strong Paid until: - = current_member.account.paid_until_string - -- unless current_member.paid? - = link_to "Upgrade and support #{ENV['GROWSTUFF_SITE_NAME']}", shop_path, class: 'btn btn-primary' diff --git a/app/views/shop/index.html.haml b/app/views/shop/index.html.haml deleted file mode 100644 index 6266050f0..000000000 --- a/app/views/shop/index.html.haml +++ /dev/null @@ -1,83 +0,0 @@ -- content_for :title, t('.title') - -%p - Growstuff relies on your support to build and run this open source - platform for food growers. We do not have outside investment, and do - not accept ads. Instead, we offer paid memberships, which give you - access to premium features, and ensure that we focus our efforts on - keeping you, our members, happy. - -%p - We are currently developing a number of advanced features for paid - members. We will announce our progress on these in our - = link_to "Feedback and Support forum", "http://www.growstuff.org/forums/growstuff-feedback-support" - as well as via other channels. - -%p - All our accounts are priced on a sliding scale. You can choose how - much you want to pay. Remember, your subscription supports an open - source, open data platform supporting home food growers and promoting - sustainable food systems! - -- if current_member && current_member.paid? - %h2 Thank you for supporting Growstuff - - %p You currently have a paid membership, and can't buy another one at this time. - - = render "shared/account_status" - -- elsif @order && !@order.order_items.empty? - %h2 Your current order - - %p - You currently have the following item in your cart: - %strong - = @most_recent_item.product - @ - = price_with_currency(@most_recent_item.price) - - %p - = link_to "View order and checkout", order_path(@order) - or - = succeed "." do - = link_to 'delete this order', @order, method: :delete, - data: { confirm: 'Are you sure?' } - -- else - - @products.each do |p| - %h2= p.name - - %div - :growstuff_markdown - #{ strip_tags p.description } - - %p - Pay what you want, starting at - = succeed "." do - = price_with_currency(p.min_price) - = forex_link(p.min_price) - - if p.recommended_price - Recommended price: - = succeed "." do - = price_with_currency(p.recommended_price) - = forex_link(p.recommended_price) - - %div - - if can? :create, Order - - = form_for @order_item do |f| - .field - = f.text_field :price, value: price_in_dollars(p.recommended_price || p.min_price) - .field - = f.hidden_field :product_id, value: p.id - .field - = f.hidden_field :quantity, value: 1 - .actions - = f.submit 'Buy', class: 'btn btn-primary' - - - else - Please - = link_to "sign in", new_member_session_path - or - = link_to "sign up", new_member_registration_path - to purchase. diff --git a/config/application.rb b/config/application.rb index 5280dce7e..ae8d6e95f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -44,9 +44,6 @@ module Growstuff # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" - # Configure a default account type - config.default_account_type = "Free" - # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] diff --git a/config/locales/en.yml b/config/locales/en.yml index d2848cecd..d5d3364a6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,11 +1,5 @@ --- en: - account: - update: Account detail was successfully updated. - account_types: - created: Account type was successfully created. - deleted: Account type was successfully deleted. - updated: Account type was successfully updated. activerecord: models: comment: @@ -99,7 +93,6 @@ en: open: ad_free_linktext: ad-free api_docs_linktext: API documentation - buy_account_linktext: buying a paid account creative_commons_linktext: Creative Commons license get_involved_body_html: > We believe in collaboration, and work closely with our members and the wider food-growing community. @@ -213,9 +206,6 @@ en: default: Everyone's seeds owner_seeds: "%{owner} seeds" string: "%{crop} seeds belonging to %{owner}" - shop: - index: - title: Shop unauthorized: create: all: Please sign in or sign up to create a %{subject}. diff --git a/config/routes.rb b/config/routes.rb index f1588fa17..777536e38 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -72,17 +72,6 @@ Growstuff::Application.routes.draw do get '/places/search' => 'places#search', as: 'search_places' get '/places/:place' => 'places#show', as: 'place' - # everything for paid accounts etc - resources :account_types - resources :accounts - resources :orders - get 'orders/:id/checkout' => 'orders#checkout', as: 'checkout_order' - get 'orders/:id/complete' => 'orders#complete', as: 'complete_order' - get 'orders/:id/cancel' => 'orders#cancel', as: 'cancel_order' - - resources :order_items - resources :products - resources :likes, only: %i(create destroy) get "home/index" @@ -91,15 +80,11 @@ Growstuff::Application.routes.draw do get 'auth/:provider/callback' => 'authentications#create' get 'members/auth/:provider/callback' => 'authentications#create' - get '/shop' => 'shop#index' - get '/shop/:action' => 'shop#:action' - comfy_route :cms_admin, path: '/admin/cms' namespace :admin do resources :members end - get '/admin/orders' => 'admin/orders#index' - get '/admin/orders/:action' => 'admin/orders#:action' + get '/admin' => 'admin#index' get '/admin/newsletter' => 'admin#newsletter', as: :admin_newsletter get '/admin/:action' => 'admin#:action' diff --git a/db/migrate/20180205000612_remove_shop.rb b/db/migrate/20180205000612_remove_shop.rb new file mode 100644 index 000000000..fa0fc8793 --- /dev/null +++ b/db/migrate/20180205000612_remove_shop.rb @@ -0,0 +1,9 @@ +class RemoveShop < ActiveRecord::Migration + def up + drop_table :order_items + drop_table :orders + drop_table :products + drop_table :account_types + drop_table :accounts + end +end diff --git a/db/schema.rb b/db/schema.rb index be74dabfc..c38e122e9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,27 +11,11 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180118112809) do +ActiveRecord::Schema.define(version: 20180205000612) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "account_types", force: :cascade do |t| - t.string "name", null: false - t.boolean "is_paid" - t.boolean "is_permanent_paid" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "accounts", force: :cascade do |t| - t.integer "member_id", null: false - t.integer "account_type_id" - t.datetime "paid_until" - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "alternate_names", force: :cascade do |t| t.string "name", null: false t.integer "crop_id", null: false @@ -359,25 +343,6 @@ ActiveRecord::Schema.define(version: 20180118112809) do t.datetime "updated_at" end - create_table "order_items", force: :cascade do |t| - t.integer "order_id" - t.integer "product_id" - t.integer "price" - t.integer "quantity" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "orders", force: :cascade do |t| - t.datetime "created_at" - t.datetime "updated_at" - t.datetime "completed_at" - t.integer "member_id" - t.string "paypal_express_token" - t.string "paypal_express_payer_id" - t.string "referral_code" - end - create_table "orders_products", id: false, force: :cascade do |t| t.integer "order_id" t.integer "product_id" @@ -461,17 +426,6 @@ ActiveRecord::Schema.define(version: 20180118112809) do add_index "posts", ["created_at", "author_id"], name: "index_posts_on_created_at_and_author_id", using: :btree add_index "posts", ["slug"], name: "index_posts_on_slug", unique: true, using: :btree - create_table "products", force: :cascade do |t| - t.string "name", null: false - t.text "description", null: false - t.integer "min_price", null: false - t.datetime "created_at" - t.datetime "updated_at" - t.integer "account_type_id" - t.integer "paid_months" - t.integer "recommended_price" - end - create_table "roles", force: :cascade do |t| t.string "name", null: false t.text "description" diff --git a/db/seeds.rb b/db/seeds.rb index be885a352..703113be3 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -7,12 +7,9 @@ def load_data Crop.transaction do # for all Growstuff sites, including production ones load_roles - load_basic_account_types create_cropbot load_crops load_plant_parts - load_paid_account_types - load_products # We don't load these in an environment except development to # prevent creating users in the wild - especially admins - with @@ -44,20 +41,6 @@ def load_roles @wrangler = Role.create(name: 'Crop Wrangler') end -def load_basic_account_types - puts "Adding 'free' and 'staff' account types..." - AccountType.create!( - name: "Free", - is_paid: false, - is_permanent_paid: false - ) - AccountType.create!( - name: "Staff", - is_paid: true, - is_permanent_paid: true - ) -end - def load_test_users # rubocop:disable Metrics/AbcSize puts "Loading test users..." @@ -141,39 +124,6 @@ def create_cropbot @cropbot_user.skip_confirmation! @cropbot_user.roles << @wrangler @cropbot_user.save! - @cropbot_user.account.account_type = AccountType.find_by(name: "Staff") - @cropbot_user.account.save -end - -def load_paid_account_types - puts "Adding 'paid' and 'seed' account types..." - @paid_account = AccountType.create!( - name: "Paid", - is_paid: true, - is_permanent_paid: false - ) - @seed_account = AccountType.create!( - name: "Seed", - is_paid: true, - is_permanent_paid: true - ) -end - -def load_products - puts "Adding products..." - Product.create!( - name: "Annual subscription", - description: "Paid account, 1 year", - min_price: 3000, - account_type_id: @paid_account.id, - paid_months: 12 - ) - Product.create!( - name: "Seed account", - description: "Paid account, in perpetuity", - min_price: 15_000, - account_type_id: @seed_account.id - ) end def load_plant_parts diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake index 03b2e3d0e..656330ea2 100644 --- a/lib/tasks/growstuff.rake +++ b/lib/tasks/growstuff.rake @@ -95,77 +95,6 @@ namespace :growstuff do end end - desc "June 2013: create account types and products." - task setup_shop: :environment do - puts "Adding account types..." - AccountType.find_or_create_by( - name: "Free", - is_paid: false, - is_permanent_paid: false - ) - @paid_account = AccountType.find_or_create_by( - name: "Paid", - is_paid: true, - is_permanent_paid: false - ) - @seed_account = AccountType.find_or_create_by( - name: "Seed", - is_paid: true, - is_permanent_paid: true - ) - @staff_account = AccountType.find_or_create_by( - name: "Staff", - is_paid: true, - is_permanent_paid: true - ) - - puts "Adding products..." - Product.find_or_create_by( - name: "Annual subscription", - description: "An annual subscription gives you access "\ - "to paid account features for one year. Does not auto-renew.", - min_price: 3000, - account_type_id: @paid_account.id, - paid_months: 12 - ) - Product.find_or_create_by( - name: "Seed account", - description: "A seed account helps Growstuff grow in its "\ - "early days. It gives you all the features of "\ - "a paid account, in perpetuity. This account "\ - "type never expires.", - min_price: 15_000, - account_type_id: @seed_account.id - ) - - puts "Giving each member an account record..." - Member.all.each do |m| - Account.create(member_id: m.id) unless m.account - end - - puts "Making Skud a staff account..." - @skud = Member.find_by(login_name: 'Skud') - if @skud - @skud.account.account_type = @staff_account - @skud.account.save - end - - puts "Done setting up shop." - end - - desc "June 2013: replace nil account_types with free accounts" - task nil_account_type: :environment do - free = AccountType.find_by(name: "Free") - raise "Free account type not found: run rake growstuff:oneoff:setup_shop"\ - unless free - Account.all.each do |a| - unless a.account_type - a.account_type = free - a.save - end - end - end - desc "July 2013: replace nil seed.tradable_to with nowhere" task tradable_to_nowhere: :environment do Seed.all.each do |s| @@ -187,8 +116,6 @@ namespace :growstuff do task set_default_crop_creator: :environment do cropbot = Member.find_by(login_name: "cropbot") raise "cropbot not found: create cropbot member on site or run rake db:seed" unless cropbot - cropbot.account.account_type = AccountType.find_by(name: "Staff") # set this just because it's nice - cropbot.account.save Crop.find_each do |crop| unless crop.creator crop.creator = cropbot diff --git a/spec/controllers/account_types_controller_spec.rb b/spec/controllers/account_types_controller_spec.rb deleted file mode 100644 index 010c8bf1f..000000000 --- a/spec/controllers/account_types_controller_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'rails_helper' - -describe AccountTypesController do - subject { response } - - context 'anon' do - describe '#index' do - before { get :index } - it { is_expected.not_to be_success } - end - end - context 'member' do - login_member(:member) - describe '#index' do - before { get :index } - it { is_expected.not_to be_success } - end - end - context 'admin' do - login_member(:admin_member) - describe '#index' do - let!(:aaa) { FactoryBot.create :account_type, name: 'aaa' } - let!(:zzz) { FactoryBot.create :account_type, name: 'zzz' } - - before { get :index } - it { is_expected.to be_success } - it { expect(assigns[:account_types].first).to eql(aaa) } - it { expect(assigns[:account_types].last).to eql(zzz) } - end - end -end diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb deleted file mode 100644 index 2b4222f1d..000000000 --- a/spec/controllers/accounts_controller_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -describe AccountsController do - login_member(:admin_member) - - def valid_attributes - { "paid_until" => Time.now } - end - - def create_account - # account details are automatically created when you create a new - # member; creating them manually will just cause errors as only one is - # allowed. This method has been left here in case it's useful in - # future. - member = FactoryBot.create(:member) - member.account - end -end diff --git a/spec/controllers/admin/orders_controller_spec.rb b/spec/controllers/admin/orders_controller_spec.rb deleted file mode 100644 index fb475b34c..000000000 --- a/spec/controllers/admin/orders_controller_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -describe Admin::OrdersController do - login_member(:admin_member) - - describe "GET search" do - it "assigns @orders" do - order = FactoryBot.create(:order) - get :search, search_by: 'order_id', search_text: order.id - assigns(:orders).should eq([order]) - end - - it "sets an error message if nothing found" do - get :search, search_by: 'order_id', search_text: 'foo' - flash[:alert].should have_text "Couldn't find order with" - end - end -end diff --git a/spec/controllers/order_items_controller_spec.rb b/spec/controllers/order_items_controller_spec.rb deleted file mode 100644 index 4de8eb98d..000000000 --- a/spec/controllers/order_items_controller_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'rails_helper' - -describe OrderItemsController do - login_member(:admin_member) - - let(:member) { FactoryBot.create(:member) } - let(:product) { FactoryBot.create(:product) } - let(:order) { FactoryBot.create(:order, member: member) } - let(:order_item) do - FactoryBot.create(:order_item, - order: order, - product: product, - price: product.min_price) - end - - context 'signed in' do - before { sign_in member } - - describe "POST create" do - describe "redirects to order" do - before do - post :create, order_item: { order_id: order.id, product_id: product.id, price: product.min_price } - end - it { expect(response).to redirect_to(OrderItem.last.order) } - it { expect(OrderItem.last.order).to be_an_instance_of Order } - end - - describe 'creates an order for you' do - it do - expect do - post :create, order_item: { - product_id: product.id, - price: product.min_price - } - end.to change(Order, :count).by(1) - end - end - - describe "with non-int price" do - it "converts 3.33 to 333 cents" do - order = FactoryBot.create(:order, member: member) - product = FactoryBot.create(:product, min_price: 1) - expect do - post :create, order_item: { order_id: order.id, product_id: product.id, price: 3.33 } - end.to change(OrderItem, :count).by(1) - OrderItem.last.price.should eq 333 - end - end - end - end -end diff --git a/spec/controllers/orders_controller_spec.rb b/spec/controllers/orders_controller_spec.rb deleted file mode 100644 index 3c6631d8c..000000000 --- a/spec/controllers/orders_controller_spec.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'rails_helper' - -describe OrdersController do - login_member(:admin_member) - - def valid_attributes - { "member_id" => 1 } - end - - def valid_session - {} - end - - describe "GET checkout" do - it 'sets the referral_code' do - member = FactoryBot.create(:member) - sign_in member - order = Order.create!(member_id: member.id) - get :checkout, id: order.to_param, referral_code: 'FOOBAR' - order.reload - order.referral_code.should eq 'FOOBAR' - end - - it "redirects to Paypal" do - member = FactoryBot.create(:member) - sign_in member - order = Order.create!(member_id: member.id) - get :checkout, id: order.to_param - response.status.should eq 302 - response.redirect_url.should match(/paypal\.com/) - end - end - - describe "GET complete" do - it "assigns the requested order as @order" do - member = FactoryBot.create(:member) - sign_in member - order = Order.create!(member_id: member.id) - get :complete, id: order.to_param - assigns(:order).should eq(order) - end - end - - describe "DELETE destroy" do - it "redirects to the shop" do - member = FactoryBot.create(:member) - sign_in member - order = Order.create!(member_id: member.id) - delete :destroy, id: order.id - response.should redirect_to(shop_url) - end - end -end diff --git a/spec/controllers/products_controller_spec.rb b/spec/controllers/products_controller_spec.rb deleted file mode 100644 index 173ef9ba4..000000000 --- a/spec/controllers/products_controller_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'rails_helper' - -describe ProductsController do - login_member(:admin_member) - - def valid_attributes - { - name: "product name", - description: 'some description', - min_price: 9.99 - } - end - - def valid_session - {} - end -end diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb deleted file mode 100644 index 2fc6b77f7..000000000 --- a/spec/controllers/shop_controller_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'rails_helper' - -describe ShopController do - let!(:product1) { FactoryBot.create(:product, name: 'aaa') } - let!(:product2) { FactoryBot.create(:product, name: 'zzz') } - - describe "GET index" do - describe 'not logged in' do - before { get :index, {} } - - describe "assigns all products as @products ordered by name" do - it { expect(assigns(:products)).to eq([product1, product2]) } - end - - describe "assigns a new @order_item to build forms" do - it { expect(assigns(:order_item)).to be_an_instance_of OrderItem } - end - - describe "assigns @order as nil if the user doesn't have one" do - it { expect(assigns(:order)).to be_nil } - end - end - describe 'logged in' do - describe "assigns @order as current_order if there is one" do - let(:member) { FactoryBot.create(:member) } - let!(:order) { FactoryBot.create(:order, member: member) } - - before do - sign_in member - get :index, {} - end - it { expect(assigns(:order)).to eq order } - end - end - end -end diff --git a/spec/factories/account_types.rb b/spec/factories/account_types.rb deleted file mode 100644 index 66717492f..000000000 --- a/spec/factories/account_types.rb +++ /dev/null @@ -1,33 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - factory :account_type do - name { Faker::Name.unique.name } - is_paid false - is_permanent_paid false - - factory :free_account_type do - name "Free" - is_paid false - is_permanent_paid false - end - - factory :paid_account_type do - name "Paid" - is_paid true - is_permanent_paid false - end - - factory :permanent_paid_account_type do - name "Permanent paid" - is_paid true - is_permanent_paid true - end - - factory :staff_account_type do - name "Staff" - is_paid true - is_permanent_paid true - end - end -end diff --git a/spec/factories/accounts.rb b/spec/factories/accounts.rb deleted file mode 100644 index fb4805964..000000000 --- a/spec/factories/accounts.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - # never do this directly. - # create a member then look at member.account_detail instead. - # (because it's auto-created, and there can only be one.) -end diff --git a/spec/factories/order_items.rb b/spec/factories/order_items.rb deleted file mode 100644 index 5dfba00ab..000000000 --- a/spec/factories/order_items.rb +++ /dev/null @@ -1,10 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - factory :order_item do - order - product - price "999" - quantity 42 - end -end diff --git a/spec/factories/orders.rb b/spec/factories/orders.rb deleted file mode 100644 index 514eb4a22..000000000 --- a/spec/factories/orders.rb +++ /dev/null @@ -1,14 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - factory :order do - member - factory :completed_order do - completed_at '2013-05-08 01:01:01' - end - - factory :referred_order do - referral_code 'CAMPAIGN1' - end - end -end diff --git a/spec/factories/products.rb b/spec/factories/products.rb deleted file mode 100644 index 444c8597d..000000000 --- a/spec/factories/products.rb +++ /dev/null @@ -1,15 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - factory :product do - name "annual subscription" - description "paid membership, renewing yearly, *hurrah*" - min_price "999" - account_type - paid_months 12 - - factory :product_with_recommended_price do - recommended_price "1200" - end - end -end diff --git a/spec/features/admin/account_types_spec.rb b/spec/features/admin/account_types_spec.rb deleted file mode 100644 index dac241586..000000000 --- a/spec/features/admin/account_types_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'rails_helper' - -feature "account types", js: true do - context "admin user" do - let(:member) { create :admin_member } - let(:account_type) { create :account_type } - - background do - login_as member - end - - scenario "navigating to account type admin with JavaScript on" do - visit root_path - # Extra click for the expandable login menu - click_link member.login_name - click_link "Admin" - expect(current_path).to eq admin_path - click_link "Account types" - expect(current_path).to eq account_types_path - end - - scenario "navigating to account type admin without JavaScript - Accessility version", js: false do - visit root_path - # Extra link not needed as menu is already expanded - click_link "Admin" - expect(current_path).to eq admin_path - click_link "Account types" - expect(current_path).to eq account_types_path - end - - scenario "adding an account type" do - visit account_types_path - click_link "New Account type" - expect(current_path).to eq new_account_type_path - fill_in 'Name', with: 'Guest' - click_button 'Save' - expect(current_path).to eq account_type_path(AccountType.last) - expect(page).to have_content 'Account type was successfully created' - end - - scenario 'editing account type' do - visit account_type_path account_type - click_link 'Edit' - fill_in 'Name', with: 'Something else' - click_button 'Save' - expect(current_path).to eq account_type_path(account_type) - expect(page).to have_content 'Account type was successfully updated' - expect(page).to have_content 'Something else' - end - - scenario 'deleting account type' do - visit account_type_path account_type - click_link 'Delete' - expect(current_path).to eq account_types_path - expect(page).to have_content 'Account type was successfully deleted' - end - end -end diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb deleted file mode 100644 index ca24daf83..000000000 --- a/spec/features/admin/products_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'rails_helper' - -feature "products" do - context "admin user" do - let(:member) { create :admin_member } - let(:product) { create :product } - - background do - login_as member - end - - scenario "navigating to product admin" do - visit admin_path - click_link "Products" - expect(current_path).to eq products_path - end - - scenario "adding a product" do - visit products_path - click_link "New Product" - expect(current_path).to eq new_product_path - fill_in 'Name', with: 'Special offer' - # note that failing to fill in a mandatory field has a messy error. - # This is not a priority defect but should be raised at some point. - fill_in 'Minimum price', with: '150' - click_button 'Save' - expect(current_path).to eq product_path(Product.last) - expect(page).to have_content 'Product was successfully created' - end - - scenario 'editing product' do - visit product_path product - click_link 'Edit' - fill_in 'Name', with: 'Something else' - click_button 'Save' - expect(current_path).to eq product_path(product) - expect(page).to have_content 'Product was successfully updated' - expect(page).to have_content 'Something else' - end - - scenario 'deleting product' - # this isn't possible. Should it be? - end -end diff --git a/spec/features/member_profile_spec.rb b/spec/features/member_profile_spec.rb index 32b11bda1..9f1005894 100644 --- a/spec/features/member_profile_spec.rb +++ b/spec/features/member_profile_spec.rb @@ -9,7 +9,6 @@ feature "member profile", js: true do expect(page).to have_css("h1", text: member.login_name) expect(page).to have_content member.bio expect(page).to have_content "Member since: #{member.created_at.to_s(:date)}" - expect(page).to have_content "Account type: Free account" expect(page).to have_content "#{member.login_name}'s gardens" expect(page).to have_link "More about this garden...", href: garden_path(member.gardens.first) end @@ -141,10 +140,6 @@ feature "member profile", js: true do scenario "has a button to edit profile" do expect(page).to have_link "Edit profile", href: edit_member_registration_path end - - scenario "has a button to upgrade account" do - expect(page).to have_link "Upgrade account", href: shop_path - end end context "someone else's profile page" do diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 793a6ada5..22b91a33b 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -10,7 +10,6 @@ feature "member deletion" do let!(:harvest) { FactoryBot.create(:harvest, owner: member) } let!(:seed) { FactoryBot.create(:seed, owner: member) } let!(:secondgarden) { FactoryBot.create(:garden, owner: member) } - let!(:order) { FactoryBot.create(:order, member: member, completed_at: Time.zone.now) } let(:admin) { FactoryBot.create(:admin_member) } background do @@ -115,16 +114,6 @@ feature "member deletion" do expect(page).to have_content "Member Deleted" end - scenario "leaves a record of orders and payments intact" do - login_as(admin) - visit admin_path - fill_in "search_text", with: member.login_name.to_s - find("#maincontainer").click_button("Search", exact: true) - expect(page).to have_content member.login_name.to_s - expect(page).to have_content "Found 1 result" - logout - end - scenario "can't be interesting" do expect(Member.interesting).not_to include(member) expect(Planting.interesting).not_to include(planting) diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index ef746c8bc..e95dfbdc6 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -71,201 +71,6 @@ describe Ability do end end - context "products" do - let(:product) { FactoryBot.create(:product) } - - context "standard member" do - it "can't read or manage products" do - ability.should_not be_able_to(:read, product) - ability.should_not be_able_to(:create, Product) - ability.should_not be_able_to(:update, product) - ability.should_not be_able_to(:destroy, product) - end - end - - context "admin" do - let(:role) { FactoryBot.create(:admin) } - - before do - member.roles << role - end - - it "has admin role" do - member.role?(:admin).should be true - end - - it "can read products" do - ability.should be_able_to(:read, product) - end - it "can create products" do - ability.should be_able_to(:create, Product) - end - it "can update products" do - ability.should be_able_to(:update, product) - end - it "can destroy products" do - ability.should be_able_to(:destroy, product) - end - end - end - - context "orders" do - let(:order) { FactoryBot.create(:order, member: member) } - let(:strangers_order) do - FactoryBot.create(:order, - member: FactoryBot.create(:member)) - end - let(:completed_order) do - FactoryBot.create(:completed_order, - member: member) - end - let(:order_item) { FactoryBot.create(:order_item, order: order) } - let(:strangers_order_item) do - FactoryBot.create(:order_item, - order: strangers_order) - end - let(:completed_order_item) do - FactoryBot.create(:order_item, - order: completed_order) - end - - context "standard member" do - it "can read their own orders" do - ability.should be_able_to(:read, order) - ability.should be_able_to(:read, completed_order) - end - - it "can't read other people's orders" do - ability.should_not be_able_to(:read, strangers_order) - end - - it "can create a new order" do - ability.should be_able_to(:create, Order) - end - - it "can complete their own current order" do - ability.should be_able_to(:complete, order) - end - - it "can't complete someone else's order" do - ability.should_not be_able_to(:complete, strangers_order) - end - - it "can't complete a completed order" do - ability.should_not be_able_to(:complete, completed_order) - end - - it "can delete a current order" do - ability.should be_able_to(:destroy, order) - end - - it "can't delete someone else's order" do - ability.should_not be_able_to(:destroy, strangers_order) - end - - it "can't delete a completed order" do - ability.should_not be_able_to(:destroy, completed_order) - end - - it "can't read their own order items" do - ability.should_not be_able_to(:read, order_item) - ability.should_not be_able_to(:read, completed_order_item) - end - - it "can't read other people's order items" do - ability.should_not be_able_to(:read, strangers_order_item) - end - - it "can create a new order item" do - ability.should be_able_to(:create, OrderItem) - end - - it "can't update their own order items" do - ability.should_not be_able_to(:update, order_item) - end - - it "can't update other people's order items" do - ability.should_not be_able_to(:update, strangers_order_item) - end - - it "can't updated items in completed orders" do - ability.should_not be_able_to(:update, completed_order_item) - end - - it "can't delete their own order item" do - ability.should_not be_able_to(:destroy, order_item) - end - - it "can't delete someone else's order item" do - ability.should_not be_able_to(:destroy, strangers_order_item) - end - - it "can't delete items from completed orders" do - ability.should_not be_able_to(:destroy, completed_order_item) - end - end - - context "admin" do - let(:role) { FactoryBot.create(:admin) } - - before do - member.roles << role - end - - it "has admin role" do - member.role?(:admin).should be true - end - - it "can read orders" do - ability.should be_able_to(:read, order) - end - - it "cannot create orders" do - ability.should_not be_able_to(:create, order) - end - - it "cannot complete orders" do - ability.should_not be_able_to(:complete, order) - end - - it "cannot delete orders" do - ability.should_not be_able_to(:destroy, order) - end - end - end - - context 'account details' do - let(:account) { member.account } - - context 'ordinary member' do - it "can't read account details" do - ability.should_not be_able_to(:read, account) - end - it "can't manage account details" do - ability.should_not be_able_to(:create, Account) - ability.should_not be_able_to(:update, account) - ability.should_not be_able_to(:destroy, account) - end - end - - context 'admin' do - let(:role) { FactoryBot.create(:admin) } - - before do - member.roles << role - end - - it "can read account details" do - ability.should be_able_to(:read, account) - end - it "can manage account details" do - ability.should be_able_to(:create, Account) - ability.should be_able_to(:update, account) - ability.should be_able_to(:destroy, account) - end - end - end - context 'plant parts' do let(:plant_part) { FactoryBot.create(:plant_part) } diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb deleted file mode 100644 index 15eb68084..000000000 --- a/spec/models/account_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'rails_helper' - -describe Account do - let(:member) { FactoryBot.create(:member) } - - it "auto-creates an account detail record when a member is created" do - member.account.should be_an_instance_of Account - end - - it "won't let you create two account details for the same member" do - @details = Account.new(member_id: member.id) - @details.should_not be_valid - end - - it "formats the 'paid until' date nicely" do - member.account.account_type = FactoryBot.create(:account_type) - member.account.paid_until_string.should eq nil - - member.account.account_type = FactoryBot.create(:permanent_paid_account_type) - member.account.paid_until_string.should eq "forever" - - member.account.account_type = FactoryBot.create(:paid_account_type) - @time = Time.zone.now - member.account.paid_until = @time - member.account.paid_until_string.should eq @time.to_s - end -end diff --git a/spec/models/account_type_spec.rb b/spec/models/account_type_spec.rb deleted file mode 100644 index c65c113ba..000000000 --- a/spec/models/account_type_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -describe AccountType do -end diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index cf7b81486..01d793ded 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -24,15 +24,6 @@ describe 'member' do member.gardens.size.should == 1 end - it 'should have a accounts entry' do - member.account.should be_an_instance_of Account - end - - it "should have a default-type account by default" do - member.account.account_type.name.should eq Growstuff::Application.config.default_account_type - member.paid?.should be(false) - end - it "doesn't show email by default" do member.show_email.should be(false) end @@ -294,89 +285,6 @@ describe 'member' do end end - context 'orders' do - it 'finds the current order' do - member = FactoryBot.create(:member) - FactoryBot.create(:completed_order, member: member) - order2 = FactoryBot.create(:order, member: member) - member.current_order.should eq order2 - end - - it "copes if there's no current order" do - member = FactoryBot.create(:member) - FactoryBot.create(:completed_order, member: member) - FactoryBot.create(:completed_order, member: member) - member.current_order.should be_nil - end - end - - context "paid accounts" do - let(:member) { FactoryBot.create(:member) } - - it "recognises a permanent paid account" do - account_type = FactoryBot.create(:account_type, - is_paid: true, is_permanent_paid: true) - member.account.account_type = account_type - member.paid?.should be(true) - end - - it "recognises a current paid account" do - account_type = FactoryBot.create(:account_type, - is_paid: true, is_permanent_paid: false) - member.account.account_type = account_type - member.account.paid_until = Time.zone.now + 1.month - member.paid?.should be(true) - end - - it "recognises an expired paid account" do - account_type = FactoryBot.create(:account_type, - is_paid: true, is_permanent_paid: false) - member.account.account_type = account_type - member.account.paid_until = Time.zone.now - 1.minute - member.paid?.should be(false) - end - - it "recognises a free account" do - account_type = FactoryBot.create(:account_type, - is_paid: false, is_permanent_paid: false) - member.account.account_type = account_type - member.paid?.should be(false) - end - - it "recognises a free account even with paid_until set" do - account_type = FactoryBot.create(:account_type, - is_paid: false, is_permanent_paid: false) - member.account.account_type = account_type - member.account.paid_until = Time.zone.now + 1.month - member.paid?.should be(false) - end - end - - context "update account" do - let(:product) do - FactoryBot.create(:product, - paid_months: 3) - end - let(:member) { FactoryBot.create(:member) } - - it "sets account_type" do - member.update_account_after_purchase(product) - member.account.account_type.should eq product.account_type - end - - it "sets paid_until" do - member.account.paid_until = nil # blank for now, as if never paid before - member.update_account_after_purchase(product) - - # stringify to avoid millisecond problems... - member.account.paid_until.to_s.should eq((Time.zone.now + 3.months).to_s) - - # and again to make sure it works for currently paid accounts - member.update_account_after_purchase(product) - member.account.paid_until.to_s.should eq((Time.zone.now + 3.months + 3.months).to_s) - end - end - context 'harvests' do it 'has harvests' do member = FactoryBot.create(:member) diff --git a/spec/models/order_item_spec.rb b/spec/models/order_item_spec.rb deleted file mode 100644 index 7c2de24c6..000000000 --- a/spec/models/order_item_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'rails_helper' - -describe OrderItem do - let(:order_item) { FactoryBot.create(:order_item) } - - it "has an order and a product" do - order_item.order.should be_an_instance_of Order - order_item.product.should be_an_instance_of Product - end - - it "validates price > product.min_price" do - @product = FactoryBot.create(:product) - order_item = FactoryBot.build(:order_item, price: @product.min_price - 1) - order_item.should_not be_valid - end - - it "doesn't let you add two items to an order" do - @product = FactoryBot.create(:product) - @order = FactoryBot.create(:order) - order_item = FactoryBot.build(:order_item, order: @order) - order_item.should be_valid - order_item.save - @order_item2 = FactoryBot.build(:order_item, order: @order) - @order_item2.should_not be_valid - end -end diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb deleted file mode 100644 index 9abb381ba..000000000 --- a/spec/models/order_spec.rb +++ /dev/null @@ -1,133 +0,0 @@ -require 'rails_helper' - -describe Order do - before(:each) do - @order = FactoryBot.create(:order) - @product = FactoryBot.create(:product) - @order_item = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id) - end - - describe '#by_member_id' do - before do - @member1 = FactoryBot.create(:member) - @member2 = FactoryBot.create(:member) - @order1 = Order.create!(member_id: @member1.id) - @order2 = Order.create!(member_id: @member2.id) - end - - it "only returns orders belonging to member" do - Order.by_member(@member1).should eq [@order1] - end - end - - it 'has order_items' do - @order.order_items.first.should eq @order_item - end - - it 'updates the account details' do - @member = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @account_type = FactoryBot.create(:account_type, name: 'paid') - @product = FactoryBot.create(:product, - account_type: @account_type, - paid_months: 3) - @order_item = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id) - - @member.account.paid_until.should be_nil - - @order.update_account - - @member.account.account_type.should eq @account_type - @member.account.paid_until.should_not be_nil - end - - it "totals the amount due" do - @member = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @product = FactoryBot.create(:product, - min_price: 1000) - # we force an order to only have one item at present. Add more if wanted - # later. - @order_item1 = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id, price: 1111, quantity: 1) - - @order.total.should eq 1111 - end - - it "gives the correct total for quantities more than 1" do - @member = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @product = FactoryBot.create(:product, - min_price: 1000) - # we force an order to only have one item at present. Add more if wanted - # later. - @order_item1 = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id, price: 1111, quantity: 2) - - @order.total.should eq 2222 - end - - it "formats order items for activemerchant" do - @member = FactoryBot.create(:member) - @order = FactoryBot.create(:order, member: @member) - @product = FactoryBot.create(:product, - name: 'foo', - min_price: 1000) - # we force an order to only have one item at present. Add more if wanted - # later. - @order_item1 = FactoryBot.create(:order_item, - order_id: @order.id, product_id: @product.id, price: 1111, quantity: 1) - - @order.activemerchant_items.should eq [{ - name: 'foo', - quantity: 1, - amount: 1111 - }] - end - - context "referral codes" do - it "has a referral code" do - referred_order = FactoryBot.create(:referred_order) - referred_order.referral_code.should_not be nil - end - - it "validates referral codes" do - referred_order = FactoryBot.build(:order, referral_code: 'CAMP_AIGN1?') - referred_order.should_not be_valid - end - - it "cleans up messy referral codes" do - referred_order = FactoryBot.create(:order, referral_code: 'CaMpAiGn 1 ') - referred_order.referral_code.should eq 'CAMPAIGN1' - end - end - - context 'search' do - it 'finds orders by member' do - order = FactoryBot.create(:order) - Order.search(by: 'member', for: order.member.login_name).should eq [order] - end - - it 'finds orders by order_id' do - order = FactoryBot.create(:order) - Order.search(by: 'order_id', for: order.id).should eq [order] - end - - it 'finds orders by paypal_token' do - order = FactoryBot.create(:order, paypal_express_token: 'foo') - Order.search(by: 'paypal_token', for: 'foo').should eq [order] - end - - it 'finds orders by paypal_payer_id' do - order = FactoryBot.create(:order, paypal_express_payer_id: 'bar') - Order.search(by: 'paypal_payer_id', for: 'bar').should eq [order] - end - - it 'finds orders by referral_code' do - order = FactoryBot.create(:order, referral_code: 'baz') - Order.search(by: 'referral_code', for: 'baz').should eq [order] - end - end -end diff --git a/spec/models/product_spec.rb b/spec/models/product_spec.rb deleted file mode 100644 index 2cc684667..000000000 --- a/spec/models/product_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'rails_helper' - -describe Product do - it "stringifies using the name" do - @product = FactoryBot.create(:product) - @product.to_s.should eq @product.name - end -end diff --git a/spec/routing/account_types_routing_spec.rb b/spec/routing/account_types_routing_spec.rb deleted file mode 100644 index 8402dd727..000000000 --- a/spec/routing/account_types_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "rails_helper" - -describe AccountTypesController do - describe "routing" do - it "routes to #index" do - get("/account_types").should route_to("account_types#index") - end - - it "routes to #new" do - get("/account_types/new").should route_to("account_types#new") - end - - it "routes to #show" do - get("/account_types/1").should route_to("account_types#show", id: "1") - end - - it "routes to #edit" do - get("/account_types/1/edit").should route_to("account_types#edit", id: "1") - end - - it "routes to #create" do - post("/account_types").should route_to("account_types#create") - end - - it "routes to #update" do - put("/account_types/1").should route_to("account_types#update", id: "1") - end - - it "routes to #destroy" do - delete("/account_types/1").should route_to("account_types#destroy", id: "1") - end - end -end diff --git a/spec/routing/order_items_routing_spec.rb b/spec/routing/order_items_routing_spec.rb deleted file mode 100644 index 7487cb9f5..000000000 --- a/spec/routing/order_items_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "rails_helper" - -describe OrderItemsController do - describe "routing" do - it "routes to #index" do - get("/order_items").should route_to("order_items#index") - end - - it "routes to #new" do - get("/order_items/new").should route_to("order_items#new") - end - - it "routes to #show" do - get("/order_items/1").should route_to("order_items#show", id: "1") - end - - it "routes to #edit" do - get("/order_items/1/edit").should route_to("order_items#edit", id: "1") - end - - it "routes to #create" do - post("/order_items").should route_to("order_items#create") - end - - it "routes to #update" do - put("/order_items/1").should route_to("order_items#update", id: "1") - end - - it "routes to #destroy" do - delete("/order_items/1").should route_to("order_items#destroy", id: "1") - end - end -end diff --git a/spec/routing/orders_routing_spec.rb b/spec/routing/orders_routing_spec.rb deleted file mode 100644 index 38184ef33..000000000 --- a/spec/routing/orders_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "rails_helper" - -describe OrdersController do - describe "routing" do - it "routes to #index" do - get("/orders").should route_to("orders#index") - end - - it "routes to #new" do - get("/orders/new").should route_to("orders#new") - end - - it "routes to #show" do - get("/orders/1").should route_to("orders#show", id: "1") - end - - it "routes to #edit" do - get("/orders/1/edit").should route_to("orders#edit", id: "1") - end - - it "routes to #create" do - post("/orders").should route_to("orders#create") - end - - it "routes to #update" do - put("/orders/1").should route_to("orders#update", id: "1") - end - - it "routes to #destroy" do - delete("/orders/1").should route_to("orders#destroy", id: "1") - end - end -end diff --git a/spec/routing/products_routing_spec.rb b/spec/routing/products_routing_spec.rb deleted file mode 100644 index 15166a805..000000000 --- a/spec/routing/products_routing_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "rails_helper" - -describe ProductsController do - describe "routing" do - it "routes to #index" do - get("/products").should route_to("products#index") - end - - it "routes to #new" do - get("/products/new").should route_to("products#new") - end - - it "routes to #show" do - get("/products/1").should route_to("products#show", id: "1") - end - - it "routes to #edit" do - get("/products/1/edit").should route_to("products#edit", id: "1") - end - - it "routes to #create" do - post("/products").should route_to("products#create") - end - - it "routes to #update" do - put("/products/1").should route_to("products#update", id: "1") - end - - it "routes to #destroy" do - delete("/products/1").should route_to("products#destroy", id: "1") - end - end -end diff --git a/spec/views/account_types/edit.html.haml_spec.rb b/spec/views/account_types/edit.html.haml_spec.rb deleted file mode 100644 index 1bd22be03..000000000 --- a/spec/views/account_types/edit.html.haml_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rails_helper' - -describe "account_types/edit" do - before(:each) do - @account_type = assign(:account_type, stub_model(AccountType, - name: "MyString", - is_paid: false, - is_permanent_paid: false)) - end - - it "renders the edit account_type form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: account_types_path(@account_type), method: "post" do - assert_select "input#account_type_name", name: "account_type[name]" - assert_select "input#account_type_is_paid", name: "account_type[is_paid]" - assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" - end - end -end diff --git a/spec/views/account_types/index.html.haml_spec.rb b/spec/views/account_types/index.html.haml_spec.rb deleted file mode 100644 index 56020fc35..000000000 --- a/spec/views/account_types/index.html.haml_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'rails_helper' - -describe "account_types/index" do - before(:each) do - @type = FactoryBot.create(:account_type) - assign(:account_types, [@type, @type]) - end - - it "renders a list of account_types" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", text: @type.name.to_s, count: 2 - end -end diff --git a/spec/views/account_types/new.html.haml_spec.rb b/spec/views/account_types/new.html.haml_spec.rb deleted file mode 100644 index 027a1b7c1..000000000 --- a/spec/views/account_types/new.html.haml_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rails_helper' - -describe "account_types/new" do - before(:each) do - assign(:account_type, stub_model(AccountType, - name: "MyString", - is_paid: false, - is_permanent_paid: false).as_new_record) - end - - it "renders new account_type form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", action: account_types_path, method: "post" do - assert_select "input#account_type_name", name: "account_type[name]" - assert_select "input#account_type_is_paid", name: "account_type[is_paid]" - assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" - end - end -end diff --git a/spec/views/account_types/show.html.haml_spec.rb b/spec/views/account_types/show.html.haml_spec.rb deleted file mode 100644 index a31d4bc33..000000000 --- a/spec/views/account_types/show.html.haml_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -describe "account_types/show" do - before(:each) do - @account_type = assign(:account_type, stub_model(AccountType, - name: "Name", - is_paid: false, - is_permanent_paid: false)) - end - - it "renders attributes in

" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should match(/Name/) - rendered.should match(/false/) - rendered.should match(/false/) - end -end diff --git a/spec/views/accounts/edit.html.haml_spec.rb b/spec/views/accounts/edit.html.haml_spec.rb deleted file mode 100644 index bc5c3b5a3..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 4ec76151e..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 77f6ff20f..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 d96fbbd96..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 beb0eacbd..cc8b145d3 100644 --- a/spec/views/admin/index_spec.rb +++ b/spec/views/admin/index_spec.rb @@ -9,8 +9,6 @@ describe 'admin/index.html.haml', type: "view" do end it "includes links to manage various things" do - assert_select "a", href: account_types_path - assert_select "a", href: products_path assert_select "a", href: roles_path assert_select "a", href: forums_path end diff --git a/spec/views/admin/orders/index_spec.rb b/spec/views/admin/orders/index_spec.rb deleted file mode 100644 index 8d80dc3ef..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/orders/index.html.haml_spec.rb b/spec/views/orders/index.html.haml_spec.rb deleted file mode 100644 index c95f204e2..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 a9f662de9..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/products/edit.html.haml_spec.rb b/spec/views/products/edit.html.haml_spec.rb deleted file mode 100644 index 3d60c9e95..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 90e08e2a3..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 336c6bac1..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 315d9caae..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/shop/index_spec.rb b/spec/views/shop/index_spec.rb deleted file mode 100644 index 754f05c09..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 From dcf528627585eac5f5b5e8991d573c73e52b3c23 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 14:38:08 +1300 Subject: [PATCH 2/6] Re-gen rubocop todo --- .rubocop_todo.yml | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9c3ccad34..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 @@ -66,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 @@ -94,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 From 3c411f15b860fcaf37987cce7671f168d4a833a1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 14:42:05 +1300 Subject: [PATCH 3/6] Re-instated the member-since text on profiles --- app/views/members/_stats.html.haml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/members/_stats.html.haml b/app/views/members/_stats.html.haml index 346d71296..8bb9613e9 100644 --- a/app/views/members/_stats.html.haml +++ b/app/views/members/_stats.html.haml @@ -1,3 +1,7 @@ +%p + %strong Member since: + = member.created_at.to_s(:date) + %h3 Activity %ul.list-inline @@ -33,4 +37,3 @@ = link_to pluralize(member.followers.size, "follower"), member_followers_path(member) - else 0 followers - From 0699677d051756d91502400a498920145843be2a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 14:42:41 +1300 Subject: [PATCH 4/6] Added back the member's last login --- app/views/members/_stats.html.haml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/members/_stats.html.haml b/app/views/members/_stats.html.haml index 8bb9613e9..a2ebab47d 100644 --- a/app/views/members/_stats.html.haml +++ b/app/views/members/_stats.html.haml @@ -1,6 +1,9 @@ %p %strong Member since: = member.created_at.to_s(:date) +%p + %strong Last Login: + = member.last_sign_in_at %h3 Activity From 54c880a66cbe535563ad188700568c5b3937a439 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 5 Feb 2018 15:36:32 +1300 Subject: [PATCH 5/6] Removed active merchant --- Gemfile | 2 -- Gemfile.lock | 10 ---------- config/application.yml.example | 5 ----- config/environments/development.rb | 11 ----------- config/environments/production.rb | 11 ----------- config/environments/staging.rb | 11 ----------- config/environments/test.rb | 7 ------- 7 files changed, 57 deletions(-) diff --git a/Gemfile b/Gemfile index 488a3b9ab..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 @@ -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 2686528e1..392b497e9 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/config/application.yml.example b/config/application.yml.example index 4aa23e439..ba343b6d0 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -57,11 +57,6 @@ GROWSTUFF_TWITTER_SECRET: "" GROWSTUFF_FLICKR_KEY: "" GROWSTUFF_FLICKR_SECRET: "" -# Paypal is used for payments, obviously. -GROWSTUFF_PAYPAL_USERNAME: "dummy" -GROWSTUFF_PAYPAL_PASSWORD: "dummy" -GROWSTUFF_PAYPAL_SIGNATURE: "dummy" - # https://developers.facebook.com/ GROWSTUFF_FACEBOOK_KEY: "" GROWSTUFF_FACEBOOK_SECRET: "" diff --git a/config/environments/development.rb b/config/environments/development.rb index d3242353e..a66a807f7 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -63,17 +63,6 @@ Growstuff::Application.configure do config.mapbox_map_id = 'growstuff.i3n2il6a' config.mapbox_access_token = 'pk.eyJ1IjoiZ3Jvd3N0dWZmIiwiYSI6IkdxMkx4alUifQ.n0igaBsw97s14zMa0lwKCA' - config.after_initialize do - ActiveMerchant::Billing::Base.mode = :test - paypal_options = { - login: ENV['GROWSTUFF_PAYPAL_USERNAME'] || 'dummy', - password: ENV['GROWSTUFF_PAYPAL_PASSWORD'] || 'dummy', - signature: ENV['GROWSTUFF_PAYPAL_SIGNATURE'] || 'dummy' - } - ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options) - ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options) - end - config.action_controller.action_on_unpermitted_parameters = :raise config.active_job.queue_adapter = :sidekiq diff --git a/config/environments/production.rb b/config/environments/production.rb index c931c058e..81cbddefd 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -91,16 +91,5 @@ Growstuff::Application.configure do config.mapbox_map_id = 'growstuff.i3n2c4ie' config.mapbox_access_token = 'pk.eyJ1IjoiZ3Jvd3N0dWZmIiwiYSI6IkdxMkx4alUifQ.n0igaBsw97s14zMa0lwKCA' - config.after_initialize do - ActiveMerchant::Billing::Base.mode = :production - paypal_options = { - login: ENV['GROWSTUFF_PAYPAL_USERNAME'], - password: ENV['GROWSTUFF_PAYPAL_PASSWORD'], - signature: ENV['GROWSTUFF_PAYPAL_SIGNATURE'] - } - ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options) - ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options) - end - config.active_job.queue_adapter = :sidekiq end diff --git a/config/environments/staging.rb b/config/environments/staging.rb index a9e242381..d4b381577 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -89,16 +89,5 @@ Growstuff::Application.configure do config.mapbox_map_id = 'growstuff.i3n2hao7' config.mapbox_access_token = 'pk.eyJ1IjoiZ3Jvd3N0dWZmIiwiYSI6IkdxMkx4alUifQ.n0igaBsw97s14zMa0lwKCA' - config.after_initialize do - ActiveMerchant::Billing::Base.mode = :test - paypal_options = { - login: ENV['GROWSTUFF_PAYPAL_USERNAME'], - password: ENV['GROWSTUFF_PAYPAL_PASSWORD'], - signature: ENV['GROWSTUFF_PAYPAL_SIGNATURE'] - } - ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options) - ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options) - end - config.active_job.queue_adapter = :sidekiq end diff --git a/config/environments/test.rb b/config/environments/test.rb index bf4135f64..d3ad694dd 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -51,13 +51,6 @@ Growstuff::Application.configure do config.analytics_code = '' config.currency = 'AUD' end - - config.after_initialize do - require "active_merchant/ext/paypal_bogus_gateway" - ActiveMerchant::Billing::Base.mode = :test - ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalBogusGateway.new - ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalBogusGateway.new - end end Geocoder.configure(lookup: :test) From f8127eeec3cf1e10b934cc64a95cacf5d5a5e30d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 9 Feb 2018 07:44:48 +1300 Subject: [PATCH 6/6] Revert "Auto corrected by following Style/StringLiterals" This reverts commit ab56a3c6b32f0cabe9ea116f317e4727631adc81. --- Gemfile | 14 +- Guardfile | 6 +- app/controllers/alternate_names_controller.rb | 4 +- app/controllers/application_controller.rb | 14 +- app/controllers/authentications_controller.rb | 4 +- app/controllers/charts/crops_controller.rb | 2 +- app/controllers/crops_controller.rb | 16 +- app/controllers/follows_controller.rb | 2 +- app/controllers/likes_controller.rb | 2 +- app/controllers/members_controller.rb | 4 +- app/controllers/notifications_controller.rb | 4 +- .../omniauth_callbacks_controller.rb | 8 +- app/controllers/order_items_controller.rb | 2 +- app/controllers/orders_controller.rb | 4 +- app/controllers/pages_controller.rb | 2 +- .../photo_associations_controller.rb | 2 +- app/controllers/photos_controller.rb | 6 +- app/controllers/registrations_controller.rb | 6 +- app/controllers/sessions_controller.rb | 2 +- app/helpers/application_helper.rb | 6 +- app/helpers/crops_helper.rb | 2 +- app/helpers/gardens_helper.rb | 10 +- app/helpers/harvests_helper.rb | 2 +- app/helpers/plantings_helper.rb | 8 +- app/helpers/seeds_helper.rb | 4 +- app/mailers/notifier.rb | 8 +- app/models/ability.rb | 2 +- app/models/account.rb | 2 +- app/models/alternate_name.rb | 2 +- app/models/comment.rb | 2 +- app/models/crop.rb | 48 +-- app/models/csv_importer.rb | 2 +- app/models/follow.rb | 4 +- app/models/forum.rb | 2 +- app/models/garden.rb | 10 +- app/models/harvest.rb | 48 +-- app/models/member.rb | 20 +- app/models/notification.rb | 2 +- app/models/order.rb | 12 +- app/models/order_item.rb | 2 +- app/models/planting.rb | 14 +- app/models/scientific_name.rb | 2 +- app/models/seed.rb | 14 +- app/services/crop_search_service.rb | 16 +- config.rb | 10 +- config/application.rb | 8 +- config/environments/test.rb | 20 +- config/initializers/devise.rb | 2 +- config/initializers/geocoder.rb | 4 +- config/initializers/time_formats.rb | 8 +- config/routes.rb | 10 +- config/setup_load_paths.rb | 2 +- .../20120903092956_devise_create_users.rb | 4 +- ...0201053200_add_approval_status_to_crops.rb | 2 +- .../20171105011017_set_prediction_data.rb | 4 +- .../20171129041341_create_photographings.rb | 8 +- db/seeds.rb | 52 +-- lib/actions/oauth_signup_action.rb | 2 +- lib/tasks/growstuff.rake | 108 +++--- lib/tasks/hooks.rake | 2 +- lib/tasks/i18n.rake | 4 +- lib/tasks/testing.rake | 4 +- script/heroku_maintenance.rb | 4 +- spec/controllers/accounts_controller_spec.rb | 2 +- .../admin/orders_controller_spec.rb | 6 +- spec/controllers/admin_controller_spec.rb | 4 +- .../charts/gardens_controller_spec.rb | 4 +- spec/controllers/comments_controller_spec.rb | 50 +-- spec/controllers/crops_controller_spec.rb | 24 +- spec/controllers/forums_controller_spec.rb | 6 +- spec/controllers/gardens_controller_spec.rb | 4 +- spec/controllers/harvests_controller_spec.rb | 84 ++--- spec/controllers/home_controller_spec.rb | 2 +- spec/controllers/likes_controller_spec.rb | 18 +- spec/controllers/member_controller_spec.rb | 24 +- .../notifications_controller_spec.rb | 36 +- .../order_items_controller_spec.rb | 8 +- spec/controllers/orders_controller_spec.rb | 14 +- .../photo_associations_controller_spec.rb | 6 +- spec/controllers/photos_controller_spec.rb | 88 ++--- spec/controllers/places_controller_spec.rb | 14 +- spec/controllers/plantings_controller_spec.rb | 14 +- spec/controllers/posts_controller_spec.rb | 22 +- spec/controllers/products_controller_spec.rb | 2 +- .../registrations_controller_spec.rb | 8 +- spec/controllers/roles_controller_spec.rb | 6 +- .../scientific_names_controller_spec.rb | 4 +- spec/controllers/seeds_controller_spec.rb | 4 +- spec/controllers/shop_controller_spec.rb | 8 +- spec/factories/account_types.rb | 8 +- spec/factories/alternate_names.rb | 4 +- spec/factories/crop.rb | 46 +-- spec/factories/forums.rb | 4 +- spec/factories/garden.rb | 6 +- spec/factories/harvests.rb | 12 +- spec/factories/like.rb | 2 +- spec/factories/member.rb | 2 +- spec/factories/notifications.rb | 4 +- spec/factories/order_items.rb | 2 +- spec/factories/photos.rb | 8 +- spec/factories/plant_parts.rb | 2 +- spec/factories/planting.rb | 2 +- spec/factories/post.rb | 6 +- spec/factories/products.rb | 8 +- spec/factories/roles.rb | 10 +- spec/factories/scientific_name.rb | 6 +- spec/factories/seeds.rb | 8 +- spec/features/admin/account_types_spec.rb | 20 +- spec/features/admin/forums_spec.rb | 26 +- spec/features/admin/products_spec.rb | 12 +- spec/features/cms_spec.rb | 8 +- .../comments/commenting_a_comment_spec.rb | 22 +- spec/features/crops/alternate_name_spec.rb | 48 +-- spec/features/crops/browse_crops_spec.rb | 12 +- spec/features/crops/creating_a_crop_spec.rb | 40 +-- spec/features/crops/crop_detail_page_spec.rb | 100 +++--- spec/features/crops/crop_photos_spec.rb | 24 +- spec/features/crops/crop_search_spec.rb | 20 +- spec/features/crops/crop_wranglers_spec.rb | 32 +- .../crops/crop_wrangling_button_spec.rb | 14 +- spec/features/crops/inflections_spec.rb | 28 +- spec/features/crops/request_new_crop_spec.rb | 40 +-- spec/features/crops/requested_crops_spec.rb | 6 +- spec/features/following_spec.rb | 40 +-- spec/features/footer_spec.rb | 4 +- spec/features/gardens/adding_gardens_spec.rb | 32 +- spec/features/gardens/gardens_index_spec.rb | 28 +- spec/features/gardens_spec.rb | 82 ++--- .../features/harvests/browse_harvests_spec.rb | 8 +- .../harvests/harvesting_a_crop_spec.rb | 84 ++--- spec/features/locale_spec.rb | 8 +- spec/features/member_profile_spec.rb | 108 +++--- spec/features/members/deletion_spec.rb | 72 ++-- spec/features/members_list_spec.rb | 28 +- spec/features/notifications_spec.rb | 18 +- spec/features/photos/new_photo_spec.rb | 26 +- spec/features/photos/show_photo_spec.rb | 20 +- .../features/places/searching_a_place_spec.rb | 44 +-- spec/features/planting_reminder_spec.rb | 34 +- .../plantings/planting_a_crop_spec.rb | 328 +++++++++--------- spec/features/posts/posting_a_post_spec.rb | 24 +- spec/features/rss/plantings_spec.rb | 2 +- spec/features/rss/posts_spec.rb | 2 +- spec/features/rss/seeds_spec.rb | 2 +- spec/features/scientific_name_spec.rb | 48 +-- spec/features/seeds/adding_seeds_spec.rb | 64 ++-- spec/features/seeds/misc_seeds_spec.rb | 32 +- spec/features/seeds/seed_photos.rb | 10 +- spec/features/shared_examples/append_date.rb | 18 +- spec/features/shared_examples/crop_suggest.rb | 50 +-- spec/features/signin_spec.rb | 26 +- spec/features/signout_spec.rb | 18 +- spec/features/signup_spec.rb | 12 +- spec/features/unsubscribing_spec.rb | 12 +- spec/helpers/application_helper_spec.rb | 6 +- spec/helpers/crops_helper_spec.rb | 12 +- spec/helpers/gardens_helper_spec.rb | 50 +-- spec/helpers/harvests_helper_spec.rb | 4 +- spec/helpers/notifications_helper_spec.rb | 6 +- spec/helpers/plantings_helper_spec.rb | 30 +- spec/helpers/seeds_helper_spec.rb | 14 +- spec/lib/actions/oauth_signup_action_spec.rb | 4 +- .../lib/haml/filters/escaped_markdown_spec.rb | 4 +- .../haml/filters/growstuff_markdown_spec.rb | 24 +- spec/mailers/notifier_spec.rb | 20 +- spec/models/ability_spec.rb | 76 ++-- spec/models/account_spec.rb | 4 +- spec/models/alternate_name_spec.rb | 2 +- spec/models/comment_spec.rb | 14 +- spec/models/crop_spec.rb | 154 ++++---- spec/models/follow_spec.rb | 12 +- spec/models/forum_spec.rb | 6 +- spec/models/garden_spec.rb | 42 +-- spec/models/harvest_spec.rb | 56 +-- spec/models/member_spec.rb | 74 ++-- spec/models/notification_spec.rb | 24 +- spec/models/order_item_spec.rb | 4 +- spec/models/order_spec.rb | 16 +- spec/models/photo_spec.rb | 6 +- spec/models/planting_spec.rb | 26 +- spec/models/post_spec.rb | 56 +-- spec/models/product_spec.rb | 2 +- spec/models/seed_spec.rb | 8 +- spec/rails_helper.rb | 8 +- spec/requests/api/v1/crop_request_spec.rb | 68 ++-- spec/requests/api/v1/gardens_request_spec.rb | 40 +-- spec/requests/api/v1/harvest_request_spec.rb | 68 ++-- spec/requests/api/v1/member_request_spec.rb | 68 ++-- spec/requests/api/v1/photos_request_spec.rb | 64 ++-- .../requests/api/v1/plantings_request_spec.rb | 90 ++--- spec/requests/api/v1/seeds_request_spec.rb | 54 +-- spec/requests/authentications_spec.rb | 4 +- spec/requests/comments_spec.rb | 6 +- spec/requests/forums_spec.rb | 6 +- spec/requests/gardens_spec.rb | 6 +- spec/requests/harvests_spec.rb | 6 +- spec/requests/notifications_spec.rb | 6 +- spec/requests/photos_spec.rb | 6 +- spec/requests/plant_parts_spec.rb | 6 +- spec/requests/plantings_spec.rb | 6 +- spec/requests/post_spec.rb | 6 +- spec/requests/scientific_names_spec.rb | 6 +- spec/requests/seeds_spec.rb | 6 +- spec/routing/account_types_routing_spec.rb | 32 +- spec/routing/authentications_routing_spec.rb | 12 +- spec/routing/comments_routing_spec.rb | 32 +- spec/routing/crops_routing_spec.rb | 32 +- spec/routing/follows_routing_spec.rb | 12 +- spec/routing/forums_routing_spec.rb | 32 +- spec/routing/gardens_routing_spec.rb | 32 +- spec/routing/harvests_routing_spec.rb | 32 +- spec/routing/notifications_routing_spec.rb | 32 +- spec/routing/order_items_routing_spec.rb | 32 +- spec/routing/orders_routing_spec.rb | 32 +- spec/routing/photos_routing_spec.rb | 32 +- spec/routing/plant_parts_routing_spec.rb | 32 +- spec/routing/plantings_routing_spec.rb | 32 +- spec/routing/products_routing_spec.rb | 32 +- spec/routing/roles_routing_spec.rb | 32 +- spec/routing/scientific_names_routing_spec.rb | 32 +- spec/routing/seeds_routing_spec.rb | 32 +- spec/routing/updates_routing_spec.rb | 32 +- spec/spec_helper.rb | 2 +- spec/support/controller_macros.rb | 2 +- spec/support/elasticsearch_helpers.rb | 4 +- spec/support/is_likeable.rb | 4 +- .../account_types/edit.html.haml_spec.rb | 14 +- .../account_types/index.html.haml_spec.rb | 6 +- .../views/account_types/new.html.haml_spec.rb | 14 +- .../account_types/show.html.haml_spec.rb | 6 +- spec/views/accounts/edit.html.haml_spec.rb | 10 +- spec/views/accounts/index.html.haml_spec.rb | 6 +- spec/views/accounts/new.html.haml_spec.rb | 10 +- spec/views/accounts/show.html.haml_spec.rb | 4 +- spec/views/admin/index_spec.rb | 16 +- spec/views/admin/newsletter_spec.rb | 4 +- spec/views/admin/orders/index_spec.rb | 14 +- spec/views/comments/edit.html.haml_spec.rb | 8 +- spec/views/comments/index.html.haml_spec.rb | 8 +- spec/views/comments/index.rss.haml_spec.rb | 4 +- spec/views/comments/new.html.haml_spec.rb | 16 +- spec/views/comments/show.html.haml_spec.rb | 4 +- spec/views/crops/_grown_for.html.haml_spec.rb | 4 +- .../crops/_planting_advice.html.haml_spec.rb | 52 +-- spec/views/crops/_popover.html.haml_spec.rb | 2 +- spec/views/crops/edit.html.haml_spec.rb | 4 +- spec/views/crops/hierarchy.html.haml_spec.rb | 6 +- spec/views/crops/index.html.haml_spec.rb | 28 +- spec/views/crops/index.rss.haml_spec.rb | 2 +- spec/views/crops/new.html.haml_spec.rb | 6 +- spec/views/crops/wrangle.html.haml_spec.rb | 14 +- spec/views/devise/confirmations/new_spec.rb | 6 +- .../mailer/confirmation_instructions_spec.rb | 4 +- .../reset_password_instructions_spec.rb | 8 +- .../devise/mailer/unlock_instructions_spec.rb | 10 +- spec/views/devise/registrations/edit_spec.rb | 34 +- spec/views/devise/registrations/new_spec.rb | 8 +- spec/views/devise/sessions/new_spec.rb | 6 +- spec/views/devise/shared/_links_spec.rb | 12 +- spec/views/devise/unlocks/new_spec.rb | 6 +- spec/views/forums/edit.html.haml_spec.rb | 16 +- spec/views/forums/index.html.haml_spec.rb | 18 +- spec/views/forums/new.html.haml_spec.rb | 12 +- spec/views/forums/show.html.haml_spec.rb | 14 +- spec/views/gardens/edit.html.haml_spec.rb | 20 +- spec/views/gardens/new.html.haml_spec.rb | 18 +- spec/views/gardens/show.html.haml_spec.rb | 14 +- spec/views/harvests/edit.html.haml_spec.rb | 22 +- spec/views/harvests/index.html.haml_spec.rb | 10 +- spec/views/harvests/new.html.haml_spec.rb | 22 +- spec/views/harvests/show.html.haml_spec.rb | 4 +- spec/views/home/_blurb.html.haml_spec.rb | 10 +- spec/views/home/_crops.html.haml_spec.rb | 2 +- spec/views/home/_members.html.haml_spec.rb | 4 +- spec/views/home/_seeds.html.haml_spec.rb | 2 +- spec/views/home/_stats.html.haml_spec.rb | 4 +- spec/views/home/index_spec.rb | 2 +- spec/views/layouts/_header_spec.rb | 28 +- spec/views/layouts/_meta_spec.rb | 4 +- spec/views/layouts/application_spec.rb | 4 +- .../views/members/_location.html.haml_spec.rb | 14 +- spec/views/members/index.html.haml_spec.rb | 6 +- spec/views/members/show.rss.haml_spec.rb | 6 +- .../notifications/index.html.haml_spec.rb | 28 +- .../views/notifications/new.html.haml_spec.rb | 28 +- .../notifications/show.html.haml_spec.rb | 12 +- spec/views/notifier/notify.html.haml_spec.rb | 6 +- spec/views/orders/index.html.haml_spec.rb | 12 +- spec/views/orders/show.html.haml_spec.rb | 34 +- spec/views/photos/edit.html.haml_spec.rb | 6 +- spec/views/photos/index.html.haml_spec.rb | 8 +- spec/views/photos/new.html.haml_spec.rb | 20 +- spec/views/photos/show.html.haml_spec.rb | 60 ++-- .../places/_map_attribution.html.haml_spec.rb | 18 +- spec/views/places/index.html.haml_spec.rb | 6 +- spec/views/places/show.html.haml_spec.rb | 10 +- spec/views/plant_parts/edit.html.haml_spec.rb | 10 +- .../views/plant_parts/index.html.haml_spec.rb | 6 +- spec/views/plant_parts/new.html.haml_spec.rb | 10 +- spec/views/plant_parts/show.html.haml_spec.rb | 6 +- spec/views/plantings/_form.html.haml_spec.rb | 4 +- spec/views/plantings/edit.html.haml_spec.rb | 26 +- spec/views/plantings/index.html.haml_spec.rb | 18 +- spec/views/plantings/index.rss.haml_spec.rb | 4 +- spec/views/plantings/new.html.haml_spec.rb | 28 +- spec/views/plantings/show.html.haml_spec.rb | 26 +- spec/views/posts/_single.html.haml_spec.rb | 84 ++--- spec/views/posts/edit.html.haml_spec.rb | 18 +- spec/views/posts/index.html.haml_spec.rb | 22 +- spec/views/posts/index.rss.haml_spec.rb | 6 +- spec/views/posts/new.html.haml_spec.rb | 16 +- spec/views/posts/show.html.haml_spec.rb | 36 +- spec/views/posts/show.rss.haml_spec.rb | 2 +- spec/views/products/edit.html.haml_spec.rb | 20 +- spec/views/products/index.html.haml_spec.rb | 10 +- spec/views/products/new.html.haml_spec.rb | 24 +- spec/views/products/show.html.haml_spec.rb | 4 +- spec/views/roles/edit.html.haml_spec.rb | 14 +- spec/views/roles/index.html.haml_spec.rb | 16 +- spec/views/roles/new.html.haml_spec.rb | 14 +- spec/views/roles/show.html.haml_spec.rb | 8 +- .../scientific_names/edit.html.haml_spec.rb | 14 +- .../scientific_names/index.html.haml_spec.rb | 20 +- .../scientific_names/new.html.haml_spec.rb | 12 +- .../scientific_names/show.html.haml_spec.rb | 4 +- spec/views/seeds/edit.html.haml_spec.rb | 20 +- spec/views/seeds/index.rss.haml_spec.rb | 2 +- spec/views/seeds/new.html.haml_spec.rb | 20 +- spec/views/seeds/show.html.haml_spec.rb | 22 +- spec/views/shop/index_spec.rb | 26 +- 330 files changed, 3121 insertions(+), 3121 deletions(-) diff --git a/Gemfile b/Gemfile index 4e6dc5797..488a3b9ab 100644 --- a/Gemfile +++ b/Gemfile @@ -78,7 +78,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 +87,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 +125,7 @@ group :development do end group :development, :test do - gem 'active_merchant-paypal-bogus-gateway' + gem "active_merchant-paypal-bogus-gateway" gem 'bullet' # performance tuning by finding unnecesary queries gem 'byebug' # debugging gem 'capybara' # integration tests 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/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 index 9c3e79dae..326cff21f 100644 --- a/app/controllers/order_items_controller.rb +++ b/app/controllers/order_items_controller.rb @@ -24,7 +24,7 @@ class OrderItemsController < ApplicationController def errors if @order_item.errors.empty? - 'There was a problem with your order.' + "There was a problem with your order." else @order_item.errors.full_messages.to_sentence end diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 0929d3948..3bc9fe45c 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -42,7 +42,7 @@ class OrdersController < ApplicationController ) format.html { redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token) } else - format.html { render action: 'show' } + format.html { render action: "show" } end end end @@ -60,7 +60,7 @@ class OrdersController < ApplicationController @order.completed_at = Time.zone.now @order.record_paypal_details(params[:token]) else - flash[:alert] = 'Could not complete your order. Please notify support.' + 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." 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/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/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6076d98ef..639d27686 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -18,7 +18,7 @@ module ApplicationHelper currency = Growstuff::Application.config.currency link = "http://www.wolframalpha.com/input/?i=#{pid}+#{currency}" - link_to '(convert)', link, target: '_blank', rel: 'noopener noreferrer' + link_to "(convert)", link, target: "_blank", rel: "noopener noreferrer" end def build_alert_classes(alert_type = :info) @@ -37,7 +37,7 @@ module ApplicationHelper end # Produces a cache key for uniquely identifying cached fragments. - def cache_key_for(klass, identifier = 'all') + def cache_key_for(klass, identifier = "all") count = klass.count max_updated_at = klass.maximum(:updated_at).try(:utc).try(:to_s, :number) "#{klass.name.downcase.pluralize}/#{identifier}-#{count}-#{max_updated_at}" @@ -102,7 +102,7 @@ module ApplicationHelper elsif planting t(".title.planting_#{type}", planting: planting.to_s) else - t('.title.default') + t(".title.default") end end diff --git a/app/helpers/crops_helper.rb b/app/helpers/crops_helper.rb index c96ff8fa1..b99d687aa 100644 --- a/app/helpers/crops_helper.rb +++ b/app/helpers/crops_helper.rb @@ -13,7 +13,7 @@ module CropsHelper if total_quantity != 0 "You have #{total_quantity} #{Seed.model_name.human(count: total_quantity)} of this crop." else - 'You have an unknown quantity of seeds of this crop.' + "You have an unknown quantity of seeds of this crop." end end diff --git a/app/helpers/gardens_helper.rb b/app/helpers/gardens_helper.rb index cfbf90024..a72505558 100644 --- a/app/helpers/gardens_helper.rb +++ b/app/helpers/gardens_helper.rb @@ -1,10 +1,10 @@ module GardensHelper def display_garden_description(garden) if garden.description.nil? - 'no description provided.' + "no description provided." else truncate(garden.description, length: 130, separator: ' ', omission: '... ') do - link_to 'Read more', garden_path(garden) + link_to "Read more", garden_path(garden) end end end @@ -19,12 +19,12 @@ module GardensHelper def display_garden_plantings(plantings) if plantings.blank? - 'None' + "None" else output = '

" expect(result).to eq output end - it 'has 2 plantings' do + it "has 2 plantings" do plantings = [] crop1 = FactoryBot.create(:crop) @@ -61,17 +61,17 @@ describe GardensHelper do result = helper.display_garden_plantings(plantings.first(2)) output = '' + output += "" expect(result).to eq output end - it 'has 3 plantings' do + it "has 3 plantings" do plantings = [] crop1 = FactoryBot.create(:crop) @@ -86,13 +86,13 @@ describe GardensHelper do result = helper.display_garden_plantings(plantings.first(2)) output = '' + output += "" expect(result).to eq output end end diff --git a/spec/helpers/harvests_helper_spec.rb b/spec/helpers/harvests_helper_spec.rb index a234bc260..1ba63810d 100644 --- a/spec/helpers/harvests_helper_spec.rb +++ b/spec/helpers/harvests_helper_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' describe HarvestsHelper do - describe 'display_quantity' do - it 'blank' do + describe "display_quantity" do + it "blank" do harvest = FactoryBot.create(:harvest, quantity: nil, weight_quantity: nil) diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 8281b3712..a00dabff3 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' describe NotificationsHelper do - describe 'reply_link' do + describe "reply_link" do let(:member) { FactoryBot.create(:member) } - it 'replies to PMs with PMs' do + it "replies to PMs with PMs" do notification = FactoryBot.create(:notification, recipient_id: member.id, post_id: nil) link = helper.reply_link(notification) link.should_not be_nil link.should eq reply_notification_url(notification) end - it 'replies to post comments with post comments' do + it "replies to post comments with post comments" do notification = FactoryBot.create(:notification, recipient_id: member.id) link = helper.reply_link(notification) diff --git a/spec/helpers/plantings_helper_spec.rb b/spec/helpers/plantings_helper_spec.rb index acde7469f..3af084d5a 100644 --- a/spec/helpers/plantings_helper_spec.rb +++ b/spec/helpers/plantings_helper_spec.rb @@ -1,64 +1,64 @@ require 'rails_helper' describe PlantingsHelper do - describe 'display_planting' do + describe "display_planting" do let!(:member) { FactoryBot.build(:member, login_name: 'crop_lady') } - it 'does not have a quantity nor a planted from value provided' do + it "does not have a quantity nor a planted from value provided" do planting = FactoryBot.build(:planting, quantity: nil, planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady.' + expect(result).to eq "crop_lady." end - it 'does not have a quantity provided' do + it "does not have a quantity provided" do planting = FactoryBot.build(:planting, quantity: nil, planted_from: 'seed', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted seeds.' + expect(result).to eq "crop_lady planted seeds." end - context 'when quantity is greater than 1' do - it 'does not have a planted from value provided' do + context "when quantity is greater than 1" do + it "does not have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 10, planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 10 units.' + expect(result).to eq "crop_lady planted 10 units." end - it 'does have a planted from value provided' do + it "does have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 5, planted_from: 'seed', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 5 seeds.' + expect(result).to eq "crop_lady planted 5 seeds." end end - context 'when quantity is 1' do - it 'does not have a planted from value provided' do + context "when quantity is 1" do + it "does not have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 1, planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 1 unit.' + expect(result).to eq "crop_lady planted 1 unit." end - it 'does have a planted from value provided' do + it "does have a planted from value provided" do planting = FactoryBot.build(:planting, quantity: 1, planted_from: 'seed', owner: member) result = helper.display_planting(planting) - expect(result).to eq 'crop_lady planted 1 seed.' + expect(result).to eq "crop_lady planted 1 seed." end end end diff --git a/spec/helpers/seeds_helper_spec.rb b/spec/helpers/seeds_helper_spec.rb index 837e1368a..3d559058e 100644 --- a/spec/helpers/seeds_helper_spec.rb +++ b/spec/helpers/seeds_helper_spec.rb @@ -1,33 +1,33 @@ require 'rails_helper' describe SeedsHelper do - describe 'seed description' do - it 'is missing' do + describe "seed description" do + it "is missing" do seed = FactoryBot.create(:seed, description: nil) result = helper.display_seed_description(seed) - expect(result).to eq 'no description provided.' + expect(result).to eq "no description provided." end - it 'is less than 130 characters long' do + it "is less than 130 characters long" do seed = FactoryBot.create(:seed, description: 'a' * 20) result = helper.display_seed_description(seed) expect(result).to eq 'a' * 20 end - it 'is 130 characters long' do + it "is 130 characters long" do seed = FactoryBot.create(:seed, description: 'a' * 130) result = helper.display_seed_description(seed) expect(result).to eq 'a' * 130 end - it 'is more than 130 characters long' do + it "is more than 130 characters long" do seed = FactoryBot.create(:seed, description: 'a' * 140) result = helper.display_seed_description(seed) - expect(result).to eq 'a' * 126 + '...' + ' ' + link_to('Read more', seed_path(seed)) + expect(result).to eq 'a' * 126 + '...' + ' ' + link_to("Read more", seed_path(seed)) end end end diff --git a/spec/lib/actions/oauth_signup_action_spec.rb b/spec/lib/actions/oauth_signup_action_spec.rb index a6f7958b1..1710428a4 100644 --- a/spec/lib/actions/oauth_signup_action_spec.rb +++ b/spec/lib/actions/oauth_signup_action_spec.rb @@ -17,8 +17,8 @@ describe 'Growstuff::OauthSignupAction' do 'image' => 'http://findicons.com/files/icons/1072/face_avatars/300/i04.png' }, 'credentials' => { - 'token' => 'token', - 'secret' => 'donttell' + 'token' => "token", + 'secret' => "donttell" }) end diff --git a/spec/lib/haml/filters/escaped_markdown_spec.rb b/spec/lib/haml/filters/escaped_markdown_spec.rb index 4677f596c..415751293 100644 --- a/spec/lib/haml/filters/escaped_markdown_spec.rb +++ b/spec/lib/haml/filters/escaped_markdown_spec.rb @@ -10,8 +10,8 @@ describe 'Haml::Filters::Escaped_Markdown' do end it 'converts Markdown to escaped HTML' do - rendered = Haml::Filters::EscapedMarkdown.render('**foo**') - rendered.should == '<p><strong>foo</strong></p>' + rendered = Haml::Filters::EscapedMarkdown.render("**foo**") + rendered.should == "<p><strong>foo</strong></p>" end it 'converts quick crop links' do diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb index 6c92c5e6d..03ad3b0e1 100644 --- a/spec/lib/haml/filters/growstuff_markdown_spec.rb +++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb @@ -35,17 +35,17 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "doesn't convert nonexistent crops" do - rendered = Haml::Filters::GrowstuffMarkdown.render(input_link('not a crop')) + rendered = Haml::Filters::GrowstuffMarkdown.render(input_link("not a crop")) expect(rendered).to match(/not a crop/) end it "doesn't convert escaped crop links" do @crop = FactoryBot.create(:crop) - rendered = Haml::Filters::GrowstuffMarkdown.render('\\' << input_link(@crop.name)) + rendered = Haml::Filters::GrowstuffMarkdown.render("\\" << input_link(@crop.name)) expect(rendered).to match(/\[#{@crop.name}\]\(crop\)/) end - it 'handles multiple crop links' do + it "handles multiple crop links" do tomato = FactoryBot.create(:tomato) maize = FactoryBot.create(:maize) string = "#{input_link(tomato)} #{input_link(maize)}" @@ -53,24 +53,24 @@ describe 'Haml::Filters::Growstuff_Markdown' do expect(rendered).to match(/#{output_link(tomato)} #{output_link(maize)}/) end - it 'converts normal markdown' do - string = '**foo**' + it "converts normal markdown" do + string = "**foo**" rendered = Haml::Filters::GrowstuffMarkdown.render(string) expect(rendered).to match(/foo<\/strong>/) end - it 'finds crops case insensitively' do + it "finds crops case insensitively" do @crop = FactoryBot.create(:crop, name: 'tomato') rendered = Haml::Filters::GrowstuffMarkdown.render(input_link('ToMaTo')) expect(rendered).to match(/#{output_link(@crop, 'ToMaTo')}/) end - it 'fixes PT bug #78615258 (Markdown rendering bug with URLs and crops in same text)' do + it "fixes PT bug #78615258 (Markdown rendering bug with URLs and crops in same text)" do tomato = FactoryBot.create(:tomato) - string = '[test](http://example.com) [tomato](crop)' + string = "[test](http://example.com) [tomato](crop)" rendered = Haml::Filters::GrowstuffMarkdown.render(string) expect(rendered).to match(/#{output_link(tomato)}/) - expect(rendered).to match 'test' + expect(rendered).to match "test" end it 'converts quick member links' do @@ -80,13 +80,13 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "doesn't convert nonexistent members" do - rendered = Haml::Filters::GrowstuffMarkdown.render(input_member_link('not a member')) + rendered = Haml::Filters::GrowstuffMarkdown.render(input_member_link("not a member")) expect(rendered).to include('not a member') end it "doesn't convert escaped members" do @member = FactoryBot.create(:member) - rendered = Haml::Filters::GrowstuffMarkdown.render('\\' << input_member_link(@member.login_name)) + rendered = Haml::Filters::GrowstuffMarkdown.render("\\" << input_member_link(@member.login_name)) expect(rendered).to match(/\[#{@member.login_name}\]\(member\)/) end @@ -97,7 +97,7 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "doesn't convert invalid @ members" do - rendered = Haml::Filters::GrowstuffMarkdown.render('@notamember') + rendered = Haml::Filters::GrowstuffMarkdown.render("@notamember") expect(rendered).to include('@notamember') end diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 344b26e7f..e50682700 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -1,7 +1,7 @@ -require 'rails_helper' +require "rails_helper" describe Notifier do - describe 'notifications' do + describe "notifications" do let(:notification) { FactoryBot.create(:notification) } let(:mail) { Notifier.notify(notification) } @@ -18,12 +18,12 @@ describe Notifier do end end - describe 'planting reminders' do + describe "planting reminders" do let(:member) { FactoryBot.create(:member) } let(:mail) { Notifier.planting_reminder(member) } it 'sets the subject correctly' do - mail.subject.should == 'What have you planted lately?' + mail.subject.should == "What have you planted lately?" end it 'comes from noreply@growstuff.org' do @@ -43,7 +43,7 @@ describe Notifier do end end - describe 'new crop request' do + describe "new crop request" do let(:member) { FactoryBot.create(:crop_wrangling_member) } let(:crop) { FactoryBot.create(:crop_request) } let(:mail) { Notifier.new_crop_request(member, crop) } @@ -65,13 +65,13 @@ describe Notifier do end end - describe 'crop approved' do + describe "crop approved" do let(:member) { FactoryBot.create(:member) } let(:crop) { FactoryBot.create(:crop) } let(:mail) { Notifier.crop_request_approved(member, crop) } it 'sets the subject correctly' do - expect(mail.subject).to eq 'Magic bean has been approved' + expect(mail.subject).to eq "Magic bean has been approved" end it 'comes from noreply@growstuff.org' do @@ -93,13 +93,13 @@ describe Notifier do end end - describe 'crop rejected' do + describe "crop rejected" do let(:member) { FactoryBot.create(:member) } let(:crop) { FactoryBot.create(:rejected_crop) } let(:mail) { Notifier.crop_request_rejected(member, crop) } it 'sets the subject correctly' do - expect(mail.subject).to eq 'Fail bean has been rejected' + expect(mail.subject).to eq "Fail bean has been rejected" end it 'comes from noreply@growstuff.org' do @@ -115,7 +115,7 @@ describe Notifier do end it 'includes the reason for rejection' do - expect(mail.body.encoded).to match 'Totally fake' + expect(mail.body.encoded).to match "Totally fake" end end end diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index d69b0ba57..ef746c8bc 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -5,7 +5,7 @@ describe Ability do let(:member) { FactoryBot.create(:member) } let(:ability) { Ability.new(member) } - context 'notifications' do + context "notifications" do it 'member can view their own notifications' do notification = FactoryBot.create(:notification, recipient: member) ability.should be_able_to(:read, notification) @@ -22,7 +22,7 @@ describe Ability do recipient: member, sender: member)) end - it 'member can send messages to someone else' do + it "member can send messages to someone else" do ability.should be_able_to(:create, FactoryBot.create(:notification, recipient: FactoryBot.create(:member), @@ -30,51 +30,51 @@ describe Ability do end end - context 'crop wrangling' do + context "crop wrangling" do let(:crop) { FactoryBot.create(:crop) } - context 'standard member' do + context "standard member" do it "can't manage crops" do ability.should_not be_able_to(:update, crop) ability.should_not be_able_to(:destroy, crop) end - it 'can request crops' do + it "can request crops" do ability.should be_able_to(:create, Crop) end - it 'can read crops' do + it "can read crops" do ability.should be_able_to(:read, crop) end end - context 'crop wrangler' do + context "crop wrangler" do let(:role) { FactoryBot.create(:crop_wrangler) } before(:each) do member.roles << role end - it 'has crop_wrangler role' do + it "has crop_wrangler role" do member.role?(:crop_wrangler).should be true end - it 'can create crops' do + it "can create crops" do ability.should be_able_to(:create, Crop) end - it 'can update crops' do + it "can update crops" do ability.should be_able_to(:update, crop) end - it 'can destroy crops' do + it "can destroy crops" do ability.should be_able_to(:destroy, crop) end end end - context 'products' do + context "products" do let(:product) { FactoryBot.create(:product) } - context 'standard member' do + context "standard member" do it "can't read or manage products" do ability.should_not be_able_to(:read, product) ability.should_not be_able_to(:create, Product) @@ -83,33 +83,33 @@ describe Ability do end end - context 'admin' do + context "admin" do let(:role) { FactoryBot.create(:admin) } before do member.roles << role end - it 'has admin role' do + it "has admin role" do member.role?(:admin).should be true end - it 'can read products' do + it "can read products" do ability.should be_able_to(:read, product) end - it 'can create products' do + it "can create products" do ability.should be_able_to(:create, Product) end - it 'can update products' do + it "can update products" do ability.should be_able_to(:update, product) end - it 'can destroy products' do + it "can destroy products" do ability.should be_able_to(:destroy, product) end end end - context 'orders' do + context "orders" do let(:order) { FactoryBot.create(:order, member: member) } let(:strangers_order) do FactoryBot.create(:order, @@ -129,8 +129,8 @@ describe Ability do order: completed_order) end - context 'standard member' do - it 'can read their own orders' do + context "standard member" do + it "can read their own orders" do ability.should be_able_to(:read, order) ability.should be_able_to(:read, completed_order) end @@ -139,11 +139,11 @@ describe Ability do ability.should_not be_able_to(:read, strangers_order) end - it 'can create a new order' do + it "can create a new order" do ability.should be_able_to(:create, Order) end - it 'can complete their own current order' do + it "can complete their own current order" do ability.should be_able_to(:complete, order) end @@ -155,7 +155,7 @@ describe Ability do ability.should_not be_able_to(:complete, completed_order) end - it 'can delete a current order' do + it "can delete a current order" do ability.should be_able_to(:destroy, order) end @@ -176,7 +176,7 @@ describe Ability do ability.should_not be_able_to(:read, strangers_order_item) end - it 'can create a new order item' do + it "can create a new order item" do ability.should be_able_to(:create, OrderItem) end @@ -205,30 +205,30 @@ describe Ability do end end - context 'admin' do + context "admin" do let(:role) { FactoryBot.create(:admin) } before do member.roles << role end - it 'has admin role' do + it "has admin role" do member.role?(:admin).should be true end - it 'can read orders' do + it "can read orders" do ability.should be_able_to(:read, order) end - it 'cannot create orders' do + it "cannot create orders" do ability.should_not be_able_to(:create, order) end - it 'cannot complete orders' do + it "cannot complete orders" do ability.should_not be_able_to(:complete, order) end - it 'cannot delete orders' do + it "cannot delete orders" do ability.should_not be_able_to(:destroy, order) end end @@ -255,10 +255,10 @@ describe Ability do member.roles << role end - it 'can read account details' do + it "can read account details" do ability.should be_able_to(:read, account) end - it 'can manage account details' do + it "can manage account details" do ability.should be_able_to(:create, Account) ability.should be_able_to(:update, account) ability.should be_able_to(:destroy, account) @@ -270,7 +270,7 @@ describe Ability do let(:plant_part) { FactoryBot.create(:plant_part) } context 'ordinary member' do - it 'can read plant parts' do + it "can read plant parts" do ability.should be_able_to(:read, plant_part) end it "can't manage plant parts" do @@ -287,15 +287,15 @@ describe Ability do member.roles << role end - it 'can read plant_part details' do + it "can read plant_part details" do ability.should be_able_to(:read, plant_part) end - it 'can manage plant_part details' do + it "can manage plant_part details" do ability.should be_able_to(:create, PlantPart) ability.should be_able_to(:update, plant_part) end - it 'can delete an unused plant part' do + it "can delete an unused plant part" do ability.should be_able_to(:destroy, plant_part) end diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 915750eaa..15eb68084 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe Account do let(:member) { FactoryBot.create(:member) } - it 'auto-creates an account detail record when a member is created' do + it "auto-creates an account detail record when a member is created" do member.account.should be_an_instance_of Account end @@ -17,7 +17,7 @@ describe Account do member.account.paid_until_string.should eq nil member.account.account_type = FactoryBot.create(:permanent_paid_account_type) - member.account.paid_until_string.should eq 'forever' + member.account.paid_until_string.should eq "forever" member.account.account_type = FactoryBot.create(:paid_account_type) @time = Time.zone.now diff --git a/spec/models/alternate_name_spec.rb b/spec/models/alternate_name_spec.rb index 64e483446..f358a9fca 100644 --- a/spec/models/alternate_name_spec.rb +++ b/spec/models/alternate_name_spec.rb @@ -10,7 +10,7 @@ describe AlternateName do it 'should be possible to add multiple alternate names to a crop' do crop = an.crop an2 = AlternateName.create( - name: 'really alternative tomato', + name: "really alternative tomato", crop_id: crop.id, creator_id: an.creator.id ) diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 593d0da1b..bc90ee8ba 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -1,28 +1,28 @@ require 'rails_helper' describe Comment do - context 'basic' do + context "basic" do let(:comment) { FactoryBot.create(:comment) } - it 'belongs to a post' do + it "belongs to a post" do comment.post.should be_an_instance_of Post end - it 'belongs to an author' do + it "belongs to an author" do comment.author.should be_an_instance_of Member end end - context 'notifications' do + context "notifications" do let(:comment) { FactoryBot.create(:comment) } - it 'sends a notification when a comment is posted' do + it "sends a notification when a comment is posted" do expect do FactoryBot.create(:comment) end.to change(Notification, :count).by(1) end - it 'sets the notification fields' do + it "sets the notification fields" do @c = FactoryBot.create(:comment) @n = Notification.first @n.sender.should eq @c.author @@ -41,7 +41,7 @@ describe Comment do end end - context 'ordering' do + context "ordering" do before(:each) do @m = FactoryBot.create(:member) @p = FactoryBot.create(:post, author: @m) diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 254573e80..3f49a249d 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -11,8 +11,8 @@ describe Crop do it 'should be fetchable from the database' do crop.save @crop2 = Crop.find_by(name: 'tomato') - @crop2.en_wikipedia_url.should eq('http://en.wikipedia.org/wiki/Tomato') - @crop2.slug.should eq('tomato') + @crop2.en_wikipedia_url.should eq("http://en.wikipedia.org/wiki/Tomato") + @crop2.slug.should eq("tomato") end it 'should stringify as the system name' do @@ -54,7 +54,7 @@ describe Crop do FactoryBot.create_list(:planting, 3, crop: tomato) end - it 'sorts by most plantings' do + it "sorts by most plantings" do Crop.popular.first.should eq maize FactoryBot.create_list(:planting, 10, crop: tomato) Crop.popular.first.should eq tomato @@ -77,7 +77,7 @@ describe Crop do @crop.plantings.size.should eq 1 end - context 'wikipedia url' do + context "wikipedia url" do subject { FactoryBot.build(:tomato, en_wikipedia_url: wikipedia_url) } context 'not a url' do @@ -116,7 +116,7 @@ describe Crop do it { expect(subject).not_to be_valid } end - context 'with script tags in url' do + context "with script tags in url" do let(:wikipedia_url) { 'http://en.wikipedia.org/wiki/SomePage' } it { expect(subject).not_to be_valid } @@ -331,13 +331,13 @@ describe Crop do let(:pp1) { FactoryBot.create(:plant_part) } let(:pp2) { FactoryBot.create(:plant_part) } - context 'harvests' do + context "harvests" do let(:h1) { FactoryBot.create(:harvest, crop: maize, plant_part: pp1) } let(:h2) { FactoryBot.create(:harvest, crop: maize, plant_part: pp2) } let!(:crop) { FactoryBot.create(:crop) } let!(:harvest) { FactoryBot.create(:harvest, crop: crop) } - it 'has harvests' do + it "has harvests" do expect(crop.harvests).to eq [harvest] end end @@ -350,21 +350,21 @@ describe Crop do @maize.plant_parts.should eq [@pp1] end - context 'search', :elasticsearch do + context "search", :elasticsearch do let(:mushroom) { FactoryBot.create(:crop, name: 'mushroom') } before { sync_elasticsearch([mushroom]) } - it 'finds exact matches' do + it "finds exact matches" do Crop.search('mushroom').should eq [mushroom] end - it 'finds approximate matches' do + it "finds approximate matches" do Crop.search('mush').should eq [mushroom] end it "doesn't find non-matches" do Crop.search('mush').should_not include @crop end - it 'searches case insensitively' do + it "searches case insensitively" do Crop.search('mUsH').should include mushroom end it "doesn't find 'rejected' crop" do @@ -379,141 +379,141 @@ describe Crop do end end - context 'csv loading' do + context "csv loading" do before(:each) do # don't use 'let' for this -- we need to actually create it, # regardless of whether it's used. @cropbot = FactoryBot.create(:cropbot) end - context 'scientific names' do - it 'adds a scientific name to a crop that has none' do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Foo bar'] + context "scientific names" do + it "adds a scientific name to a crop that has none" do + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Foo bar"] tomato = CsvImporter.new.import_crop(row) expect(tomato.scientific_names.size).to eq 1 - expect(tomato.default_scientific_name).to eq 'Foo bar' + expect(tomato.default_scientific_name).to eq "Foo bar" end - it 'picks up scientific name from parent crop if available' do + it "picks up scientific name from parent crop if available" do parent = CsvImporter.new.import_crop( - ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Parentis cropis'] + ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Parentis cropis"] ) tomato = CsvImporter.new.import_crop( - ['Tomato', 'http://en.wikipedia.org/wiki/Parent', 'parent'] + ["Tomato", "http://en.wikipedia.org/wiki/Parent", "parent"] ) expect(tomato.parent).to eq parent - expect(tomato.parent.default_scientific_name).to eq 'Parentis cropis' - expect(tomato.default_scientific_name).to eq 'Parentis cropis' + expect(tomato.parent.default_scientific_name).to eq "Parentis cropis" + expect(tomato.default_scientific_name).to eq "Parentis cropis" end it "doesn't add a duplicate scientific name" do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Foo bar, Foo bar'] + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Foo bar, Foo bar"] tomato = CsvImporter.new.import_crop(row) expect(tomato.scientific_names.size).to eq 1 end it "doesn't add a duplicate scientific name from parent" do CsvImporter.new.import_crop( - ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Parentis cropis'] + ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Parentis cropis"] ) tomato = CsvImporter.new.import_crop( - ['Tomato', 'http://en.wikipedia.org/wiki/Parent', 'parent', 'Parentis cropis'] + ["Tomato", "http://en.wikipedia.org/wiki/Parent", "parent", "Parentis cropis"] ) expect(tomato.scientific_names.size).to eq 1 end - it 'loads a crop with multiple scientific names' do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Foo,Bar'] + it "loads a crop with multiple scientific names" do + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Foo,Bar"] tomato = CsvImporter.new.import_crop(row) - expect(tomato.scientific_names[0].name).to eq 'Foo' - expect(tomato.scientific_names[1].name).to eq 'Bar' + expect(tomato.scientific_names[0].name).to eq "Foo" + expect(tomato.scientific_names[1].name).to eq "Bar" end - it 'loads multiple scientific names with variant spacing' do - row = ['parent', 'http://en.wikipedia.org/wiki/Parent', '', 'Baz, Quux'] + it "loads multiple scientific names with variant spacing" do + row = ["parent", "http://en.wikipedia.org/wiki/Parent", "", "Baz, Quux"] tomato = CsvImporter.new.import_crop(row) expect(tomato.scientific_names.size).to eq 2 - expect(tomato.scientific_names[0].name).to eq 'Baz' - expect(tomato.scientific_names[1].name).to eq 'Quux' + expect(tomato.scientific_names[0].name).to eq "Baz" + expect(tomato.scientific_names[1].name).to eq "Quux" end end # scientific names - context 'alternate names' do - it 'loads an alternate name' do - row = ['tomato', 'http://en.wikipedia.org/wiki/Parent', '', '', 'Foo'] + context "alternate names" do + it "loads an alternate name" do + row = ["tomato", "http://en.wikipedia.org/wiki/Parent", "", "", "Foo"] tomato = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 1 - expect(tomato.alternate_names.last.name).to eq 'Foo' + expect(tomato.alternate_names.last.name).to eq "Foo" end - it 'adds multiple alternate names' do - row = ['tomato', 'http://en.wikipedia.org/wiki/Parent', '', '', 'Foo, Bar'] + it "adds multiple alternate names" do + row = ["tomato", "http://en.wikipedia.org/wiki/Parent", "", "", "Foo, Bar"] tomato = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 2 - expect(tomato.alternate_names[0].name).to eq 'Foo' - expect(tomato.alternate_names[1].name).to eq 'Bar' + expect(tomato.alternate_names[0].name).to eq "Foo" + expect(tomato.alternate_names[1].name).to eq "Bar" end - it 'adds multiple alt names with variant spacing' do - row = ['tomato', 'http://en.wikipedia.org/wiki/Parent', '', '', 'Foo,Bar,Baz, Quux'] + it "adds multiple alt names with variant spacing" do + row = ["tomato", "http://en.wikipedia.org/wiki/Parent", "", "", "Foo,Bar,Baz, Quux"] tomato = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 4 - expect(tomato.alternate_names[0].name).to eq 'Foo' - expect(tomato.alternate_names[1].name).to eq 'Bar' - expect(tomato.alternate_names[2].name).to eq 'Baz' - expect(tomato.alternate_names[3].name).to eq 'Quux' + expect(tomato.alternate_names[0].name).to eq "Foo" + expect(tomato.alternate_names[1].name).to eq "Bar" + expect(tomato.alternate_names[2].name).to eq "Baz" + expect(tomato.alternate_names[3].name).to eq "Quux" end - it 'Adds a duplicate alternate name for second crop' do - row = ['tomato', 'http://en.wikipedia.org/wiki/tomato', '', '', 'Foo'] + it "Adds a duplicate alternate name for second crop" do + row = ["tomato", "http://en.wikipedia.org/wiki/tomato", "", "", "Foo"] tomato = CsvImporter.new.import_crop(row) - row = ['tomoto', 'http://en.wikipedia.org/wiki/tomoto', '', '', 'Foo'] + row = ["tomoto", "http://en.wikipedia.org/wiki/tomoto", "", "", "Foo"] tomoto = CsvImporter.new.import_crop(row) expect(tomato.alternate_names.size).to eq 1 expect(tomoto.alternate_names.size).to eq 1 end end # alternate names - it 'loads the simplest possible crop' do - tomato_row = ['tomato', 'http://en.wikipedia.org/wiki/Tomato'] + it "loads the simplest possible crop" do + tomato_row = ["tomato", "http://en.wikipedia.org/wiki/Tomato"] tomato = CsvImporter.new.import_crop(tomato_row) - expect(tomato.name).to eq 'tomato' + expect(tomato.name).to eq "tomato" expect(tomato.en_wikipedia_url).to eq 'http://en.wikipedia.org/wiki/Tomato' expect(tomato.creator).to eq @cropbot end - it 'loads a crop with a scientific name' do - tomato_row = ['tomato', 'http://en.wikipedia.org/wiki/Tomato', '', 'Solanum lycopersicum'] + it "loads a crop with a scientific name" do + tomato_row = ["tomato", "http://en.wikipedia.org/wiki/Tomato", "", "Solanum lycopersicum"] tomato = CsvImporter.new.import_crop(tomato_row) - expect(tomato.name).to eq 'tomato' + expect(tomato.name).to eq "tomato" expect(tomato.scientific_names.size).to eq 1 - expect(tomato.scientific_names.last.name).to eq 'Solanum lycopersicum' + expect(tomato.scientific_names.last.name).to eq "Solanum lycopersicum" end - it 'loads a crop with an alternate name' do + it "loads a crop with an alternate name" do crop = CsvImporter.new.import_crop( - ['tomato', 'http://en.wikipedia.org/wiki/Tomato', nil, nil, 'Foo'] + ["tomato", "http://en.wikipedia.org/wiki/Tomato", nil, nil, "Foo"] ) - expect(crop.name).to eq 'tomato' + expect(crop.name).to eq "tomato" expect(crop.alternate_names.size).to eq 1 - expect(crop.alternate_names.last.name).to eq 'Foo' + expect(crop.alternate_names.last.name).to eq "Foo" end - it 'loads a crop with a parent' do + it "loads a crop with a parent" do parent = FactoryBot.create(:crop, name: 'parent') crop = CsvImporter.new.import_crop( - ['tomato', 'http://en.wikipedia.org/wiki/Tomato', 'parent'] + ["tomato", "http://en.wikipedia.org/wiki/Tomato", "parent"] ) expect(crop.parent).to eq parent end - it 'loads a crop with a missing parent' do - tomato_row = 'tomato,http://en.wikipedia.org/wiki/Tomato,parent' + it "loads a crop with a missing parent" do + tomato_row = "tomato,http://en.wikipedia.org/wiki/Tomato,parent" CSV.parse(tomato_row) do |row| CsvImporter.new.import_crop(row) @@ -524,40 +524,40 @@ describe Crop do end it "doesn't add unnecessary duplicate crops" do - tomato_row = 'tomato,http://en.wikipedia.org/wiki/Tomato,,Solanum lycopersicum' + tomato_row = "tomato,http://en.wikipedia.org/wiki/Tomato,,Solanum lycopersicum" CSV.parse(tomato_row) do |row| CsvImporter.new.import_crop(row) end loaded = Crop.last - expect(loaded.name).to eq 'tomato' + expect(loaded.name).to eq "tomato" expect(loaded.en_wikipedia_url).to eq 'http://en.wikipedia.org/wiki/Tomato' expect(loaded.creator).to eq @cropbot end end - context 'crop-post association' do + context "crop-post association" do let!(:tomato) { FactoryBot.create(:tomato) } let!(:maize) { FactoryBot.create(:maize) } - let!(:post) { FactoryBot.create(:post, body: '[maize](crop)[tomato](crop)[tomato](crop)') } + let!(:post) { FactoryBot.create(:post, body: "[maize](crop)[tomato](crop)[tomato](crop)") } - describe 'destroying a crop' do + describe "destroying a crop" do before do tomato.destroy end - it 'should delete the association between post and the crop(tomato)' do + it "should delete the association between post and the crop(tomato)" do expect(Post.find(post.id).crops).to eq [maize] end - it 'should not delete the posts' do + it "should not delete the posts" do expect(Post.find(post.id)).not_to eq nil end end end - context 'crop rejections' do + context "crop rejections" do let!(:rejected_reason) do FactoryBot.create(:crop, name: 'tomato', approval_status: 'rejected', @@ -570,13 +570,13 @@ describe Crop do rejection_notes: 'blah blah blah') end - describe 'rejecting a crop' do - it 'should give reason if a default option' do - expect(rejected_reason.rejection_explanation).to eq 'not edible' + describe "rejecting a crop" do + it "should give reason if a default option" do + expect(rejected_reason.rejection_explanation).to eq "not edible" end - it 'should show rejection notes if reason was other' do - expect(rejected_other.rejection_explanation).to eq 'blah blah blah' + it "should show rejection notes if reason was other" do + expect(rejected_other.rejection_explanation).to eq "blah blah blah" end end end diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb index 139695a2f..bd61fe2ee 100644 --- a/spec/models/follow_spec.rb +++ b/spec/models/follow_spec.rb @@ -6,34 +6,34 @@ describe Follow do @member2 = FactoryBot.create(:member) end - it 'sends a notification when a follow is created' do + it "sends a notification when a follow is created" do expect do Follow.create(follower_id: @member1.id, followed_id: @member2.id) end.to change(Notification, :count).by(1) end - it 'does not delete any members when follow is deleted' do + it "does not delete any members when follow is deleted" do expect do follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id) follow.destroy end.not_to change(Member, :count) end - context 'when follow is created' do + context "when follow is created" do before(:each) do @follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id) end - it 'should not duplicate follows' do + it "should not duplicate follows" do expect(Follow.create(follower_id: @member1.id, followed_id: @member2.id)).not_to be_valid end - it 'should list users in following/follower collections when follow is created' do + it "should list users in following/follower collections when follow is created" do expect(@member1.followed).to include(@member2) expect(@member2.followers).to include(@member1) end - it 'should no longer list users in following/follower collections when follow is deleted' do + it "should no longer list users in following/follower collections when follow is deleted" do @follow.destroy expect(@member1.followed).not_to include(@member2) expect(@member2.followers).not_to include(@member1) diff --git a/spec/models/forum_spec.rb b/spec/models/forum_spec.rb index c0d4d47f5..310c36842 100644 --- a/spec/models/forum_spec.rb +++ b/spec/models/forum_spec.rb @@ -3,11 +3,11 @@ require 'rails_helper' describe Forum do let(:forum) { FactoryBot.create(:forum) } - it 'belongs to an owner' do + it "belongs to an owner" do forum.owner.should be_an_instance_of Member end - it 'stringifies nicely' do + it "stringifies nicely" do forum.to_s.should eq forum.name end @@ -15,7 +15,7 @@ describe Forum do forum.slug.should eq 'permaculture' end - it 'has many posts' do + it "has many posts" do @post1 = FactoryBot.create(:forum_post, forum: forum) @post2 = FactoryBot.create(:forum_post, forum: forum) forum.posts.size.should == 2 diff --git a/spec/models/garden_spec.rb b/spec/models/garden_spec.rb index ec7d5fae2..f8e5a3311 100644 --- a/spec/models/garden_spec.rb +++ b/spec/models/garden_spec.rb @@ -4,12 +4,12 @@ describe Garden do let(:owner) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: owner) } - it 'should have a slug' do + it "should have a slug" do garden.slug.should match(/member\d+-springfield-community-garden/) end - it 'should have a description' do - garden.description.should == 'This is a **totally** cool garden' + it "should have a description" do + garden.description.should == "This is a **totally** cool garden" end it "doesn't allow a nil name" do @@ -18,27 +18,27 @@ describe Garden do end it "doesn't allow a blank name" do - garden = FactoryBot.build(:garden, name: '') + garden = FactoryBot.build(:garden, name: "") garden.should_not be_valid end - it 'allows numbers' do - garden = FactoryBot.build(:garden, name: '100 vines of 2 kamo-kamo') + it "allows numbers" do + garden = FactoryBot.build(:garden, name: "100 vines of 2 kamo-kamo") garden.should_not be_valid end - it 'allows brackets' do - garden = FactoryBot.build(:garden, name: 'Garden (second)') + it "allows brackets" do + garden = FactoryBot.build(:garden, name: "Garden (second)") garden.should be_valid end - it 'allows macrons' do - garden = FactoryBot.build(:garden, name: 'Kūmara and pūha patch') + it "allows macrons" do + garden = FactoryBot.build(:garden, name: "Kūmara and pūha patch") garden.should_not be_valid end it "doesn't allow a name with only spaces" do - garden = FactoryBot.build(:garden, name: ' ') + garden = FactoryBot.build(:garden, name: " ") garden.should_not be_valid end @@ -47,15 +47,15 @@ describe Garden do garden.should_not be_valid end - it 'should have an owner' do + it "should have an owner" do garden.owner.should be_an_instance_of Member end - it 'should stringify as its name' do + it "should stringify as its name" do garden.to_s.should == garden.name end - context 'featured plantings' do + context "featured plantings" do let(:tomato) { FactoryBot.create(:tomato) } let(:maize) { FactoryBot.create(:maize) } let(:chard) { FactoryBot.create(:chard) } @@ -63,14 +63,14 @@ describe Garden do let(:pear) { FactoryBot.create(:pear) } let(:walnut) { FactoryBot.create(:walnut) } - it 'should fetch < 4 featured plantings if insufficient exist' do + it "should fetch < 4 featured plantings if insufficient exist" do @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) garden.featured_plantings.should eq [@p2, @p1] end - it 'should fetch most recent 4 featured plantings' do + it "should fetch most recent 4 featured plantings" do @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) @@ -80,7 +80,7 @@ describe Garden do garden.featured_plantings.should eq [@p5, @p4, @p3, @p2] end - it 'should skip repeated plantings' do + it "should skip repeated plantings" do @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) @@ -93,7 +93,7 @@ describe Garden do end end - it 'destroys plantings when deleted' do + it "destroys plantings when deleted" do garden = FactoryBot.create(:garden, owner: owner) @planting1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) @planting2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) @@ -135,7 +135,7 @@ describe Garden do end it "doesn't allow non-numeric quantities" do - garden = FactoryBot.build(:garden, area: '99a') + garden = FactoryBot.build(:garden, area: "99a") garden.should_not be_valid end end @@ -151,7 +151,7 @@ describe Garden do it 'should refuse invalid unit values' do garden = FactoryBot.build(:garden, area_unit: 'not valid') garden.should_not be_valid - garden.errors[:area_unit].should include('not valid is not a valid area unit') + garden.errors[:area_unit].should include("not valid is not a valid area unit") end it 'sets area unit to blank if area is blank' do @@ -175,7 +175,7 @@ describe Garden do end end - it 'marks plantings as finished when garden is inactive' do + it "marks plantings as finished when garden is inactive" do garden = FactoryBot.create(:garden) p1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) p2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) diff --git a/spec/models/harvest_spec.rb b/spec/models/harvest_spec.rb index da6f06aa8..1944c6365 100644 --- a/spec/models/harvest_spec.rb +++ b/spec/models/harvest_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' describe Harvest do - it 'has an owner' do + it "has an owner" do harvest = FactoryBot.create(:harvest) harvest.owner.should be_an_instance_of Member end - it 'has a crop' do + it "has a crop" do harvest = FactoryBot.create(:harvest) harvest.crop.should be_an_instance_of Crop end @@ -38,7 +38,7 @@ describe Harvest do end it "doesn't allow non-numeric quantities" do - @harvest = FactoryBot.build(:harvest, quantity: '99a') + @harvest = FactoryBot.build(:harvest, quantity: "99a") @harvest.should_not be_valid end end @@ -55,7 +55,7 @@ describe Harvest do it 'should refuse invalid unit values' do @harvest = FactoryBot.build(:harvest, unit: 'not valid') @harvest.should_not be_valid - @harvest.errors[:unit].should include('not valid is not a valid unit') + @harvest.errors[:unit].should include("not valid is not a valid unit") end it 'sets unit to blank if quantity is blank' do @@ -92,7 +92,7 @@ describe Harvest do end it "doesn't allow non-numeric weight quantities" do - @harvest = FactoryBot.build(:harvest, weight_quantity: '99a') + @harvest = FactoryBot.build(:harvest, weight_quantity: "99a") @harvest.should_not be_valid end end @@ -108,7 +108,7 @@ describe Harvest do it 'should refuse invalid weight unit values' do @harvest = FactoryBot.build(:harvest, weight_unit: 'not valid') @harvest.should_not be_valid - @harvest.errors[:weight_unit].should include('not valid is not a valid unit') + @harvest.errors[:weight_unit].should include("not valid is not a valid unit") end it 'sets weight_unit to blank if quantity is blank' do @@ -118,21 +118,21 @@ describe Harvest do end end - context 'standardized weights' do + context "standardized weights" do it 'converts from pounds' do - @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: 'lb') + @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: "lb") @harvest.should be_valid @harvest.reload.si_weight.should eq 0.907 end it 'converts from ounces' do - @harvest = FactoryBot.create(:harvest, weight_quantity: 16, weight_unit: 'oz') + @harvest = FactoryBot.create(:harvest, weight_quantity: 16, weight_unit: "oz") @harvest.should be_valid @harvest.reload.si_weight.should eq 0.454 end it 'leaves kg alone' do - @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: 'kg') + @harvest = FactoryBot.create(:harvest, weight_quantity: 2, weight_unit: "kg") @harvest.should be_valid @harvest.reload.si_weight.should eq 2.0 end @@ -146,79 +146,79 @@ describe Harvest do end end - context 'stringification' do - let(:crop) { FactoryBot.create(:crop, name: 'apricot') } + context "stringification" do + let(:crop) { FactoryBot.create(:crop, name: "apricot") } - it 'apricots' do + it "apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: nil, unit: nil, weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq 'apricots' + @h.to_s.should eq "apricots" end - it '1 individual apricot' do + it "1 individual apricot" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 1, unit: 'individual', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '1 individual apricot' + @h.to_s.should eq "1 individual apricot" end - it '10 individual apricots' do + it "10 individual apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 10, unit: 'individual', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '10 individual apricots' + @h.to_s.should eq "10 individual apricots" end - it '1 bushel of apricots' do + it "1 bushel of apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 1, unit: 'bushel', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '1 bushel of apricots' + @h.to_s.should eq "1 bushel of apricots" end - it '1.5 bushels of apricots' do + it "1.5 bushels of apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 1.5, unit: 'bushel', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '1.5 bushels of apricots' + @h.to_s.should eq "1.5 bushels of apricots" end - it '10 bushels of apricots' do + it "10 bushels of apricots" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 10, unit: 'bushel', weight_quantity: nil, weight_unit: nil) - @h.to_s.should eq '10 bushels of apricots' + @h.to_s.should eq "10 bushels of apricots" end - it 'apricots weighing 1.2 kg' do + it "apricots weighing 1.2 kg" do @h = FactoryBot.create(:harvest, crop: crop, quantity: nil, unit: nil, weight_quantity: 1.2, weight_unit: 'kg') - @h.to_s.should eq 'apricots weighing 1.2 kg' + @h.to_s.should eq "apricots weighing 1.2 kg" end - it '10 bushels of apricots weighing 100 kg' do + it "10 bushels of apricots weighing 100 kg" do @h = FactoryBot.create(:harvest, crop: crop, quantity: 10, unit: 'bushel', weight_quantity: 100, weight_unit: 'kg') - @h.to_s.should eq '10 bushels of apricots weighing 100 kg' + @h.to_s.should eq "10 bushels of apricots weighing 100 kg" end end diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index 7bdee1fee..cf7b81486 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -28,7 +28,7 @@ describe 'member' do member.account.should be_an_instance_of Account end - it 'should have a default-type account by default' do + it "should have a default-type account by default" do member.account.account_type.name.should eq Growstuff::Application.config.default_account_type member.paid?.should be(false) end @@ -48,7 +48,7 @@ describe 'member' do end it 'should be able to fetch gardens' do - member.gardens.first.name.should eq 'Garden' + member.gardens.first.name.should eq "Garden" end it 'has many plantings' do @@ -56,19 +56,19 @@ describe 'member' do member.plantings.size.should eq 1 end - it 'has many comments' do + it "has many comments" do FactoryBot.create(:comment, author: member) FactoryBot.create(:comment, author: member) member.comments.size.should == 2 end - it 'has many forums' do + it "has many forums" do FactoryBot.create(:forum, owner: member) FactoryBot.create(:forum, owner: member) member.forums.size.should == 2 end - it 'has many likes' do + it "has many likes" do @post1 = FactoryBot.create(:post, author: member) @post2 = FactoryBot.create(:post, author: member) @like1 = FactoryBot.create(:like, member: member, likeable: @post1) @@ -118,24 +118,24 @@ describe 'member' do end context 'same :login_name' do - it 'should not allow two members with the same login_name' do - FactoryBot.create(:member, login_name: 'bob') - member = FactoryBot.build(:member, login_name: 'bob') + it "should not allow two members with the same login_name" do + FactoryBot.create(:member, login_name: "bob") + member = FactoryBot.build(:member, login_name: "bob") member.should_not be_valid - member.errors[:login_name].should include('has already been taken') + member.errors[:login_name].should include("has already been taken") end - it 'tests uniqueness case-insensitively' do - FactoryBot.create(:member, login_name: 'bob') - member = FactoryBot.build(:member, login_name: 'BoB') + it "tests uniqueness case-insensitively" do + FactoryBot.create(:member, login_name: "bob") + member = FactoryBot.build(:member, login_name: "BoB") member.should_not be_valid - member.errors[:login_name].should include('has already been taken') + member.errors[:login_name].should include("has already been taken") end end context 'case sensitivity' do it 'preserves case of login name' do - FactoryBot.create(:member, login_name: 'BOB') + FactoryBot.create(:member, login_name: "BOB") Member.find('bob').login_name.should eq 'BOB' end end @@ -144,40 +144,40 @@ describe 'member' do it "doesn't allow short names" do member = FactoryBot.build(:invalid_member_shortname) member.should_not be_valid - member.errors[:login_name].should include('should be between 2 and 25 characters long') + member.errors[:login_name].should include("should be between 2 and 25 characters long") end it "doesn't allow really long names" do member = FactoryBot.build(:invalid_member_longname) member.should_not be_valid - member.errors[:login_name].should include('should be between 2 and 25 characters long') + member.errors[:login_name].should include("should be between 2 and 25 characters long") end it "doesn't allow spaces in names" do member = FactoryBot.build(:invalid_member_spaces) member.should_not be_valid - member.errors[:login_name].should include('may only include letters, numbers, or underscores') + member.errors[:login_name].should include("may only include letters, numbers, or underscores") end it "doesn't allow other chars in names" do member = FactoryBot.build(:invalid_member_badchars) member.should_not be_valid - member.errors[:login_name].should include('may only include letters, numbers, or underscores') + member.errors[:login_name].should include("may only include letters, numbers, or underscores") end it "doesn't allow reserved names" do member = FactoryBot.build(:invalid_member_badname) member.should_not be_valid - member.errors[:login_name].should include('name is reserved') + member.errors[:login_name].should include("name is reserved") end end context 'valid login names' do - it 'allows plain alphanumeric chars in names' do + it "allows plain alphanumeric chars in names" do member = FactoryBot.build(:valid_member_alphanumeric) member.should be_valid end - it 'allows uppercase chars in names' do + it "allows uppercase chars in names" do member = FactoryBot.build(:valid_member_uppercase) member.should be_valid end - it 'allows underscores in names' do + it "allows underscores in names" do member = FactoryBot.build(:valid_member_underscore) member.should be_valid end @@ -203,7 +203,7 @@ describe 'member' do it 'converts role names properly' do # need to make sure spaces get turned to underscores - role = FactoryBot.create(:role, name: 'a b c') + role = FactoryBot.create(:role, name: "a b c") member.roles << role member.role?(:a_b_c).should eq true end @@ -310,17 +310,17 @@ describe 'member' do end end - context 'paid accounts' do + context "paid accounts" do let(:member) { FactoryBot.create(:member) } - it 'recognises a permanent paid account' do + it "recognises a permanent paid account" do account_type = FactoryBot.create(:account_type, is_paid: true, is_permanent_paid: true) member.account.account_type = account_type member.paid?.should be(true) end - it 'recognises a current paid account' do + it "recognises a current paid account" do account_type = FactoryBot.create(:account_type, is_paid: true, is_permanent_paid: false) member.account.account_type = account_type @@ -328,7 +328,7 @@ describe 'member' do member.paid?.should be(true) end - it 'recognises an expired paid account' do + it "recognises an expired paid account" do account_type = FactoryBot.create(:account_type, is_paid: true, is_permanent_paid: false) member.account.account_type = account_type @@ -336,14 +336,14 @@ describe 'member' do member.paid?.should be(false) end - it 'recognises a free account' do + it "recognises a free account" do account_type = FactoryBot.create(:account_type, is_paid: false, is_permanent_paid: false) member.account.account_type = account_type member.paid?.should be(false) end - it 'recognises a free account even with paid_until set' do + it "recognises a free account even with paid_until set" do account_type = FactoryBot.create(:account_type, is_paid: false, is_permanent_paid: false) member.account.account_type = account_type @@ -352,19 +352,19 @@ describe 'member' do end end - context 'update account' do + context "update account" do let(:product) do FactoryBot.create(:product, paid_months: 3) end let(:member) { FactoryBot.create(:member) } - it 'sets account_type' do + it "sets account_type" do member.update_account_after_purchase(product) member.account.account_type.should eq product.account_type end - it 'sets paid_until' do + it "sets paid_until" do member.account.paid_until = nil # blank for now, as if never paid before member.update_account_after_purchase(product) @@ -417,7 +417,7 @@ describe 'member' do context 'subscriptions' do let(:member) { FactoryBot.create(:member) } - let(:gb) { instance_double('Gibbon::API.new') } + let(:gb) { instance_double("Gibbon::API.new") } it 'subscribes to the newsletter' do expect(gb).to receive_message_chain('lists.subscribe') @@ -444,12 +444,12 @@ describe 'member' do it { expect(Member.interesting).not_to include(member) } it { expect(Member.has_plantings).not_to include(member) } end - it 'unsubscribes from mailing list' do + it "unsubscribes from mailing list" do expect(member).to receive(:newsletter_unsubscribe).and_return(true) member.destroy end - context 'deleted admin member' do + context "deleted admin member" do let(:member) { FactoryBot.create(:admin_member) } before { member.destroy } @@ -457,7 +457,7 @@ describe 'member' do context 'crop creator' do let!(:crop) { FactoryBot.create(:crop, creator: member) } - it 'leaves crops behind, reassigned to cropbot' do + it "leaves crops behind, reassigned to cropbot" do expect(Crop.all).to include(crop) end end @@ -465,7 +465,7 @@ describe 'member' do context 'forum owners' do let!(:forum) { FactoryBot.create(:forum, owner: member) } - it 'leaves forums behind, reassigned to ex_admin' do + it "leaves forums behind, reassigned to ex_admin" do expect(forum.owner).to eq(member) end end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 96d390215..4f04573d5 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -3,19 +3,19 @@ require 'rails_helper' describe Notification do let(:notification) { FactoryBot.create(:notification) } - it 'belongs to a post' do + it "belongs to a post" do notification.post.should be_an_instance_of Post end - it 'belongs to a recipient' do + it "belongs to a recipient" do notification.recipient.should be_an_instance_of Member end - it 'belongs to a sender' do + it "belongs to a sender" do notification.sender.should be_an_instance_of Member end - it 'has a scope for unread' do + it "has a scope for unread" do Notification.unread.should eq [notification] @n2 = FactoryBot.create(:notification, read: true) Notification.unread.should eq [notification] @@ -24,13 +24,13 @@ describe Notification do Notification.unread.should include notification end - it 'counts unread' do + it "counts unread" do @who = notification.recipient @n2 = FactoryBot.create(:notification, recipient: @who, read: false) @who.notifications.unread_count.should eq 2 end - it 'sends email if asked' do + it "sends email if asked" do @notification2 = FactoryBot.create(:notification) @notification2.send_email ActionMailer::Base.deliveries.last.to.should == [@notification2.recipient.email] @@ -42,18 +42,18 @@ describe Notification do ActionMailer::Base.deliveries.last.to.should_not == [notification.recipient.email] end - it 'sends email on creation' do + it "sends email on creation" do @notification2 = FactoryBot.create(:notification) ActionMailer::Base.deliveries.last.to.should == [@notification2.recipient.email] end - it 'replaces missing subjects with (no subject)' do + it "replaces missing subjects with (no subject)" do notification = FactoryBot.create(:notification, subject: nil) - notification.subject.should == '(no subject)' + notification.subject.should == "(no subject)" end - it 'replaces whitespace-only subjects with (no subject)' do - notification = FactoryBot.create(:notification, subject: ' ') - notification.subject.should == '(no subject)' + it "replaces whitespace-only subjects with (no subject)" do + notification = FactoryBot.create(:notification, subject: " ") + notification.subject.should == "(no subject)" end end diff --git a/spec/models/order_item_spec.rb b/spec/models/order_item_spec.rb index 1d9835d7d..7c2de24c6 100644 --- a/spec/models/order_item_spec.rb +++ b/spec/models/order_item_spec.rb @@ -3,12 +3,12 @@ require 'rails_helper' describe OrderItem do let(:order_item) { FactoryBot.create(:order_item) } - it 'has an order and a product' do + it "has an order and a product" do order_item.order.should be_an_instance_of Order order_item.product.should be_an_instance_of Product end - it 'validates price > product.min_price' do + it "validates price > product.min_price" do @product = FactoryBot.create(:product) order_item = FactoryBot.build(:order_item, price: @product.min_price - 1) order_item.should_not be_valid diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index 87ae130a9..9abb381ba 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -16,7 +16,7 @@ describe Order do @order2 = Order.create!(member_id: @member2.id) end - it 'only returns orders belonging to member' do + it "only returns orders belonging to member" do Order.by_member(@member1).should eq [@order1] end end @@ -43,7 +43,7 @@ describe Order do @member.account.paid_until.should_not be_nil end - it 'totals the amount due' do + it "totals the amount due" do @member = FactoryBot.create(:member) @order = FactoryBot.create(:order, member: @member) @product = FactoryBot.create(:product, @@ -56,7 +56,7 @@ describe Order do @order.total.should eq 1111 end - it 'gives the correct total for quantities more than 1' do + it "gives the correct total for quantities more than 1" do @member = FactoryBot.create(:member) @order = FactoryBot.create(:order, member: @member) @product = FactoryBot.create(:product, @@ -69,7 +69,7 @@ describe Order do @order.total.should eq 2222 end - it 'formats order items for activemerchant' do + it "formats order items for activemerchant" do @member = FactoryBot.create(:member) @order = FactoryBot.create(:order, member: @member) @product = FactoryBot.create(:product, @@ -87,18 +87,18 @@ describe Order do }] end - context 'referral codes' do - it 'has a referral code' do + context "referral codes" do + it "has a referral code" do referred_order = FactoryBot.create(:referred_order) referred_order.referral_code.should_not be nil end - it 'validates referral codes' do + it "validates referral codes" do referred_order = FactoryBot.build(:order, referral_code: 'CAMP_AIGN1?') referred_order.should_not be_valid end - it 'cleans up messy referral codes' do + it "cleans up messy referral codes" do referred_order = FactoryBot.create(:order, referral_code: 'CaMpAiGn 1 ') referred_order.referral_code.should eq 'CAMPAIGN1' end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 4400f7d2f..5f07a3e29 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -9,7 +9,7 @@ describe Photo do let(:harvest) { FactoryBot.create(:harvest) } let(:garden) { FactoryBot.create(:garden) } - context 'adds photos' do + context "adds photos" do it 'to a planting' do planting.photos << photo expect(planting.photos.size).to eq 1 @@ -29,7 +29,7 @@ describe Photo do end end - context 'removing photos' do + context "removing photos" do it 'from a planting' do planting.photos << photo photo.destroy @@ -48,7 +48,7 @@ describe Photo do expect(garden.photos.size).to eq 0 end - it 'automatically if unused' do + it "automatically if unused" do photo.destroy_if_unused expect(-> { photo.reload }).to raise_error ActiveRecord::RecordNotFound end diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index 266b75ed7..60a95c245 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -162,11 +162,11 @@ describe Planting do planting.owner.should be_an_instance_of Member end - it 'generates a location' do + it "generates a location" do planting.location.should eq "#{garden_owner.login_name}'s #{garden.name}" end - it 'should have a slug' do + it "should have a slug" do planting.slug.should match(/^member\d+-springfield-community-garden-tomato$/) end @@ -176,15 +176,15 @@ describe Planting do end describe '#planted?' do - it 'should be false for future plantings' do + it "should be false for future plantings" do planting = FactoryBot.create :planting, planted_at: Time.zone.today + 1 expect(planting.planted?).to eq(false) end - it 'should be false for never planted' do + it "should be false for never planted" do planting = FactoryBot.create :planting, planted_at: nil expect(planting.planted?).to eq(false) end - it 'should be true for past plantings' do + it "should be true for past plantings" do planting = FactoryBot.create :planting, planted_at: Time.zone.today - 1 expect(planting.planted?).to eq(true) end @@ -224,7 +224,7 @@ describe Planting do @planting.should_not be_valid end - it 'allows blank quantities' do + it "allows blank quantities" do @planting = FactoryBot.build(:planting, quantity: nil) @planting.should be_valid @planting = FactoryBot.build(:planting, quantity: '') @@ -249,7 +249,7 @@ describe Planting do it 'should refuse invalid sunniness values' do @planting = FactoryBot.build(:planting, sunniness: 'not valid') @planting.should_not be_valid - @planting.errors[:sunniness].should include('not valid is not a valid sunniness value') + @planting.errors[:sunniness].should include("not valid is not a valid sunniness value") end end @@ -271,7 +271,7 @@ describe Planting do it 'should refuse invalid planted_from values' do @planting = FactoryBot.build(:planting, planted_from: 'not valid') @planting.should_not be_valid - @planting.errors[:planted_from].should include('not valid is not a valid planting method') + @planting.errors[:planted_from].should include("not valid is not a valid planting method") end end @@ -336,7 +336,7 @@ describe Planting do end end - context 'default arguments' do + context "default arguments" do it 'ignores plantings without photos' do # first, an interesting planting @planting = FactoryBot.create(:planting) @@ -370,8 +370,8 @@ describe Planting do end end - context 'with howmany argument' do - it 'only returns the number asked for' do + context "with howmany argument" do + it "only returns the number asked for" do @plantings = FactoryBot.create_list(:planting, 10) @plantings.each do |p| p.photos << FactoryBot.create(:photo, owner: planting.owner) @@ -381,7 +381,7 @@ describe Planting do end end # interesting plantings - context 'finished' do + context "finished" do it 'has finished fields' do @planting = FactoryBot.create(:finished_planting) @planting.finished.should be true @@ -402,7 +402,7 @@ describe Planting do Planting.current.should_not include @f end - context 'finished date validation' do + context "finished date validation" do it 'requires finished date after planting date' do @f = FactoryBot.build(:finished_planting, planted_at: '2014-01-01', finished_at: '2013-01-01') @f.should_not be_valid diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 4eb8d6ad6..98880ce2b 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -3,33 +3,33 @@ require 'rails_helper' describe Post do let(:member) { FactoryBot.create(:member) } - it_behaves_like 'it is likeable' + it_behaves_like "it is likeable" - it 'should have a slug' do + it "should have a slug" do post = FactoryBot.create(:post, author: member) time = post.created_at - datestr = time.strftime('%Y%m%d') + datestr = time.strftime("%Y%m%d") # 2 digit day and month, full-length years # Counting digits using Math.log is not precise enough! datestr.size.should eq(4 + time.year.to_s.size) post.slug.should eq("#{member.login_name}-#{datestr}-a-post") end - it 'has many comments' do + it "has many comments" do post = FactoryBot.create(:post, author: member) FactoryBot.create(:comment, post: post) FactoryBot.create(:comment, post: post) post.comments.size.should == 2 end - it 'supports counting comments' do + it "supports counting comments" do post = FactoryBot.create(:post, author: member) FactoryBot.create(:comment, post: post) FactoryBot.create(:comment, post: post) post.comment_count.should == 2 end - it 'destroys comments when deleted' do + it "destroys comments when deleted" do post = FactoryBot.create(:post, author: member) FactoryBot.create(:comment, post: post) FactoryBot.create(:comment, post: post) @@ -39,7 +39,7 @@ describe Post do Comment.count.should eq(all - 2) end - it 'belongs to a forum' do + it "belongs to a forum" do post = FactoryBot.create(:forum_post) post.forum.should be_an_instance_of Forum end @@ -50,40 +50,40 @@ describe Post do end it "doesn't allow a blank subject" do - post = FactoryBot.build(:post, subject: '') + post = FactoryBot.build(:post, subject: "") post.should_not be_valid end it "doesn't allow a subject with only spaces" do - post = FactoryBot.build(:post, subject: ' ') + post = FactoryBot.build(:post, subject: " ") post.should_not be_valid end - context 'recent activity' do + context "recent activity" do before do Time.stub(now: Time.now) end let!(:post) { FactoryBot.create(:post, created_at: 1.day.ago) } - it 'sets recent activity to post time' do + it "sets recent activity to post time" do post.recent_activity.to_i.should eq post.created_at.to_i end - it 'sets recent activity to comment time' do + it "sets recent activity to comment time" do comment = FactoryBot.create(:comment, post: post, created_at: 1.hour.ago) post.recent_activity.to_i.should eq comment.created_at.to_i end - it 'shiny new post is recently active' do + it "shiny new post is recently active" do # create a shiny new post post2 = FactoryBot.create(:post, created_at: 1.minute.ago) Post.recently_active.first.should eq post2 Post.recently_active.second.should eq post end - it 'new comment on old post is recently active' do + it "new comment on old post is recently active" do # now comment on an older post post2 = FactoryBot.create(:post, created_at: 1.minute.ago) FactoryBot.create(:comment, post: post, created_at: 1.second.ago) @@ -92,22 +92,22 @@ describe Post do end end - context 'notifications' do + context "notifications" do let(:member2) { FactoryBot.create(:member) } - it 'sends a notification when a member is mentioned using @-syntax' do + it "sends a notification when a member is mentioned using @-syntax" do expect do FactoryBot.create(:post, author: member, body: "Hey @#{member2}") end.to change(Notification, :count).by(1) end - it 'sends a notification when a member is mentioned using [](member) syntax' do + it "sends a notification when a member is mentioned using [](member) syntax" do expect do FactoryBot.create(:post, author: member, body: "Hey [#{member2}](member)") end.to change(Notification, :count).by(1) end - it 'sets the notification field' do + it "sets the notification field" do p = FactoryBot.create(:post, author: member, body: "Hey @#{member2}") n = Notification.first n.sender.should eq member @@ -116,7 +116,7 @@ describe Post do n.body.should eq p.body end - it 'sends notifications to all members mentioned' do + it "sends notifications to all members mentioned" do member3 = FactoryBot.create(:member) expect do FactoryBot.create(:post, author: member, body: "Hey @#{member2} & @#{member3}") @@ -130,23 +130,23 @@ describe Post do end end - context 'crop-post association' do + context "crop-post association" do let!(:tomato) { FactoryBot.create(:tomato) } let!(:maize) { FactoryBot.create(:maize) } let!(:chard) { FactoryBot.create(:chard) } - let!(:post) { FactoryBot.create(:post, body: '[maize](crop)[tomato](crop)[tomato](crop)') } + let!(:post) { FactoryBot.create(:post, body: "[maize](crop)[tomato](crop)[tomato](crop)") } - it 'should be generated' do + it "should be generated" do expect(tomato.posts).to eq [post] expect(maize.posts).to eq [post] end - it 'should not duplicate' do + it "should not duplicate" do expect(post.crops) =~ [tomato, maize] end - it 'should be updated when post was modified' do - post.update_attributes(body: '[chard](crop)') + it "should be updated when post was modified" do + post.update_attributes(body: "[chard](crop)") expect(post.crops).to eq [chard] expect(chard.posts).to eq [post] @@ -154,17 +154,17 @@ describe Post do expect(maize.posts).to eq [] end - describe 'destroying the post' do + describe "destroying the post" do before do post.destroy end - it 'should delete the association' do + it "should delete the association" do expect(Crop.find(tomato.id).posts).to eq [] expect(Crop.find(maize.id).posts).to eq [] end - it 'should not delete the crops' do + it "should not delete the crops" do expect(Crop.find(tomato.id)).not_to eq nil expect(Crop.find(maize.id)).not_to eq nil end diff --git a/spec/models/product_spec.rb b/spec/models/product_spec.rb index 1ff0ba516..2cc684667 100644 --- a/spec/models/product_spec.rb +++ b/spec/models/product_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe Product do - it 'stringifies using the name' do + it "stringifies using the name" do @product = FactoryBot.create(:product) @product.to_s.should eq @product.name end diff --git a/spec/models/seed_spec.rb b/spec/models/seed_spec.rb index 020e37741..e45d0e240 100644 --- a/spec/models/seed_spec.rb +++ b/spec/models/seed_spec.rb @@ -7,7 +7,7 @@ describe Seed do seed.save.should be(true) end - it 'should have a slug' do + it "should have a slug" do seed.save seed.slug.should match(/member\d+-magic-bean/) end @@ -28,7 +28,7 @@ describe Seed do @seed.should_not be_valid end - it 'allows blank quantities' do + it "allows blank quantities" do @seed = FactoryBot.build(:seed, quantity: nil) @seed.should be_valid @seed = FactoryBot.build(:seed, quantity: '') @@ -48,8 +48,8 @@ describe Seed do @seed = FactoryBot.build(:seed, tradable_to: 'not valid') @seed.should_not be_valid @seed.errors[:tradable_to].should include( - 'You may only trade seed nowhere, locally, '\ - 'nationally, or internationally' + "You may only trade seed nowhere, locally, "\ + "nationally, or internationally" ) end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index dfced9e4b..e28dd6e24 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,5 +1,5 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' -ENV['RAILS_ENV'] ||= 'test' +ENV["RAILS_ENV"] ||= 'test' require 'simplecov' require 'coveralls' @@ -17,7 +17,7 @@ SimpleCov.start :rails do end require 'spec_helper' -require File.expand_path('../../config/environment', __FILE__) +require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! Rails.application.eager_load! @@ -58,8 +58,8 @@ include Warden::Test::Helpers # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. # -Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } -Dir[Rails.root.join('spec/features/shared_examples/**/*.rb')].each { |f| require f } +Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } +Dir[Rails.root.join("spec/features/shared_examples/**/*.rb")].each { |f| require f } # Checks for pending migrations before tests are run. # If you are not using ActiveRecord, you can remove this line. diff --git a/spec/requests/api/v1/crop_request_spec.rb b/spec/requests/api/v1/crop_request_spec.rb index 936d1a7a6..6a392eb74 100644 --- a/spec/requests/api/v1/crop_request_spec.rb +++ b/spec/requests/api/v1/crop_request_spec.rb @@ -5,53 +5,53 @@ RSpec.describe 'Plantings', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:crop) { FactoryBot.create :crop } let(:crop_encoded_as_json_api) do - { 'id' => crop.id.to_s, - 'type' => 'crops', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'plantings' => plantings_as_json_api, - 'parent' => parent_as_json_api, - 'photos' => photos_as_json_api, - 'harvests' => harvests_as_json_api + { "id" => crop.id.to_s, + "type" => "crops", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "plantings" => plantings_as_json_api, + "parent" => parent_as_json_api, + "photos" => photos_as_json_api, + "harvests" => harvests_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/crops/#{crop.id}" } let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:parent_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/parent", - 'related' => "#{resource_url}/parent" } } + { "links" => + { "self" => "#{resource_url}/relationships/parent", + "related" => "#{resource_url}/parent" } } end let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:attributes) do { - 'name' => crop.name, - 'en-wikipedia-url' => crop.en_wikipedia_url, - 'perennial' => false, - 'median-lifespan' => nil, - 'median-days-to-first-harvest' => nil, - 'median-days-to-last-harvest' => nil + "name" => crop.name, + "en-wikipedia-url" => crop.en_wikipedia_url, + "perennial" => false, + "median-lifespan" => nil, + "median-days-to-first-harvest" => nil, + "median-days-to-last-harvest" => nil } end @@ -63,25 +63,25 @@ RSpec.describe 'Plantings', type: :request do describe '#show' do before { get "/api/v1/crops/#{crop.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('plantings' => plantings_as_json_api) } - it { expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) } - it { expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) } - it { expect(subject['data']['relationships']).to include('parent' => parent_as_json_api) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("parent" => parent_as_json_api) } it { expect(subject['data']).to eq(crop_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/crops', { 'crop' => { 'name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/crops/#{crop.id}", { 'crop' => { 'name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/crops/#{crop.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/gardens_request_spec.rb b/spec/requests/api/v1/gardens_request_spec.rb index 234606bcd..d6005e286 100644 --- a/spec/requests/api/v1/gardens_request_spec.rb +++ b/spec/requests/api/v1/gardens_request_spec.rb @@ -5,36 +5,36 @@ RSpec.describe 'Gardens', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:garden) { FactoryBot.create :garden } let(:garden_encoded_as_json_api) do - { 'id' => garden.id.to_s, - 'type' => 'gardens', - 'links' => { 'self' => resource_url }, - 'attributes' => { 'name' => garden.name }, - 'relationships' => + { "id" => garden.id.to_s, + "type" => "gardens", + "links" => { "self" => resource_url }, + "attributes" => { "name" => garden.name }, + "relationships" => { - 'owner' => owner_as_json_api, - 'plantings' => plantings_as_json_api, - 'photos' => photos_as_json_api + "owner" => owner_as_json_api, + "plantings" => plantings_as_json_api, + "photos" => photos_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/gardens/#{garden.id}" } let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end scenario '#index' do @@ -49,16 +49,16 @@ RSpec.describe 'Gardens', type: :request do scenario '#create' do post '/api/v1/gardens', { 'garden' => { 'name' => 'can i make this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#update' do post "/api/v1/gardens/#{garden.id}", { 'garden' => { 'name' => 'can i modify this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#delete' do delete "/api/v1/gardens/#{garden.id}", {}, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end end diff --git a/spec/requests/api/v1/harvest_request_spec.rb b/spec/requests/api/v1/harvest_request_spec.rb index b685b2990..af2d4201e 100644 --- a/spec/requests/api/v1/harvest_request_spec.rb +++ b/spec/requests/api/v1/harvest_request_spec.rb @@ -5,54 +5,54 @@ RSpec.describe 'Harvests', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:harvest) { FactoryBot.create :harvest } let(:harvest_encoded_as_json_api) do - { 'id' => harvest.id.to_s, - 'type' => 'harvests', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'crop' => crop_as_json_api, - 'planting' => planting_as_json_api, - 'owner' => owner_as_json_api, - 'photos' => photos_as_json_api + { "id" => harvest.id.to_s, + "type" => "harvests", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "crop" => crop_as_json_api, + "planting" => planting_as_json_api, + "owner" => owner_as_json_api, + "photos" => photos_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/harvests/#{harvest.id}" } let(:crop_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/crop", - 'related' => "#{resource_url}/crop" } } + "related" => "#{resource_url}/crop" } } end let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:planting_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/planting", - 'related' => "#{resource_url}/planting" } } + "related" => "#{resource_url}/planting" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:attributes) do { - 'harvested-at' => '2015-09-17', - 'description' => harvest.description, - 'unit' => harvest.unit, - 'weight-quantity' => harvest.weight_quantity.to_s, - 'weight-unit' => harvest.weight_unit, - 'si-weight' => harvest.si_weight + "harvested-at" => "2015-09-17", + "description" => harvest.description, + "unit" => harvest.unit, + "weight-quantity" => harvest.weight_quantity.to_s, + "weight-unit" => harvest.weight_unit, + "si-weight" => harvest.si_weight } end @@ -64,25 +64,25 @@ RSpec.describe 'Harvests', type: :request do describe '#show' do before { get "/api/v1/harvests/#{harvest.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('planting' => planting_as_json_api) } - it { expect(subject['data']['relationships']).to include('crop' => crop_as_json_api) } - it { expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) } - it { expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include("planting" => planting_as_json_api) } + it { expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } it { expect(subject['data']).to eq(harvest_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/harvests', { 'harvest' => { 'description' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/harvests/#{harvest.id}", { 'harvest' => { 'description' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/harvests/#{harvest.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/member_request_spec.rb b/spec/requests/api/v1/member_request_spec.rb index 2e9977132..6067e59b6 100644 --- a/spec/requests/api/v1/member_request_spec.rb +++ b/spec/requests/api/v1/member_request_spec.rb @@ -5,54 +5,54 @@ RSpec.describe 'Members', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:member) { FactoryBot.create :member } let(:member_encoded_as_json_api) do - { 'id' => member.id.to_s, - 'type' => 'members', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'gardens' => gardens_as_json_api, - 'harvests' => harvests_as_json_api, - 'photos' => photos_as_json_api, - 'plantings' => plantings_as_json_api, - 'seeds' => seeds_as_json_api + { "id" => member.id.to_s, + "type" => "members", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "gardens" => gardens_as_json_api, + "harvests" => harvests_as_json_api, + "photos" => photos_as_json_api, + "plantings" => plantings_as_json_api, + "seeds" => seeds_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/members/#{member.id}" } let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:seeds_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/seeds", - 'related' => "#{resource_url}/seeds" } } + { "links" => + { "self" => "#{resource_url}/relationships/seeds", + "related" => "#{resource_url}/seeds" } } end let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:gardens_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/gardens", - 'related' => "#{resource_url}/gardens" } } + { "links" => + { "self" => "#{resource_url}/relationships/gardens", + "related" => "#{resource_url}/gardens" } } end let(:attributes) do { - 'login-name' => member.login_name + "login-name" => member.login_name } end @@ -63,26 +63,26 @@ RSpec.describe 'Members', type: :request do describe '#show' do before { get "/api/v1/members/#{member.id}", {}, headers } - it { expect(subject['data']['relationships']).to include('gardens' => gardens_as_json_api) } - it { expect(subject['data']['relationships']).to include('plantings' => plantings_as_json_api) } - it { expect(subject['data']['relationships']).to include('seeds' => seeds_as_json_api) } - it { expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) } - it { expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("gardens" => gardens_as_json_api) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("seeds" => seeds_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } it { expect(subject['data']).to eq(member_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/members', { 'member' => { 'login_name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/members/#{member.id}", { 'member' => { 'login_name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/members/#{member.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/photos_request_spec.rb b/spec/requests/api/v1/photos_request_spec.rb index 6f5c1434b..e9e584a60 100644 --- a/spec/requests/api/v1/photos_request_spec.rb +++ b/spec/requests/api/v1/photos_request_spec.rb @@ -5,52 +5,52 @@ RSpec.describe 'Photos', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:photo) { FactoryBot.create :photo } let(:photo_encoded_as_json_api) do - { 'id' => photo.id.to_s, - 'type' => 'photos', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'owner' => owner_as_json_api, - 'plantings' => plantings_as_json_api, - 'harvests' => harvests_as_json_api, - 'gardens' => gardens_as_json_api + { "id" => photo.id.to_s, + "type" => "photos", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "owner" => owner_as_json_api, + "plantings" => plantings_as_json_api, + "harvests" => harvests_as_json_api, + "gardens" => gardens_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/photos/#{photo.id}" } let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:gardens_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/gardens", - 'related' => "#{resource_url}/gardens" } } + { "links" => + { "self" => "#{resource_url}/relationships/gardens", + "related" => "#{resource_url}/gardens" } } end let(:plantings_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/plantings", - 'related' => "#{resource_url}/plantings" } } + "related" => "#{resource_url}/plantings" } } end let(:attributes) do { - 'thumbnail-url' => photo.thumbnail_url, - 'fullsize-url' => photo.fullsize_url, - 'link-url' => photo.link_url, - 'license-name' => photo.license_name, - 'title' => photo.title + "thumbnail-url" => photo.thumbnail_url, + "fullsize-url" => photo.fullsize_url, + "link-url" => photo.link_url, + "license-name" => photo.license_name, + "title" => photo.title } end @@ -62,24 +62,24 @@ RSpec.describe 'Photos', type: :request do describe '#show' do before { get "/api/v1/photos/#{photo.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('plantings' => plantings_as_json_api) } - it { expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) } - it { expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } it { expect(subject['data']).to eq(photo_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/photos', { 'photo' => { 'name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/photos/#{photo.id}", { 'photo' => { 'name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/photos/#{photo.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/api/v1/plantings_request_spec.rb b/spec/requests/api/v1/plantings_request_spec.rb index 02a7be3f4..4e96cefb4 100644 --- a/spec/requests/api/v1/plantings_request_spec.rb +++ b/spec/requests/api/v1/plantings_request_spec.rb @@ -5,65 +5,65 @@ RSpec.describe 'Plantings', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:planting) { FactoryBot.create :planting } let(:planting_encoded_as_json_api) do - { 'id' => planting.id.to_s, - 'type' => 'plantings', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'garden' => garden_as_json_api, - 'crop' => crop_as_json_api, - 'owner' => owner_as_json_api, - 'photos' => photos_as_json_api, - 'harvests' => harvests_as_json_api + { "id" => planting.id.to_s, + "type" => "plantings", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "garden" => garden_as_json_api, + "crop" => crop_as_json_api, + "owner" => owner_as_json_api, + "photos" => photos_as_json_api, + "harvests" => harvests_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/plantings/#{planting.id}" } let(:harvests_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/harvests", - 'related' => "#{resource_url}/harvests" } } + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:photos_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/photos", - 'related' => "#{resource_url}/photos" } } + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:crop_as_json_api) do - { 'links' => - { 'self' => + { "links" => + { "self" => "#{resource_url}/relationships/crop", - 'related' => "#{resource_url}/crop" } } + "related" => "#{resource_url}/crop" } } end let(:garden_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/garden", - 'related' => "#{resource_url}/garden" } } + { "links" => + { "self" => "#{resource_url}/relationships/garden", + "related" => "#{resource_url}/garden" } } end let(:attributes) do { - 'planted-at' => '2014-07-30', - 'finished-at' => nil, - 'finished' => false, - 'quantity' => 33, - 'description' => planting.description, - 'sunniness' => nil, - 'planted-from' => nil, - 'expected-lifespan' => nil, - 'finish-predicted-at' => nil, - 'percentage-grown' => nil, - 'first-harvest-date' => nil, - 'last-harvest-date' => nil + "planted-at" => "2014-07-30", + "finished-at" => nil, + "finished" => false, + "quantity" => 33, + "description" => planting.description, + "sunniness" => nil, + "planted-from" => nil, + "expected-lifespan" => nil, + "finish-predicted-at" => nil, + "percentage-grown" => nil, + "first-harvest-date" => nil, + "last-harvest-date" => nil } end @@ -74,26 +74,26 @@ RSpec.describe 'Plantings', type: :request do scenario '#show' do get "/api/v1/plantings/#{planting.id}", {}, headers - expect(subject['data']['relationships']).to include('garden' => garden_as_json_api) - expect(subject['data']['relationships']).to include('crop' => crop_as_json_api) - expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) - expect(subject['data']['relationships']).to include('harvests' => harvests_as_json_api) - expect(subject['data']['relationships']).to include('photos' => photos_as_json_api) + expect(subject['data']['relationships']).to include("garden" => garden_as_json_api) + expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) + expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) + expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) + expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) expect(subject['data']).to eq(planting_encoded_as_json_api) end scenario '#create' do post '/api/v1/plantings', { 'planting' => { 'description' => 'can i make this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#update' do post "/api/v1/plantings/#{planting.id}", { 'planting' => { 'description' => 'can i modify this' } }, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end scenario '#delete' do delete "/api/v1/plantings/#{planting.id}", {}, headers - expect(response.code).to eq '404' + expect(response.code).to eq "404" end end diff --git a/spec/requests/api/v1/seeds_request_spec.rb b/spec/requests/api/v1/seeds_request_spec.rb index 733ab7e22..f518e91de 100644 --- a/spec/requests/api/v1/seeds_request_spec.rb +++ b/spec/requests/api/v1/seeds_request_spec.rb @@ -5,41 +5,41 @@ RSpec.describe 'Photos', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:seed) { FactoryBot.create :seed } let(:seed_encoded_as_json_api) do - { 'id' => seed.id.to_s, - 'type' => 'seeds', - 'links' => { 'self' => resource_url }, - 'attributes' => attributes, - 'relationships' => { - 'owner' => owner_as_json_api, - 'crop' => crop_as_json_api + { "id" => seed.id.to_s, + "type" => "seeds", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "owner" => owner_as_json_api, + "crop" => crop_as_json_api } } end let(:resource_url) { "http://www.example.com/api/v1/seeds/#{seed.id}" } let(:owner_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/owner", - 'related' => "#{resource_url}/owner" } } + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:crop_as_json_api) do - { 'links' => - { 'self' => "#{resource_url}/relationships/crop", - 'related' => "#{resource_url}/crop" } } + { "links" => + { "self" => "#{resource_url}/relationships/crop", + "related" => "#{resource_url}/crop" } } end let(:attributes) do { - 'description' => seed.description, - 'quantity' => seed.quantity, - 'plant-before' => '2013-07-15', - 'tradable-to' => seed.tradable_to, - 'days-until-maturity-min' => seed.days_until_maturity_min, - 'days-until-maturity-max' => seed.days_until_maturity_max, - 'organic' => seed.organic, - 'gmo' => seed.gmo, - 'heirloom' => seed.heirloom + "description" => seed.description, + "quantity" => seed.quantity, + "plant-before" => "2013-07-15", + "tradable-to" => seed.tradable_to, + "days-until-maturity-min" => seed.days_until_maturity_min, + "days-until-maturity-max" => seed.days_until_maturity_max, + "organic" => seed.organic, + "gmo" => seed.gmo, + "heirloom" => seed.heirloom } end @@ -51,23 +51,23 @@ RSpec.describe 'Photos', type: :request do describe '#show' do before { get "/api/v1/seeds/#{seed.id}", {}, headers } it { expect(subject['data']['attributes']).to eq(attributes) } - it { expect(subject['data']['relationships']).to include('owner' => owner_as_json_api) } - it { expect(subject['data']['relationships']).to include('crop' => crop_as_json_api) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) } it { expect(subject['data']).to eq(seed_encoded_as_json_api) } end describe '#create' do before { post '/api/v1/seeds', { 'seed' => { 'name' => 'can i make this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#update' do before { post "/api/v1/seeds/#{seed.id}", { 'seed' => { 'name' => 'can i modify this' } }, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end describe '#delete' do before { delete "/api/v1/seeds/#{seed.id}", {}, headers } - it { expect(response.code).to eq '404' } + it { expect(response.code).to eq "404" } end end diff --git a/spec/requests/authentications_spec.rb b/spec/requests/authentications_spec.rb index 45b7754b9..6cc612f44 100644 --- a/spec/requests/authentications_spec.rb +++ b/spec/requests/authentications_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Authentications' do - describe 'GET /authentications' do +describe "Authentications" do + describe "GET /authentications" do end end diff --git a/spec/requests/comments_spec.rb b/spec/requests/comments_spec.rb index 6e5544657..c9b2ba9dc 100644 --- a/spec/requests/comments_spec.rb +++ b/spec/requests/comments_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Comments' do - describe 'GET /comments' do - it 'works! (now write some real specs)' do +describe "Comments" do + describe "GET /comments" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get comments_path response.status.should be(200) diff --git a/spec/requests/forums_spec.rb b/spec/requests/forums_spec.rb index 34a86ea66..ff7cb283d 100644 --- a/spec/requests/forums_spec.rb +++ b/spec/requests/forums_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Forums' do - describe 'GET /forums' do - it 'works! (now write some real specs)' do +describe "Forums" do + describe "GET /forums" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get forums_path response.status.should be(200) diff --git a/spec/requests/gardens_spec.rb b/spec/requests/gardens_spec.rb index 74a9931fb..91a8dc8b7 100644 --- a/spec/requests/gardens_spec.rb +++ b/spec/requests/gardens_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Gardens' do - describe 'GET /gardens' do - it 'works! (now write some real specs)' do +describe "Gardens" do + describe "GET /gardens" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get gardens_path response.status.should be(200) diff --git a/spec/requests/harvests_spec.rb b/spec/requests/harvests_spec.rb index 17785af18..f3774b3c0 100644 --- a/spec/requests/harvests_spec.rb +++ b/spec/requests/harvests_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Harvests' do - describe 'GET /harvests' do - it 'works! (now write some real specs)' do +describe "Harvests" do + describe "GET /harvests" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get harvests_path response.status.should be(200) diff --git a/spec/requests/notifications_spec.rb b/spec/requests/notifications_spec.rb index b5879f678..85afbdd9f 100644 --- a/spec/requests/notifications_spec.rb +++ b/spec/requests/notifications_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Notifications' do - describe 'GET /notifications' do - it 'works! (now write some real specs)' do +describe "Notifications" do + describe "GET /notifications" do + it "works! (now write some real specs)" do get notifications_path # can't see notifications because not logged in # therefore redirect to homepage diff --git a/spec/requests/photos_spec.rb b/spec/requests/photos_spec.rb index a3d39871c..b937ded3d 100644 --- a/spec/requests/photos_spec.rb +++ b/spec/requests/photos_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Photos' do - describe 'GET /photos' do - it 'works! (now write some real specs)' do +describe "Photos" do + describe "GET /photos" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get photos_path response.status.should be(200) diff --git a/spec/requests/plant_parts_spec.rb b/spec/requests/plant_parts_spec.rb index c44e42599..1fc2150b2 100644 --- a/spec/requests/plant_parts_spec.rb +++ b/spec/requests/plant_parts_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'PlantParts' do - describe 'GET /plant_parts' do - it 'works! (now write some real specs)' do +describe "PlantParts" do + describe "GET /plant_parts" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get plant_parts_path response.status.should be(200) diff --git a/spec/requests/plantings_spec.rb b/spec/requests/plantings_spec.rb index e156f9589..cb66922e0 100644 --- a/spec/requests/plantings_spec.rb +++ b/spec/requests/plantings_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Plantings' do - describe 'GET /plantings' do - it 'works! (now write some real specs)' do +describe "Plantings" do + describe "GET /plantings" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get plantings_path response.status.should be(200) diff --git a/spec/requests/post_spec.rb b/spec/requests/post_spec.rb index a2e316c38..3bb479aa8 100644 --- a/spec/requests/post_spec.rb +++ b/spec/requests/post_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Posts' do - describe 'GET /posts' do - it 'works! (now write some real specs)' do +describe "Posts" do + describe "GET /posts" do + it "works! (now write some real specs)" do get posts_path response.status.should be(200) end diff --git a/spec/requests/scientific_names_spec.rb b/spec/requests/scientific_names_spec.rb index 02785b4ad..922f6f270 100644 --- a/spec/requests/scientific_names_spec.rb +++ b/spec/requests/scientific_names_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'ScientificNames' do - describe 'GET /scientific_names' do - it 'works! (now write some real specs)' do +describe "ScientificNames" do + describe "GET /scientific_names" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get scientific_names_path response.status.should be(200) diff --git a/spec/requests/seeds_spec.rb b/spec/requests/seeds_spec.rb index 08d3c0f18..8bc5aeccf 100644 --- a/spec/requests/seeds_spec.rb +++ b/spec/requests/seeds_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -describe 'Seeds' do - describe 'GET /seeds' do - it 'works! (now write some real specs)' do +describe "Seeds" do + describe "GET /seeds" do + it "works! (now write some real specs)" do # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get seeds_path response.status.should be(200) diff --git a/spec/routing/account_types_routing_spec.rb b/spec/routing/account_types_routing_spec.rb index 53ed9b4a3..8402dd727 100644 --- a/spec/routing/account_types_routing_spec.rb +++ b/spec/routing/account_types_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe AccountTypesController do - describe 'routing' do - it 'routes to #index' do - get('/account_types').should route_to('account_types#index') + describe "routing" do + it "routes to #index" do + get("/account_types").should route_to("account_types#index") end - it 'routes to #new' do - get('/account_types/new').should route_to('account_types#new') + it "routes to #new" do + get("/account_types/new").should route_to("account_types#new") end - it 'routes to #show' do - get('/account_types/1').should route_to('account_types#show', id: '1') + it "routes to #show" do + get("/account_types/1").should route_to("account_types#show", id: "1") end - it 'routes to #edit' do - get('/account_types/1/edit').should route_to('account_types#edit', id: '1') + it "routes to #edit" do + get("/account_types/1/edit").should route_to("account_types#edit", id: "1") end - it 'routes to #create' do - post('/account_types').should route_to('account_types#create') + it "routes to #create" do + post("/account_types").should route_to("account_types#create") end - it 'routes to #update' do - put('/account_types/1').should route_to('account_types#update', id: '1') + it "routes to #update" do + put("/account_types/1").should route_to("account_types#update", id: "1") end - it 'routes to #destroy' do - delete('/account_types/1').should route_to('account_types#destroy', id: '1') + it "routes to #destroy" do + delete("/account_types/1").should route_to("account_types#destroy", id: "1") end end end diff --git a/spec/routing/authentications_routing_spec.rb b/spec/routing/authentications_routing_spec.rb index 39d814011..0601b9924 100644 --- a/spec/routing/authentications_routing_spec.rb +++ b/spec/routing/authentications_routing_spec.rb @@ -1,13 +1,13 @@ -require 'rails_helper' +require "rails_helper" describe AuthenticationsController do - describe 'routing' do - it 'routes to #create' do - post('/authentications').should route_to('authentications#create') + describe "routing" do + it "routes to #create" do + post("/authentications").should route_to("authentications#create") end - it 'routes to #destroy' do - delete('/authentications/1').should route_to('authentications#destroy', id: '1') + it "routes to #destroy" do + delete("/authentications/1").should route_to("authentications#destroy", id: "1") end end end diff --git a/spec/routing/comments_routing_spec.rb b/spec/routing/comments_routing_spec.rb index 8f9363dcc..5390ab066 100644 --- a/spec/routing/comments_routing_spec.rb +++ b/spec/routing/comments_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe CommentsController do - describe 'routing' do - it 'routes to #index' do - get('/comments').should route_to('comments#index') + describe "routing" do + it "routes to #index" do + get("/comments").should route_to("comments#index") end - it 'routes to #new' do - get('/comments/new').should route_to('comments#new') + it "routes to #new" do + get("/comments/new").should route_to("comments#new") end - it 'routes to #show' do - get('/comments/1').should route_to('comments#show', id: '1') + it "routes to #show" do + get("/comments/1").should route_to("comments#show", id: "1") end - it 'routes to #edit' do - get('/comments/1/edit').should route_to('comments#edit', id: '1') + it "routes to #edit" do + get("/comments/1/edit").should route_to("comments#edit", id: "1") end - it 'routes to #create' do - post('/comments').should route_to('comments#create') + it "routes to #create" do + post("/comments").should route_to("comments#create") end - it 'routes to #update' do - put('/comments/1').should route_to('comments#update', id: '1') + it "routes to #update" do + put("/comments/1").should route_to("comments#update", id: "1") end - it 'routes to #destroy' do - delete('/comments/1').should route_to('comments#destroy', id: '1') + it "routes to #destroy" do + delete("/comments/1").should route_to("comments#destroy", id: "1") end end end diff --git a/spec/routing/crops_routing_spec.rb b/spec/routing/crops_routing_spec.rb index 644bad3d6..97c1a874c 100644 --- a/spec/routing/crops_routing_spec.rb +++ b/spec/routing/crops_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe CropsController do - describe 'routing' do - it 'routes to #index' do - get('/crops').should route_to('crops#index') + describe "routing" do + it "routes to #index" do + get("/crops").should route_to("crops#index") end - it 'routes to #new' do - get('/crops/new').should route_to('crops#new') + it "routes to #new" do + get("/crops/new").should route_to("crops#new") end - it 'routes to #show' do - get('/crops/1').should route_to('crops#show', id: '1') + it "routes to #show" do + get("/crops/1").should route_to("crops#show", id: "1") end - it 'routes to #edit' do - get('/crops/1/edit').should route_to('crops#edit', id: '1') + it "routes to #edit" do + get("/crops/1/edit").should route_to("crops#edit", id: "1") end - it 'routes to #create' do - post('/crops').should route_to('crops#create') + it "routes to #create" do + post("/crops").should route_to("crops#create") end - it 'routes to #update' do - put('/crops/1').should route_to('crops#update', id: '1') + it "routes to #update" do + put("/crops/1").should route_to("crops#update", id: "1") end - it 'routes to #destroy' do - delete('/crops/1').should route_to('crops#destroy', id: '1') + it "routes to #destroy" do + delete("/crops/1").should route_to("crops#destroy", id: "1") end end end diff --git a/spec/routing/follows_routing_spec.rb b/spec/routing/follows_routing_spec.rb index 06aaa6b76..ddb01e00c 100644 --- a/spec/routing/follows_routing_spec.rb +++ b/spec/routing/follows_routing_spec.rb @@ -1,13 +1,13 @@ -require 'spec_helper' +require "spec_helper" describe FollowsController do - describe 'routing' do - it 'routes to #create' do - post('/follows').should route_to('follows#create') + describe "routing" do + it "routes to #create" do + post("/follows").should route_to("follows#create") end - it 'routes to #destroy' do - delete('/follows/1').should route_to('follows#destroy', id: '1') + it "routes to #destroy" do + delete("/follows/1").should route_to("follows#destroy", id: "1") end end end diff --git a/spec/routing/forums_routing_spec.rb b/spec/routing/forums_routing_spec.rb index ca229917f..9ce6f427b 100644 --- a/spec/routing/forums_routing_spec.rb +++ b/spec/routing/forums_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe ForumsController do - describe 'routing' do - it 'routes to #index' do - get('/forums').should route_to('forums#index') + describe "routing" do + it "routes to #index" do + get("/forums").should route_to("forums#index") end - it 'routes to #new' do - get('/forums/new').should route_to('forums#new') + it "routes to #new" do + get("/forums/new").should route_to("forums#new") end - it 'routes to #show' do - get('/forums/1').should route_to('forums#show', id: '1') + it "routes to #show" do + get("/forums/1").should route_to("forums#show", id: "1") end - it 'routes to #edit' do - get('/forums/1/edit').should route_to('forums#edit', id: '1') + it "routes to #edit" do + get("/forums/1/edit").should route_to("forums#edit", id: "1") end - it 'routes to #create' do - post('/forums').should route_to('forums#create') + it "routes to #create" do + post("/forums").should route_to("forums#create") end - it 'routes to #update' do - put('/forums/1').should route_to('forums#update', id: '1') + it "routes to #update" do + put("/forums/1").should route_to("forums#update", id: "1") end - it 'routes to #destroy' do - delete('/forums/1').should route_to('forums#destroy', id: '1') + it "routes to #destroy" do + delete("/forums/1").should route_to("forums#destroy", id: "1") end end end diff --git a/spec/routing/gardens_routing_spec.rb b/spec/routing/gardens_routing_spec.rb index 8ec871b3b..6888f099f 100644 --- a/spec/routing/gardens_routing_spec.rb +++ b/spec/routing/gardens_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe GardensController do - describe 'routing' do - it 'routes to #index' do - get('/gardens').should route_to('gardens#index') + describe "routing" do + it "routes to #index" do + get("/gardens").should route_to("gardens#index") end - it 'routes to #new' do - get('/gardens/new').should route_to('gardens#new') + it "routes to #new" do + get("/gardens/new").should route_to("gardens#new") end - it 'routes to #show' do - get('/gardens/1').should route_to('gardens#show', id: '1') + it "routes to #show" do + get("/gardens/1").should route_to("gardens#show", id: "1") end - it 'routes to #edit' do - get('/gardens/1/edit').should route_to('gardens#edit', id: '1') + it "routes to #edit" do + get("/gardens/1/edit").should route_to("gardens#edit", id: "1") end - it 'routes to #create' do - post('/gardens').should route_to('gardens#create') + it "routes to #create" do + post("/gardens").should route_to("gardens#create") end - it 'routes to #update' do - put('/gardens/1').should route_to('gardens#update', id: '1') + it "routes to #update" do + put("/gardens/1").should route_to("gardens#update", id: "1") end - it 'routes to #destroy' do - delete('/gardens/1').should route_to('gardens#destroy', id: '1') + it "routes to #destroy" do + delete("/gardens/1").should route_to("gardens#destroy", id: "1") end end end diff --git a/spec/routing/harvests_routing_spec.rb b/spec/routing/harvests_routing_spec.rb index 41ad0c187..c6890df15 100644 --- a/spec/routing/harvests_routing_spec.rb +++ b/spec/routing/harvests_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe HarvestsController do - describe 'routing' do - it 'routes to #index' do - get('/harvests').should route_to('harvests#index') + describe "routing" do + it "routes to #index" do + get("/harvests").should route_to("harvests#index") end - it 'routes to #new' do - get('/harvests/new').should route_to('harvests#new') + it "routes to #new" do + get("/harvests/new").should route_to("harvests#new") end - it 'routes to #show' do - get('/harvests/1').should route_to('harvests#show', id: '1') + it "routes to #show" do + get("/harvests/1").should route_to("harvests#show", id: "1") end - it 'routes to #edit' do - get('/harvests/1/edit').should route_to('harvests#edit', id: '1') + it "routes to #edit" do + get("/harvests/1/edit").should route_to("harvests#edit", id: "1") end - it 'routes to #create' do - post('/harvests').should route_to('harvests#create') + it "routes to #create" do + post("/harvests").should route_to("harvests#create") end - it 'routes to #update' do - put('/harvests/1').should route_to('harvests#update', id: '1') + it "routes to #update" do + put("/harvests/1").should route_to("harvests#update", id: "1") end - it 'routes to #destroy' do - delete('/harvests/1').should route_to('harvests#destroy', id: '1') + it "routes to #destroy" do + delete("/harvests/1").should route_to("harvests#destroy", id: "1") end end end diff --git a/spec/routing/notifications_routing_spec.rb b/spec/routing/notifications_routing_spec.rb index 8b0628575..bb7335e1b 100644 --- a/spec/routing/notifications_routing_spec.rb +++ b/spec/routing/notifications_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe NotificationsController do - describe 'routing' do - it 'routes to #index' do - get('/notifications').should route_to('notifications#index') + describe "routing" do + it "routes to #index" do + get("/notifications").should route_to("notifications#index") end - it 'routes to #new' do - get('/notifications/new').should route_to('notifications#new') + it "routes to #new" do + get("/notifications/new").should route_to("notifications#new") end - it 'routes to #show' do - get('/notifications/1').should route_to('notifications#show', id: '1') + it "routes to #show" do + get("/notifications/1").should route_to("notifications#show", id: "1") end - it 'routes to #edit' do - get('/notifications/1/edit').should route_to('notifications#edit', id: '1') + it "routes to #edit" do + get("/notifications/1/edit").should route_to("notifications#edit", id: "1") end - it 'routes to #create' do - post('/notifications').should route_to('notifications#create') + it "routes to #create" do + post("/notifications").should route_to("notifications#create") end - it 'routes to #update' do - put('/notifications/1').should route_to('notifications#update', id: '1') + it "routes to #update" do + put("/notifications/1").should route_to("notifications#update", id: "1") end - it 'routes to #destroy' do - delete('/notifications/1').should route_to('notifications#destroy', id: '1') + it "routes to #destroy" do + delete("/notifications/1").should route_to("notifications#destroy", id: "1") end end end diff --git a/spec/routing/order_items_routing_spec.rb b/spec/routing/order_items_routing_spec.rb index 095842d7f..7487cb9f5 100644 --- a/spec/routing/order_items_routing_spec.rb +++ b/spec/routing/order_items_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe OrderItemsController do - describe 'routing' do - it 'routes to #index' do - get('/order_items').should route_to('order_items#index') + describe "routing" do + it "routes to #index" do + get("/order_items").should route_to("order_items#index") end - it 'routes to #new' do - get('/order_items/new').should route_to('order_items#new') + it "routes to #new" do + get("/order_items/new").should route_to("order_items#new") end - it 'routes to #show' do - get('/order_items/1').should route_to('order_items#show', id: '1') + it "routes to #show" do + get("/order_items/1").should route_to("order_items#show", id: "1") end - it 'routes to #edit' do - get('/order_items/1/edit').should route_to('order_items#edit', id: '1') + it "routes to #edit" do + get("/order_items/1/edit").should route_to("order_items#edit", id: "1") end - it 'routes to #create' do - post('/order_items').should route_to('order_items#create') + it "routes to #create" do + post("/order_items").should route_to("order_items#create") end - it 'routes to #update' do - put('/order_items/1').should route_to('order_items#update', id: '1') + it "routes to #update" do + put("/order_items/1").should route_to("order_items#update", id: "1") end - it 'routes to #destroy' do - delete('/order_items/1').should route_to('order_items#destroy', id: '1') + it "routes to #destroy" do + delete("/order_items/1").should route_to("order_items#destroy", id: "1") end end end diff --git a/spec/routing/orders_routing_spec.rb b/spec/routing/orders_routing_spec.rb index 4c7d925c5..38184ef33 100644 --- a/spec/routing/orders_routing_spec.rb +++ b/spec/routing/orders_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe OrdersController do - describe 'routing' do - it 'routes to #index' do - get('/orders').should route_to('orders#index') + describe "routing" do + it "routes to #index" do + get("/orders").should route_to("orders#index") end - it 'routes to #new' do - get('/orders/new').should route_to('orders#new') + it "routes to #new" do + get("/orders/new").should route_to("orders#new") end - it 'routes to #show' do - get('/orders/1').should route_to('orders#show', id: '1') + it "routes to #show" do + get("/orders/1").should route_to("orders#show", id: "1") end - it 'routes to #edit' do - get('/orders/1/edit').should route_to('orders#edit', id: '1') + it "routes to #edit" do + get("/orders/1/edit").should route_to("orders#edit", id: "1") end - it 'routes to #create' do - post('/orders').should route_to('orders#create') + it "routes to #create" do + post("/orders").should route_to("orders#create") end - it 'routes to #update' do - put('/orders/1').should route_to('orders#update', id: '1') + it "routes to #update" do + put("/orders/1").should route_to("orders#update", id: "1") end - it 'routes to #destroy' do - delete('/orders/1').should route_to('orders#destroy', id: '1') + it "routes to #destroy" do + delete("/orders/1").should route_to("orders#destroy", id: "1") end end end diff --git a/spec/routing/photos_routing_spec.rb b/spec/routing/photos_routing_spec.rb index 1337de4b2..a645d0a60 100644 --- a/spec/routing/photos_routing_spec.rb +++ b/spec/routing/photos_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PhotosController do - describe 'routing' do - it 'routes to #index' do - get('/photos').should route_to('photos#index') + describe "routing" do + it "routes to #index" do + get("/photos").should route_to("photos#index") end - it 'routes to #new' do - get('/photos/new').should route_to('photos#new') + it "routes to #new" do + get("/photos/new").should route_to("photos#new") end - it 'routes to #show' do - get('/photos/1').should route_to('photos#show', id: '1') + it "routes to #show" do + get("/photos/1").should route_to("photos#show", id: "1") end - it 'routes to #edit' do - get('/photos/1/edit').should route_to('photos#edit', id: '1') + it "routes to #edit" do + get("/photos/1/edit").should route_to("photos#edit", id: "1") end - it 'routes to #create' do - post('/photos').should route_to('photos#create') + it "routes to #create" do + post("/photos").should route_to("photos#create") end - it 'routes to #update' do - put('/photos/1').should route_to('photos#update', id: '1') + it "routes to #update" do + put("/photos/1").should route_to("photos#update", id: "1") end - it 'routes to #destroy' do - delete('/photos/1').should route_to('photos#destroy', id: '1') + it "routes to #destroy" do + delete("/photos/1").should route_to("photos#destroy", id: "1") end end end diff --git a/spec/routing/plant_parts_routing_spec.rb b/spec/routing/plant_parts_routing_spec.rb index 2a00948bc..966047f3f 100644 --- a/spec/routing/plant_parts_routing_spec.rb +++ b/spec/routing/plant_parts_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PlantPartsController do - describe 'routing' do - it 'routes to #index' do - get('/plant_parts').should route_to('plant_parts#index') + describe "routing" do + it "routes to #index" do + get("/plant_parts").should route_to("plant_parts#index") end - it 'routes to #new' do - get('/plant_parts/new').should route_to('plant_parts#new') + it "routes to #new" do + get("/plant_parts/new").should route_to("plant_parts#new") end - it 'routes to #show' do - get('/plant_parts/1').should route_to('plant_parts#show', id: '1') + it "routes to #show" do + get("/plant_parts/1").should route_to("plant_parts#show", id: "1") end - it 'routes to #edit' do - get('/plant_parts/1/edit').should route_to('plant_parts#edit', id: '1') + it "routes to #edit" do + get("/plant_parts/1/edit").should route_to("plant_parts#edit", id: "1") end - it 'routes to #create' do - post('/plant_parts').should route_to('plant_parts#create') + it "routes to #create" do + post("/plant_parts").should route_to("plant_parts#create") end - it 'routes to #update' do - put('/plant_parts/1').should route_to('plant_parts#update', id: '1') + it "routes to #update" do + put("/plant_parts/1").should route_to("plant_parts#update", id: "1") end - it 'routes to #destroy' do - delete('/plant_parts/1').should route_to('plant_parts#destroy', id: '1') + it "routes to #destroy" do + delete("/plant_parts/1").should route_to("plant_parts#destroy", id: "1") end end end diff --git a/spec/routing/plantings_routing_spec.rb b/spec/routing/plantings_routing_spec.rb index 4098d7703..473fe827e 100644 --- a/spec/routing/plantings_routing_spec.rb +++ b/spec/routing/plantings_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PlantingsController do - describe 'routing' do - it 'routes to #index' do - get('/plantings').should route_to('plantings#index') + describe "routing" do + it "routes to #index" do + get("/plantings").should route_to("plantings#index") end - it 'routes to #new' do - get('/plantings/new').should route_to('plantings#new') + it "routes to #new" do + get("/plantings/new").should route_to("plantings#new") end - it 'routes to #show' do - get('/plantings/1').should route_to('plantings#show', id: '1') + it "routes to #show" do + get("/plantings/1").should route_to("plantings#show", id: "1") end - it 'routes to #edit' do - get('/plantings/1/edit').should route_to('plantings#edit', id: '1') + it "routes to #edit" do + get("/plantings/1/edit").should route_to("plantings#edit", id: "1") end - it 'routes to #create' do - post('/plantings').should route_to('plantings#create') + it "routes to #create" do + post("/plantings").should route_to("plantings#create") end - it 'routes to #update' do - put('/plantings/1').should route_to('plantings#update', id: '1') + it "routes to #update" do + put("/plantings/1").should route_to("plantings#update", id: "1") end - it 'routes to #destroy' do - delete('/plantings/1').should route_to('plantings#destroy', id: '1') + it "routes to #destroy" do + delete("/plantings/1").should route_to("plantings#destroy", id: "1") end end end diff --git a/spec/routing/products_routing_spec.rb b/spec/routing/products_routing_spec.rb index c19642a21..15166a805 100644 --- a/spec/routing/products_routing_spec.rb +++ b/spec/routing/products_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe ProductsController do - describe 'routing' do - it 'routes to #index' do - get('/products').should route_to('products#index') + describe "routing" do + it "routes to #index" do + get("/products").should route_to("products#index") end - it 'routes to #new' do - get('/products/new').should route_to('products#new') + it "routes to #new" do + get("/products/new").should route_to("products#new") end - it 'routes to #show' do - get('/products/1').should route_to('products#show', id: '1') + it "routes to #show" do + get("/products/1").should route_to("products#show", id: "1") end - it 'routes to #edit' do - get('/products/1/edit').should route_to('products#edit', id: '1') + it "routes to #edit" do + get("/products/1/edit").should route_to("products#edit", id: "1") end - it 'routes to #create' do - post('/products').should route_to('products#create') + it "routes to #create" do + post("/products").should route_to("products#create") end - it 'routes to #update' do - put('/products/1').should route_to('products#update', id: '1') + it "routes to #update" do + put("/products/1").should route_to("products#update", id: "1") end - it 'routes to #destroy' do - delete('/products/1').should route_to('products#destroy', id: '1') + it "routes to #destroy" do + delete("/products/1").should route_to("products#destroy", id: "1") end end end diff --git a/spec/routing/roles_routing_spec.rb b/spec/routing/roles_routing_spec.rb index 589c40dd8..7b6469efb 100644 --- a/spec/routing/roles_routing_spec.rb +++ b/spec/routing/roles_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe RolesController do - describe 'routing' do - it 'routes to #index' do - get('/roles').should route_to('roles#index') + describe "routing" do + it "routes to #index" do + get("/roles").should route_to("roles#index") end - it 'routes to #new' do - get('/roles/new').should route_to('roles#new') + it "routes to #new" do + get("/roles/new").should route_to("roles#new") end - it 'routes to #show' do - get('/roles/1').should route_to('roles#show', id: '1') + it "routes to #show" do + get("/roles/1").should route_to("roles#show", id: "1") end - it 'routes to #edit' do - get('/roles/1/edit').should route_to('roles#edit', id: '1') + it "routes to #edit" do + get("/roles/1/edit").should route_to("roles#edit", id: "1") end - it 'routes to #create' do - post('/roles').should route_to('roles#create') + it "routes to #create" do + post("/roles").should route_to("roles#create") end - it 'routes to #update' do - put('/roles/1').should route_to('roles#update', id: '1') + it "routes to #update" do + put("/roles/1").should route_to("roles#update", id: "1") end - it 'routes to #destroy' do - delete('/roles/1').should route_to('roles#destroy', id: '1') + it "routes to #destroy" do + delete("/roles/1").should route_to("roles#destroy", id: "1") end end end diff --git a/spec/routing/scientific_names_routing_spec.rb b/spec/routing/scientific_names_routing_spec.rb index 5020404ea..7bbbfa764 100644 --- a/spec/routing/scientific_names_routing_spec.rb +++ b/spec/routing/scientific_names_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe ScientificNamesController do - describe 'routing' do - it 'routes to #index' do - get('/scientific_names').should route_to('scientific_names#index') + describe "routing" do + it "routes to #index" do + get("/scientific_names").should route_to("scientific_names#index") end - it 'routes to #new' do - get('/scientific_names/new').should route_to('scientific_names#new') + it "routes to #new" do + get("/scientific_names/new").should route_to("scientific_names#new") end - it 'routes to #show' do - get('/scientific_names/1').should route_to('scientific_names#show', id: '1') + it "routes to #show" do + get("/scientific_names/1").should route_to("scientific_names#show", id: "1") end - it 'routes to #edit' do - get('/scientific_names/1/edit').should route_to('scientific_names#edit', id: '1') + it "routes to #edit" do + get("/scientific_names/1/edit").should route_to("scientific_names#edit", id: "1") end - it 'routes to #create' do - post('/scientific_names').should route_to('scientific_names#create') + it "routes to #create" do + post("/scientific_names").should route_to("scientific_names#create") end - it 'routes to #update' do - put('/scientific_names/1').should route_to('scientific_names#update', id: '1') + it "routes to #update" do + put("/scientific_names/1").should route_to("scientific_names#update", id: "1") end - it 'routes to #destroy' do - delete('/scientific_names/1').should route_to('scientific_names#destroy', id: '1') + it "routes to #destroy" do + delete("/scientific_names/1").should route_to("scientific_names#destroy", id: "1") end end end diff --git a/spec/routing/seeds_routing_spec.rb b/spec/routing/seeds_routing_spec.rb index ad8615cc4..74f4aff64 100644 --- a/spec/routing/seeds_routing_spec.rb +++ b/spec/routing/seeds_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe SeedsController do - describe 'routing' do - it 'routes to #index' do - get('/seeds').should route_to('seeds#index') + describe "routing" do + it "routes to #index" do + get("/seeds").should route_to("seeds#index") end - it 'routes to #new' do - get('/seeds/new').should route_to('seeds#new') + it "routes to #new" do + get("/seeds/new").should route_to("seeds#new") end - it 'routes to #show' do - get('/seeds/1').should route_to('seeds#show', id: '1') + it "routes to #show" do + get("/seeds/1").should route_to("seeds#show", id: "1") end - it 'routes to #edit' do - get('/seeds/1/edit').should route_to('seeds#edit', id: '1') + it "routes to #edit" do + get("/seeds/1/edit").should route_to("seeds#edit", id: "1") end - it 'routes to #create' do - post('/seeds').should route_to('seeds#create') + it "routes to #create" do + post("/seeds").should route_to("seeds#create") end - it 'routes to #update' do - put('/seeds/1').should route_to('seeds#update', id: '1') + it "routes to #update" do + put("/seeds/1").should route_to("seeds#update", id: "1") end - it 'routes to #destroy' do - delete('/seeds/1').should route_to('seeds#destroy', id: '1') + it "routes to #destroy" do + delete("/seeds/1").should route_to("seeds#destroy", id: "1") end end end diff --git a/spec/routing/updates_routing_spec.rb b/spec/routing/updates_routing_spec.rb index 1b3c8ea59..966647515 100644 --- a/spec/routing/updates_routing_spec.rb +++ b/spec/routing/updates_routing_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe PostsController do - describe 'routing' do - it 'routes to #index' do - get('/posts').should route_to('posts#index') + describe "routing" do + it "routes to #index" do + get("/posts").should route_to("posts#index") end - it 'routes to #new' do - get('/posts/new').should route_to('posts#new') + it "routes to #new" do + get("/posts/new").should route_to("posts#new") end - it 'routes to #show' do - get('/posts/1').should route_to('posts#show', id: '1') + it "routes to #show" do + get("/posts/1").should route_to("posts#show", id: "1") end - it 'routes to #edit' do - get('/posts/1/edit').should route_to('posts#edit', id: '1') + it "routes to #edit" do + get("/posts/1/edit").should route_to("posts#edit", id: "1") end - it 'routes to #create' do - post('/posts').should route_to('posts#create') + it "routes to #create" do + post("/posts").should route_to("posts#create") end - it 'routes to #update' do - put('/posts/1').should route_to('posts#update', id: '1') + it "routes to #update" do + put("/posts/1").should route_to("posts#update", id: "1") end - it 'routes to #destroy' do - delete('/posts/1').should route_to('posts#destroy', id: '1') + it "routes to #destroy" do + delete("/posts/1").should route_to("posts#destroy", id: "1") end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 300bca74d..9a0b542df 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -87,5 +87,5 @@ RSpec.configure do |config| Kernel.srand config.seed # Remember which tests failed, so you can run rspec with the `--only-failures` flag. - config.example_status_persistence_file_path = 'tmp/examples.txt' + config.example_status_persistence_file_path = "tmp/examples.txt" end diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb index b8236e95f..354c64069 100644 --- a/spec/support/controller_macros.rb +++ b/spec/support/controller_macros.rb @@ -3,7 +3,7 @@ module ControllerMacros def login_member(member_factory = :member) let(:member) { FactoryBot.create(member_factory || :member) } before(:each) do - @request.env['devise.mapping'] = Devise.mappings[:member] + @request.env["devise.mapping"] = Devise.mappings[:member] sign_in member end end diff --git a/spec/support/elasticsearch_helpers.rb b/spec/support/elasticsearch_helpers.rb index 5b73b5b0c..aaa4fd689 100644 --- a/spec/support/elasticsearch_helpers.rb +++ b/spec/support/elasticsearch_helpers.rb @@ -1,6 +1,6 @@ module ElasticsearchHelpers def sync_elasticsearch(crops) - return unless ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' + return unless ENV['GROWSTUFF_ELASTICSEARCH'] == "true" crops.each { |crop| crop.__elasticsearch__.index_document } Crop.__elasticsearch__.refresh_index! end @@ -10,6 +10,6 @@ RSpec.configure do |config| config.include ElasticsearchHelpers config.before(:all, elasticsearch: true) do - Crop.__elasticsearch__.create_index! force: true if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true' + Crop.__elasticsearch__.create_index! force: true if ENV['GROWSTUFF_ELASTICSEARCH'] == "true" end end diff --git a/spec/support/is_likeable.rb b/spec/support/is_likeable.rb index fb24eaa02..e1a590b30 100644 --- a/spec/support/is_likeable.rb +++ b/spec/support/is_likeable.rb @@ -1,4 +1,4 @@ -shared_examples 'it is likeable' do +shared_examples "it is likeable" do before(:each) do # Possibly a horrible hack. # Will fail if factory name does not match the model name.. @@ -9,7 +9,7 @@ shared_examples 'it is likeable' do @like2 = FactoryBot.create(:like, member: @member2, likeable: @likeable) end - it 'has many likes' do + it "has many likes" do expect(@likeable.likes.length).to eq 2 end diff --git a/spec/views/account_types/edit.html.haml_spec.rb b/spec/views/account_types/edit.html.haml_spec.rb index e8f934358..1bd22be03 100644 --- a/spec/views/account_types/edit.html.haml_spec.rb +++ b/spec/views/account_types/edit.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe 'account_types/edit' do +describe "account_types/edit" do before(:each) do @account_type = assign(:account_type, stub_model(AccountType, - name: 'MyString', + name: "MyString", is_paid: false, is_permanent_paid: false)) end - it 'renders the edit account_type form' do + it "renders the edit account_type form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: account_types_path(@account_type), method: 'post' do - assert_select 'input#account_type_name', name: 'account_type[name]' - assert_select 'input#account_type_is_paid', name: 'account_type[is_paid]' - assert_select 'input#account_type_is_permanent_paid', name: 'account_type[is_permanent_paid]' + assert_select "form", action: account_types_path(@account_type), method: "post" do + assert_select "input#account_type_name", name: "account_type[name]" + assert_select "input#account_type_is_paid", name: "account_type[is_paid]" + assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" end end end diff --git a/spec/views/account_types/index.html.haml_spec.rb b/spec/views/account_types/index.html.haml_spec.rb index 94f19d072..56020fc35 100644 --- a/spec/views/account_types/index.html.haml_spec.rb +++ b/spec/views/account_types/index.html.haml_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -describe 'account_types/index' do +describe "account_types/index" do before(:each) do @type = FactoryBot.create(:account_type) assign(:account_types, [@type, @type]) end - it 'renders a list of account_types' do + it "renders a list of account_types" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'tr>td', text: @type.name.to_s, count: 2 + assert_select "tr>td", text: @type.name.to_s, count: 2 end end diff --git a/spec/views/account_types/new.html.haml_spec.rb b/spec/views/account_types/new.html.haml_spec.rb index db7cec061..027a1b7c1 100644 --- a/spec/views/account_types/new.html.haml_spec.rb +++ b/spec/views/account_types/new.html.haml_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' -describe 'account_types/new' do +describe "account_types/new" do before(:each) do assign(:account_type, stub_model(AccountType, - name: 'MyString', + name: "MyString", is_paid: false, is_permanent_paid: false).as_new_record) end - it 'renders new account_type form' do + it "renders new account_type form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'form', action: account_types_path, method: 'post' do - assert_select 'input#account_type_name', name: 'account_type[name]' - assert_select 'input#account_type_is_paid', name: 'account_type[is_paid]' - assert_select 'input#account_type_is_permanent_paid', name: 'account_type[is_permanent_paid]' + assert_select "form", action: account_types_path, method: "post" do + assert_select "input#account_type_name", name: "account_type[name]" + assert_select "input#account_type_is_paid", name: "account_type[is_paid]" + assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]" end end end diff --git a/spec/views/account_types/show.html.haml_spec.rb b/spec/views/account_types/show.html.haml_spec.rb index 6bb888f1a..a31d4bc33 100644 --- a/spec/views/account_types/show.html.haml_spec.rb +++ b/spec/views/account_types/show.html.haml_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -describe 'account_types/show' do +describe "account_types/show" do before(:each) do @account_type = assign(:account_type, stub_model(AccountType, - name: 'Name', + name: "Name", is_paid: false, is_permanent_paid: false)) 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/accounts/edit.html.haml_spec.rb b/spec/views/accounts/edit.html.haml_spec.rb index d77edd8c8..bc5c3b5a3 100644 --- a/spec/views/accounts/edit.html.haml_spec.rb +++ b/spec/views/accounts/edit.html.haml_spec.rb @@ -1,18 +1,18 @@ require 'rails_helper' -describe 'accounts/edit' do +describe "accounts/edit" do before(:each) do @member = FactoryBot.create(:member) @account = assign(:account, @member.account) end - it 'renders the edit account form' do + 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]' + assert_select "form", action: accounts_path(@account), method: "post" do + assert_select "input#account_member_id", name: "account[member_id]" + assert_select "input#account_account_type", name: "account[account_type]" end end end diff --git a/spec/views/accounts/index.html.haml_spec.rb b/spec/views/accounts/index.html.haml_spec.rb index 7e54347fb..4ec76151e 100644 --- a/spec/views/accounts/index.html.haml_spec.rb +++ b/spec/views/accounts/index.html.haml_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -describe 'accounts/index' do +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 + it "renders a list of accounts" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'tr>td', text: @account.member_id.to_s, count: 2 + assert_select "tr>td", text: @account.member_id.to_s, count: 2 end end diff --git a/spec/views/accounts/new.html.haml_spec.rb b/spec/views/accounts/new.html.haml_spec.rb index 5bc6ba812..77f6ff20f 100644 --- a/spec/views/accounts/new.html.haml_spec.rb +++ b/spec/views/accounts/new.html.haml_spec.rb @@ -1,18 +1,18 @@ require 'rails_helper' -describe 'accounts/new' do +describe "accounts/new" do before(:each) do @member = FactoryBot.create(:member) assign(:account, @member.account) end - it 'renders new account form' do + 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]' + 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 index b852b12d1..d96fbbd96 100644 --- a/spec/views/accounts/show.html.haml_spec.rb +++ b/spec/views/accounts/show.html.haml_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -describe 'accounts/show' do +describe "accounts/show" do before(:each) do @member = FactoryBot.create(:member) @account = assign(:account, @member.account) 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 have_content @account.member_id.to_s diff --git a/spec/views/admin/index_spec.rb b/spec/views/admin/index_spec.rb index 442a0c36c..beb0eacbd 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,14 @@ 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: account_types_path + assert_select "a", href: products_path + assert_select "a", href: roles_path + assert_select "a", href: forums_path end - it 'has a link to newsletter subscribers' do - 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 index 905b6a3ff..8d80dc3ef 100644 --- a/spec/views/admin/orders/index_spec.rb +++ b/spec/views/admin/orders/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'admin/orders/index.html.haml', type: 'view' do +describe 'admin/orders/index.html.haml', type: "view" do before(:each) do @member = FactoryBot.create(:admin_member) sign_in @member @@ -8,13 +8,13 @@ describe 'admin/orders/index.html.haml', type: 'view' do render end - it 'includes a search form for orders' do - assert_select 'form' - assert_select 'input#search_text' - assert_select 'select#search_by' + 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' + 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 index 9660b44fb..c95f204e2 100644 --- a/spec/views/orders/index.html.haml_spec.rb +++ b/spec/views/orders/index.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'orders/index' do +describe "orders/index" do before(:each) do @member = FactoryBot.create(:member) sign_in @member @@ -9,15 +9,15 @@ describe 'orders/index' do assign(:orders, [@order1, @order2]) end - it 'shows your current account status' do + it "shows your current account status" do render - rendered.should have_content 'Your current account status' + rendered.should have_content "Your current account status" end - it 'renders a list of orders' do + it "renders a list of orders" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'tr>td a/@href', text: "/orders/#{@order1.id}" - assert_select 'tr>td a/@href', text: "/orders/#{@order2.id}" + 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 index 233616b9e..a9f662de9 100644 --- a/spec/views/orders/show.html.haml_spec.rb +++ b/spec/views/orders/show.html.haml_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' -describe 'orders/show' do +describe "orders/show" do before(:each) do @member = FactoryBot.create(:member) sign_in @member controller.stub(:current_user) { @member } end - context 'current order' do + context "current order" do before(:each) do @order = assign(:order, FactoryBot.create(:order, member: @member)) @order_item = FactoryBot.create(:order_item, @@ -17,38 +17,38 @@ describe 'orders/show' do render end - it 'displays order number' do - rendered.should have_content 'Order number' + 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' + 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/ + 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 + 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 + it "asks for a referral code" do assert_select "input[id='referral_code']" end - it 'shows a checkout button' do + 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' + it "shows a delete order button" do + assert_select "a", text: "Delete this order" end end - context 'completed order' do + context "completed order" do before(:each) do @order = assign(:order, FactoryBot.create(:completed_order, member: @member)) @order_item = FactoryBot.create(:order_item, @@ -59,11 +59,11 @@ describe 'orders/show' do end it "doesn't show a checkout button" do - assert_select 'a', text: 'Checkout', count: 0 + assert_select "a", text: "Checkout", count: 0 end it "doesn't show delete order button" do - assert_select 'a', text: 'Delete this order', count: 0 + assert_select "a", text: "Delete this order", count: 0 end end 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 index 568445d72..3d60c9e95 100644 --- a/spec/views/products/edit.html.haml_spec.rb +++ b/spec/views/products/edit.html.haml_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' -describe 'products/edit' do +describe "products/edit" do before(:each) do @product = assign(:product, stub_model(Product, - name: 'MyString', - description: 'MyString', - min_price: '9.99')) + name: "MyString", + description: "MyString", + min_price: "9.99")) end - it 'renders the edit product form' do + 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]' + assert_select "form", action: products_path(@product), method: "post" do + assert_select "input#product_name", name: "product[name]" + assert_select "textarea#product_description", name: "product[description]" + assert_select "input#product_min_price", name: "product[min_price]" + assert_select "input#product_recommended_price", name: "product[recommended_price]" end end end diff --git a/spec/views/products/index.html.haml_spec.rb b/spec/views/products/index.html.haml_spec.rb index c92e2dc02..90e08e2a3 100644 --- a/spec/views/products/index.html.haml_spec.rb +++ b/spec/views/products/index.html.haml_spec.rb @@ -1,16 +1,16 @@ require 'rails_helper' -describe 'products/index' do +describe "products/index" do before(:each) do @product = FactoryBot.create(:product) assign(:products, [@product, @product]) end - it 'renders a list of products' do + it "renders a list of products" do render # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select 'tr>td', text: @product.name, count: 2 - assert_select 'tr>td', text: @product.description, count: 2 - assert_select 'tr>td', text: @product.min_price.to_s, count: 2 + assert_select "tr>td", text: @product.name, count: 2 + assert_select "tr>td", text: @product.description, count: 2 + assert_select "tr>td", text: @product.min_price.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 index f4b596eaf..336c6bac1 100644 --- a/spec/views/products/new.html.haml_spec.rb +++ b/spec/views/products/new.html.haml_spec.rb @@ -1,24 +1,24 @@ require 'rails_helper' -describe 'products/new' do +describe "products/new" do before(:each) do assign(:product, stub_model(Product, - name: 'MyString', - description: 'MyString', - min_price: '9.99').as_new_record) + name: "MyString", + description: "MyString", + min_price: "9.99").as_new_record) end - it 'renders new product form' do + 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]' + 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 index 243eae01b..315d9caae 100644 --- a/spec/views/products/show.html.haml_spec.rb +++ b/spec/views/products/show.html.haml_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -describe 'products/show' do +describe "products/show" do before(:each) do @product = assign(:product, FactoryBot.create(:product)) 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 have_content @product.name 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 index a23320f44..754f05c09 100644 --- a/spec/views/shop/index_spec.rb +++ b/spec/views/shop/index_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'shop/index.html.haml', type: 'view' do +describe 'shop/index.html.haml', type: "view" do before(:each) do @product1 = FactoryBot.create(:product) @product2 = FactoryBot.create(:product_with_recommended_price) @@ -8,7 +8,7 @@ describe 'shop/index.html.haml', type: 'view' do assign(:order_item, OrderItem.new) end - context 'signed in' do + context "signed in" do before(:each) do @member = FactoryBot.create(:member) controller.stub(:current_user) { @member } @@ -16,7 +16,7 @@ describe 'shop/index.html.haml', type: 'view' do end it 'shows products' do - assert_select('h2', text: @product1.name) + assert_select("h2", text: @product1.name) end it 'shows prices in configured currency' do @@ -38,15 +38,15 @@ describe 'shop/index.html.haml', type: 'view' do end it 'displays the order form' do - assert_select 'form', count: 2 + assert_select "form", count: 2 end it 'renders markdown in product descriptions' do - assert_select 'em', text: 'hurrah', count: 2 + assert_select "em", text: 'hurrah', count: 2 end end - context 'is paid' do + context "is paid" do before(:each) do @member = FactoryBot.create(:member) @member.account.account_type = FactoryBot.create(:paid_account_type) @@ -54,29 +54,29 @@ describe 'shop/index.html.haml', type: 'view' do controller.stub(:current_member) { @member } end - it 'recognises the paid member' do + it "recognises the paid member" do @member.paid?.should be(true) end - it 'tells you you have a paid membership' do + it "tells you you have a paid membership" do render - rendered.should have_content 'You currently have a paid' + rendered.should have_content "You currently have a paid" end it "doesn't show shop" do render - assert_select 'form', false + assert_select "form", false end end - context 'signed out' do + 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' + it "tells you to sign up/sign in" do + rendered.should have_content "sign in or sign up" end end end