Commit b118aa796b63ee873cf734693e9d8dde5d0a06bc

Authored by Rodrigo Souto
1 parent b5af58d1

[comments-refactor-review] Small fixes on ApproveComment task and its tests

app/models/approve_comment.rb
1 class ApproveComment < Task 1 class ApproveComment < Task
2 validates_presence_of :target_id 2 validates_presence_of :target_id
3 3
4 - settings_items :comment_attributes, :closing_statment 4 + settings_items :comment_attributes, :closing_statment
5 5
6 - validates_presence_of :comment_attributes 6 + validates_presence_of :comment_attributes
7 7
8 def comment 8 def comment
9 - @comment ||= Comment.new(JSON.parse(self.comment_attributes)) unless self.comment_attributes.nil?  
10 - @comment 9 + @comment ||= Comment.new(JSON.parse(self.comment_attributes)) unless self.comment_attributes.nil?
11 end 10 end
12 11
13 def requestor_name 12 def requestor_name
@@ -22,7 +21,6 @@ class ApproveComment &lt; Task @@ -22,7 +21,6 @@ class ApproveComment &lt; Task
22 article ? article.name : _("Article removed.") 21 article ? article.name : _("Article removed.")
23 end 22 end
24 23
25 -  
26 def perform 24 def perform
27 comment.save! 25 comment.save!
28 end 26 end
@@ -33,8 +31,8 @@ class ApproveComment &lt; Task @@ -33,8 +31,8 @@ class ApproveComment &lt; Task
33 31
34 def icon 32 def icon
35 result = {:type => :defined_image, :src => '/images/icons-app/article-minor.png'} 33 result = {:type => :defined_image, :src => '/images/icons-app/article-minor.png'}
36 - result.merge({:url => article.url}) if article  
37 - return result 34 + result.merge!({:url => article.url}) if article
  35 + result
38 end 36 end
39 37
40 def linked_subject 38 def linked_subject
test/unit/approve_comment_test.rb
@@ -144,8 +144,6 @@ class ApproveCommentTest &lt; ActiveSupport::TestCase @@ -144,8 +144,6 @@ class ApproveCommentTest &lt; ActiveSupport::TestCase
144 end 144 end
145 145
146 should 'default decision be skip if there is an article associated to task' do 146 should 'default decision be skip if there is an article associated to task' do
147 -# a = ApproveComment.create!(:name => 'test name', :target => @community, :comment_attributes => @comment.attributes.to_json, :requestor => @profile)  
148 -#FIXME see if article= method will survive  
149 a = ApproveComment.new(:comment_attributes => @comment.attributes.to_json) 147 a = ApproveComment.new(:comment_attributes => @comment.attributes.to_json)
150 assert 'skip', a.default_decision 148 assert 'skip', a.default_decision
151 end 149 end