Changeset 144

Show
Ignore:
Timestamp:
11/24/05 03:00:59 (3 years ago)
Author:
lazyatom
Message:

Added load_plugin_fixtures task and documentation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/engines/README

    r121 r144  
    241241        $LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path) 
    242242 
     243== Loading Fixtures 
     244 
     245An additional helpful task for loading fixture data is also provided (thanks to Joe Van Dyk): 
     246 
     247  rake load_plugin_fixtures 
     248  rake load_plugin_fixtures PLUGIN=login_engine 
     249   
     250will load the engine fixture data into your development database. 
     251 
     252=== Important Caveat 
     253Unlike the new 'fixture' directive described above, this task currently relies on you ensuring that the table name to load fixtures into is the same as the name of the fixtures file you are trying to load. If you are using defaults, this should be fine. If you have changed table names, you will need to rename your fixtures files (and possibly update your tests to reflect this too). 
     254 
     255You should also note that fixtures typically tend to depend on test configuration information (such as test salt values), so not all data will be usable in fixture form. 
  • plugins/engines/tasks/engines.rake

    r121 r144  
    3232  end 
    3333end 
     34 
     35# this is just a rip-off from the plugin stuff in railties/lib/tasks/documentation.rake,  
     36# because the default plugindoc stuff doesn't support subdirectories like app. 
     37 
     38AllEngines = FileList['vendor/plugins/*_engine'].map {|engine| File.basename(engine)} 
     39# Define doc tasks for each engine 
     40AllEngines.each do |engine| 
     41  task :"#{engine}_enginedoc" => :environment do 
     42    engine_base   = "vendor/plugins/#{engine}" 
     43    options       = [] 
     44    files         = Rake::FileList.new 
     45    options << "-o doc/plugins/#{engine}" 
     46    options << "--title '#{engine.titlecase} Documentation'" 
     47    options << '--line-numbers --inline-source' 
     48    options << '--all' # include protected methods 
     49    options << '-T html' 
     50 
     51    files.include("#{engine_base}/lib/**/*.rb") 
     52    files.include("#{engine_base}/app/**/*.rb") 
     53    if File.exists?("#{engine_base}/README") 
     54      files.include("#{engine_base}/README")     
     55      options << "--main '#{engine_base}/README'" 
     56    end 
     57    files.include("#{engine_base}/CHANGELOG") if File.exists?("#{engine_base}/CHANGELOG") 
     58 
     59    options << files.to_s 
     60 
     61    sh %(rdoc #{options * ' '}) 
     62  end 
     63end 
     64 
     65desc "Generate documation for all installed engines" 
     66task :enginedoc => AllEngines.map {|engine| :"#{engine}_enginedoc"} 
     67 
     68 
     69desc "Load plugin/engine fixtures into the current environment's database." 
     70task :load_plugin_fixtures => :environment do 
     71  require 'active_record/fixtures' 
     72  ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym) 
     73  plugin = ENV['PLUGIN'] || '*' 
     74  Dir.glob(File.join(RAILS_ROOT, 'vendor', 'plugins', plugin, 'test', 'fixtures', '*.yml')).each do |fixture_file| 
     75    Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*')) 
     76  end 
     77end