Commit 56915809caf11bd4f53e27270aad12c8cff2eed1

Authored by Rodrigo Souto
1 parent c1cd1797

Fixing approve comment json lib call

(ActionItem2737)
app/models/approve_comment.rb
@@ -6,7 +6,7 @@ class ApproveComment < Task @@ -6,7 +6,7 @@ class ApproveComment < Task
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? 9 + @comment ||= Comment.new(ActiveSupport::JSON.decode(self.comment_attributes)) unless self.comment_attributes.nil?
10 end 10 end
11 11
12 def requestor_name 12 def requestor_name
test/functional/comment_controller_test.rb
@@ -150,7 +150,7 @@ class CommentControllerTest < ActionController::TestCase @@ -150,7 +150,7 @@ class CommentControllerTest < ActionController::TestCase
150 login_as @profile.identifier 150 login_as @profile.identifier
151 page = profile.articles.create!(:name => 'myarticle', :body => 'the body of the text') 151 page = profile.articles.create!(:name => 'myarticle', :body => 'the body of the text')
152 xhr :post, :create, :profile => @profile.identifier, :id => page.id, :comment => { :title => '', :body => '' }, :confirm => 'true' 152 xhr :post, :create, :profile => @profile.identifier, :id => page.id, :comment => { :title => '', :body => '' }, :confirm => 'true'
153 - response = JSON.parse @response.body 153 + response = ActiveSupport::JSON.decode @response.body
154 assert_match /errorExplanation/, response["html"] 154 assert_match /errorExplanation/, response["html"]
155 end 155 end
156 156
@@ -507,7 +507,7 @@ class CommentControllerTest < ActionController::TestCase @@ -507,7 +507,7 @@ class CommentControllerTest < ActionController::TestCase
507 comment = fast_create(Comment, :body => 'Original comment', :source_id => page.id, :source_type => 'Article', :author_id => profile) 507 comment = fast_create(Comment, :body => 'Original comment', :source_id => page.id, :source_type => 'Article', :author_id => profile)
508 508
509 xhr :post, :update, :id => comment.id, :profile => profile.identifier, :comment => { :body => 'Comment edited' } 509 xhr :post, :update, :id => comment.id, :profile => profile.identifier, :comment => { :body => 'Comment edited' }
510 - assert JSON.parse(@response.body)["ok"], "attribute ok expected to be true" 510 + assert ActiveSupport::JSON.decode(@response.body)["ok"], "attribute ok expected to be true"
511 assert_equal 'Comment edited', Comment.find(comment.id).body 511 assert_equal 'Comment edited', Comment.find(comment.id).body
512 end 512 end
513 513