Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
26e4a2b72d
|
|
@ -151,3 +151,4 @@ user_mods.sql
|
||||||
connection_stale_expire.sql
|
connection_stale_expire.sql
|
||||||
rename_chat_messages.sql
|
rename_chat_messages.sql
|
||||||
fix_connection_fields.sql
|
fix_connection_fields.sql
|
||||||
|
session_ratings.sql
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE music_sessions_user_history ADD COLUMN rating_comment TEXT;
|
||||||
|
|
@ -13,7 +13,7 @@ module JamRuby
|
||||||
VAR_LAST_NAME = '@LASTNAME'
|
VAR_LAST_NAME = '@LASTNAME'
|
||||||
|
|
||||||
DEFAULT_SENDER = "noreply@jamkazam.com"
|
DEFAULT_SENDER = "noreply@jamkazam.com"
|
||||||
BATCH_SIZE = 1000
|
BATCH_SIZE = 5
|
||||||
|
|
||||||
BODY_TEMPLATE =<<FOO
|
BODY_TEMPLATE =<<FOO
|
||||||
Hello #{VAR_FIRST_NAME},
|
Hello #{VAR_FIRST_NAME},
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ module JamRuby
|
||||||
self.primary_key = 'id'
|
self.primary_key = 'id'
|
||||||
|
|
||||||
attr_accessible :max_concurrent_connections, :session_removed_at, :rating
|
attr_accessible :max_concurrent_connections, :session_removed_at, :rating
|
||||||
|
validates_inclusion_of :rating, :in => -1..1, :allow_nil => true
|
||||||
|
|
||||||
belongs_to(:user,
|
belongs_to(:user,
|
||||||
:class_name => "JamRuby::User",
|
:class_name => "JamRuby::User",
|
||||||
|
|
@ -16,8 +17,13 @@ module JamRuby
|
||||||
:class_name => "MusicSessionHistory",
|
:class_name => "MusicSessionHistory",
|
||||||
:foreign_key => "music_session_id")
|
:foreign_key => "music_session_id")
|
||||||
|
|
||||||
validates_inclusion_of :rating, :in => 0..2, :allow_nil => true
|
def self.latest_history(client_id)
|
||||||
after_save :track_user_progression
|
self.where(:client_id => client_id)
|
||||||
|
.order('created_at DESC')
|
||||||
|
.limit(1)
|
||||||
|
.includes(:user)
|
||||||
|
.first
|
||||||
|
end
|
||||||
|
|
||||||
def music_session_history
|
def music_session_history
|
||||||
@msh ||= JamRuby::MusicSessionHistory.find_by_music_session_id(self.music_session_id)
|
@msh ||= JamRuby::MusicSessionHistory.find_by_music_session_id(self.music_session_id)
|
||||||
|
|
@ -104,10 +110,23 @@ module JamRuby
|
||||||
self.perf_data.try(:uri)
|
self.perf_data.try(:uri)
|
||||||
end
|
end
|
||||||
|
|
||||||
def track_user_progression
|
def add_rating(rval, comment='')
|
||||||
if self.rating == 0
|
rval = rval.to_i
|
||||||
user.update_progression_field(:first_good_music_session_at)
|
self.rating = rval if 0 != rval
|
||||||
end
|
self.rating_comment = comment
|
||||||
end
|
end
|
||||||
|
|
||||||
|
MIN_SESSION_DURATION_RATING = 60
|
||||||
|
|
||||||
|
def should_rate_session?
|
||||||
|
(2 <= music_session_history.unique_users.all.count &&
|
||||||
|
MIN_SESSION_DURATION_RATING < (Time.now - music_session_history.created_at).seconds) ||
|
||||||
|
Rails.env.development?
|
||||||
|
end
|
||||||
|
|
||||||
|
def good_rating?
|
||||||
|
0 < self.rating.to_i
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ module JamRuby
|
||||||
|
|
||||||
def self.perform(args={})
|
def self.perform(args={})
|
||||||
session_id, interval_idx = args['session_id'], args['interval_idx'].to_i
|
session_id, interval_idx = args['session_id'], args['interval_idx'].to_i
|
||||||
return unless session_id && session = MusicSession.find(session_id)
|
return unless session_id && session = MusicSession.find_by_id(session_id)
|
||||||
GoogleAnalyticsEvent.enqueue(CAT_SESS_DUR, ACTION_SESS_DUR, SESSION_INTERVALS[interval_idx])
|
GoogleAnalyticsEvent.enqueue(CAT_SESS_DUR, ACTION_SESS_DUR, SESSION_INTERVALS[interval_idx])
|
||||||
interval_idx += 1
|
interval_idx += 1
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ module JamRuby
|
||||||
@queue = QUEUE_BAND_TRACKER
|
@queue = QUEUE_BAND_TRACKER
|
||||||
|
|
||||||
def self.perform(session_id)
|
def self.perform(session_id)
|
||||||
return unless session = MusicSession.find(session_id)
|
return unless session = MusicSession.find_by_id(session_id)
|
||||||
band = session.band
|
band = session.band
|
||||||
if band.in_real_session?(session)
|
if band.in_real_session?(session)
|
||||||
band.update_attribute(:did_real_session, true)
|
band.update_attribute(:did_real_session, true)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ describe MusicSessionUserHistory do
|
||||||
let(:user_history2) { FactoryGirl.create(:music_session_user_history, :history => music_session.music_session_history, :user => some_user) }
|
let(:user_history2) { FactoryGirl.create(:music_session_user_history, :history => music_session.music_session_history, :user => some_user) }
|
||||||
|
|
||||||
describe "create" do
|
describe "create" do
|
||||||
|
pending
|
||||||
it {user_history1.music_session_id.should == music_session.id }
|
it {user_history1.music_session_id.should == music_session.id }
|
||||||
it {user_history1.created_at.should_not be_nil }
|
it {user_history1.created_at.should_not be_nil }
|
||||||
it {user_history1.session_removed_at.should be_nil }
|
it {user_history1.session_removed_at.should be_nil }
|
||||||
|
|
@ -15,28 +16,35 @@ describe MusicSessionUserHistory do
|
||||||
|
|
||||||
describe "rating" do
|
describe "rating" do
|
||||||
|
|
||||||
describe "success" do
|
it "success" do
|
||||||
|
user_history1.update_attribute(:rating, 1)
|
||||||
before(:each) do
|
expect( user_history1.errors.any? ).to eq(false)
|
||||||
user_history1.update_attribute(:rating ,0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it { user_history1.errors.any?.should be_false}
|
it "out of range" do
|
||||||
end
|
user_history1.rating = 2
|
||||||
|
|
||||||
describe "out of range" do
|
|
||||||
before(:each) do
|
|
||||||
user_history1.update_attribute(:rating, 3)
|
|
||||||
user_history1.save
|
user_history1.save
|
||||||
|
expect( user_history1.errors.any? ).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { user_history1.errors.any?.should be_true}
|
it 'should rate success' do
|
||||||
|
users = [user_history1, user_history2]
|
||||||
|
Timecop.travel(Time.now + (MusicSessionUserHistory::MIN_SESSION_DURATION_RATING * 1.5).seconds)
|
||||||
|
expect( user_history1.should_rate_session? ).to eq(true)
|
||||||
|
Timecop.return
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should rate fails' do
|
||||||
|
users = [user_history1]
|
||||||
|
expect( user_history1.should_rate_session? ).to eq(false)
|
||||||
|
users = [user_history1, user_history2]
|
||||||
|
expect( user_history2.should_rate_session? ).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "end_history" do
|
describe "end_history" do
|
||||||
|
pending
|
||||||
it "histories created at the same time" do
|
it "histories created at the same time" do
|
||||||
user_history1.reload
|
user_history1.reload
|
||||||
user_history2.reload
|
user_history2.reload
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
|
|
@ -19,6 +19,11 @@
|
||||||
join : "Join"
|
join : "Join"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var sessionQualityTypes = {
|
||||||
|
good : "Good",
|
||||||
|
poor : "Poor"
|
||||||
|
};
|
||||||
|
|
||||||
var invitationTypes = {
|
var invitationTypes = {
|
||||||
email : "Email",
|
email : "Email",
|
||||||
facebook : "Facebook",
|
facebook : "Facebook",
|
||||||
|
|
@ -83,6 +88,7 @@
|
||||||
audioTest : "AudioTest",
|
audioTest : "AudioTest",
|
||||||
sessionCount : "SessionCount",
|
sessionCount : "SessionCount",
|
||||||
sessionMusicians : "SessionMusicians",
|
sessionMusicians : "SessionMusicians",
|
||||||
|
sessionQuality : "SessionQuality",
|
||||||
invite : "Invite",
|
invite : "Invite",
|
||||||
findSession : "FindSession",
|
findSession : "FindSession",
|
||||||
friendConnect : "Connect",
|
friendConnect : "Connect",
|
||||||
|
|
@ -174,6 +180,11 @@
|
||||||
context.ga('send', 'event', categories.sessionMusicians, joinOrCreate);
|
context.ga('send', 'event', categories.sessionMusicians, joinOrCreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function trackSessionQuality(goodOrPoor) {
|
||||||
|
assertOneOf(goodOrPoor, sessionQualityTypes);
|
||||||
|
context.ga('send', 'event', categories.sessionQuality, goodOrPoor);
|
||||||
|
}
|
||||||
|
|
||||||
function trackServiceInvitations(invitationType, numInvited) {
|
function trackServiceInvitations(invitationType, numInvited) {
|
||||||
assertOneOf(invitationType, invitationTypes);
|
assertOneOf(invitationType, invitationTypes);
|
||||||
assertNumber(numInvited);
|
assertNumber(numInvited);
|
||||||
|
|
@ -271,6 +282,7 @@
|
||||||
var GA = {};
|
var GA = {};
|
||||||
GA.Categories = categories;
|
GA.Categories = categories;
|
||||||
GA.SessionCreationTypes = sessionCreationTypes;
|
GA.SessionCreationTypes = sessionCreationTypes;
|
||||||
|
GA.SessionQualityTypes = sessionQualityTypes;
|
||||||
GA.InvitationTypes = invitationTypes;
|
GA.InvitationTypes = invitationTypes;
|
||||||
GA.FriendConnectTypes = friendConnectTypes;
|
GA.FriendConnectTypes = friendConnectTypes;
|
||||||
GA.RecordingActions = recordingActions;
|
GA.RecordingActions = recordingActions;
|
||||||
|
|
@ -281,6 +293,7 @@
|
||||||
GA.trackFTUECompletion = trackFTUECompletion;
|
GA.trackFTUECompletion = trackFTUECompletion;
|
||||||
GA.trackSessionCount = trackSessionCount;
|
GA.trackSessionCount = trackSessionCount;
|
||||||
GA.trackSessionMusicians = trackSessionMusicians;
|
GA.trackSessionMusicians = trackSessionMusicians;
|
||||||
|
GA.trackSessionQuality = trackSessionQuality;
|
||||||
GA.trackServiceInvitations = trackServiceInvitations;
|
GA.trackServiceInvitations = trackServiceInvitations;
|
||||||
GA.trackFindSessions = trackFindSessions;
|
GA.trackFindSessions = trackFindSessions;
|
||||||
GA.virtualPageView = virtualPageView;
|
GA.virtualPageView = virtualPageView;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,123 @@
|
||||||
|
(function(context,$) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
context.JK = context.JK || {};
|
||||||
|
context.JK.RateSessionDialog = function(app) {
|
||||||
|
var logger = context.JK.logger;
|
||||||
|
var dialogId = 'rate-session-dialog';
|
||||||
|
var $scopeSelector = "[layout-id='rate-session-dialog']";
|
||||||
|
var clientId = context.JK.JamServer.clientID;
|
||||||
|
|
||||||
|
function reset() {
|
||||||
|
clientId = context.JK.JamServer.clientID;
|
||||||
|
$('#btn-rate-session-up', $scopeSelector).removeClass('selected');
|
||||||
|
$('#btn-rate-session-down', $scopeSelector).removeClass('selected');
|
||||||
|
$('#txt-rate-session-comment',"[layout-id='rate-session-dialog']").val('');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showDialog() {
|
||||||
|
if (clientId) {
|
||||||
|
reset();
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: "/api/participant_histories/"+clientId
|
||||||
|
}).done(function (response) {
|
||||||
|
if (response &&
|
||||||
|
response.hasOwnProperty('should_rate_session') &&
|
||||||
|
true==response['should_rate_session']) {
|
||||||
|
app.layout.showDialog(dialogId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeDialog() {
|
||||||
|
app.layout.closeDialog(dialogId);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRating() {
|
||||||
|
if ($('#btn-rate-session-down', $scopeSelector).hasClass('selected')) {
|
||||||
|
return -1;
|
||||||
|
} else if ($('#btn-rate-session-up', $scopeSelector).hasClass('selected')) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getComment() {
|
||||||
|
return $('#txt-rate-session-comment',"[layout-id='rate-session-dialog']").val();
|
||||||
|
}
|
||||||
|
|
||||||
|
function events() {
|
||||||
|
$('#btn-rate-session-cancel', $scopeSelector).click(function(evt) {
|
||||||
|
closeDialog();
|
||||||
|
});
|
||||||
|
$('#btn-rate-session-up', $scopeSelector).click(function(evt) {
|
||||||
|
if ($(this).hasClass('selected')) {
|
||||||
|
$(this).removeClass('selected')
|
||||||
|
} else {
|
||||||
|
$(this).addClass('selected');
|
||||||
|
}
|
||||||
|
if ($('#btn-rate-session-down').hasClass('selected')) {
|
||||||
|
$('#btn-rate-session-down').removeClass('selected')
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
$('#btn-rate-session-down', $scopeSelector).click(function(evt) {
|
||||||
|
if ($(this).hasClass('selected')) {
|
||||||
|
$(this).removeClass('selected')
|
||||||
|
} else {
|
||||||
|
$(this).addClass('selected');
|
||||||
|
}
|
||||||
|
if ($('#btn-rate-session-up').hasClass('selected')) {
|
||||||
|
$('#btn-rate-session-up').removeClass('selected')
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
$('#btn-rate-session-send', $scopeSelector).click(function(evt) {
|
||||||
|
var rr = getRating(), cc = getComment();
|
||||||
|
if (0 == rr && 0 == cc.length) {
|
||||||
|
closeDialog();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var url = "/api/participant_histories/"+clientId+"/rating";
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: url,
|
||||||
|
data: { rating: getRating(), comment: getComment() }
|
||||||
|
}).done(function (response) {
|
||||||
|
var qq = getRating();
|
||||||
|
if (0 < qq) {
|
||||||
|
context.JK.GA.trackSessionQuality(context.JK.GA.SessionQualityTypes.good);
|
||||||
|
} else if (0 > qq){
|
||||||
|
context.JK.GA.trackSessionQuality(context.JK.GA.SessionQualityTypes.poor);
|
||||||
|
}
|
||||||
|
closeDialog();
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function beforeShow(data) {
|
||||||
|
// confirm user should see dialog
|
||||||
|
}
|
||||||
|
|
||||||
|
function afterShow(data) {
|
||||||
|
}
|
||||||
|
|
||||||
|
function initialize() {
|
||||||
|
var dialogBindings = {
|
||||||
|
'beforeShow' : beforeShow,
|
||||||
|
'afterShow' : afterShow
|
||||||
|
};
|
||||||
|
app.bindDialog(dialogId, dialogBindings);
|
||||||
|
events();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.initialize = initialize;
|
||||||
|
this.showDialog = showDialog;
|
||||||
|
};
|
||||||
|
})(window,jQuery);
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
var playbackControls = null;
|
var playbackControls = null;
|
||||||
var promptLeave = false;
|
var promptLeave = false;
|
||||||
var backendMixerAlertThrottleTimer = null;
|
var backendMixerAlertThrottleTimer = null;
|
||||||
|
var rateSessionDialog = null;
|
||||||
|
|
||||||
var rest = context.JK.Rest();
|
var rest = context.JK.Rest();
|
||||||
|
|
||||||
|
|
@ -1305,15 +1306,27 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sessionLeave(evt) {
|
function bailOut() {
|
||||||
evt.preventDefault();
|
|
||||||
|
|
||||||
promptLeave = false;
|
promptLeave = false;
|
||||||
context.window.location = '/client#/home';
|
context.window.location = '/client#/home';
|
||||||
|
}
|
||||||
|
|
||||||
|
function sessionLeave(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
rateSession();
|
||||||
|
bailOut();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function rateSession() {
|
||||||
|
if (rateSessionDialog === null) {
|
||||||
|
rateSessionDialog = new context.JK.RateSessionDialog(context.JK.app);
|
||||||
|
rateSessionDialog.initialize();
|
||||||
|
}
|
||||||
|
rateSessionDialog.showDialog();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function sessionResync(evt) {
|
function sessionResync(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
var response = context.jamClient.SessionAudioResync();
|
var response = context.jamClient.SessionAudioResync();
|
||||||
|
|
|
||||||
|
|
@ -728,3 +728,25 @@ table.vu td {
|
||||||
#update-session-invite-musicians {
|
#update-session-invite-musicians {
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rate-thumbsup {
|
||||||
|
width:64px;
|
||||||
|
height:64px;
|
||||||
|
display:inline-block;
|
||||||
|
background-image:url('/assets/content/icon_thumbsup_big_off.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
.rate-thumbsup.selected {
|
||||||
|
background-image:url('/assets/content/icon_thumbsup_big_on.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
.rate-thumbsdown {
|
||||||
|
width:64px;
|
||||||
|
height:64px;
|
||||||
|
display:inline-block;
|
||||||
|
background-image:url('/assets/content/icon_thumbsdown_big_off.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
.rate-thumbsdown.selected {
|
||||||
|
background-image:url('/assets/content/icon_thumbsdown_big_on.png');
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -151,16 +151,27 @@ class ApiMusicSessionsController < ApiController
|
||||||
end
|
end
|
||||||
|
|
||||||
def participant_rating
|
def participant_rating
|
||||||
@history = MusicSessionUserHistory.find(params[:id])
|
if @history = MusicSessionUserHistory.latest_history(params[:client_id])
|
||||||
@history.rating = params[:rating]
|
if request.post?
|
||||||
|
@history.add_rating(params[:rating], params[:comment])
|
||||||
@history.save
|
@history.save
|
||||||
|
|
||||||
if @history.errors.any?
|
if @history.errors.any?
|
||||||
response.status = :unprocessable_entity
|
response.status = :unprocessable_entity
|
||||||
respond_with @history
|
respond_with @history
|
||||||
else
|
else
|
||||||
|
if @history.good_rating? && @history.user.first_good_music_session_at.nil?
|
||||||
|
@history.user.first_good_music_session_at = Time.now
|
||||||
|
@history.user.save
|
||||||
|
end
|
||||||
render :json => {}, :status => :ok
|
render :json => {}, :status => :ok
|
||||||
end
|
end
|
||||||
|
elsif request.get?
|
||||||
|
render :json => { :should_rate_session => @history.should_rate_session? }, :status => :ok
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render :json => { :message => ValidationMessages::SESSION_NOT_FOUND }, :status => 404
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def track_index
|
def track_index
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<div class="dialog-overlay-sm" layout="dialog" layout-id="rate-session-dialog" id="rate-session-dialog">
|
||||||
|
<!-- dialog header -->
|
||||||
|
<div class="content-head">
|
||||||
|
<%= image_tag "shared/icon_session.png", {:height => 19, :width => 19, :class => "content-icon"} %>
|
||||||
|
<h1>please rate your session</h1>
|
||||||
|
</div>
|
||||||
|
<div class="dialog-inner">
|
||||||
|
<div class="center">
|
||||||
|
<a id="btn-rate-session-up" class="rate-thumbsup" href="#"></a> <a id="btn-rate-session-down" href="#" class="rate-thumbsdown"></a>
|
||||||
|
<br clear="left"><br>
|
||||||
|
<textarea id="txt-rate-session-comment" class="w80" rows="3" placeholder="Tell us more about what you liked or didn't like..."></textarea>
|
||||||
|
<br><br>
|
||||||
|
<a id="btn-rate-session-send" href="#" class="button-orange">SEND FEEDBACK</a> <a id="btn-rate-session-cancel" href="#" class="button-grey">NOT NOW, THANKS</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- end inner -->
|
||||||
|
</div>
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
<%= render "clients/gear/gear_wizard" %>
|
<%= render "clients/gear/gear_wizard" %>
|
||||||
<%= render "terms" %>
|
<%= render "terms" %>
|
||||||
<%= render "leaveSessionWarning" %>
|
<%= render "leaveSessionWarning" %>
|
||||||
|
<%= render "rateSession" %>
|
||||||
<%= render "alert" %>
|
<%= render "alert" %>
|
||||||
<%= render "sidebar" %>
|
<%= render "sidebar" %>
|
||||||
<%= render "createSession" %>
|
<%= render "createSession" %>
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,8 @@ SampleApp::Application.routes.draw do
|
||||||
match '/sessions/:id/claimed_recording/:claimed_recording_id/start' => 'api_music_sessions#claimed_recording_start', :via => :post
|
match '/sessions/:id/claimed_recording/:claimed_recording_id/start' => 'api_music_sessions#claimed_recording_start', :via => :post
|
||||||
match '/sessions/:id/claimed_recording/:claimed_recording_id/stop' => 'api_music_sessions#claimed_recording_stop', :via => :post
|
match '/sessions/:id/claimed_recording/:claimed_recording_id/stop' => 'api_music_sessions#claimed_recording_stop', :via => :post
|
||||||
|
|
||||||
match '/participant_histories/:id/rating' => 'api_music_sessions#participant_rating', :via => :post
|
match '/participant_histories/:client_id/rating' => 'api_music_sessions#participant_rating', :via => :post
|
||||||
|
match '/participant_histories/:client_id' => 'api_music_sessions#participant_rating', :via => :get
|
||||||
|
|
||||||
# genres
|
# genres
|
||||||
match '/genres' => 'api_genres#index', :via => :get
|
match '/genres' => 'api_genres#index', :via => :get
|
||||||
|
|
|
||||||
|
|
@ -656,10 +656,10 @@ describe "Music Session API ", :type => :api do
|
||||||
msuh = FactoryGirl.create(:music_session_user_history, :music_session_id => music_session.id, :client_id => client.client_id, :user_id => user.id)
|
msuh = FactoryGirl.create(:music_session_user_history, :music_session_id => music_session.id, :client_id => client.client_id, :user_id => user.id)
|
||||||
msuh.rating.should be_nil
|
msuh.rating.should be_nil
|
||||||
login(user)
|
login(user)
|
||||||
post "/api/participant_histories/#{msuh.id}/rating.json", { :rating => 0 }.to_json, "CONTENT_TYPE" => "application/json"
|
post "/api/participant_histories/#{msuh.client_id}/rating.json", { :rating => 1 }.to_json, "CONTENT_TYPE" => "application/json"
|
||||||
last_response.status.should == 200
|
last_response.status.should == 200
|
||||||
msuh.reload
|
msuh.reload
|
||||||
msuh.rating.should == 0
|
msuh.rating.to_i.should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it "track sync" do
|
it "track sync" do
|
||||||
|
|
|
||||||
|
|
@ -160,8 +160,9 @@ describe "User Progression", :type => :api do
|
||||||
client = FactoryGirl.create(:connection, :user => user)
|
client = FactoryGirl.create(:connection, :user => user)
|
||||||
music_session = FactoryGirl.create(:music_session, :creator => user, :description => "My Session")
|
music_session = FactoryGirl.create(:music_session, :creator => user, :description => "My Session")
|
||||||
msuh = FactoryGirl.create(:music_session_user_history, :music_session_id => music_session.id, :client_id => client.client_id, :user_id => user.id)
|
msuh = FactoryGirl.create(:music_session_user_history, :music_session_id => music_session.id, :client_id => client.client_id, :user_id => user.id)
|
||||||
|
expect(msuh).to_not eq(nil)
|
||||||
login(user)
|
login(user)
|
||||||
post "/api/participant_histories/#{msuh.id}/rating.json", { :rating => 0 }.to_json, "CONTENT_TYPE" => "application/json"
|
post "/api/participant_histories/#{msuh.client_id}/rating.json", { :rating => 1 }.to_json, "CONTENT_TYPE" => "application/json"
|
||||||
|
|
||||||
user.reload
|
user.reload
|
||||||
user.first_good_music_session_at.should_not be_nil
|
user.first_good_music_session_at.should_not be_nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue