@@ -519,11 +519,17 class Project < ActiveRecord::Base | |||||
519 | # Returns a scope of all custom fields enabled for project issues |
|
519 | # Returns a scope of all custom fields enabled for project issues | |
520 | # (explicitly associated custom fields and custom fields enabled for all projects) |
|
520 | # (explicitly associated custom fields and custom fields enabled for all projects) | |
521 | def all_issue_custom_fields |
|
521 | def all_issue_custom_fields | |
522 | @all_issue_custom_fields ||= IssueCustomField. |
|
522 | if new_record? | |
523 | sorted. |
|
523 | @all_issue_custom_fields ||= IssueCustomField. | |
524 | where("is_for_all = ? OR id IN (SELECT DISTINCT cfp.custom_field_id" + |
|
524 | sorted. | |
525 | " FROM #{table_name_prefix}custom_fields_projects#{table_name_suffix} cfp" + |
|
525 | where("is_for_all = ? OR id IN (?)", true, issue_custom_field_ids) | |
526 | " WHERE cfp.project_id = ?)", true, id) |
|
526 | else | |
|
527 | @all_issue_custom_fields ||= IssueCustomField. | |||
|
528 | sorted. | |||
|
529 | where("is_for_all = ? OR id IN (SELECT DISTINCT cfp.custom_field_id" + | |||
|
530 | " FROM #{table_name_prefix}custom_fields_projects#{table_name_suffix} cfp" + | |||
|
531 | " WHERE cfp.project_id = ?)", true, id) | |||
|
532 | end | |||
527 | end |
|
533 | end | |
528 |
|
534 | |||
529 | def project |
|
535 | def project |
@@ -610,6 +610,20 class ProjectsControllerTest < ActionController::TestCase | |||||
610 | assert_response 404 |
|
610 | assert_response 404 | |
611 | end |
|
611 | end | |
612 |
|
612 | |||
|
613 | def test_get_copy_should_preselect_custom_fields | |||
|
614 | field1 = IssueCustomField.generate!(:is_for_all => false) | |||
|
615 | field2 = IssueCustomField.generate!(:is_for_all => false) | |||
|
616 | source = Project.generate!(:issue_custom_fields => [field1]) | |||
|
617 | @request.session[:user_id] = 1 | |||
|
618 | ||||
|
619 | get :copy, :id => source.id | |||
|
620 | assert_response :success | |||
|
621 | assert_select 'fieldset#project_issue_custom_fields' do | |||
|
622 | assert_select 'input[type=checkbox][value=?][checked=checked]', field1.id.to_s | |||
|
623 | assert_select 'input[type=checkbox][value=?]:not([checked])', field2.id.to_s | |||
|
624 | end | |||
|
625 | end | |||
|
626 | ||||
613 | def test_post_copy_should_copy_requested_items |
|
627 | def test_post_copy_should_copy_requested_items | |
614 | @request.session[:user_id] = 1 # admin |
|
628 | @request.session[:user_id] = 1 # admin | |
615 | CustomField.delete_all |
|
629 | CustomField.delete_all |
General Comments 0
You need to be logged in to leave comments.
Login now