diff --git a/app/models/blog.rb b/app/models/blog.rb index 5dea943..d00f0a3 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb @@ -68,7 +68,7 @@ class Blog < Folder settings_items :visualization_format, :type => :string, :default => 'full' validates_inclusion_of :visualization_format, :in => [ 'full', 'short' ], :if => :visualization_format - settings_items :display_posts_in_current_language, :type => :boolean, :default => true + settings_items :display_posts_in_current_language, :type => :boolean, :default => false alias :display_posts_in_current_language? :display_posts_in_current_language diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index e5b696f..f851a16 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -1323,11 +1323,17 @@ class CmsControllerTest < ActionController::TestCase assert_no_tag :select, :attributes => { :id => 'article_language'} end - should 'display display posts in current language input checked on edit blog' do - get :new, :profile => profile.identifier, :type => 'Blog' + should 'display display posts in current language input checked when editing blog' do + profile.articles << Blog.new(:name => 'Blog for test', :profile => profile, :display_posts_in_current_language => true) + get :edit, :profile => profile.identifier, :id => profile.blog.id assert_tag :tag => 'input', :attributes => { :type => 'checkbox', :name => 'article[display_posts_in_current_language]', :checked => 'checked' } end + should 'display display posts in current language input not checked on new blog' do + get :new, :profile => profile.identifier, :type => 'Blog' + assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox', :name => 'article[display_posts_in_current_language]', :checked => 'checked' } + end + should 'update to false blog display posts in current language setting' do profile.articles << Blog.new(:name => 'Blog for test', :profile => profile, :display_posts_in_current_language => true) post :edit, :profile => profile.identifier, :id => profile.blog.id, :article => { :display_posts_in_current_language => false } diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index 1d7e4c7..c741ea0 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -1135,7 +1135,8 @@ class ContentViewerControllerTest < ActionController::TestCase should 'replace article for his translation at blog listing if blog option is enabled' do FastGettext.stubs(:locale).returns('es') blog = fast_create(Blog, :profile_id => profile.id, :path => 'blog') - blog.stubs(:display_posts_in_current_language).returns(true) + blog.display_posts_in_current_language = true + blog.save en_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en', :parent_id => blog.id) es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article) @@ -1147,7 +1148,8 @@ class ContentViewerControllerTest < ActionController::TestCase should 'not display article at blog listing if blog option is enabled and there is no translation for the language' do FastGettext.stubs(:locale).returns('pt') blog = fast_create(Blog, :profile_id => profile.id, :path => 'blog') - blog.stubs(:display_posts_in_current_language).returns(true) + blog.display_posts_in_current_language = true + blog.save en_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en', :parent_id => blog.id) es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article) pt_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'pt', :parent_id => blog.id, :translation_of_id => en_article) @@ -1175,7 +1177,8 @@ class ContentViewerControllerTest < ActionController::TestCase should 'display only native translations at blog listing if blog option is enabled' do FastGettext.stubs(:locale).returns('es') blog = fast_create(Blog, :profile_id => profile.id, :path => 'blog') - blog.stubs(:display_posts_in_current_language).returns(true) + blog.display_posts_in_current_language = true + blog.save! en_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en', :parent_id => blog.id) es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article) blog.posts = [en_article, es_article] diff --git a/test/unit/blog_test.rb b/test/unit/blog_test.rb index 1e17513..70b2a36 100644 --- a/test/unit/blog_test.rb +++ b/test/unit/blog_test.rb @@ -179,10 +179,10 @@ class BlogTest < ActiveSupport::TestCase assert Blog.new.has_posts? end - should 'display posts in current language by default' do + should 'not display posts in current language by default' do blog = Blog.new - assert blog.display_posts_in_current_language - assert blog.display_posts_in_current_language? + assert !blog.display_posts_in_current_language + assert !blog.display_posts_in_current_language? end should 'update display posts in current language setting' do -- libgit2 0.21.2