diff options
author | Viktar Basharymau <viktar.basharymau@thehamon.com> | 2014-06-25 12:40:02 +0300 |
---|---|---|
committer | Viktar Basharymau <viktar.basharymau@thehamon.com> | 2014-06-27 17:46:47 +0300 |
commit | 0526fad51a06ee4b739c4ec0ecd9f26351f5c08f (patch) | |
tree | e6d2bdddabddcb6d31df1be473e5171cb03966c2 /activerecord | |
parent | 13ff102c8439c683fb34371a0672d7b48e110d1f (diff) | |
download | rails-0526fad51a06ee4b739c4ec0ecd9f26351f5c08f.tar.gz rails-0526fad51a06ee4b739c4ec0ecd9f26351f5c08f.tar.bz2 rails-0526fad51a06ee4b739c4ec0ecd9f26351f5c08f.zip |
Get rid of duplication in db:fixtures:{identify,load}
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/railties/databases.rake | 13 | ||||
-rw-r--r-- | activerecord/lib/active_record/tasks/database_tasks.rb | 6 |
2 files changed, 7 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 695ae2ae41..2a44c9e559 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -189,11 +189,7 @@ db_namespace = namespace :db do task :load => [:environment, :load_config] do require 'active_record/fixtures' - base_dir = if ENV['FIXTURES_PATH'] - ActiveRecord::Tasks::DatabaseTasks.root.join(ENV['FIXTURES_PATH']) - else - ActiveRecord::Tasks::DatabaseTasks.fixtures_path - end + base_dir = ActiveRecord::Tasks::DatabaseTasks.fixtures_path fixtures_dir = File.join [base_dir, ENV['FIXTURES_DIR']].compact @@ -211,12 +207,7 @@ db_namespace = namespace :db do puts %Q(The fixture ID for "#{label}" is #{ActiveRecord::FixtureSet.identify(label)}.) if label - base_dir = if ENV['FIXTURES_PATH'] - ActiveRecord::Tasks::DatabaseTasks.root.join(ENV['FIXTURES_PATH']) - else - ActiveRecord::Tasks::DatabaseTasks.fixtures_path - end - + base_dir = ActiveRecord::Tasks::DatabaseTasks.fixtures_path Dir["#{base_dir}/**/*.yml"].each do |file| if data = YAML::load(ERB.new(IO.read(file)).result) diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index 7712a14b79..4727469420 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -58,7 +58,11 @@ module ActiveRecord end def fixtures_path - @fixtures_path ||= File.join(root, 'test', 'fixtures') + @fixtures_path ||= if ENV['FIXTURES_PATH'] + File.join(root, ENV['FIXTURES_PATH']) + else + File.join(root, 'test', 'fixtures') + end end def root |