Add tests for ordering and quickpay

This commit is contained in:
benji 2015-03-10 08:52:16 +01:00
parent 35fc8ecc77
commit a5dbe99d27
2 changed files with 34 additions and 11 deletions

View file

@ -29,14 +29,20 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
benji:
nickname: 'benji'
name: 'Benjamin'
last_name: 'Cousaert'
nickname: benji
name: Benjamin
last_name: Cousaert
dagschotel_id: 1
iasoon:
nickname: iasoon
name: Ilion
last_name: Beyst
admin:
nickname: 'admin'
admin: 1
nickname: admin
admin: 1
koelkast:
nickname: koelkast
koelkast: 1
nickname: koelkast
koelkast: 1

View file

@ -1,15 +1,16 @@
require 'test_helper'
class OrderIntegrationTest < ActionDispatch::IntegrationTest
test 'orders are saved for the right user' do
allproducts = [products(:fanta), products(:cola), products(:mate), products(:bueno)]
allproducts.each do |product|
def setup
Product.all.each do |product|
product.avatar = File.new('public/seeds/products/fanta.jpg', 'r')
product.save
end
sign_in users(:koelkast)
end
test 'orders are saved for the right user' do
visit new_user_order_path(users(:benji))
assert page.has_content? 'Order for benji'
@ -19,4 +20,20 @@ class OrderIntegrationTest < ActionDispatch::IntegrationTest
click_button "Order!"
end
end
test 'quickpay' do
assert_difference "User.find(users(:benji).id).balance_cents", -User.find(users(:benji).id).dagschotel.price_cents do
visit user_quickpay_path(users(:benji))
assert page.has_content? 'Success!'
end
end
test 'cancelling quickpay' do
visit user_quickpay_path(users(:benji))
assert_difference "User.find(users(:benji).id).balance_cents", User.find(users(:benji).id).dagschotel.price_cents do
click_link 'Undo'
assert page.has_content? 'Success!'
end
end
end