Commit 26f01247e119233f175ac5ad470ab183787417ca
Committed by
Antonio Terceiro
1 parent
6fb823a9
Exists in
master
and in
29 other branches
Highlight block fix
- Hightlight block links no longer break when noosfero is under a subdir Signed-off-by: Andre Bernardes <andrebsguedes@gmail.com> Signed-off-by: Tallys Martins <tallysmartins@yahoo.com.br>
Showing
2 changed files
with
14 additions
and
0 deletions
Show diff stats
app/models/highlights_block.rb
@@ -12,6 +12,7 @@ class HighlightsBlock < Block | @@ -12,6 +12,7 @@ class HighlightsBlock < Block | ||
12 | block.images.each do |i| | 12 | block.images.each do |i| |
13 | i[:image_id] = i[:image_id].to_i | 13 | i[:image_id] = i[:image_id].to_i |
14 | i[:position] = i[:position].to_i | 14 | i[:position] = i[:position].to_i |
15 | + i[:address] = Noosfero.root + i[:address] unless Noosfero.root.nil? | ||
15 | begin | 16 | begin |
16 | file = UploadedFile.find(i[:image_id]) | 17 | file = UploadedFile.find(i[:image_id]) |
17 | i[:image_src] = file.public_filename | 18 | i[:image_src] = file.public_filename |
test/unit/highlights_block_test.rb
@@ -119,6 +119,19 @@ class HighlightsBlockTest < ActiveSupport::TestCase | @@ -119,6 +119,19 @@ class HighlightsBlockTest < ActiveSupport::TestCase | ||
119 | block.featured_images | 119 | block.featured_images |
120 | end | 120 | end |
121 | 121 | ||
122 | + should 'return correct sub-dir address' do | ||
123 | + Noosfero.stubs(:root).returns("/social") | ||
124 | + f1 = mock() | ||
125 | + f1.expects(:public_filename).returns('address') | ||
126 | + UploadedFile.expects(:find).with(1).returns(f1) | ||
127 | + block = HighlightsBlock.new | ||
128 | + i1 = {:image_id => 1, :address => '/address', :position => 3, :title => 'address'} | ||
129 | + block.images = [i1] | ||
130 | + block.save! | ||
131 | + block.reload | ||
132 | + assert_equal block.images.first[:address], "/social/address" | ||
133 | + end | ||
134 | + | ||
122 | [Environment, Profile].each do |klass| | 135 | [Environment, Profile].each do |klass| |
123 | should "choose between owner galleries when owner is #{klass.name}" do | 136 | should "choose between owner galleries when owner is #{klass.name}" do |
124 | owner = fast_create(klass) | 137 | owner = fast_create(klass) |