* merged
This commit is contained in:
commit
3c4f5c7e55
|
|
@ -5,4 +5,6 @@
|
|||
*/vendor/cache
|
||||
HTML
|
||||
.DS_Store
|
||||
coverage/
|
||||
coverage
|
||||
update2
|
||||
|
||||
|
|
|
|||
|
|
@ -125,4 +125,4 @@ scores_mod_connections2.sql
|
|||
track_download_counts.sql
|
||||
scores_mod_users2.sql
|
||||
user_bio.sql
|
||||
track_changes_counter.sql
|
||||
scores_better_test_data.sql
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
-- cooking up some better test data for use with findblah
|
||||
|
||||
delete from GeoIPLocations;
|
||||
insert into GeoIPLocations (locId, countryCode, region, city, postalCode, latitude, longitude, metroCode, areaCode) values
|
||||
(17192,'US','TX','Austin','78749',30.2076,-97.8587,635,'512'),
|
||||
(667,'US','TX','Dallas','75207',32.7825,-96.8207,623,'214'),
|
||||
(30350,'US','TX','Houston','77001',29.7633,-95.3633,618,'713'),
|
||||
(31423,'US','CO','Denver','80201',39.7392,-104.9847,751,'303'),
|
||||
(1807,'US','TX','San Antonio','78201',29.4713,-98.5353,641,'210'),
|
||||
(23565,'US','FL','Miami','33101',25.7743,-80.1937,528,'305'),
|
||||
(11704,'US','FL','Tampa','33601',27.9475,-82.4584,539,'813'),
|
||||
(26424,'US','MA','Boston','02101',42.3584,-71.0598,506,'617'),
|
||||
(5059,'US','ME','Portland','04101',43.6589,-70.2615,500,'207'),
|
||||
(2739,'US','OR','Portland','97201',45.5073,-122.6932,820,'503'),
|
||||
(1539,'US','WA','Seattle','98101',47.6103,-122.3341,819,'206'),
|
||||
(2720,'US','CA','Mountain View','94040',37.3845,-122.0881,807,'650'),
|
||||
(154078,'US','AR','Mountain View','72560',35.8732,-92.0717,693,'870'),
|
||||
(3964,'US','CA','Barstow','92311',34.9701,-116.9929,803,'760'),
|
||||
(14447,'US','OK','Tulsa','74101',36.154,-95.9928,671,'918'),
|
||||
(162129,'US','TN','Memphis','37501',35.1693,-89.9904,640,'713');
|
||||
|
||||
delete from GeoIPBlocks;
|
||||
insert into GeoIPBlocks (beginIp, endIp, locId) values
|
||||
(x'00000000'::bigint,x'0FFFFFFF'::bigint,17192),
|
||||
(x'10000000'::bigint,x'1FFFFFFF'::bigint,667),
|
||||
(x'20000000'::bigint,x'2FFFFFFF'::bigint,30350),
|
||||
(x'30000000'::bigint,x'3FFFFFFF'::bigint,31423),
|
||||
(x'40000000'::bigint,x'4FFFFFFF'::bigint,1807),
|
||||
(x'50000000'::bigint,x'5FFFFFFF'::bigint,23565),
|
||||
(x'60000000'::bigint,x'6FFFFFFF'::bigint,11704),
|
||||
(x'70000000'::bigint,x'7FFFFFFF'::bigint,26424),
|
||||
(x'80000000'::bigint,x'8FFFFFFF'::bigint,5059),
|
||||
(x'90000000'::bigint,x'9FFFFFFF'::bigint,2739),
|
||||
(x'A0000000'::bigint,x'AFFFFFFF'::bigint,1539),
|
||||
(x'B0000000'::bigint,x'BFFFFFFF'::bigint,2720),
|
||||
(x'C0000000'::bigint,x'CFFFFFFF'::bigint,154078),
|
||||
(x'D0000000'::bigint,x'DFFFFFFF'::bigint,3964),
|
||||
(x'E0000000'::bigint,x'EFFFFFFF'::bigint,14447),
|
||||
(x'F0000000'::bigint,x'FFFEFFFF'::bigint,162129);
|
||||
-- (x'FFFF0000'::bigint,x'FFFFFFFF'::bigint,bogus)
|
||||
|
||||
delete from GeoIPISP;
|
||||
insert into GeoIPISP values
|
||||
(x'00000000'::bigint,x'0FFFFFFF'::bigint,'Intergalactic Boogie'),
|
||||
(x'10000000'::bigint,x'1FFFFFFF'::bigint,'Powerful Pipes'),
|
||||
(x'20000000'::bigint,x'2FFFFFFF'::bigint,'Powerful Pipes'),
|
||||
(x'30000000'::bigint,x'3FFFFFFF'::bigint,'Intergalactic Boogie'),
|
||||
(x'40000000'::bigint,x'4FFFFFFF'::bigint,'Tangled Webs'),
|
||||
(x'50000000'::bigint,x'5FFFFFFF'::bigint,'Tangled Webs'),
|
||||
(x'60000000'::bigint,x'6FFFFFFF'::bigint,'Powerful Pipes'),
|
||||
(x'70000000'::bigint,x'7FFFFFFF'::bigint,'Intergalactic Boogie'),
|
||||
(x'80000000'::bigint,x'8FFFFFFF'::bigint,'Greasy Lightning'),
|
||||
(x'90000000'::bigint,x'9FFFFFFF'::bigint,'Powerful Pipes'),
|
||||
(x'A0000000'::bigint,x'AFFFFFFF'::bigint,'Intergalactic Boogie'),
|
||||
(x'B0000000'::bigint,x'BFFFFFFF'::bigint,'Tangled Webs'),
|
||||
(x'C0000000'::bigint,x'CFFFFFFF'::bigint,'Greasy Lightning'),
|
||||
(x'D0000000'::bigint,x'DFFFFFFF'::bigint,'Tangled Webs'),
|
||||
(x'E0000000'::bigint,x'EFFFFFFF'::bigint,'Intergalactic Boogie'),
|
||||
(x'F0000000'::bigint,x'FFFEFFFF'::bigint,'Powerful Pipes');
|
||||
-- (x'FFFF0000'::bigint,x'FFFFFFFF'::bigint,'bogus')
|
||||
|
||||
DELETE FROM jamcompany;
|
||||
ALTER SEQUENCE jamcompany_coid_seq RESTART WITH 1;
|
||||
INSERT INTO jamcompany (company) SELECT DISTINCT company FROM geoipisp ORDER BY company;
|
||||
|
||||
DELETE FROM jamisp;
|
||||
INSERT INTO jamisp (beginip, endip, coid) SELECT x.beginip, x.endip, y.coid FROM geoipisp x, jamcompany y WHERE x.company = y.company;
|
||||
|
||||
UPDATE geoiplocations SET geog = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)::geography;
|
||||
UPDATE geoipblocks SET geom = ST_MakeEnvelope(beginip, -1, endip, 1);
|
||||
UPDATE jamisp SET geom = ST_MakeEnvelope(beginip, -1, endip, 1);
|
||||
|
|
@ -44,7 +44,7 @@ module JamRuby
|
|||
end
|
||||
|
||||
# reclaim the existing connection, if ip_address is not nil then perhaps a new address as well
|
||||
def reconnect(conn, reconnect_music_session_id, ip_address)
|
||||
def reconnect(conn, reconnect_music_session_id, ip_address, &blk)
|
||||
music_session_id = nil
|
||||
reconnected = false
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ module JamRuby
|
|||
joined_session_at_expression = "(CASE WHEN music_session_id='#{reconnect_music_session_id}' THEN NOW() ELSE NULL END)"
|
||||
end
|
||||
|
||||
if ip_address
|
||||
if ip_address and !ip_address.eql?(conn.ip_address)
|
||||
# turn ip_address string into a number, then fetch the isp and block records and update location info
|
||||
|
||||
addr = JamIsp.ip_to_num(ip_address)
|
||||
|
|
@ -72,6 +72,7 @@ module JamRuby
|
|||
|
||||
location = GeoIpLocations.lookup(locid)
|
||||
if location.nil?
|
||||
# todo what's a better default location?
|
||||
locidispid = 0
|
||||
latitude = 0.0
|
||||
longitude = 0.0
|
||||
|
|
@ -88,6 +89,7 @@ module JamRuby
|
|||
end
|
||||
|
||||
conn.ip_address = ip_address
|
||||
conn.addr = addr
|
||||
conn.locidispid = locidispid
|
||||
conn.latitude = latitude
|
||||
conn.longitude = longitude
|
||||
|
|
@ -95,6 +97,9 @@ module JamRuby
|
|||
conn.region = region
|
||||
conn.city = city
|
||||
conn.save!(validate: false)
|
||||
|
||||
# we're passing all this stuff so that the user record might be updated as well...
|
||||
blk.call(addr, locidispid, latitude, longitude, countrycode, region, city) unless blk.nil?
|
||||
end
|
||||
|
||||
sql =<<SQL
|
||||
|
|
@ -221,6 +226,7 @@ SQL
|
|||
|
||||
location = GeoIpLocations.lookup(locid)
|
||||
if location.nil?
|
||||
# todo what's a better default location?
|
||||
locidispid = 0
|
||||
latitude = 0.0
|
||||
longitude = 0.0
|
||||
|
|
@ -238,13 +244,14 @@ SQL
|
|||
|
||||
lock_connections(conn)
|
||||
|
||||
conn.exec("INSERT INTO connections (user_id, client_id, addr, locidispid, latitude, longitude, countrycode, region, city, aasm_state, ip_address) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
[user_id, client_id, addr, locidispid, latitude, longitude, countrycode, region, city, Connection::CONNECT_STATE.to_s, ip_address]).clear
|
||||
conn.exec("INSERT INTO connections (user_id, client_id, ip_address, addr, locidispid, latitude, longitude, countrycode, region, city, aasm_state) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
[user_id, client_id, ip_address, addr, locidispid, latitude, longitude, countrycode, region, city, Connection::CONNECT_STATE.to_s]).clear
|
||||
|
||||
# we just created a new connection-if this is the first time the user has shown up, we need to send out a message to his friends
|
||||
conn.exec("SELECT count(user_id) FROM connections WHERE user_id = $1", [user_id]) do |result|
|
||||
count = result.getvalue(0, 0) .to_i
|
||||
blk.call(conn, count) unless blk.nil?
|
||||
# we're passing all this stuff so that the user record might be updated as well...
|
||||
blk.call(conn, count, addr, locidispid, latitude, longitude, countrycode, region, city) unless blk.nil?
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,9 +6,13 @@ module JamRuby
|
|||
self.table_name = 'jamisp'
|
||||
|
||||
def self.ip_to_num(ip_addr)
|
||||
i = IPAddr.new(ip_addr)
|
||||
return i.to_i if i.ipv4?
|
||||
nil
|
||||
begin
|
||||
i = IPAddr.new(ip_addr)
|
||||
return i.to_i if i.ipv4?
|
||||
nil
|
||||
rescue IPAddr::InvalidAddressError
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def self.lookup(ipnum)
|
||||
|
|
@ -23,5 +27,13 @@ module JamRuby
|
|||
c.exec_params('insert into jamisp (beginip, endip, coid, geom) values($1::bigint, $2::bigint, $3, ST_MakeEnvelope($1::bigint, -1, $2::bigint, 1))',
|
||||
[beginip, endip, coid])
|
||||
end
|
||||
|
||||
def self_delete()
|
||||
raise "mother trucker"
|
||||
end
|
||||
|
||||
def self.delete_all()
|
||||
raise "mother trucker"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -48,31 +48,164 @@ 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)
|
||||
end
|
||||
|
||||
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.should == 17192000002
|
||||
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.should == 17192000002
|
||||
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
|
||||
|
||||
it "create connection, reconnect, then delete it" do
|
||||
|
||||
client_id = "client_id3"
|
||||
#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).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.should == 17192000002
|
||||
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.should == 17192000002
|
||||
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
|
||||
|
||||
@connman.reconnect(cc, nil, "33.1.2.3") { |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
|
||||
}
|
||||
|
||||
cc = Connection.find_by_client_id!(client_id)
|
||||
cc.connected?.should be_true
|
||||
cc.ip_address.should eql("33.1.2.3")
|
||||
cc.addr.should == 0x21010203
|
||||
cc.locidispid.should == 30350000003
|
||||
cc.latitude.should == 29.7633
|
||||
cc.longitude.should == -95.3633
|
||||
cc.city.should eql('Houston')
|
||||
cc.region.should eql('TX')
|
||||
cc.countrycode.should eql('US')
|
||||
|
||||
x = User.find(user.id)
|
||||
#x.ip_address.should eql("33.1.2.3")
|
||||
x.addr.should == 0x21010203
|
||||
x.locidispid.should == 30350000003
|
||||
x.lat.should == 29.7633
|
||||
x.lng.should == -95.3633
|
||||
x.city.should eql('Houston')
|
||||
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).to_i.should == 0
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,24 +2,32 @@ require 'spec_helper'
|
|||
|
||||
describe GeoIpBlocks do
|
||||
|
||||
before do
|
||||
GeoIpBlocks.delete_all
|
||||
GeoIpBlocks.createx(0x01020300, 0x010203ff, 1)
|
||||
GeoIpBlocks.createx(0x02030400, 0x020304ff, 2)
|
||||
end
|
||||
#before do
|
||||
#GeoIpBlocks.delete_all
|
||||
#GeoIpBlocks.createx(0x01020300, 0x010203ff, 1)
|
||||
#GeoIpBlocks.createx(0x02030400, 0x020304ff, 2)
|
||||
#end
|
||||
|
||||
after do
|
||||
GeoIpBlocks.delete_all
|
||||
GeoIpBlocks.createx(0x00000000, 0xffffffff, 17192)
|
||||
end
|
||||
#after do
|
||||
#GeoIpBlocks.delete_all
|
||||
#GeoIpBlocks.createx(0x00000000, 0xffffffff, 17192)
|
||||
#end
|
||||
|
||||
it "count" do GeoIpBlocks.count.should == 2 end
|
||||
it "count" do GeoIpBlocks.count.should == 16 end
|
||||
|
||||
let(:first) { GeoIpBlocks.lookup(0x01020304) }
|
||||
let(:second) { GeoIpBlocks.lookup(0x02030405) }
|
||||
let(:third) { GeoIpBlocks.lookup(9999999999) } # bogus
|
||||
let(:first) { GeoIpBlocks.lookup(0x01020304) } # 17192
|
||||
let(:second) { GeoIpBlocks.lookup(0x12030405) } # 667
|
||||
let(:third) { GeoIpBlocks.lookup(0xffff0001) } # bogus
|
||||
|
||||
it "first" do first.should_not be_nil end
|
||||
it "first.beginip" do first.beginip.should == 0x00000000 end
|
||||
it "first.endip" do first.endip.should == 0x0fffffff end
|
||||
it "first.locid" do first.locid.should == 17192 end
|
||||
|
||||
it "second" do second.should_not be_nil end
|
||||
it "second.beginip" do second.beginip.should == 0x10000000 end
|
||||
it "second.endip" do second.endip.should == 0x1fffffff end
|
||||
it "second.locid" do second.locid.should == 667 end
|
||||
|
||||
it "first.locid" do first.locid.should == 1 end
|
||||
it "second.locid" do second.locid.should == 2 end
|
||||
it "third" do third.should be_nil end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,33 +3,35 @@ require 'spec_helper'
|
|||
describe GeoIpLocations do
|
||||
|
||||
before do
|
||||
GeoIpLocations.delete_all
|
||||
GeoIpLocations.createx(17192, 'US', 'TX', 'Austin', '78749', 30.2076, -97.8587, 635, '512')
|
||||
GeoIpLocations.createx(48086, 'MX', '28', 'Matamoros', '', 25.8833, -97.5000, nil, '')
|
||||
#GeoIpLocations.delete_all
|
||||
#GeoIpLocations.createx(17192, 'US', 'TX', 'Austin', '78749', 30.2076, -97.8587, 635, '512')
|
||||
#GeoIpLocations.createx(48086, 'MX', '28', 'Matamoros', '', 25.8833, -97.5000, nil, '')
|
||||
end
|
||||
|
||||
it "count" do GeoIpLocations.count.should == 2 end
|
||||
it "count" do GeoIpLocations.count.should == 16 end
|
||||
|
||||
let(:first) { GeoIpLocations.lookup(17192) }
|
||||
let(:second) { GeoIpLocations.lookup(48086) }
|
||||
let(:third) { GeoIpLocations.lookup(999999) } # bogus
|
||||
let(:first) { GeoIpLocations.lookup(17192) }
|
||||
let(:second) { GeoIpLocations.lookup(1539) }
|
||||
let(:third) { GeoIpLocations.lookup(999999) } # bogus
|
||||
|
||||
it "first" do
|
||||
first.locid.should == 17192
|
||||
first.countrycode.should eql('US')
|
||||
first.region.should eql('TX')
|
||||
first.city.should eql('Austin')
|
||||
first.latitude.should == 30.2076
|
||||
first.longitude.should == -97.8587
|
||||
describe "first" do
|
||||
it "first" do first.should_not be_nil end
|
||||
it "first.locid" do first.locid.should == 17192 end
|
||||
it "first.countrycode" do first.countrycode.should eql('US') end
|
||||
it "first.region" do first.region.should eql('TX') end
|
||||
it "first.city" do first.city.should eql('Austin') end
|
||||
it "first.latitude" do first.latitude.should == 30.2076 end
|
||||
it "first.longitude" do first.longitude.should == -97.8587 end
|
||||
end
|
||||
|
||||
it "second" do
|
||||
second.locid.should == 48086
|
||||
second.countrycode.should eql('MX')
|
||||
second.region.should eql('28')
|
||||
second.city.should eql('Matamoros')
|
||||
second.latitude.should == 25.8833
|
||||
second.longitude.should == -97.5000
|
||||
describe "second" do
|
||||
it "second" do first.should_not be_nil end
|
||||
it "second.locid" do second.locid.should == 1539 end
|
||||
it "second.countrycode" do second.countrycode.should eql('US') end
|
||||
it "second.region" do second.region.should eql('WA') end
|
||||
it "second.city" do second.city.should eql('Seattle') end
|
||||
it "second.latitude" do second.latitude.should == 47.6103 end
|
||||
it "second.longitude" do second.longitude.should == -122.3341 end
|
||||
end
|
||||
|
||||
it "third" do third.should be_nil end
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@ describe GetWork do
|
|||
|
||||
it "get_work_1" do
|
||||
x = GetWork.get_work(1)
|
||||
puts x.inspect
|
||||
x.should be_nil
|
||||
end
|
||||
|
||||
it "get_work_list_1" do
|
||||
x = GetWork.get_work_list(1)
|
||||
puts x.inspect
|
||||
x.should eql([])
|
||||
end
|
||||
end
|
||||
|
|
@ -2,22 +2,22 @@ require 'spec_helper'
|
|||
|
||||
describe JamIsp do
|
||||
|
||||
before do
|
||||
JamIsp.delete_all
|
||||
JamIsp.createx(0x01020300, 0x010203ff, 1)
|
||||
JamIsp.createx(0x02030400, 0x020304ff, 2)
|
||||
JamIsp.createx(0x03040500, 0x030405ff, 3)
|
||||
JamIsp.createx(0x04050600, 0x040506ff, 4)
|
||||
JamIsp.createx(0xc0A80100, 0xc0A801ff, 5)
|
||||
JamIsp.createx(0xfffefd00, 0xfffefdff, 6)
|
||||
end
|
||||
#before do
|
||||
# JamIsp.delete_all
|
||||
# JamIsp.createx(0x01020300, 0x010203ff, 1)
|
||||
# JamIsp.createx(0x02030400, 0x020304ff, 2)
|
||||
# JamIsp.createx(0x03040500, 0x030405ff, 3)
|
||||
# JamIsp.createx(0x04050600, 0x040506ff, 4)
|
||||
# JamIsp.createx(0xc0A80100, 0xc0A801ff, 5)
|
||||
# JamIsp.createx(0xfffefd00, 0xfffefdff, 6)
|
||||
#end
|
||||
|
||||
after do
|
||||
JamIsp.delete_all
|
||||
JamIsp.createx(0x00000000, 0xffffffff, 1)
|
||||
end
|
||||
#after do
|
||||
# JamIsp.delete_all
|
||||
# JamIsp.createx(0x00000000, 0xffffffff, 1)
|
||||
#end
|
||||
|
||||
it "count" do JamIsp.count.should == 6 end
|
||||
it "count" do JamIsp.count.should == 16 end
|
||||
|
||||
let(:first_addr) { JamIsp.ip_to_num('1.2.3.4') }
|
||||
let(:second_addr) { JamIsp.ip_to_num('2.3.4.5') }
|
||||
|
|
@ -34,18 +34,12 @@ describe JamIsp do
|
|||
it "sixth_addr" do sixth_addr.should == 0xfffefdfc end
|
||||
|
||||
let(:first) { JamIsp.lookup(0x01020304) }
|
||||
let(:second) { JamIsp.lookup(0x02030405) }
|
||||
let(:third) { JamIsp.lookup(0x03040506) }
|
||||
let(:fourth) { JamIsp.lookup(0x04050607) }
|
||||
let(:fifth) { JamIsp.lookup(0xc0A8016b) }
|
||||
let(:sixth) { JamIsp.lookup(0xfffefdfc) }
|
||||
let(:seventh) { JamIsp.lookup(0) } # bogus
|
||||
let(:second) { JamIsp.lookup(0x12030405) }
|
||||
let(:third) { JamIsp.lookup(0x43040506) }
|
||||
let(:seventh) { JamIsp.lookup(0xffff0123) } # bogus
|
||||
|
||||
it "first.coid" do first.coid.should == 1 end
|
||||
it "second.coid" do second.coid.should == 2 end
|
||||
it "third.coid" do third.coid.should == 3 end
|
||||
it "fourth.coid" do fourth.coid.should == 4 end
|
||||
it "fifth.coid" do fifth.coid.should == 5 end
|
||||
it "sixth.coid" do sixth.coid.should == 6 end
|
||||
it "first.coid" do first.coid.should == 2 end
|
||||
it "second.coid" do second.coid.should == 3 end
|
||||
it "third.coid" do third.coid.should == 4 end
|
||||
it "seventh" do seventh.should be_nil end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ require 'database_cleaner'
|
|||
require 'factories'
|
||||
|
||||
# uncomment this to see active record logs
|
||||
# ActiveRecord::Base.logger = Logger.new(STDOUT) if defined?(ActiveRecord::Base)
|
||||
#ActiveRecord::Base.logger = Logger.new(STDOUT) if defined?(ActiveRecord::Base)
|
||||
|
||||
include JamRuby
|
||||
|
||||
|
|
@ -74,8 +74,8 @@ Spork.prefork do
|
|||
config.filter_run_excluding aws: true unless run_tests? :aws
|
||||
|
||||
config.before(:suite) do
|
||||
DatabaseCleaner.strategy = :truncation, {:except => %w[instruments genres icecast_server_groups] }
|
||||
DatabaseCleaner.clean_with(:truncation, {:except => %w[instruments genres icecast_server_groups] })
|
||||
DatabaseCleaner.strategy = :truncation, {:except => %w[instruments genres icecast_server_groups jamcompany jamisp geoipblocks geoipisp geoiplocations] }
|
||||
DatabaseCleaner.clean_with(:truncation, {:except => %w[instruments genres icecast_server_groups jamcompany jamisp geoipblocks geoipisp geoiplocations] })
|
||||
end
|
||||
|
||||
config.before(:each) do
|
||||
|
|
|
|||
|
|
@ -28,15 +28,20 @@
|
|||
|
||||
var audioProfiles = prettyPrintAudioProfiles(context.jamClient.TrackGetDevices());
|
||||
|
||||
var badAudioConfigs = context.JK.getBadAudioConfigs();
|
||||
|
||||
var template = context.JK.fillTemplate($('#template-account-main').html(), {
|
||||
email: userDetail.email,
|
||||
name: userDetail.name,
|
||||
location : userDetail.location,
|
||||
instruments : prettyPrintInstruments(userDetail.instruments),
|
||||
photoUrl : context.JK.resolveAvatarUrl(userDetail.photo_url),
|
||||
profiles : audioProfiles
|
||||
validProfiles : audioProfiles,
|
||||
invalidProfiles : badAudioConfigs.length > 0 ? badAudioConfigs.join(", ") : "N/A"
|
||||
});
|
||||
$('#account-content-scroller').html(template );
|
||||
$('#account-content-scroller').html(template);
|
||||
|
||||
badAudioConfigs.join(", ");
|
||||
}
|
||||
|
||||
function prettyPrintAudioProfiles(devices) {
|
||||
|
|
|
|||
|
|
@ -30,21 +30,30 @@
|
|||
|
||||
function populateAccountAudio() {
|
||||
|
||||
// load Audio Driver dropdown
|
||||
var devices = context.jamClient.TrackGetDevices();
|
||||
$('#account-audio-content-scroller table tbody').html('');
|
||||
|
||||
var badAudioConfigs = context.JK.getBadAudioConfigs();
|
||||
|
||||
// render valid device profiles
|
||||
var options = {
|
||||
devices: devices
|
||||
configurations: context.JK.getGoodAudioConfigs(),
|
||||
valid: 1
|
||||
}
|
||||
|
||||
var template = context._.template($('#template-account-audio').html(), options, {variable: 'data'});
|
||||
|
||||
appendAudio(template);
|
||||
|
||||
// render invalid device profiles
|
||||
options = {
|
||||
configurations: badAudioConfigs,
|
||||
valid: 0
|
||||
}
|
||||
template = context._.template($('#template-account-audio').html(), options, {variable: 'data'});
|
||||
appendAudio(template);
|
||||
}
|
||||
|
||||
function appendAudio(template) {
|
||||
$('#account-audio-content-scroller table tbody').replaceWith(template);
|
||||
$('#account-audio-content-scroller table tbody').append(template);
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@
|
|||
context.JK.GA.trackSessionMusicians(context.JK.GA.SessionCreationTypes.create);
|
||||
},
|
||||
error: function() {
|
||||
app.ajaxError(arguments);
|
||||
app.notifyServerError(arguments0, "Unable to Create Session");
|
||||
$('#btn-create-session').removeClass('button-disabled');
|
||||
$('#btn-create-session').unbind('click', false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,6 +140,14 @@
|
|||
return ['a'];
|
||||
}
|
||||
|
||||
function FTUEGetAllAudioConfigurations() {
|
||||
return ['a'];
|
||||
}
|
||||
|
||||
function FTUEGetGoodAudioConfigurations() {
|
||||
return ['a'];
|
||||
}
|
||||
|
||||
function RegisterVolChangeCallBack(functionName) {
|
||||
dbg('RegisterVolChangeCallBack');
|
||||
}
|
||||
|
|
@ -664,6 +672,8 @@
|
|||
this.FTUEStartLatency = FTUEStartLatency;
|
||||
this.FTUEGetExpectedLatency = FTUEGetExpectedLatency;
|
||||
this.FTUEGetGoodConfigurationList = FTUEGetGoodConfigurationList;
|
||||
this.FTUEGetAllAudioConfigurations = FTUEGetAllAudioConfigurations;
|
||||
this.FTUEGetGoodAudioConfigurations = FTUEGetGoodAudioConfigurations;
|
||||
|
||||
// Session
|
||||
this.SessionAddTrack = SessionAddTrack;
|
||||
|
|
|
|||
|
|
@ -465,9 +465,14 @@
|
|||
];
|
||||
var optionsHtml = '';
|
||||
var deviceOptionFunc = function (deviceKey, index, list) {
|
||||
optionsHtml += '<option title="' + devices[deviceKey] + '" value="' + deviceKey + '">' +
|
||||
devices[deviceKey] + '</option>';
|
||||
optionsHtml += '<option title="' + devices[deviceKey] + '" value="' + deviceKey + '">' + devices[deviceKey] + '</option>';
|
||||
};
|
||||
var badDeviceOptionFunc = function(deviceKey, index, list) {
|
||||
optionsHtml += '<option disabled="disabled" title="' + deviceKey + '" value="' + deviceKey + '">' + deviceKey + ' (unavailable)' + '</option>';
|
||||
};
|
||||
|
||||
var badAudioConfigs = context.JK.getBadAudioConfigs();
|
||||
|
||||
for (var i = 0; i < funcs.length; i++) {
|
||||
optionsHtml = '<option selected="selected" value="">Choose...</option>';
|
||||
|
||||
|
|
@ -476,10 +481,11 @@
|
|||
$select.empty();
|
||||
var sortedDeviceKeys = context._.keys(devices).sort();
|
||||
context._.each(sortedDeviceKeys, deviceOptionFunc);
|
||||
context._.each(badAudioConfigs, badDeviceOptionFunc);
|
||||
$select.html(optionsHtml);
|
||||
context.JK.dropdown($select);
|
||||
$select.removeAttr("disabled");
|
||||
$('[layout-wizard-step="2"] .settings-asio select').removeAttr("disabled").easyDropDown('enable')
|
||||
$('[layout-wizard-step="2"] .settings-asio select').removeAttr("disabled").easyDropDown('enable');
|
||||
// Set selects to lowest possible values to start:
|
||||
$('#asio-framesize').val('2.5').change();
|
||||
$('#asio-input-latency').val('0').change();
|
||||
|
|
@ -505,6 +511,12 @@
|
|||
drivers[driverKey] + '</option>';
|
||||
};
|
||||
|
||||
var badDeviceOptionFunc = function(deviceKey, index, list) {
|
||||
optionsHtml += '<option disabled="disabled" title="' + deviceKey + '" value="' + deviceKey + '">' + deviceKey + ' (unavailable)' + '</option>';
|
||||
};
|
||||
|
||||
var badAudioConfigs = context.JK.getBadAudioConfigs();
|
||||
|
||||
var optionsHtml = '<option selected="selected" value="">Choose...</option>';
|
||||
var selectors = [
|
||||
'[layout-wizard-step="0"] .settings-2-device select',
|
||||
|
|
@ -513,6 +525,7 @@
|
|||
];
|
||||
var sortedDeviceKeys = context._.keys(drivers).sort();
|
||||
context._.each(sortedDeviceKeys, driverOptionFunc);
|
||||
context._.each(badAudioConfigs, badDeviceOptionFunc);
|
||||
$.each(selectors, function (index, selector) {
|
||||
var $select = $(selector);
|
||||
$select.empty();
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@
|
|||
} else {
|
||||
rest.createEmailInvitations(emails, $('#txt-message').val())
|
||||
.error(function() {
|
||||
app.ajaxError(arguments);
|
||||
app.ajaxError();
|
||||
app.layout.closeDialog('inviteUsers');
|
||||
}).success(function() {
|
||||
app.notifyAlert('Invites sent', 'You sent '+emails.length.toString()+' email invites');
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@
|
|||
userId: val.id,
|
||||
cssClass: css,
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
userName: val.name.length > 20 ? val.name.substring(0,20) + "..." : val.name,
|
||||
status: val.online ? 'Available' : 'Offline',
|
||||
extra_info: '',
|
||||
hoverAction: val.musician ? "musician" : "fan",
|
||||
|
|
|
|||
|
|
@ -638,7 +638,25 @@
|
|||
var result = context.jamClient.FTUEGetGoodConfigurationList();
|
||||
console.log("hasOneConfiguredDevice: ", result);
|
||||
return result.length > 0;
|
||||
}
|
||||
};
|
||||
|
||||
context.JK.getGoodAudioConfigs = function() {
|
||||
return context.jamClient.FTUEGetGoodAudioConfigurations();
|
||||
};
|
||||
|
||||
context.JK.getBadAudioConfigs = function() {
|
||||
var badAudioConfigs = [];
|
||||
var allAudioConfigs = context.jamClient.FTUEGetAllAudioConfigurations();
|
||||
var goodAudioConfigs = context.JK.getGoodAudioConfigs();
|
||||
|
||||
for (var i=0; i < allAudioConfigs.length; i++) {
|
||||
if ($.inArray(allAudioConfigs[i], goodAudioConfigs) === -1) {
|
||||
badAudioConfigs.push(allAudioConfigs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return badAudioConfigs;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -162,7 +162,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
tr.invalid-profile {
|
||||
background-color:red;
|
||||
}
|
||||
|
||||
img.invalid-profile {
|
||||
vertical-align:middle;
|
||||
}
|
||||
|
||||
.button-grey {
|
||||
margin-right:6px;
|
||||
|
|
|
|||
|
|
@ -31,8 +31,16 @@
|
|||
iu.save
|
||||
iu
|
||||
end
|
||||
else
|
||||
iu = InvitedUser.new
|
||||
iu.sender = current_user
|
||||
iu.save
|
||||
@invited_users = [iu]
|
||||
end
|
||||
if err = @invited_users.detect {|iu| iu.errors.any? }
|
||||
response.status = :unprocessable_entity
|
||||
respond_with err
|
||||
end
|
||||
respond_with @invited_users, :responder => ApiResponder, :location => invitations_url(@invited_users)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,81 +4,85 @@ class ApiScoringController < ApiController
|
|||
before_filter :api_signed_in_user
|
||||
|
||||
def work # clientid; returns another clientid
|
||||
client_id = params[:clientid]
|
||||
if client_id.nil? then render :json => {message: 'client_id not specified'}, :status => 400; return end
|
||||
clientid = params[:clientid]
|
||||
if clientid.nil? then render :json => {message: 'clientid not specified'}, :status => 400; return end
|
||||
|
||||
c = Connection.where(client_id: client_id).first
|
||||
if c.nil? then render :json => {message: 'connection not found'}, :status => 404; return end
|
||||
if !c.user.id.eql?(current_user.id) then render :json => {message: 'user does not own client_id'}, :status => 403; return end
|
||||
conn = Connection.where(client_id: clientid).first
|
||||
if conn.nil? then render :json => {message: 'session not found'}, :status => 404; return end
|
||||
if !current_user.id.eql?(conn.user.id) then render :json => {message: 'session not owned by user'}, :status => 403; return end
|
||||
|
||||
# todo this method is a stub
|
||||
#puts "ApiScoringController#work(#{client_id}) => locidispid #{c.locidispid}"
|
||||
result_client_id = JamRuby::GetWork.get_work(c.locidispid)
|
||||
#result_client_id = client_id+'peer'
|
||||
#puts "ApiScoringController#work(#{clientid}) => locidispid #{c.locidispid}"
|
||||
result_client_id = JamRuby::GetWork.get_work(conn.locidispid)
|
||||
#result_client_id = clientid+'peer'
|
||||
|
||||
render :json => {:clientid => result_client_id}, :status => 200
|
||||
end
|
||||
|
||||
def worklist # clientid; returns a list of clientid
|
||||
client_id = params[:clientid]
|
||||
if client_id.nil? then render :json => {message: 'client_id not specified'}, :status => 400; return end
|
||||
clientid = params[:clientid]
|
||||
if clientid.nil? then render :json => {message: 'clientid not specified'}, :status => 400; return end
|
||||
|
||||
c = Connection.where(client_id: client_id).first
|
||||
if c.nil? then render :json => {message: 'connection not found'}, :status => 404; return end
|
||||
if !c.user.id.eql?(current_user.id) then render :json => {message: 'user does not own client_id'}, :status => 403; return end
|
||||
conn = Connection.where(client_id: clientid).first
|
||||
if conn.nil? then render :json => {message: 'session not found'}, :status => 404; return end
|
||||
if !current_user.id.eql?(conn.user.id) then render :json => {message: 'session not owned by user'}, :status => 403; return end
|
||||
|
||||
# todo this method is a stub
|
||||
result_client_ids = JamRuby::GetWork.get_work_list(c.locidispid)
|
||||
#result_client_ids = [client_id+'peer1', client_id+'peer2']
|
||||
result_client_ids = JamRuby::GetWork.get_work_list(conn.locidispid)
|
||||
#result_client_ids = [clientid+'peer1', clientid+'peer2']
|
||||
|
||||
render :json => {:clientids => result_client_ids}, :status => 200
|
||||
end
|
||||
|
||||
def record # aclientid, aAddr, bclientid, bAddr, score returns nothing
|
||||
|
||||
aclient_id = params[:aclientid]
|
||||
#puts "================= record #{params.inspect}"
|
||||
aclientid = params[:aclientid]
|
||||
aip_address = params[:aAddr]
|
||||
bclient_id = params[:bclientid]
|
||||
bclientid = params[:bclientid]
|
||||
bip_address = params[:bAddr]
|
||||
score = params[:score]
|
||||
|
||||
if aclient_id.nil? then render :json => {message: 'aclient_id not specified'}, :status => 400; return end
|
||||
if aclientid.nil? then render :json => {message: 'aclientid not specified'}, :status => 400; return end
|
||||
if aip_address.nil? then render :json => {message: 'aAddr not specified'}, :status => 400; return end
|
||||
if bclient_id.nil? then render :json => {message: 'bclient_id not specified'}, :status => 400; return end
|
||||
if bclientid.nil? then render :json => {message: 'bclientid not specified'}, :status => 400; return end
|
||||
if bip_address.nil? then render :json => {message: 'bAddr not specified'}, :status => 400; return end
|
||||
|
||||
# no score means the test was run but failed, details should still be recorded for later consideration
|
||||
if score.nil? then render :json => {message: 'score not specified'}, :status => 400; return end
|
||||
|
||||
aaddr = JamRuby::JamIsp.ip_to_num(aip_address)
|
||||
if aaddr.nil? then render :json => {message: 'aAddr not valid ip_address'}, :status => 400; return end
|
||||
aAddr = JamRuby::JamIsp.ip_to_num(aip_address)
|
||||
if aAddr.nil? then render :json => {message: 'aAddr not valid ip_address'}, :status => 400; return end
|
||||
|
||||
baddr = JamRuby::JamIsp.ip_to_num(bip_address)
|
||||
if baddr.nil? then render :json => {message: 'bAddr not valid ip_address'}, :status => 400; return end
|
||||
bAddr = JamRuby::JamIsp.ip_to_num(bip_address)
|
||||
if bAddr.nil? then render :json => {message: 'bAddr not valid ip_address'}, :status => 400; return end
|
||||
|
||||
if aaddr == baddr then render :json => {message: 'aAddr and bAddr are the same'}, :status => 403; return end
|
||||
if aAddr == bAddr then render :json => {message: 'aAddr and bAddr are the same'}, :status => 403; return end
|
||||
|
||||
if !score.is_a? Numeric then render :json => {message: 'score not valid numeric'}, :status => 400; return end
|
||||
|
||||
aconn = Connection.where(client_id: aclient_id).first
|
||||
aconn = Connection.where(client_id: aclientid).first
|
||||
if aconn.nil? then render :json => {message: 'a\'s session not found'}, :status => 404; return end
|
||||
if aaddr != aconn.addr then render :json => {message: 'a\'s session addr does not match aAddr'}, :status => 403; return end
|
||||
if !current_user.id.eql?(aconn.user.id) then render :json => {message: 'a\' session not owned by user'}, :status => 403; return end
|
||||
if aAddr != aconn.addr then render :json => {message: 'a\'s session addr does not match aAddr'}, :status => 403; return end
|
||||
if !current_user.id.eql?(aconn.user.id) then render :json => {message: 'a\'s session not owned by user'}, :status => 403; return end
|
||||
|
||||
bconn = Connection.where(client_id: bclient_id).first
|
||||
bconn = Connection.where(client_id: bclientid).first
|
||||
if bconn.nil? then render :json => {message: 'b\'s session not found'}, :status => 404; return end
|
||||
if baddr != bconn.addr then render :json => {message: 'b\'s session addr does not match bAddr'}, :status => 403; return end
|
||||
if bAddr != bconn.addr then render :json => {message: 'b\'s session addr does not match bAddr'}, :status => 403; return end
|
||||
|
||||
if score < 0 or score > 999 then render :json => {message: 'score < 0 or score > 999'}, :status => 403; return end
|
||||
|
||||
aloc = JamRuby::GeoIpBlocks.lookup(aaddr)
|
||||
aisp = JamRuby::JamIsp.lookup(aaddr)
|
||||
aloc = JamRuby::GeoIpBlocks.lookup(aAddr)
|
||||
aisp = JamRuby::JamIsp.lookup(aAddr)
|
||||
if aisp.nil? or aloc.nil? then render :json => {message: 'a\'s location or isp not found'}, :status => 404; return end
|
||||
alocidispid = aloc.locid*1000000+aisp.coid;
|
||||
|
||||
bloc = JamRuby::GeoIpBlocks.lookup(baddr)
|
||||
bisp = JamRuby::JamIsp.lookup(baddr)
|
||||
bloc = JamRuby::GeoIpBlocks.lookup(bAddr)
|
||||
bisp = JamRuby::JamIsp.lookup(bAddr)
|
||||
if bisp.nil? or bloc.nil? then render :json => {message: 'b\'s location or isp not found'}, :status => 404; return end
|
||||
blocidispid = bloc.locid*1000000+bisp.coid
|
||||
|
||||
JamRuby::Score.createx(alocidispid, aclient_id, aaddr, blocidispid, bclient_id, baddr, score.ceil, nil)
|
||||
JamRuby::Score.createx(alocidispid, aclientid, aAddr, blocidispid, bclientid, bAddr, score.ceil, nil)
|
||||
|
||||
render :json => {}, :status => 200
|
||||
end
|
||||
|
|
|
|||
|
|
@ -106,7 +106,8 @@
|
|||
</div>
|
||||
|
||||
<div class="account-mid audio">
|
||||
<strong>Approved Profiles:</strong> <span class="audio-profiles-short">{profiles}</span>
|
||||
<strong>Approved Profiles:</strong> <span class="audio-profiles-short">{validProfiles}</span><br />
|
||||
<strong>Invalid Profiles:</strong> <span class="audio-profiles-short">{invalidProfiles}</span>
|
||||
</div>
|
||||
|
||||
<div class="right">
|
||||
|
|
|
|||
|
|
@ -34,25 +34,28 @@
|
|||
|
||||
</tbody>
|
||||
</table>
|
||||
<br clear="all" />
|
||||
<div class="left"><a href="#" data-purpose="add-profile" class="button-orange">ADD NEW PROFILE</a></div><div class="right"><a href="javascript:history.go(-1)" class="button-grey">BACK</a></div>
|
||||
</div>
|
||||
<br clear="all" />
|
||||
<br clear="all" />
|
||||
<br clear="all" />
|
||||
<br clear="all" />
|
||||
<div class="ml35">
|
||||
<img src="/assets/content/icon_alert_big.png" class="invalid-profile" width="15" height="15" /> — INVALID CONFIGURATION OR DEVICE NOT CONNECTED
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end content scrolling area -->
|
||||
</div>
|
||||
|
||||
<script type="text/template" id="template-account-audio">
|
||||
<tbody>
|
||||
{% var keys = Object.keys(data.devices); %}
|
||||
{% for (var i = 0; i < keys.length; i++) { %}
|
||||
<tr>
|
||||
<td>{{data.devices[keys[i]]}}</td>
|
||||
<td class="actions"><a href="#" data-id="{{keys[i]}}" data-purpose="delete-audio-profile" class="button-orange">DELETE</a></td>
|
||||
</tr>
|
||||
{% } %}
|
||||
|
||||
</tbody>
|
||||
{% var configs = data.configurations; %}
|
||||
{% for (var i = 0; i < configs.length; i++) { %}
|
||||
<tr>
|
||||
<td>{{configs[i]}} {% if (data.valid === 0) { %} <img src="/assets/content/icon_alert_big.png" width="15" height="15" class="invalid-profile" /> {% } %}</td>
|
||||
<td class="actions"><a href="#" data-id="{{configs[i]}}" data-purpose="delete-audio-profile" class="button-orange">DELETE</a></td>
|
||||
</tr>
|
||||
{% } %}
|
||||
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@
|
|||
<p class="unknown" style="display:none;">Unable to determine latency. Please click <a href="#" layout-wizard-link="2">here</a> to try another test which may be able to determine your audio performance.</p>
|
||||
<p class="neutral loading" style="display:none;">Estimating latency...</p>
|
||||
<p class="good" style="display:none;">Your audio speed is good. When done with settings, click Save Settings to continue.</p>
|
||||
<p class="acceptable" style="display:none;">Your audio speed is acceptable, but borderline. Try setting Frame to 2.5 and Buffers to 0 and see if your audio quality is still OK. When done with settings, click Save Settings to continue. You can also view the <a href="#">Choosing an Audio Device</a> article for information on faster audio devices.</p>
|
||||
<p class="acceptable" style="display:none;">Your audio speed is acceptable, but borderline. Try setting Frame to 2.5 and Buffers to 0 and see if your audio quality is still OK. When done with settings, click Save Settings to continue. You can also view the <a href="https://jamkazam.desk.com/customer/portal/articles/1292412-choosing-an-audio-device" rel="external">Choosing an Audio Device</a> article for information on faster audio devices.</p>
|
||||
<p class="bad" style="display:none;">We're sorry, but your audio speed is too slow to use JamKazam. Try setting Frame to 2.5 and Buffers to 0 and see if your audio quality is still OK. You can also view the <a href="https://jamkazam.desk.com/customer/portal/articles/1292412-choosing-an-audio-device" rel="external">Choosing an Audio Device</a> article for information on faster audio devices. You can also click <a href="#" layout-wizard-link="2">here</a> to try another test which may be able to measure your audio performance more accurately.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,17 +4,21 @@ describe ApiScoringController do
|
|||
render_views
|
||||
|
||||
BOGUS_CLIENT_ID = 'nobodyclientid'
|
||||
BOGUS_IP_ADDRESS = '0.0.0.0'
|
||||
BOGUS_IP_ADDRESS = '1.2.3.4'
|
||||
BAD_IP_ADDRESS = 'a.b.c.d'
|
||||
|
||||
MARY_IP_ADDRESS = '75.92.54.210' # 1264334546, 4B.5C.36.D2
|
||||
MARY_ADDR = 1264334546
|
||||
MARY_LOCIDISPID = 17192008423
|
||||
|
||||
MIKE_IP_ADDRESS = '173.172.108.1' # 2913758209, AD.AC.6C.01
|
||||
MIKE_ADDR = 2913758209
|
||||
|
||||
MARY_LOCIDISPID = 17192008423
|
||||
MIKE_LOCIDISPID = 17192043640
|
||||
|
||||
JOHN_IP_ADDRESS = '255.255.1.2' # 4294902018, FF.FF.01.02
|
||||
JOHN_ADDR = 4294902018
|
||||
JOHN_LOCIDISPID = 0
|
||||
|
||||
before do
|
||||
@mary = FactoryGirl.create(:user, first_name: 'mary')
|
||||
@mary_connection = FactoryGirl.create(:connection, user: @mary, ip_address: MARY_IP_ADDRESS, addr: MARY_ADDR, locidispid: MARY_LOCIDISPID)
|
||||
|
|
@ -23,6 +27,10 @@ describe ApiScoringController do
|
|||
@mike = FactoryGirl.create(:user, first_name: 'mike')
|
||||
@mike_connection = FactoryGirl.create(:connection, user: @mike, ip_address: MIKE_IP_ADDRESS, addr: MIKE_ADDR, locidispid: MIKE_LOCIDISPID)
|
||||
@mike_client_id = @mike_connection.client_id
|
||||
|
||||
@john = FactoryGirl.create(:user, first_name: 'john')
|
||||
@john_connection = FactoryGirl.create(:connection, user: @john, ip_address: JOHN_IP_ADDRESS, addr: JOHN_ADDR, locidispid: JOHN_LOCIDISPID)
|
||||
@john_client_id = @john_connection.client_id
|
||||
end
|
||||
|
||||
after do
|
||||
|
|
@ -30,6 +38,8 @@ describe ApiScoringController do
|
|||
@mary.delete
|
||||
@mike_connection.delete
|
||||
@mike.delete
|
||||
@john_connection.delete
|
||||
@john.delete
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
|
|
@ -40,34 +50,34 @@ describe ApiScoringController do
|
|||
|
||||
describe 'work' do
|
||||
|
||||
it 'try work with nobody and nobody' do
|
||||
controller.current_user = nil
|
||||
get :work, {}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
end
|
||||
|
||||
it 'try work with mary and nobody' do
|
||||
controller.current_user = @mary
|
||||
get :work, {}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
end
|
||||
|
||||
it 'try work with nobody and mary' do
|
||||
it 'try work with nobody login and mary' do
|
||||
controller.current_user = nil
|
||||
get :work, {clientid: @mary_client_id}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('not logged in')
|
||||
end
|
||||
|
||||
it 'try work with mary and mary' do
|
||||
it 'try work with mary login and nothing' do
|
||||
controller.current_user = @mary
|
||||
get :work, {}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should eql('clientid not specified')
|
||||
end
|
||||
|
||||
it 'try work with mary login and bogus' do
|
||||
controller.current_user = @mary
|
||||
get :work, {clientid: BOGUS_CLIENT_ID}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should eql('session not found')
|
||||
end
|
||||
|
||||
it 'try work with mary login and mary' do
|
||||
controller.current_user = @mary
|
||||
get :work, {clientid: @mary_client_id}
|
||||
response.should be_success
|
||||
|
|
@ -77,7 +87,7 @@ describe ApiScoringController do
|
|||
[@mary_client_id, @mike_client_id].should include(json[:clientid])
|
||||
end
|
||||
|
||||
it 'try work with mike and mike' do
|
||||
it 'try work with mike login and mike' do
|
||||
controller.current_user = @mike
|
||||
get :work, {clientid: @mike_client_id}
|
||||
response.should be_success
|
||||
|
|
@ -87,47 +97,56 @@ describe ApiScoringController do
|
|||
[@mary_client_id, @mike_client_id].should include(json[:clientid])
|
||||
end
|
||||
|
||||
it 'try work with mike and mary' do
|
||||
it 'try work with mary login and mike' do
|
||||
controller.current_user = @mary
|
||||
get :work, {clientid: @mike_client_id}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should eql('session not owned by user')
|
||||
end
|
||||
|
||||
it 'try work with mike login and mary' do
|
||||
controller.current_user = @mike
|
||||
get :work, {clientid: @mary_client_id}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('session not owned by user')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'worklist' do
|
||||
|
||||
it 'try worklist with nobody and nobody' do
|
||||
it 'try worklist with nobody login and nobody' do
|
||||
controller.current_user = nil
|
||||
get :worklist, {}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('not logged in')
|
||||
end
|
||||
|
||||
it 'try worklist with mary and nobody' do
|
||||
it 'try worklist with mary login and nobody' do
|
||||
controller.current_user = @mary
|
||||
get :worklist, {}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('clientid not specified')
|
||||
end
|
||||
|
||||
it 'try worklist with nobody and mary' do
|
||||
it 'try worklist with nobody login and mary' do
|
||||
controller.current_user = nil
|
||||
get :worklist, {clientid: @mary_client_id}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('not logged in')
|
||||
end
|
||||
|
||||
it 'try worklist with mary and mary' do
|
||||
it 'try worklist with mary login and mary' do
|
||||
controller.current_user = @mary
|
||||
get :worklist, {clientid: @mary_client_id}
|
||||
response.should be_success
|
||||
|
|
@ -142,7 +161,7 @@ describe ApiScoringController do
|
|||
|
||||
end
|
||||
|
||||
it 'try worklist with mike and mike' do
|
||||
it 'try worklist with mike login and mike' do
|
||||
controller.current_user = @mike
|
||||
get :worklist, {clientid: @mike_client_id}
|
||||
response.should be_success
|
||||
|
|
@ -156,26 +175,26 @@ describe ApiScoringController do
|
|||
json[:clientids][0].should_not eql(json[:clientids][1])
|
||||
end
|
||||
|
||||
it 'try worklist with mary and mike' do
|
||||
it 'try worklist with mary login and mike' do
|
||||
controller.current_user = @mary
|
||||
get :worklist, {clientid: @mike_client_id}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('session not owned by user')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'record' do
|
||||
|
||||
it 'record with no login, mary, mary_ip_address, mike, mike_addr, score' do
|
||||
it 'record with nobody login, mary, mary_ip_address, mike, mike_addr, score' do
|
||||
controller.current_user = nil
|
||||
post :record, {:format => 'json', :aclientid => @mary_client_id, :aAddr => MARY_IP_ADDRESS, :bclientid => @mike_client_id, :bAddr => MIKE_IP_ADDRESS, :score => 20}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('not logged in')
|
||||
end
|
||||
|
||||
it 'record with mary login, nil, mary_addr, mike, mike_addr, score' do
|
||||
|
|
@ -184,7 +203,7 @@ describe ApiScoringController do
|
|||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('aclientid not specified')
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, nil, mike, mike_addr, score' do
|
||||
|
|
@ -193,7 +212,7 @@ describe ApiScoringController do
|
|||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('aAddr not specified')
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, mary_addr, nil, mike_addr, score' do
|
||||
|
|
@ -202,7 +221,7 @@ describe ApiScoringController do
|
|||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('bclientid not specified')
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, mary_addr, mike, nil, score' do
|
||||
|
|
@ -211,7 +230,7 @@ describe ApiScoringController do
|
|||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('bAddr not specified')
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, mary_addr, mike, mike_addr, nil' do
|
||||
|
|
@ -220,7 +239,7 @@ describe ApiScoringController do
|
|||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('score not specified')
|
||||
end
|
||||
|
||||
it 'record with mary login, bogus, mary_addr, mike, mike_addr, score' do
|
||||
|
|
@ -229,7 +248,7 @@ describe ApiScoringController do
|
|||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('a\'s session not found')
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, mary_addr, bogus, mike_addr, score' do
|
||||
|
|
@ -238,7 +257,16 @@ describe ApiScoringController do
|
|||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('b\'s session not found')
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, bogus, mike, mike_addr, score' do
|
||||
controller.current_user = @mary
|
||||
post :record, {:format => 'json', :aclientid => @mary_client_id, :aAddr => BAD_IP_ADDRESS, :bclientid => @mike_client_id, :bAddr => MIKE_IP_ADDRESS, :score => 20}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should eql('aAddr not valid ip_address')
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, bogus, mike, mike_addr, score' do
|
||||
|
|
@ -247,7 +275,16 @@ describe ApiScoringController do
|
|||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('a\'s session addr does not match aAddr')
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, mary_addr, mike, bogus, score' do
|
||||
controller.current_user = @mary
|
||||
post :record, {:format => 'json', :aclientid => @mary_client_id, :aAddr => MARY_IP_ADDRESS, :bclientid => @mike_client_id, :bAddr => BAD_IP_ADDRESS, :score => 20}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should eql('bAddr not valid ip_address')
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, mary_addr, mike, bogus, score' do
|
||||
|
|
@ -256,7 +293,7 @@ describe ApiScoringController do
|
|||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('b\'s session addr does not match bAddr')
|
||||
end
|
||||
|
||||
it 'record with mary login, mike, mike_addr, mary, mary_addr, score' do
|
||||
|
|
@ -265,25 +302,7 @@ describe ApiScoringController do
|
|||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, mary_addr, mike, mike_addr, -1' do
|
||||
controller.current_user = @mary
|
||||
post :record, {:format => 'json', :aclientid => @mary_client_id, :aAddr => MARY_IP_ADDRESS, :bclientid => @mike_client_id, :bAddr => MIKE_IP_ADDRESS, :score => -1}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, mary_addr, mike, mike_addr, 1000' do
|
||||
controller.current_user = @mary
|
||||
post :record, {:format => 'json', :aclientid => @mary_client_id, :aAddr => MARY_IP_ADDRESS, :bclientid => @mike_client_id, :bAddr => MIKE_IP_ADDRESS, :score => 1000}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('a\'s session not owned by user')
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, mary_addr, mary, mary_addr, score' do
|
||||
|
|
@ -292,7 +311,52 @@ describe ApiScoringController do
|
|||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should_not be_nil
|
||||
json[:message].should eql('aAddr and bAddr are the same')
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, mary_addr, mike, mike_addr, -1' do
|
||||
controller.current_user = @mary
|
||||
post :record, {:format => 'json', :aclientid => @mary_client_id, :aAddr => MARY_IP_ADDRESS, :bclientid => @mike_client_id, :bAddr => MIKE_IP_ADDRESS, :score => -1}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should eql('score < 0 or score > 999')
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, mary_addr, mike, mike_addr, 1000' do
|
||||
controller.current_user = @mary
|
||||
post :record, {:format => 'json', :aclientid => @mary_client_id, :aAddr => MARY_IP_ADDRESS, :bclientid => @mike_client_id, :bAddr => MIKE_IP_ADDRESS, :score => 1000}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should eql('score < 0 or score > 999')
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, mary_addr, mike, mike_addr, bogus' do
|
||||
controller.current_user = @mary
|
||||
post :record, {:format => 'json', :aclientid => @mary_client_id, :aAddr => MARY_IP_ADDRESS, :bclientid => @mike_client_id, :bAddr => MIKE_IP_ADDRESS, :score => 'abc'}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should eql('score not valid numeric')
|
||||
end
|
||||
|
||||
it 'record with john login, john, john_addr, mike, mike_addr, bogus' do
|
||||
controller.current_user = @john
|
||||
post :record, {:format => 'json', :aclientid => @john_client_id, :aAddr => JOHN_IP_ADDRESS, :bclientid => @mike_client_id, :bAddr => MIKE_IP_ADDRESS, :score => 20}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should eql('a\'s location or isp not found')
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, mary_addr, john, john_addr, bogus' do
|
||||
controller.current_user = @mary
|
||||
post :record, {:format => 'json', :aclientid => @mary_client_id, :aAddr => MARY_IP_ADDRESS, :bclientid => @john_client_id, :bAddr => JOHN_IP_ADDRESS, :score => 20}
|
||||
response.should_not be_success
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json.length.should == 1
|
||||
json[:message].should eql('b\'s location or isp not found')
|
||||
end
|
||||
|
||||
it 'record with mary login, mary, mary_addr, mike, mike_addr, score' do
|
||||
|
|
|
|||
|
|
@ -25,17 +25,15 @@ describe "Invited Users API ", :type => :api do
|
|||
end
|
||||
|
||||
it "create with no note" do
|
||||
post '/api/invited_users.json', {:email => 'tester@jamkazam.com'}.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
last_response.status.should eql(201)
|
||||
post '/api/invited_users.json', {:emails => ['tester@jamkazam.com']}.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
last_response.status.should eql(200)
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
|
||||
# now fetch it's data
|
||||
location_header = last_response.headers["Location"]
|
||||
get location_header
|
||||
|
||||
# parse json and test
|
||||
body = JSON.parse(last_response.body)
|
||||
bodies = JSON.parse(last_response.body)
|
||||
expect(bodies.size).to eq(1)
|
||||
body = bodies[0]
|
||||
body["id"].should_not be_nil
|
||||
body["created_at"].should_not be_nil
|
||||
body["email"].should == "tester@jamkazam.com"
|
||||
|
|
@ -44,14 +42,12 @@ describe "Invited Users API ", :type => :api do
|
|||
end
|
||||
|
||||
it "create with a note" do
|
||||
post '/api/invited_users.json', {:email => 'tester@jamkazam.com', :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
last_response.status.should eql(201)
|
||||
post '/api/invited_users.json', {:emails => ['tester@jamkazam.com'], :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
last_response.status.should eql(200)
|
||||
|
||||
# now fetch it's data
|
||||
location_header = last_response.headers["Location"]
|
||||
get location_header
|
||||
|
||||
body = JSON.parse(last_response.body)
|
||||
bodies = JSON.parse(last_response.body)
|
||||
expect(bodies.length).to eq(1)
|
||||
body = bodies[0]
|
||||
body["id"].should_not be_nil
|
||||
body["created_at"].should_not be_nil
|
||||
body["email"].should == "tester@jamkazam.com"
|
||||
|
|
@ -63,7 +59,7 @@ describe "Invited Users API ", :type => :api do
|
|||
user.can_invite = false
|
||||
user.save
|
||||
|
||||
post '/api/invited_users.json', {:email => 'tester@jamkazam.com', :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
post '/api/invited_users.json', {:emails => ['tester@jamkazam.com'], :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
last_response.status.should eql(422)
|
||||
body = JSON.parse(last_response.body)
|
||||
body["errors"].should_not be_nil
|
||||
|
|
@ -79,7 +75,7 @@ describe "Invited Users API ", :type => :api do
|
|||
end
|
||||
|
||||
it "cant create with blank email" do
|
||||
post '/api/invited_users.json', {:email => "", :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
post '/api/invited_users.json', {:emails => [""], :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
last_response.status.should eql(422)
|
||||
body = JSON.parse(last_response.body)
|
||||
body["errors"].should_not be_nil
|
||||
|
|
@ -87,7 +83,7 @@ describe "Invited Users API ", :type => :api do
|
|||
end
|
||||
|
||||
it "cant create with invalid email" do
|
||||
post '/api/invited_users.json', {:email => "blurp", :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
post '/api/invited_users.json', {:emails => ["blurp"], :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
last_response.status.should eql(422)
|
||||
body = JSON.parse(last_response.body)
|
||||
body["errors"].should_not be_nil
|
||||
|
|
@ -95,14 +91,12 @@ describe "Invited Users API ", :type => :api do
|
|||
end
|
||||
|
||||
it "list" do
|
||||
post '/api/invited_users.json', {:email => "tester@jamkazam.com", :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
last_response.status.should eql(201)
|
||||
post '/api/invited_users.json', {:emails => ["tester@jamkazam.com"], :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
last_response.status.should eql(200)
|
||||
|
||||
# now fetch it's data
|
||||
location_header = last_response.headers["Location"]
|
||||
get location_header
|
||||
|
||||
body = JSON.parse(last_response.body)
|
||||
bodies = JSON.parse(last_response.body)
|
||||
expect(bodies.length).to eq(1)
|
||||
body = bodies[0]
|
||||
id = body["id"]
|
||||
|
||||
get '/api/invited_users.json', "CONTENT_TYPE" => 'application/json'
|
||||
|
|
@ -115,14 +109,12 @@ describe "Invited Users API ", :type => :api do
|
|||
end
|
||||
|
||||
it "show" do
|
||||
post '/api/invited_users.json', {:email => "tester@jamkazam.com", :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
last_response.status.should eql(201)
|
||||
post '/api/invited_users.json', {:emails => ["tester@jamkazam.com"], :note => "please join"}.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
last_response.status.should eql(200)
|
||||
|
||||
# now fetch it's data
|
||||
location_header = last_response.headers["Location"]
|
||||
get location_header
|
||||
|
||||
body = JSON.parse(last_response.body)
|
||||
bodies = JSON.parse(last_response.body)
|
||||
expect(bodies.length).to eq(1)
|
||||
body = bodies[0]
|
||||
id = body["id"]
|
||||
|
||||
get "/api/invited_users/#{id}.json", "CONTENT_TYPE" => 'application/json'
|
||||
|
|
|
|||
|
|
@ -488,7 +488,19 @@ module JamWebsockets
|
|||
context = nil
|
||||
|
||||
ConnectionManager.active_record_transaction do |connection_manager|
|
||||
music_session_id, reconnected = connection_manager.reconnect(connection, reconnect_music_session_id, remote_ip)
|
||||
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.addr = addr
|
||||
user.locidispid = locidispid
|
||||
user.lat = latitude
|
||||
user.lng = longitude
|
||||
user.country = countrycode
|
||||
user.state = region
|
||||
user.city = city
|
||||
user.save!(validate: false)
|
||||
end
|
||||
|
||||
context = @client_lookup[client_id]
|
||||
if music_session_id.nil?
|
||||
# if this is a reclaim of a connection, but music_session_id comes back null, then we need to check if this connection was IN a music session before.
|
||||
|
|
@ -528,7 +540,17 @@ module JamWebsockets
|
|||
unless connection
|
||||
# log this connection in the database
|
||||
ConnectionManager.active_record_transaction do |connection_manager|
|
||||
connection_manager.create_connection(user.id, client.client_id, remote_ip) do |conn, count|
|
||||
connection_manager.create_connection(user.id, client.client_id, remote_ip) do |conn, count, addr, locidispid, latitude, longitude, countrycode, region, city|
|
||||
# first update the user record with the current location
|
||||
user.addr = addr
|
||||
user.locidispid = locidispid
|
||||
user.lat = latitude
|
||||
user.lng = longitude
|
||||
user.country = countrycode
|
||||
user.state = region
|
||||
user.city = city;
|
||||
user.save!(validation: false)
|
||||
|
||||
if count == 1
|
||||
Notification.send_friend_update(user.id, true, conn)
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue