This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assert_template(:partial => 'shared/_item_variant_table_title') | |
#ArgumentError: assertion message must be String or Proc: | |
#<expecting partial <"shared/_item_variant_table_title"> but action rendered | |
# <["shared/_item_variant_table_title", | |
# "_item_variant_table_title", | |
# "shared/_flash_div", | |
# "_flash_div"]>>(<Test::Unit::Assertions::AssertionMessage>) | |
assert_template(:partial => 'shared/_item_variant_table_title', :count => 1) | |
#ArgumentError: assertion message must be String or Proc: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReturnedItem < AR:Base | |
belongs_to :sold_item | |
delegate :unit_price, :to => :sold_item | |
has_one :item_variant, :through => :sold_item | |
delegate :full_name, :sku, :packaging, :uom_string, :to => :item_variant | |
end | |
#item_variant is another AR model | |
## | |
#My problem is | |
ReturnedItem.new(:sold_item => an_saved_sold_item).full_name => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Shipment < ActiveRecord::Base | |
has_many :shipping_items | |
end | |
class ShippingItem < ActiveRecord::Base | |
belongs_to :shipment | |
has_many :container_allocations | |
end | |
class ContainerAllocation < ActiveRecord::Base | |
belongs_to shipping_item | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
has_many :own_use_contents, :dependent => :destroy, :inverse_of => :own_use_package do | |
def total_quantity | |
loaded? ? to_a.sum(&:quantity) : sum(:quantity) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#routes | |
scope :path => 'shipping_reports', :controller => 'ShippingReports', :as => 'shipping_reports' do | |
get 'index' | |
end | |
#test | |
class ShippingReportsControllerTest < ActionController::TestCase | |
test "routing" do | |
assert_routing '/shipping_reports/index', { :controller => "ShippingReports", :action => "index" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@search= ShippingItem.joins(:shipment => {:shipment_booking => {:dest_place => :address}}). | |
departed. | |
merge(Shipment.with_check_price_done). | |
merge(Shipment.eta_in_prev_months 12). | |
where(:unit_check_price.gt => 0). | |
select('MAX(shipment_bookings.eta) AS latest_eta, shipping_items.item_variant_id AS latest_iv_id, addresses.country AS latest_country'). | |
group('shipping_items.item_variant_id, addresses.country'). | |
search(params[:search]) | |
@subquery = @search.relation.to_sql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test 'create a standard po with items' do | |
po_count = PurchaseOrder.count | |
visit new_purchase_order_path | |
page.select po.supplier.name, from: 'purchase_order_supplier_id' | |
page.select po.company_profile.name, from: 'purchase_order_company_profile_id' | |
page.select po.delivery_site.name, from: 'purchase_order_delivery_site_id' | |
page.click_button 'purchase_order_submit' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Activate the gem you are reporting the issue against. | |
gem 'rails', '3.0.20' | |
gem 'paper_trail', '3.0.0' | |
require 'rails/all' | |
require 'action_controller/railtie' | |
# ENV["RAILS_ENV"] = "test" | |
require 'rails/test_help' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def adjusted real_value, type, &block | |
puts @data | |
key = [real_value, type] | |
if @data.include? key | |
@data[key][1]= Date.current # <- calls Date.current internally to keep track of oldest record, | |
# How can i alter the return of Date.current for it to return eg yesterday | |
else | |
trim_data | |
@data[key] = [yield, Date.current] | |
@data[key].first |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ris = RequestedItem.currently_requested.joins(:order_request). | |
group(:item_variant_id).select('requested_items.*, order_request.business_site_id').all | |
ris.first[:business_site_id].class == String #instead of Fixnum... | |
#with SQLite with can: | |
if ris.first[:business_site_id] == DEFAULT_SITE | |
.. | |
#but with PG, we must: | |
if ris.first[:business_site_id].try(:to_i) == DEFAULT_SITE | |
.. |