1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/test/controller
Tawan Sierek 064744bef6
Fix ActionDispatch::IntegrationTest#open_session
Reset a new session directly after its creation in
`ActionDispatch::IntegrationTest#open_session`. Reset the session to a clean
state before making it available to the client's test code.

Issue #22742 reports unexpected behavior of integration tests that run multiple
sessions. For example an `ActionDispatch::Flash` instance is shared across
multiple sessions, though a client code will rightfully assume that each new
session has its own flash hash.

The following test failed due to this behavior:

    class Issue22742Test < ActionDispatch::IntegrationTest
      test 'issue #22742' do
        integration_session # initialize first session
        a = open_session
        b = open_session

        refute_same(a.integration_session, b.integration_session)
      end
    end

Instead of creating a new `ActionDispatch::Integration::Session` instance,
the same instance is shared across all newly opened test sessions. This is
due to the way how new test sessions are created in
`ActionDispatch::IntegrationTest#open_session`. The already existing
`ActionDispatch::IntegrationTest` instance is duplicated  with `Object#dup`,
This approach was introduced in commit 15c31c7639. `Object#dup` copies the
instance variables, but not the objects they reference. Therefore this issue
only occurred when the current test instance had been tapped in such a way that
the instance variable `@integration_session` was initialized before creating the
new test session.

Close #22742

[Tawan Sierek + Sina Sadeghian]
2016-11-18 15:07:16 -05:00
..
api Remove deprecated support to :text in render 2016-10-10 00:02:52 -03:00
controller_fixtures
metal applies new string literal convention in actionpack/test 2016-08-06 18:54:50 +02:00
mime Add three new rubocop rules 2016-08-16 04:30:11 -03:00
new_base Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
parameters Fix style violations 2016-11-14 13:18:31 -05:00
request Fixed CONTENT_LENGTH header in ActionController::TestRequest 2016-11-15 12:50:38 +03:00
action_pack_assertions_test.rb Add three new rubocop rules 2016-08-16 04:30:11 -03:00
base_test.rb improve error message when include assertions fail 2016-09-16 12:03:37 -07:00
caching_test.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
content_type_test.rb normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
default_url_options_with_before_action_test.rb Add three new rubocop rules 2016-08-16 04:30:11 -03:00
filters_test.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
flash_hash_test.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
flash_test.rb improve error message when include assertions fail 2016-09-16 12:03:37 -07:00
force_ssl_test.rb Remove unneeded FIXME note 2016-08-29 11:04:15 -03:00
form_builder_test.rb applies new string literal convention in actionpack/test 2016-08-06 18:54:50 +02:00
helper_test.rb improve error message when include assertions fail 2016-09-16 12:03:37 -07:00
http_basic_authentication_test.rb normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
http_digest_authentication_test.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
http_token_authentication_test.rb Add three new rubocop rules 2016-08-16 04:30:11 -03:00
integration_test.rb Fix ActionDispatch::IntegrationTest#open_session 2016-11-18 15:07:16 -05:00
live_stream_test.rb Silence a warning 2016-10-07 15:21:48 -04:00
localized_templates_test.rb applies new string literal convention in actionpack/test 2016-08-06 18:54:50 +02:00
log_subscriber_test.rb Add three new rubocop rules 2016-08-16 04:30:11 -03:00
output_escaping_test.rb applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
parameter_encoding_test.rb Add three new rubocop rules 2016-08-16 04:30:11 -03:00
params_wrapper_test.rb Merge pull request #27007 from maclover7/jm-fix-26912 2016-11-13 23:09:08 -05:00
permitted_params_test.rb applies new string literal convention in actionpack/test 2016-08-06 18:54:50 +02:00
redirect_test.rb Remove deprecated support to :back in redirect_to 2016-10-09 23:57:49 -03:00
render_js_test.rb modernizes hash syntax in actionpack 2016-08-06 19:35:13 +02:00
render_json_test.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
render_test.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
render_xml_test.rb modernizes hash syntax in actionpack 2016-08-06 19:35:13 +02:00
renderer_test.rb Allow any key in Renderer environment hash 2016-10-15 07:03:33 -05:00
renderers_test.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
request_forgery_protection_test.rb Add three new rubocop rules 2016-08-16 04:30:11 -03:00
required_params_test.rb Remove deprecated methods in ActionController::Parameters 2016-10-10 00:16:16 -03:00
rescue_test.rb applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
resources_test.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
routing_test.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
runner_test.rb applies new string literal convention in actionpack/test 2016-08-06 18:54:50 +02:00
send_file_test.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
show_exceptions_test.rb normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
streaming_test.rb applies new string literal convention in actionpack/test 2016-08-06 18:54:50 +02:00
test_case_test.rb Show what was the error when assertion has failed 2016-11-05 15:54:22 +09:00
url_for_integration_test.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
url_for_test.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
url_rewriter_test.rb Add three new rubocop rules 2016-08-16 04:30:11 -03:00
webservice_test.rb remove redundant curlies from hash arguments 2016-08-06 19:44:11 +02:00