6772312ea7
The primary license of the project is changing to: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later with some specific files to be licensed under the one of two licenses: CC0-1.0 LGPL-3.0-or-later This commit is one of the many steps to relicense the entire codebase. Documentation granting permission for this relicensing (from all past contributors who hold copyrights) is on file with Software Freedom Conservancy, Inc.
35 lines
1.3 KiB
Ruby
35 lines
1.3 KiB
Ruby
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
require 'rails_helper'
|
|
|
|
describe InsertBillingSubscriptions, :skip => true do
|
|
|
|
let(:sub) do
|
|
# billing_plan = Qx.insert_into(:billing_plans).values({name: 'test_bp', amount: 0, stripe_plan_id: 'stripe_bp', created_at: Time.current, updated_at: Time.current}).returning('*').execute.last
|
|
# InsertBillingSubscriptions.trial(3624, billing_plan['stripe_plan_id'])[:json]
|
|
end
|
|
|
|
describe '.trial' do
|
|
it 'creates the record' do
|
|
sub
|
|
expect(sub["id"]).to be_present
|
|
end
|
|
end
|
|
|
|
describe '.check_trial' do
|
|
|
|
it 'marks as inactive after 10 days' do
|
|
sub
|
|
Timecop.freeze(10.days.from_now){ InsertBillingSubscriptions.check_trial(sub['id']) }
|
|
updated = Qx.fetch(:billing_subscriptions, sub['id']).last
|
|
expect(updated['status']).to eq('inactive')
|
|
end
|
|
|
|
it 'does not change the status if not still trialing after 10 days' do
|
|
sub
|
|
Qx.update(:billing_subscriptions).set(status: 'active').where("id = $id", id: sub['id']).execute
|
|
Timecop.freeze(10.days.from_now){ InsertBillingSubscriptions.check_trial(sub['id']) }
|
|
updated = Qx.fetch(:billing_subscriptions, sub['id']).last
|
|
expect(updated['status']).to eq('active')
|
|
end
|
|
end
|
|
end
|