Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,4 @@ DEPENDENCIES
webvalve

BUNDLED WITH
1.17.3
2.2.20
5 changes: 5 additions & 0 deletions app/models/unity/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,10 @@ def trial_expired?
return true unless trial_ends_at.present?
trial_ends_at < Time.current
end

def awaiting_cancellation?
active? &&
cancellation_date > Time.current
end
end
end
18 changes: 18 additions & 0 deletions spec/models/unity/subscription_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,22 @@
RSpec.describe Unity::Subscription, type: :model do
it { should belong_to :subscription_plan }
it { should belong_to Unity.config.user_class.downcase.to_sym }

context "when cancelling a subscription" do
context "when the subscription is still active" do

let(:subscription) do
build(
:unity_subscription,
gateway_status: :active,
marked_for_cancellation_at: Time.currents,
cancellation_date: 2.days.from_now,
)
end

it "responds true to #awaiting_cancellation?" do
expect(subscription.awaiting_cancellation?).to eq true
end
end
end
end