From 247cb32a23f950fb3bcf8d4f818625db4916b3df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Semp=C3=A9?= Date: Thu, 5 Oct 2023 10:09:03 +0200 Subject: [PATCH] feat(override-plan): Ability to fetch a single subscription (#141) --- spec/lago/api/resources/subscription_spec.rb | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/lago/api/resources/subscription_spec.rb b/spec/lago/api/resources/subscription_spec.rb index f8a20df..b39113e 100644 --- a/spec/lago/api/resources/subscription_spec.rb +++ b/spec/lago/api/resources/subscription_spec.rb @@ -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 {