diff options
-rw-r--r-- | app/controllers/messages_controller.rb | 19 | ||||
-rw-r--r-- | app/views/messages/quote.js.erb | 6 | ||||
-rw-r--r-- | test/functional/messages_controller_test.rb | 5 |
3 files changed, 15 insertions, 15 deletions
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index cc53c0d78..6b154a81c 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -105,20 +105,11 @@ class MessagesController < ApplicationController end def quote - user = @message.author - text = @message.content - subject = @message.subject.gsub('"', '\"') - subject = "RE: #{subject}" unless subject.starts_with?('RE:') - content = "#{ll(Setting.default_language, :text_user_wrote, user)}\\n> " - content << text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub('"', '\"').gsub(/(\r?\n|\r\n?)/, "\\n> ") + "\\n\\n" - render(:update) { |page| - page << "$('message_subject').value = \"#{subject}\";" - page.<< "$('message_content').value = \"#{content}\";" - page.show 'reply' - page << "Form.Element.focus('message_content');" - page << "Element.scrollTo('reply');" - page << "$('message_content').scrollTop = $('message_content').scrollHeight - $('message_content').clientHeight;" - } + @subject = @message.subject + @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') + + @content = "#{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> " + @content << @message.content.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" end def preview diff --git a/app/views/messages/quote.js.erb b/app/views/messages/quote.js.erb new file mode 100644 index 000000000..706aa3a72 --- /dev/null +++ b/app/views/messages/quote.js.erb @@ -0,0 +1,6 @@ +$('message_subject').value = "<%= raw escape_javascript(@subject) %>"; +$('message_content').value = "<%= raw escape_javascript(@content) %>"; +Element.show('reply'); +Form.Element.focus('message_content'); +Element.scrollTo('reply'); +$('message_content').scrollTop = $('message_content').scrollHeight - $('message_content').clientHeight; diff --git a/test/functional/messages_controller_test.rb b/test/functional/messages_controller_test.rb index 294f87035..4bf8ff90f 100644 --- a/test/functional/messages_controller_test.rb +++ b/test/functional/messages_controller_test.rb @@ -186,7 +186,10 @@ class MessagesControllerTest < ActionController::TestCase @request.session[:user_id] = 2 xhr :get, :quote, :board_id => 1, :id => 3 assert_response :success - assert_select_rjs :show, 'reply' + assert_equal 'text/javascript', response.content_type + assert_template 'quote' + assert_include 'RE: First post', response.body + assert_include '> An other reply', response.body end def test_preview_new |