diff --git a/ruby/lib/jam_ruby/models/music_session.rb b/ruby/lib/jam_ruby/models/music_session.rb
index ba4054dff..d3c7660cc 100644
--- a/ruby/lib/jam_ruby/models/music_session.rb
+++ b/ruby/lib/jam_ruby/models/music_session.rb
@@ -49,7 +49,7 @@ module JamRuby
query = MusicSession
.joins(
%Q{
- LEFT OUTER JOIN
+ INNER JOIN
connections
ON
music_sessions.id = connections.music_session_id
diff --git a/ruby/spec/jam_ruby/models/music_session_spec.rb b/ruby/spec/jam_ruby/models/music_session_spec.rb
index 6a06555d2..358cdbb09 100644
--- a/ruby/spec/jam_ruby/models/music_session_spec.rb
+++ b/ruby/spec/jam_ruby/models/music_session_spec.rb
@@ -81,9 +81,13 @@ describe MusicSession do
it "orders two sessions by created_at starting with most recent" do
creator = FactoryGirl.create(:user)
-
+ creator2 = FactoryGirl.create(:user)
+
earlier_session = FactoryGirl.create(:music_session, :creator => creator, :description => "Earlier Session")
- later_session = FactoryGirl.create(:music_session, :creator => creator, :description => "Later Session")
+ FactoryGirl.create(:connection, :user => creator, :music_session => earlier_session)
+
+ later_session = FactoryGirl.create(:music_session, :creator => creator2, :description => "Later Session")
+ FactoryGirl.create(:connection, :user => creator2, :music_session => later_session)
user = FactoryGirl.create(:user)
@@ -94,14 +98,18 @@ describe MusicSession do
end
it "orders sessions with inviteds first, even if created first" do
- creator = FactoryGirl.create(:user)
- earlier_session = FactoryGirl.create(:music_session, :creator => creator, :description => "Earlier Session")
- later_session = FactoryGirl.create(:music_session, :creator => creator, :description => "Later Session")
+ creator1 = FactoryGirl.create(:user)
+ creator2 = FactoryGirl.create(:user)
+
+ earlier_session = FactoryGirl.create(:music_session, :creator => creator1, :description => "Earlier Session")
+ FactoryGirl.create(:connection, :user => creator1, :music_session => earlier_session)
+ later_session = FactoryGirl.create(:music_session, :creator => creator2, :description => "Later Session")
+ FactoryGirl.create(:connection, :user => creator2, :music_session => later_session)
user = FactoryGirl.create(:user)
- FactoryGirl.create(:connection, :user => creator, :music_session => earlier_session)
- FactoryGirl.create(:friendship, :user => creator, :friend => user)
- FactoryGirl.create(:friendship, :user => user, :friend => creator)
- FactoryGirl.create(:invitation, :sender => creator, :receiver => user, :music_session => earlier_session)
+ FactoryGirl.create(:connection, :user => creator1, :music_session => earlier_session)
+ FactoryGirl.create(:friendship, :user => creator1, :friend => user)
+ FactoryGirl.create(:friendship, :user => user, :friend => creator1)
+ FactoryGirl.create(:invitation, :sender => creator1, :receiver => user, :music_session => earlier_session)
music_sessions = MusicSession.index(user)
music_sessions.length.should == 2
@@ -114,7 +122,10 @@ describe MusicSession do
creator1 = FactoryGirl.create(:user)
creator2 = FactoryGirl.create(:user)
earlier_session = FactoryGirl.create(:music_session, :creator => creator1, :description => "Earlier Session")
+ FactoryGirl.create(:connection, :user => creator1, :music_session => earlier_session)
later_session = FactoryGirl.create(:music_session, :creator => creator2, :description => "Later Session")
+ FactoryGirl.create(:connection, :user => creator2, :music_session => later_session)
+
user = FactoryGirl.create(:user)
FactoryGirl.create(:friendship, :user => creator1, :friend => user)
FactoryGirl.create(:friendship, :user => user, :friend => creator1)
@@ -152,6 +163,7 @@ describe MusicSession do
creator = FactoryGirl.create(:user)
genre = FactoryGirl.create(:genre)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session", :genres => [genre])
+ FactoryGirl.create(:connection, :user => creator, :music_session => session)
user = FactoryGirl.create(:user)
music_sessions = MusicSession.index(user, nil, [genre.id])
@@ -196,6 +208,19 @@ describe MusicSession do
music_sessions.length.should == 1
end
+ it "does not list a session if it has no participants" do
+ # it's a design goal that there should be no sessions with 0 connections;
+ # however, this bug continually crops up so the .index method will protect against this common bug
+
+ creator = FactoryGirl.create(:user)
+ session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session")
+ session.connections.delete_all # should leave a bogus, 0 participant session around
+
+ music_sessions = MusicSession.index(creator, nil, nil)
+ music_sessions.length.should == 0
+
+ end
+
it "does not list a session if my_bands_only is set and it's not my band" do
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session")
@@ -209,6 +234,7 @@ describe MusicSession do
band = FactoryGirl.create(:band)
creator = FactoryGirl.create(:user)
session = FactoryGirl.create(:music_session, :creator => creator, :description => "Session", :band => band)
+ FactoryGirl.create(:connection, :user => creator, :music_session => session)
user = FactoryGirl.create(:user)
FactoryGirl.create(:band_musician, :band => band, :user => creator)
FactoryGirl.create(:band_musician, :band => band, :user => user)
diff --git a/web/app/assets/javascripts/findSession.js b/web/app/assets/javascripts/findSession.js
index 497f0170f..a829a56b3 100644
--- a/web/app/assets/javascripts/findSession.js
+++ b/web/app/assets/javascripts/findSession.js
@@ -162,7 +162,8 @@
}
function startSessionLatencyChecks(sessionList) {
- logger.debug("Starting latency checks");
+ logger.debug("Starting latency checks on " + sessionList.length + " sessions");
+
sessionLatency.subscribe(app.clientId, latencyResponse);
$.each(sessionList, function(index, session) {
sessions[session.id] = session;
@@ -217,7 +218,6 @@
* sortScore in sessionLatency.
*/
function renderSession(sessionId) {
-
// store session in the appropriate bucket and increment category counts
var session = sessions[sessionId];
if (containsInvitation(session)) {
diff --git a/web/app/helpers/application_helper.rb b/web/app/helpers/application_helper.rb
index 3330b45ab..7b53ed426 100644
--- a/web/app/helpers/application_helper.rb
+++ b/web/app/helpers/application_helper.rb
@@ -13,4 +13,8 @@ module ApplicationHelper
def self.base_uri(request)
(request.ssl? ? "https://" : "http://") + request.host_with_port
end
+
+ def bugsnag?
+ Rails.application.config.bugsnag_notify_release_stages.include? Rails.env
+ end
end
diff --git a/web/app/views/layouts/application.html.erb b/web/app/views/layouts/application.html.erb
index 7d5d78b31..b815b0477 100644
--- a/web/app/views/layouts/application.html.erb
+++ b/web/app/views/layouts/application.html.erb
@@ -23,8 +23,10 @@
<%= stylesheet_link_tag "client/search", media: "all" %>
<%= stylesheet_link_tag "client/ftue", media: "all" %>
<%= stylesheet_link_tag "client/createSession", media: "all" %>
-
-
+ <% if bugsnag? %>
+
+
+ <% end %>
<%= include_gon %>
<%= csrf_meta_tags %>
diff --git a/web/app/views/layouts/client.html.erb b/web/app/views/layouts/client.html.erb
index bfaa43d12..78f81a203 100644
--- a/web/app/views/layouts/client.html.erb
+++ b/web/app/views/layouts/client.html.erb
@@ -7,8 +7,10 @@
<%= stylesheet_link_tag "client/client", media: "all" %>
-
-
+ <% if bugsnag? %>
+
+
+ <% end %>
<%= include_gon %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
diff --git a/web/app/views/layouts/corporate.html.erb b/web/app/views/layouts/corporate.html.erb
index 67476673e..e9b31c516 100644
--- a/web/app/views/layouts/corporate.html.erb
+++ b/web/app/views/layouts/corporate.html.erb
@@ -5,8 +5,10 @@
<%= stylesheet_link_tag "corp/corporate", :media => "all" %>
-
-
+ <% if bugsnag? %>
+
+
+ <% end %>
<%= javascript_include_tag "corp/corporate" %>
<%= csrf_meta_tags %>
diff --git a/web/app/views/layouts/landing.erb b/web/app/views/layouts/landing.erb
index 448dff97d..4178d9deb 100644
--- a/web/app/views/layouts/landing.erb
+++ b/web/app/views/layouts/landing.erb
@@ -8,8 +8,10 @@
<%= stylesheet_link_tag "landing/landing", media: "all" %>
-
-
+ <% if bugsnag? %>
+
+
+ <% end %>
<%= include_gon %>
<%= csrf_meta_tags %>
diff --git a/web/config/application.rb b/web/config/application.rb
index 56a4daea8..648fcddc6 100644
--- a/web/config/application.rb
+++ b/web/config/application.rb
@@ -150,5 +150,6 @@ if defined?(Bundler)
config.allow_force_native_client = true
config.bugsnag_key = "4289fc981c8ce3eb0969003c4f498b01"
+ config.bugsnag_notify_release_stages = ["production"] # add 'development' if you want to test a bugsnag feature locally
end
end
diff --git a/web/config/initializers/bugsnag.rb b/web/config/initializers/bugsnag.rb
index b4bb811fb..8f4775f27 100644
--- a/web/config/initializers/bugsnag.rb
+++ b/web/config/initializers/bugsnag.rb
@@ -1,7 +1,7 @@
Bugsnag.configure do |config|
config.api_key = Rails.application.config.bugsnag_key
config.use_ssl = false
- config.notify_release_stages = ["production"] # add 'development' if you want to test a feature locally
+ config.notify_release_stages = Rails.application.config.bugsnag_notify_release_stages
config.auto_notify = true
config.app_version = JamWeb::VERSION
end
diff --git a/web/spec/requests/music_sessions_api_spec.rb b/web/spec/requests/music_sessions_api_spec.rb
index 2206728d0..976393522 100755
--- a/web/spec/requests/music_sessions_api_spec.rb
+++ b/web/spec/requests/music_sessions_api_spec.rb
@@ -558,8 +558,9 @@ describe "Music Session API ", :type => :api do
it "Finds a single open session" do
creator = FactoryGirl.create(:user)
- FactoryGirl.create(:music_session, :creator => creator, :description => "My Session")
-
+ session = FactoryGirl.create(:music_session, :creator => creator, :description => "My Session")
+ client = FactoryGirl.create(:connection, :user => creator, :music_session => session)
+
user = FactoryGirl.create(:user)
login(user)