Sha256: 5b08ebe7fcdbcda0dccdf663155d0838cbf8fe400cd00440ab6813da6994b8ec

Contents?: true

Size: 1.38 KB

Versions: 6

Compression:

Stored size: 1.38 KB

Contents

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

module RedmineCrm
  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

6 entries across 6 versions & 1 rubygems

Version Path
redmine_crm-0.0.63 test/liquid/drops/issues_drop_test.rb
redmine_crm-0.0.62 test/liquid/drops/issues_drop_test.rb
redmine_crm-0.0.61 test/liquid/drops/issues_drop_test.rb
redmine_crm-0.0.60 test/liquid/drops/issues_drop_test.rb
redmine_crm-0.0.59 test/liquid/drops/issues_drop_test.rb
redmine_crm-0.0.58 test/liquid/drops/issues_drop_test.rb