Db does not truncate between tests

This commit is contained in:
Martin Lensment 2015-01-23 18:44:59 +02:00
parent 79e64dc2ab
commit ea5c443ffb
3 changed files with 1404 additions and 1350 deletions

File diff suppressed because it is too large Load diff

View file

@ -34,8 +34,10 @@ RSpec.configure do |config|
config.before(:suite) do config.before(:suite) do
ActiveRecord::Base.establish_connection :api_log_test ActiveRecord::Base.establish_connection :api_log_test
DatabaseCleaner.strategy = :deletion DatabaseCleaner.strategy = :deletion
DatabaseCleaner.clean
ActiveRecord::Base.establish_connection :test ActiveRecord::Base.establish_connection :test
DatabaseCleaner.strategy = :truncation DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean
end end
config.before(:each) do config.before(:each) do
@ -54,21 +56,21 @@ RSpec.configure do |config|
DatabaseCleaner.strategy = :truncation DatabaseCleaner.strategy = :truncation
end end
config.before(:each) do # config.before(:each) do
ActiveRecord::Base.establish_connection :api_log_test # ActiveRecord::Base.establish_connection :api_log_test
DatabaseCleaner.start # DatabaseCleaner.start
ActiveRecord::Base.establish_connection :test # ActiveRecord::Base.establish_connection :test
DatabaseCleaner.start # DatabaseCleaner.start
end # end
config.after(:each) do # config.after(:each) do
ActiveRecord::Base.establish_connection :api_log_test # ActiveRecord::Base.establish_connection :api_log_test
DatabaseCleaner.clean # DatabaseCleaner.clean
ActiveRecord::Base.establish_connection :test # ActiveRecord::Base.establish_connection :test
DatabaseCleaner.clean # DatabaseCleaner.clean
end # end
Capybara.javascript_driver = :poltergeist Capybara.javascript_driver = :poltergeist

View file

