Sha256: b4f079e5ea30ce43d032b269493205ae9b58eba1c9a7c16f922669887e62fa10

Contents?: true

Size: 1.67 KB

Versions: 9

Compression:

Stored size: 1.67 KB

Contents

require File.dirname(__FILE__) + '/../../test_helper'
require 'admin/content_controller'
require 'http_mock'

class Admin::ContentController; def rescue_action(e) raise e end; end

class Admin::ArticlePreviewTest < Test::Unit::TestCase
  fixtures :contents, :users, :categories, :resources, :text_filters, :blogs

  def setup
    @controller = Admin::ContentController.new
    @request = ActionController::TestRequest.new
    @response = ActionController::TestResponse.new
    @request.session = {:user => users(:tobi)}

    @art_count = Article.find(:all).size
  end

  def assert_no_new_articles
    assert_equal @art_count, Article.find(:all).size
  end

  def test_only_title
    post :preview, 'article' => { :title => 'A title' }
    assert_response :success
    assert_rendered_file 'preview'
    assert_tag :tag => 'h4', :content => 'A title'
    assert_no_tag :tag => 'p'
    assert_no_new_articles
  end

  def test_only_body
    post :preview, :article => { :body => 'A body' }

    assert_tag :tag => 'p',
      :child => 'A body',
      :after => { :tag => 'h4', :content => nil }

    assert_no_new_articles
  end

  def test_only_extended
    post :preview, :article => { :body => 'An extension' }

    assert_tag :tag => 'p',
      :child => 'An extension',
      :after => { :tag => 'h4', :content => nil }

    assert_no_new_articles
  end

  def test_full_post
    post :preview, :article => {
      :title => 'A title', :body => 'A body',
      :extended => 'An extension' }

    assert_tag \
      :tag => 'p',
      :child => 'An extension',
      :after => {:tag => 'p', :child => 'A body',
        :after => { :tag => 'h4', :content => nil }}

    assert_no_new_articles
  end


end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
typo-3.99.0 test/functional/admin/article_preview_test.rb
typo-3.99.1 test/functional/admin/article_preview_test.rb
typo-3.99.2 test/functional/admin/article_preview_test.rb
typo-3.99.3 test/functional/admin/article_preview_test.rb
typo-4.0.0 test/functional/admin/article_preview_test.rb
typo-3.99.4 test/functional/admin/article_preview_test.rb
typo-4.0.2 test/functional/admin/article_preview_test.rb
typo-4.0.1 test/functional/admin/article_preview_test.rb
typo-4.0.3 test/functional/admin/article_preview_test.rb