Commit 9731f6e8cc928a1e6165c49c530c7c78f43694c9

Authored by Daniela Feitosa
1 parent 14a816da

Disabling translation for forum posts

(ActionItem1817)
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
@@ -16,8 +16,4 @@ class TextileArticle &lt; TextArticle @@ -16,8 +16,4 @@ class TextileArticle &lt; TextArticle
16 true 16 true
17 end 17 end
18 18
19 - def translatable?  
20 - true  
21 - end  
22 -  
23 end 19 end
app/models/tiny_mce_article.rb
@@ -19,8 +19,4 @@ class TinyMceArticle &lt; TextArticle @@ -19,8 +19,4 @@ class TinyMceArticle &lt; TextArticle
19 true 19 true
20 end 20 end
21 21
22 - def translatable?  
23 - true  
24 - end  
25 -  
26 end 22 end
lib/noosfero/translatable_content.rb 0 → 100644
@@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
  1 +module Noosfero::TranslatableContent
  2 +
  3 + def translatable?
  4 + parent.nil? || !parent.forum?
  5 + end
  6 +end
test/unit/event_test.rb
@@ -267,8 +267,7 @@ class EventTest &lt; ActiveSupport::TestCase @@ -267,8 +267,7 @@ class EventTest &lt; 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 &lt; Test::Unit::TestCase @@ -39,4 +39,8 @@ class TextArticleTest &lt; 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 &lt; Test::Unit::TestCase @@ -145,10 +145,4 @@ class TextileArticleTest &lt; 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 &lt; Test::Unit::TestCase @@ -236,9 +236,4 @@ class TinyMceArticleTest &lt; 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
test/unit/translatable_content_test.rb 0 → 100644
@@ -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