Commit d00cb722bba0b59bda5fddf10c46e8b33936d266

Authored by Rafael Martins
1 parent d0eca4af

Fixes for ProfileTest

* Search with latitude/longitude with new search methods
* Correctly searching recent profiles
* New search results object
Showing 1 changed file with 11 additions and 11 deletions   Show diff stats
test/unit/profile_test.rb
... ... @@ -433,10 +433,10 @@ class ProfileTest < ActiveSupport::TestCase
433 433 assert article.advertise?
434 434 end
435 435  
436   - should 'have latitude and longitude' do
437   - e = fast_create(Enterprise, :lat => 45, :lng => 45)
  436 + should 'search with latitude and longitude' do
  437 + e = fast_create(Enterprise, {:lat => 45, :lng => 45}, :search => true)
438 438  
439   - assert_includes Enterprise.find_within(2, :origin => [45, 45]), e
  439 + assert_includes Enterprise.find_by_contents('', {}, {:radius => 2, :latitude => 45, :longitude => 45})[:results].docs, e
440 440 end
441 441  
442 442 should 'have a public profile by default' do
... ... @@ -566,7 +566,7 @@ class ProfileTest < ActiveSupport::TestCase
566 566 assert_equivalent [c2, c3], profile.categories(true)
567 567 end
568 568  
569   - should 'be able to create an profile already with categories' do
  569 + should 'be able to create a profile with categories' do
570 570 c1 = create(Category)
571 571 c2 = create(Category)
572 572  
... ... @@ -959,7 +959,7 @@ class ProfileTest < ActiveSupport::TestCase
959 959  
960 960 Profile.any_instance.stubs(:template).returns(template)
961 961  
962   - p = create(Profile)
  962 + p = create(Profile, :name => "ProfileTest1")
963 963  
964 964 a_copy = p.articles[0]
965 965  
... ... @@ -1548,12 +1548,12 @@ class ProfileTest < ActiveSupport::TestCase
1548 1548  
1549 1549 should 'find more recent profile' do
1550 1550 Profile.delete_all
1551   - p1 = fast_create(Profile, :updated_at => 4.days.ago)
1552   - p2 = fast_create(Profile, :updated_at => Time.now)
1553   - p3 = fast_create(Profile, :updated_at => 2.days.ago)
  1551 + p1 = fast_create(Profile, :created_at => 4.days.ago)
  1552 + p2 = fast_create(Profile, :created_at => Time.now)
  1553 + p3 = fast_create(Profile, :created_at => 2.days.ago)
1554 1554 assert_equal [p2,p3,p1] , Profile.more_recent
1555 1555  
1556   - p4 = fast_create(Profile, :updated_at => 3.days.ago)
  1556 + p4 = fast_create(Profile, :created_at => 3.days.ago)
1557 1557 assert_equal [p2,p3,p4,p1] , Profile.more_recent
1558 1558 end
1559 1559  
... ... @@ -1664,7 +1664,7 @@ class ProfileTest < ActiveSupport::TestCase
1664 1664 should 'index by schema name when database is postgresql' do
1665 1665 uses_postgresql 'schema_one'
1666 1666 p1 = Profile.create!(:name => 'some thing', :identifier => 'some-thing')
1667   - assert_equal [p1], Profile.find_by_contents('thing')[:results]
  1667 + assert_equal [p1], Profile.find_by_contents('thing')[:results].docs
1668 1668 uses_postgresql 'schema_two'
1669 1669 p2 = Profile.create!(:name => 'another thing', :identifier => 'another-thing')
1670 1670 assert_not_includes Profile.find_by_contents('thing')[:results], p1
... ... @@ -1678,7 +1678,7 @@ class ProfileTest < ActiveSupport::TestCase
1678 1678 should 'not index by schema name when database is not postgresql' do
1679 1679 uses_sqlite
1680 1680 p1 = Profile.create!(:name => 'some thing', :identifier => 'some-thing')
1681   - assert_equal Profile.find_by_contents('thing')[:results], [p1]
  1681 + assert_equal [p1], Profile.find_by_contents('thing')[:results].docs
1682 1682 p2 = Profile.create!(:name => 'another thing', :identifier => 'another-thing')
1683 1683 assert_includes Profile.find_by_contents('thing')[:results], p1
1684 1684 assert_includes Profile.find_by_contents('thing')[:results], p2
... ...