Skip to content

Commit

Permalink
feat(override-plan): Ability to fetch a single subscription (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsempe authored Oct 5, 2023
1 parent bcf55a9 commit 247cb32
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/lago/api/resources/subscription_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,32 @@
end
end

describe '#get' do
context 'when subscription is successfully fetched' do
before do
stub_request(:get, "https://api.getlago.com/api/v1/subscriptions/#{factory_subscription.external_id}")
.to_return(body: response, status: 200)
end

it 'returns a subscription' do
subscription = resource.get(factory_subscription.external_id)

expect(subscription.external_id).to eq(factory_subscription.external_id)
end
end

context 'when there is an issue' do
before do
stub_request(:get, "https://api.getlago.com/api/v1/subscriptions/#{factory_subscription.external_id}")
.to_return(body: error_response, status: 422)
end

it 'raises an error' do
expect { resource.get(factory_subscription.external_id) }.to raise_error Lago::Api::HttpError
end
end
end

describe '#get_all' do
let(:response) do
{
Expand Down

0 comments on commit 247cb32

Please sign in to comment.