#= require ultimate/underscore/underscore #= require ultimate/underscore/underscore.string #= require ultimate/underscore/underscore.inflection #= require ultimate/helpers/record_tag module "Ultimate.Helpers.RecordTag" _.extend @, Ultimate.Helpers.RecordTag class RecordTagPost body: "What a wonderful world!" constructor: (options = {}) -> _.extend @, options record = new RecordTagPost() singular = 'record_tag_post' test "dom_class", -> equal dom_class(record), singular equal dom_class(record, "custom_prefix"), "custom_prefix_#{singular}" test "dom_id", -> record.id = null equal dom_id(record), "new_#{singular}" equal dom_id(record, "custom_prefix"), "custom_prefix_#{singular}" record.id = 1 equal dom_id(record), "#{singular}_1" equal dom_id(record, "edit"), "edit_#{singular}_1" test "content_tag_for", -> record.id = 45 equal content_tag_for('li', record), "
  • " equal content_tag_for('ul', record, 'archived'), "" equal content_tag_for('tr', record, class: "special", style: "background-color: #f0f0f0"), "" equal content_tag_for('tr', record, 'archived', class: "special", style: "background-color: #f0f0f0"), "" equal content_tag_for('tr', record, -> record.body), "What a wonderful world!" post_1 = new RecordTagPost(id: 101, body: "Hello!") post_2 = new RecordTagPost(id: 102, body: "World!") equal content_tag_for('li', [post_1, post_2], (post) -> post.body), "
  • Hello!
  • \n
  • World!
  • " options = class: 'important' content_tag_for('li', record, options) deepEqual options, class: 'important' test "div_for", -> equal div_for(record, class: 'special', -> record.body), "
    What a wonderful world!
    " post_1 = new RecordTagPost(id: 101, body: "Hello!") post_2 = new RecordTagPost(id: 102, body: "World!") equal div_for([post_1, post_2], (post) -> post.body), "
    Hello!
    \n
    World!
    "