[Git][noosfero/noosfero][master] Fix image address in highlightBlock when in subdir

Daniela Feitosa gitlab at gitlab.com
Tue Oct 6 15:28:42 BRT 2015


Daniela Feitosa pushed to branch master at Noosfero / noosfero


Commits:
70d40ab5 by Thiago Ribeiro at 2015-10-06T15:23:49Z
Fix image address in highlightBlock when in subdir

Signed-off-by: Thiago Ribeiro <thiagitosouza at gmail.com>
Signed-off-by: Simião Carvalho <simiaosimis at gmail.com>
Signed-off-by: Daniela Soares Feitosa <danielafeitosa at colivre.coop.br>

Closes merge request !688

- - - - -


2 changed files:

- app/views/blocks/highlights.html.erb
- test/unit/highlights_block_test.rb


Changes:

=====================================
app/views/blocks/highlights.html.erb
=====================================
--- a/app/views/blocks/highlights.html.erb
+++ b/app/views/blocks/highlights.html.erb
@@ -4,7 +4,7 @@
     <div class='highlights-container'>
       <% block.featured_images.each do |img| %>
         <a href="<%= img[:address] %>" title="<%= img[:title] %>" class="highlights-image-link">
-          <%= content_tag :img, nil, :src => img[:image_src], :alt => img[:title] %>
+          <%= image_tag [Noosfero.root, img[:image_src]].join, alt: img[:title] %>
           <p class="highlights-label"><%= img[:title] %></p>
         </a>
       <% end %>


=====================================
test/unit/highlights_block_test.rb
=====================================
--- a/test/unit/highlights_block_test.rb
+++ b/test/unit/highlights_block_test.rb
@@ -132,6 +132,19 @@ class HighlightsBlockTest < ActiveSupport::TestCase
     assert_equal block.images.first[:address], "/social/address"
   end
 
+  should 'display images with subdir src' do
+    Noosfero.stubs(:root).returns("/social")
+    f1 = mock()
+    f1.expects(:public_filename).returns('/img_address')
+    UploadedFile.expects(:find).with(1).returns(f1)
+    block = HighlightsBlock.new
+    i1 = {:image_id => 1, :address => '/address'}
+    block.images = [i1]
+    block.save!
+
+    assert_tag_in_string instance_eval(& block.content), :tag => 'img', :attributes => { :src => "/social/img_address" }
+  end
+
   [Environment, Profile].each do |klass|
     should "choose between owner galleries when owner is #{klass.name}" do
       owner = fast_create(klass)



View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/70d40ab534163196c225ab27289b34a7b865b416
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20151006/362d17e6/attachment.html>


More information about the Noosfero-dev mailing list