3.3-stable.diff

Marcin Świątkiewicz, 2017-01-18 16:09

Download (12.3 KB)

View differences:

app/controllers/issues_controller.rb
282 282
      @issues.reject! {|issue| @issues.detect {|other| issue.is_descendant_of?(other)}}
283 283
    end
284 284

  
285
    @assignee_to_author = true if attributes['assigned_to_id'].present? && attributes['assigned_to_id'] == 'author'
286

  
285 287
    @issues.each do |orig_issue|
286 288
      orig_issue.reload
287 289
      if @copy
......
294 296
        issue = orig_issue
295 297
      end
296 298
      journal = issue.init_journal(User.current, params[:notes])
299
      if @assignee_to_author
300
        attributes['assigned_to_id'] = issue.author_id
301
      end
297 302
      issue.safe_attributes = attributes
298 303
      call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
299 304
      if issue.save
......
369 374
  # Overrides Redmine::MenuManager::MenuController::ClassMethods for
370 375
  # when the "New issue" tab is enabled
371 376
  def current_menu_item
372
    if Setting.new_item_menu_tab == '1' && [:new, :create].include?(action_name.to_sym) 
377
    if Setting.new_item_menu_tab == '1' && [:new, :create].include?(action_name.to_sym)
373 378
      :new_issue
374 379
    else
375 380
      super
test/functional/issues_controller_test.rb
603 603
      str_big5  = "\xa4@\xa4\xeb".force_encoding('Big5')
604 604
      issue = Issue.generate!(:subject => str_utf8)
605 605

  
606
      get :index, :project_id => 1, 
607
                  :f => ['subject'], 
606
      get :index, :project_id => 1,
607
                  :f => ['subject'],
608 608
                  :op => '=', :values => [str_utf8],
609 609
                  :format => 'csv'
610 610
      assert_equal 'text/csv; header=present', @response.content_type
......
622 622
      str_utf8  = "\xe4\xbb\xa5\xe5\x86\x85".force_encoding('UTF-8')
623 623
      issue = Issue.generate!(:subject => str_utf8)
624 624

  
625
      get :index, :project_id => 1, 
626
                  :f => ['subject'], 
625
      get :index, :project_id => 1,
626
                  :f => ['subject'],
627 627
                  :op => '=', :values => [str_utf8],
628 628
                  :c => ['status', 'subject'],
629 629
                  :format => 'csv',
......
645 645
      str1  = "test_index_csv_tw"
646 646
      issue = Issue.generate!(:subject => str1, :estimated_hours => '1234.5')
647 647

  
648
      get :index, :project_id => 1, 
649
                  :f => ['subject'], 
648
      get :index, :project_id => 1,
649
                  :f => ['subject'],
650 650
                  :op => '=', :values => [str1],
651 651
                  :c => ['estimated_hours', 'subject'],
652 652
                  :format => 'csv',
......
662 662
      str1  = "test_index_csv_fr"
663 663
      issue = Issue.generate!(:subject => str1, :estimated_hours => '1234.5')
664 664

  
665
      get :index, :project_id => 1, 
666
                  :f => ['subject'], 
665
      get :index, :project_id => 1,
666
                  :f => ['subject'],
667 667
                  :op => '=', :values => [str1],
668 668
                  :c => ['estimated_hours', 'subject'],
669 669
                  :format => 'csv',
......
740 740
    Setting.issue_list_default_columns = %w(subject author)
741 741
    get :index, :sort => 'tracker'
742 742
  end
743
  
743

  
744 744
  def test_index_sort_by_assigned_to
745 745
    get :index, :sort => 'assigned_to'
746 746
    assert_response :success
......
748 748
    assert_equal assignees.sort, assignees
749 749
    assert_select 'table.issues.sort-by-assigned-to.sort-asc'
750 750
  end
751
  
751

  
752 752
  def test_index_sort_by_assigned_to_desc
753 753
    get :index, :sort => 'assigned_to:desc'
754 754
    assert_response :success
......
756 756
    assert_equal assignees.sort.reverse, assignees
757 757
    assert_select 'table.issues.sort-by-assigned-to.sort-desc'
758 758
  end
759
  
759

  
760 760
  def test_index_group_by_assigned_to
761 761
    get :index, :group_by => 'assigned_to', :sort => 'priority'
762 762
    assert_response :success
763 763
  end
764
  
764

  
765 765
  def test_index_sort_by_author
766 766
    get :index, :sort => 'author'
