You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to assert an included jsonapi document with
# Assume `class Foo has_one(:bar, polymorphic: true)`
describe 'foos#show' do
context 'with included bar' do
foo_in_db, bar_in_db = seed_a_foo_with_a_bar # Foo.find(42).bar exists
get "/foos/42", params: { include: 'bar }
foo_json = json_item
bar_included_in_foo_json = json_include(json_included_types.first)
expect(json_included_item).to be
assert_payload(:'bar_payload', bar_in_db, bar_included_in_foo_json)
The problem : there was a bug in my application code (irrelevant here) and json_included_types.first was nil/didn't contain my expected Bar, therefore resulting in a json_include(nil) which did not return an error and instead returned a version of the main json_item (Foo) stripped of its metadata, causing the test to pass when it actually failed
The text was updated successfully, but these errors were encountered:
happycollision
added a commit
to happycollision/jsonapi_spec_helpers
that referenced
this issue
Feb 24, 2018
I was trying to assert an included jsonapi document with
The problem : there was a bug in my application code (irrelevant here) and
json_included_types.first
was nil/didn't contain my expected Bar, therefore resulting in ajson_include(nil)
which did not return an error and instead returned a version of the mainjson_item
(Foo) stripped of its metadata, causing the test to pass when it actually failedThe text was updated successfully, but these errors were encountered: