Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

Commit

Permalink
fixes #5 Bloken link to Wiki page
Browse files Browse the repository at this point in the history
  • Loading branch information
hidaka committed Nov 12, 2013
1 parent 1f5bb5f commit 5ca44da
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/issue_wiki_journal/wiki_changeset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 30 additions & 7 deletions test/functional/wiki_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5ca44da

Please sign in to comment.