767 767
    assert_response :success
768 768
    authors = assigns(:issues).collect(&:author)
769 769
    assert_equal authors.sort, authors
770 770
  end
771
  
771

  
772 772
  def test_index_sort_by_author_desc
773 773
    get :index, :sort => 'author:desc'
774 774
    assert_response :success
775 775
    authors = assigns(:issues).collect(&:author)
776 776
    assert_equal authors.sort.reverse, authors
777 777
  end
778
  
778

  
779 779
  def test_index_group_by_author
780 780
    get :index, :group_by => 'author', :sort => 'priority'
781 781
    assert_response :success
782 782
  end
783
  
783

  
784 784
  def test_index_sort_by_spent_hours
785 785
    get :index, :sort => 'spent_hours:desc'
786 786
    assert_response :success
787 787
    hours = assigns(:issues).collect(&:spent_hours)
788 788
    assert_equal hours.sort.reverse, hours
789 789
  end
790
  
790

  
791 791
  def test_index_sort_by_total_spent_hours
792 792
    get :index, :sort => 'total_spent_hours:desc'
793 793
    assert_response :success
794 794
    hours = assigns(:issues).collect(&:total_spent_hours)
795 795
    assert_equal hours.sort.reverse, hours
796 796
  end
797
  
797

  
798 798
  def test_index_sort_by_total_estimated_hours
799 799
    get :index, :sort => 'total_estimated_hours:desc'
800 800
    assert_response :success
......
1141 1141
  def test_index_should_not_include_new_issue_tab_for_project_without_trackers
1142 1142
    with_settings :new_item_menu_tab => '1' do
1143 1143
      Project.find(1).trackers.clear
1144
  
1144

  
1145 1145
      @request.session[:user_id] = 2
1146 1146
      get :index, :project_id => 1
1147 1147
      assert_select '#main-menu a.new-issue', 0
......
1153 1153
      role = Role.find(1)
1154 1154
      role.remove_permission! :add_issues
1155 1155
      role.add_permission! :copy_issues
1156
  
1156

  
1157 1157
      @request.session[:user_id] = 2
1158 1158
      get :index, :project_id => 1
1159 1159
      assert_select '#main-menu a.new-issue', 0
......
1439 1439

  
1440 1440
  def test_show_should_display_prev_next_links_with_query_and_sort_on_association
1441 1441
    @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => nil}
1442
    
1442

  
1443 1443
    %w(project tracker status priority author assigned_to category fixed_version).each do |assoc_sort|
1444 1444
      @request.session['issues_index_sort'] = assoc_sort
1445 1445

  
......
1684 1684
  end
1685 1685

  
1686 1686
  def test_show_export_to_pdf
1687
    issue = Issue.find(3) 
1687
    issue = Issue.find(3)
1688 1688
    assert issue.relations.select{|r| r.other_issue(issue).visible?}.present?
1689 1689
    get :show, :id => 3, :format => 'pdf'
1690 1690
    assert_response :success
......
2152 2152
    get :new, :project_id => 'invalid'
2153 2153
    assert_response 404
2154 2154
  end
2155
 
2155

  
2156 2156
  def test_new_with_parent_id_should_only_propose_valid_trackers
2157 2157
    @request.session[:user_id] = 2
2158 2158
    t = Tracker.find(3)
......
2704 2704
                              :custom_field_values => {'2' => 'Value for field 2'}}
2705 2705
      end
2706 2706
      assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
2707
  
2707

  
2708 2708
      assert_equal 1, ActionMailer::Base.deliveries.size
2709 2709
    end
2710 2710
  end
......
2874 2874
    get :new, :project_id => 1
2875 2875
    assert_response :success
2876 2876
    assert_template 'new'
2877
    
2877

  
2878 2878
    issue = assigns(:issue)
2879 2879
    assert_not_nil issue.default_status
2880 2880

  
......
3297 3297
  def test_get_edit_should_display_the_time_entry_form_with_log_time_permission
3298 3298
    @request.session[:user_id] = 2
3299 3299
    Role.find_by_name('Manager').update_attribute :permissions, [:view_issues, :edit_issues, :log_time]
3300
    
3300

  
3301 3301
    get :edit, :id => 1
3302 3302
    assert_select 'input[name=?]', 'time_entry[hours]'
3303 3303
  end
......
3305 3305
  def test_get_edit_should_not_display_the_time_entry_form_without_log_time_permission
3306 3306
    @request.session[:user_id] = 2
