2010-06-16 14:43:29 +00:00
|
|
|
require 'spec_helper'
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-16 14:43:29 +00:00
|
|
|
describe Locomotive::Liquid::Drops::Contents do
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-16 14:43:29 +00:00
|
|
|
before(:each) do
|
|
|
|
@site = Factory.build(:site)
|
|
|
|
@content_type = Factory.build(:content_type, :site => @site, :slug => 'projects')
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-16 14:43:29 +00:00
|
|
|
it 'retrieves a content type from a slug' do
|
|
|
|
@site.content_types.expects(:where).with(:slug => 'projects')
|
|
|
|
render_template '{{ contents.projects }}'
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2011-07-01 00:15:45 +00:00
|
|
|
describe '#group_by' do
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-16 14:43:29 +00:00
|
|
|
it 'orders contents' do
|
|
|
|
@site.content_types.stubs(:where).returns([@content_type])
|
|
|
|
@content_type.contents.klass.expects(:group_by_category).with(:ordered_contents)
|
|
|
|
render_template '{% for group in contents.projects.group_by_category %} {{ group.name }} {% endfor %}'
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-16 14:43:29 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-16 14:43:29 +00:00
|
|
|
def render_template(template = '', assigns = {})
|
|
|
|
assigns = {
|
2010-10-12 15:26:05 +00:00
|
|
|
'contents' => Locomotive::Liquid::Drops::Contents.new
|
2010-06-16 14:43:29 +00:00
|
|
|
}.merge(assigns)
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-10-12 15:26:05 +00:00
|
|
|
Liquid::Template.parse(template).render(::Liquid::Context.new({}, assigns, { :site => @site }))
|
2010-06-16 14:43:29 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
|
|
|
end
|