Merge pull request #32143 from sambostock/bubble-up-session-assertions
Delegate child session assertions to parent session
This commit is contained in:
commit
c135b922cf
|
@ -1,3 +1,16 @@
|
||||||
|
* Include child session assertion count in ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
|
`IntegrationTest#open_session` uses `dup` to create the new session, which
|
||||||
|
meant it had its own copy of `@assertions`. This prevented the assertions
|
||||||
|
from being correctly counted and reported.
|
||||||
|
|
||||||
|
Child sessions now have their `attr_accessor` overriden to delegate to the
|
||||||
|
root session.
|
||||||
|
|
||||||
|
Fixes #32142
|
||||||
|
|
||||||
|
*Sam Bostock*
|
||||||
|
|
||||||
* Add SameSite protection to every written cookie.
|
* Add SameSite protection to every written cookie.
|
||||||
|
|
||||||
Enabling `SameSite` cookie protection is an addition to CSRF protection,
|
Enabling `SameSite` cookie protection is an addition to CSRF protection,
|
||||||
|
|
|
@ -320,6 +320,7 @@ module ActionDispatch
|
||||||
APP_SESSIONS = {}
|
APP_SESSIONS = {}
|
||||||
|
|
||||||
attr_reader :app
|
attr_reader :app
|
||||||
|
attr_accessor :root_session # :nodoc:
|
||||||
|
|
||||||
def initialize(*args, &blk)
|
def initialize(*args, &blk)
|
||||||
super(*args, &blk)
|
super(*args, &blk)
|
||||||
|
@ -387,10 +388,19 @@ module ActionDispatch
|
||||||
def open_session
|
def open_session
|
||||||
dup.tap do |session|
|
dup.tap do |session|
|
||||||
session.reset!
|
session.reset!
|
||||||
|
session.root_session = self.root_session || self
|
||||||
yield session if block_given?
|
yield session if block_given?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def assertions # :nodoc:
|
||||||
|
root_session ? root_session.assertions : super
|
||||||
|
end
|
||||||
|
|
||||||
|
def assertions=(assertions) # :nodoc:
|
||||||
|
root_session ? root_session.assertions = assertions : super
|
||||||
|
end
|
||||||
|
|
||||||
# Copy the instance variables from the current session instance into the
|
# Copy the instance variables from the current session instance into the
|
||||||
# test instance.
|
# test instance.
|
||||||
def copy_session_variables! #:nodoc:
|
def copy_session_variables! #:nodoc:
|
||||||
|
|
|
@ -138,6 +138,14 @@ class IntegrationTestTest < ActiveSupport::TestCase
|
||||||
assert_not session1.equal?(session2)
|
assert_not session1.equal?(session2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_child_session_assertions_bubble_up_to_root
|
||||||
|
assertions_before = @test.assertions
|
||||||
|
@test.open_session.assert(true)
|
||||||
|
assertions_after = @test.assertions
|
||||||
|
|
||||||
|
assert_equal 1, assertions_after - assertions_before
|
||||||
|
end
|
||||||
|
|
||||||
# RSpec mixes Matchers (which has a #method_missing) into
|
# RSpec mixes Matchers (which has a #method_missing) into
|
||||||
# IntegrationTest's superclass. Make sure IntegrationTest does not
|
# IntegrationTest's superclass. Make sure IntegrationTest does not
|
||||||
# try to delegate these methods to the session object.
|
# try to delegate these methods to the session object.
|
||||||
|
|
Loading…
Reference in New Issue