Commit 9731f6e8cc928a1e6165c49c530c7c78f43694c9
1 parent
14a816da
Exists in
master
and in
29 other branches
Disabling translation for forum posts
(ActionItem1817)
Showing
10 changed files
with
43 additions
and
25 deletions
Show diff stats
app/models/event.rb
| @@ -120,10 +120,7 @@ class Event < Article | @@ -120,10 +120,7 @@ class Event < Article | ||
| 120 | true | 120 | true |
| 121 | end | 121 | end |
| 122 | 122 | ||
| 123 | - def translatable? | ||
| 124 | - true | ||
| 125 | - end | ||
| 126 | - | 123 | + include Noosfero::TranslatableContent |
| 127 | include MaybeAddHttp | 124 | include MaybeAddHttp |
| 128 | 125 | ||
| 129 | end | 126 | end |
app/models/text_article.rb
| @@ -2,4 +2,6 @@ | @@ -2,4 +2,6 @@ | ||
| 2 | class TextArticle < Article | 2 | class TextArticle < Article |
| 3 | 3 | ||
| 4 | xss_terminate :only => [ :name, :abstract, :body ], :on => 'validation' | 4 | xss_terminate :only => [ :name, :abstract, :body ], :on => 'validation' |
| 5 | + | ||
| 6 | + include Noosfero::TranslatableContent | ||
| 5 | end | 7 | end |
app/models/textile_article.rb
app/models/tiny_mce_article.rb
test/unit/event_test.rb
| @@ -267,8 +267,7 @@ class EventTest < ActiveSupport::TestCase | @@ -267,8 +267,7 @@ class EventTest < ActiveSupport::TestCase | ||
| 267 | end | 267 | end |
| 268 | 268 | ||
| 269 | should 'be translatable' do | 269 | should 'be translatable' do |
| 270 | - e = Event.new | ||
| 271 | - assert e.translatable? | 270 | + assert_kind_of Noosfero::TranslatableContent, Event.new |
| 272 | end | 271 | end |
| 273 | 272 | ||
| 274 | end | 273 | end |
test/unit/text_article_test.rb
| @@ -39,4 +39,8 @@ class TextArticleTest < Test::Unit::TestCase | @@ -39,4 +39,8 @@ class TextArticleTest < Test::Unit::TestCase | ||
| 39 | assert_no_match /[<>]/, article.body | 39 | assert_no_match /[<>]/, article.body |
| 40 | end | 40 | end |
| 41 | 41 | ||
| 42 | + should 'be translatable' do | ||
| 43 | + assert_kind_of Noosfero::TranslatableContent, TextArticle.new | ||
| 44 | + end | ||
| 45 | + | ||
| 42 | end | 46 | end |
test/unit/textile_article_test.rb
| @@ -145,10 +145,4 @@ class TextileArticleTest < Test::Unit::TestCase | @@ -145,10 +145,4 @@ class TextileArticleTest < Test::Unit::TestCase | ||
| 145 | assert_equal false, a.advertise? | 145 | assert_equal false, a.advertise? |
| 146 | assert_equal false, a.is_trackable? | 146 | assert_equal false, a.is_trackable? |
| 147 | end | 147 | end |
| 148 | - | ||
| 149 | - should 'be translatable' do | ||
| 150 | - a = TextileArticle.new | ||
| 151 | - assert a.translatable? | ||
| 152 | - end | ||
| 153 | - | ||
| 154 | end | 148 | end |
test/unit/tiny_mce_article_test.rb
| @@ -236,9 +236,4 @@ class TinyMceArticleTest < Test::Unit::TestCase | @@ -236,9 +236,4 @@ class TinyMceArticleTest < Test::Unit::TestCase | ||
| 236 | assert_equal false, a.advertise? | 236 | assert_equal false, a.advertise? |
| 237 | assert_equal false, a.is_trackable? | 237 | assert_equal false, a.is_trackable? |
| 238 | end | 238 | end |
| 239 | - | ||
| 240 | - should 'be translatable' do | ||
| 241 | - a = TinyMceArticle.new | ||
| 242 | - assert a.translatable? | ||
| 243 | - end | ||
| 244 | end | 239 | end |
| @@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
| 1 | +require File.dirname(__FILE__) + '/../test_helper' | ||
| 2 | + | ||
| 3 | +class TranslatableContentTest < ActiveSupport::TestCase | ||
| 4 | + | ||
| 5 | + class Content | ||
| 6 | + attr_accessor :parent | ||
| 7 | + include Noosfero::TranslatableContent | ||
| 8 | + end | ||
| 9 | + | ||
| 10 | + def setup | ||
| 11 | + @content = Content.new | ||
| 12 | + end | ||
| 13 | + attr_reader :content | ||
| 14 | + | ||
| 15 | + should 'be translatable if no parent' do | ||
| 16 | + assert content.translatable? | ||
| 17 | + end | ||
| 18 | + | ||
| 19 | + should 'not be translatable if parent is a forum' do | ||
| 20 | + content.parent = Forum.new | ||
| 21 | + assert !content.translatable? | ||
| 22 | + end | ||
| 23 | + | ||
| 24 | + should 'be translatable if parent is not a forum' do | ||
| 25 | + content.parent = Blog.new | ||
| 26 | + assert content.translatable? | ||
| 27 | + end | ||
| 28 | + | ||
| 29 | +end |