Sha256: da70b2a780b3375831e1c0a850c3b3f0afc2f680740fb6fe9f573ae50d2a9407

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

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

module Redmineup
  class UsersDropTest < ActiveSupport::TestCase
    def setup
      @user = User.first
      @liquid_render = LiquidRender.new('user' => Liquid::UserDrop.new(@user),
                                        'users' => Liquid::UsersDrop.new(User.all))
    end

    def test_users_all
      users_text = @liquid_render.render('{% for user in users.all %} {{user.name }} {% endfor %}')
      User.all.map(&:name).each do |name|
        assert_match name, users_text
      end
    end

    def test_users_current
      assert_equal User.first.name, @liquid_render.render('{{ users.current.name }}')
    end

    def test_users_size
      assert_equal '3', @liquid_render.render('{{ users.size }}')
    end

    def test_user_name
      assert_equal @user.name, @liquid_render.render('{{ user.name }}')
    end

    def test_user_delegated
      assert_equal [@user.name, @user.language].join('|'),
                   @liquid_render.render('{{ user.name }}|{{ user.language }}')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
redmineup-1.0.5 test/liquid/drops/uses_drop_test.rb
redmineup-1.0.4 test/liquid/drops/uses_drop_test.rb
redmineup-1.0.3 test/liquid/drops/uses_drop_test.rb
redmineup-1.0.2 test/liquid/drops/uses_drop_test.rb