Commit d968021fec308b3354fff17fb94c6c32677ca034
1 parent
77aa69cd
Exists in
master
and in
27 other branches
hide translations when there is no languages in environment
Showing
6 changed files
with
61 additions
and
1 deletions
Show diff stats
lib/noosfero/translatable_content.rb
test/functional/cms_controller_test.rb
@@ -1432,6 +1432,9 @@ class CmsControllerTest < ActionController::TestCase | @@ -1432,6 +1432,9 @@ class CmsControllerTest < ActionController::TestCase | ||
1432 | end | 1432 | end |
1433 | 1433 | ||
1434 | should 'article language should be selected' do | 1434 | should 'article language should be selected' do |
1435 | + e = Environment.default | ||
1436 | + e.languages = ['ru'] | ||
1437 | + e.save | ||
1435 | textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'ru') | 1438 | textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'ru') |
1436 | get :edit, :profile => @profile.identifier, :id => textile.id | 1439 | get :edit, :profile => @profile.identifier, :id => textile.id |
1437 | assert_tag :option, :attributes => { :selected => 'selected', :value => 'ru' }, :parent => { | 1440 | assert_tag :option, :attributes => { :selected => 'selected', :value => 'ru' }, :parent => { |
@@ -1439,6 +1442,9 @@ class CmsControllerTest < ActionController::TestCase | @@ -1439,6 +1442,9 @@ class CmsControllerTest < ActionController::TestCase | ||
1439 | end | 1442 | end |
1440 | 1443 | ||
1441 | should 'list possible languages and include blank option' do | 1444 | should 'list possible languages and include blank option' do |
1445 | + e = Environment.default | ||
1446 | + e.languages = ['en', 'pt','fr','hy','de', 'ru', 'es', 'eo', 'it'] | ||
1447 | + e.save | ||
1442 | get :new, :profile => @profile.identifier, :type => 'TextileArticle' | 1448 | get :new, :profile => @profile.identifier, :type => 'TextileArticle' |
1443 | assert_equal Noosfero.locales.invert, assigns(:locales) | 1449 | assert_equal Noosfero.locales.invert, assigns(:locales) |
1444 | assert_tag :option, :attributes => { :value => '' }, :parent => { | 1450 | assert_tag :option, :attributes => { :value => '' }, :parent => { |
test/functional/content_viewer_controller_test.rb
@@ -978,6 +978,8 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -978,6 +978,8 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
978 | end | 978 | end |
979 | 979 | ||
980 | should 'display add translation link if article is translatable' do | 980 | should 'display add translation link if article is translatable' do |
981 | + environment.languages = ['en'] | ||
982 | + environment.save | ||
981 | login_as @profile.identifier | 983 | login_as @profile.identifier |
982 | textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'en') | 984 | textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'en') |
983 | xhr :get, :view_page, :profile => @profile.identifier, :page => textile.path, :toolbar => true | 985 | xhr :get, :view_page, :profile => @profile.identifier, :page => textile.path, :toolbar => true |
test/unit/event_test.rb
@@ -319,4 +319,30 @@ class EventTest < ActiveSupport::TestCase | @@ -319,4 +319,30 @@ class EventTest < ActiveSupport::TestCase | ||
319 | should 'be notifiable' do | 319 | should 'be notifiable' do |
320 | assert Event.new.notifiable? | 320 | assert Event.new.notifiable? |
321 | end | 321 | end |
322 | + | ||
323 | + should 'not be translatable if there is no language available on environment' do | ||
324 | + environment = fast_create(Environment) | ||
325 | + environment.languages = nil | ||
326 | + profile = fast_create(Person, :environment_id => environment.id) | ||
327 | + | ||
328 | + event = Event.new(:profile => profile) | ||
329 | + | ||
330 | + assert !event.translatable? | ||
331 | + end | ||
332 | + | ||
333 | + should 'be translatable if there is languages on environment' do | ||
334 | + environment = fast_create(Environment) | ||
335 | + environment.languages = nil | ||
336 | + profile = fast_create(Person, :environment_id => environment.id) | ||
337 | + event = fast_create(Event, :profile_id => profile.id) | ||
338 | + | ||
339 | + assert !event.translatable? | ||
340 | + | ||
341 | + | ||
342 | + environment.languages = ['en','pt','fr'] | ||
343 | + environment.save | ||
344 | + event.reload | ||
345 | + assert event.translatable? | ||
346 | + end | ||
347 | + | ||
322 | end | 348 | end |
test/unit/text_article_test.rb
@@ -85,4 +85,29 @@ class TextArticleTest < ActiveSupport::TestCase | @@ -85,4 +85,29 @@ class TextArticleTest < ActiveSupport::TestCase | ||
85 | assert_equal "<img src=\"/test.png\" />", article.body | 85 | assert_equal "<img src=\"/test.png\" />", article.body |
86 | end | 86 | end |
87 | 87 | ||
88 | + should 'not be translatable if there is no language available on environment' do | ||
89 | + environment = fast_create(Environment) | ||
90 | + environment.languages = nil | ||
91 | + profile = fast_create(Person, :environment_id => environment.id) | ||
92 | + | ||
93 | + text = TextArticle.new(:profile => profile) | ||
94 | + | ||
95 | + assert !text.translatable? | ||
96 | + end | ||
97 | + | ||
98 | + should 'be translatable if there is languages on environment' do | ||
99 | + environment = fast_create(Environment) | ||
100 | + environment.languages = nil | ||
101 | + profile = fast_create(Person, :environment_id => environment.id) | ||
102 | + text = fast_create(TextArticle, :profile_id => profile.id) | ||
103 | + | ||
104 | + assert !text.translatable? | ||
105 | + | ||
106 | + | ||
107 | + environment.languages = ['en','pt','fr'] | ||
108 | + environment.save | ||
109 | + text.reload | ||
110 | + assert text.translatable? | ||
111 | + end | ||
112 | + | ||
88 | end | 113 | end |
test/unit/translatable_content_test.rb
@@ -3,7 +3,7 @@ require_relative "../test_helper" | @@ -3,7 +3,7 @@ require_relative "../test_helper" | ||
3 | class TranslatableContentTest < ActiveSupport::TestCase | 3 | class TranslatableContentTest < ActiveSupport::TestCase |
4 | 4 | ||
5 | class Content | 5 | class Content |
6 | - attr_accessor :parent | 6 | + attr_accessor :parent, :profile |
7 | include Noosfero::TranslatableContent | 7 | include Noosfero::TranslatableContent |
8 | end | 8 | end |
9 | 9 |