FIX: include default label when exporting reports

This commit is contained in:
Arpit Jalan 2019-07-26 12:57:13 +05:30
parent 0f4fa98a82
commit 0603636cea
2 changed files with 13 additions and 0 deletions

View File

@ -152,6 +152,7 @@ class Report
report.average = opts[:average] if opts[:average]
report.percent = opts[:percent] if opts[:percent]
report.filters = opts[:filters] if opts[:filters]
report.labels = Report.default_labels
report
end

View File

@ -66,6 +66,18 @@ describe Jobs::ExportCsvFile do
expect(report.third).to contain_exactly("2010-01-03", "50.0")
end
it 'works with single-column reports with default label' do
user.user_visits.create!(visited_at: '2010-01-01')
Fabricate(:user).user_visits.create!(visited_at: '2010-01-03')
exporter.instance_variable_get(:@extra)['name'] = 'visits'
report = exporter.report_export.to_a
expect(report.first).to contain_exactly("Day", "Count")
expect(report.second).to contain_exactly("2010-01-01", "1")
expect(report.third).to contain_exactly("2010-01-03", "1")
end
it 'works with multi-columns reports' do
DiscourseIpInfo.stubs(:get).with("1.1.1.1").returns(location: "Earth")
user.user_auth_token_logs.create!(action: "login", client_ip: "1.1.1.1", created_at: '2010-01-01')