diff --git a/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 b/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 index d7a2116bee6..14dd5e3d20b 100644 --- a/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 +++ b/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 @@ -54,8 +54,8 @@ function findTopicList(store, tracking, filter, filterParams, extras) { tracking.trackIncoming(list.filter); } Discourse.Session.currentProp('topicList', list); - if (list.topic_list && list.topic_list.tags) { - Discourse.Site.currentProp('top_tags', list.topic_list.tags); + if (list.topic_list && list.topic_list.top_tags) { + Discourse.Site.currentProp('top_tags', list.topic_list.top_tags); } return list; }); diff --git a/app/models/topic_list.rb b/app/models/topic_list.rb index 375659dc5c8..0e02b74fe15 100644 --- a/app/models/topic_list.rb +++ b/app/models/topic_list.rb @@ -34,7 +34,7 @@ class TopicList :filter, :for_period, :per_page, - :tags, + :top_tags, :current_user def initialize(filter, current_user, topics, opts = nil) @@ -48,7 +48,7 @@ class TopicList end end - def tags + def top_tags opts = @category ? { category: @category } : {} opts[:guardian] = Guardian.new(@current_user) Tag.top_tags(opts) diff --git a/app/serializers/topic_list_serializer.rb b/app/serializers/topic_list_serializer.rb index 039a15342bd..0a9300790f2 100644 --- a/app/serializers/topic_list_serializer.rb +++ b/app/serializers/topic_list_serializer.rb @@ -7,7 +7,7 @@ class TopicListSerializer < ApplicationSerializer :draft_sequence, :for_period, :per_page, - :tags + :top_tags has_many :topics, serializer: TopicListItemSerializer, embed: :objects @@ -23,7 +23,7 @@ class TopicListSerializer < ApplicationSerializer object.more_topics_url.present? && (object.topics.size == object.per_page) end - def include_tags? + def include_top_tags? Tag.include_tags? end end diff --git a/spec/models/topic_list_spec.rb b/spec/models/topic_list_spec.rb index dcb6b5aab71..dde096ae0a9 100644 --- a/spec/models/topic_list_spec.rb +++ b/spec/models/topic_list_spec.rb @@ -46,12 +46,12 @@ describe TopicList do end end - describe '#tags' do + describe '#top_tags' do it 'should return the right tags' do tag = Fabricate(:tag, topics: [topic]) other_tag = Fabricate(:tag, topics: [topic], name: "use-anywhere") output = [tag.name, other_tag.name] - expect(topic_list.tags.sort).to eq(output.sort) + expect(topic_list.top_tags.sort).to eq(output.sort) end describe 'when there are tags restricted to a category' do @@ -63,18 +63,18 @@ describe TopicList do let(:topic_list) { TopicList.new('latest', topic.user, [topic], category: category.id, category_id: category.id) } it 'should only return tags allowed in the category' do - expect(topic_list.tags).to eq([tag.name]) + expect(topic_list.top_tags).to eq([tag.name]) end it "with no category, should return all tags" do - expect(TopicList.new('latest', other_topic.user, [other_topic]).tags.sort).to eq([tag.name, other_tag.name].sort) + expect(TopicList.new('latest', other_topic.user, [other_topic]).top_tags.sort).to eq([tag.name, other_tag.name].sort) end it "with another category with no tags, should return no tags" do other_category = Fabricate(:category) topic3 = Fabricate(:topic, category: other_category) list = TopicList.new('latest', topic3.user, [topic3], category: other_category.id, category_id: other_category.id) - expect(list.tags).to be_empty + expect(list.top_tags).to be_empty end end end