Sha256: 6b7ea67d184696d50a67de78f66128050b56364f246a8471907b5c5608a0fd8d

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

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

module Redmineup
  class IssuesDropTest < ActiveSupport::TestCase
    def setup
      @issue = Issue.first
      @user = User.first
      @liquid_render = LiquidRender.new('user' => Liquid::UserDrop.new(@user),
                                        'issue' => Liquid::IssueDrop.new(@issue),
                                        'issues' => Liquid::IssuesDrop.new(Issue.all))
    end

    def test_issues_all
      issues_text = @liquid_render.render('{% for issue in issues.all %} {{issue.subject }} {% endfor %}')
      Issue.all.map(&:subject).each do |subject|
        assert_match subject, issues_text
      end
    end

    def test_issues_size
      assert_equal '4', @liquid_render.render('{{ issues.size }}')
    end

    def test_issue_author
      assert_equal @user.name, @liquid_render.render('{{ issue.author.name }}')
    end

    def test_issue_delegated
      assert_equal [@issue.id, @issue.subject, @issue.description].join('|'),
                   @liquid_render.render('{{ issue.id }}|{{ issue.subject }}|{{ issue.description }}')

      assert_not_equal @issue.subject, @liquid_render.render('{% if issue.closed? %}{{issue.subject}}{% endif %}')
      @issue.closed = true
      assert_equal @issue.subject, @liquid_render.render('{% if issue.closed? %}{{issue.subject}}{% endif %}')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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