From ce79ec012711089f35a20ef38880a31f20faa497 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Mon, 15 Jan 2018 17:28:35 -0500 Subject: [PATCH] FIX: subfolder: top referred topics report was missing subfolder in links --- app/assets/javascripts/admin/templates/dashboard.hbs | 2 +- app/models/incoming_links_report.rb | 2 +- spec/models/incoming_links_report_spec.rb | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/admin/templates/dashboard.hbs b/app/assets/javascripts/admin/templates/dashboard.hbs index 6b4dc88584a..a761b4990c3 100644 --- a/app/assets/javascripts/admin/templates/dashboard.hbs +++ b/app/assets/javascripts/admin/templates/dashboard.hbs @@ -224,7 +224,7 @@
diff --git a/app/models/incoming_links_report.rb b/app/models/incoming_links_report.rb index cf28011b8d4..5e817e18b28 100644 --- a/app/models/incoming_links_report.rb +++ b/app/models/incoming_links_report.rb @@ -102,7 +102,7 @@ class IncomingLinksReport num_clicks.each do |topic_id, num_clicks_element| topic = topics.find { |t| t.id == topic_id } if topic - report.data << { topic_id: topic_id, topic_title: topic.title, topic_slug: topic.slug, num_clicks: num_clicks_element } + report.data << { topic_id: topic_id, topic_title: topic.title, topic_url: topic.relative_url, num_clicks: num_clicks_element } end end report.data diff --git a/spec/models/incoming_links_report_spec.rb b/spec/models/incoming_links_report_spec.rb index 2ce2398fc7d..e1582565f6d 100644 --- a/spec/models/incoming_links_report_spec.rb +++ b/spec/models/incoming_links_report_spec.rb @@ -52,8 +52,8 @@ describe IncomingLinksReport do r = IncomingLinksReport.find('top_referred_topics').as_json expect(r[:data]).to eq [ - { topic_id: p1.topic.id, topic_title: p1.topic.title, topic_slug: p1.topic.slug, num_clicks: 7 }, - { topic_id: p2.topic.id, topic_title: p2.topic.title, topic_slug: p2.topic.slug, num_clicks: 2 + 3 }, + { topic_id: p1.topic.id, topic_title: p1.topic.title, topic_url: p1.topic.relative_url, num_clicks: 7 }, + { topic_id: p2.topic.id, topic_title: p2.topic.title, topic_url: p2.topic.relative_url, num_clicks: 2 + 3 }, ] end end @@ -163,8 +163,8 @@ describe IncomingLinksReport do IncomingLinksReport.stubs(:link_count_per_topic).returns(topic1.id => 8, topic2.id => 3) Topic.stubs(:select).returns(Topic); Topic.stubs(:where).returns(Topic) # bypass some activerecord methods Topic.stubs(:all).returns([topic1, topic2]) - expect(top_referred_topics[:data][0]).to eq(topic_id: topic1.id, topic_title: topic1.title, topic_slug: topic1.slug, num_clicks: 8) - expect(top_referred_topics[:data][1]).to eq(topic_id: topic2.id, topic_title: topic2.title, topic_slug: topic2.slug, num_clicks: 3) + expect(top_referred_topics[:data][0]).to eq(topic_id: topic1.id, topic_title: topic1.title, topic_url: topic1.relative_url, num_clicks: 8) + expect(top_referred_topics[:data][1]).to eq(topic_id: topic2.id, topic_title: topic2.title, topic_url: topic2.relative_url, num_clicks: 3) end end