Skip to content

Commit

Permalink
Fix: do not include empty png in map.to_s.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Oct 6, 2024
1 parent ea1febe commit 9a3feed
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
5 changes: 4 additions & 1 deletion slack-strava/models/map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ def png_size
end

def to_s
"proxy=#{proxy_image_url}, png=#{png_size} byte(s)"
[
"proxy=#{proxy_image_url}",
png ? "png=#{png_size} byte(s)" : nil
].compact.join(', ')
end

def delete_png!
Expand Down
24 changes: 24 additions & 0 deletions spec/models/map_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'spec_helper'

describe Map do
let(:activity) { Fabricate(:user_activity) }
let(:map) { activity.map }

context 'to_s' do
context 'without png' do
it 'includes proxy URL' do
expect(map.to_s).to eq "proxy=https://slava.playplay.io/api/maps/#{map.id}.png"
end
end

context 'with png' do
before do
map.png = BSON::Binary.new(SecureRandom.hex)
end

it 'includes proxy URL' do
expect(map.to_s).to eq "proxy=https://slava.playplay.io/api/maps/#{map.id}.png, png=32 byte(s)"
end
end
end
end

0 comments on commit 9a3feed

Please sign in to comment.