diff --git a/ruby/spec/jam_ruby/connection_manager_spec.rb b/ruby/spec/jam_ruby/connection_manager_spec.rb index 88672dec2..374d09d84 100644 --- a/ruby/spec/jam_ruby/connection_manager_spec.rb +++ b/ruby/spec/jam_ruby/connection_manager_spec.rb @@ -48,6 +48,10 @@ describe ConnectionManager do it "can't create two client_ids of same value" do client_id = "client_id1" user_id = create_user("test", "user1", "user1@jamkazam.com") + user = User.find(user_id) + user.musician_instruments << FactoryGirl.build(:musician_instrument, user: user) + user.save! + user = nil @connman.create_connection(user_id, client_id, "1.1.1.1") expect { @connman.create_connection(user_id, client_id, "1.1.1.1") }.to raise_error(PG::Error) @@ -56,23 +60,58 @@ describe ConnectionManager do it "create connection then delete it" do client_id = "client_id2" - user_id = create_user("test", "user2", "user2@jamkazam.com") - count = @connman.create_connection(user_id, client_id, "1.1.1.1") + #user_id = create_user("test", "user2", "user2@jamkazam.com") + user = FactoryGirl.create(:user) + + count = @connman.create_connection(user.id, client_id, "1.1.1.1") { |conn, count, addr, locidispid, latitude, longitude, countrycode, region, city| + # first update the user record with the current location + u = User.find(user.id) + u.addr = addr + u.locidispid = locidispid + u.lat = latitude + u.lng = longitude + u.country = countrycode + u.state = region + u.city = city; + u.save! + u = nil + } + count.should == 1 + # make sure the connection is seen - @conn.exec("SELECT count(*) FROM connections where user_id = $1", [user_id]) do |result| - result.getvalue(0, 0).should == "1" + @conn.exec("SELECT count(*) FROM connections where user_id = $1", [user.id]) do |result| + result.getvalue(0, 0).to_i.should == 1 end cc = Connection.find_by_client_id!(client_id) cc.connected?.should be_true + cc.ip_address.should eql("1.1.1.1") + cc.addr.should == 0x01010101 + cc.locidispid == 0 + cc.latitude.should == 30.2076 + cc.longitude.should == -97.8587 + cc.city.should eql('Austin') + cc.region.should eql('TX') + cc.countrycode.should eql('US') + + x = User.find(user.id) + #x.ip_address.should eql("1.1.1.1") + x.addr.should == 0x01010101 + x.locidispid == 0 + x.lat.should == 30.2076 + x.lng.should == -97.8587 + x.city.should eql('Austin') + x.state.should eql('TX') + x.country.should eql('US') + x = nil count = @connman.delete_connection(client_id) count.should == 0 - @conn.exec("SELECT count(*) FROM connections where user_id = $1", [user_id]) do |result| - result.getvalue(0, 0).should == "0" + @conn.exec("SELECT count(*) FROM connections where user_id = $1", [user.id]) do |result| + result.getvalue(0, 0).to_i.should == 0 end end diff --git a/ruby/spec/jam_ruby/models/get_work_spec.rb b/ruby/spec/jam_ruby/models/get_work_spec.rb index 015d1e6a3..15b6d0e0a 100644 --- a/ruby/spec/jam_ruby/models/get_work_spec.rb +++ b/ruby/spec/jam_ruby/models/get_work_spec.rb @@ -2,19 +2,14 @@ require 'spec_helper' describe GetWork do - before(:each) do - - end - it "get_work_1" do - x = GetWork.get_work(1) - puts x.inspect + x = GetWork.get_work(0) x.should be_nil end it "get_work_list_1" do - x = GetWork.get_work_list(1) - puts x.inspect + x = GetWork.get_work_list(0) x.should eql([]) end + end \ No newline at end of file diff --git a/websocket-gateway/lib/jam_websockets/router.rb b/websocket-gateway/lib/jam_websockets/router.rb index ab77d4e99..91cc68623 100644 --- a/websocket-gateway/lib/jam_websockets/router.rb +++ b/websocket-gateway/lib/jam_websockets/router.rb @@ -487,7 +487,7 @@ module JamWebsockets ConnectionManager.active_record_transaction do |connection_manager| music_session_id, reconnected = connection_manager.reconnect(connection, reconnect_music_session_id, remote_ip) do |addr, locidispid, latitude, longitude, countrycode, region, city| # update user - user.ip_address = remote_ip + #user.ip_address = remote_ip user.addr = addr user.locidispid = locidispid user.lat = latitude @@ -543,7 +543,7 @@ module JamWebsockets user.country = countrycode user.state = region user.city = city; - user.save! + user.save!(validation: false) if count == 1 Notification.send_friend_update(user.id, true, conn)