On 3/6/06, Rick Olson <[EMAIL PROTECTED]> wrote:
> So, I sat down to use set_fixture_class, and it bombed on the first
> thing I tried:
>
> set_fixture_class :content_drafts => "Article::Draft"
>
> I made a quick patch, and I'd appreciate a quick run through your
> tests to make sure it doesn't disturb anything:
> http://dev.rubyonrails.org/ticket/4095
>
> As I was typing this, I realized that the string gives us no benefits.
>  I made a much lighter patch that accepts the class instead (which was
> actually the first thing I tried):
>
> set_fixture_class :content_drafts => Article::Draft

I like the fact you're passing a class,   much nicer way of handling
things like modules.

However,

http://dev.rubyonrails.org/attachment/ticket/4095/simpler_set_fixture_class.diff#L18

12      +    klass = case @class_name
13      +      when Symbol, String
14      +        Object.const_get(@class_name) if 
Object.const_defined?(@class_name)
15      +      when Class
16      +        @class_name
17      +      else
18      +        nil
19           end
20      +    klass.find(self[klass.primary_key]) if klass

That nil is just going to raise a NoMethodError,   why not raise a
specific exception, or at least a RuntimeError with a nice message?



> thoughts?
>
> --
> Rick Olson
> http://techno-weenie.net
> _______________________________________________
> Rails-core mailing list
> Rails-core@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-core
>


--
Cheers

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

Reply via email to