Update banner repository spec so that it passes · fastruby/allsearch_api@3b1b0df · GitHub
Skip to content

Commit 3b1b0df

Browse files
Update banner repository spec so that it passes
related to [pulibrary#404] Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>
1 parent 0604397 commit 3b1b0df

6 files changed

Lines changed: 13 additions & 22 deletions

File tree

‎app/services/csv_loading_service.rb‎

Lines changed: 1 addition & 5 deletions

‎db/structure.sql‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
\restrict 7jn6boioBXAuAqQ7Mw4YSUHvdX7FhWWhQHIiFcR8GWabNbTTaSBnSP2IJJLiq67
2-
3-
-- Dumped from database version 15.10
4-
-- Dumped by pg_dump version 18.1
5-
61
SET statement_timeout = 0;
72
SET lock_timeout = 0;
83
SET idle_in_transaction_session_timeout = 0;
9-
SET transaction_timeout = 0;
104
SET client_encoding = 'UTF8';
115
SET standard_conforming_strings = on;
126
SELECT pg_catalog.set_config('search_path', '', false);
@@ -619,8 +613,6 @@ CREATE INDEX staff_search_idx ON public.library_staff_records USING gin (searcha
619613
-- PostgreSQL database dump complete
620614
--
621615

622-
\unrestrict 7jn6boioBXAuAqQ7Mw4YSUHvdX7FhWWhQHIiFcR8GWabNbTTaSBnSP2IJJLiq67
623-
624616
SET search_path TO "$user", public;
625617

626618
INSERT INTO "schema_migrations" (version) VALUES

‎init/rom_factory.rb‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ def database_if_available
3030
def rom_if_available
3131
db_connection
3232
.bind { |connection| verify_database_ready(connection) }
33-
.or do |connection|
34-
`bundle exec rake db:migrate`
35-
db_connection
36-
end.bind { |connection| rom_container(connection) }
33+
.bind { |connection| rom_container(connection) }
3734
end
3835

3936
private
@@ -46,8 +43,9 @@ def db_connection
4643
Failure(error)
4744
end
4845

46+
# rubocop:disable Metrics/MethodLength
4947
def verify_database_ready(connection)
50-
required_tables = [:schema_migrations, :ar_internal_metadata, :banners]
48+
required_tables = [:schema_migrations, :ar_internal_metadata]
5149
missing_tables = required_tables.reject { |table| connection.table_exists?(table) }
5250

5351
if missing_tables.empty?
@@ -60,6 +58,7 @@ def verify_database_ready(connection)
6058
rescue StandardError => error
6159
Failure(error)
6260
end
61+
# rubocop:enable Metrics/MethodLength
6362

6463
def rom_container(db_connection)
6564
rom_config = ROM::Configuration.new(:sql, db_connection)

‎lib/tasks/best_bets.rake‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
23
require_relative '../../init/rom_factory'
34
namespace :best_bets do
45
desc 'Refresh the best_bet_documents table with data from the spreadsheet'

‎spec/init/rom_factory_spec.rb‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@
4242
allow(Sequel).to receive(:postgres).and_return(db)
4343
allow(db).to receive(:table_exists?).with(:schema_migrations).and_return(true)
4444
allow(db).to receive(:table_exists?).with(:ar_internal_metadata).and_return(true)
45+
# rubocop :disable RSpec/VerifiedDoubles
4546
rom_config = double('ROM::Configuration', register_relation: true,
4647
default: instance_double(ROM::Gateway, use_logger: true)).as_null_object
48+
# rubocop :enable RSpec/VerifiedDoubles
4749
allow(ROM::Configuration).to receive(:new).and_return(rom_config)
4850
allow(ROM).to receive(:container).and_return(ROM::Container.new([], [], [], []))
4951
expect(described_class.new.rom_if_available).to be_success

‎spec/repositories/banner_repository_spec.rb‎

Lines changed: 5 additions & 4 deletions

0 commit comments

Comments
 (0)