change_me_to_usable_in_edit_and_update_v2.patch

Mizuki ISHIKAWA, 2018-06-25 02:43

Download (1.95 KB)

View differences:

app/controllers/issues_controller.rb
463 463
    @issue.init_journal(User.current)
464 464

  
465 465
    issue_attributes = params[:issue]
466
    issue_attributes[:assigned_to_id] = User.current.id if issue_attributes && issue_attributes[:assigned_to_id] == 'me'
466 467
    if issue_attributes && params[:conflict_resolution]
467 468
      case params[:conflict_resolution]
468 469
      when 'overwrite'
test/functional/issues_controller_test.rb
4446 4446
    end
4447 4447
  end
4448 4448

  
4449
  def test_get_edit_with_me_assigned_to_id
4450
    @request.session[:user_id] = 2
4451
    get :edit, :params => {
4452
      :id => 1,
4453
      :issue => { :assigned_to_id => 'me' }
4454
    }
4455
    assert_response :success
4456
    assert_select 'select[name=?]', 'issue[assigned_to_id]' do
4457
      assert_select 'option[value="2"][selected=selected]'
4458
    end
4459
  end
4460

  
4449 4461
  def test_update_form_for_existing_issue
4450 4462
    @request.session[:user_id] = 2
4451 4463
    patch :edit, :params => {
......
5261 5273
    assert_equal 'Original subject', issue.reload.subject
5262 5274
  end
5263 5275

  
5276
  def test_update_with_me_assigned_to_id
5277
    @request.session[:user_id] = 2
5278
    issue = Issue.find(1)
5279
    assert_not_equal 2, issue.assigned_to_id
5280
    put :update, :params => {
5281
        :id => issue.id,
5282
        :issue => {
5283
          :assigned_to_id => 'me'
5284
        }
5285
      }
5286
    assert_response 302
5287
    assert_equal 2, issue.reload.assigned_to_id
5288
  end
5289

  
5264 5290
  def test_get_bulk_edit
5265 5291
    @request.session[:user_id] = 2
5266 5292
    get :bulk_edit, :params => {