Guest User

Untitled

a guest
Feb 20th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. Index: test/unit/section_drop_test.rb
  2. ===================================================================
  3. --- test/unit/section_drop_test.rb (revision 1907)
  4. +++ test/unit/section_drop_test.rb (working copy)
  5. @@ -22,4 +22,16 @@
  6. assert Mephisto::Liquid::SectionDrop.new(sections(:home)).is_blog
  7. [:about, :cupcake_home, :cupcake_about].each { |s| assert Mephisto::Liquid::SectionDrop.new(sections(s)).is_paged }
  8. end
  9. +
  10. + # need to adjust fixtures to test these properly.
  11. + def test_should_return_recent_articles
  12. + section = Mephisto::Liquid::SectionDrop.new(sections(:home))
  13. + assert section.recent_articles.size > 0
  14. + assert section.recent_articles.size <= sections(:home).articles_per_page
  15. + end
  16. +
  17. + def test_should_return_all_articles
  18. + section = Mephisto::Liquid::SectionDrop.new(sections(:home))
  19. + assert section.articles.size > 0
  20. + end
  21. end
  22. Index: lib/mephisto/liquid/section_drop.rb
  23. ===================================================================
  24. --- lib/mephisto/liquid/section_drop.rb (revision 1907)
  25. +++ lib/mephisto/liquid/section_drop.rb (working copy)
  26. @@ -31,6 +31,17 @@
  27. def is_home
  28. @source.home?
  29. end
  30. +
  31. + def recent_articles
  32. + @recent_articles ||= @source.articles.find_by_date(
  33. + :include => [:user],
  34. + :limit => @source.articles_per_page,
  35. + :offset => 0 ).collect(&:to_liquid)
  36. + end
  37. +
  38. + def articles
  39. + @article ||= @source.articles.find_by_date( :include => [:user] ).collect(&:to_liquid)
  40. + end
  41. end
  42. end
  43. end
  44. \ No newline at end of file
Add Comment
Please, Sign In to add comment