Change test structure to follow closer newer Rails 5 rules

* Create new class called ApplicationIntegrationTest, so we don't have
  to override ActionDispatch::IntegrationTest
* Move UI tests to inherit from ApplicationSystemTestCase
* Existing REST API or EPP tests inherit from
  ApplicationIntegrationTest.
* Move `require 'application_system_test_case'` at the end of
  `test_helper`

I don't particularly agree with the Rails' convention of treating UI
tests as system tests and API tests as integration tests, but I see no
benefit in actively fighting against it.
This commit is contained in:
Maciej Szlosarczyk 2018-07-27 09:36:27 +03:00
parent 311aa503b3
commit 526a9ccd58
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
41 changed files with 42 additions and 42 deletions

View file

@ -3,7 +3,7 @@ require 'test_helper'
require 'database_cleaner'
require 'selenium/webdriver'
class ApplicationSystemTestCase < ActionDispatch::IntegrationTest; end
ApplicationSystemTestCase = Class.new(ApplicationIntegrationTest)
class JavaScriptApplicationSystemTestCase < ApplicationSystemTestCase
self.use_transactional_fixtures = false

View file

@ -1,6 +1,6 @@
require 'test_helper'
class APIDomainContactsTest < ActionDispatch::IntegrationTest
class APIDomainContactsTest < ApplicationIntegrationTest
def test_replace_all_tech_contacts_of_the_current_registrar
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
new_contact_id: 'john-001' },

View file

@ -1,6 +1,6 @@
require 'test_helper'
class APIDomainTransfersTest < ActionDispatch::IntegrationTest
class APIDomainTransfersTest < ApplicationIntegrationTest
setup do
@domain = domains(:shop)
@new_registrar = registrars(:goodnames)

View file

@ -1,6 +1,6 @@
require 'test_helper'
class APINameserversPutTest < ActionDispatch::IntegrationTest
class APINameserversPutTest < ApplicationIntegrationTest
def test_replaces_registrar_nameservers
old_nameserver_ids = [nameservers(:shop_ns1).id,
nameservers(:airport_ns1).id,

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainCreateNameserversTest < ActionDispatch::IntegrationTest
class EppDomainCreateNameserversTest < ApplicationIntegrationTest
# Glue record requirement
def test_nameserver_ip_address_is_required_if_hostname_is_under_the_same_domain
request_xml = <<-XML

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainCreateTransferCodeTest < ActionDispatch::IntegrationTest
class EppDomainCreateTransferCodeTest < ApplicationIntegrationTest
setup do
travel_to Time.zone.parse('2010-07-05')
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainDeleteTest < ActionDispatch::IntegrationTest
class EppDomainDeleteTest < ApplicationIntegrationTest
def test_bypasses_domain_and_registrant_and_contacts_validation
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainRenewTest < ActionDispatch::IntegrationTest
class EppDomainRenewTest < ApplicationIntegrationTest
self.use_transactional_fixtures = false
setup do

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainUpdateTest < ActionDispatch::IntegrationTest
class EppDomainUpdateTest < ApplicationIntegrationTest
def test_update_domain
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainTransferBaseTest < ActionDispatch::IntegrationTest
class EppDomainTransferBaseTest < ApplicationIntegrationTest
def test_non_existent_domain
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainTransferQueryTest < ActionDispatch::IntegrationTest
class EppDomainTransferQueryTest < ApplicationIntegrationTest
def test_returns_domain_transfer_details
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
xml_doc = Nokogiri::XML(response.body)

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainTransferRequestTest < ActionDispatch::IntegrationTest
class EppDomainTransferRequestTest < ApplicationIntegrationTest
setup do
@domain = domains(:shop)
@new_registrar = registrars(:goodnames)

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppLoginCredentialsTest < ActionDispatch::IntegrationTest
class EppLoginCredentialsTest < ApplicationIntegrationTest
def test_correct_credentials
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppLoginSessionLimitTest < ActionDispatch::IntegrationTest
class EppLoginSessionLimitTest < ApplicationIntegrationTest
setup do
travel_to Time.zone.parse('2010-07-05')
EppSession.delete_all

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppLogoutTest < ActionDispatch::IntegrationTest
class EppLogoutTest < ApplicationIntegrationTest
def test_success_response
post '/epp/session/logout', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert Nokogiri::XML(response.body).at_css('result[code="1500"]')

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppPollTest < ActionDispatch::IntegrationTest
class EppPollTest < ApplicationIntegrationTest
def test_messages
post '/epp/command/poll', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_equal '1301', Nokogiri::XML(response.body).at_css('result')[:code]

View file

@ -1,6 +1,6 @@
require 'test_helper'
class ContactVersionsTest < ActionDispatch::IntegrationTest
class ContactVersionsTest < ApplicationSystemTestCase
def setup
super

View file

@ -1,6 +1,6 @@
require 'test_helper'
class AdminContactsTest < ActionDispatch::IntegrationTest
class AdminContactsTest < ApplicationSystemTestCase
def setup
super

View file

@ -1,6 +1,6 @@
require 'test_helper'
class DomainVersionsTest < ActionDispatch::IntegrationTest
class DomainVersionsTest < ApplicationSystemTestCase
def setup
super

View file

@ -1,6 +1,6 @@
require 'test_helper'
class AdminAreaDomainDetailsTest < ActionDispatch::IntegrationTest
class AdminAreaDomainDetailsTest < ApplicationSystemTestCase
setup do
sign_in users(:admin)
@domain = domains(:shop)

View file

@ -1,6 +1,6 @@
require 'test_helper'
class AdminAreaDomainForceDeleteTest < ActionDispatch::IntegrationTest
class AdminAreaDomainForceDeleteTest < ApplicationSystemTestCase
include ActionMailer::TestHelper
setup do

View file

@ -1,6 +1,6 @@
require 'test_helper'
class AdminDomainsTestTest < ActionDispatch::IntegrationTest
class AdminDomainsTestTest < ApplicationSystemTestCase
setup do
sign_in users(:admin)
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class AdminAreaNewMailTemplateTest < ActionDispatch::IntegrationTest
class AdminAreaNewMailTemplateTest < ApplicationSystemTestCase
setup do
sign_in users(:admin)
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class AdminAreaDeleteRegistrarTest < ActionDispatch::IntegrationTest
class AdminAreaDeleteRegistrarTest < ApplicationSystemTestCase
setup do
sign_in users(:admin)
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class AdminAreaRegistrarDetailsTest < ActionDispatch::IntegrationTest
class AdminAreaRegistrarDetailsTest < ApplicationSystemTestCase
include ActionView::Helpers::NumberHelper
setup do

View file

@ -1,6 +1,6 @@
require 'test_helper'
class AdminAreaEditRegistrarTest < ActionDispatch::IntegrationTest
class AdminAreaEditRegistrarTest < ApplicationSystemTestCase
setup do
sign_in users(:admin)
@registrar = registrars(:bestnames)

View file

@ -1,6 +1,6 @@
require 'test_helper'
class AdminAreaNewRegistrarTest < ActionDispatch::IntegrationTest
class AdminAreaNewRegistrarTest < ApplicationSystemTestCase
setup do
sign_in users(:admin)
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class RegistrantDomainsTest < ActionDispatch::IntegrationTest
class RegistrantDomainsTest < ApplicationSystemTestCase
setup do
sign_in users(:registrant)

View file

@ -1,6 +1,6 @@
require 'test_helper'
class RegistrantLayoutTest < ActionDispatch::IntegrationTest
class RegistrantLayoutTest < ApplicationSystemTestCase
def setup
super
sign_in(users(:registrant))

View file

@ -1,6 +1,6 @@
require 'test_helper'
class BalanceTopUpTest < ActionDispatch::IntegrationTest
class BalanceTopUpTest < ApplicationSystemTestCase
setup do
sign_in users(:api_bestnames)
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class RegistrarAreaBulkTransferTest < ActionDispatch::IntegrationTest
class RegistrarAreaBulkTransferTest < ApplicationSystemTestCase
setup do
sign_in users(:api_goodnames)
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class RegistrarAreaNameserverBulkChangeTest < ActionDispatch::IntegrationTest
class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
setup do
sign_in users(:api_goodnames)
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class RegistrarAreaTechContactBulkChangeTest < ActionDispatch::IntegrationTest
class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase
setup do
sign_in users(:api_bestnames)
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class RegistrarDomainsTest < ActionDispatch::IntegrationTest
class RegistrarDomainsTest < ApplicationSystemTestCase
def test_downloads_domain_list_as_csv
sign_in users(:api_bestnames)
travel_to Time.zone.parse('2010-07-05 10:30')

View file

@ -1,6 +1,6 @@
require 'test_helper'
class ListInvoicesTest < ActionDispatch::IntegrationTest
class ListInvoicesTest < ApplicationSystemTestCase
def setup
super

View file

@ -1,6 +1,6 @@
require 'test_helper'
class NewInvoicePaymentTest < ActionDispatch::IntegrationTest
class NewInvoicePaymentTest < ApplicationSystemTestCase
def setup
super

View file

@ -1,6 +1,6 @@
require 'test_helper'
class NewInvoiceTest < ActionDispatch::IntegrationTest
class NewInvoiceTest < ApplicationSystemTestCase
def setup
super

View file

@ -1,6 +1,6 @@
require 'test_helper'
class PaymentCallbackTest < ActionDispatch::IntegrationTest
class PaymentCallbackTest < ApplicationSystemTestCase
def setup
super

View file

@ -1,6 +1,6 @@
require 'test_helper'
class PaymentReturnTest < ActionDispatch::IntegrationTest
class PaymentReturnTest < ApplicationSystemTestCase
def setup
super

View file

@ -13,8 +13,6 @@ require 'capybara/minitest'
require 'webmock/minitest'
require 'support/rails5_assertions' # Remove once upgraded to Rails 5
require 'application_system_test_case'
Setting.address_processing = false
Setting.registry_country_code = 'US'
@ -29,7 +27,7 @@ class ActiveSupport::TestCase
end
end
class ActionDispatch::IntegrationTest
class ApplicationIntegrationTest < ActionDispatch::IntegrationTest
include Capybara::DSL
include Capybara::Minitest::Assertions
include AbstractController::Translation
@ -41,3 +39,5 @@ class ActionDispatch::IntegrationTest
Capybara.use_default_driver
end
end
require 'application_system_test_case'