diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index 7a477a0b14..3a3248c908 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -66,7 +66,11 @@ class JournalsController < ApplicationController if @journal user = @journal.user text = @journal.notes - @content = +"#{ll(Setting.default_language, :text_user_wrote_in, {:value => user, :link => "#note-#{params[:journal_indice]}"})}\n> " + indice = params[:journal_indice] + if indice.blank? + indice = @journal.issue.visible_journals_with_index.find{|j| j.id == @journal.id}.indice + end + @content = +"#{ll(Setting.default_language, :text_user_wrote_in, {:value => user, :link => "#note-#{indice}"})}\n> " else user = @issue.author text = @issue.description diff --git a/test/functional/journals_controller_test.rb b/test/functional/journals_controller_test.rb index 0acf2d9665..9ac4580a97 100644 --- a/test/functional/journals_controller_test.rb +++ b/test/functional/journals_controller_test.rb @@ -190,6 +190,23 @@ class JournalsControllerTest < Redmine::ControllerTest assert_include '> A comment with a private version', response.body end + def test_reply_to_note_without_journal_indice_params + @request.session[:user_id] = 2 + # Verify that the :indice method has been called + Journal.any_instance.expects(:indice).returns(2).at_least_once + get :new, :params => { + :id => 6, + :journal_id => 4, + :journal_indice => nil + }, + :xhr => true + + assert_response :success + assert_equal 'text/javascript', response.content_type + assert_include 'Redmine Admin wrote in #note-2:', response.body + assert_include '> A comment with a private version', response.body + end + def test_reply_to_private_note_should_fail_without_permission journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Privates notes', :private_notes => true) @request.session[:user_id] = 2