Sha256: 55ecd6ddba080bf969dea29a58ea8ad80a2a2ebe0103e8d1ef4931c04ee6f913

Contents?: true

Size: 957 Bytes

Versions: 6

Compression:

Stored size: 957 Bytes

Contents

require 'spec_helper'
 
describe Locomotive::Liquid::Drops::Contents do
  
  before(:each) do
    @site = Factory.build(:site)
    @content_type = Factory.build(:content_type, :site => @site, :slug => 'projects')
  end
  
  it 'retrieves a content type from a slug' do
    @site.content_types.expects(:where).with(:slug => 'projects')
    render_template '{{ contents.projects }}'
  end
  
  context '#group_by' do
    
    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
    
  end
  
  def render_template(template = '', assigns = {})
    assigns = {
      'contents' => Locomotive::Liquid::Drops::Contents.new(@site)
    }.merge(assigns)
    
    Liquid::Template.parse(template).render assigns
  end
    
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
locomotive_cms-0.0.3.3 spec/lib/locomotive/liquid/drops/contents_spec.rb
locomotive_cms-0.0.3.1 spec/lib/locomotive/liquid/drops/contents_spec.rb
locomotive_cms-0.0.2.9 spec/lib/locomotive/liquid/drops/contents_spec.rb
locomotive_cms-0.0.2.8 spec/lib/locomotive/liquid/drops/contents_spec.rb
locomotive_cms-0.0.2.7 spec/lib/locomotive/liquid/drops/contents_spec.rb
locomotive_cms-0.0.2.6 spec/lib/locomotive/liquid/drops/contents_spec.rb