From 155cb812d93c50d82f9fe6b8e8f0f4faaa355062 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Tue, 27 Jan 2015 11:26:21 +0200 Subject: [PATCH] Updated spec and rails helper --- spec/epp/contact_spec.rb | 9 ++------ spec/epp/keyrelay_spec.rb | 3 --- spec/epp/poll_spec.rb | 1 + spec/models/contact_spec.rb | 5 +++++ spec/rails_helper.rb | 42 +++++++++++++++++++++---------------- 5 files changed, 32 insertions(+), 28 deletions(-) diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 8395fb3ef..a2a5f9cdb 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -2,9 +2,6 @@ require 'rails_helper' describe 'EPP Contact', epp: true do before :all do - DatabaseCleaner.clean_with(:truncation) - DatabaseCleaner.strategy = nil - Fabricate(:epp_user) Fabricate(:epp_user, username: 'registrar1', registrar: registrar1) Fabricate(:epp_user, username: 'registrar2', registrar: registrar2) @@ -82,11 +79,9 @@ describe 'EPP Contact', epp: true do log.length.should == 1 log[0].request_command.should == 'create' log[0].request_object.should == 'contact' - log[0].request_successful.should == 'true' - log[0].api_user_name.should == 'registrar1' + log[0].request_successful.should == true + log[0].api_user_name.should == 'gitlab' log[0].api_user_registrar.should == 'Registrar OÜ' - log[0].request.should be_blank - log[0].response.should be_blank end it 'successfully adds registrar' do diff --git a/spec/epp/keyrelay_spec.rb b/spec/epp/keyrelay_spec.rb index c9e730585..ab3f1693c 100644 --- a/spec/epp/keyrelay_spec.rb +++ b/spec/epp/keyrelay_spec.rb @@ -1,6 +1,5 @@ require 'rails_helper' - describe 'EPP Keyrelay', epp: true do let(:server_zone) { Epp::Server.new({ server: 'localhost', tag: 'zone', password: 'ghyt9e4fu', port: 701 }) } let(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) } @@ -9,8 +8,6 @@ describe 'EPP Keyrelay', epp: true do before(:each) { create_settings } before(:all) do - DatabaseCleaner.clean_with(:truncation) - DatabaseCleaner.strategy = nil @elkdata = Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) @zone = Fabricate(:registrar) Fabricate(:epp_user, username: 'zone', registrar: @zone) diff --git a/spec/epp/poll_spec.rb b/spec/epp/poll_spec.rb index a22659887..82186f17e 100644 --- a/spec/epp/poll_spec.rb +++ b/spec/epp/poll_spec.rb @@ -17,6 +17,7 @@ describe 'EPP Poll', epp: true do end it 'returns no messages in poll' do + ApiLog::EppLog.delete_all response = epp_request(epp_xml.poll, :xml) expect(response[:msg]).to eq('Command completed successfully; no messages') diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index d06b23525..daa6c4963 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -1,6 +1,11 @@ require 'rails_helper' describe Contact do + before :all do + # DatabaseCleaner.clean_with(:truncation) + # DatabaseCleaner.strategy = :transaction + end + before { create_disclosure_settings } it { should have_one(:address) } diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index ab4ef939b..403680d20 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -33,30 +33,36 @@ RSpec.configure do |config| config.before(:suite) do ActiveRecord::Base.establish_connection :api_log_test - DatabaseCleaner.strategy = :deletion + DatabaseCleaner.clean_with(:truncation) + DatabaseCleaner.strategy = nil + ActiveRecord::Base.establish_connection :test + end + + config.before(:all) do + DatabaseCleaner.clean_with(:truncation) + end + + config.before(:all, epp: true) do + DatabaseCleaner.strategy = nil + end + + config.before(:each, js: true) do DatabaseCleaner.strategy = :truncation end - # config.before(:each) do - # DatabaseCleaner.strategy = :transaction - # end + config.before(:each, type: :request) do + DatabaseCleaner.strategy = :truncation + end - # config.before(:all, epp: true) do - # ActiveRecord::Base.establish_connection :api_log_test - # DatabaseCleaner.clean + config.before(:each, type: :model) do + DatabaseCleaner.strategy = :transaction + DatabaseCleaner.start + end - # ActiveRecord::Base.establish_connection :test - # DatabaseCleaner.clean - # end - - # config.before(:each, js: true) do - # DatabaseCleaner.strategy = :truncation - # end - - # config.before(:each, type: :request) do - # DatabaseCleaner.strategy = :truncation - # end + config.after(:each, type: :model) do + DatabaseCleaner.clean + end Capybara.javascript_driver = :poltergeist