1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-26 20:54:21 +01:00
fab-manager/test/integration/subscriptions_test.rb

31 lines
784 B
Ruby
Raw Normal View History

2016-04-06 11:27:56 +02:00
class SubscriptionsTest < ActionDispatch::IntegrationTest
setup do
2016-04-06 15:23:13 +02:00
@user = User.find_by_username('jdupond')
2016-04-06 11:27:56 +02:00
login_as(@user, scope: :user)
end
test "user take a subscription" do
plan = Plan.where(group_id: @user.group.id, type: 'Plan').first
2016-04-06 15:57:27 +02:00
VCR.use_cassette("subscriptions_user_create_success") do
post '/api/subscriptions',
{
subscription: {
plan_id: plan.id,
user_id: @user.id,
card_token: stripe_card_token
}
}.to_json, default_headers
end
2016-04-06 11:27:56 +02:00
assert_equal 201, response.status, response.body
assert_equal Mime::JSON, response.content_type
subscription = json_response(response.body)
assert_equal plan.id, subscription[:plan_id]
end
end