2014-12-04 19:50:02 +01:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: products
|
|
|
|
#
|
2014-12-04 20:32:31 +01:00
|
|
|
# id :integer not null, primary key
|
2015-03-19 16:22:55 +01:00
|
|
|
# name :string not null
|
|
|
|
# price_cents :integer default("0"), not null
|
2015-02-09 17:06:24 +01:00
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
2015-03-19 16:22:55 +01:00
|
|
|
# avatar_file_name :string
|
|
|
|
# avatar_content_type :string
|
|
|
|
# avatar_file_size :integer
|
|
|
|
# avatar_updated_at :datetime
|
|
|
|
# category :integer default("0")
|
|
|
|
# stock :integer default("0"), not null
|
2014-12-04 19:50:02 +01:00
|
|
|
#
|
|
|
|
|
2014-11-24 21:45:32 +01:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class ProductTest < ActiveSupport::TestCase
|
2015-03-03 17:41:53 +01:00
|
|
|
test "price behaves correctly" do
|
|
|
|
p = products(:fanta)
|
|
|
|
|
|
|
|
assert_equal p.price_cents, 60
|
|
|
|
assert_equal p.price, 0.6
|
|
|
|
|
|
|
|
p.price = 1.3
|
|
|
|
|
|
|
|
assert_equal p.price, 1.3
|
|
|
|
assert_equal p.price_cents, 130
|
|
|
|
end
|
2014-11-24 21:45:32 +01:00
|
|
|
end
|