Sha256: 205709524dd31ea763a7cc56449e41b765cf8c9eb501e9713d481a4f04773bbe

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

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

module YeshuaCrm
  class NewsDropTest < ActiveSupport::TestCase
    def setup
      @news = News.first
      @user = User.first
      @liquid_render = LiquidRender.new('user' => Liquid::UserDrop.new(@user),
                                        'news' => Liquid::NewsDrop.new(@news),
                                        'newss' => Liquid::NewssDrop.new(News.all))
    end

    def test_newss_all
      newss_text = @liquid_render.render('{% for news in newss.all %} {{news.title }} {% endfor %}')
      News.all.map(&:title).each do |title|
        assert_match title, newss_text
      end
    end

    def test_newss_last
      assert_equal News.last.title, @liquid_render.render('{{ newss.last.title }}')
    end

    def test_newss_size
      assert_equal '2', @liquid_render.render('{{ newss.size }}')
    end

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

    def test_issue_delegated
      assert_equal [@news.id, @news.title, @news.description].join('|'),
                   @liquid_render.render('{{ news.id }}|{{ news.title }}|{{ news.description }}')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yeshua_crm-1.0.1 test/liquid/drops/news_drop_test.rb
yeshua_crm-1.0.0 test/liquid/drops/news_drop_test.rb