Commit 70d40ab534163196c225ab27289b34a7b865b416
Committed by
Daniela Feitosa
1 parent
eb417840
Exists in
master
and in
29 other branches
Fix image address in highlightBlock when in subdir
Signed-off-by: Thiago Ribeiro <thiagitosouza@gmail.com> Signed-off-by: Simião Carvalho <simiaosimis@gmail.com> Signed-off-by: Daniela Soares Feitosa <danielafeitosa@colivre.coop.br> Closes merge request !688
Showing
2 changed files
with
14 additions
and
1 deletions
Show diff stats
app/views/blocks/highlights.html.erb
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | <div class='highlights-container'> |
5 | 5 | <% block.featured_images.each do |img| %> |
6 | 6 | <a href="<%= img[:address] %>" title="<%= img[:title] %>" class="highlights-image-link"> |
7 | - <%= content_tag :img, nil, :src => img[:image_src], :alt => img[:title] %> | |
7 | + <%= image_tag [Noosfero.root, img[:image_src]].join, alt: img[:title] %> | |
8 | 8 | <p class="highlights-label"><%= img[:title] %></p> |
9 | 9 | </a> |
10 | 10 | <% end %> | ... | ... |
test/unit/highlights_block_test.rb
... | ... | @@ -132,6 +132,19 @@ class HighlightsBlockTest < ActiveSupport::TestCase |
132 | 132 | assert_equal block.images.first[:address], "/social/address" |
133 | 133 | end |
134 | 134 | |
135 | + should 'display images with subdir src' do | |
136 | + Noosfero.stubs(:root).returns("/social") | |
137 | + f1 = mock() | |
138 | + f1.expects(:public_filename).returns('/img_address') | |
139 | + UploadedFile.expects(:find).with(1).returns(f1) | |
140 | + block = HighlightsBlock.new | |
141 | + i1 = {:image_id => 1, :address => '/address'} | |
142 | + block.images = [i1] | |
143 | + block.save! | |
144 | + | |
145 | + assert_tag_in_string instance_eval(& block.content), :tag => 'img', :attributes => { :src => "/social/img_address" } | |
146 | + end | |
147 | + | |
135 | 148 | [Environment, Profile].each do |klass| |
136 | 149 | should "choose between owner galleries when owner is #{klass.name}" do |
137 | 150 | owner = fast_create(klass) | ... | ... |