1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/test/integration/plans/create_plan_test.rb

48 lines
1.2 KiB
Ruby
Raw Normal View History

2021-11-10 17:06:21 +01:00
# frozen_string_literal: true
require 'test_helper'
class CreatePlanTest < ActionDispatch::IntegrationTest
setup do
admin = User.with_role(:admin).first
login_as(admin, scope: :user)
end
test 'create a plan' do
plans_count = Plan.count
post '/api/plans',
params: {
plan: {
base_name: 'Abonnement test',
type: 'Plan',
group_id: 1,
plan_category_id: nil,
interval: 'week',
interval_count: 2,
amount: 10,
ui_weight: 0,
is_rolling: true,
monthly_payment: false,
description: 'lorem ipsum dolor sit amet',
partner_id: '',
plan_file_attributes: {
id: nil,
_destroy: nil,
attachment: nil
}
}
}.to_json,
headers: default_headers
# Check response format & status
assert_equal 201, response.status, response.body
assert_equal Mime[:json], response.content_type
# Check the created plan
plan = json_response(response.body)
2022-05-23 16:15:49 +02:00
assert_equal Plan.last.id, plan[:plan_ids][0]
2021-11-10 17:06:21 +01:00
assert_equal plans_count + 1, Plan.count
end
end