Skip to content

Commit

Permalink
fix ActiveRecord::Fixtures deprecation warning in AR 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
brettg authored and rdy committed Jun 4, 2015
1 parent 6b58c49 commit 6999fc3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/fixture_builder/builder.rb
Expand Up @@ -27,13 +27,22 @@ def create_fixture_objects

def load_legacy_fixtures
legacy_fixtures.each do |fixture_file|
# Rails 3.0 and 3.1+ support
fixtures_class = defined?(ActiveRecord::Fixtures) ? ActiveRecord::Fixtures : ::Fixtures
fixtures = fixtures_class.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
populate_custom_names(fixtures)
end
end

# Rails 3.0 and 3.1+ support
def fixtures_class
if defined?(ActiveRecord::FixtureSet)
ActiveRecord::FixtureSet
elsif defined?(ActiveRecord::Fixtures)
ActiveRecord::Fixtures
else
::Fixtures
end
end

def surface_errors
yield
rescue Object => error
Expand Down

0 comments on commit 6999fc3

Please sign in to comment.