diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 79bef405c..6854b17dd 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -50,6 +50,10 @@ RSpec.configure do |config| DatabaseCleaner.strategy = :truncation end + config.before(:each, type: :request) do + DatabaseCleaner.strategy = :truncation + end + config.before(:each) do ActiveRecord::Base.establish_connection :api_log_test DatabaseCleaner.start diff --git a/spec/requests/contact_v1_spec.rb b/spec/requests/contact_v1_spec.rb index b4f830207..1f1741979 100644 --- a/spec/requests/contact_v1_spec.rb +++ b/spec/requests/contact_v1_spec.rb @@ -18,6 +18,16 @@ describe Repp::ContactV1 do # TODO: Maybe there is a way not to convert from and to json again expect(body['contacts'].to_json).to eq(epp_user.registrar.contacts.to_json) + + log = ApiLog::ReppLog.first + expect(log[:request_path]).to eq('/repp/v1/contacts') + expect(log[:request_method]).to eq('GET') + expect(log[:request_params]).to eq('{}') + expect(log[:response].length).to be > 20 + expect(log[:response_code]).to eq('200') + expect(log[:api_user_name]).to eq('gitlab') + expect(log[:api_user_registrar]).to eq('Registrar OÜ') + expect(log[:ip]).to eq('127.0.0.1') end end end diff --git a/spec/requests/domain_v1_spec.rb b/spec/requests/domain_v1_spec.rb index 898132823..0e362179a 100644 --- a/spec/requests/domain_v1_spec.rb +++ b/spec/requests/domain_v1_spec.rb @@ -17,6 +17,16 @@ describe Repp::DomainV1 do # TODO: Maybe there is a way not to convert from and to json again expect(body['domains'].to_json).to eq(epp_user.registrar.domains.to_json) + + log = ApiLog::ReppLog.first + expect(log[:request_path]).to eq('/repp/v1/domains') + expect(log[:request_method]).to eq('GET') + expect(log[:request_params]).to eq('{}') + expect(log[:response].length).to be > 20 + expect(log[:response_code]).to eq('200') + expect(log[:api_user_name]).to eq('gitlab') + expect(log[:api_user_registrar]).to eq('Registrar OÜ') + expect(log[:ip]).to eq('127.0.0.1') end end end