From e3817276a3c0b386c74f5326575976ffd73c993f Mon Sep 17 00:00:00 2001 From: Arthur Del Esposte Date: Wed, 4 Nov 2015 13:40:30 +0000 Subject: [PATCH] Fix article visibility in creation --- app/models/article.rb | 11 ++++++++--- test/unit/community_test.rb | 2 ++ test/unit/person_test.rb | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/models/article.rb b/app/models/article.rb index 5130196..e9a25ea 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -29,9 +29,14 @@ class Article < ActiveRecord::Base def initialize(*params) super - if !params.blank? && params.first.has_key?(:profile) && !params.first[:profile].blank? - profile = params.first[:profile] - self.published = false unless profile.public? + if !params.blank? + if params.first.has_key?(:profile) && !params.first[:profile].blank? + profile = params.first[:profile] + self.published = false unless profile.public_profile + end + + self.published = params.first["published"] if params.first.has_key?("published") + self.published = params.first[:published] if params.first.has_key?(:published) end end diff --git a/test/unit/community_test.rb b/test/unit/community_test.rb index e0edf22..a42e67c 100644 --- a/test/unit/community_test.rb +++ b/test/unit/community_test.rb @@ -39,7 +39,9 @@ class CommunityTest < ActiveSupport::TestCase community = create(Community, :environment => Environment.default, :name => 'my new community') assert_kind_of Blog, community.articles.find_by_path(blog.path) + assert community.articles.find_by_path(blog.path).published? assert_kind_of RssFeed, community.articles.find_by_path(blog.feed.path) + assert community.articles.find_by_path(blog.feed.path).published? end should 'have contact_person' do diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb index 72f865b..8e18c85 100644 --- a/test/unit/person_test.rb +++ b/test/unit/person_test.rb @@ -181,7 +181,9 @@ class PersonTest < ActiveSupport::TestCase person = create(User).person assert_kind_of Blog, person.articles.find_by_path(blog.path) + assert person.articles.find_by_path(blog.path).published? assert_kind_of RssFeed, person.articles.find_by_path(blog.feed.path) + assert person.articles.find_by_path(blog.feed.path).published? end should 'create a default set of blocks' do -- libgit2 0.21.2