1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

updates tests to use test helpers

This commit is contained in:
Nicolas Florentin 2016-04-06 15:22:32 +02:00
parent 23884bc2c5
commit 2cd1127a09
3 changed files with 10 additions and 25 deletions

View File

@ -28,10 +28,7 @@ class AbusesTest < ActionDispatch::IntegrationTest
message: 'This project is in infringement with the patent US5014921 A.'
}
}.to_json,
{
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s
}
default_headers
# Check response format & status
assert_equal 201, response.status, response.body
@ -66,13 +63,10 @@ class AbusesTest < ActionDispatch::IntegrationTest
message: ''
}
}.to_json,
{
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s
}
default_headers
assert_equal 422, response.status, response.body
assert_match /can't be blank/, response.body
assert_match /can't be blank|doit être rempli/, response.body
end
end
end

View File

@ -13,27 +13,18 @@ module Reservations
invoice_items_count = InvoiceItem.count
VCR.use_cassette("reservations_create_without_plan_success") do
token = Stripe::Token.create(
:card => {
:number => "4242424242424242",
:exp_month => 4,
:exp_year => 1.year.from_now.year,
:cvc => "314"
},
)
post reservations_path, { reservation: {
user_id: @user.id,
reservable_id: machine.id,
reservable_type: machine.class.name,
card_token: token.id,
card_token: stripe_card_token,
slots_attributes: [
{ start_at: availability.start_at.to_s(:iso8601),
end_at: (availability.start_at + 1.hour).to_s(:iso8601),
availability_id: availability.id
}
]
}}.to_json, { 'Accept' => Mime::JSON, 'Content-Type' => Mime::JSON.to_s }
}}.to_json, default_headers
end
# general assertions
@ -52,9 +43,6 @@ module Reservations
assert invoice_item.stp_invoice_item_id
assert_equal invoice_item.amount, machine.prices.find_by(group_id: @user.group_id).amount
p json_response(response.body)
end
end
end

View File

@ -13,7 +13,6 @@ end
Sidekiq::Testing.inline!
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new({ color: true })]
require "stripe"
@ -26,6 +25,10 @@ class ActiveSupport::TestCase
JSON.parse(body, symbolize_names: true)
end
def default_headers
{ 'Accept' => Mime::JSON, 'Content-Type' => Mime::JSON.to_s }
end
def stripe_card_token
Stripe::Token.create(
:card => {