This commit is contained in:
Seth Call 2014-08-19 10:07:21 -05:00
parent 0c3a43a177
commit 3daedbd549
4 changed files with 33 additions and 11 deletions

View File

@ -172,7 +172,7 @@ def austin_geoip
geoiplocation = GeoIpLocations.find_by_locid(17192)
geoipblock = GeoIpBlocks.find_by_locid(17192)
jamisp = JamIsp.find_by_beginip(geoipblock.beginip)
{jamisp: jamisp, geoiplocation: geoiplocation, geoipblock: geoipblock, locidispid: Score.compute_locidispid(geoiplocation.locid, geoipblock.coid)}
{jamisp: jamisp, geoiplocation: geoiplocation, geoipblock: geoipblock, locidispid: Score.compute_locidispid(geoiplocation.locid, jamisp.coid)}
end
# gets related models for an IP in the 1st block from the scores_better_test_data.sql
@ -180,7 +180,7 @@ def dallas_geoip
geoiplocation = GeoIpLocations.find_by_locid(667)
geoipblock = GeoIpBlocks.find_by_locid(667)
jamisp = JamIsp.find_by_beginip(geoipblock.beginip)
{jamisp: jamisp, geoiplocation: geoiplocation, geoipblock: geoipblock, locidispid: Score.compute_locidispid(geoiplocation.locid, geoipblock.coid)}
{jamisp: jamisp, geoiplocation: geoiplocation, geoipblock: geoipblock, locidispid: Score.compute_locidispid(geoiplocation.locid, jamisp.coid)}
end
# attempts to make the creation of a score more straightforward.

View File

@ -14,7 +14,7 @@
var LATENCY = {
ME : {description: "ME", style: "latency-me", min: -1, max: -1},
GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 20.0},
GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 40.0},
MEDIUM : {description: "FAIR", style: "latency-fair", min: 40.0, max: 70.0},
POOR : {description: "POOR", style: "latency-poor", min: 70.0, max: 100},
UNACCEPTABLE: {description: "UNACCEPTABLE", style: "latency-unacceptable", min: 100, max: 10000000},

View File

@ -8,8 +8,8 @@ describe "Find Session", :js => true, :type => :feature, :capybara_feature => tr
let(:austin) { austin_geoip }
let(:dallas) { dallas_geoip }
let(:user) { FactoryGirl.create(:user, last_jam_locidispid: austin_geoip[:geoiplocation].) }
let(:finder) { FactoryGirl.create(:user) }
let(:user) { FactoryGirl.create(:user, last_jam_locidispid: austin_geoip[:locidispid], last_jam_addr: austin_ip) }
let(:finder) { FactoryGirl.create(:user, last_jam_locidispid: dallas_geoip[:locidispid], last_jam_addr: dallas_ip) }
before(:each) do
@ -27,6 +27,7 @@ describe "Find Session", :js => true, :type => :feature, :capybara_feature => tr
describe "basic" do
before(:each) do
create_phony_database
emulate_client
fast_signin(user, "/client#/findSession")
FactoryGirl.create(:friendship, :user => user, :friend => finder)
@ -47,7 +48,7 @@ describe "Find Session", :js => true, :type => :feature, :capybara_feature => tr
describe "listing behavior" do
describe "active sessions" do
let!(:session1_creator) { FactoryGirl.create(:single_user_session) }
let!(:session1_creator) { FactoryGirl.create(:single_user_session, last_jam_locidispid: dallas_geoip[:locidispid], last_jam_addr: dallas_ip) }
it "find one active session" do
find('#btn-refresh').trigger(:click)
@ -68,14 +69,35 @@ describe "Find Session", :js => true, :type => :feature, :capybara_feature => tr
end
it "shows latency information correctly" do
user.last_jam_locidispid = austin[:locidispid]
user.save!
find('#btn-refresh').trigger(:click)
page.assert_selector('div#sessions-active .found-session', count: 1)
find(".latency-value.latency-unknown[data-user-id='#{session1_creator.id}']", text: 'UNKNOWN')
# create score with viewer and creator
score1, score2 = create_score(austin, dallas, { auserid: session1_creator.id, buserid: user.id }) # creates scores with very recent created_at, so it should be skipped
session1_creator
#screenshot_and_open_image
score1, score2 = create_score(austin, dallas, { auserid: user.id, buserid: session1_creator.id},
austin[:jamisp].beginip, dallas[:jamisp].beginip, 'a_client_id', 'b_client_id', score=3) # creates scores with very recent created_at, so it should be skipped
find('#btn-refresh').trigger(:click)
page.assert_selector('div#sessions-active .found-session', count: 1)
find(".latency-value.latency-good[data-user-id='#{session1_creator.id}']", text: 'GOOD')
Score.connection.execute('DELETE FROM scores').check
score1, score2 = create_score(austin, dallas, { auserid: user.id, buserid: session1_creator.id},
austin[:jamisp].beginip, dallas[:jamisp].beginip, 'a_client_id', 'b_client_id', score=40) # creates scores with very recent created_at, so it should be skipped
find('#btn-refresh').trigger(:click)
page.assert_selector('div#sessions-active .found-session', count: 1)
find(".latency-value.latency-fair[data-user-id='#{session1_creator.id}']", text: 'FAIR')
Score.connection.execute('DELETE FROM scores').check
score1, score2 = create_score(austin, dallas, { auserid: user.id, buserid: session1_creator.id},
austin[:jamisp].beginip, dallas[:jamisp].beginip, 'a_client_id', 'b_client_id', score=100) # creates scores with very recent created_at, so it should be skipped
find('#btn-refresh').trigger(:click)
page.assert_selector('div#sessions-active .found-session', count: 1)
find(".latency-value.latency-poor[data-user-id='#{session1_creator.id}']", text: 'POOR')
end
end

View File

@ -172,7 +172,7 @@ def austin_geoip
geoiplocation = GeoIpLocations.find_by_locid(17192)
geoipblock = GeoIpBlocks.find_by_locid(17192)
jamisp = JamIsp.find_by_beginip(geoipblock.beginip)
{jamisp: jamisp, geoiplocation: geoiplocation, geoipblock: geoipblock, locidispid: Score.compute_locidispid(geoiplocation.locid, geoipblock.coid) }
{jamisp: jamisp, geoiplocation: geoiplocation, geoipblock: geoipblock, locidispid: Score.compute_locidispid(geoiplocation.locid, jamisp.coid) }
end
# gets related models for an IP in the 1st block from the scores_better_test_data.sql
@ -180,7 +180,7 @@ def dallas_geoip
geoiplocation = GeoIpLocations.find_by_locid(667)
geoipblock = GeoIpBlocks.find_by_locid(667)
jamisp = JamIsp.find_by_beginip(geoipblock.beginip)
{jamisp: jamisp, geoiplocation: geoiplocation, geoipblock: geoipblock, locidispid: Score.compute_locidispid(geoiplocation.locid, geoipblock.coid)}
{jamisp: jamisp, geoiplocation: geoiplocation, geoipblock: geoipblock, locidispid: Score.compute_locidispid(geoiplocation.locid, jamisp.coid)}
end
# attempts to make the creation of a score more straightforward.