diff --git a/app/models/category_finder.rb b/app/models/category_finder.rb index c77f838..66c0ed0 100644 --- a/app/models/category_finder.rb +++ b/app/models/category_finder.rb @@ -56,8 +56,6 @@ class CategoryFinder def options_for_find(klass, options={}) case klass.name - when 'Comment' - {:select => 'distinct comments.*', :joins => 'inner join articles_categories on articles_categories.article_id = comments.article_id', :conditions => ['articles_categories.category_id in (?)', category_ids]}.merge!(options) when 'Product' {:select => 'distinct products.*', :joins => 'inner join categories_profiles on products.enterprise_id = categories_profiles.profile_id', :conditions => ['categories_profiles.category_id in (?)', category_ids]}.merge!(options) when 'Article', 'Person', 'Community', 'Enterprise', 'Event' @@ -70,8 +68,6 @@ class CategoryFinder def options_for_find_by_initial(klass, initial) # FIXME copy/pasted from options_for_find above !!! case klass.name - when 'Comment' - {:select => 'distinct comments.*', :joins => 'inner join articles_categories on articles_categories.article_id = comments.article_id', :conditions => ['articles_categories.category_id in (?) and (comments.title like (?) or comments.title like (?))', category_ids, initial + '%', initial.upcase + '%']} when 'Product' {:select => 'distinct products.*', :joins => 'inner join categories_profiles on products.enterprise_id = categories_profiles.profile_id', :conditions => ['categories_profiles.category_id in (?) and (products.name like (?) or products.name like (?))', category_ids, initial + '%', initial.upcase + '%']} when 'Article', 'Person', 'Community', 'Enterprise' diff --git a/app/models/comment.rb b/app/models/comment.rb index 3d822dc..f68d4a5 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -39,10 +39,6 @@ class Comment < ActiveRecord::Base self.find(:all, :order => 'created_at desc, id desc', :limit => limit) end - def self.find_by_initial(initial) - self.find(:all, :order => 'comments.title', :conditions => ['comments.title like (?) or comments.title like (?)', initial + '%', initial.upcase + '%']) - end - after_save :notify_article after_destroy :notify_article def notify_article diff --git a/app/models/environment.rb b/app/models/environment.rb index a1b5e39..baf5653 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -220,7 +220,4 @@ class Environment < ActiveRecord::Base has_many :events, :through => :profiles, :source => :articles, :class_name => 'Event' - # FIXME is this the better/faster way to do this? - has_many :comments, :through => :articles - end diff --git a/test/unit/category_finder_test.rb b/test/unit/category_finder_test.rb index 64e9317..3c6931f 100644 --- a/test/unit/category_finder_test.rb +++ b/test/unit/category_finder_test.rb @@ -40,25 +40,6 @@ class CategoryFinderTest < ActiveSupport::TestCase assert_not_includes @finder.find('articles','found'), art2 end - should 'search for comments in a specific category' do - person = create_user('teste').person - - # in category - art1 = person.articles.build(:name => 'an article to be found') - art1.categories << @category - art1.save! - comment1 = art1.comments.build(:title => 'comment to be found', :body => 'hfyfyh', :author => person); comment1.save! - - # not in category - art2 = person.articles.build(:name => 'another article to be found') - art2.save! - comment2 = art2.comments.build(:title => 'comment to be found', :body => 'hfyfyh', :author => person); comment2.save! - - list = @finder.find(:comments, 'found') - assert_includes list, comment1 - assert_not_includes list, comment2 - end - should 'search for enterprises in a specific category' do # in category @@ -239,19 +220,6 @@ class CategoryFinderTest < ActiveSupport::TestCase assert_not_includes list, a2 end - should 'find comments by initial' do - person = create_user('testuser').person - a1 = person.articles.create!(:name => 'aaaa', :body => '...', :categories => [@category]) - - c1 = a1.comments.create!(:title => 'aaaaa', :body => '...', :author => person) - c2 = a1.comments.create!(:title => 'bbbbb', :body => '...', :author => person) - - list = CategoryFinder.new(@category).find_by_initial(:comments, 'a') - - assert_includes list, c1 - assert_not_includes list, c2 - end - should 'find person and enterprise by radius and region' do finder = CategoryFinder.new(@category) diff --git a/test/unit/environment_finder_test.rb b/test/unit/environment_finder_test.rb index c749cf1..2082652 100644 --- a/test/unit/environment_finder_test.rb +++ b/test/unit/environment_finder_test.rb @@ -23,13 +23,6 @@ class EnvironmentFinderTest < ActiveSupport::TestCase assert_includes finder.find(:communities, 'beautiful'), c1 end - should 'find comments' do - person = create_user('teste').person - art = person.articles.build(:name => 'an article to be found'); art.save! - comment = art.comments.build(:title => 'comment to be found', :body => 'some sample text', :author => person); comment.save! - assert_includes EnvironmentFinder.new(Environment.default).find(:comments, 'found'), comment - end - should 'find products' do finder = EnvironmentFinder.new(Environment.default) ent = Enterprise.create!(:name => 'teste', :identifier => 'teste') @@ -95,19 +88,6 @@ class EnvironmentFinderTest < ActiveSupport::TestCase assert_not_includes found, c2 end - should 'find comments by initial' do - person = create_user('teste').person - art = person.articles.build(:name => 'an article to be found'); art.save! - - comment1 = art.comments.build(:title => 'a comment to be found', :body => 'some sample text', :author => person); comment1.save! - comment2 = art.comments.build(:title => 'b: a comment to be found', :body => 'some sample text', :author => person); comment2.save! - - found = EnvironmentFinder.new(Environment.default).find_by_initial(:comments, 'a') - - assert_includes found, comment1 - assert_not_includes found, comment2 - end - should 'find products by initial' do finder = EnvironmentFinder.new(Environment.default) ent = Enterprise.create!(:name => 'teste', :identifier => 'teste') -- libgit2 0.21.2