* protect against double-activation of search of find session screen

This commit is contained in:
Seth Call 2015-07-22 08:16:00 -05:00
parent bade8884f3
commit 6fede36b04
4 changed files with 29 additions and 8 deletions

View File

@ -79,7 +79,7 @@ module JamRuby
end
def self.write(name, data)
return if self.ignore
return if self.ignore # doing any writes in a test environment cause annoying puts to occur
if @client && data && data.length > 0
data['host'] = @host

View File

@ -22,8 +22,8 @@
var currentActiveSessionsQuery = defaultActiveSessionsQuery();
var $btnRefresh = null;
var $asSpinner = null;
var $ssNext = null;
var $ssScroller = null;
var $ssSpinner = null;
@ -45,11 +45,18 @@
}
function loadSessions() {
if($btnRefresh.is('disabled')) {
return;
}
$btnRefresh.addClass('disabled')
$asSpinner.show();
$ssSpinner.show();
$noActiveSessionsMsgSelector.hide();
$noScheduledSessionsMsgSelector.hide();
var doneCount = 0;
// get active sessions
rest.findActiveSessions(currentActiveSessionsQuery)
.done(function(sessions) {
@ -68,6 +75,10 @@
.always(function() {
context.JK.bindHoverEvents();
$asSpinner.hide();
doneCount += 1;
if(doneCount == 2) {
$btnRefresh.removeClass('disabled')
}
});
// get scheduled sessions
@ -86,6 +97,10 @@
})
.always(function() {
$ssSpinner.hide();
doneCount += 1;
if(doneCount == 2) {
$btnRefresh.removeClass('disabled')
}
});
// context.JK.bindInstrumentHover($(CATEGORY.ACTIVE.id));
@ -287,7 +302,7 @@
}
});
$('#btn-refresh').on("click", search);
$btnRefresh.on("click", search);
}
function initialize() {
@ -306,6 +321,7 @@
$ssSpinner = $screen.find('#sessions-scheduled .paginate-wait');
$asSpinner = $screen.find('#sessions-active .paginate-wait');
$btnRefresh = $('#btn-refresh')
$dateFilter.datepicker({
dateFormat: "D d MM yy",

View File

@ -59,8 +59,9 @@ describe "Find Session", :js => true, :type => :feature, :capybara_feature => tr
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
page.should have_no_selector('#btn-refresh.disabled')
find('#btn-refresh').trigger(:click)
find('.paginate-wait')
page.should have_no_selector('#btn-refresh.disabled')
find('#sessions-active .found-session', count: 1)
end
@ -69,8 +70,9 @@ describe "Find Session", :js => true, :type => :feature, :capybara_feature => tr
20.times do
FactoryGirl.create(:single_user_session)
end
page.should have_no_selector('#btn-refresh.disabled')
find('#btn-refresh').trigger(:click)
page.should have_no_selector('.paginate-wait')
page.should have_no_selector('#btn-refresh.disabled')
page.assert_selector('#sessions-active .found-session', count: 20)
# attempt to scroll down--the end of session list should show, and there should now be 21 items
# page.execute_script('jQuery("#findSession .content-body-scroller").scrollTo("100%",100)') #scroll to the bottom of the element
@ -112,8 +114,9 @@ describe "Find Session", :js => true, :type => :feature, :capybara_feature => tr
let!(:scheduled_session) {FactoryGirl.create(:music_session) }
it "find one scheduled session" do
page.should have_no_selector('#btn-refresh.disabled')
find('#btn-refresh').trigger(:click)
page.should have_no_selector('.paginate-wait')
page.should have_no_selector('#btn-refresh.disabled')
page.assert_selector('div#sessions-scheduled .found-session', count: 1)
end
@ -121,8 +124,9 @@ describe "Find Session", :js => true, :type => :feature, :capybara_feature => tr
20.times do
FactoryGirl.create(:music_session)
end
page.should have_no_selector('#btn-refresh.disabled')
find('#btn-refresh').trigger(:click)
page.should have_no_selector('.paginate-wait')
page.should have_no_selector('#btn-refresh.disabled')
page.assert_selector('div#sessions-scheduled .found-session', count: 20)
page.execute_script('jQuery("#findSession .content-body-scroller").scrollTo("100%",100)') #scroll to the bottom of the element

View File

@ -288,8 +288,9 @@ def verify_find_session_score(score, parent_selector, current_user, target_user)
austin[:jamisp].beginip, dallas[:jamisp].beginip, 'a_client_id', 'b_client_id', score=score) # creates scores with very recent created_at, so it should be skipped
end
page.should have_no_selector('#btn-refresh.disabled')
find('#btn-refresh').trigger(:click)
find('.paginate-wait')
page.should have_no_selector('#btn-refresh.disabled')
page.assert_selector("div#{parent_selector} .found-session", count: 1)
hoverable = find(".latency-value#{expected[:latency_badge_selector]}[data-user-id='#{target_user.id}']", text: expected[:latency_badge_text])