From 65d2d4830bccb4cb5f552ef0840511972885d0c1 Mon Sep 17 00:00:00 2001 From: Winson Wan Date: Fri, 12 Apr 2024 09:44:12 -0700 Subject: [PATCH] resolve whitespace changes --- app/controllers/store_controller.rb | 2 -- app/models/account_code.rb | 6 +++--- app/models/customer.rb | 6 +++--- app/models/order.rb | 26 +++++++++++------------ features/step_definitions/option_steps.rb | 2 -- spec/models/order_adding_items_spec.rb | 2 +- 6 files changed, 20 insertions(+), 24 deletions(-) diff --git a/app/controllers/store_controller.rb b/app/controllers/store_controller.rb index fc7faf259..5379ba9df 100644 --- a/app/controllers/store_controller.rb +++ b/app/controllers/store_controller.rb @@ -1,14 +1,12 @@ class StoreController < ApplicationController include StoreHelper - skip_before_filter :verify_authenticity_token, :only => %w(show_changed showdate_changed) before_filter :set_customer, :except => %w[process_donation] before_filter :is_logged_in, :only => %w[checkout place_order] before_filter :order_is_not_empty, :only => %w[shipping_address checkout place_order] - # ACTION INVARIANT BEFORE ACTION # ------ ----------------------- # index, subscribe, donate_to_fund valid @customer diff --git a/app/models/account_code.rb b/app/models/account_code.rb index db09ac553..f8b2750cf 100644 --- a/app/models/account_code.rb +++ b/app/models/account_code.rb @@ -29,7 +29,7 @@ def name_or_code_given def self.default_account_code_id self.default_account_code.id end - + def self.default_account_code AccountCode.first end @@ -43,12 +43,12 @@ def <=>(other) end class CannotDelete < RuntimeError ; end - + # convenience accessors def name_or_code ; name.blank? ? code : name ; end def name_with_code ; sprintf("%-6.6s %s", code, name) ; end - + # cannot delete the last account code or the one associated as any # of the defaults diff --git a/app/models/customer.rb b/app/models/customer.rb index 6724c2ea9..1f7555b83 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -25,7 +25,7 @@ class Customer < ActiveRecord::Base def active_vouchers vouchers.select { |v| Time.current <= Time.at_end_of_season(v.season) } end - + has_many :vouchertypes, :through => :vouchers has_many :showdates, :through => :vouchers has_many :orders, -> { where( 'orders.sold_on IS NOT NULL').order(:sold_on => :desc) } @@ -62,7 +62,7 @@ def restricted_email !email.blank? && !email.match( /#{domain}\z/i ) end validate :restricted_email, :if => :self_created?, :on => :create - + EMAIL_UNIQUENESS_ERROR_MESSAGE = 'has already been registered.' validates_uniqueness_of :email, :allow_blank => true, @@ -428,7 +428,7 @@ def self.csv_header ['First name', 'Last name', 'ID', 'Email', 'Street', 'City', 'State', 'Zip', 'Day/main phone', 'Eve/alt phone', "Don't mail", "Don't email"].freeze end - + def self.to_csv(custs,opts={}) CSV::Writer.generate(output='') do |csv| unless opts[:suppress_header] diff --git a/app/models/order.rb b/app/models/order.rb index 4357cc2af..506d84987 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -16,7 +16,7 @@ class Order < ActiveRecord::Base # pending and errored states of a CC order (pending = payment has occurred but order has not # yet been finalized; errored = payment has occurred and order NEVER got finalized, eg due # to server timeout or other event that happens during that step) - + PENDING = 'pending' # string in authorization field that marks in-process CC order ERRORED = 'errored' # payment made, but timeout/something bad happened that prevented order finalization @@ -78,7 +78,7 @@ def check_purchaser_info scope :completed, ->() { where('sold_on IS NOT NULL') } scope :abandoned_since, ->(since) { where('sold_on IS NULL').where('updated_at < ?', since) } scope :pending_but_paid, ->() { where(:authorization => PENDING) } - + scope :for_customer_reporting, ->() { includes(:vouchers => [:customer, :showdate,:vouchertype]). includes(:donations => [:customer, :account_code]). @@ -100,7 +100,7 @@ def customer_name ; customer.full_name ; end def purchaser_name ; purchaser.full_name ; end def purchase_medium ; Purchasemethod.get(purchasemethod).purchase_medium ; end - + def self.new_from_donation(amount, account_code, donor) order = Order.new(:purchaser => donor, :customer => donor) order.add_donation(Donation.from_amount_and_account_code_id(amount, account_code.id)) @@ -187,10 +187,10 @@ def add_tickets_without_capacity_checks(valid_voucher, number, seats=[]) self.vouchers += new_vouchers self.save! else # since order can't proceed, DESTROY all vouchers so not orphaned - new_vouchers.each { |v| v.destroy if v.persisted? } + new_vouchers.each { |v| v.destroy if v.persisted? } end end - + def ticket_count ; vouchers.size ; end def item_count ; ticket_count + (includes_donation? ? 1 : 0) + retail_items.size; end @@ -223,7 +223,7 @@ def reserved_seating_params nil end end - + def add_donation(d) ; self.donation = d ; end def donation=(d) self.donation_data[:amount] = d.amount @@ -250,7 +250,7 @@ def includes_bundle? vouchers.any? { |v| v.bundle? } end end - + def add_retail_item(r) raise Order::NotPersistedError unless persisted? self.retail_items << r if r @@ -318,7 +318,7 @@ def streaming_access_instructions # this is almost certainly a Demeter violation...but not sure how to make better vouchers.first.showdate.access_instructions end - + def collect_notes # collect the showdate-specific (= show-specific) notes in the order items.map(&:showdate).compact.uniq.map(&:patron_notes).compact @@ -363,7 +363,7 @@ def finalize_with_existing_customer_id!(cid,processed_by,sold_on=Time.current) self.processed_by = processed_by self.finalize!(sold_on) end - + def finalize_with_new_customer!(customer,processed_by,sold_on=Time.current) customer.force_valid = true self.customer = self.purchaser = customer @@ -421,7 +421,7 @@ def finalize!(sold_on_date = Time.current) raise e end end - + def refundable? completed? && items.any? { |i| !i.kind_of?(CanceledItem) } # in case all items were ALREADY refunded and now marked as canceled @@ -459,13 +459,13 @@ def item_descriptions end def summary_of_contents - if includes_vouchers? && includes_donation? - 'order and donation' + if includes_vouchers? && includes_donation? + 'order and donation' elsif includes_donation? 'donation' else 'order' end - end + end end diff --git a/features/step_definitions/option_steps.rb b/features/step_definitions/option_steps.rb index c559ac788..2839a7a20 100644 --- a/features/step_definitions/option_steps.rb +++ b/features/step_definitions/option_steps.rb @@ -3,7 +3,6 @@ Option.first.update_attributes!(:season_start_month => d.month, :season_start_day => d.day) end - When /^I fill in all valid options$/ do opts = { 'venue' => "Test Theater", @@ -20,7 +19,6 @@ end end - Given /^the (boolean )?setting "(.*)" is "(.*)"$/ do |bool,opt,val| val = !!(val =~ /true/i) if bool Option.first.update_attributes!(opt.downcase.gsub(/\s+/, '_') => val) diff --git a/spec/models/order_adding_items_spec.rb b/spec/models/order_adding_items_spec.rb index e5a4f9090..6404fea80 100644 --- a/spec/models/order_adding_items_spec.rb +++ b/spec/models/order_adding_items_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe Order, 'adding' do - before :each do + before :each do @order = Order.create!(:processed_by => create(:customer)) # generic customer @vv = create(:valid_voucher) end