Skip to content

Commit

Permalink
Fix tests and code be selecting the first element of the attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
Katy600 committed Jul 11, 2024
1 parent 64dc49a commit a855677
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/presenters/message_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def download_file_link
end

def attachment_file_name
message.attachment.filename.to_s
message.attachment.first.filename.to_s
end

def attachment_file_size
h.number_to_human_size(message.attachment.byte_size)
h.number_to_human_size(message.attachment.first.byte_size)
end

def hide_author?
Expand Down
4 changes: 2 additions & 2 deletions spec/presenters/message_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
context 'with an attachment' do
let(:file) { File.expand_path('features/examples/shorter_lorem.docx', Rails.root) }
let(:file_size) { number_to_human_size(File.size(file)) }
let(:attachment) { Rack::Test::UploadedFile.new(file) }
let(:attachment) { [Rack::Test::UploadedFile.new(file)] }

before do
allow(message.attachment).to receive(:url).and_return('http://example.com')
allow(message.attachment.first).to receive(:url).and_return('http://example.com')
end

it 'includes a download link to the attachment' do
Expand Down

0 comments on commit a855677

Please sign in to comment.