@@ -512,11 +512,17 class Project < ActiveRecord::Base | |||||
512 | # Returns a scope of all custom fields enabled for project issues |
|
512 | # Returns a scope of all custom fields enabled for project issues | |
513 | # (explicitly associated custom fields and custom fields enabled for all projects) |
|
513 | # (explicitly associated custom fields and custom fields enabled for all projects) | |
514 | def all_issue_custom_fields |
|
514 | def all_issue_custom_fields | |
515 | @all_issue_custom_fields ||= IssueCustomField. |
|
515 | if new_record? | |
516 | sorted. |
|
516 | @all_issue_custom_fields ||= IssueCustomField. | |
517 | where("is_for_all = ? OR id IN (SELECT DISTINCT cfp.custom_field_id" + |
|
517 | sorted. | |
518 | " FROM #{table_name_prefix}custom_fields_projects#{table_name_suffix} cfp" + |
|
518 | where("is_for_all = ? OR id IN (?)", true, issue_custom_field_ids) | |
519 | " WHERE cfp.project_id = ?)", true, id) |
|
519 | else | |
|
520 | @all_issue_custom_fields ||= IssueCustomField. | |||
|
521 | sorted. | |||
|
522 | where("is_for_all = ? OR id IN (SELECT DISTINCT cfp.custom_field_id" + | |||
|
523 | " FROM #{table_name_prefix}custom_fields_projects#{table_name_suffix} cfp" + | |||
|
524 | " WHERE cfp.project_id = ?)", true, id) | |||
|
525 | end | |||
520 | end |
|
526 | end | |
521 |
|
527 | |||
522 | def project |
|
528 | 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