Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11487 (closed task: fixed)

Opened 5 months ago

Last modified 5 months ago

[PATCH] Fix for generator tests in Railties so they are relevant (and pass!)

Reported by: thechrisoshow Assigned to: core
Priority: normal Milestone: 2.x
Component: Railties Version: edge
Severity: normal Keywords:
Cc:

Description

A bunch of tests to do with generating scaffolds, resources and models were failing because the tests were no longer applicable.

This patch fixes those tests, so they are testing the correct assumptions.

Attachments

fix_generator_tests.diff (19.5 kB) - added by thechrisoshow on 03/31/08 20:18:15.
Removed protected method that was never used

Change History

03/31/08 19:19:29 changed by miloops

I was working in a solution to this also, you may want to consider the solution to assert_generated_migration that was working for me:

  def assert_generated_migration(name,parent="ActiveRecord::Migration")
    file = Dir.glob("#{RAILS_ROOT}/db/migrate/*_#{name.to_s.underscore}.rb").first
    file = file.match(/db\/migrate\/[0-9]+_#{name.to_s.underscore}/).to_s
    assert_generated_class file,parent do |body|
      assert body=~/timestamps/, "should have timestamps defined"
      yield body if block_given?
    end
  end

03/31/08 19:59:07 changed by miloops

I also noticed that you removed the assertion of generated timestamps in migrations. The method assert_generated_timestamps is now defined but never used.

Is there a reason for this or you may want to include back this assertion?

03/31/08 20:05:07 changed by thechrisoshow

You're right about the timezones - I got migrations and fixtures mixed up (crazy I know!).

This latest patch adds your miloops sexier method - and also fixes a whole other set of tests that I had forgot (the ones in rails_generator_test.rb).

03/31/08 20:18:15 changed by thechrisoshow

  • attachment fix_generator_tests.diff added.

Removed protected method that was never used

04/01/08 00:29:27 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [9176]) Update generator tests. Closes #11487 [thechrisoshow]