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

Rework headers functional tests #9716

Merged
merged 2 commits into from
Mar 15, 2013

Conversation

senny
Copy link
Member

@senny senny commented Mar 14, 2013

1. headers in functional tests

#9700 already added support for functional tests as well. I just added test-cases to lock the behaviour and updated the documentation accordingly.

2. document functional tests

I added documentation for the request simulation methods in functional tests.

@senny
Copy link
Member Author

senny commented Mar 14, 2013

@carlosantoniodasilva @pixeltrix let me know what you think.

@@ -626,6 +630,24 @@ def test_params_passing_doesnt_modify_in_place
assert_equal 2004, page[:year]
end

test "set additional HTTP headers" do
@request.env['Referer'] = "http://www.google.com"
@request.env['Content-Type'] = "application/rss+xml"
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't these be @request.headers ?

@senny
Copy link
Member Author

senny commented Mar 14, 2013

@pixeltrix the fact that I used both notations is clearly a sign that it is confusing 😄 it is the other way around though. Using request.headers does not work. You need to use request.env as the headers method always instantiated a new Http::Headers class the changes will not persist: https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/http/request.rb#L151-L153

@senny
Copy link
Member Author

senny commented Mar 15, 2013

@pixeltrix I updated the examples to be more useful. The access is still through @request.env. The problem is that Http::Headers does not reference the hash passed in but has it's own hash.

The env hash passed to `Http::Headers#new` must be in env format.
Also be aware that the passed hash is modified directly.

docs and test-cases for setting headers/env in functional tests.

Follow up to rails#9700.
pixeltrix added a commit that referenced this pull request Mar 15, 2013
@pixeltrix pixeltrix merged commit ddb9040 into rails:master Mar 15, 2013
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