diff --git a/app/models/topic_list.rb b/app/models/topic_list.rb index 4a56c86d015..b26db3cff2c 100644 --- a/app/models/topic_list.rb +++ b/app/models/topic_list.rb @@ -19,9 +19,9 @@ class TopicList end end - def self.preload(topics) + def self.preload(topics, object) if @preload - @preload.each{|preload| preload.call(topics)} + @preload.each{|preload| preload.call(topics, object)} end end @@ -33,7 +33,8 @@ class TopicList :filter, :for_period, :per_page, - :tags + :tags, + :current_user def initialize(filter, current_user, topics, opts=nil) @filter = filter @@ -116,7 +117,7 @@ class TopicList Topic.preload_custom_fields(@topics, preloaded_custom_fields) end - TopicList.preload(@topics) + TopicList.preload(@topics, self) @topics end diff --git a/spec/models/topic_list_spec.rb b/spec/models/topic_list_spec.rb index 29ea180008d..c3b1df41c03 100644 --- a/spec/models/topic_list_spec.rb +++ b/spec/models/topic_list_spec.rb @@ -31,7 +31,8 @@ describe TopicList do context "preload" do it "allows preloading of data" do preloaded_topic = false - preloader = lambda do |topics| + preloader = lambda do |topics, topic_list| + expect(TopicList === topic_list).to eq(true) expect(topics.length).to eq(1) preloaded_topic = true end