Commit e3817276a3c0b386c74f5326575976ffd73c993f
1 parent
3c4d2c8d
Exists in
master
and in
29 other branches
Fix article visibility in creation
* It fix the private feed creation problem * Closes #148 Signed-off-by: Daniela Soares Feitosa <danielafeitosa@colivre.coop.br>
Showing
3 changed files
with
12 additions
and
3 deletions
Show diff stats
app/models/article.rb
@@ -29,9 +29,14 @@ class Article < ActiveRecord::Base | @@ -29,9 +29,14 @@ class Article < ActiveRecord::Base | ||
29 | def initialize(*params) | 29 | def initialize(*params) |
30 | super | 30 | super |
31 | 31 | ||
32 | - if !params.blank? && params.first.has_key?(:profile) && !params.first[:profile].blank? | ||
33 | - profile = params.first[:profile] | ||
34 | - self.published = false unless profile.public? | 32 | + if !params.blank? |
33 | + if params.first.has_key?(:profile) && !params.first[:profile].blank? | ||
34 | + profile = params.first[:profile] | ||
35 | + self.published = false unless profile.public_profile | ||
36 | + end | ||
37 | + | ||
38 | + self.published = params.first["published"] if params.first.has_key?("published") | ||
39 | + self.published = params.first[:published] if params.first.has_key?(:published) | ||
35 | end | 40 | end |
36 | 41 | ||
37 | end | 42 | end |
test/unit/community_test.rb
@@ -39,7 +39,9 @@ class CommunityTest < ActiveSupport::TestCase | @@ -39,7 +39,9 @@ class CommunityTest < ActiveSupport::TestCase | ||
39 | community = create(Community, :environment => Environment.default, :name => 'my new community') | 39 | community = create(Community, :environment => Environment.default, :name => 'my new community') |
40 | 40 | ||
41 | assert_kind_of Blog, community.articles.find_by_path(blog.path) | 41 | assert_kind_of Blog, community.articles.find_by_path(blog.path) |
42 | + assert community.articles.find_by_path(blog.path).published? | ||
42 | assert_kind_of RssFeed, community.articles.find_by_path(blog.feed.path) | 43 | assert_kind_of RssFeed, community.articles.find_by_path(blog.feed.path) |
44 | + assert community.articles.find_by_path(blog.feed.path).published? | ||
43 | end | 45 | end |
44 | 46 | ||
45 | should 'have contact_person' do | 47 | should 'have contact_person' do |
test/unit/person_test.rb
@@ -181,7 +181,9 @@ class PersonTest < ActiveSupport::TestCase | @@ -181,7 +181,9 @@ class PersonTest < ActiveSupport::TestCase | ||
181 | person = create(User).person | 181 | person = create(User).person |
182 | 182 | ||
183 | assert_kind_of Blog, person.articles.find_by_path(blog.path) | 183 | assert_kind_of Blog, person.articles.find_by_path(blog.path) |
184 | + assert person.articles.find_by_path(blog.path).published? | ||
184 | assert_kind_of RssFeed, person.articles.find_by_path(blog.feed.path) | 185 | assert_kind_of RssFeed, person.articles.find_by_path(blog.feed.path) |
186 | + assert person.articles.find_by_path(blog.feed.path).published? | ||
185 | end | 187 | end |
186 | 188 | ||
187 | should 'create a default set of blocks' do | 189 | should 'create a default set of blocks' do |