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

Ticket #8714 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

[PATCH] Fix actionpack testsuite

Reported by: mpalmer Assigned to: core
Priority: high Milestone: 1.x
Component: ActionPack Version: edge
Severity: normal Keywords:
Cc:

Description

Running the actionpack test suite for r7076 produces:

./test/controller/new_render_test.rb:3: superclass mismatch for class Customer (TypeError)

This is because Customer is already defined as being a different type of struct at the top of test/controller/render_test.rb. My guess is that nobody's seen this before due to load order issues, since the "definition" in render_test.rb is guarded against multiple definitions, while the one in new_render_test.rb isn't. If new_render_test.rb loads first, then everything's OK since the more extensive form of Customer gets loaded and the guard prevents multiple definition. However, render_test.rb gets loaded first for me, and so everything goes to poop.

The attached patch handles this problem in two ways:

  • It guards both instances of Customer against multiple definition (this prevents any possibility of "superclass mismatch" errors);
  • The definition of Customer has been corrected to be the same in both cases (since otherwise, if the (:name) form of Customer is used, other tests fail).

The real solution, IMHO, is to split the definition of Customer out into a separate file and require it wherever it's needed, but I don't know where such a file would go, so I'm leaving that well alone and sticking with the "slightly hackish" version.

Attachments

fix_actionpack_tests.patch (1.3 kB) - added by mpalmer on 07/07/07 00:13:24.
Improved patch

Change History

06/28/07 02:28:32 changed by chjunior

In a conversation with lifofifo we got some speculations. With him the tests are passing, and I'm having the same error that this ticket describes. lifo's ruby version is the same as me, and rake too. The speculation that we have is about the version of the unit test package, but this could not be verified since this information is not included in the package.

06/28/07 03:40:15 changed by mpalmer

I'm running Ubuntu Dapper, with the Test::Unit from libruby1.8 version 1.8.4-1ubuntu1.3. My unit/test.rb has an md5sum of 9f50148cf8391e9337e0764b16871fb1, if that helps you in determining whether you've got the same Test::Unit as I do.

Personally, whether it's working for some people or not, the test suite is still a bit broken considering the differing definitions of the Customer model. It's worth fixing the test suite just for that, IMHO.

07/06/07 15:12:59 changed by mikong

This is similar to http://dev.rubyonrails.org/ticket/8849.

This was already mentioned in the mailing list, but I'd just like to post a link here so that when the properties of this 8714 ticket is changed, 8849 won't be forgotten. If there's a better or standard way of grouping similar tickets together, please let me know.

Btw, isn't this supposed to be a major ticket instead of normal? Just my opinion, so am not actually changing the property.

07/07/07 00:13:24 changed by mpalmer

  • attachment fix_actionpack_tests.patch added.

Improved patch

07/07/07 00:14:33 changed by mpalmer

A new and improved patch, placing the model in actionpack/test/fake_models.rb, as per mikong's suggestion.

07/17/07 09:44:06 changed by nzkoz

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

(In [7190]) Introduce fake_models.rb to avoid platform-specific code. [mpalmer] Closes #8714