Commit f3cf61a8eeb5f9618159e994a8cce5662955d081
1 parent
e66e4541
Exists in
master
and in
29 other branches
ActionItem501: removing filtering by initial
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2145 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
16 changed files
with
1 additions
and
386 deletions
Show diff stats
app/controllers/public/search_controller.rb
... | ... | @@ -6,7 +6,7 @@ class SearchController < ApplicationController |
6 | 6 | before_filter :prepare_filter |
7 | 7 | before_filter :check_search_whole_site |
8 | 8 | before_filter :load_search_assets |
9 | - before_filter :check_valid_assets, :only => [ :assets, :directory ] | |
9 | + before_filter :check_valid_assets, :only => [ :assets ] | |
10 | 10 | |
11 | 11 | no_design_blocks |
12 | 12 | |
... | ... | @@ -191,14 +191,6 @@ class SearchController < ApplicationController |
191 | 191 | end |
192 | 192 | attr_reader :category |
193 | 193 | |
194 | - def directory | |
195 | - @results = { @asset => @finder.find_by_initial(@asset, params[:initial]) } | |
196 | - @asset_name = gettext(SEARCH_IN.find { |entry| entry.first == @asset }[1]) | |
197 | - @names = { @asset => @asset_name } | |
198 | - | |
199 | - render :action => @asset | |
200 | - end | |
201 | - | |
202 | 194 | def tags |
203 | 195 | @tags = Tag.find(:all).inject({}) do |memo,tag| |
204 | 196 | memo[tag.name] = tag.taggings.count |
... | ... | @@ -211,25 +203,6 @@ class SearchController < ApplicationController |
211 | 203 | @tagged = @tag.taggings.map(&:taggable) |
212 | 204 | end |
213 | 205 | |
214 | - def sellers | |
215 | - # FIXME use a better select for category | |
216 | - @categories = ProductCategory.find(:all) | |
217 | - @regions = Region.find(:all).select{|r|r.lat && r.lng} | |
218 | - @product_category = ProductCategory.find(params[:category]) if params[:category] | |
219 | - @region = Region.find(params[:region]) if params[:region] | |
220 | - | |
221 | - options = {} | |
222 | - options.merge! :origin => [params[:lat].to_f, params[:long].to_f], :within => params[:radius] if !params[:lat].blank? && !params[:long].blank? && !params[:radius].blank? | |
223 | - options.merge! :origin => [@region.lat, @region.lng], :within => params[:radius] if !params[:region].blank? && !params[:radius].blank? | |
224 | - if @product_category | |
225 | - finder = CategoryFinder.new(@product_category) | |
226 | - product_ids = finder.find('products',nil) | |
227 | - options.merge! :include => :products, :conditions => ['products.id IN ?', product_ids ] | |
228 | - end | |
229 | - | |
230 | - @enterprises = Enterprise.find(:all, options) | |
231 | - end | |
232 | - | |
233 | 206 | ####################################################### |
234 | 207 | |
235 | 208 | def popup | ... | ... |
app/models/article.rb
... | ... | @@ -136,10 +136,6 @@ class Article < ActiveRecord::Base |
136 | 136 | false |
137 | 137 | end |
138 | 138 | |
139 | - def self.find_by_initial(initial) | |
140 | - self.find(:all, :order => 'articles.name', :conditions => [ 'articles.name like (?) or articles.name like (?)', initial + '%', initial.upcase + '%']) | |
141 | - end | |
142 | - | |
143 | 139 | def display_to?(user) |
144 | 140 | if self.profile.public_content |
145 | 141 | true | ... | ... |
app/models/category_finder.rb
... | ... | @@ -28,10 +28,6 @@ class CategoryFinder |
28 | 28 | find(asset, nil, :limit => limit) |
29 | 29 | end |
30 | 30 | |
31 | - def find_by_initial(asset, initial) | |
32 | - asset_class(asset).find(:all, options_for_find_by_initial(asset_class(asset), initial)) | |
33 | - end | |
34 | - | |
35 | 31 | def count(asset, query='', options={}) |
36 | 32 | # because will_paginate needs a page |
37 | 33 | options = {:page => 1}.merge(options) |
... | ... | @@ -81,20 +77,6 @@ class CategoryFinder |
81 | 77 | end |
82 | 78 | end |
83 | 79 | |
84 | - def options_for_find_by_initial(klass, initial) | |
85 | - # FIXME copy/pasted from options_for_find above !!! | |
86 | - case klass.name | |
87 | - when 'Product' | |
88 | - {:select => 'distinct products.*', :joins => 'inner join categories_profiles on products.enterprise_id = categories_profiles.profile_id', :conditions => ['categories_profiles.category_id = (?) and (products.name like (?) or products.name like (?))', category_id, initial + '%', initial.upcase + '%']} | |
89 | - when 'Article' | |
90 | - {:joins => 'inner join articles_categories on (articles_categories.article_id = articles.id)', :conditions => ['articles_categories.category_id = (?) and (%s.name like (?) or %s.name like (?))' % [klass.table_name, klass.table_name], category_id, initial + '%', initial.upcase + '%']} | |
91 | - when 'Person', 'Community', 'Enterprise' | |
92 | - {:joins => 'inner join categories_profiles on (categories_profiles.profile_id = profiles.id)', :conditions => ['categories_profiles.category_id = (?) and (%s.name like (?) or %s.name like (?))' % [klass.table_name, klass.table_name], category_id, initial + '%', initial.upcase + '%']} | |
93 | - else | |
94 | - raise "unreconized class #{klass.name}" | |
95 | - end | |
96 | - end | |
97 | - | |
98 | 80 | def asset_class(asset) |
99 | 81 | asset.to_s.singularize.camelize.constantize |
100 | 82 | end | ... | ... |
app/models/environment_finder.rb
... | ... | @@ -42,10 +42,6 @@ class EnvironmentFinder |
42 | 42 | find(asset, nil, :limit => limit) |
43 | 43 | end |
44 | 44 | |
45 | - def find_by_initial(asset, initial) | |
46 | - @environment.send(asset).find_by_initial(initial) | |
47 | - end | |
48 | - | |
49 | 45 | def count(asset, query = '', options = {}) |
50 | 46 | # because will_paginate needs a page |
51 | 47 | options = {:page => 1}.merge(options) | ... | ... |
app/models/product.rb
... | ... | @@ -43,10 +43,6 @@ class Product < ActiveRecord::Base |
43 | 43 | self.find(:all, :order => 'id desc', :limit => limit) |
44 | 44 | end |
45 | 45 | |
46 | - def self.find_by_initial(initial) | |
47 | - self.find(:all, :order => 'products.name', :conditions => [ 'products.name like (?) or products.name like (?)', initial + '%', initial.upcase + '%']) | |
48 | - end | |
49 | - | |
50 | 46 | def enterprise_updated(e) |
51 | 47 | self.lat = e.lat |
52 | 48 | self.lng = e.lng | ... | ... |
app/models/profile.rb
... | ... | @@ -342,10 +342,6 @@ class Profile < ActiveRecord::Base |
342 | 342 | self.find(:all, :order => 'id desc', :limit => limit) |
343 | 343 | end |
344 | 344 | |
345 | - def self.find_by_initial(initial) | |
346 | - self.find(:all, :order => 'profiles.name', :conditions => [ 'profiles.name like (?) or profiles.name like (?)', (initial + '%'), (initial.upcase + '%') ]) | |
347 | - end | |
348 | - | |
349 | 345 | # returns +true+ if the given +user+ can see profile information about this |
350 | 346 | # +profile+, and +false+ otherwise. |
351 | 347 | def display_info_to?(user) | ... | ... |
app/views/search/_directory.rhtml
... | ... | @@ -1,6 +0,0 @@ |
1 | -<div class="search-index"> | |
2 | - <%= link_to_unless(params[:initial].blank?, _('Recent'), params.merge(:action => 'assets', :initial => nil)) %> | |
3 | - | |
4 | - <%= ('a'..'z').map { |initial| link_to_unless(params[:initial] == initial, initial.upcase, params.merge(:action => 'directory', :asset => @asset, :initial => initial)) }.join(' ') %> | |
5 | -</div> | |
6 | -<br style='clear:both'/> |
app/views/search/people.rhtml
... | ... | @@ -11,7 +11,6 @@ |
11 | 11 | <%= _('(recently added)') %> |
12 | 12 | <% end %> |
13 | 13 | </h1> |
14 | - <%= render :partial => 'directory' %> | |
15 | 14 | <% else %> |
16 | 15 | <h1> <%= @asset_name %>: <%= h(@category ? (_('Search results for "%{query}" in "%{category}"') % { :query => @query, :category => @category.name}) : (_('Search results for "%s"') % @query)) %> </h1> |
17 | 16 | <div style='text-align: center'> | ... | ... |
public/designs/themes/zen3/stylesheets/controller_search.css
public/stylesheets/controller_search.css
... | ... | @@ -2,17 +2,6 @@ |
2 | 2 | position: relative; /* to the text appear on MSIE 6 */ |
3 | 3 | } |
4 | 4 | |
5 | -.search-index { | |
6 | - text-align: center; | |
7 | - position: relative; | |
8 | - font-weight: bold; | |
9 | -} | |
10 | - | |
11 | -.search-index a { | |
12 | - text-decoration: none; | |
13 | - font-weight: normal; | |
14 | -} | |
15 | - | |
16 | 5 | #search-results { |
17 | 6 | margin-top: 10px; |
18 | 7 | /* none by default, but... Who knows the future? :-) */ | ... | ... |
test/functional/search_controller_test.rb
... | ... | @@ -514,138 +514,6 @@ class SearchControllerTest < Test::Unit::TestCase |
514 | 514 | assert_no_tag :tag => 'input', :attributes => { :name => 'find_in[]', :value => 'products', :checked => 'checked' } |
515 | 515 | end |
516 | 516 | |
517 | - ############## directory #################### | |
518 | - should 'link to people directory in index' do | |
519 | - get :assets, :asset => 'people' | |
520 | - assert_tag :tag => 'a', :attributes => { :href => '/directory/people/a'}, :content => 'A' | |
521 | - assert_tag :tag => 'a', :attributes => { :href => '/directory/people/b'}, :content => 'B' | |
522 | - end | |
523 | - | |
524 | - should 'display link in people directory to other initials but not to the same' do | |
525 | - get :directory, :asset => 'people', :initial => 'r' | |
526 | - assert_tag :tag => 'a', :attributes => { :href => '/directory/people/a' } | |
527 | - assert_no_tag :tag => 'a', :attributes => { :href => '/directory/people/r' } | |
528 | - end | |
529 | - | |
530 | - should 'display link to recent people while in directory' do | |
531 | - get :directory, :asset => 'people', :initial => 'a' | |
532 | - assert_tag :tag => 'a', :attributes => { :href => '/assets/people' }, :content => 'Recent' | |
533 | - end | |
534 | - | |
535 | - should 'not leave category in link to other char in directory' do | |
536 | - cat = Category.create!(:name => 'just_a_category', :environment => Environment.default) | |
537 | - get :directory, :asset => 'people', :initial => 'r', :category_path => cat.path.split('/') | |
538 | - assert_tag :tag => 'a', :attributes => { :href => "/directory/people/k/#{cat.path}" } | |
539 | - end | |
540 | - | |
541 | - ############### directory for every kind of asset ################# | |
542 | - should 'display people with a given initial' do | |
543 | - included = create_user('fergunson').person | |
544 | - not_included = create_user('yanerson').person | |
545 | - | |
546 | - get :directory, :asset => 'people', :initial => 'f' | |
547 | - assert_includes assigns(:results)[:people], included | |
548 | - assert_not_includes assigns(:results)[:people], not_included | |
549 | - end | |
550 | - | |
551 | - should 'display communities with a given initial' do | |
552 | - c1 = Community.create!(:name => 'a beautiful community', :identifier => 'bea_comm', :environment => Environment.default) | |
553 | - c2 = Community.create!(:name => 'beautiful community (another)', :identifier => 'an_bea_comm', :environment => Environment.default) | |
554 | - | |
555 | - get :directory, :asset => 'communities', :initial => 'a' | |
556 | - | |
557 | - assert_includes assigns(:results)[:communities], c1 | |
558 | - assert_not_includes assigns(:results)[:communities], c2 | |
559 | - end | |
560 | - | |
561 | - should 'display enterprises with a given initial' do | |
562 | - ent1 = Enterprise.create!(:name => 'aaaaa', :identifier => 'teste1') | |
563 | - ent2 = Enterprise.create!(:name => 'bbbbb', :identifier => 'teste2') | |
564 | - | |
565 | - get :directory, :asset => 'enterprises', :initial => 'a' | |
566 | - | |
567 | - assert_includes assigns(:results)[:enterprises], ent1 | |
568 | - assert_not_includes assigns(:results)[:enterprises], ent2 | |
569 | - end | |
570 | - | |
571 | - should 'display articles with a given initial' do | |
572 | - person = create_user('teste').person | |
573 | - art1 = person.articles.build(:name => 'an article to be found'); art1.save! | |
574 | - art2 = person.articles.build(:name => 'better article'); art2.save! | |
575 | - | |
576 | - get :directory, :asset => 'articles', :initial => 'a' | |
577 | - | |
578 | - assert_includes assigns(:results)[:articles], art1 | |
579 | - assert_not_includes assigns(:results)[:articles], art2 | |
580 | - end | |
581 | - | |
582 | - should 'display people with a given initial, under a specific category' do | |
583 | - | |
584 | - in_category_and_with_initial = create_user('fergunson').person | |
585 | - in_category_and_with_initial.add_category @category | |
586 | - | |
587 | - in_category_but_without_initial = create_user('yanerson').person | |
588 | - in_category_but_without_initial.add_category @category | |
589 | - | |
590 | - not_in_category_but_with_initial = create_user('fergy').person | |
591 | - not_in_category_and_without_initial = create_user('xalanxalan').person | |
592 | - | |
593 | - get :directory, :asset => 'people', :initial => 'f', :category_path => [ 'my-category' ] | |
594 | - | |
595 | - assert_includes assigns(:results)[:people], in_category_and_with_initial | |
596 | - assert_not_includes assigns(:results)[:people], in_category_but_without_initial | |
597 | - assert_not_includes assigns(:results)[:people], not_in_category_but_with_initial | |
598 | - assert_not_includes assigns(:results)[:people], not_in_category_and_without_initial | |
599 | - end | |
600 | - | |
601 | - should 'display communities with a given initial, under a specific category' do | |
602 | - c1 = Community.create!(:name => 'a beautiful community', :identifier => 'bea_comm', :environment => Environment.default); c1.add_category @category | |
603 | - c2 = Community.create!(:name => 'beautiful community (another)', :identifier => 'an_bea_comm', :environment => Environment.default); c2.add_category @category | |
604 | - | |
605 | - c3 = Community.create!(:name => 'another beautiful community', :identifier => 'lalala', :environment => Environment.default); | |
606 | - c4 = Community.create!(:name => 'damn beautiful community (another)', :identifier => 'lelele', :environment => Environment.default) | |
607 | - | |
608 | - get :directory, :asset => 'communities', :initial => 'a', :category_path => [ 'my-category' ] | |
609 | - | |
610 | - assert_includes assigns(:results)[:communities], c1 | |
611 | - assert_not_includes assigns(:results)[:communities], c2 | |
612 | - assert_not_includes assigns(:results)[:communities], c3 | |
613 | - assert_not_includes assigns(:results)[:communities], c4 | |
614 | - end | |
615 | - | |
616 | - should 'display enterprises with a given initial, under a specific category' do | |
617 | - ent1 = Enterprise.create!(:name => 'aaaaa', :identifier => 'teste1'); ent1.add_category @category | |
618 | - ent2 = Enterprise.create!(:name => 'bbbbb', :identifier => 'teste2'); ent1.add_category @category | |
619 | - ent3 = Enterprise.create!(:name => 'aaaa1111', :identifier => 'teste1111') | |
620 | - ent4 = Enterprise.create!(:name => 'ddddd', :identifier => 'teste2222') | |
621 | - | |
622 | - get :directory, :asset => 'enterprises', :initial => 'a', :category_path => [ 'my-category' ] | |
623 | - | |
624 | - assert_includes assigns(:results)[:enterprises], ent1 | |
625 | - assert_not_includes assigns(:results)[:enterprises], ent2 | |
626 | - assert_not_includes assigns(:results)[:enterprises], ent3 | |
627 | - assert_not_includes assigns(:results)[:enterprises], ent4 | |
628 | - end | |
629 | - | |
630 | - should 'display articles with a given initial, under a specific category' do | |
631 | - person = create_user('teste').person | |
632 | - art1 = person.articles.build(:name => 'an article to be found'); art1.save! | |
633 | - art1.add_category @category | |
634 | - art2 = person.articles.build(:name => 'better article'); art2.save! | |
635 | - art2.add_category @category | |
636 | - | |
637 | - art3 = person.articles.build(:name => 'another article to be found'); art3.save! | |
638 | - art4 = person.articles.build(:name => 'damn article'); art4.save! | |
639 | - | |
640 | - | |
641 | - get :directory, :asset => 'articles', :initial => 'a', :category_path => [ 'my-category' ] | |
642 | - | |
643 | - assert_includes assigns(:results)[:articles], art1 | |
644 | - assert_not_includes assigns(:results)[:articles], art2 | |
645 | - assert_not_includes assigns(:results)[:articles], art3 | |
646 | - assert_not_includes assigns(:results)[:articles], art4 | |
647 | - end | |
648 | - | |
649 | 517 | should 'find enterprise by product category' do |
650 | 518 | ent1 = Enterprise.create!(:name => 'test1', :identifier => 'test1') |
651 | 519 | prod_cat = ProductCategory.create!(:name => 'pctest', :environment => Environment.default) | ... | ... |
test/unit/article_test.rb
... | ... | @@ -211,18 +211,6 @@ class ArticleTest < Test::Unit::TestCase |
211 | 211 | assert_equal [articles[1], articles[0]], person.articles.most_commented(2) |
212 | 212 | end |
213 | 213 | |
214 | - should 'find by initial' do | |
215 | - person = create_user('testuser').person | |
216 | - | |
217 | - a1 = person.articles.create!(:name => 'An nice article') | |
218 | - a2 = person.articles.create!(:name => 'Better stay off here') | |
219 | - | |
220 | - list = Article.find_by_initial('a') | |
221 | - | |
222 | - assert_includes list, a1 | |
223 | - assert_not_includes list, a2 | |
224 | - end | |
225 | - | |
226 | 214 | should 'identify itself as a non-folder' do |
227 | 215 | assert !Article.new.folder?, 'should identify itself as non-folder' |
228 | 216 | end | ... | ... |
test/unit/category_finder_test.rb
... | ... | @@ -111,34 +111,6 @@ class CategoryFinderTest < ActiveSupport::TestCase |
111 | 111 | assert_includes f.find(:articles, 'beautiful'), article |
112 | 112 | end |
113 | 113 | |
114 | - should 'find communites by initial in category hierarchy' do | |
115 | - parent = Category.create!(:name => 'parent category', :environment => Environment.default) | |
116 | - child = Category.create!(:name => 'child category', :environment => Environment.default, :parent => parent) | |
117 | - p1 = create_user('people_1').person | |
118 | - p1.name = 'person with inner beaity' | |
119 | - p1.add_category(child) | |
120 | - p1.save! | |
121 | - | |
122 | - parent.reload | |
123 | - | |
124 | - f = CategoryFinder.new(parent) | |
125 | - assert_includes f.find_by_initial(:people, 'p'), p1 | |
126 | - end | |
127 | - | |
128 | - should 'find articles by initial in category hierarchy' do | |
129 | - parent = Category.create!(:name => 'parent category', :environment => Environment.default) | |
130 | - child = Category.create!(:name => 'child category', :environment => Environment.default, :parent => parent) | |
131 | - | |
132 | - p1 = create_user('people_1').person | |
133 | - | |
134 | - article = p1.articles.create!(:name => 'fucking beautiful article', :category_ids => [child.id]) | |
135 | - | |
136 | - parent.reload | |
137 | - | |
138 | - f = CategoryFinder.new(parent) | |
139 | - assert_includes f.find_by_initial(:articles, 'f'), article | |
140 | - end | |
141 | - | |
142 | 114 | should 'list recent enterprises' do |
143 | 115 | ent = Enterprise.create!(:name => 'teste', :identifier => 'teste', :category_ids => [@category.id]) |
144 | 116 | assert_includes @finder.recent('enterprises'), ent |
... | ... | @@ -276,60 +248,6 @@ class CategoryFinderTest < ActiveSupport::TestCase |
276 | 248 | assert_equal [articles[1], articles[0]], @finder.most_commented_articles(2) |
277 | 249 | end |
278 | 250 | |
279 | - should 'find people by initial' do | |
280 | - p1 = create_user('aaaa').person; p1.add_category(@category) | |
281 | - p2 = create_user('bbbb').person; p2.add_category(@category) | |
282 | - | |
283 | - list = CategoryFinder.new(@category).find_by_initial(:people, 'a') | |
284 | - | |
285 | - assert_includes list, p1 | |
286 | - assert_not_includes list, p2 | |
287 | - end | |
288 | - | |
289 | - should 'find enterprises by initial' do | |
290 | - ent1 = Enterprise.create!(:name => 'aaaa', :identifier => 'aaaa'); ent1.add_category(@category) | |
291 | - ent2 = Enterprise.create!(:name => 'bbbb', :identifier => 'bbbb'); ent2.add_category(@category) | |
292 | - | |
293 | - list = CategoryFinder.new(@category).find_by_initial(:enterprises, 'a') | |
294 | - | |
295 | - assert_includes list, ent1 | |
296 | - assert_not_includes list, ent2 | |
297 | - end | |
298 | - | |
299 | - should 'find communities by initial' do | |
300 | - comm1 = Community.create!(:name => 'aaaa', :identifier => 'aaaa'); comm1.add_category(@category) | |
301 | - comm2 = Community.create!(:name => 'bbbb', :identifier => 'bbbb'); comm2.add_category(@category) | |
302 | - | |
303 | - list = CategoryFinder.new(@category).find_by_initial(:communities, 'a') | |
304 | - | |
305 | - assert_includes list, comm1 | |
306 | - assert_not_includes list, comm2 | |
307 | - end | |
308 | - | |
309 | - should 'find products by initial' do | |
310 | - ent = Enterprise.create!(:name => 'my enterprise', :identifier => 'myent') | |
311 | - ent.add_category(@category) | |
312 | - | |
313 | - p1 = ent.products.create!(:name => 'A product') | |
314 | - p2 = ent.products.create!(:name => 'Better product') | |
315 | - | |
316 | - list = CategoryFinder.new(@category).find_by_initial(:products, 'a') | |
317 | - | |
318 | - assert_includes list, p1 | |
319 | - assert_not_includes list, p2 | |
320 | - end | |
321 | - | |
322 | - should 'find articles by initial' do | |
323 | - person = create_user('testuser').person | |
324 | - a1 = person.articles.create!(:name => 'aaaa', :body => '...', :category_ids => [@category.id]) | |
325 | - a2 = person.articles.create!(:name => 'bbbb', :body => '...', :category_ids => [@category.id]) | |
326 | - | |
327 | - list = CategoryFinder.new(@category).find_by_initial(:articles, 'a') | |
328 | - | |
329 | - assert_includes list, a1 | |
330 | - assert_not_includes list, a2 | |
331 | - end | |
332 | - | |
333 | 251 | should 'find person and enterprise by radius and region' do |
334 | 252 | finder = CategoryFinder.new(@category) |
335 | 253 | ... | ... |
test/unit/environment_finder_test.rb
... | ... | @@ -125,59 +125,6 @@ class EnvironmentFinderTest < ActiveSupport::TestCase |
125 | 125 | assert_equal 99, finder.count('people', 'my query', {}) |
126 | 126 | end |
127 | 127 | |
128 | - should 'find articles by initial' do | |
129 | - person = create_user('teste').person | |
130 | - art1 = person.articles.create!(:name => 'an article to be found') | |
131 | - art2 = person.articles.create!(:name => 'blah: an article that cannot be found') | |
132 | - found = EnvironmentFinder.new(Environment.default).find_by_initial(:articles, 'a') | |
133 | - | |
134 | - assert_includes found, art1 | |
135 | - assert_not_includes found, art2 | |
136 | - end | |
137 | - | |
138 | - should 'find people by initial' do | |
139 | - finder = EnvironmentFinder.new(Environment.default) | |
140 | - p1 = create_user('alalala').person | |
141 | - p2 = create_user('blablabla').person | |
142 | - | |
143 | - found = finder.find_by_initial(:people, 'a') | |
144 | - assert_includes found, p1 | |
145 | - assert_not_includes found, p2 | |
146 | - end | |
147 | - | |
148 | - should 'find communities by initial' do | |
149 | - c1 = Community.create!(:name => 'a beautiful community', :identifier => 'bea_comm', :environment => Environment.default) | |
150 | - c2 = Community.create!(:name => 'b: another beautiful community', :identifier => 'bbbbb', :environment => Environment.default) | |
151 | - | |
152 | - found = EnvironmentFinder.new(Environment.default).find_by_initial(:communities, 'a') | |
153 | - | |
154 | - assert_includes found, c1 | |
155 | - assert_not_includes found, c2 | |
156 | - end | |
157 | - | |
158 | - should 'find products by initial' do | |
159 | - finder = EnvironmentFinder.new(Environment.default) | |
160 | - ent = Enterprise.create!(:name => 'teste', :identifier => 'teste') | |
161 | - prod1 = ent.products.create!(:name => 'a beautiful product') | |
162 | - prod2 = ent.products.create!(:name => 'b: a beautiful product') | |
163 | - | |
164 | - found = finder.find_by_initial(:products, 'a') | |
165 | - | |
166 | - assert_includes found, prod1 | |
167 | - assert_not_includes found, prod2 | |
168 | - end | |
169 | - | |
170 | - should 'find enterprises by initial' do | |
171 | - finder = EnvironmentFinder.new(Environment.default) | |
172 | - ent1 = Enterprise.create!(:name => 'aaaa', :identifier => 'aaaa') | |
173 | - ent2 = Enterprise.create!(:name => 'bbbb', :identifier => 'bbbb') | |
174 | - | |
175 | - found = finder.find_by_initial(:enterprises, 'a') | |
176 | - | |
177 | - assert_includes found, ent1 | |
178 | - assert_not_includes found, ent2 | |
179 | - end | |
180 | - | |
181 | 128 | should 'find person and enterprise by radius and region' do |
182 | 129 | finder = EnvironmentFinder.new(Environment.default) |
183 | 130 | ... | ... |
test/unit/product_test.rb
... | ... | @@ -55,18 +55,6 @@ class ProductTest < Test::Unit::TestCase |
55 | 55 | end |
56 | 56 | end |
57 | 57 | |
58 | - should 'find by initial' do | |
59 | - p1 = Product.create!(:name => 'a test product') | |
60 | - p2 = Product.create!(:name => 'A Capitalize Product') | |
61 | - p3 = Product.create!(:name => 'b-class test product') | |
62 | - | |
63 | - list = Product.find_by_initial('a') | |
64 | - | |
65 | - assert_includes list, p1 | |
66 | - assert_includes list, p2 | |
67 | - assert_not_includes list, p3 | |
68 | - end | |
69 | - | |
70 | 58 | should 'calculate catagory full name' do |
71 | 59 | cat = mock |
72 | 60 | cat.expects(:full_name).returns('A/B/C') | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -437,16 +437,6 @@ class ProfileTest < Test::Unit::TestCase |
437 | 437 | assert profile.articles.find_by_path('feed').advertise? |
438 | 438 | end |
439 | 439 | |
440 | - should 'find by initial' do | |
441 | - inside = Profile.create!(:name => 'A person', :identifier => 'aperson') | |
442 | - outside = Profile.create!(:name => 'B Movie', :identifier => 'bmovie') | |
443 | - | |
444 | - list = Profile.find_by_initial('a') | |
445 | - | |
446 | - assert_includes list, inside | |
447 | - assert_not_includes list, outside | |
448 | - end | |
449 | - | |
450 | 440 | should 'have latitude and longitude' do |
451 | 441 | e = Enterprise.create!(:name => 'test1', :identifier => 'test1') |
452 | 442 | e.lat, e.lng = 45, 45 ; e.save! | ... | ... |