Skip to content

Commit 9ede207

Browse files
didcodebreach
authored andcommitted
fix issue locomotivecms#1197 (account.avatar.url is a frozen string)
1 parent 6a24430 commit 9ede207

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

lib/locomotive/dragonfly.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def self.fetch_file(source)
2525
if source.is_a?(String) || source.is_a?(Hash) # simple string or drop
2626
source = source['url'] if source.is_a?(Hash)
2727

28-
clean_source!(source)
28+
source = clean_source(source)
2929

3030
if source =~ /^http/
3131
file = self.app.fetch_url(source)
@@ -50,12 +50,14 @@ def self.app
5050

5151
protected
5252

53-
def self.clean_source!(source)
53+
def self.clean_source(source)
5454
# remove the leading / trailing whitespaces
55-
source.strip!
55+
_source = source.strip
5656

5757
# remove the query part (usually, timestamp) if local file
58-
source.sub!(/(\?.*)$/, '') unless source =~ /^http/
58+
_source = _source.sub(/(\?.*)$/, '') unless _source =~ /^http/
59+
60+
_source
5961
end
6062

6163
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require 'spec_helper'
2+
3+
describe Locomotive::Shared::AccountsHelper do
4+
5+
describe 'account_avatar_url' do
6+
7+
let(:account) { create(:account, avatar: FixturedAsset.open('5k.png')).reload }
8+
9+
subject { account_avatar_url(account) }
10+
11+
it { expect(subject).to match(/^\/images\/dynamic\/[^\/]+\/5k.png\?sha=.*$/) }
12+
13+
end
14+
15+
end
16+
17+

0 commit comments

Comments
 (0)