Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rspec failure on X-Inertia requests #94

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

iatanas0v
Copy link
Contributor

@iatanas0v iatanas0v commented Mar 10, 2023

As initial request and subsequent requests are handled with different renderers sometimes we may end up in situation where controller action may fail just in one of those cases:

https://github.com/inertiajs/inertia-rails/blob/master/lib/inertia_rails/renderer.rb#L19L28

This is exactly what happened on one of my work projects. Subsequent requests (with X-Inertia header were failing) but my rspec specs were all 🟢 .

Naturally, I decided to add another spec that issues the request with X-Inertia header. It turned out that the rspec helper is not expecting that 😅 . This PR aims to resolve that and allow tests like the one below.

it 'works on subsequential requests' do
  get homepage_path, headers: {'X-Inertia' => true}

  expect(inertia_props.keys).to include('records', 'pagination', 'filters')
end

@iatanas0v iatanas0v changed the title fix rspec failure on Inertia requests fix rspec failure on X-Inertia requests Mar 10, 2023
@iatanas0v iatanas0v changed the title fix rspec failure on X-Inertia requests Fix rspec failure on X-Inertia requests Jun 10, 2024
Copy link
Collaborator

@BrandonShar BrandonShar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @iatanas0v and sorry for taking so long to review this, I"m not sure how I missed it!

@BrandonShar BrandonShar merged commit 4873804 into inertiajs:master Oct 25, 2024
@iatanas0v iatanas0v deleted the fix-rspec-on-inertia-requests branch October 25, 2024 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants