diff --git a/slack-strava/models/map.rb b/slack-strava/models/map.rb index 2d6d697..b0175c7 100644 --- a/slack-strava/models/map.rb +++ b/slack-strava/models/map.rb @@ -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! diff --git a/spec/models/map_spec.rb b/spec/models/map_spec.rb new file mode 100644 index 0000000..60b3b8c --- /dev/null +++ b/spec/models/map_spec.rb @@ -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