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