Merge pull request #809 from internetee/tune-test-env

Tune test env
This commit is contained in:
Timo Võhmar 2018-04-11 15:49:29 +03:00 committed by GitHub
commit df741f133f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 51 additions and 41 deletions

View file

@ -43,6 +43,7 @@ Rails.application.configure do
config.log_level = :debug
config.active_job.queue_adapter = :test
config.logger = ActiveSupport::Logger.new(nil)
config.active_support.test_order = :random # :random is the default in Rails 5
end
# In this mode, any jobs you queue will be run in the same thread, synchronously

View file

@ -3,7 +3,7 @@ require 'test_helper'
class AdminAreaDomainForceDeleteTest < ActionDispatch::IntegrationTest
include ActionMailer::TestHelper
def setup
setup do
login_as users(:admin)
@domain = domains(:shop)
ActionMailer::Base.deliveries.clear

View file

@ -1,7 +1,7 @@
require 'test_helper'
class AdminDomainsTestTest < ActionDispatch::IntegrationTest
def setup
setup do
login_as users(:admin)
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class AdminAreaDeleteRegistrarTest < ActionDispatch::IntegrationTest
def setup
setup do
login_as users(:admin)
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class AdminAreaEditRegistrarTest < ActionDispatch::IntegrationTest
def setup
setup do
login_as users(:admin)
@registrar = registrars(:bestnames)
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class AdminAreaNewRegistrarTest < ActionDispatch::IntegrationTest
def setup
setup do
login_as users(:admin)
end

View file

@ -3,7 +3,7 @@ require 'test_helper'
class ShowRegistrarTest < ActionDispatch::IntegrationTest
include ActionView::Helpers::NumberHelper
def setup
setup do
login_as users(:admin)
@registrar = registrars(:bestnames)
visit admin_registrar_path(@registrar)

View file

@ -1,7 +1,7 @@
require 'test_helper'
class APIDomainTransfersTest < ActionDispatch::IntegrationTest
def setup
setup do
@domain = domains(:shop)
@new_registrar = registrars(:goodnames)
Setting.transfer_wait_time = 0 # Auto-approval

View file

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

View file

@ -3,7 +3,7 @@ require 'test_helper'
class EppDomainRenewTest < ActionDispatch::IntegrationTest
self.use_transactional_fixtures = false
def setup
setup do
travel_to Time.zone.parse('2010-07-05')
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class EppDomainTransferRequestTest < ActionDispatch::IntegrationTest
def setup
setup do
@domain = domains(:shop)
@new_registrar = registrars(:goodnames)
Setting.transfer_wait_time = 0

View file

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

View file

@ -1,7 +1,7 @@
require 'test_helper'
class RegistrantDomainsTest < ActionDispatch::IntegrationTest
def setup
setup do
login_as users(:registrant)
Setting.days_to_keep_business_registry_cache = 1

View file

@ -1,7 +1,7 @@
require 'test_helper'
class RegistrarDomainTransfersTest < ActionDispatch::IntegrationTest
def setup
setup do
WebMock.reset!
login_as users(:api_goodnames)
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class RegistrarNameserverReplacementTest < ActionDispatch::IntegrationTest
def setup
setup do
WebMock.reset!
login_as users(:api_goodnames)
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class ContactTest < ActiveSupport::TestCase
def setup
setup do
@contact = contacts(:john)
end

View file

@ -12,11 +12,16 @@ class ContactIdenticalTest < ActiveSupport::TestCase
org_name
]
def setup
setup do
@original_address_processing = Setting.address_processing
@contact = contacts(:william)
@identical = contacts(:identical_to_william)
end
teardown do
Setting.address_processing = @original_address_processing
end
def test_returns_identical
assert_equal @identical, @contact.identical(@identical.registrar)
end
@ -33,30 +38,24 @@ class ContactIdenticalTest < ActiveSupport::TestCase
assert_nil @contact.identical(@identical.registrar)
end
def test_takes_address_into_account_when_processing_enabled
def test_takes_address_into_account_when_address_processing_is_on
Setting.address_processing = true
Contact.address_attribute_names.each do |attribute|
previous_value = @identical.public_send(attribute)
@identical.update_attribute(attribute, 'other')
Contact.stub :address_processing?, true do
assert_nil @contact.identical(@identical.registrar)
end
assert_nil @contact.identical(@identical.registrar)
@identical.update_attribute(attribute, previous_value)
end
end
def test_ignores_address_when_processing_disabled
def test_ignores_address_when_address_processing_is_off
Setting.address_processing = false
Contact.address_attribute_names.each do |attribute|
previous_value = @identical.public_send(attribute)
@identical.update_attribute(attribute, 'other')
Contact.stub :address_processing?, false do
assert_equal @identical, @contact.identical(@identical.registrar)
end
assert_equal @identical, @contact.identical(@identical.registrar)
@identical.update_attribute(attribute, previous_value)
end
end

View file

@ -1,10 +1,15 @@
require 'test_helper'
class ContactPostalAddressTest < ActiveSupport::TestCase
def setup
setup do
@original_address_processing = Setting.address_processing
@contact = contacts(:john)
end
teardown do
Setting.address_processing = @original_address_processing
end
def test_invalid_if_country_code_is_invalid_and_address_processing_is_on
Setting.address_processing = true
@contact.country_code = 'invalid'

View file

@ -1,7 +1,7 @@
require 'test_helper'
class ContactTransferTest < ActiveSupport::TestCase
def setup
setup do
@contact = contacts(:john)
@new_registrar = registrars(:goodnames)
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class DomainTest < ActiveSupport::TestCase
def setup
setup do
@domain = domains(:shop)
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class DomainTransferableTest < ActiveSupport::TestCase
def setup
setup do
@domain = domains(:shop)
@new_registrar = registrars(:goodnames)
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class DomainTransferTest < ActiveSupport::TestCase
def setup
setup do
@domain_transfer = domain_transfers(:shop)
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class EppSessionTest < ActiveSupport::TestCase
def setup
setup do
@epp_session = epp_sessions(:api_bestnames)
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class MessageTest < ActiveSupport::TestCase
def setup
setup do
@message = messages(:greeting)
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class NameserverGlueRecordTest < ActiveSupport::TestCase
def setup
setup do
@nameserver = nameservers(:shop_ns1)
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class NameserverTest < ActiveSupport::TestCase
def setup
setup do
@nameserver = nameservers(:shop_ns1)
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class RegistrarCodeTest < ActiveSupport::TestCase
def setup
setup do
@registrar = registrars(:bestnames).dup
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class DeleteRegistrarTest < ActiveSupport::TestCase
def setup
setup do
@registrar = registrars(:not_in_use)
end

View file

@ -1,7 +1,7 @@
require 'test_helper'
class RegistrarTest < ActiveSupport::TestCase
def setup
setup do
@registrar = registrars(:bestnames)
end

View file

@ -20,6 +20,10 @@ class ActiveSupport::TestCase
ActiveRecord::Migration.check_pending!
fixtures :all
teardown do
travel_back
end
end
class ActionDispatch::IntegrationTest
@ -28,8 +32,9 @@ class ActionDispatch::IntegrationTest
include Capybara::Minitest::Assertions
include AbstractController::Translation
def teardown
teardown do
Warden.test_reset!
WebMock.reset!
Capybara.reset_sessions!
Capybara.use_default_driver
end