Commit 9986427022d2ce43200b46850c5a1a54beb1a1c1
1 parent
cae48f79
Exists in
master
and in
29 other branches
Fix named to not join
Showing
2 changed files
with
4 additions
and
3 deletions
Show diff stats
app/models/article.rb
@@ -152,9 +152,10 @@ class Article < ActiveRecord::Base | @@ -152,9 +152,10 @@ class Article < ActiveRecord::Base | ||
152 | {:conditions => [ 'parent_id is null and profile_id = ?', profile.id ]} | 152 | {:conditions => [ 'parent_id is null and profile_id = ?', profile.id ]} |
153 | } | 153 | } |
154 | 154 | ||
155 | + named_scope :join_profile, :joins => [:profile] | ||
156 | + | ||
155 | named_scope :public, | 157 | named_scope :public, |
156 | - :conditions => [ "advertise = ? AND published = ? AND profiles.visible = ? AND profiles.public_profile = ?", true, true, true, true ], | ||
157 | - :include => [:profile] | 158 | + :conditions => [ "advertise = ? AND published = ? AND profiles.visible = ? AND profiles.public_profile = ?", true, true, true, true ] |
158 | 159 | ||
159 | named_scope :more_recent, | 160 | named_scope :more_recent, |
160 | :conditions => [ "advertise = ? AND published = ? AND profiles.visible = ? AND profiles.public_profile = ? AND | 161 | :conditions => [ "advertise = ? AND published = ? AND profiles.visible = ? AND profiles.public_profile = ? AND |
test/unit/article_test.rb
@@ -1773,7 +1773,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -1773,7 +1773,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
1773 | art4 = Article.create!(:name => 'article 4', :profile_id => fast_create(Person, :visible => false).id) | 1773 | art4 = Article.create!(:name => 'article 4', :profile_id => fast_create(Person, :visible => false).id) |
1774 | art5 = Article.create!(:name => 'article 5', :profile_id => fast_create(Person, :public_profile => false).id) | 1774 | art5 = Article.create!(:name => 'article 5', :profile_id => fast_create(Person, :public_profile => false).id) |
1775 | 1775 | ||
1776 | - articles = Article.public | 1776 | + articles = Article.join_profile.public |
1777 | assert_includes articles, art1 | 1777 | assert_includes articles, art1 |
1778 | assert_not_includes articles, art2 | 1778 | assert_not_includes articles, art2 |
1779 | assert_not_includes articles, art3 | 1779 | assert_not_includes articles, art3 |