Commit 50ba75f56dadbe0e919c57cda43ca872ee9ae68a
1 parent
b2005120
Exists in
master
and in
29 other branches
ActionItem405: removing comment searching stuff
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1907 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
5 changed files
with
0 additions
and
63 deletions
Show diff stats
app/models/category_finder.rb
... | ... | @@ -56,8 +56,6 @@ class CategoryFinder |
56 | 56 | |
57 | 57 | def options_for_find(klass, options={}) |
58 | 58 | case klass.name |
59 | - when 'Comment' | |
60 | - {: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) | |
61 | 59 | when 'Product' |
62 | 60 | {: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) |
63 | 61 | when 'Article', 'Person', 'Community', 'Enterprise', 'Event' |
... | ... | @@ -70,8 +68,6 @@ class CategoryFinder |
70 | 68 | def options_for_find_by_initial(klass, initial) |
71 | 69 | # FIXME copy/pasted from options_for_find above !!! |
72 | 70 | case klass.name |
73 | - when 'Comment' | |
74 | - {: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 + '%']} | |
75 | 71 | when 'Product' |
76 | 72 | {: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 + '%']} |
77 | 73 | when 'Article', 'Person', 'Community', 'Enterprise' | ... | ... |
app/models/comment.rb
... | ... | @@ -39,10 +39,6 @@ class Comment < ActiveRecord::Base |
39 | 39 | self.find(:all, :order => 'created_at desc, id desc', :limit => limit) |
40 | 40 | end |
41 | 41 | |
42 | - def self.find_by_initial(initial) | |
43 | - self.find(:all, :order => 'comments.title', :conditions => ['comments.title like (?) or comments.title like (?)', initial + '%', initial.upcase + '%']) | |
44 | - end | |
45 | - | |
46 | 42 | after_save :notify_article |
47 | 43 | after_destroy :notify_article |
48 | 44 | def notify_article | ... | ... |
app/models/environment.rb
... | ... | @@ -220,7 +220,4 @@ class Environment < ActiveRecord::Base |
220 | 220 | |
221 | 221 | has_many :events, :through => :profiles, :source => :articles, :class_name => 'Event' |
222 | 222 | |
223 | - # FIXME is this the better/faster way to do this? | |
224 | - has_many :comments, :through => :articles | |
225 | - | |
226 | 223 | end | ... | ... |
test/unit/category_finder_test.rb
... | ... | @@ -40,25 +40,6 @@ class CategoryFinderTest < ActiveSupport::TestCase |
40 | 40 | assert_not_includes @finder.find('articles','found'), art2 |
41 | 41 | end |
42 | 42 | |
43 | - should 'search for comments in a specific category' do | |
44 | - person = create_user('teste').person | |
45 | - | |
46 | - # in category | |
47 | - art1 = person.articles.build(:name => 'an article to be found') | |
48 | - art1.categories << @category | |
49 | - art1.save! | |
50 | - comment1 = art1.comments.build(:title => 'comment to be found', :body => 'hfyfyh', :author => person); comment1.save! | |
51 | - | |
52 | - # not in category | |
53 | - art2 = person.articles.build(:name => 'another article to be found') | |
54 | - art2.save! | |
55 | - comment2 = art2.comments.build(:title => 'comment to be found', :body => 'hfyfyh', :author => person); comment2.save! | |
56 | - | |
57 | - list = @finder.find(:comments, 'found') | |
58 | - assert_includes list, comment1 | |
59 | - assert_not_includes list, comment2 | |
60 | - end | |
61 | - | |
62 | 43 | should 'search for enterprises in a specific category' do |
63 | 44 | |
64 | 45 | # in category |
... | ... | @@ -239,19 +220,6 @@ class CategoryFinderTest < ActiveSupport::TestCase |
239 | 220 | assert_not_includes list, a2 |
240 | 221 | end |
241 | 222 | |
242 | - should 'find comments by initial' do | |
243 | - person = create_user('testuser').person | |
244 | - a1 = person.articles.create!(:name => 'aaaa', :body => '...', :categories => [@category]) | |
245 | - | |
246 | - c1 = a1.comments.create!(:title => 'aaaaa', :body => '...', :author => person) | |
247 | - c2 = a1.comments.create!(:title => 'bbbbb', :body => '...', :author => person) | |
248 | - | |
249 | - list = CategoryFinder.new(@category).find_by_initial(:comments, 'a') | |
250 | - | |
251 | - assert_includes list, c1 | |
252 | - assert_not_includes list, c2 | |
253 | - end | |
254 | - | |
255 | 223 | should 'find person and enterprise by radius and region' do |
256 | 224 | finder = CategoryFinder.new(@category) |
257 | 225 | ... | ... |
test/unit/environment_finder_test.rb
... | ... | @@ -23,13 +23,6 @@ class EnvironmentFinderTest < ActiveSupport::TestCase |
23 | 23 | assert_includes finder.find(:communities, 'beautiful'), c1 |
24 | 24 | end |
25 | 25 | |
26 | - should 'find comments' do | |
27 | - person = create_user('teste').person | |
28 | - art = person.articles.build(:name => 'an article to be found'); art.save! | |
29 | - comment = art.comments.build(:title => 'comment to be found', :body => 'some sample text', :author => person); comment.save! | |
30 | - assert_includes EnvironmentFinder.new(Environment.default).find(:comments, 'found'), comment | |
31 | - end | |
32 | - | |
33 | 26 | should 'find products' do |
34 | 27 | finder = EnvironmentFinder.new(Environment.default) |
35 | 28 | ent = Enterprise.create!(:name => 'teste', :identifier => 'teste') |
... | ... | @@ -95,19 +88,6 @@ class EnvironmentFinderTest < ActiveSupport::TestCase |
95 | 88 | assert_not_includes found, c2 |
96 | 89 | end |
97 | 90 | |
98 | - should 'find comments by initial' do | |
99 | - person = create_user('teste').person | |
100 | - art = person.articles.build(:name => 'an article to be found'); art.save! | |
101 | - | |
102 | - comment1 = art.comments.build(:title => 'a comment to be found', :body => 'some sample text', :author => person); comment1.save! | |
103 | - comment2 = art.comments.build(:title => 'b: a comment to be found', :body => 'some sample text', :author => person); comment2.save! | |
104 | - | |
105 | - found = EnvironmentFinder.new(Environment.default).find_by_initial(:comments, 'a') | |
106 | - | |
107 | - assert_includes found, comment1 | |
108 | - assert_not_includes found, comment2 | |
109 | - end | |
110 | - | |
111 | 91 | should 'find products by initial' do |
112 | 92 | finder = EnvironmentFinder.new(Environment.default) |
113 | 93 | ent = Enterprise.create!(:name => 'teste', :identifier => 'teste') | ... | ... |