note-11-diff-and-test.patch

Mizuki ISHIKAWA, 2019-06-19 11:14

Download (2.02 KB)

View differences:

app/controllers/journals_controller.rb
66 66
    if @journal
67 67
      user = @journal.user
68 68
      text = @journal.notes
69
      @content = +"#{ll(Setting.default_language, :text_user_wrote_in, {:value => user, :link => "#note-#{params[:journal_indice]}"})}\n> "
69
      indice = params[:journal_indice]
70
      if indice.blank?
71
        indice = @journal.issue.visible_journals_with_index.find{|j| j.id == @journal.id}.indice
72
      end
73
      @content = +"#{ll(Setting.default_language, :text_user_wrote_in, {:value => user, :link => "#note-#{indice}"})}\n> "
70 74
    else
71 75
      user = @issue.author
72 76
      text = @issue.description
test/functional/journals_controller_test.rb
190 190
    assert_include '> A comment with a private version', response.body
191 191
  end
192 192

  
193
  def test_reply_to_note_without_journal_indice_params
194
    @request.session[:user_id] = 2
195
    # Verify that the :indice method has been called
196
    Journal.any_instance.expects(:indice).returns(2).at_least_once
197
    get :new, :params => {
198
        :id => 6,
199
        :journal_id => 4,
200
        :journal_indice => nil
201
      },
202
      :xhr => true
203

  
204
    assert_response :success
205
    assert_equal 'text/javascript', response.content_type
206
    assert_include 'Redmine Admin wrote in #note-2:', response.body
207
    assert_include '> A comment with a private version', response.body
208
  end
209

  
193 210
  def test_reply_to_private_note_should_fail_without_permission
194 211
    journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Privates notes', :private_notes => true)
195 212
    @request.session[:user_id] = 2