Skip to content

Commit

Permalink
Get more tests passing.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpendragon committed Dec 12, 2024
1 parent 2d6a6b9 commit 19fe0ae
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/adapters/retrying_disk_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ def initialize(inner_storage_adapter)
@inner_storage_adapter = inner_storage_adapter
end

def upload(...)
def upload(**args)
with_rescue([Errno::EPIPE, Errno::EAGAIN, Errno::EIO, Errno::ECONNRESET], retries: 5) do
inner_storage_adapter.upload(...)
inner_storage_adapter.upload(**args)
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/auth_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class AuthToken < ApplicationRecord
before_create :assign_token
before_save :clean_group
serialize :group, Array
serialize :group, coder: YAML, type: Array
validates :label, presence: true

private
Expand Down
8 changes: 5 additions & 3 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
require_relative "read_only_mode"
require "rails"
if ["development", "test"].include? ENV["RAILS_ENV"]
require "dotenv/rails-now"
Dotenv::Railtie.load
require "dotenv/load"
Dotenv::Rails.load
end
require_relative "lando_env"
require "active_model/railtie"
Expand All @@ -21,7 +21,9 @@
Bundler.require(*Rails.groups)
module Figgy
class Application < Rails::Application
config.load_defaults "6.0"
config.load_defaults "7.1"
# Enabled because of https://github.com/heartcombo/devise/pull/5462
config.action_controller.raise_on_open_redirects = false
config.action_controller.forgery_protection_origin_check = false
config.assets.quiet = true
config.generators do |generate|
Expand Down
2 changes: 1 addition & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_dispatch.show_exceptions = false
config.action_dispatch.show_exceptions = :none
config.action_controller.allow_forgery_protection = false
config.action_mailer.perform_caching = false
config.action_mailer.delivery_method = :test
Expand Down
16 changes: 8 additions & 8 deletions spec/adapters/retrying_disk_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
context "when upload fails because of an Errno::EPIPE" do
it "retries" do
counts = 0
allow(storage_adapter.inner_storage_adapter).to receive(:upload).and_wrap_original do |method, *args|
allow(storage_adapter.inner_storage_adapter).to receive(:upload).and_wrap_original do |method, **args|
counts += 1
raise Errno::EPIPE if counts == 1
method.call(*args)
method.call(**args)
end

uploaded_file = storage_adapter.upload(file: file, resource: ScannedResource.new(id: SecureRandom.uuid), original_filename: "test.tiff")
Expand All @@ -33,10 +33,10 @@
context "when upload fails because of an Errno::EAGAIN" do
it "tries again" do
counts = 0
allow(storage_adapter.inner_storage_adapter).to receive(:upload).and_wrap_original do |method, *args|
allow(storage_adapter.inner_storage_adapter).to receive(:upload).and_wrap_original do |method, **args|
counts += 1
raise Errno::EAGAIN if counts == 1
method.call(*args)
method.call(**args)
end

uploaded_file = storage_adapter.upload(file: file, resource: ScannedResource.new(id: SecureRandom.uuid), original_filename: "test.tiff")
Expand All @@ -48,10 +48,10 @@
context "when upload fails because of an Errno::EIO" do
it "tries again" do
counts = 0
allow(storage_adapter.inner_storage_adapter).to receive(:upload).and_wrap_original do |method, *args|
allow(storage_adapter.inner_storage_adapter).to receive(:upload).and_wrap_original do |method, **args|
counts += 1
raise Errno::EIO if counts == 1
method.call(*args)
method.call(**args)
end

uploaded_file = storage_adapter.upload(file: file, resource: ScannedResource.new(id: SecureRandom.uuid), original_filename: "test.tiff")
Expand All @@ -63,10 +63,10 @@
context "when upload fails because of an Errno::ECONNRESET" do
it "tries again" do
counts = 0
allow(storage_adapter.inner_storage_adapter).to receive(:upload).and_wrap_original do |method, *args|
allow(storage_adapter.inner_storage_adapter).to receive(:upload).and_wrap_original do |method, **args|
counts += 1
raise Errno::EIO if counts == 1
method.call(*args)
method.call(**args)
end

uploaded_file = storage_adapter.upload(file: file, resource: ScannedResource.new(id: SecureRandom.uuid), original_filename: "test.tiff")
Expand Down

0 comments on commit 19fe0ae

Please sign in to comment.