Commit 5e592c2009475389827491395cc5917fe8e5c2cf
Exists in
theme-brasil-digital-from-staging
and in
8 other branches
fix merge conflit
Showing
2 changed files
with
12 additions
and
0 deletions
Show diff stats
app/models/person.rb
@@ -90,6 +90,7 @@ class Person < Profile | @@ -90,6 +90,7 @@ class Person < Profile | ||
90 | #Article followers relation | 90 | #Article followers relation |
91 | has_many :article_followers, :dependent => :destroy | 91 | has_many :article_followers, :dependent => :destroy |
92 | has_many :following_articles, :class_name => 'Article', :through => :article_followers, :source => :article | 92 | has_many :following_articles, :class_name => 'Article', :through => :article_followers, :source => :article |
93 | + has_many :comments, :foreign_key => :author_id | ||
93 | 94 | ||
94 | has_many :friendships, :dependent => :destroy | 95 | has_many :friendships, :dependent => :destroy |
95 | has_many :friends, :class_name => 'Person', :through => :friendships | 96 | has_many :friends, :class_name => 'Person', :through => :friendships |
test/unit/person_test.rb
@@ -1832,6 +1832,17 @@ class PersonTest < ActiveSupport::TestCase | @@ -1832,6 +1832,17 @@ class PersonTest < ActiveSupport::TestCase | ||
1832 | person = user.person | 1832 | person = user.person |
1833 | person.user.expects(:save!).never | 1833 | person.user.expects(:save!).never |
1834 | person.save! | 1834 | person.save! |
1835 | + end | ||
1836 | + | ||
1837 | + should 'access comments through profile' do | ||
1838 | + p1 = fast_create(Person) | ||
1839 | + p2 = fast_create(Person) | ||
1840 | + article = fast_create(Article) | ||
1841 | + c1 = fast_create(Comment, :source_id => article.id, :author_id => p1.id) | ||
1842 | + c2 = fast_create(Comment, :source_id => article.id, :author_id => p2.id) | ||
1843 | + c3 = fast_create(Comment, :source_id => article.id, :author_id => p1.id) | ||
1844 | + | ||
1845 | + assert_equivalent [c1,c3], p1.comments | ||
1835 | end | 1846 | end |
1836 | 1847 | ||
1837 | end | 1848 | end |