Add tests for ordering and quickpay
This commit is contained in:
parent
35fc8ecc77
commit
a5dbe99d27
2 changed files with 34 additions and 11 deletions
14
test/fixtures/users.yml
vendored
14
test/fixtures/users.yml
vendored
|
@ -29,12 +29,18 @@
|
|||
# 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'
|
||||
nickname: admin
|
||||
admin: 1
|
||||
|
||||
koelkast:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue