A platform for community discussion. Free, open, simple.
FIX: Support exporting reports which reference topics (#9957)
David Taylor3106f85983a5
diff --git a/app/jobs/regular/export_csv_file.rb b/app/jobs/regular/export_csv_file.rbindex 9485fc2fdc3..7d9b00d1661 100644--- a/app/jobs/regular/export_csv_file.rb+++ b/app/jobs/regular/export_csv_file.rb@@ -231,6 +231,9 @@ module Jobsif label[:type] == :usertitles[label[:properties][:username]] = label[:title]header << label[:properties][:username]+ elsif label[:type] == :topic+ titles[label[:properties][:id]] = label[:title]+ header << label[:properties][:id]elsetitles[label[:property]] = label[:title]header << label[:property]diff --git a/spec/jobs/export_csv_file_spec.rb b/spec/jobs/export_csv_file_spec.rbindex 9182f9f37d9..a29bae2549f 100644--- a/spec/jobs/export_csv_file_spec.rb+++ b/spec/jobs/export_csv_file_spec.rb@@ -152,6 +152,20 @@ describe Jobs::ExportCsvFile doexpect(report.second).to contain_exactly(user.username, "Earth", "2010-01-01 00:00:00 UTC")end+ it 'works with topic reports' do+ freeze_time DateTime.parse('2010-01-01 6:00')++ exporter.extra['name'] = 'top_referred_topics'+ post1 = Fabricate(:post)+ post2 = Fabricate(:post)+ IncomingLink.add(host: "a.com", referer: "http://twitter.com", post_id: post1.id, ip_address: '1.1.1.1')++ report = exporter.report_export.to_a++ expect(report.first).to contain_exactly("Topic", "Clicks")+ expect(report.second).to contain_exactly(post1.topic.id.to_s, "1")+ end+it 'works with stacked_chart reports' doApplicationRequest.create!(date: '2010-01-01', req_type: 'page_view_logged_in', count: 1)ApplicationRequest.create!(date: '2010-01-02', req_type: 'page_view_logged_in', count: 2)