article_test.rb 1019 Bytes
require File.dirname(__FILE__) + '/../../../../test/test_helper'

class ArticleTest < ActiveSupport::TestCase
  include ArticleDataExport

  def setup
    @john = fast_create(Person, :name => "John Snow")
  end

  should 'get the attributes of John TinyMceArticle' do
    lord = fast_create(Person, :name => "Lord Commander")
    article = create(TinyMceArticle, :name => "The Night's Watch Oath", :body => "Night gathers, and now my watch begins...", :profile => @john, :author => lord)

    attributes = article_attr_to_hash(article)

    assert_equal attributes["type"], "TinyMceArticle"
    assert_equal attributes["data"]["title"], "The Night's Watch Oath"
    assert_equal attributes["data"]["author_id"], lord.id
  end

  should 'get the attributes of John Event' do
    article = create(Event, :name => "Run Away", :body => "...", :profile => @john)

    attributes = article_attr_to_hash(article)

    assert_equal attributes["type"], "Event"
    assert_equal attributes["data"]["title"], "Run Away"
  end
end