3307 3307
    Role.find_by_name('Manager').remove_permission! :log_time
3308
    
3308

  
3309 3309
    get :edit, :id => 1
3310 3310
    assert_select 'input[name=?]', 'time_entry[hours]', 0
3311 3311
  end
......
3926 3926
    assert_response :redirect
3927 3927
    assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
3928 3928
  end
3929
 
3929

  
3930 3930
  def test_put_update_should_redirect_with_previous_and_next_issue_ids_params
3931 3931
    @request.session[:user_id] = 2
3932 3932

  
......
3981 3981

  
3982 3982
      assert_select 'select[name=?]', 'issue[project_id]'
3983 3983
      assert_select 'input[name=?]', 'issue[parent_issue_id]'
3984
  
3984

  
3985 3985
      # Project specific custom field, date type
3986 3986
      field = CustomField.find(9)
3987 3987
      assert !field.is_for_all?
3988 3988
      assert_equal 'date', field.field_format
3989 3989
      assert_select 'input[name=?]', 'issue[custom_field_values][9]'
3990
  
3990

  
3991 3991
      # System wide custom field
3992 3992
      assert CustomField.find(1).is_for_all?
3993 3993
      assert_select 'select[name=?]', 'issue[custom_field_values][1]'
3994
  
3994

  
3995 3995
      # Be sure we don't display inactive IssuePriorities
3996 3996
      assert ! IssuePriority.find(15).active?
3997 3997
      assert_select 'select[name=?]', 'issue[priority_id]' do
......
4155 4155
                                       :issue => {:priority_id => '',
4156 4156
                                                  :assigned_to_id => group.id,
4157 4157
                                                  :custom_field_values => {'2' => ''}}
4158
  
4158

  
4159 4159
      assert_response 302
4160 4160
      assert_equal [group, group], Issue.where(:id => [1, 2]).collect {|i| i.assigned_to}
4161 4161
    end
......
4213 4213
    end
4214 4214
  end
4215 4215

  
4216
  def test_bulk_update_with_author_change
4217
    @request.session[:user_id] = 2
4218
    Issue.where(id: [1, 2]).each {|i| i.update_attributes(assigned_to_id: 8)}
4219
    post :bulk_update, :ids => [1, 2], :issue => {:project_id => '2', assigned_to_id: 'author'}
4220
    Issue.where(id: [1, 2]).each {|i| assert_equal 2, i.assigned_to_id}
4221
  end
4222

  
4223
  def test_bulk_update_with_different_author
4224
    @request.session[:user_id] = 2
4225
    ids = Project.find(2).issues.map(&:id)
4226
    post :bulk_update, :ids => ids, :issue => {:project_id => '2', assigned_to_id: 'author'}
4227
    Project.find(2).issues.each {|i| assert_equal i.author_id, i.assigned_to_id}
4228
  end
4229

  
4216 4230
  def test_bulk_update_project
4217 4231
    @request.session[:user_id] = 2
4218 4232
    post :bulk_update, :ids => [1, 2], :issue => {:project_id => '2'}
......
4468 4482
      assert_select 'option[value="2"]'
4469 4483
    end
4470 4484
  end
4471
  
4485

  
4472 4486
  def test_bulk_copy_to_another_project
4473 4487
    @request.session[:user_id] = 2
4474 4488
    assert_difference 'Issue.count', 2 do
......
4521 4535
                    :assigned_to_id => 3)
4522 4536
    ]
4523 4537
    assert_difference 'Issue.count', issues.size do
4524
      post :bulk_update, :ids => issues.map(&:id), :copy => '1', 
4538
      post :bulk_update, :ids => issues.map(&:id), :copy => '1',
4525 4539
           :issue => {
4526 4540
             :project_id => '', :tracker_id => '', :assigned_to_id => '',
4527 4541
             :status_id => '', :start_date => '', :due_date => ''
......
4553 4567
    @request.session[:user_id] = 2
4554 4568
    assert_difference 'Issue.count', 2 do
4555 4569
      assert_no_difference 'Project.find(1).issues.count' do
4556
        post :bulk_update, :ids => [1, 2], :copy => '1', 
4570
        post :bulk_update, :ids => [1, 2], :copy => '1',
4557 4571
             :issue => {
4558 4572
               :project_id => '2', :tracker_id => '', :assigned_to_id => '2',
4559 4573
               :status_id => '1', :start_date => '2009-12-01', :due_date => '2009-12-31'