@ -67,11 +67,15 @@ module Epp
puts r[:parsed].to_s puts r[:parsed].to_s
end end
def next_domain_name
"example#{@uniq_no.call}.ee"
end
### REQUEST TEMPLATES ### ### REQUEST TEMPLATES ###
def domain_info_xml(xml_params = {}) def domain_info_xml(xml_params = {})
defaults = { defaults = {
name: { value: 'example.ee', attrs: { hosts: 'all' } }, name: { value: next_domain_name, attrs: { hosts: 'all' } },
authInfo: { authInfo: {
pw: { value: '2fooBAR' } pw: { value: '2fooBAR' }
} }
@ -86,7 +90,7 @@ module Epp
# rubocop: disable Metrics/MethodLength # rubocop: disable Metrics/MethodLength
def domain_create_xml(xml_params = {}, dnssec_params = {}) def domain_create_xml(xml_params = {}, dnssec_params = {})
defaults = { defaults = {
name: { value: 'example.ee' }, name: { value: next_domain_name },
period: { value: '1', attrs: { unit: 'y' } }, period: { value: '1', attrs: { unit: 'y' } },
ns: [ ns: [
{ {
@ -102,7 +106,7 @@ module Epp
} }
} }
], ],
registrant: { value: 'jd1234' }, registrant: { value: 'citizen_1234' },
_anonymus: [ _anonymus: [
{ contact: { value: 'sh8013', attrs: { type: 'admin' } } }, { contact: { value: 'sh8013', attrs: { type: 'admin' } } },
{ contact: { value: 'sh8013', attrs: { type: 'tech' } } }, { contact: { value: 'sh8013', attrs: { type: 'tech' } } },
@ -138,11 +142,9 @@ module Epp
epp_xml.create(xml_params, dnssec_params, custom_params) epp_xml.create(xml_params, dnssec_params, custom_params)
end end
def domain_create_xml_with_legal_doc def domain_create_xml_with_legal_doc(xml_params = {})
epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345') defaults = {
name: { value: next_domain_name },
epp_xml.create({
name: { value: 'example.ee' },
period: { value: '1', attrs: { unit: 'y' } }, period: { value: '1', attrs: { unit: 'y' } },
ns: [ ns: [
{ {
@ -158,13 +160,19 @@ module Epp
} }
} }
], ],
registrant: { value: 'jd1234' }, registrant: { value: 'citizen_1234' },
_anonymus: [ _anonymus: [
{ contact: { value: 'sh8013', attrs: { type: 'admin' } } }, { contact: { value: 'sh8013', attrs: { type: 'admin' } } },
{ contact: { value: 'sh8013', attrs: { type: 'tech' } } }, { contact: { value: 'sh8013', attrs: { type: 'tech' } } },
{ contact: { value: 'sh801333', attrs: { type: 'tech' } } } { contact: { value: 'sh801333', attrs: { type: 'tech' } } }
] ]
}, {}, { }
xml_params = defaults.deep_merge(xml_params)
epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345')
epp_xml.create(xml_params, {}, {
_anonymus: [ _anonymus: [
legalDocument: { legalDocument: {
value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==', value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==',
@ -176,7 +184,7 @@ module Epp
def domain_create_with_invalid_ns_ip_xml def domain_create_with_invalid_ns_ip_xml
xml_params = { xml_params = {
name: { value: 'example.ee' }, name: { value: next_domain_name },
period: { value: '1', attrs: { unit: 'y' } }, period: { value: '1', attrs: { unit: 'y' } },
ns: [ ns: [
{ {
@ -192,7 +200,7 @@ module Epp
} }
} }
], ],
registrant: { value: 'jd1234' }, registrant: { value: 'citizen_1234' },
_anonymus: [ _anonymus: [
{ contact: { value: 'sh8013', attrs: { type: 'admin' } } }, { contact: { value: 'sh8013', attrs: { type: 'admin' } } },
{ contact: { value: 'sh8013', attrs: { type: 'tech' } } }, { contact: { value: 'sh8013', attrs: { type: 'tech' } } },
@ -220,7 +228,7 @@ module Epp
def domain_create_with_host_attrs def domain_create_with_host_attrs
xml_params = { xml_params = {
name: { value: 'example.ee' }, name: { value: next_domain_name },
period: { value: '1', attrs: { unit: 'y' } }, period: { value: '1', attrs: { unit: 'y' } },
ns: [ ns: [
{ {
@ -236,7 +244,7 @@ module Epp
} }
} }
], ],
registrant: { value: 'jd1234' }, registrant: { value: 'citizen_1234' },
_anonymus: [ _anonymus: [
{ contact: { value: 'sh8013', attrs: { type: 'admin' } } }, { contact: { value: 'sh8013', attrs: { type: 'admin' } } },
{ contact: { value: 'sh8013', attrs: { type: 'tech' } } }, { contact: { value: 'sh8013', attrs: { type: 'tech' } } },
@ -264,7 +272,7 @@ module Epp
def domain_update_xml(xml_params = {}, dnssec_params = {}, custom_params = {}) def domain_update_xml(xml_params = {}, dnssec_params = {}, custom_params = {})
defaults = { defaults = {
name: { value: 'example.ee' } name: { value: next_domain_name }
} }
xml_params = defaults.deep_merge(xml_params) xml_params = defaults.deep_merge(xml_params)
@ -275,7 +283,7 @@ module Epp
def domain_check_xml(xml_params = {}) def domain_check_xml(xml_params = {})
defaults = { defaults = {
_anonymus: [ _anonymus: [
{ name: { value: 'example.ee' } } { name: { value: next_domain_name } }
] ]
} }
xml_params = defaults.deep_merge(xml_params) xml_params = defaults.deep_merge(xml_params)
@ -285,9 +293,9 @@ module Epp
def domain_transfer_xml(xml_params = {}, op = 'query', custom_params = {}) def domain_transfer_xml(xml_params = {}, op = 'query', custom_params = {})
defaults = { defaults = {
name: { value: 'example.ee' }, name: { value: next_domain_name },
authInfo: { authInfo: {
pw: { value: '98oiewslkfkd', attrs: { roid: 'JD1234-REP' } } pw: { value: '98oiewslkfkd', attrs: { roid: 'citizen_1234-REP' } }
} }
} }