amend preloader api to supply topic list
This commit is contained in:
parent
2c59ffeb2c
commit
9c51e3e8e7
|
@ -19,9 +19,9 @@ class TopicList
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.preload(topics)
|
def self.preload(topics, object)
|
||||||
if @preload
|
if @preload
|
||||||
@preload.each{|preload| preload.call(topics)}
|
@preload.each{|preload| preload.call(topics, object)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,8 @@ class TopicList
|
||||||
:filter,
|
:filter,
|
||||||
:for_period,
|
:for_period,
|
||||||
:per_page,
|
:per_page,
|
||||||
:tags
|
:tags,
|
||||||
|
:current_user
|
||||||
|
|
||||||
def initialize(filter, current_user, topics, opts=nil)
|
def initialize(filter, current_user, topics, opts=nil)
|
||||||
@filter = filter
|
@filter = filter
|
||||||
|
@ -116,7 +117,7 @@ class TopicList
|
||||||
Topic.preload_custom_fields(@topics, preloaded_custom_fields)
|
Topic.preload_custom_fields(@topics, preloaded_custom_fields)
|
||||||
end
|
end
|
||||||
|
|
||||||
TopicList.preload(@topics)
|
TopicList.preload(@topics, self)
|
||||||
|
|
||||||
@topics
|
@topics
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,8 @@ describe TopicList do
|
||||||
context "preload" do
|
context "preload" do
|
||||||
it "allows preloading of data" do
|
it "allows preloading of data" do
|
||||||
preloaded_topic = false
|
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)
|
expect(topics.length).to eq(1)
|
||||||
preloaded_topic = true
|
preloaded_topic = true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue