require 'test_helper' class EppContactUpdateBaseTest < ActionDispatch::IntegrationTest setup do @contact = contacts(:john) end def test_updates_contact assert_equal 'john-001', @contact.code assert_not_equal 'new name', @contact.name assert_not_equal 'new-email@inbox.test', @contact.email assert_not_equal '+123.4', @contact.phone # https://github.com/internetee/registry/issues/415 @contact.update_columns(code: @contact.code.upcase) request_xml = <<-XML john-001 new name +123.4 new-email@inbox.test XML post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' @contact.reload response_xml = Nokogiri::XML(response.body) assert_equal '1000', response_xml.at_css('result')[:code] assert_equal 1, response_xml.css('result').size assert_equal 'new name', @contact.name assert_equal 'new-email@inbox.test', @contact.email assert_equal '+123.4', @contact.phone end def test_non_existing_contact assert_nil Contact.find_by(code: 'non-existing') request_xml = <<-XML non-existing any XML post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' response_xml = Nokogiri::XML(response.body) assert_equal '2303', response_xml.at_css('result')[:code] end end