Commit 0c8eff93411b037fb8374bd149f2f494d675d499

Authored by Antonio Terceiro
1 parent 771ecf69

rails3: remove useless named scope in Article

It seems it was created to avoid including too many objects when
retrieving that named_scope, but using :joins instead of :includes
already does this.
app/models/article.rb
... ... @@ -217,10 +217,8 @@ class Article < ActiveRecord::Base
217 217 {:conditions => [ 'parent_id is null and profile_id = ?', profile.id ]}
218 218 }
219 219  
220   - scope :join_profile, :joins => [:profile]
221   -
222 220 scope :public,
223   - :conditions => [ "advertise = ? AND published = ? AND profiles.visible = ? AND profiles.public_profile = ?", true, true, true, true ]
  221 + :conditions => [ "advertise = ? AND published = ? AND profiles.visible = ? AND profiles.public_profile = ?", true, true, true, true ], :joins => [:profile]
224 222  
225 223 scope :more_recent,
226 224 :conditions => [ "advertise = ? AND published = ? AND profiles.visible = ? AND profiles.public_profile = ? AND
... ...
test/unit/article_test.rb
... ... @@ -1618,7 +1618,7 @@ class ArticleTest < ActiveSupport::TestCase
1618 1618 art4 = Article.create!(:name => 'article 4', :profile_id => fast_create(Person, :visible => false).id)
1619 1619 art5 = Article.create!(:name => 'article 5', :profile_id => fast_create(Person, :public_profile => false).id)
1620 1620  
1621   - articles = Article.join_profile.public
  1621 + articles = Article.public
1622 1622 assert_includes articles, art1
1623 1623 assert_not_includes articles, art2
1624 1624 assert_not_includes articles, art3
... ...