diff --git a/lib/issue_wiki_journal/wiki_changeset.rb b/lib/issue_wiki_journal/wiki_changeset.rb index 8c9c4f2..0011c99 100644 --- a/lib/issue_wiki_journal/wiki_changeset.rb +++ b/lib/issue_wiki_journal/wiki_changeset.rb @@ -131,7 +131,7 @@ def message(fix = false) version: version, only_path: true end @message ||= l('issue_wiki_journal.text_status_changed_by_wiki_changeset', - page: @page.title, + page: "#{@project.identifier}:#{@page.title}", version: %Q!"#{version}":#{version_path}!) + ":\n\n" + "bq. #{comments}" end diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index a118ebd..eec7158 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -34,8 +34,12 @@ class IssueWikiJournal::WikiControllerTest < ActionController::TestCase def setup @controller = ::WikiController.new @request.session[:user_id] = 2 + @project = Project.find(1) + # Set to 1 status to be applied by the fixing keywords Setting.commit_fix_status_id = 5 + # Allow issues of all the other projects to be referenced and fixed + Setting.commit_cross_project_ref = 1 end @@ -45,7 +49,8 @@ def setup [:en, :ja].each_with_index do |locale, i| ::I18n.locale = locale update_wiki_page with: 'refs #1 message', as_version: i - assert_equal journals.last.notes, changeset_message('New_Page', 1 + i, 'refs #1 message'), + assert_equal journals.last.notes, + changeset_message('New_Page', 'refs #1 message', version: i + 1), "Journal message test with #{locale} locale" end end @@ -83,6 +88,22 @@ def setup end end + test 'Journalizing: when commit_cross_project_ref setting is OFF' do + Setting.commit_cross_project_ref = 0 + + assert_no_difference 'Journal.count' do + create_wiki_page with: 'refs #1 message', in_project: Project.find(2) + end + end + + test 'Journalizing: when commit_cross_project_ref setting is ON' do + Setting.commit_cross_project_ref = 1 + + assert_difference 'Journal.count' do + create_wiki_page with: 'refs #1 message', in_project: Project.find(2) + end + end + test 'Status changes: with comment "fixes #1 message"' do create_wiki_page with: 'fixes #1 message' assert Issue.find(1).closed? @@ -114,29 +135,31 @@ def setup end assert_equal Issue.find(1).journals.last.notes, - changeset_message('New_Page', 1, 'fixes #1, refs #2 message') + changeset_message('New_Page', 'fixes #1, refs #2 message') assert Issue.find(1).closed? assert_equal Issue.find(2).journals.last.notes, - changeset_message('New_Page', 1, 'fixes #1, refs #2 message') + changeset_message('New_Page', 'fixes #1, refs #2 message') refute Issue.find(2).closed? end private def update_wiki_page(args = {}) - comment, version = args.values_at(:with, :as_version) + comment, version, project = args.values_at(:with, :as_version, :in_project) - put :update, project_id: 1, id: 'New Page', + put :update, project_id: project || @project.id, id: 'New Page', content: {comments: comment, text: "h1. New Page\n\n Version #{version || 0}", version: version || 0} end alias_method :create_wiki_page, :update_wiki_page - def changeset_message(page, version, message) + def changeset_message(page, message, options = {}) + version, project = {project: @project, version: 1}.merge(options).values_at(:version, :project) + ::I18n.t('issue_wiki_journal.text_status_changed_by_wiki_changeset', - page: page, + page: "#{project.identifier}:#{page}", version: %Q!"#{version}":#{version_path(page, version)}!) + ":\n\nbq. #{message}" end