Skip to content

Commit

Permalink
resolve whitespace changes
Browse files Browse the repository at this point in the history
  • Loading branch information
winsonwan committed Apr 12, 2024
1 parent af17987 commit 65d2d48
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 24 deletions.
2 changes: 0 additions & 2 deletions app/controllers/store_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/models/account_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions app/models/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down
26 changes: 13 additions & 13 deletions app/models/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]).
Expand All @@ -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))
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 0 additions & 2 deletions features/step_definitions/option_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion spec/models/order_adding_items_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 65d2d48

Please sign in to comment.