Commit be52cafcce5fdbd1131fb2c0ea51923ef81875c6

Authored by Antonio Terceiro
2 parents 96adc976 003273e0

Merge branch 'stable'

app/helpers/application_helper.rb
... ... @@ -942,4 +942,11 @@ module ApplicationHelper
942 942 content_for(:head) { stylesheet_link_tag(*args) }
943 943 end
944 944  
  945 + def article_to_html(article)
  946 + content = article.to_html(:page => params[:npage])
  947 + return self.instance_eval(&content) if content.kind_of?(Proc)
  948 + content
  949 + end
  950 +
  951 +
945 952 end
... ...
app/helpers/content_viewer_helper.rb
... ... @@ -24,12 +24,6 @@ module ContentViewerHelper
24 24 title
25 25 end
26 26  
27   - def article_to_html(article)
28   - content = article.to_html(:page => params[:npage])
29   - return self.instance_eval(&content) if content.kind_of?(Proc)
30   - content
31   - end
32   -
33 27 def link_to_comments(article)
34 28 link_to( number_of_comments(article), article.url.merge(:anchor => 'comments_list') )
35 29 end
... ...
app/models/article_block.rb
... ... @@ -9,8 +9,11 @@ class ArticleBlock < Block
9 9 end
10 10  
11 11 def content
12   - block_title(title) +
13   - (article ? article.to_html : _('Article not selected yet.'))
  12 + block = self
  13 + lambda do
  14 + block_title(block.title) +
  15 + (block.article ? article_to_html(block.article) : _('Article not selected yet.'))
  16 + end
14 17 end
15 18  
16 19 def article_id
... ...
script/ci-build
1 1 #!/bin/sh
2 2  
3   -cp config/database.yml.sqlite3 config/database.yml && /usr/bin/rake db:schema:load && /usr/bin/rake
  3 +set -e
  4 +
  5 +build() {
  6 + cp config/database.yml.sqlite3 config/database.yml && /usr/bin/rake db:schema:load && /usr/bin/rake
  7 +}
  8 +
  9 +# build the code in the VCS
  10 +build
  11 +
  12 +# build the release tarball as well
  13 +version=$(ruby -Ilib -rnoosfero -e 'puts Noosfero::VERSION')
  14 +rm -rf pkg/ && rake -f Rakefile.pkg && cd pkg/noosfero-${version}/ && build
... ...
test/unit/article_block_test.rb
... ... @@ -2,6 +2,8 @@ require File.dirname(__FILE__) + '/../test_helper'
2 2  
3 3 class ArticleBlockTest < Test::Unit::TestCase
4 4  
  5 + include ApplicationHelper
  6 +
5 7 should 'describe itself' do
6 8 assert_not_equal Block.description, ArticleBlock.description
7 9 end
... ... @@ -12,7 +14,7 @@ class ArticleBlockTest &lt; Test::Unit::TestCase
12 14 article.expects(:to_html).returns("Article content")
13 15 block.stubs(:article).returns(article)
14 16  
15   - assert_match(/Article content/, block.content)
  17 + assert_match(/Article content/, instance_eval(&block.content))
16 18 end
17 19  
18 20 should 'refer to an article' do
... ... @@ -87,7 +89,7 @@ class ArticleBlockTest &lt; Test::Unit::TestCase
87 89 block.expects(:title).returns('')
88 90 block.stubs(:article).returns(article)
89 91  
90   - assert_equal "<h3 class=\"block-title empty\"></h3>Article content", block.content
  92 + assert_equal "<h3></h3>Article content", instance_eval(&block.content)
91 93 end
92 94  
93 95 should "display title if defined" do
... ... @@ -97,7 +99,45 @@ class ArticleBlockTest &lt; Test::Unit::TestCase
97 99 block.expects(:title).returns('Article title')
98 100 block.stubs(:article).returns(article)
99 101  
100   - assert_equal "<h3 class=\"block-title\">Article title</h3>Article content", block.content
  102 + assert_equal "<h3>Article title</h3>Article content", instance_eval(&block.content)
  103 + end
  104 +
  105 + should 'display image if article is an image' do
  106 + profile = create_user('testuser').person
  107 + block = ArticleBlock.new
  108 + image = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'))
  109 +
  110 + block.article = image
  111 + block.save!
  112 +
  113 + expects(:image_tag).with(image.public_filename(:display), :class => image.css_class_name, :style => 'max-width: 100%').returns('image')
  114 +
  115 + assert_match(/image/, instance_eval(&block.content))
  116 + end
  117 +
  118 + should 'display link to archive if article is an archive' do
  119 + profile = create_user('testuser').person
  120 + block = ArticleBlock.new
  121 + file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain'))
  122 +
  123 + block.article = file
  124 + block.save!
  125 +
  126 + assert_tag_in_string instance_eval(&block.content), :tag => 'a', :content => 'test.txt'
101 127 end
102 128  
  129 + protected
  130 +
  131 + def content_tag(tag, text, options = {})
  132 + "<#{tag}>#{text}</#{tag}>"
  133 + end
  134 + def image_tag(arg)
  135 + arg
  136 + end
  137 + def link_to(text, url, options = {})
  138 + "<a href='#{url.to_s}'>#{text}</a>"
  139 + end
  140 + def params
  141 + {}
  142 + end
103 143 end
... ...
test/unit/blog_helper_test.rb
... ... @@ -5,6 +5,7 @@ class BlogHelperTest &lt; Test::Unit::TestCase
5 5 include BlogHelper
6 6 include ContentViewerHelper
7 7 include ActionView::Helpers::AssetTagHelper
  8 + include ApplicationHelper
8 9  
9 10 def setup
10 11 stubs(:show_date).returns('')
... ...
test/unit/content_viewer_helper_test.rb
... ... @@ -5,6 +5,7 @@ class ContentViewerHelperTest &lt; Test::Unit::TestCase
5 5 include ActionView::Helpers::TagHelper
6 6 include ContentViewerHelper
7 7 include DatesHelper
  8 + include ApplicationHelper
8 9  
9 10 def setup
10 11 @profile = create_user('blog_helper_test').person
... ...