Sha256: 74e1483484c6d80670cbd561dd76f6ce2c99ae67ea199bd96d02c34f83174464

Contents?: true

Size: 1.88 KB

Versions: 18

Compression:

Stored size: 1.88 KB

Contents

require 'test_helper'

class CommentsControllerTest < Zena::Controller::TestCase
  include Zena::Use::Urls::ControllerMethods # zen_path

  def test_create
    login(:lion)
    post 'create', 'node_id'=>nodes_zip(:status), 'comment'=>{'title'=>'blowe', 'text' => 'I do not know..'}
    assert_response :redirect
    assert_redirected_to zen_path(nodes(:status))
    comment = assigns['comment']
    assert !comment.new_record?
  end

  def test_update
    login(:tiger)
    put 'update', 'id'=>comments_id(:tiger_says_inside), 'comment'=>{'title'=>'hahaha', 'text' => 'new text'}
    assert_response :redirect
    assert_redirected_to zen_path(nodes(:status))
    comment = assigns['comment']
    assert_equal comments_id(:tiger_says_inside), comment[:id]
    comment = comments(:tiger_says_inside) # reload
    assert_equal 'hahaha', comment[:title]
    assert_equal 'new text', comment[:text]
  end

  def test_cannot_update
    login(:ant)
    put 'update', 'id'=>comments_id(:tiger_says_inside), 'comment'=>{'title'=>'other title', 'text' => 'other text'}
    assert_response :redirect
    assert_redirected_to zen_path(nodes(:status))
    comment = assigns['comment']
    assert !comment.new_record?
    assert_equal 'You do not have the rights to modify comments.', comment.errors[:base]
    comment = comments(:tiger_says_inside)
    assert_equal 'We could not do better then this. I *really* mean that. Look at the "":20.', comment[:text]
  end

  def test_index
    login(:anon)
    get 'index'
    assert_response :not_found
    login(:lion)
    get 'index'
    assert_response :success
  end

  def test_remove
    login(:lion)
    assert_equal Zena::Status[:prop], comments(:public_spam_in_en).status
    post "remove", "id"=>comments_id(:public_spam_in_en)
    assert_response :success
    assert_equal Zena::Status[:rem], comments(:public_spam_in_en).status
  end

  def test_bin
  end
  # TODO: test rjs...
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
zena-1.0.0.rc2 test/functional/comments_controller_test.rb
zena-1.0.0.rc1 test/functional/comments_controller_test.rb
zena-0.16.9 test/functional/comments_controller_test.rb
zena-1.0.0.beta3 test/functional/comments_controller_test.rb
zena-0.16.8 test/functional/comments_controller_test.rb
zena-1.0.0.beta2 test/functional/comments_controller_test.rb
zena-1.0.0.beta1 test/functional/comments_controller_test.rb
zena-0.16.7 test/functional/comments_controller_test.rb
zena-0.16.6 test/functional/comments_controller_test.rb
zena-0.16.5 test/functional/comments_controller_test.rb
zena-0.16.4 test/functional/comments_controller_test.rb
zena-0.16.3 test/functional/comments_controller_test.rb
zena-0.16.2 test/functional/comments_controller_test.rb
zena-0.16.1 test/functional/comments_controller_test.rb
zena-0.16.0 test/functional/comments_controller_test.rb
zena-0.15.2 test/functional/comments_controller_test.rb
zena-0.15.1 test/functional/comments_controller_test.rb
zena-0.15.0 test/functional/comments_controller_test.rb