From 6f9f72c9b5b826de95418d04f3d80e8c5d38ff6e Mon Sep 17 00:00:00 2001 From: Jonathan Kolyer Date: Sun, 3 Nov 2013 01:49:51 -0600 Subject: [PATCH] vrfs-774: changing country value from USA to US for max_mind_geo support --- ruby/spec/factories.rb | 10 ++-------- ruby/spec/jam_ruby/connection_manager_spec.rb | 2 +- ruby/spec/jam_ruby/models/band_search_spec.rb | 8 ++++---- .../jam_ruby/models/musician_search_spec.rb | 17 +++++++++++++---- ruby/spec/jam_ruby/models/search_spec.rb | 6 +++--- ruby/spec/jam_ruby/models/user_search_spec.rb | 8 ++++---- ruby/spec/jam_ruby/models/user_spec.rb | 6 +++--- websocket-gateway/spec/factories.rb | 2 +- 8 files changed, 31 insertions(+), 28 deletions(-) diff --git a/ruby/spec/factories.rb b/ruby/spec/factories.rb index 3a0fa30d4..5de772b2b 100644 --- a/ruby/spec/factories.rb +++ b/ruby/spec/factories.rb @@ -8,7 +8,7 @@ FactoryGirl.define do email_confirmed true city "Apex" state "NC" - country "USA" + country "US" musician true terms_of_service true @@ -77,7 +77,7 @@ FactoryGirl.define do biography "My Biography" city "Apex" state "NC" - country "USA" + country "US" end factory :genre, :class => JamRuby::Genre do @@ -110,12 +110,6 @@ FactoryGirl.define do priority 0 end - factory :musician_instrument2, :class => JamRuby::MusicianInstrument do - instrument { Instrument.find('tuba') } - proficiency_level 1 - priority 0 - end - factory :invited_user, :class => JamRuby::InvitedUser do sequence(:email) { |n| "user#{n}@someservice.com" } autofriend false diff --git a/ruby/spec/jam_ruby/connection_manager_spec.rb b/ruby/spec/jam_ruby/connection_manager_spec.rb index 0056e9486..aacd9f6c9 100644 --- a/ruby/spec/jam_ruby/connection_manager_spec.rb +++ b/ruby/spec/jam_ruby/connection_manager_spec.rb @@ -12,7 +12,7 @@ describe ConnectionManager do end def create_user(first_name, last_name, email, options = {:musician => true}) - @conn.exec("INSERT INTO users (first_name, last_name, email, musician, encrypted_password, city, state, country) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING id", [first_name, last_name, email, options[:musician], '1', 'Apex', 'NC', 'USA']) do |result| + @conn.exec("INSERT INTO users (first_name, last_name, email, musician, encrypted_password, city, state, country) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING id", [first_name, last_name, email, options[:musician], '1', 'Apex', 'NC', 'US']) do |result| return result.getvalue(0, 0) end end diff --git a/ruby/spec/jam_ruby/models/band_search_spec.rb b/ruby/spec/jam_ruby/models/band_search_spec.rb index 99af288f8..2af217b3f 100644 --- a/ruby/spec/jam_ruby/models/band_search_spec.rb +++ b/ruby/spec/jam_ruby/models/band_search_spec.rb @@ -6,7 +6,7 @@ describe User do before(:each) do - @band = Band.save(nil, "Example Band", "www.bands.com", "zomg we rock", "Apex", "NC", "USA", ["hip hop"], user.id, nil, nil) + @band = Band.save(nil, "Example Band", "www.bands.com", "zomg we rock", "Apex", "NC", "US", ["hip hop"], user.id, nil, nil) end @@ -93,7 +93,7 @@ describe User do end it "should tokenize correctly" do - @band2 = Band.save(nil, "Peach pit", "www.bands.com", "zomg we rock", "Apex", "NC", "USA", ["hip hop"], user.id, nil, nil) + @band2 = Band.save(nil, "Peach pit", "www.bands.com", "zomg we rock", "Apex", "NC", "US", ["hip hop"], user.id, nil, nil) ws = Band.search("pea") ws.length.should == 1 user_result = ws[0] @@ -102,7 +102,7 @@ describe User do it "should not return anything with a 1 character search" do - @band2 = Band.save(nil, "Peach pit", "www.bands.com", "zomg we rock", "Apex", "NC", "USA", ["hip hop"], user.id, nil, nil) + @band2 = Band.save(nil, "Peach pit", "www.bands.com", "zomg we rock", "Apex", "NC", "US", ["hip hop"], user.id, nil, nil) ws = Band.search("pe") ws.length.should == 1 user_result = ws[0] @@ -111,4 +111,4 @@ describe User do ws = Band.search("p") ws.length.should == 0 end -end \ No newline at end of file +end diff --git a/ruby/spec/jam_ruby/models/musician_search_spec.rb b/ruby/spec/jam_ruby/models/musician_search_spec.rb index bfd372f91..18eb61c3d 100644 --- a/ruby/spec/jam_ruby/models/musician_search_spec.rb +++ b/ruby/spec/jam_ruby/models/musician_search_spec.rb @@ -13,7 +13,7 @@ describe User do email_confirmed: true, city: "Apex", state: "NC", - country: "USA" + country: "US" } @users = [] @users << @user1 = FactoryGirl.create(:user, params) @@ -63,17 +63,26 @@ describe User do end it "should find musicians with an instrument" do - @user1.musician_instruments << FactoryGirl.build(:musician_instrument2, user: @user1) + 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' } ii.should_not be_nil params = { :instrument => ii.id } results = User.musician_search(params) - results.all[0].instruments.detect {|inst| inst.id=='tuba'}.id.should == ii.id + results.all.each do |rr| + rr.instruments.detect { |inst| inst.id=='tuba' }.id.should == ii.id + end results.all.count.should == 1 end it "should find musicians within a given distance of location" do - pending + @user1.lat.should_not == nil + params = { :distance => 10, :city => 'New York' } + results = User.musician_search(params) + results.all.count.should == 0 end end diff --git a/ruby/spec/jam_ruby/models/search_spec.rb b/ruby/spec/jam_ruby/models/search_spec.rb index b0798c570..65b658269 100644 --- a/ruby/spec/jam_ruby/models/search_spec.rb +++ b/ruby/spec/jam_ruby/models/search_spec.rb @@ -7,9 +7,9 @@ describe Search do def create_peachy_data - @user = FactoryGirl.create(:user, first_name: "Peach", last_name: "Pit", email: "user@example.com", musician: true, city: "Apex", state: "NC", country:"USA") - @fan = FactoryGirl.create(:user, first_name: "Peach Peach", last_name: "Pit", email: "fan@example.com", musician: false, city: "Apex", state: "NC", country:"USA") - @band = FactoryGirl.create(:band, name: "Peach pit", website: "www.bands.com", biography: "zomg we rock", city: "Apex", state: "NC", country:"USA") + @user = FactoryGirl.create(:user, first_name: "Peach", last_name: "Pit", email: "user@example.com", musician: true, city: "Apex", state: "NC", country:"US") + @fan = FactoryGirl.create(:user, first_name: "Peach Peach", last_name: "Pit", email: "fan@example.com", musician: false, city: "Apex", state: "NC", country:"US") + @band = FactoryGirl.create(:band, name: "Peach pit", website: "www.bands.com", biography: "zomg we rock", city: "Apex", state: "NC", country:"US") end def assert_peachy_data diff --git a/ruby/spec/jam_ruby/models/user_search_spec.rb b/ruby/spec/jam_ruby/models/user_search_spec.rb index 486b955b2..c45b37200 100644 --- a/ruby/spec/jam_ruby/models/user_search_spec.rb +++ b/ruby/spec/jam_ruby/models/user_search_spec.rb @@ -5,7 +5,7 @@ describe User do before(:each) do @user = FactoryGirl.create(:user, first_name: "Example", last_name: "User", email: "user@example.com", password: "foobar", password_confirmation: "foobar", musician: true, email_confirmed: true, - city: "Apex", state: "NC", country: "USA") + city: "Apex", state: "NC", country: "US") end it "should allow search of one user" do @@ -54,7 +54,7 @@ describe User do it "should tokenize correctly" do @user2 = FactoryGirl.create(:user, first_name: "peaches", last_name: "test", email: "peach@example.com", password: "foobar", password_confirmation: "foobar", musician: true, email_confirmed: true, - city: "Apex", state: "NC", country: "USA") + city: "Apex", state: "NC", country: "US") ws = User.search("pea") ws.length.should == 1 user_result = ws[0] @@ -64,7 +64,7 @@ describe User do it "users who have signed up, but not confirmed should show up in search index due to VRFS-378" do @user3 = FactoryGirl.create(:user, first_name: "unconfirmed", last_name: "unconfirmed", email: "unconfirmed@example.com", password: "foobar", password_confirmation: "foobar", musician: true, email_confirmed: false, - city: "Apex", state: "NC", country: "USA") + city: "Apex", state: "NC", country: "US") ws = User.search("unconfirmed") ws.length.should == 1 @@ -77,4 +77,4 @@ describe User do user_result = ws[0] user_result.id.should == @user3.id end -end \ No newline at end of file +end diff --git a/ruby/spec/jam_ruby/models/user_spec.rb b/ruby/spec/jam_ruby/models/user_spec.rb index df1c01ef7..581ac4d80 100644 --- a/ruby/spec/jam_ruby/models/user_spec.rb +++ b/ruby/spec/jam_ruby/models/user_spec.rb @@ -6,7 +6,7 @@ describe User do before do @user = User.new(first_name: "Example", last_name: "User", email: "user@example.com", - password: "foobar", password_confirmation: "foobar", city: "Apex", state: "NC", country: "USA", terms_of_service: true, musician: true) + password: "foobar", password_confirmation: "foobar", city: "Apex", state: "NC", country: "US", terms_of_service: true, musician: true) @user.musician_instruments << FactoryGirl.build(:musician_instrument, user: @user) end @@ -285,7 +285,7 @@ describe User do end describe "create_dev_user" do - before { @dev_user = User.create_dev_user("Seth", "Call", "seth@jamkazam.com", "Jam123", "Austin", "Texas", "USA", nil, nil) } + before { @dev_user = User.create_dev_user("Seth", "Call", "seth@jamkazam.com", "Jam123", "Austin", "Texas", "US", nil, nil) } subject { @dev_user } @@ -298,7 +298,7 @@ describe User do end describe "updates record" do - before { @dev_user = User.create_dev_user("Seth", "Call2", "seth@jamkazam.com", "Jam123", "Austin", "Texas", "USA", nil, nil) } + before { @dev_user = User.create_dev_user("Seth", "Call2", "seth@jamkazam.com", "Jam123", "Austin", "Texas", "US", nil, nil) } it { should be_valid } diff --git a/websocket-gateway/spec/factories.rb b/websocket-gateway/spec/factories.rb index 3522a5e5f..6a388c637 100644 --- a/websocket-gateway/spec/factories.rb +++ b/websocket-gateway/spec/factories.rb @@ -9,7 +9,7 @@ FactoryGirl.define do musician true city "Apex" state "NC" - country "USA" + country "US" terms_of_service true