mirror of
https://github.com/internetee/registry.git
synced 2025-08-02 16:02:03 +02:00
parent
490528ca18
commit
e60380c60a
9 changed files with 103 additions and 30 deletions
43
test/integration/registrar/domain_transfers_test.rb
Normal file
43
test/integration/registrar/domain_transfers_test.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarDomainTransfersTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
WebMock.reset!
|
||||
login_as users(:api_goodnames)
|
||||
end
|
||||
|
||||
def test_batch_transfer_succeeds
|
||||
body = { data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } }
|
||||
headers = { 'Content-type' => 'application/json' }
|
||||
request_stub = stub_request(:post, /domain_transfers/).with(body: body,
|
||||
headers: headers,
|
||||
basic_auth: ['test_goodnames', 'testtest'])
|
||||
.to_return(status: 204)
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Transfer'
|
||||
|
||||
click_on 'Batch'
|
||||
attach_file 'Batch file', Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_transfer.csv').to_s
|
||||
click_button 'Transfer batch'
|
||||
|
||||
assert_requested request_stub
|
||||
assert_current_path registrar_domains_path
|
||||
assert_text 'Domains have been successfully transferred'
|
||||
end
|
||||
|
||||
def test_batch_transfer_fails_gracefully
|
||||
body = { errors: [{ title: 'epic fail' }] }.to_json
|
||||
headers = { 'Content-type' => 'application/json' }
|
||||
stub_request(:post, /domain_transfers/).to_return(status: 400, body: body, headers: headers)
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Transfer'
|
||||
|
||||
click_on 'Batch'
|
||||
attach_file 'Batch file', Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_transfer.csv').to_s
|
||||
click_button 'Transfer batch'
|
||||
|
||||
assert_text 'epic fail'
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue