Skip to content

Commit

Permalink
rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
loomchild committed Nov 13, 2024
1 parent fa6b384 commit 462f68b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/nylas/utils/file_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def self.build_form_request(request_body)
file = File.open(attachment[:file_path], "rb")
end

# Setting original filename and content type if available. See code rest-client#lib/restclient/payload.rb
# Setting original filename and content type if available. See rest-client#lib/restclient/payload.rb
filename = attachment[:filename] || attachment["filename"]
file.define_singleton_method(:original_filename) { filename } if filename

Expand Down
11 changes: 8 additions & 3 deletions spec/nylas/utils/file_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@
let(:mock_file) { instance_double("file") }

it "returns form data when attachment size is greater than 3MB" do
large_attachment = { size: 4 * 1024 * 1024, content: mock_file, filename: 'file.txt', content_type: 'text/plain' }
large_attachment = {
size: 4 * 1024 * 1024,
content: mock_file,
filename: "file.txt",
content_type: "text/plain"
}
request_body = { attachments: [large_attachment] }

allow(mock_file).to receive(:read).and_return("file content")
Expand All @@ -202,8 +207,8 @@

expect(payload).to include("multipart" => true)
expect(opened_files).to include(mock_file)
expect(mock_file.original_filename).to eq('file.txt')
expect(mock_file.content_type).to eq('text/plain')
expect(mock_file.original_filename).to eq("file.txt")
expect(mock_file.content_type).to eq("text/plain")
end

it "returns json data when attachment size is less than 3MB" do
Expand Down

0 comments on commit 462f68b

Please sign in to comment.