mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
[bug] unable to create a plan
This commit is contained in:
parent
72421f99a5
commit
0f57e1081f
@ -1,5 +1,8 @@
|
||||
# Changelog Fab-manager
|
||||
|
||||
- Added an automated test on the plan creation endpoint
|
||||
- Fix a bug: unable to create a plan
|
||||
|
||||
## v5.1.11 2021 October 22
|
||||
|
||||
- Refactored subscription new/renew/free extend interfaces and API
|
||||
|
2
Procfile
2
Procfile
@ -1,4 +1,4 @@
|
||||
web: bundle exec rails server puma -p $PORT
|
||||
#web: bundle exec rails server puma -p $PORT
|
||||
worker: bundle exec sidekiq -C ./config/sidekiq.yml
|
||||
wp-client: bin/webpack-dev-server
|
||||
wp-server: SERVER_BUNDLE_ONLY=yes bin/webpack --watch
|
||||
|
@ -132,6 +132,6 @@ class Plan < ApplicationRecord
|
||||
end
|
||||
|
||||
def update_gateway_product
|
||||
PaymentGatewayService.new.create_or_update_product(Plan.base_name, id)
|
||||
PaymentGatewayService.new.create_or_update_product(Plan.name, id)
|
||||
end
|
||||
end
|
||||
|
47
test/integration/plans/create_plan_test.rb
Normal file
47
test/integration/plans/create_plan_test.rb
Normal file
@ -0,0 +1,47 @@
|
||||
# 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)
|
||||
assert_equal Plan.last.id, plan[:id]
|
||||
assert_equal plans_count + 1, Plan.count
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user