Sha256: 5663c8c9e8dec379d45ede117a332479a7a415cb5392b6d2a17108d27183c34d

Contents?: true

Size: 1.66 KB

Versions: 6

Compression:

Stored size: 1.66 KB

Contents

ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
require "authlogic/test_case" 

class ActiveSupport::TestCase
  self.use_transactional_fixtures = true
  self.use_instantiated_fixtures  = false
end

I18n.locale = "en-US"
Spree::Config.set(:default_country_id => Country.first.id) if Country.first

ActionController::TestCase.class_eval do
  # special overload methods for "global"/nested params
  [ :get, :post, :put, :delete ].each do |overloaded_method|
    define_method overloaded_method do |*args|
      action,params,extras = *args
      super action, params || {}, *extras unless @params
      super action, @params.merge( params || {} ), *extras if @params
    end
  end
end  

def setup
  super
  @params = {}
end

class TestCouponCalc
  def self.calculate_discount(checkout)    
    0.99
  end
end

class Zone
  def self.global
    find_by_name("GlobalZone") || Factory(:global_zone)
  end
end
def create_complete_order
  @zone = Zone.global
  @order = Factory(:order)
  3.times do
    #variant = Factory(:product).variants.first
    variant = Factory(:variant)
    Factory(:line_item, :variant => variant, :order => @order)
  end

  @shipping_method = Factory(:shipping_method)
  @checkout = @order.checkout
  @shipment = @order.shipment
  @order.shipment.shipping_method = @shipping_method
  @order.shipment.address = Factory(:address)
  @checkout.bill_address = Factory(:address)
  unless @zone.include?(@order.shipment.address)
    ZoneMember.create(:zone => Zone.global, :zoneable => @order.shipment.address.country)
    @zone.reload
  end

  @checkout.save
  @shipment.save
  @order.save
  @order.reload
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
spree-enriquez-0.9.4 test/test_helper.rb
spree-0.9.4 test/test_helper.rb
spree-0.9.3 test/test_helper.rb
spree-0.9.2 test/test_helper.rb
spree-0.9.1 test/test_helper.rb
spree-0.9.0 test/test_helper.rb