Sha256: 96b5365da366ba2f37ec5ac8f619419ad374fc67b09181e7978846f3d1cb0816
Contents?: true
Size: 1.95 KB
Versions: 2
Compression:
Stored size: 1.95 KB
Contents
require 'spec_helper.rb' module Locomotive module Sort describe BooleanSortTag do before :each do @type = FactoryGirl.build(:content_type) @type.entries_custom_fields.build(label: 'name', type: 'string') @type.entries_custom_fields.build(label: 'bool', type: 'boolean') @type.save @site = @type.site Locomotive::Plugins.use_site(@site) @plugin = Plugin.new() @type.entries.create(name: "A", bool: false) @type.entries.create(name: "B", bool: true) @type.entries.create(name: "C", bool: false) @context = ::Liquid::Context.new({}, {'contents' => Locomotive::Liquid::Drops::ContentTypes.new}, {enabled_plugin_tags: [Locomotive::Sort::BooleanSortTag::TagSubclass], site: @site}) end it 'should sort content entries' do template = "{% sort_boolean to sorted from contents.#{@type.slug} by bool %}"+ "{% for entry in sorted %}"+ "{{entry.name}}, " + "{% endfor %}" ::Liquid::Template.parse(template).render(@context).should eq "B, A, C, " end it 'should sort content entries in reverse' do template = "{% sort_boolean to sorted from contents.#{@type.slug} by bool reverse %}"+ "{% for entry in sorted %}"+ "{{entry.name}}, " + "{% endfor %}" ::Liquid::Template.parse(template).render(@context).should eq "A, C, B, " end it 'should not sort content entries if disabled' do @context = ::Liquid::Context.new({}, {'contents' => Locomotive::Liquid::Drops::ContentTypes.new}, {enabled_plugin_tags: [], site: @site}) template = "{% sort_boolean to sorted from contents.#{@type.slug} by bool %}"+ "{% for entry in sorted %}"+ "{{entry.name}}, " + "{% endfor %}" ::Liquid::Template.parse(template).render(@context).should eq "A, B, C, " end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
locomotive_sort_plugin-0.4.0 | spec/lib/locomotive/sort/plugin/boolean_sort_tag_spec.rb |
locomotive_sort_plugin-0.3.1 | spec/lib/locomotive/sort/plugin/boolean_sort_tag_spec.rb |