From b05e8ae5744bd5f562cd4bd4b2daa73976230ceb Mon Sep 17 00:00:00 2001 From: ricoch Date: Thu, 1 Oct 2020 15:30:08 -0300 Subject: [PATCH 01/17] Add .rspec file --- .rspec | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .rspec diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..34c5164 --- /dev/null +++ b/.rspec @@ -0,0 +1,3 @@ +--format documentation +--color +--require spec_helper From f8d47be737d336804f62c68485f4e263b01087bc Mon Sep 17 00:00:00 2001 From: ricoch Date: Thu, 1 Oct 2020 15:30:57 -0300 Subject: [PATCH 02/17] Add timecop --- activeadmin-async_exporter.gemspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/activeadmin-async_exporter.gemspec b/activeadmin-async_exporter.gemspec index d4020dd..d93b9a8 100644 --- a/activeadmin-async_exporter.gemspec +++ b/activeadmin-async_exporter.gemspec @@ -23,10 +23,11 @@ Gem::Specification.new do |s| s.add_dependency 'rails', '>= 1.0.0' # Development dependencies + s.add_development_dependency 'pry-rails', '~> 0.3.9' s.add_development_dependency 'rspec', '~> 3.9.0' s.add_development_dependency 'rubocop-rails', '~> 2.3' s.add_development_dependency 'rubocop-rootstrap', '~> 0.1.0' s.add_development_dependency 'simplecov', '~> 0.17.1' s.add_development_dependency 'sqlite3', '1.4.1' - s.add_development_dependency 'pry-rails' + s.add_development_dependency 'timecop', '~> 0.9.1' end From 126307c347463fa5c09b6b5ce2aff75dca6a5b32 Mon Sep 17 00:00:00 2001 From: ricoch Date: Thu, 1 Oct 2020 15:31:50 -0300 Subject: [PATCH 03/17] Configure local csv file path --- lib/active_admin/async_exporter/config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_admin/async_exporter/config.rb b/lib/active_admin/async_exporter/config.rb index 854a8df..bc616d7 100644 --- a/lib/active_admin/async_exporter/config.rb +++ b/lib/active_admin/async_exporter/config.rb @@ -18,7 +18,7 @@ class Config def initialize @aws_bucket_name = nil @aws_bucket_folder_path = nil - @disk_folder_path = nil + @disk_folder_path = './csv' end end end From 7b56b77091e6fb98ff0f5fa8a80ae587a7eeb2d5 Mon Sep 17 00:00:00 2001 From: ricoch Date: Thu, 1 Oct 2020 15:32:12 -0300 Subject: [PATCH 04/17] Setup spec_helper --- spec/spec_helper.rb | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 198ab85..b2b7026 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,26 @@ # frozen_string_literal: true -require 'bundler/setup' -require 'activeadmin-async_exporter' +ENV['RAILS_ENV'] ||= 'test' +require 'dummy/config/environment.rb' +require 'pry' +require 'active_admin' +require 'timecop' + +require 'simplecov' +SimpleCov.start + +Rails.application.routes.default_url_options[:host] = 'localhost:3000' + +require 'tmpdir' +ActiveStorage::Blob.service = + ActiveStorage::Service::DiskService.new(root: Dir.mktmpdir('active_storage_tests')) + +ActiveRecord::Base.establish_connection( + adapter: 'sqlite3', + database: ':memory:' +) + +load 'dummy/db/schema.rb' require 'simplecov' SimpleCov.start @@ -17,3 +36,4 @@ c.syntax = :expect end end + From d9f810170b9ee03492692761088aeb61903bd374 Mon Sep 17 00:00:00 2001 From: ricoch Date: Thu, 1 Oct 2020 15:32:30 -0300 Subject: [PATCH 05/17] Add user --- .../db/migrate/20200925172213_create_user.rb | 7 +++++ spec/dummy/db/schema.rb | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 spec/dummy/db/migrate/20200925172213_create_user.rb create mode 100644 spec/dummy/db/schema.rb diff --git a/spec/dummy/db/migrate/20200925172213_create_user.rb b/spec/dummy/db/migrate/20200925172213_create_user.rb new file mode 100644 index 0000000..ac162f2 --- /dev/null +++ b/spec/dummy/db/migrate/20200925172213_create_user.rb @@ -0,0 +1,7 @@ +class CreateUser < ActiveRecord::Migration[5.2] + def change + create_table :users do |t| + t.string :username, null: false + end + end +end diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb new file mode 100644 index 0000000..b151eb5 --- /dev/null +++ b/spec/dummy/db/schema.rb @@ -0,0 +1,30 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_09_25_172213) do + + create_table "admin_reports", force: :cascade do |t| + t.integer "author_id" + t.string "entity", null: false + t.string "format", default: "csv", null: false + t.integer "status", null: false + t.string "location_url" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["author_id"], name: "index_admin_reports_on_author_id" + end + + create_table "users", force: :cascade do |t| + t.string "username", null: false + end + +end From 884585f90a0548b388ddbb11c841b3216ba32edc Mon Sep 17 00:00:00 2001 From: ricoch Date: Thu, 1 Oct 2020 15:32:59 -0300 Subject: [PATCH 06/17] Update gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index f641c69..bb38e0b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,9 @@ Gemfile.lock *.gem +.rspec_status +/coverage/ /spec/dummy/log/ /spec/dummy/tmp/ +/spec/dummy/csv/ +/spec/dummy/db/development.sqlite3 +/spec/dummy/db/test.sqlite3 From f39b23de4c5a3c54c1c97c911fa5db85b942c377 Mon Sep 17 00:00:00 2001 From: ricoch Date: Thu, 1 Oct 2020 15:33:16 -0300 Subject: [PATCH 07/17] Add file fixtures --- spec/fixtures/files/block.csv | 5 +++++ spec/fixtures/files/username.csv | 5 +++++ spec/fixtures/files/username_and_block.csv | 5 +++++ 3 files changed, 15 insertions(+) create mode 100644 spec/fixtures/files/block.csv create mode 100644 spec/fixtures/files/username.csv create mode 100644 spec/fixtures/files/username_and_block.csv diff --git a/spec/fixtures/files/block.csv b/spec/fixtures/files/block.csv new file mode 100644 index 0000000..406399e --- /dev/null +++ b/spec/fixtures/files/block.csv @@ -0,0 +1,5 @@ +test_block +The username is: user_1 +The username is: user_2 +The username is: user_3 +The username is: AdminUser diff --git a/spec/fixtures/files/username.csv b/spec/fixtures/files/username.csv new file mode 100644 index 0000000..db64234 --- /dev/null +++ b/spec/fixtures/files/username.csv @@ -0,0 +1,5 @@ +username +user_1 +user_2 +user_3 +AdminUser diff --git a/spec/fixtures/files/username_and_block.csv b/spec/fixtures/files/username_and_block.csv new file mode 100644 index 0000000..e0b022b --- /dev/null +++ b/spec/fixtures/files/username_and_block.csv @@ -0,0 +1,5 @@ +username,test_block +user_1,The username is: user_1 +user_2,The username is: user_2 +user_3,The username is: user_3 +AdminUser,The username is: AdminUser From 7cfaa57c174f9fc39d6192bb6dd7384e2cfa1557 Mon Sep 17 00:00:00 2001 From: ricoch Date: Thu, 1 Oct 2020 15:33:35 -0300 Subject: [PATCH 08/17] Add successful worker tests --- .rubocop.yml | 8 + .../async_exporter/reports/worker.rb | 2 + spec/worker_spec.rb | 139 ++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 spec/worker_spec.rb diff --git a/.rubocop.yml b/.rubocop.yml index ff25bf7..fc7bac6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -30,3 +30,11 @@ Naming/FileName: Style/EvalWithLocation: Exclude: - lib/active_admin/async_exporter/reports/worker.rb + +Style/StringLiterals: + Exclude: + - spec/dummy/db/schema.rb + +Style/NumericLiterals: + Exclude: + - spec/dummy/db/schema.rb diff --git a/lib/active_admin/async_exporter/reports/worker.rb b/lib/active_admin/async_exporter/reports/worker.rb index c60cae1..c76ede2 100644 --- a/lib/active_admin/async_exporter/reports/worker.rb +++ b/lib/active_admin/async_exporter/reports/worker.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'pry' + module ActiveAdmin module AsyncExporter class Worker < ApplicationJob diff --git a/spec/worker_spec.rb b/spec/worker_spec.rb new file mode 100644 index 0000000..32874bc --- /dev/null +++ b/spec/worker_spec.rb @@ -0,0 +1,139 @@ +RSpec.describe ActiveAdmin::AsyncExporter::Worker do + let!(:users) do + ['user_1', 'user_2', 'user_3'].map do |username| + User.find_or_create_by!(username: username) + end + end + let(:controller) { Admin::UsersController.new } + let(:decorate_model) { false } + let(:file_name) { 'file_name' } + let(:query) { nil } + let(:csv_path) { './csv' } + let(:admin) { User.find_or_create_by!(username: 'AdminUser') } + let(:csv_fixture_file_path) { "./spec/fixtures/files/#{csv_fixture_file_name}.csv" } + let(:csv_fixture_file_name) { 'username' } + + let(:admin_report) do + AdminReport.create!(author_id: admin.id, + entity: User.name, + status: :pending) + end + + let(:columns) { { username: { block: false, value: "username" } } } + + let(:options) do + { + admin_report_id: admin_report.id, + controller: controller.class.name, + columns: columns, + decorate_model: decorate_model, + file_name: file_name, + query: query + } + end + + subject do + described_class.perform_now(options) + end + + context 'with valid options' do + let(:test_date) { Time.current } + let(:full_file_name) { [file_name, test_date.to_i].join('_') + '.csv' } + let(:file_path) { "#{csv_path}/#{full_file_name}" } + + before do + Timecop.freeze(test_date) + end + + after do + FileUtils.rm(file_path) + Timecop.return + end + + shared_examples 'creates the physical file with data' do + it 'creates the physical file at the given location_url' do + subject + expect(File.open(admin_report.reload.location_url)).to be + end + + it 'physical path is the expected' do + subject + expect(admin_report.reload.location_url).to eq(file_path) + end + + it 'physical file contains data' do + subject + expect(File.open(admin_report.reload.location_url).read).to be + end + + it 'generated csv file contains the expected results' do + subject + + generated_file_data = File.open(admin_report.reload.location_url).read + + expect(File.open(csv_fixture_file_path).read).to eq(generated_file_data) + end + end + + it 'changes admin_report status to ready' do + expect { subject }.to change { admin_report.reload.status }.from('pending').to('ready') + end + + it 'changes admin_report location_url' do + expect { subject }.to change { admin_report.reload.location_url } + end + + context 'when the file_name is given' do + it 'full file name is the correct file name' do + subject + expect(admin_report.reload.location_url.split('/').last).to eq(full_file_name) + end + + it_behaves_like 'creates the physical file with data' + end + + context 'when the file_name is not given' do + let(:file_name) { nil } + let(:full_file_name) do + [controller.current_collection.name.pluralize.downcase, test_date.to_i].join('_') + '.csv' + end + + it 'full file name is the correct file name' do + subject + expect(admin_report.reload.location_url.split('/').last).to eq(full_file_name) + end + + it_behaves_like 'creates the physical file with data' + end + + context 'when the column is an attribute' do + it_behaves_like 'creates the physical file with data' + end + + context 'when the column is a block' do + let(:block) do + Proc.new { |user| "The username is: #{user.username}" } + end + let(:csv_fixture_file_name) { 'block' } + let(:columns) { { test_block: { block: true, value: block.source } } } + + it_behaves_like 'creates the physical file with data' + end + + context 'when we have multiple columns' do + let(:block) do + Proc.new { |user| "The username is: #{user.username}" } + end + + let(:csv_fixture_file_name) { 'username_and_block' } + let(:columns) do + { + username: { block: false, value: 'username' }, + test_block: { block: true, value: block.source } + } + end + + it_behaves_like 'creates the physical file with data' + end + end +end From 5401d2bd804ed202ca268dfb6aba916668050166 Mon Sep 17 00:00:00 2001 From: ricoch Date: Thu, 1 Oct 2020 15:36:26 -0300 Subject: [PATCH 09/17] Fix rubocop issues --- .rubocop.yml | 4 ++++ spec/spec_helper.rb | 1 - spec/worker_spec.rb | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index fc7bac6..f424edc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -38,3 +38,7 @@ Style/StringLiterals: Style/NumericLiterals: Exclude: - spec/dummy/db/schema.rb + +Layout/EmptyLinesAroundBlockBody: + Exclude: + - spec/dummy/db/schema.rb diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b2b7026..d0c488f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -36,4 +36,3 @@ c.syntax = :expect end end - diff --git a/spec/worker_spec.rb b/spec/worker_spec.rb index 32874bc..ab05dfb 100644 --- a/spec/worker_spec.rb +++ b/spec/worker_spec.rb @@ -1,6 +1,6 @@ RSpec.describe ActiveAdmin::AsyncExporter::Worker do let!(:users) do - ['user_1', 'user_2', 'user_3'].map do |username| + %w[user_1 user_2 user_3].map do |username| User.find_or_create_by!(username: username) end end @@ -19,7 +19,7 @@ status: :pending) end - let(:columns) { { username: { block: false, value: "username" } } } + let(:columns) { { username: { block: false, value: 'username' } } } let(:options) do { @@ -112,7 +112,7 @@ context 'when the column is a block' do let(:block) do - Proc.new { |user| "The username is: #{user.username}" } + proc { |user| "The username is: #{user.username}" } end let(:csv_fixture_file_name) { 'block' } let(:columns) { { test_block: { block: true, value: block.source } } } @@ -122,7 +122,7 @@ context 'when we have multiple columns' do let(:block) do - Proc.new { |user| "The username is: #{user.username}" } + proc { |user| "The username is: #{user.username}" } end let(:csv_fixture_file_name) { 'username_and_block' } From 66d829c259bdfb40fea3e8a35e6281a64ba662f6 Mon Sep 17 00:00:00 2001 From: ricoch Date: Fri, 16 Oct 2020 14:57:40 -0300 Subject: [PATCH 10/17] Replace timecop with activesupport test helpers --- activeadmin-async_exporter.gemspec | 1 - spec/spec_helper.rb | 2 +- spec/support/time_helpers.rb | 5 +++++ spec/worker_spec.rb | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 spec/support/time_helpers.rb diff --git a/activeadmin-async_exporter.gemspec b/activeadmin-async_exporter.gemspec index d93b9a8..a348748 100644 --- a/activeadmin-async_exporter.gemspec +++ b/activeadmin-async_exporter.gemspec @@ -29,5 +29,4 @@ Gem::Specification.new do |s| s.add_development_dependency 'rubocop-rootstrap', '~> 0.1.0' s.add_development_dependency 'simplecov', '~> 0.17.1' s.add_development_dependency 'sqlite3', '1.4.1' - s.add_development_dependency 'timecop', '~> 0.9.1' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d0c488f..ab6a350 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,7 +4,7 @@ require 'dummy/config/environment.rb' require 'pry' require 'active_admin' -require 'timecop' +require 'support/time_helpers.rb' require 'simplecov' SimpleCov.start diff --git a/spec/support/time_helpers.rb b/spec/support/time_helpers.rb new file mode 100644 index 0000000..5fbf28e --- /dev/null +++ b/spec/support/time_helpers.rb @@ -0,0 +1,5 @@ +require 'active_support/testing/time_helpers' + +RSpec.configure do |config| + config.include ActiveSupport::Testing::TimeHelpers +end diff --git a/spec/worker_spec.rb b/spec/worker_spec.rb index ab05dfb..7f01cc5 100644 --- a/spec/worker_spec.rb +++ b/spec/worker_spec.rb @@ -42,12 +42,12 @@ let(:file_path) { "#{csv_path}/#{full_file_name}" } before do - Timecop.freeze(test_date) + travel_to(test_date) end after do FileUtils.rm(file_path) - Timecop.return + travel_back end shared_examples 'creates the physical file with data' do From 032d7243d5a8b8da464b711c8996bc3639e97cda Mon Sep 17 00:00:00 2001 From: ricoch Date: Fri, 16 Oct 2020 14:57:58 -0300 Subject: [PATCH 11/17] Fix deprecation warning on update_attributes --- lib/active_admin/async_exporter/reports/worker.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_admin/async_exporter/reports/worker.rb b/lib/active_admin/async_exporter/reports/worker.rb index c76ede2..07a2ac5 100644 --- a/lib/active_admin/async_exporter/reports/worker.rb +++ b/lib/active_admin/async_exporter/reports/worker.rb @@ -17,7 +17,7 @@ def perform(options = {}) end file = Services::StorageService.call(path: path, name: file_name).store - AdminReport.find(options[:admin_report_id]).update_attributes!( + AdminReport.find(options[:admin_report_id]).update!( status: :ready, location_url: file.url ) From ba857ef2ff338b94b28fbaf324a0852b1569a60e Mon Sep 17 00:00:00 2001 From: Ricoch <42209955+Ricoch@users.noreply.github.com> Date: Fri, 16 Oct 2020 15:00:27 -0300 Subject: [PATCH 12/17] Update csv folder location and name Co-authored-by: Juan Manuel Ramallo --- lib/active_admin/async_exporter/config.rb | 2 +- spec/worker_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/active_admin/async_exporter/config.rb b/lib/active_admin/async_exporter/config.rb index bc616d7..d50ae0d 100644 --- a/lib/active_admin/async_exporter/config.rb +++ b/lib/active_admin/async_exporter/config.rb @@ -18,7 +18,7 @@ class Config def initialize @aws_bucket_name = nil @aws_bucket_folder_path = nil - @disk_folder_path = './csv' + @disk_folder_path = Rails.root.join('tmp/activeadmin-async_exporter') end end end diff --git a/spec/worker_spec.rb b/spec/worker_spec.rb index 7f01cc5..bf8f452 100644 --- a/spec/worker_spec.rb +++ b/spec/worker_spec.rb @@ -8,7 +8,7 @@ let(:decorate_model) { false } let(:file_name) { 'file_name' } let(:query) { nil } - let(:csv_path) { './csv' } + let(:csv_path) { Rails.root.join('tmp/activeadmin-async_exporter') } let(:admin) { User.find_or_create_by!(username: 'AdminUser') } let(:csv_fixture_file_path) { "./spec/fixtures/files/#{csv_fixture_file_name}.csv" } let(:csv_fixture_file_name) { 'username' } From 920790295cd1cff8cfff6e6e3d27a349f74a4d8e Mon Sep 17 00:00:00 2001 From: ricoch Date: Fri, 16 Oct 2020 15:22:31 -0300 Subject: [PATCH 13/17] Remove ActiveStorage::Blob.service from spec_helper --- spec/spec_helper.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ab6a350..70b6189 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,8 +12,6 @@ Rails.application.routes.default_url_options[:host] = 'localhost:3000' require 'tmpdir' -ActiveStorage::Blob.service = - ActiveStorage::Service::DiskService.new(root: Dir.mktmpdir('active_storage_tests')) ActiveRecord::Base.establish_connection( adapter: 'sqlite3', From e98fd6ffe8cd88b0d6c343deae2d131d8cfe5894 Mon Sep 17 00:00:00 2001 From: ricoch Date: Fri, 16 Oct 2020 15:22:41 -0300 Subject: [PATCH 14/17] Fix tests --- spec/worker_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/worker_spec.rb b/spec/worker_spec.rb index bf8f452..c02d746 100644 --- a/spec/worker_spec.rb +++ b/spec/worker_spec.rb @@ -52,6 +52,7 @@ shared_examples 'creates the physical file with data' do it 'creates the physical file at the given location_url' do + expect { File.open(admin_report.reload.location_url.to_s) }.to raise_exception(Errno::ENOENT) subject expect(File.open(admin_report.reload.location_url)).to be end @@ -80,7 +81,7 @@ end it 'changes admin_report location_url' do - expect { subject }.to change { admin_report.reload.location_url } + expect { subject }.to change { admin_report.reload.location_url }.from(nil).to(file_path) end context 'when the file_name is given' do From b8a50171201a77c5b18b0e38b13a85d3c304b2ec Mon Sep 17 00:00:00 2001 From: ricoch Date: Fri, 16 Oct 2020 16:03:37 -0300 Subject: [PATCH 15/17] Move pry requirement --- lib/active_admin/async_exporter/reports/worker.rb | 2 -- spec/dummy/config/application.rb | 1 + spec/spec_helper.rb | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/active_admin/async_exporter/reports/worker.rb b/lib/active_admin/async_exporter/reports/worker.rb index 07a2ac5..d2d82f1 100644 --- a/lib/active_admin/async_exporter/reports/worker.rb +++ b/lib/active_admin/async_exporter/reports/worker.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'pry' - module ActiveAdmin module AsyncExporter class Worker < ApplicationJob diff --git a/spec/dummy/config/application.rb b/spec/dummy/config/application.rb index 499e4fe..e9bb31e 100644 --- a/spec/dummy/config/application.rb +++ b/spec/dummy/config/application.rb @@ -10,6 +10,7 @@ require 'action_view/railtie' require 'sprockets/railtie' require 'active_storage/engine' +require 'pry' Bundler.require(*Rails.groups) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 70b6189..5cb1f8c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,7 +2,6 @@ ENV['RAILS_ENV'] ||= 'test' require 'dummy/config/environment.rb' -require 'pry' require 'active_admin' require 'support/time_helpers.rb' From 62bca0d31b036525509834578e4dcfb16e9f2b23 Mon Sep 17 00:00:00 2001 From: ricoch Date: Mon, 19 Oct 2020 12:35:55 -0300 Subject: [PATCH 16/17] Fix code analysis --- spec/worker_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/worker_spec.rb b/spec/worker_spec.rb index c02d746..3ef6cb9 100644 --- a/spec/worker_spec.rb +++ b/spec/worker_spec.rb @@ -52,7 +52,7 @@ shared_examples 'creates the physical file with data' do it 'creates the physical file at the given location_url' do - expect { File.open(admin_report.reload.location_url.to_s) }.to raise_exception(Errno::ENOENT) + expect { File.open(admin_report.location_url.to_s) }.to raise_exception(Errno::ENOENT) subject expect(File.open(admin_report.reload.location_url)).to be end From 88bf10c6f1b2b50d9d8461b19bc6300431657bf1 Mon Sep 17 00:00:00 2001 From: ricoch Date: Mon, 19 Oct 2020 12:41:00 -0300 Subject: [PATCH 17/17] Remove unnecesary db configuration for tests --- spec/spec_helper.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5cb1f8c..71db309 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,13 +12,6 @@ require 'tmpdir' -ActiveRecord::Base.establish_connection( - adapter: 'sqlite3', - database: ':memory:' -) - -load 'dummy/db/schema.rb' - require 'simplecov' SimpleCov.start