Defect #8932
closedUser.acts_as_customizable and association loading broken by Rails 2.3.11
0%
Description
Assuming we have 8 UserCustomFields.
In Rails 2.3.5 we can write:
>> User.find_by_admin(1, :include => :custom_values).custom_values.size => 8
In Rails 2.3.11 this fails:
>> User.find_by_admin(1, :include => :custom_values).custom_values.size => 0
This is because the ActiveRecord association code tries to load rows with custom_values.customized_type = 'User'
.
If we put acts_as_customizable
from User
and Group
to Principal
the :include
option also works with Rails 2.3.11.
Files
Related issues
Updated by Jean-Baptiste Barth about 13 years ago
Are you absolutely sure it won't break anything ? Could you apply the patch on current trunk, try to run the whole test suite and tell us if it's OK ? It could be a first step...
Updated by Thomas Löber about 13 years ago
With the attached patch applied to trunk
(r6402) the tests finished without errors.
I applied the patch to branches/1.2-stable
(r6294) on our production server Wednesday night and it is running fine (~30 issues added/updated) since that time.
So I'm quite (though not absolutely) sure that it has no negative impact.
C:/Ruby187/bin/ruby.exe -I"lib;test" "C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/a s/projects_helper_test.rb" "test/unit/helpers/repository_helper_test.rb" "test/unit/helpers/search_helper_test.rb" "test/unit /hook_test.rb" "test/unit/lib/redmine/i18n_test.rb" "test/unit/lib/redmine/menu_manager/mapper_test.rb" "test/unit/lib/redmin nit/lib/redmine/scm/adapters/subversion_adapter_test.rb" "test/unit/lib/redmine/themes_test.rb" "test/unit/lib/redmine/unifie em_test.rb" "test/unit/repository_git_test.rb" "test/unit/repository_mercurial_test.rb" "test/unit/repository_subversion_test (Test LDAP server not configured) * DEFERRED: #link_to_if_authorized authorized user should be tested. * DEFERRED: #link_to_if_authorized unauthorized user should be tested. * DEFERRED: IssuesHelper#show_detail with a estimated hours attribute should format the time into two decimal places. * DEFERRED: IssuesHelper#show_detail with a estimated hours attribute should format the old time into two decimal places. * DEFERRED: IssuesHelper#show_detail should test custom fields. * DEFERRED: IssuesHelper#show_detail should test attachments. * DEFERRED: #number_of_rows with one project should return the number of rows just for that project. * DEFERRED: #number_of_rows with no project should return the total number of rows for all the projects, resursively. * DEFERRED: #render_project should be tested. * DEFERRED: #render_issues should be tested. * DEFERRED: #render_version should be tested. * DEFERRED: #subject_for_project should test the PNG format. * DEFERRED: #subject_for_project should test the PDF format. * DEFERRED: #line_for_project :html format late line should start from the starting point on the left. * DEFERRED: #line_for_project :html format late line should be the total delayed width of the project. * DEFERRED: #line_for_project :html format done line should start from the starting point on the left. * DEFERRED: #line_for_project :html format done line should Be the total done width of the project. * DEFERRED: #line_for_project :html format status content should show the percent complete. * DEFERRED: #line_for_project should test the PNG format. * DEFERRED: #line_for_project should test the PDF format. * DEFERRED: #subject_for_version should test the PNG format. * DEFERRED: #subject_for_version should test the PDF format. * DEFERRED: #line_for_version should test the PNG format. * DEFERRED: #line_for_version should test the PDF format. * DEFERRED: #subject_for_issue should test the PNG format. * DEFERRED: #subject_for_issue should test the PDF format. * DEFERRED: #line_for_issue should test the PNG format. * DEFERRED: #line_for_issue should test the PDF format. * DEFERRED: #to_image should be tested. * DEFERRED: #to_pdf should be tested. * DEFERRED: Mapper#initialize should be tested. * DEFERRED: MenuManager#current_menu_item should be tested. * DEFERRED: MenuManager#render_main_menu should be tested. * DEFERRED: MenuManager#render_menu should be tested. * DEFERRED: MenuManager#menu_item_and_children should be tested. * DEFERRED: MenuManager#extract_node_details should be tested. * DEFERRED: MenuItem#caption should be tested. * DEFERRED: MenuItem#html_options should be tested. * DEFERRED: MenuManager#map should be tested. * DEFERRED: MenuManager#items should be tested. Bazaar test repository NOT FOUND. Skipping unit tests !!! Cvs test repository NOT FOUND. Skipping unit tests !!! Darcs test repository NOT FOUND. Skipping unit tests !!! Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS. Git test repository NOT FOUND. Skipping unit tests !!! Mercurial test repository NOT FOUND. Skipping unit tests !!! Subversion test repository NOT FOUND. Skipping unit tests !!! * DEFERRED: #start_date should be tested when issues have no start date. * DEFERRED: #due_date should be tested when issues have no due date. Bazaar test repository NOT FOUND. Skipping unit tests !!! CVS test repository NOT FOUND. Skipping unit tests !!! Darcs test repository NOT FOUND. Skipping unit tests !!! Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS. Git test repository NOT FOUND. Skipping unit tests !!! Mercurial test repository NOT FOUND. Skipping unit tests !!! Subversion test repository NOT FOUND. Skipping unit tests !!! Skipping LDAP tests. * DEFERRED: User#notify_about? other events should be added and tested. Skipping openid tests. Loaded suite C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader Started ............................................................................................................................. ............................................................................................................................. Finished in 264.762504 seconds. 1084 tests, 4236 assertions, 0 failures, 0 errors C:/Ruby187/bin/ruby.exe -I"lib;test" "C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/functi l/files_controller_test.rb" "test/functional/gantts_controller_test.rb" "test/functional/groups_controller_test.rb" "test/fun l/project_enumerations_controller_test.rb" "test/functional/queries_controller_test.rb" "test/functional/reports_controller_t .rb" "test/functional/time_entry_reports_controller_test.rb" "test/functional/trackers_controller_test.rb" "test/functional/u Skipping openid tests. * DEFERRED: IssueRelationsController should prevent relation creation when there's a circular dependency. D:/loeberth/Ablage/redmine/app/controllers/my_controller.rb:32: warning: already initialized constant BLOCKS D:/loeberth/Ablage/redmine/app/controllers/my_controller.rb:36: warning: already initialized constant DEFAULT_LAYOUT D:/loeberth/Ablage/redmine/app/controllers/repositories_controller.rb:244: warning: already initialized constant REV_PARAM_RE Bazaar test repository NOT FOUND. Skipping functional tests !!! CVS test repository NOT FOUND. Skipping functional tests !!! Darcs test repository NOT FOUND. Skipping functional tests !!! Filesystem test repository NOT FOUND. Skipping functional tests !!! Git test repository NOT FOUND. Skipping functional tests !!! Mercurial test repository NOT FOUND. Skipping functional tests !!! Subversion test repository NOT FOUND. Skipping functional tests !!! Loaded suite C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader Started ............................................................................................................................. Finished in 139.652095 seconds. 700 tests, 2155 assertions, 0 failures, 0 errors C:/Ruby187/bin/ruby.exe -I"lib;test" "C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/integr est/versions_test.rb" "test/integration/application_test.rb" "test/integration/issues_test.rb" "test/integration/layout_test. Loaded suite C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader Started ............................................................................................................................. ............................................................................................................................. Finished in 332.18853 seconds. 1115 tests, 2185 assertions, 0 failures, 0 errors
Updated by Etienne Massip about 13 years ago
- Target version set to Candidate for next minor release
Updated by Etienne Massip about 13 years ago
- Target version changed from Candidate for next minor release to Candidate for next major release
Updated by Jean-Philippe Lang about 12 years ago
- Status changed from New to Closed
Works OK with Rails 3.2.6.
Loading development environment (Rails 3.2.6) irb(main):001:0> User.find_by_admin(1, :include => :custom_values).custom_values.size ←[1m←[36mUser Load (0.0ms)←[0m ←[1mSELECT `users`.* FROM `users` WHERE `users `.`type` IN ('User', 'AnonymousUser') AND `users`.`admin` = 1 LIMIT 1←[0m ←[1m←[35mSQL (0.0ms)←[0m SELECT `custom_values`.`id` AS t0_r0, `custom_values `.`customized_type` AS t0_r1, `custom_values`.`customized_id` AS t0_r2, `custom_ values`.`custom_field_id` AS t0_r3, `custom_values`.`value` AS t0_r4, `custom_fi elds`.`id` AS t1_r0, `custom_fields`.`type` AS t1_r1, `custom_fields`.`name` AS t1_r2, `custom_fields`.`field_format` AS t1_r3, `custom_fields`.`possible_values ` AS t1_r4, `custom_fields`.`regexp` AS t1_r5, `custom_fields`.`min_length` AS t 1_r6, `custom_fields`.`max_length` AS t1_r7, `custom_fields`.`is_required` AS t1 _r8, `custom_fields`.`is_for_all` AS t1_r9, `custom_fields`.`is_filter` AS t1_r1 0, `custom_fields`.`position` AS t1_r11, `custom_fields`.`searchable` AS t1_r12, `custom_fields`.`default_value` AS t1_r13, `custom_fields`.`editable` AS t1_r14 , `custom_fields`.`visible` AS t1_r15, `custom_fields`.`multiple` AS t1_r16 FROM `custom_values` LEFT OUTER JOIN `custom_fields` ON `custom_fields`.`id` = `cust om_values`.`custom_field_id` WHERE `custom_values`.`customized_type` = 'Principa l' AND `custom_values`.`customized_id` IN (1) ORDER BY custom_fields.position => 1
Updated by Jean-Philippe Lang about 12 years ago
- Target version deleted (
Candidate for next major release)