Skip to content

Commit

Permalink
And another test
Browse files Browse the repository at this point in the history
  • Loading branch information
TomNaessens committed Dec 1, 2015
1 parent 91d0ef9 commit aad98e7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
10 changes: 7 additions & 3 deletions test/controllers/orders_controller_test.rb
Expand Up @@ -7,6 +7,8 @@ class OrdersControllerTest < ActionController::TestCase
def setup
stub_request(:get, 'http://fkgent.be/api_isengard_v2.php').with(query: hash_including(u: /.*/)).to_return(body: 'FAIL')
stub_request(:get, 'http://registratie.fkgent.be/api/v2/members/clubs_for_ugent_nr.json').with(query: hash_including(key: /.*/)).to_return(body: '{}')

sign_in create(:user, admin: true)
end

test 'uploading partially failed orders' do
Expand Down Expand Up @@ -36,9 +38,11 @@ def setup
assert_equal 0.01, three.reload.paid
end

test 'resend actuallly sends an email' do
assert_difference 'ActionMailer::Base.deliveries.size', orders(:one).tickets.count do
xhr :get, :resend, event_id: events(:codenight), id: orders(:one).id
test 'resend actually sends an email' do
order = create(:free_order)

assert_difference 'ActionMailer::Base.deliveries.size', order.tickets.count do
xhr :get, :resend, event_id: order.event, id: order
end
end

Expand Down
22 changes: 20 additions & 2 deletions test/factories/orders.rb
Expand Up @@ -25,8 +25,26 @@
name { Faker::Name.name }
email { Faker::Internet.email }

paid 0
price { Faker::Number.number(2) }
factory :free_order do
paid 0
price 0
end

factory :paid_order do
price 10

factory :unpaid_order do
paid 0
end

factory :partially_paid_order do
paid 5
end

factory :fully_paid_order do
paid 10
end
end

# Related tickets
transient do
Expand Down

0 comments on commit aad98e7

Please sign in to comment.