Sha256: d99c136ab63073152ad09a0e5f075c69c65e5ae96c3fa398035cb17757ff4095

Contents?: true

Size: 1.91 KB

Versions: 10

Compression:

Stored size: 1.91 KB

Contents

require 'test_helper'

class SubcommentsControllerTest < ActionController::TestCase
  setup do
    @subcomment = create(:subcomment)
    @comment = @subcomment.commentable
    @product = @comment.commentable
  end

  test "should get index" do
    get :index, product_id: @product, comment_id: @comment
    assert_response :success
  end

  test "should get json index" do
    get :index, product_id: @product, comment_id: @comment, format: :json
    assert_response :success
  end

  test "should get show" do
    get :show, product_id: @product, comment_id: @comment, id: @subcomment
    assert_response :success
  end

  test "should get json show" do
    get :show, product_id: @product, comment_id: @comment, id: @subcomment, format: :json
    assert_response :success
  end

  test "should get new" do
    get :new, product_id: @product, comment_id: @comment
    assert_response :success
  end

  test "should get edit" do
    get :edit, product_id: @product, comment_id: @comment, id: @subcomment
    assert_response :success
  end

  test "should create" do
    assert_difference("Product.find('#{@product.id}').comments.find('#{@comment.id}').comments.count") do
      post :create, product_id: @product, comment_id: @comment, comment: {author_name: 'Hello'}
    end
    assert_response 302
  end

  test "should update" do
    request.path = "/products/#{@product.id}/comments/#{@comment.id}/comments/#{@subcomment.id}"
    patch :update, id: @subcomment.id, product_id: @product, comment_id: @comment, comment: {author_name: 'World'}
    assert_redirected_to product_comment_comment_path(@product, @comment, @subcomment)
  end

  test "should destroy" do
    assert_difference("Product.find('#{@product.id}').comments.find('#{@comment.id}').comments.count", -1) do
      delete :destroy, product_id: @product, comment_id: @comment, id: @subcomment
    end
    assert_redirected_to product_comment_comments_path(@product, @comment)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
iord-1.2.2 test/controllers/subcomments_controller_test.rb
iord-1.2.1 test/controllers/subcomments_controller_test.rb
iord-1.2.0 test/controllers/subcomments_controller_test.rb
iord-1.1.3 test/controllers/subcomments_controller_test.rb
iord-1.1.2 test/controllers/subcomments_controller_test.rb
iord-1.1.1 test/controllers/subcomments_controller_test.rb
iord-1.1.0 test/controllers/subcomments_controller_test.rb
iord-1.0.3 test/controllers/subcomments_controller_test.rb
iord-1.0.2 test/controllers/subcomments_controller_test.rb
iord-1.0.1 test/controllers/subcomments_controller_test.rb