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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

iatanas0v
Copy link

@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
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.

1 participant