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 1 class ApproveComment < Task
2 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 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 10 end
12 11  
13 12 def requestor_name
... ... @@ -22,7 +21,6 @@ class ApproveComment &lt; Task
22 21 article ? article.name : _("Article removed.")
23 22 end
24 23  
25   -
26 24 def perform
27 25 comment.save!
28 26 end
... ... @@ -33,8 +31,8 @@ class ApproveComment &lt; Task
33 31  
34 32 def icon
35 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 36 end
39 37  
40 38 def linked_subject
... ...
test/unit/approve_comment_test.rb
... ... @@ -144,8 +144,6 @@ class ApproveCommentTest &lt; ActiveSupport::TestCase
144 144 end
145 145  
146 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 147 a = ApproveComment.new(:comment_attributes => @comment.attributes.to_json)
150 148 assert 'skip', a.default_decision
151 149 end
... ...