diff --git a/app/controllers/projects/comments_controller.rb b/app/controllers/projects/comments_controller.rb index c925b33b4..e1f7f1073 100644 --- a/app/controllers/projects/comments_controller.rb +++ b/app/controllers/projects/comments_controller.rb @@ -41,11 +41,7 @@ class Projects::CommentsController < Projects::BaseController end def new_line - @path = if @commentable.class == Issue - project_issue_comments_path(@project, @commentable) - elsif @commentable.class == Grit::Commit - project_commit_comments_path(@project, @commentable) - end + @path = view_context.project_commentable_comments_path(@project, @commentable) render :layout => false end diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index c05cd3339..204348df6 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -1,23 +1,29 @@ # -*- encoding : utf-8 -*- module CommentsHelper def project_commentable_comment_path(project, commentable, comment) - case - when Comment.issue_comment?(commentable.class) + if Comment.issue_comment?(commentable.class) project_issue_comment_path(project, commentable, comment) - when Comment.commit_comment?(commentable.class) + elsif Comment.commit_comment?(commentable.class) project_commit_comment_path(project, commentable, comment) end end def project_commentable_path(project, commentable) - case - when Comment.issue_comment?(commentable.class) + if Comment.issue_comment?(commentable.class) polymorphic_path [project, commentable.pull_request ? commentable.pull_request : commentable] - when Comment.commit_comment?(commentable.class) + elsif Comment.commit_comment?(commentable.class) commit_path project, commentable.id end end + def project_commentable_comments_path(project, commentable) + if commentable.class == Issue + project_issue_comments_path(@project, @commentable) + elsif commentable.class == Grit::Commit + project_commit_comments_path(@project, @commentable) + end + end + def comment_anchor c "#{(c.data.present? && c.actual_inline_comment?(@diff)) ? 'diff-' : ''}comment#{c.id}" end