scribe/spec/actions/articles/show_spec.cr
Edward Loveall f05a12a880
Add support for missing posts
Posts, like 8661f4724aa9, can go missing if the account or post was
removed. In this case, the API returns data like this:

```json
{
  "data": {
    "post": null
  }
}
```

When this happens, we can detect it because the parsed response now has
a nil value: `response.data.post == nil` and construct an `EmptyPage`
instead of a `Page`. The `Articles::Show` action can then render
conditionally based on if the response from `PageConverter` is a `Page`
or an `EmptyPage`.
2022-06-17 16:00:01 -04:00

15 lines
331 B
Crystal

require "../../spec_helper"
include ActionHelpers
describe Articles::Show do
context "if the article is missing" do
it "should raise a MissingPageError" do
context = action_context(path: "/abc123")
expect_raises(MissingPageError) do
Articles::Show.new(context, params).call
end
end
end
end