diff --git a/ruby/lib/jam_ruby/lib/stats.rb b/ruby/lib/jam_ruby/lib/stats.rb index 613a99342..697965526 100644 --- a/ruby/lib/jam_ruby/lib/stats.rb +++ b/ruby/lib/jam_ruby/lib/stats.rb @@ -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 diff --git a/web/app/assets/javascripts/findSession.js b/web/app/assets/javascripts/findSession.js index 63697d545..25dd1e893 100644 --- a/web/app/assets/javascripts/findSession.js +++ b/web/app/assets/javascripts/findSession.js @@ -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", diff --git a/web/spec/features/find_sessions_spec.rb b/web/spec/features/find_sessions_spec.rb index 9de878a8f..b43e34192 100644 --- a/web/spec/features/find_sessions_spec.rb +++ b/web/spec/features/find_sessions_spec.rb @@ -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 diff --git a/web/spec/support/maxmind.rb b/web/spec/support/maxmind.rb index ecbe81db8..85b2fb8f6 100644 --- a/web/spec/support/maxmind.rb +++ b/web/spec/support/maxmind.rb @@ -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])