Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[PATCH] integration test sessions fixture fix

#5301

In integration tests when creating a new session with open_session, fixtures would no longer be accessible in the new session.


# works
companies(:test)

open_session do |sess|
  # fixtures not accessible on sess... error
  #sess.companies(:test)
end

The code was broken because the existing session instance adds the fixture methods by checking if the current session responds to the fixture method name with respond_to?, but the fixture methods are private and would return false which would prevent the fixture methods in the new session from being created. Passing true to respond_to? checks private methods as well, which would then return true and then create the fixture access methods in the new session.

The patch should explain the issue more clearly.

Reported by Andrew Kaspick · August 4th, 2010 @ 08:49 PM

State: committed
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Andrew Kaspick
    Andrew Kaspick

    The issue becomes more apparent when extending the session with a module that makes use of fixtures. In this example, if a method in HelperMethods tries to access a fixture, it wouldn't work. This patch fixes that issue.

    open_session do |sess|
      sess.extend HelperMethods
    end
    

    August 4th, 2010 @ 08:55 PM

  2. Andrew Kaspick
    Andrew Kaspick
    • Tag set to patch, rails_2_3_stable

    August 4th, 2010 @ 08:57 PM

  3. Andrew Kaspick
    Andrew Kaspick
    • Tag changed from patch, rails_2_3_stable to integration_test, patch, rails_2_3_stable

    August 4th, 2010 @ 08:58 PM

  4. Andrew Kaspick
    Andrew Kaspick
    • Tag changed from integration_test, patch, rails_2_3_stable to integration_test, open_session, patch, rails_2_3_stable, tests

    August 6th, 2010 @ 05:30 AM

  5. Robert Pankowecki
    Robert Pankowecki

    The patch looks fine for me. Test is also included so I think we should take it.

    August 7th, 2010 @ 10:41 AM

  6. Michael Koziarski
    Michael Koziarski
    • State changed from new to committed
    • Importance changed from to Low

    Applied in a159fd0

    September 9th, 2010 @ 11:47 PM