[Git][noosfero/noosfero][master] 2 commits: comment_paragraph: change filename of exported comments

Leandro Nunes gitlab at mg.gitlab.com
Tue Jul 19 18:16:27 BRT 2016


Leandro Nunes pushed to branch master at Noosfero / noosfero


Commits:
51dcaa95 by Victor Costa at 2016-06-17T10:24:48-03:00
comment_paragraph: change filename of exported comments

- - - - -
56cc28dc by Leandro Nunes at 2016-07-19T21:14:46+00:00
Merge branch 'filename-comment-paragraph' into 'master'

comment_paragraph: change filename of exported comments



See merge request !966
- - - - -


2 changed files:

- plugins/comment_paragraph/lib/comment_paragraph_plugin/api.rb
- plugins/comment_paragraph/test/unit/api_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
@@ -40,7 +40,7 @@ class CommentParagraphPlugin::API < Grape::API
     get ":id/comment_paragraph_plugin/export" do
       article = find_article(environment.articles, params[:id])
       result = export_comments_csv(article)
-      filename = "comments_for_article#{article.id}_#{DateTime.now.to_i}.csv"
+      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)}"


=====================================
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
@@ -102,6 +102,7 @@ class APITest <  ActiveSupport::TestCase
     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
+    assert_match /#{article.slug}/, last_response.original_headers["Content-Disposition"]
   end
 
 end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/bde4a4f817aa26f57e6c6d21e7b67339a33f7996...56cc28dc8b10f3ec9912b0a761060cc9e82cd667
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160719/6d32c79d/attachment-0001.html>


More information about the Noosfero-dev mailing list