-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
10b1281
commit 7d61780
Showing
6 changed files
with
99 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module AssembleMarcFiles | ||
class << self | ||
def run | ||
program = AssembleMarcFiles.new | ||
program.execute | ||
rescue StandardError => e | ||
text = <<~MSG | ||
AssembleMarcFiles run error (#{e}) | ||
MSG | ||
NotifierMailer.administrators(text).deliver_now | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# frozen_string_literal: true | ||
|
||
module AssembleMarcFiles | ||
class AssembleMarcFiles | ||
def execute | ||
puts "hello" | ||
end | ||
|
||
# def run | ||
# umpebc_products_modified.each do |modified_product| | ||
# generate_product_marc_files(modified_product) | ||
# end | ||
# rescue StandardError => e | ||
# text = <<~MSG | ||
# AssembleMarcFiles run error (#{e}) | ||
# MSG | ||
# NotifierMailer.administrators(text).deliver_now | ||
# end | ||
# | ||
# private | ||
# | ||
# def generate_product_marc_files(product) | ||
# product.dois.each do |doi| | ||
# end | ||
# end | ||
# | ||
# def umpebc_products_modified | ||
# umpebc_product_family.products.map { |product| product if product.modified? }.compact | ||
# end | ||
# | ||
# def umpebc_product_family | ||
# @umpebc_product_family ||= begin | ||
# product_families = LibPtgBox::LibPtgBox.new.product_families | ||
# umpebc_family = nil | ||
# product_families.each do |family| | ||
# next unless /umpebc/i.match?(family.name) | ||
# | ||
# umpebc_family = family | ||
# break | ||
# end | ||
# raise 'umpebc product family not found' unless umpebc_family | ||
# | ||
# umpebc_family | ||
# end | ||
# end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe AssembleMarcFiles do | ||
describe '#run' do | ||
let(:program) { instance_double(AssembleMarcFiles::AssembleMarcFiles, "AssembleMarcFiles") } | ||
|
||
before { allow(AssembleMarcFiles::AssembleMarcFiles).to receive(:new).and_return(program) } | ||
|
||
context 'when execute program' do | ||
before { allow(program).to receive(:execute) } | ||
|
||
it 'program execute' do | ||
described_class.run | ||
expect(program).to have_received(:execute) | ||
end | ||
end | ||
|
||
context 'when standard error' do | ||
let(:mail) { double("NotifierMailer") } # rubocop:disable RSpec/VerifiedDoubles | ||
|
||
before do | ||
allow(program).to receive(:execute).and_raise(StandardError) | ||
allow(NotifierMailer).to receive(:administrators).with("AssembleMarcFiles run error (StandardError)\n").and_return(mail) | ||
allow(mail).to receive(:deliver_now) | ||
end | ||
|
||
it 'notifies administrators' do | ||
described_class.run | ||
expect(mail).to have_received(:deliver_now) | ||
end | ||
end | ||
end | ||
end |