diff --git a/plugins/comment_paragraph/lib/comment_paragraph_plugin/api.rb b/plugins/comment_paragraph/lib/comment_paragraph_plugin/api.rb index d263db3..30dd436 100644 --- 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)}" diff --git a/plugins/comment_paragraph/test/unit/api_test.rb b/plugins/comment_paragraph/test/unit/api_test.rb index 57c282d..e74661f 100644 --- 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 -- libgit2 0.21.2