2014-12-04 19:50:02 +01:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: orders
|
|
|
|
#
|
2015-03-19 16:22:55 +01:00
|
|
|
# id :integer not null, primary key
|
|
|
|
# user_id :integer
|
|
|
|
# price_cents :integer
|
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
|
|
|
# cancelled :boolean default("f")
|
2014-12-04 19:50:02 +01:00
|
|
|
#
|
|
|
|
|
2014-11-09 22:53:39 +01:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class OrderTest < ActiveSupport::TestCase
|
2015-03-03 17:41:53 +01:00
|
|
|
def setup
|
|
|
|
@order = Order.new
|
|
|
|
@order.order_items.build(product: products(:fanta), count: 1)
|
|
|
|
@order.order_items.build(product: products(:bueno), count: 2)
|
|
|
|
end
|
|
|
|
|
2015-03-03 15:56:23 +01:00
|
|
|
test "order total price is correct" do
|
2015-03-19 16:22:55 +01:00
|
|
|
assert_equal @order.price, 3.00
|
2015-03-03 17:41:53 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
test "to_sentence is correct" do
|
|
|
|
assert_equal @order.to_sentence, "1 Fanta and 2 Kinder Buenos"
|
2015-03-03 15:56:23 +01:00
|
|
|
end
|
2014-11-09 22:53:39 +01:00
|
|
|
end
|