Commit eeb785d2fe783966593f8522d44f999636b7fb27
Exists in
master
and in
29 other branches
Merge branch 'hide_translation' into 'master'
Hide translation Hide translation on article and event creation if there is no languages defined in environment See merge request !443
Showing
6 changed files
with
61 additions
and
1 deletions
Show diff stats
lib/noosfero/translatable_content.rb
test/functional/cms_controller_test.rb
... | ... | @@ -1438,6 +1438,9 @@ class CmsControllerTest < ActionController::TestCase |
1438 | 1438 | end |
1439 | 1439 | |
1440 | 1440 | should 'article language should be selected' do |
1441 | + e = Environment.default | |
1442 | + e.languages = ['ru'] | |
1443 | + e.save | |
1441 | 1444 | textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'ru') |
1442 | 1445 | get :edit, :profile => @profile.identifier, :id => textile.id |
1443 | 1446 | assert_tag :option, :attributes => { :selected => 'selected', :value => 'ru' }, :parent => { |
... | ... | @@ -1445,6 +1448,9 @@ class CmsControllerTest < ActionController::TestCase |
1445 | 1448 | end |
1446 | 1449 | |
1447 | 1450 | should 'list possible languages and include blank option' do |
1451 | + e = Environment.default | |
1452 | + e.languages = ['en', 'pt','fr','hy','de', 'ru', 'es', 'eo', 'it'] | |
1453 | + e.save | |
1448 | 1454 | get :new, :profile => @profile.identifier, :type => 'TextileArticle' |
1449 | 1455 | assert_equal Noosfero.locales.invert, assigns(:locales) |
1450 | 1456 | assert_tag :option, :attributes => { :value => '' }, :parent => { | ... | ... |
test/functional/content_viewer_controller_test.rb
... | ... | @@ -958,6 +958,8 @@ class ContentViewerControllerTest < ActionController::TestCase |
958 | 958 | end |
959 | 959 | |
960 | 960 | should 'display add translation link if article is translatable' do |
961 | + environment.languages = ['en'] | |
962 | + environment.save | |
961 | 963 | login_as @profile.identifier |
962 | 964 | textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'en') |
963 | 965 | 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 | 319 | should 'be notifiable' do |
320 | 320 | assert Event.new.notifiable? |
321 | 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 | 348 | end | ... | ... |
test/unit/text_article_test.rb
... | ... | @@ -85,4 +85,29 @@ class TextArticleTest < ActiveSupport::TestCase |
85 | 85 | assert_equal "<img src=\"/test.png\" />", article.body |
86 | 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 | 113 | end | ... | ... |
test/unit/translatable_content_test.rb