From b118aa796b63ee873cf734693e9d8dde5d0a06bc Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Fri, 12 Jul 2013 19:25:23 -0300 Subject: [PATCH] [comments-refactor-review] Small fixes on ApproveComment task and its tests --- app/models/approve_comment.rb | 12 +++++------- test/unit/approve_comment_test.rb | 2 -- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/models/approve_comment.rb b/app/models/approve_comment.rb index c45e761..6e7e77f 100644 --- a/app/models/approve_comment.rb +++ b/app/models/approve_comment.rb @@ -1,13 +1,12 @@ class ApproveComment < Task validates_presence_of :target_id - settings_items :comment_attributes, :closing_statment + settings_items :comment_attributes, :closing_statment - validates_presence_of :comment_attributes + validates_presence_of :comment_attributes def comment - @comment ||= Comment.new(JSON.parse(self.comment_attributes)) unless self.comment_attributes.nil? - @comment + @comment ||= Comment.new(JSON.parse(self.comment_attributes)) unless self.comment_attributes.nil? end def requestor_name @@ -22,7 +21,6 @@ class ApproveComment < Task article ? article.name : _("Article removed.") end - def perform comment.save! end @@ -33,8 +31,8 @@ class ApproveComment < Task def icon result = {:type => :defined_image, :src => '/images/icons-app/article-minor.png'} - result.merge({:url => article.url}) if article - return result + result.merge!({:url => article.url}) if article + result end def linked_subject diff --git a/test/unit/approve_comment_test.rb b/test/unit/approve_comment_test.rb index 48f9dab..29d8353 100644 --- a/test/unit/approve_comment_test.rb +++ b/test/unit/approve_comment_test.rb @@ -144,8 +144,6 @@ class ApproveCommentTest < ActiveSupport::TestCase end should 'default decision be skip if there is an article associated to task' do -# a = ApproveComment.create!(:name => 'test name', :target => @community, :comment_attributes => @comment.attributes.to_json, :requestor => @profile) -#FIXME see if article= method will survive a = ApproveComment.new(:comment_attributes => @comment.attributes.to_json) assert 'skip', a.default_decision end -- libgit2 0.21.2