Sha256: 5bc3505b63974148e3249fe9bc61c95c227b9b38af2f516137c43c709d1e80d3

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

require File.dirname(__FILE__) + '/../liquid_helper'
include LiquidHelperMethods

module Redmineup
  class ArraysFilterTest < ActiveSupport::TestCase
    def setup
      @liquid_render = LiquidRender.new
      @array = '6,7,8,9,1,2,3,4,5'
    end

    def test_first_filter
      assert_match '1', @liquid_render.render("{{ '#{@array}' | split: ',' | first: 5 | last }}")
    end

    def test_sort_filter
      assert_match '123456789', @liquid_render.render("{{ '#{@array}' | split: ',' | sort }}")
    end

    def test_where_filter
      assert_match '{"name"=>"two", "value"=>5}', @liquid_render.render("{{ objects_arr | where: 'name', 'two' }}")
      assert_match '{"name"=>"one", "value"=>10}', @liquid_render.render("{{ objects_arr | where: 'value', 6, '>' }}")
      assert_match '{"name"=>"one", "value"=>10}', @liquid_render.render("{{ objects_arr | where: 'name', 'on', 'match' }}")
      assert_match '3', @liquid_render.render("{{ objects_arr | where: 'value', '', 'any' | size }}")
      assert_match '1', @liquid_render.render("{{ objects_arr | where: 'value', '', 'none' | size }}")
      assert_match '2', @liquid_render.render("{{ issues.all | where: 'author.name', 'Jonathan', '==' | size }}")
      assert_match '1', @liquid_render.render("{{ issues.all | where: 'author.language', 'CH', '==' | size }}")
      assert_match '0', @liquid_render.render("{{ issues.all | where: 'author.name', '', 'none' | size }}")
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
redmineup-1.0.5 test/liquid/filters/arrays_filter_test.rb
redmineup-1.0.4 test/liquid/filters/arrays_filter_test.rb
redmineup-1.0.3 test/liquid/filters/arrays_filter_test.rb
redmineup-1.0.2 test/liquid/filters/arrays_filter_test.rb