Skip to content

Add a scenario for using subdomain constrained routes #2520

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

Merged
merged 3 commits into from
Oct 7, 2021

Conversation

mirkode
Copy link
Contributor

@mirkode mirkode commented Sep 27, 2021

Just some documentation on how to use host! in before block for testing subdomain constrained requests.

Credits for this go to @gferrarocamus for pointing this out, see #789 (comment)

Copy link
Member

@pirj pirj left a comment

Choose a reason for hiding this comment

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

A couple of notes.
Looks good otherwise, thank you!

headers = { "ACCEPT" => "application/json" }
post "/widgets", :params => { :widget => {:name => "My Widget"} }, :headers => headers

expect(response.content_type).to eq("application/json; charset=utf-8")
Copy link
Member

Choose a reason for hiding this comment

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

As you may have noticed, content_type depends on the Rails version. We have different examples, and they are either run or skipped depending on CI job matrix.
I suggest .to start_with("application/json") so that this example passes with all Rails versions from our matrix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @pirj ,

Thanks for your feedback. I added the requested changes.
However the test without the host! is still passing, so I wanna look into this again. I will let you know once the PR is ready for review again.
Thanks for taking the time!

Copy link
Member

Choose a reason for hiding this comment

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

I checked on Rails 6 that this fails without host!

@JonRowe JonRowe merged commit 3f0e350 into rspec:main Oct 7, 2021
@pirj
Copy link
Member

pirj commented Oct 7, 2021

Thank you for the contribution!

JonRowe added a commit that referenced this pull request Jan 26, 2022
Add a scenario for using subdomain constrained routes
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.

3 participants