Skip to content

Commit a159fd0

Browse files
akaspickNZKoz
authored andcommitted
Fix fixtures in integration test sessions
Signed-off-by: Michael Koziarski <[email protected]>
1 parent e8b84ab commit a159fd0

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

actionpack/lib/action_controller/integration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ def open_session(application = nil)
536536
if self.class.respond_to?(:fixture_table_names)
537537
self.class.fixture_table_names.each do |table_name|
538538
name = table_name.tr(".", "_")
539-
next unless respond_to?(name)
539+
next unless respond_to?(name, true)
540540
extras.__send__(:define_method, name) { |*args|
541541
delegate.send(name, *args)
542542
}

actionpack/test/controller/integration_test.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,24 @@ def method_missing(name, *args)
227227
end
228228
end
229229

230+
require 'active_record_unit'
231+
# Tests that fixtures are accessible in the integration test sessions
232+
class IntegrationTestWithFixtures < ActiveRecordTestCase
233+
include ActionController::Integration::Runner
234+
235+
fixtures :companies
236+
237+
def test_fixtures_in_new_session
238+
sym = :thirty_seven_signals
239+
# fixtures are accessible in main session
240+
assert_not_nil companies(sym)
241+
242+
# create a new session and the fixtures should be accessible in it as well
243+
session1 = open_session { |sess| }
244+
assert_not_nil session1.companies(sym)
245+
end
246+
end
247+
230248
# Tests that integration tests don't call Controller test methods for processing.
231249
# Integration tests have their own setup and teardown.
232250
class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest

0 commit comments

Comments
 (0)