Sha256: b740509223d577f8fe309e3dbe3fd237ce5f430430d57ae9cfa87cd636b1475f

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require 'test_helper'

module Admin
  class PostsControllerTest < ActionDispatch::IntegrationTest
    test "index" do
      post = posts(:one)

      get admin_posts_path

      assert_response :ok
      assert_select "td.cell-data--active-storage > a[href='#{admin_post_path(post)}']"
    end

    test "new" do
      get new_admin_post_path

      assert_response :ok
    end

    test "create with valid parameters increases Post count by 1" do
      file = fixture_file_upload("cover_image.jpg")

      assert_difference "Post.count", 1 do
        post admin_posts_path, params: {
          post: {
            title: "New post title",
            cover_image: file
          }
        }
      end

      assert_response :redirect
    end

    test "create with invalid parameters does not increase Post count" do
      file = fixture_file_upload("cover_image.jpg")

      assert_difference "Post.count", 0 do
        post admin_posts_path, params: {
          post: {
            title: "",
            cover_image: file
          }
        }
      end

      assert_response :unprocessable_entity
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
administrate-field-active_storage-1.0.2 test_app/test/controllers/admin/posts_controller_test.rb
administrate-field-active_storage-1.0.1 test_app/test/controllers/admin/posts_controller_test.rb
administrate-field-active_storage-1.0.0 test_app/test/controllers/admin/posts_controller_test.rb