diff --git a/app/models/article.rb b/app/models/article.rb index 60e8be4..9fbf25f 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -197,7 +197,7 @@ class Article < ActiveRecord::Base if user.nil? false else - (user == self.profile) || user.memberships.include?(self.profile) || (profile.kind_of?(Person) && profile.friends.include?(user)) + (user == self.profile) || user.memberships.include?(self.profile) || (profile.kind_of?(Person) && profile.friends.include?(user)) || user.has_permission?('post_content', self.profile) end end end diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index e4b8308..e8d2352 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -507,6 +507,17 @@ class ArticleTest < Test::Unit::TestCase assert article.display_to?(friend) end + + should 'display articles to people who can edit them' do + person = create_user('test_user').person + article = Article.create!(:name => 'test article', :profile => person, :public_article => false) + + admin_user = create_user('admin_user').person + admin_user.stubs(:has_permission?).with('post_content', article.profile).returns('true') + + assert article.display_to?(admin_user) + end + should 'make a copy of the article as child of it' do person = create_user('test_user').person a = person.articles.create!(:name => 'test article', :body => 'some text') -- libgit2 0.21.2