diff --git a/app/controllers/admin/zonefiles_controller.rb b/app/controllers/admin/zonefiles_controller.rb index 7a4e4b414..30b4b9a61 100644 --- a/app/controllers/admin/zonefiles_controller.rb +++ b/app/controllers/admin/zonefiles_controller.rb @@ -4,7 +4,7 @@ module Admin # TODO: Refactor this def create - if DNS::Zone.origins.include?(params[:origin]) + if ::DNS::Zone.origins.include?(params[:origin]) @zonefile = ActiveRecord::Base.connection.execute( "select generate_zonefile('#{params[:origin]}')" diff --git a/config/environments/test.rb b/config/environments/test.rb index 1220a8d42..df9ab2bbf 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -5,12 +5,12 @@ Rails.application.configure do # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! - config.cache_classes = false + config.cache_classes = true # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. - config.eager_load = false + config.eager_load = true # Configure static asset server for tests with Cache-Control for performance. config.serve_static_files = true @@ -41,25 +41,6 @@ Rails.application.configure do # The available log levels are: :debug, :info, :warn, :error, :fatal, and :unknown, # corresponding to the log level numbers from 0 up to 5 respectively config.log_level = :debug - - # for finding database optimization - config.after_initialize do - Bullet.enable = true - Bullet.bullet_logger = true - Bullet.rails_logger = true - Bullet.raise = false # raise an error if n+1 query occurs - Bullet.unused_eager_loading_enable = false - - # Currenty hard to fix, it is triggered by Epp::Domain.new_from_epp for create request - Bullet.add_whitelist type: :n_plus_one_query, class_name: 'Contact', association: :registrar - - # when domain updates, then we need to update all contact linked status, - # somehow it triggers bullet counter cache for versions, - # there was no output indicating each version where fetched or counted - # thus needs more investigation - Bullet.add_whitelist type: :counter_cache, class_name: 'Contact', association: :versions - end - config.active_job.queue_adapter = :test config.logger = ActiveSupport::Logger.new(nil) end diff --git a/spec/requests/admin/zonefiles/create_spec.rb b/spec/requests/admin/zonefiles/create_spec.rb new file mode 100644 index 000000000..e9dfb62c8 --- /dev/null +++ b/spec/requests/admin/zonefiles/create_spec.rb @@ -0,0 +1,14 @@ +require 'rails_helper' + +RSpec.describe 'Admin area zone file generation', settings: false do + let!(:zone) { create(:zone, origin: 'com') } + + before do + sign_in_to_admin_area + end + + it 'generates new' do + post admin_zonefiles_path(origin: 'com') + expect(response).to be_success + end +end