Sha256: 18d656d8538697c6e4b9028e9c084d9cf048469854601a2332c77ff5c644f6b8

Contents?: true

Size: 1.72 KB

Versions: 5

Compression:

Stored size: 1.72 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(:get_bucket_cors).returns(
          mock('Excon::Response', data: { body: { 'CORSConfiguration' => [] } })
        )
        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

5 entries across 5 versions & 1 rubygems

Version Path
workarea-admin-3.4.31 test/integration/workarea/admin/assets_integration_test.rb
workarea-admin-3.4.30 test/integration/workarea/admin/assets_integration_test.rb
workarea-admin-3.4.29 test/integration/workarea/admin/assets_integration_test.rb
workarea-admin-3.4.28 test/integration/workarea/admin/assets_integration_test.rb
workarea-admin-3.4.27 test/integration/workarea/admin/assets_integration_test.rb