require File.dirname(__FILE__) + '/../liquid_helper' include LiquidHelperMethods module YeshuaCrm class CellsDropTest < ActiveSupport::TestCase def setup @cell = Cell.first @user = User.first @liquid_render = LiquidRender.new('user' => Liquid::UserDrop.new(@user), 'cell' => Liquid::CellDrop.new(@cell), 'cells' => Liquid::CellsDrop.new(Cell.all)) end def test_cells_all cells_text = @liquid_render.render('{% for cell in cells.all %} {{cell.identifier }} {% endfor %}') Cell.all.map(&:identifier).each do |identifier| assert_match identifier, cells_text end end def test_cells_active cells_text = @liquid_render.render('{% for cell in cells.active %} {{cell.identifier }} {% endfor %}') Cell.where(:status => 1).map(&:identifier).each do |identifier| assert_match identifier, cells_text end end def test_cells_size assert_equal '2', @liquid_render.render('{{ cells.size }}') end def test_cell_issues issues_text = @liquid_render.render('{% for issue in cell.issues %} {{issue.subject }} {% endfor %}') Cell.first.issues.each do |issue| assert_match issue.subject, issues_text end end def test_cell_delegated assert_equal [@cell.id, @cell.identifier, @cell.description].join('|'), @liquid_render.render('{{ cell.id }}|{{ cell.identifier }}|{{ cell.description }}') end end end