Skip to content
Merged
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
25 changes: 25 additions & 0 deletions AccessGridTest/ConsoleServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
}
""";

string capturedBody = null;

Check warning on line 267 in AccessGridTest/ConsoleServiceTests.cs

View workflow job for this annotation

GitHub Actions / test (8.0.x)

Converting null literal or possible null value to non-nullable type.
_mockHttpClient
.Setup(x => x.SendAsync(It.IsAny<HttpRequestMessage>()))
.Returns<HttpRequestMessage>(async req =>
Expand Down Expand Up @@ -349,7 +349,7 @@
{
var json = """{ "id": "tmpl-123", "name": "Test" }""";

string capturedBody = null;

Check warning on line 352 in AccessGridTest/ConsoleServiceTests.cs

View workflow job for this annotation

GitHub Actions / test (8.0.x)

Converting null literal or possible null value to non-nullable type.
_mockHttpClient
.Setup(x => x.SendAsync(It.IsAny<HttpRequestMessage>()))
.Returns<HttpRequestMessage>(async req =>
Expand Down Expand Up @@ -565,6 +565,31 @@
Assert.That(result.Pagination.TotalCount, Is.EqualTo(1));
}

[Test]
public async Task GetLedgerItemsAsync_ParsesAmountFromJsonString()
{
// Rails serializes BigDecimal as a JSON string, not a number.
var json = """
{
"ledger_items": [
{
"created_at": "2025-06-15T14:30:00Z",
"amount": "-1.50",
"id": "li_abc123",
"kind": "access_pass_debit"
}
],
"pagination": { "current_page": 1, "per_page": 50, "total_pages": 1, "total_count": 1 }
}
""";
StubHttpResponse(json);

var result = await _client.Console.GetLedgerItemsAsync();

Assert.That(result.LedgerItems, Has.Count.EqualTo(1));
Assert.That(result.LedgerItems[0].Amount, Is.EqualTo(-1.50m));
}

[Test]
public async Task GetLedgerItemsAsync_PassesDateFilters()
{
Expand Down
1 change: 1 addition & 0 deletions src/AccessGrid/Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ public class LedgerItem
public DateTime? CreatedAt { get; set; }

[JsonPropertyName("amount")]
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
public decimal Amount { get; set; }

[JsonPropertyName("id")]
Expand Down
Loading