Skip to content

Commit

Permalink
Merge branch 'dev' into impl/add-storage-missing-services
Browse files Browse the repository at this point in the history
  • Loading branch information
Kharonus committed Sep 25, 2024
2 parents d0d5330 + 5cb0f20 commit bddf831
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ module Inputs
private_class_method :new

def self.build(folder_id:, file_name:, contract: UploadDataContract.new)
contract.call(folder_id:, file_name:).to_monad.fmap do |result|
new(file_name: result[:file_name], folder_id: ParentFolder.new(result[:folder_id]))
end
contract.call(folder_id:, file_name:)
.to_monad
.fmap { |result| new(file_name: result[:file_name], folder_id: result[:folder_id]) }
end
end
end
Expand Down
7 changes: 3 additions & 4 deletions modules/storages/app/services/storages/upload_link_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ def call(user:, upload_data:)
private

def request_upload_link(auth_strategy, upload_data)
Peripherals::Registry
.resolve("#{@storage}.queries.upload_link")
.call(storage: @storage, auth_strategy:, upload_data:)
.on_failure do |error|
Peripherals::Registry.resolve("#{@storage}.queries.upload_link")
.call(storage: @storage, auth_strategy:, upload_data:)
.on_failure do |error|
add_error(:base, error.errors, options: { storage_name: @storage.name, folder: upload_data.folder_id })
log_storage_error(error.errors)
@result.success = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@
end

it "returns a Success(UploadData)" do
result = input.build(folder_id: "/Folder/Subfolder", file_name: "i_am_file_with_a_name.txt")
result = input.build(folder_id: "1337", file_name: "i_am_file_with_a_name.txt")

expect(result).to be_success
upload_data = result.value!
expect(upload_data.folder_id).to eq(Storages::Peripherals::ParentFolder.new("/Folder/Subfolder"))
expect(upload_data.folder_id).to eq("1337")
expect(upload_data.file_name).to eq("i_am_file_with_a_name.txt")
end

context "when invalid" do
context "with a nil file name" do
let(:kwargs) { { folder_id: "/folder", file_name: nil } }
let(:kwargs) { { folder_id: "42", file_name: nil } }

it "returns a failure" do
result = input.build(**kwargs)
Expand All @@ -63,7 +63,7 @@
end

context "with a empty file name" do
let(:kwargs) { { folder_id: "/folder", file_name: "" } }
let(:kwargs) { { folder_id: "42", file_name: "" } }

it "returns a failure" do
result = input.build(**kwargs)
Expand Down

0 comments on commit bddf831

Please sign in to comment.