Skip to content

Commit

Permalink
can run test
Browse files Browse the repository at this point in the history
  • Loading branch information
sue445 committed Jul 9, 2013
1 parent da1e88f commit f220c51
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/active_record/turntable/active_record_ext/fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
#
require 'active_record/fixtures'
module ActiveRecord
class Fixtures
if ActiveRecord::VERSION::STRING > "4.0"
TURNTABLE_AR_FIXTURE = FixtureSet
else
TURNTABLE_AR_FIXTURE = Fixtures
end

class TURNTABLE_AR_FIXTURE
def self.create_fixtures(fixtures_directory, table_names, class_names = {})
table_names = [table_names].flatten.map { |n| n.to_s }
table_names.each { |n|
Expand All @@ -24,7 +30,7 @@ def self.create_fixtures(fixtures_directory, table_names, class_names = {})
fixture_files = files_to_read.map do |path|
table_name = path.tr '/', '_'

fixtures_map[path] = ActiveRecord::Fixtures.new(
fixtures_map[path] = ActiveRecord::TURNTABLE_AR_FIXTURE.new(
connection,
table_name,
class_names[table_name.to_sym] || table_name.classify,
Expand Down
7 changes: 6 additions & 1 deletion lib/active_record/turntable/shard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ def spec_for(config)
raise "Please install the #{config['adapter']} adapter: `gem install activerecord-#{config['adapter']}-adapter` (#{e})"
end
adapter_method = "#{config['adapter']}_connection"
ActiveRecord::Base::ConnectionSpecification.new(config, adapter_method)

if ActiveRecord::VERSION::STRING > "4.0"
ActiveRecord::ConnectionAdapters::ConnectionSpecification.new(config, adapter_method)
else
ActiveRecord::Base::ConnectionSpecification.new(config, adapter_method)
end
end
end
end
Expand Down

0 comments on commit f220c51

Please sign in to comment.