[Git][noosfero/noosfero][master] 5 commits: export comments of discussion correctly
Leandro Nunes
gitlab at mg.gitlab.com
Tue Oct 10 13:26:00 BRT 2017
Leandro Nunes pushed to branch master at Noosfero / noosfero
Commits:
30292d15 by Leandro Nunes dos Santos at 2017-10-09T14:42:28-03:00
export comments of discussion correctly
- - - - -
0a4e33c8 by Leandro Nunes dos Santos at 2017-10-09T15:39:51-03:00
fix unit test
- - - - -
9795cdf9 by Leandro Nunes dos Santos at 2017-10-09T17:12:54-03:00
fix unit api test
- - - - -
332740c5 by Leandro Nunes dos Santos at 2017-10-10T12:04:54-03:00
fix unit tests
- - - - -
cb31e59f by Leandro Nunes at 2017-10-10T16:25:39+00:00
Merge branch 'export-comment-of-discussion' into 'master'
export comments of discussion correctly
See merge request noosfero/noosfero!1328
- - - - -
5 changed files:
- plugins/comment_paragraph/lib/comment_paragraph_plugin/api.rb
- plugins/comment_paragraph/lib/comment_paragraph_plugin/comments_report.rb
- plugins/comment_paragraph/test/functional/comment_paragraph_plugin_profile_controller_test.rb
- plugins/comment_paragraph/test/unit/api_test.rb
- plugins/comment_paragraph/test/unit/comments_report_test.rb
Changes:
=====================================
plugins/comment_paragraph/lib/comment_paragraph_plugin/api.rb
=====================================
--- a/plugins/comment_paragraph/lib/comment_paragraph_plugin/api.rb
+++ b/plugins/comment_paragraph/lib/comment_paragraph_plugin/api.rb
@@ -42,9 +42,9 @@ class CommentParagraphPlugin::API < Grape::API
result = export_comments_csv(article)
filename = "#{article.slug}_#{DateTime.now.strftime("%Y%m%d%H%M")}.csv"
content_type 'text/csv; charset=UTF-8; header=present'
- env['api.format'] = :binary # there's no formatter for :binary, data will be returned "as is"
- header 'Content-Disposition', "attachment; filename*=UTF-8''#{CGI.escape(filename)}"
- result
+ header 'Cache-Control', 'no-cache, must-revalidate, post-check=0, pre-check=0'
+ header 'Content-Disposition', "attachment; filename=#{CGI.escape(filename)}"
+ {:data => result}
end
end
=====================================
plugins/comment_paragraph/lib/comment_paragraph_plugin/comments_report.rb
=====================================
--- a/plugins/comment_paragraph/lib/comment_paragraph_plugin/comments_report.rb
+++ b/plugins/comment_paragraph/lib/comment_paragraph_plugin/comments_report.rb
@@ -45,7 +45,8 @@ module CommentParagraphPlugin::CommentsReport
comment_title: comment.present? ? comment.title : '-',
comment_content: comment.present? ? comment.body : '-',
comment_author_name: comment.present? ? comment.author_name : '-',
- comment_author_email: comment.present? ? comment.author_email : '-'
+ comment_author_email: comment.present? ? comment.author_email : '-',
+ comment_date: comment.present? ? comment.created_at.in_time_zone : '-'
}
end
=====================================
plugins/comment_paragraph/test/functional/comment_paragraph_plugin_profile_controller_test.rb
=====================================
--- a/plugins/comment_paragraph/test/functional/comment_paragraph_plugin_profile_controller_test.rb
+++ b/plugins/comment_paragraph/test/functional/comment_paragraph_plugin_profile_controller_test.rb
@@ -56,8 +56,8 @@ class CommentParagraphPluginProfileControllerTest < ActionController::TestCase
xhr :get, :export_comments, :profile => @profile.identifier, :id => article.id
assert_equal 'text/csv; charset=UTF-8; header=present', @response.content_type
lines = @response.body.split("\n")
- assert_equal '"paragraph_id","paragraph_text","comment_id","comment_reply_to","comment_title","comment_content","comment_author_name","comment_author_email"', lines.first
- assert_equal "\"\",\"\",\"#{comment2.id}\",\"\",\"b comment\",\"b comment\",\"#{comment2.author_name}\",\"#{comment2.author_email}\"", lines.second
+ assert_equal '"paragraph_id","paragraph_text","comment_id","comment_reply_to","comment_title","comment_content","comment_author_name","comment_author_email","comment_date"', lines.first
+ assert_equal "\"\",\"\",\"#{comment2.id}\",\"\",\"b comment\",\"b comment\",\"#{comment2.author_name}\",\"#{comment2.author_email}\",\"#{comment2.created_at}\"", lines.second
end
should 'not export any comments as CSV' do
=====================================
plugins/comment_paragraph/test/unit/api_test.rb
=====================================
--- a/plugins/comment_paragraph/test/unit/api_test.rb
+++ b/plugins/comment_paragraph/test/unit/api_test.rb
@@ -99,9 +99,10 @@ class APITest < ActiveSupport::TestCase
get "/api/v1/articles/#{article.id}/comment_paragraph_plugin/export?#{params.to_query}"
assert_equal 200, last_response.status
assert_equal 'text/csv; charset=UTF-8; header=present', last_response.content_type
- lines = last_response.body.split("\n")
- assert_equal '"paragraph_id","paragraph_text","comment_id","comment_reply_to","comment_title","comment_content","comment_author_name","comment_author_email"', lines.first
- assert_equal "\"\",\"\",\"#{comment2.id}\",\"\",\"b comment\",\"b comment\",\"#{comment2.author_name}\",\"#{comment2.author_email}\"", lines.second
+ json = JSON.parse(last_response.body)
+ lines = json['data'].to_s.split("\n")
+ assert_equal '"paragraph_id","paragraph_text","comment_id","comment_reply_to","comment_title","comment_content","comment_author_name","comment_author_email","comment_date"', lines.first
+ assert_equal "\"\",\"\",\"#{comment2.id}\",\"\",\"b comment\",\"b comment\",\"#{comment2.author_name}\",\"#{comment2.author_email}\",\"#{comment2.created_at}\"", lines.second
assert_match /#{article.slug}/, last_response.original_headers["Content-Disposition"]
end
=====================================
plugins/comment_paragraph/test/unit/comments_report_test.rb
=====================================
--- a/plugins/comment_paragraph/test/unit/comments_report_test.rb
+++ b/plugins/comment_paragraph/test/unit/comments_report_test.rb
@@ -16,8 +16,8 @@ class CommentsReportTest < ActiveSupport::TestCase
comment2 = fast_create(Comment, :created_at => Time.now - 2.days, :source_id => article, :title => 'b comment', :body => 'b comment', :paragraph_uuid => nil)
csv = export_comments_csv(article)
lines = csv.split("\n")
- assert_equal '"paragraph_id","paragraph_text","comment_id","comment_reply_to","comment_title","comment_content","comment_author_name","comment_author_email"', lines.first
- assert_equal "\"\",\"\",\"#{comment2.id}\",\"\",\"b comment\",\"b comment\",\"#{comment2.author_name}\",\"#{comment2.author_email}\"", lines.second
+ assert_equal '"paragraph_id","paragraph_text","comment_id","comment_reply_to","comment_title","comment_content","comment_author_name","comment_author_email","comment_date"', lines.first
+ assert_equal "\"\",\"\",\"#{comment2.id}\",\"\",\"b comment\",\"b comment\",\"#{comment2.author_name}\",\"#{comment2.author_email}\",\"#{comment2.created_at}\"", lines.second
end
end
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/f33196eda2278b7d9cbbb984833c4c1870de1200...cb31e59f2da03bfb5e08bf496c7e4fe3c53bc593
---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/f33196eda2278b7d9cbbb984833c4c1870de1200...cb31e59f2da03bfb5e08bf496c7e4fe3c53bc593
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20171010/c1e9a9e3/attachment-0001.html>
More information about the Noosfero-dev
mailing list