2015-03-09 13:17:41 +01:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class OrderIntegrationTest < ActionDispatch::IntegrationTest
|
2015-03-10 08:52:16 +01:00
|
|
|
def setup
|
|
|
|
Product.all.each do |product|
|
2015-03-09 13:17:41 +01:00
|
|
|
product.avatar = File.new('public/seeds/products/fanta.jpg', 'r')
|
|
|
|
product.save
|
|
|
|
end
|
|
|
|
|
|
|
|
sign_in users(:koelkast)
|
2015-03-10 08:52:16 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'orders are saved for the right user' do
|
2015-03-09 13:17:41 +01:00
|
|
|
visit new_user_order_path(users(:benji))
|
|
|
|
|
|
|
|
assert page.has_content? 'Order for benji'
|
|
|
|
|
2015-03-19 16:22:55 +01:00
|
|
|
assert_difference "User.find(users(:benji).id).debt_cents", 240 do
|
2015-03-09 13:17:41 +01:00
|
|
|
fill_in 'order_order_items_attributes_2_count', with: 2
|
|
|
|
click_button "Order!"
|
|
|
|
end
|
|
|
|
end
|
2015-03-10 08:52:16 +01:00
|
|
|
|
|
|
|
test 'quickpay' do
|
2015-03-19 16:22:55 +01:00
|
|
|
assert_difference "User.find(users(:benji).id).debt_cents", User.find(users(:benji).id).dagschotel.price_cents do
|
2015-03-10 08:52:16 +01:00
|
|
|
visit user_quickpay_path(users(:benji))
|
|
|
|
assert page.has_content? 'Success!'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'cancelling quickpay' do
|
|
|
|
visit user_quickpay_path(users(:benji))
|
|
|
|
|
2015-03-19 16:22:55 +01:00
|
|
|
assert_difference "User.find(users(:benji).id).debt_cents", -User.find(users(:benji).id).dagschotel.price_cents do
|
2015-03-10 08:52:16 +01:00
|
|
|
click_link 'Undo'
|
|
|
|
assert page.has_content? 'Success!'
|
|
|
|
end
|
|
|
|
end
|
2015-03-09 13:17:41 +01:00
|
|
|
end
|