Skip to content

Commit 38bda8a

Browse files
authored
chore: sync listCharges fixture with certificate-purchase entry (#468)
* chore: sync listCharges fixture with certificate-purchase entry * chore: remove accidental mise.toml * chore(billing_test): split certificate-purchase assertions into own test * chore: add CHANGELOG entry for listCharges fixture sync
1 parent 5b3db24 commit 38bda8a

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ This project uses [Semantic Versioning 2.0.0](http://semver.org/), the format is
44

55
## main
66

7+
### Changed
8+
9+
- Updated the `listCharges` test fixture to include a certificate purchase entry demonstrating that `product_reference` is a string even when it represents a numeric ID. (#468)
10+
711
### Removed
812

913
- **BREAKING**: Removed the deprecated `contact_id` attribute from the `Certificate` struct. The field was deprecated on 2022-05-17 and is no longer required for certificate operations.

test/dnsimple/client/billing_test.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def setup
4141

4242
assert_kind_of(Dnsimple::PaginatedResponse, response)
4343
assert_kind_of(Array, response.data)
44-
assert_equal(3, response.data.size)
44+
assert_equal(4, response.data.size)
4545

4646
response.data.each do |result|
4747
assert_kind_of(Dnsimple::Struct::Charge, result)
@@ -57,6 +57,19 @@ def setup
5757
assert_equal("14.5", response.data[0].items[0].amount.to_s("F"))
5858
end
5959

60+
test "returns certificate-purchase charges with string product reference" do
61+
stub_request(:get, %r{/v2/#{@account_id}/billing/charges})
62+
.to_return(read_http_fixture("listCharges/success.http"))
63+
64+
response = @subject.charges(@account_id)
65+
cert_charge = response.data[3]
66+
67+
assert_equal("5-2", cert_charge.reference)
68+
assert_equal("certificate-purchase", cert_charge.items[0].product_type)
69+
assert_kind_of(String, cert_charge.items[0].product_reference)
70+
assert_equal("42", cert_charge.items[0].product_reference)
71+
end
72+
6073
test "supports filters" do
6174
stub_request(:get, %r{/v2/#{@account_id}/billing/charges})
6275
.to_return(read_http_fixture("listCharges/success.http"))

test/fixtures.http/listCharges/success.http

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ cache-control: no-store, must-revalidate, private, max-age=0
99
x-request-id: a57a87c8-626a-4361-9fb8-b55ca9be8e5d
1010
x-runtime: 0.060526
1111

12-
{"data":[{"invoiced_at":"2023-08-17T05:53:36Z","total_amount":"14.50","balance_amount":"0.00","reference":"1-2","state":"collected","items":[{"description":"Register bubble-registered.com","amount":"14.50","product_id":1,"product_type":"domain-registration","product_reference":"bubble-registered.com"}]},{"invoiced_at":"2023-08-17T05:57:53Z","total_amount":"14.50","balance_amount":"0.00","reference":"2-2","state":"refunded","items":[{"description":"Register example.com","amount":"14.50","product_id":2,"product_type":"domain-registration","product_reference":"example.com"}]},{"invoiced_at":"2023-10-24T07:49:05Z","total_amount":"1099999.99","balance_amount":"0.00","reference":"4-2","state":"collected","items":[{"description":"Test Line Item 1","amount":"99999.99","product_id":null,"product_type":"manual","product_reference":null},{"description":"Test Line Item 2","amount":"1000000.00","product_id":null,"product_type":"manual","product_reference":null}]}],"pagination":{"current_page":1,"per_page":30,"total_entries":3,"total_pages":1}}
12+
{"data":[{"invoiced_at":"2023-08-17T05:53:36Z","total_amount":"14.50","balance_amount":"0.00","reference":"1-2","state":"collected","items":[{"description":"Register bubble-registered.com","amount":"14.50","product_id":1,"product_type":"domain-registration","product_reference":"bubble-registered.com"}]},{"invoiced_at":"2023-08-17T05:57:53Z","total_amount":"14.50","balance_amount":"0.00","reference":"2-2","state":"refunded","items":[{"description":"Register example.com","amount":"14.50","product_id":2,"product_type":"domain-registration","product_reference":"example.com"}]},{"invoiced_at":"2023-10-24T07:49:05Z","total_amount":"1099999.99","balance_amount":"0.00","reference":"4-2","state":"collected","items":[{"description":"Test Line Item 1","amount":"99999.99","product_id":null,"product_type":"manual","product_reference":null},{"description":"Test Line Item 2","amount":"1000000.00","product_id":null,"product_type":"manual","product_reference":null}]},{"invoiced_at":"2023-10-24T09:00:00Z","total_amount":"20.00","balance_amount":"0.00","reference":"5-2","state":"collected","items":[{"description":"Purchase Certificate www.bubble-registered.com","amount":"20.00","product_id":42,"product_type":"certificate-purchase","product_reference":"42"}]}],"pagination":{"current_page":1,"per_page":30,"total_entries":4,"total_pages":1}}

0 commit comments

Comments
 (0)