test/models/storage/test_file.rb in gitlab-fog-azure-rm-1.8.0 vs test/models/storage/test_file.rb in gitlab-fog-azure-rm-1.9.0

- old
+ new

@@ -1,11 +1,11 @@ require File.expand_path '../../test_helper', __dir__ # Test class for Storage Container Model class TestFile < Minitest::Test # rubocop:disable Metrics/ClassLength def setup - @service = Fog::Storage::AzureRM.new(storage_account_credentials) + @service = Fog::AzureRM::Storage.new(storage_account_credentials) @directory = directory(@service) @file = file(@service) @raw_cloud_blob = storage_blob @mocked_response = mocked_storage_http_error @@ -169,11 +169,11 @@ @service.stub :get_blob_properties, @raw_cloud_blob do @service.stub :copy_blob, [copy_id, copy_status] do @service.stub :wait_blob_copy_operation_to_finish, true do target_file = @file.copy('target_container', 'target_blob') - assert_instance_of Fog::Storage::AzureRM::File, target_file + assert_instance_of Fog::AzureRM::Storage::File, target_file end end end end @@ -288,11 +288,23 @@ assert @file.url(Time.now + 3600, content_disposition: 'attachment'), @blob_https_url end end def test_url_method_with_response_content_disposition - @file.collection.stub :get_url, @blob_https_url, { content_disposition: 'attachment' } do - assert @file.url(Time.now + 3600, { query: { 'response-content-disposition' => 'attachment' } }), @blob_https_url + fake = Minitest::Mock.new + expiry = Time.now + 3600 + fake.expect :call, nil, [@file.key, expiry, { content_disposition: 'attachment', content_type: nil }] + @file.collection.stub(:get_url, fake) do + @file.url(expiry, { query: { 'response-content-disposition' => 'attachment' } }) + end + end + + def test_url_method_with_response_content_type + fake = Minitest::Mock.new + expiry = Time.now + 3600 + fake.expect :call, nil, [@file.key, expiry, { content_disposition: nil, content_type: 'image/png' }] + @file.collection.stub(:get_url, fake) do + @file.url(expiry, { query: { 'response-content-type' => 'image/png' } }) end end def test_url_method_without_key_exception assert_raises(ArgumentError) do