Sha256: 7236cb54dc60585732febde53d1473ab164fc50673fac7040b6448a3130c90d8

Contents?: true

Size: 1.58 KB

Versions: 10

Compression:

Stored size: 1.58 KB

Contents

require 'test_helper'

module Workarea
  module Admin
    class AssetsIntegrationTest < Workarea::IntegrationTest
      include Admin::IntegrationTest

      def test_ensures_cors_policy_for_bulk_upload
        Workarea.s3.expects(:put_bucket_cors).once
        get admin.content_assets_path
        assert(response.ok?)

        get admin.content_assets_path, xhr: true
        assert(response.ok?)

        get admin.content_assets_path
        assert(response.ok?)
      end

      def test_can_create_an_asset
        post admin.content_assets_path,
          params: {
            asset: {
              name: 'Test Asset',
              file: product_image_file,
              tag_list: 'foo,bar,baz'
            }
          }

        assert_equal(1, Content::Asset.count)

        asset = Content::Asset.first
        assert_equal('Test Asset', asset.name)
        assert_equal(%w(foo bar baz), asset.tags)
      end

      def test_can_update_an_asset
        asset = create_asset(
          name: 'Test Asset',
          file: product_image_file,
          tag_list: 'foo,bar,baz'
        )

        patch admin.content_asset_path(asset),
          params: {
            asset: {
              name: 'New Name',
              tag_list: 'other,tags'
            }
          }

        asset.reload
        assert_equal('New Name', asset.name)
        assert_equal(%w(other tags), asset.tags)
      end

      def test_can_destroy_an_asset
        asset = create_asset(file: product_image_file)
        delete admin.content_asset_path(asset)
        assert(Content::Asset.empty?)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
workarea-admin-3.5.4 test/integration/workarea/admin/assets_integration_test.rb
workarea-admin-3.4.26 test/integration/workarea/admin/assets_integration_test.rb
workarea-admin-3.5.3 test/integration/workarea/admin/assets_integration_test.rb
workarea-admin-3.4.25 test/integration/workarea/admin/assets_integration_test.rb
workarea-admin-3.5.2 test/integration/workarea/admin/assets_integration_test.rb
workarea-admin-3.4.24 test/integration/workarea/admin/assets_integration_test.rb
workarea-admin-3.5.1 test/integration/workarea/admin/assets_integration_test.rb
workarea-admin-3.4.23 test/integration/workarea/admin/assets_integration_test.rb
workarea-admin-3.4.22 test/integration/workarea/admin/assets_integration_test.rb
workarea-admin-3.5.0 test/integration/workarea/admin/assets_integration_test.rb