2013-10-28 14:22:06 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
2013-11-23 08:18:12 +00:00
|
|
|
describe 'Musician search' do
|
2013-10-28 14:22:06 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
# need a data set with actual distances
|
|
|
|
|
describe "test set A" do
|
2013-10-28 17:03:58 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
before(:each) do
|
|
|
|
|
create_phony_database
|
2014-05-26 19:16:01 +00:00
|
|
|
end
|
|
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
let!(:austin_user) { FactoryGirl.create(:austin_user) }
|
|
|
|
|
let!(:dallas_user) { FactoryGirl.create(:dallas_user) }
|
|
|
|
|
let!(:miami_user) { FactoryGirl.create(:miami_user) }
|
|
|
|
|
let!(:seattle_user) { FactoryGirl.create(:seattle_user) }
|
2014-05-26 19:16:01 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
describe "search on distance" do
|
2014-05-26 19:16:01 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
it "finds self when very local search" do
|
|
|
|
|
Search.musician_filter({distance: 1, orderby: 'distance'}, austin_user).results.should == [austin_user] # just to see that distance is 0 to self
|
|
|
|
|
Search.musician_filter({distance: 1, orderby: 'distance'}, dallas_user).results.should == [dallas_user] # just to see that distance is 0 to self
|
|
|
|
|
Search.musician_filter({distance: 1, orderby: 'distance'}, miami_user).results.should == [miami_user] # just to see that distance is 0 to self
|
|
|
|
|
Search.musician_filter({distance: 1, orderby: 'distance'}, seattle_user).results.should == [seattle_user] # just to see that distance is 0 to self
|
|
|
|
|
end
|
2014-05-26 19:16:01 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
it "finds dallas when in range of austin" do
|
|
|
|
|
expected_results = [austin_user, dallas_user]
|
2014-05-26 19:16:01 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
Search.musician_filter({distance: 500, orderby: 'distance'}, austin_user).results.should == expected_results
|
|
|
|
|
Search.musician_filter({distance: 100, orderby: 'distance'}, austin_user).results.should == [austin_user]
|
|
|
|
|
end
|
2013-10-28 17:03:58 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
it "finds miami when in range of austin" do
|
|
|
|
|
expected_results = [austin_user, dallas_user, miami_user]
|
2013-11-23 06:04:33 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
Search.musician_filter({distance: 1500, orderby: 'distance'}, austin_user).results.should == expected_results
|
|
|
|
|
Search.musician_filter({distance: 300, orderby: 'distance'}, austin_user).results.should == [austin_user, dallas_user]
|
|
|
|
|
Search.musician_filter({distance: 100, orderby: 'distance'}, austin_user).results.should == [austin_user]
|
|
|
|
|
end
|
2013-11-05 10:14:34 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
it "finds seattle when in range of austin" do
|
|
|
|
|
expected_results = [austin_user, dallas_user, miami_user, seattle_user]
|
2013-11-05 12:25:36 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
Search.musician_filter({distance: 2000, orderby: 'distance'}, austin_user).results.should == expected_results
|
|
|
|
|
Search.musician_filter({distance: 1500, orderby: 'distance'}, austin_user).results.should == [austin_user, dallas_user, miami_user]
|
|
|
|
|
Search.musician_filter({distance: 300, orderby: 'distance'}, austin_user).results.should == [austin_user, dallas_user]
|
|
|
|
|
Search.musician_filter({distance: 100, orderby: 'distance'}, austin_user).results.should == [austin_user]
|
|
|
|
|
end
|
2013-11-15 22:35:55 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
it "finds austin & dallas by user-specified location when in range" do
|
|
|
|
|
Search.musician_filter({distance: 500, orderby: 'distance', city: 'Austin', region: 'TX', country: 'US'}, austin_user).results.should == [austin_user, dallas_user]
|
|
|
|
|
end
|
2013-11-23 08:18:12 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
it "finds dallas & austin by user-specified location when in range" do
|
|
|
|
|
Search.musician_filter({distance: 500, orderby: 'distance', city: 'Dallas', region: 'TX', country: 'US'}, austin_user).results.should == [dallas_user, austin_user]
|
|
|
|
|
end
|
2013-11-23 08:18:12 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
it "finds miami user-specified location when in range" do
|
|
|
|
|
Search.musician_filter({distance: 300, orderby: 'distance', city: 'Tampa', region: 'FL', country: 'US'}, austin_user).results.should == [miami_user]
|
|
|
|
|
end
|
2013-10-28 14:22:06 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
it "finds all users with user-specified location when in range" do
|
|
|
|
|
Search.musician_filter({distance: 2500, orderby: 'distance', city: 'Tampa', region: 'FL', country: 'US'}, austin_user).results.should == [miami_user, dallas_user, austin_user, seattle_user]
|
|
|
|
|
end
|
2013-11-23 06:04:33 +00:00
|
|
|
end
|
2013-10-28 14:22:06 +00:00
|
|
|
end
|
|
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
describe "test set B" do
|
|
|
|
|
|
|
|
|
|
before(:each) do
|
|
|
|
|
# @geocode1 = FactoryGirl.create(:geocoder)
|
|
|
|
|
# @geocode2 = FactoryGirl.create(:geocoder)
|
|
|
|
|
t = Time.now - 10.minute
|
|
|
|
|
|
|
|
|
|
@user1 = FactoryGirl.create(:user, created_at: t+1.minute, last_jam_locidispid: 1)
|
|
|
|
|
@user2 = FactoryGirl.create(:user, created_at: t+2.minute, last_jam_locidispid: 2)
|
|
|
|
|
@user3 = FactoryGirl.create(:user, created_at: t+3.minute, last_jam_locidispid: 3)
|
|
|
|
|
@user4 = FactoryGirl.create(:user, created_at: t+4.minute, last_jam_locidispid: 4)
|
|
|
|
|
@user5 = FactoryGirl.create(:user, created_at: t+5.minute, last_jam_locidispid: 5)
|
|
|
|
|
@user6 = FactoryGirl.create(:user, created_at: t+6.minute) # not geocoded
|
|
|
|
|
@user7 = FactoryGirl.create(:user, created_at: t+7.minute, musician: false) # not musician
|
|
|
|
|
|
|
|
|
|
@musicians = []
|
|
|
|
|
@musicians << @user1
|
|
|
|
|
@musicians << @user2
|
|
|
|
|
@musicians << @user3
|
|
|
|
|
@musicians << @user4
|
|
|
|
|
@musicians << @user5
|
|
|
|
|
@musicians << @user6
|
|
|
|
|
|
|
|
|
|
@geomusicians = []
|
|
|
|
|
@geomusicians << @user1
|
|
|
|
|
@geomusicians << @user2
|
|
|
|
|
@geomusicians << @user3
|
|
|
|
|
@geomusicians << @user4
|
|
|
|
|
@geomusicians << @user5
|
|
|
|
|
|
|
|
|
|
# from these scores:
|
|
|
|
|
# user1 has scores other users in user1 location, and with user2, user3, user4
|
|
|
|
|
# user2 has scores with users in user3 and user4 location
|
|
|
|
|
# Score.delete_all
|
|
|
|
|
Score.createx(1, 'a', 1, 1, 'a', 1, 10)
|
|
|
|
|
Score.createx(1, 'a', 1, 2, 'b', 2, 20)
|
|
|
|
|
Score.createx(1, 'a', 1, 3, 'c', 3, 30)
|
|
|
|
|
Score.createx(1, 'a', 1, 4, 'd', 4, 40)
|
|
|
|
|
Score.createx(2, 'b', 2, 3, 'c', 3, 15)
|
|
|
|
|
Score.createx(2, 'b', 2, 4, 'd', 4, 70)
|
2013-11-23 06:04:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
context 'default filter settings' do
|
2013-11-23 08:18:12 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
it "finds all musicians" do
|
|
|
|
|
# expects all the musicians (geocoded)
|
|
|
|
|
results = Search.musician_filter({score_limit: Search::TEST_SCORE})
|
|
|
|
|
results.search_type.should == :musicians_filter
|
|
|
|
|
results.results.count.should == @musicians.length
|
|
|
|
|
results.results.should eq @musicians.reverse
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "finds all musicians page 1" do
|
|
|
|
|
# expects all the musicians
|
|
|
|
|
results = Search.musician_filter({page: 1, score_limit: Search::TEST_SCORE})
|
|
|
|
|
results.search_type.should == :musicians_filter
|
|
|
|
|
results.results.count.should == @musicians.length
|
|
|
|
|
results.results.should eq @musicians.reverse
|
2013-11-23 06:04:33 +00:00
|
|
|
end
|
2013-11-05 15:07:02 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
it "finds all musicians page 2" do
|
|
|
|
|
# expects no musicians (all fit on page 1)
|
|
|
|
|
results = Search.musician_filter({page: 2, score_limit: Search::TEST_SCORE})
|
|
|
|
|
results.search_type.should == :musicians_filter
|
|
|
|
|
results.results.count.should == 0
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "finds all musicians page 1 per_page 3" do
|
|
|
|
|
# expects three of the musicians
|
|
|
|
|
results = Search.musician_filter({per_page: 3, score_limit: Search::TEST_SCORE})
|
|
|
|
|
results.search_type.should == :musicians_filter
|
|
|
|
|
results.results.count.should == 3
|
|
|
|
|
results.results.should eq @musicians.reverse.slice(0, 3)
|
|
|
|
|
end
|
2013-11-26 06:03:42 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
it "finds all musicians page 2 per_page 3" do
|
|
|
|
|
# expects two of the musicians
|
|
|
|
|
results = Search.musician_filter({page: 2, per_page: 3, score_limit: Search::TEST_SCORE})
|
|
|
|
|
results.search_type.should == :musicians_filter
|
|
|
|
|
results.results.count.should == 3
|
|
|
|
|
results.results.should eq @musicians.reverse.slice(3, 3)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "finds all musicians page 3 per_page 3" do
|
|
|
|
|
# expects two of the musicians
|
|
|
|
|
results = Search.musician_filter({page: 3, per_page: 3, score_limit: Search::TEST_SCORE})
|
|
|
|
|
results.search_type.should == :musicians_filter
|
|
|
|
|
results.results.count.should == 0
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "sorts musicians by followers" do
|
|
|
|
|
# establish sorting order
|
|
|
|
|
|
|
|
|
|
# @user4
|
|
|
|
|
f1 = Follow.new
|
|
|
|
|
f1.user = @user2
|
|
|
|
|
f1.followable = @user4
|
|
|
|
|
f1.save
|
|
|
|
|
|
|
|
|
|
f2 = Follow.new
|
|
|
|
|
f2.user = @user3
|
|
|
|
|
f2.followable = @user4
|
|
|
|
|
f2.save
|
|
|
|
|
|
|
|
|
|
f3 = Follow.new
|
|
|
|
|
f3.user = @user4
|
|
|
|
|
f3.followable = @user4
|
|
|
|
|
f3.save
|
|
|
|
|
|
|
|
|
|
# @user3
|
|
|
|
|
f4 = Follow.new
|
|
|
|
|
f4.user = @user3
|
|
|
|
|
f4.followable = @user3
|
|
|
|
|
f4.save
|
|
|
|
|
|
|
|
|
|
f5 = Follow.new
|
|
|
|
|
f5.user = @user4
|
|
|
|
|
f5.followable = @user3
|
|
|
|
|
f5.save
|
|
|
|
|
|
|
|
|
|
# @user2
|
|
|
|
|
f6 = Follow.new
|
|
|
|
|
f6.user = @user1
|
|
|
|
|
f6.followable = @user2
|
|
|
|
|
f6.save
|
|
|
|
|
|
|
|
|
|
# @user4.followers.concat([@user2, @user3, @user4])
|
|
|
|
|
# @user3.followers.concat([@user3, @user4])
|
|
|
|
|
# @user2.followers.concat([@user1])
|
|
|
|
|
expect(@user4.followers.count).to be 3
|
|
|
|
|
expect(Follow.count).to be 6
|
|
|
|
|
|
|
|
|
|
# refresh the order to ensure it works right
|
|
|
|
|
f1 = Follow.new
|
|
|
|
|
f1.user = @user3
|
|
|
|
|
f1.followable = @user2
|
|
|
|
|
f1.save
|
|
|
|
|
|
|
|
|
|
f2 = Follow.new
|
|
|
|
|
f2.user = @user4
|
|
|
|
|
f2.followable = @user2
|
|
|
|
|
f2.save
|
|
|
|
|
|
|
|
|
|
f3 = Follow.new
|
|
|
|
|
f3.user = @user2
|
|
|
|
|
f3.followable = @user2
|
|
|
|
|
f3.save
|
|
|
|
|
|
|
|
|
|
# @user2.followers.concat([@user3, @user4, @user2])
|
|
|
|
|
results = Search.musician_filter({:per_page => @musicians.size, score_limit: Search::TEST_SCORE, orderby: 'followed'}, @user3)
|
|
|
|
|
expect(results.results[0].id).to eq(@user2.id)
|
|
|
|
|
|
|
|
|
|
# check the follower count for given entry
|
|
|
|
|
expect(results.results[0].search_follow_count.to_i).not_to eq(0)
|
|
|
|
|
# check the follow relationship between current_user and result
|
|
|
|
|
expect(results.is_follower?(@user2)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'paginates properly' do
|
|
|
|
|
# make sure pagination works right
|
|
|
|
|
params = {:per_page => 2, :page => 1, score_limit: Search::TEST_SCORE}
|
|
|
|
|
results = Search.musician_filter(params)
|
|
|
|
|
expect(results.results.count).to be 2
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def make_recording(usr)
|
|
|
|
|
connection = FactoryGirl.create(:connection, :user => usr, locidispid: usr.last_jam_locidispid)
|
|
|
|
|
instrument = FactoryGirl.create(:instrument, :description => 'a great instrument')
|
|
|
|
|
track = FactoryGirl.create(:track, :connection => connection, :instrument => instrument)
|
|
|
|
|
music_session = FactoryGirl.create(:active_music_session, :creator => usr, :musician_access => true)
|
|
|
|
|
# music_session.connections << connection
|
|
|
|
|
# music_session.save
|
|
|
|
|
connection.join_the_session(music_session, true, nil, usr, 10)
|
|
|
|
|
recording = Recording.start(music_session, usr)
|
|
|
|
|
recording.stop
|
|
|
|
|
recording.reload
|
|
|
|
|
genre = FactoryGirl.create(:genre)
|
|
|
|
|
recording.claim(usr, "name", "description", genre, true)
|
|
|
|
|
recording.reload
|
|
|
|
|
recording
|
2013-11-17 23:29:23 +00:00
|
|
|
end
|
2013-11-26 06:03:42 +00:00
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
def make_session(usr)
|
|
|
|
|
connection = FactoryGirl.create(:connection, :user => usr, locidispid: usr.last_jam_locidispid)
|
|
|
|
|
music_session = FactoryGirl.create(:active_music_session, :creator => usr, :musician_access => true)
|
|
|
|
|
# music_session.connections << connection
|
|
|
|
|
# music_session.save
|
|
|
|
|
connection.join_the_session(music_session, true, nil, usr, 10)
|
2014-05-26 19:16:01 +00:00
|
|
|
end
|
|
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
context 'musician stat counters' do
|
|
|
|
|
|
|
|
|
|
it "displays musicians top followings" do
|
|
|
|
|
f1 = Follow.new
|
|
|
|
|
f1.user = @user4
|
|
|
|
|
f1.followable = @user4
|
|
|
|
|
f1.save
|
|
|
|
|
|
|
|
|
|
f2 = Follow.new
|
|
|
|
|
f2.user = @user4
|
|
|
|
|
f2.followable = @user3
|
|
|
|
|
f2.save
|
|
|
|
|
|
|
|
|
|
f3 = Follow.new
|
|
|
|
|
f3.user = @user4
|
|
|
|
|
f3.followable = @user2
|
|
|
|
|
f3.save
|
|
|
|
|
|
|
|
|
|
# @user4.followers.concat([@user4])
|
|
|
|
|
# @user3.followers.concat([@user4])
|
|
|
|
|
# @user2.followers.concat([@user4])
|
|
|
|
|
expect(@user4.top_followings.count).to eq 3
|
|
|
|
|
expect(@user4.top_followings.map(&:id)).to match_array((@musicians - [@user1, @user5, @user6]).map(&:id))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "friends stat shows friend count" do
|
|
|
|
|
# create friendship record
|
|
|
|
|
Friendship.save(@user1.id, @user2.id)
|
|
|
|
|
# search on user2
|
|
|
|
|
results = Search.musician_filter({score_limit: Search::TEST_SCORE}, @user2)
|
|
|
|
|
friend = results.results.detect { |mm| mm.id == @user1.id }
|
|
|
|
|
expect(friend).to_not be_nil
|
|
|
|
|
expect(results.friend_count(friend)).to be 1
|
|
|
|
|
@user1.reload
|
|
|
|
|
expect(friend.friends?(@user2)).to be true
|
|
|
|
|
expect(results.is_friend?(@user1)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "recording stat shows recording count" do
|
|
|
|
|
Recording.delete_all
|
|
|
|
|
|
|
|
|
|
recording = make_recording(@user1)
|
|
|
|
|
expect(recording.users.length).to be 1
|
|
|
|
|
expect(recording.users.first).to eq(@user1)
|
|
|
|
|
@user1.reload
|
|
|
|
|
expect(@user1.recordings.length).to be 1
|
|
|
|
|
expect(@user1.recordings.first).to eq(recording)
|
|
|
|
|
expect(recording.claimed_recordings.length).to be 1
|
|
|
|
|
expect(@user1.recordings.detect { |rr| rr == recording }).to_not be_nil
|
|
|
|
|
|
|
|
|
|
results = Search.musician_filter({score_limit: Search::TEST_SCORE}, @user1)
|
|
|
|
|
# puts "====================== results #{results.inspect}"
|
|
|
|
|
uu = results.results.detect { |mm| mm.id == @user1.id }
|
|
|
|
|
expect(uu).to_not be_nil
|
|
|
|
|
|
|
|
|
|
expect(results.record_count(uu)).to be 1
|
|
|
|
|
expect(results.session_count(uu)).to be 1
|
|
|
|
|
end
|
|
|
|
|
|
2014-05-26 19:16:01 +00:00
|
|
|
end
|
|
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
context 'musician sorting' do
|
|
|
|
|
|
|
|
|
|
it "by plays" do
|
|
|
|
|
Recording.delete_all
|
|
|
|
|
|
|
|
|
|
make_recording(@user1)
|
|
|
|
|
# order results by num recordings
|
|
|
|
|
results = Search.musician_filter({orderby: 'plays', score_limit: Search::TEST_SCORE}, @user2)
|
|
|
|
|
# puts "========= results #{results.inspect}"
|
|
|
|
|
expect(results.results.length).to eq(2)
|
|
|
|
|
expect(results.results[0].id).to eq(@user1.id)
|
|
|
|
|
expect(results.results[1].id).to eq(@user3.id)
|
|
|
|
|
|
|
|
|
|
# add more data and make sure order still correct
|
|
|
|
|
make_recording(@user3)
|
|
|
|
|
make_recording(@user3)
|
|
|
|
|
results = Search.musician_filter({:orderby => 'plays', score_limit: Search::TEST_SCORE}, @user2)
|
|
|
|
|
expect(results.results.length).to eq(2)
|
|
|
|
|
expect(results.results[0].id).to eq(@user3.id)
|
|
|
|
|
expect(results.results[1].id).to eq(@user1.id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "by now playing" do
|
|
|
|
|
pending "these tests worked, so leaving them in, but we don't currently have 'Now Playing' in the find musicians screen"
|
|
|
|
|
# should get 1 result with 1 active session
|
|
|
|
|
make_session(@user1)
|
|
|
|
|
results = Search.musician_filter({:orderby => 'playing', score_limit: Search::TEST_SCORE}, @user2)
|
|
|
|
|
expect(results.results.count).to be 1
|
|
|
|
|
expect(results.results.first.id).to eq(@user1.id)
|
|
|
|
|
|
|
|
|
|
# should get 2 results with 2 active sessions
|
|
|
|
|
# sort order should be created_at DESC
|
|
|
|
|
make_session(@user3)
|
|
|
|
|
results = Search.musician_filter({:orderby => 'playing', score_limit: Search::TEST_SCORE}, @user2)
|
|
|
|
|
expect(results.results.count).to be 2
|
|
|
|
|
expect(results.results[0].id).to eq(@user3.id)
|
|
|
|
|
expect(results.results[1].id).to eq(@user1.id)
|
|
|
|
|
end
|
|
|
|
|
|
2014-05-26 19:16:01 +00:00
|
|
|
end
|
|
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
context 'filter settings' do
|
2014-09-22 20:55:02 +00:00
|
|
|
it "searches musicians for an instrument" do
|
2014-09-22 19:20:58 +00:00
|
|
|
minst = FactoryGirl.create(:musician_instrument, {
|
|
|
|
|
:user => @user1,
|
|
|
|
|
:instrument => Instrument.find('tuba')})
|
|
|
|
|
@user1.musician_instruments << minst
|
|
|
|
|
@user1.reload
|
|
|
|
|
ii = @user1.instruments.detect { |inst| inst.id == 'tuba' }
|
|
|
|
|
expect(ii).to_not be_nil
|
2014-09-22 20:55:02 +00:00
|
|
|
results = Search.musician_filter({:instrument => ii.id, score_limit: Search::TEST_SCORE}, @user2)
|
2014-09-22 19:20:58 +00:00
|
|
|
results.results.each do |rr|
|
|
|
|
|
expect(rr.instruments.detect { |inst| inst.id=='tuba' }.id).to eq(ii.id)
|
|
|
|
|
end
|
|
|
|
|
expect(results.results.count).to be 1
|
|
|
|
|
end
|
2013-11-26 06:03:42 +00:00
|
|
|
end
|
|
|
|
|
|
2014-09-22 19:20:58 +00:00
|
|
|
context 'new users' do
|
|
|
|
|
|
|
|
|
|
it "find three for user1" do
|
|
|
|
|
# user2..4 are scored against user1
|
|
|
|
|
ms = Search.new_musicians(@user1, Time.now - 1.week)
|
|
|
|
|
ms.should_not be_nil
|
|
|
|
|
ms.length.should == 3
|
|
|
|
|
ms.should eq [@user2, @user3, @user4]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "find two for user2" do
|
|
|
|
|
# user1,3,4 are scored against user1, but user4 is bad
|
|
|
|
|
ms = Search.new_musicians(@user2, Time.now - 1.week)
|
|
|
|
|
ms.should_not be_nil
|
|
|
|
|
ms.length.should == 2
|
|
|
|
|
ms.should eq [@user3, @user1]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "find two for user3" do
|
|
|
|
|
# user1..2 are scored against user3
|
|
|
|
|
ms = Search.new_musicians(@user3, Time.now - 1.week)
|
|
|
|
|
ms.should_not be_nil
|
|
|
|
|
ms.length.should == 2
|
|
|
|
|
ms.should eq [@user2, @user1]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "find one for user4" do
|
|
|
|
|
# user1..2 are scored against user4, but user2 is bad
|
|
|
|
|
ms = Search.new_musicians(@user4, Time.now - 1.week)
|
|
|
|
|
ms.should_not be_nil
|
|
|
|
|
ms.length.should == 1
|
|
|
|
|
ms.should eq [@user1]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "find none for user5" do
|
|
|
|
|
# user1..4 are not scored against user5
|
|
|
|
|
ms = Search.new_musicians(@user5, Time.now - 1.week)
|
|
|
|
|
ms.should_not be_nil
|
|
|
|
|
ms.length.should == 0
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
2013-11-17 23:29:23 +00:00
|
|
|
end
|
|
|
|
|
|
2013-10-28 14:22:06 +00:00
|
|
|
end
|