From 54f462f408911cec85421c523853a08f3b0e1457 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 19 Oct 2012 15:50:15 +0600 Subject: [PATCH] [refs #579] small refactoring --- app/helpers/comments_helper.rb | 4 ++-- app/helpers/diff_helper.rb | 4 ++-- app/models/comment.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index 204348df6..fbc6fb905 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -17,9 +17,9 @@ module CommentsHelper end def project_commentable_comments_path(project, commentable) - if commentable.class == Issue + if commentable.is_a? Issue project_issue_comments_path(@project, @commentable) - elsif commentable.class == Grit::Commit + elsif commentable.is_a? Grit::Commit project_commit_comments_path(@project, @commentable) end end diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index 7f7bca252..d9f41984f 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -258,9 +258,9 @@ module DiffHelper def new_comment_path hash = {:path => @filepath, :line => @num_line} - if @commentable.class == Issue + if @commentable.is_a? Issue project_new_line_pull_comment_path(@project, @commentable, hash.merge({:in_reply => @add_reply_id})) - elsif @commentable.class == Grit::Commit + elsif @commentable.is_a? Grit::Commit new_line_commit_comment_path(@project, @commentable, hash) end end diff --git a/app/models/comment.rb b/app/models/comment.rb index 1f8884273..a0358a70a 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -84,7 +84,7 @@ class Comment < ActiveRecord::Base end def pull_comment? - return true if commentable.class == Issue && commentable.pull_request.present? + return true if commentable.is_a?(Issue) && commentable.pull_request.present? end def set_additional_data params @@ -94,7 +94,7 @@ class Comment < ActiveRecord::Base return true end self.data = {:path => params[:path], :line => params[:line]} - if commentable.class == Issue && pull = commentable.pull_request + if commentable.is_a?(Issue) && pull = commentable.pull_request diff_path = pull.diff.select {|d| d.a_path == params[:path]} return false unless actual_inline_comment?(pull.diff, true)