Skip to content

Commit ae10cee

Browse files
committed
add spec to test dependencies sorting for cache_key
1 parent 217650f commit ae10cee

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

spec/presenter_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,29 @@ class SubNestedPresenter < Curly::Presenter
226226
expect(cache_key).to eq "Foo::BarPresenter/42/Foo::BumPresenter/1337"
227227
end
228228

229+
it "includes the cache keys of all presenters in the dependency list" do
230+
presenter = Class.new(Curly::Presenter) do
231+
version 42
232+
depends_on 'foo/bum'
233+
depends_on 'foo/aum'
234+
end
235+
236+
dependency = Class.new(Curly::Presenter) do
237+
version 1337
238+
end
239+
240+
dependency_2 = Class.new(Curly::Presenter) do
241+
version 1338
242+
end
243+
244+
stub_const("Foo::BarPresenter", presenter)
245+
stub_const("Foo::BumPresenter", dependency)
246+
stub_const("Foo::AumPresenter", dependency_2)
247+
248+
cache_key = Foo::BarPresenter.cache_key
249+
expect(cache_key).to eq "Foo::BarPresenter/42/Foo::AumPresenter/1338/Foo::BumPresenter/1337"
250+
end
251+
229252
it "uses the view path of a dependency if there is no presenter for it" do
230253
presenter = Class.new(Curly::Presenter) do
231254
version 42

0 commit comments

Comments
 (0)