require 'test_helper'
class EppDomainCreateTransferCodeTest < ActionDispatch::IntegrationTest
def setup
travel_to Time.zone.parse('2010-07-05')
end
def test_generates_default
request_xml = <<-XML
brandnew.test
1
john-001
#{'test' * 2000}
XML
post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
refute_empty Domain.find_by(name: 'brandnew.test').transfer_code
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
end
def test_honors_custom
request_xml = <<-XML
brandnew.test
1
john-001
1058ad73
#{'test' * 2000}
XML
post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_equal '1058ad73', Domain.find_by(name: 'brandnew.test').transfer_code
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
end
end