Anyone have comments on ticket 3935
(http://dev.rubyonrails.org/ticket/3935) ? I think it should be in
1.1.

It allows for a set_fixture_class method in unit tests so table
accessor methods still work if your model uses a set_table_name call.

So for example (and from the unit tests):
model:

class Joke < ActiveRecord::Base
  set_table_name 'funny_jokes'
end

The fixture would be at test/fixtures/funny_jokes.yml

In the unit test, you would need to supply:

set_fixture_class :funny_jokes => 'Joke'

Additionally, I had in mind a later patch which would allow for:

fixtures :funny_jokes => 'Joke', :more_things => 'Thing'

and would call set_fixture_class and then fixtures if passed a hash
instead of of an array.



The one thing that may need thought is that in order to make this
change, I had to change the prototypes of Fixture#initialize,
Fixtures#initialize and Fixtures#create_fixtures, which are not
backwards compatable, but the only code in rails which uses these is
in the fixtures code and the test code.

I think making fixtures work for models with set_table_name is more important.

Thoughts?
_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to