added ams_users invocation to ams_index method of controller; fixed bug in spec relating to user id accessor of user object

This commit is contained in:
Scott Comer 2014-06-15 10:58:19 -05:00
parent 07c1a4c85d
commit 740d48631a
2 changed files with 10 additions and 5 deletions

View File

@ -364,14 +364,14 @@ describe ActiveMusicSession do
music_sessions[1].tag.should_not be_nil
music_sessions[1].latency.should_not be_nil
users = ActiveMusicSession.ams_users()
users = ActiveMusicSession.ams_users().take(100)
users.should_not be_nil
users.length.should == 2
if users[0].music_session_id == earlier_session.id
users[0].user_id.should == creator.id
users[0].id.should == creator.id
users[0].latency.should == 15 # (5 + 20 + 5) / 2
users[1].music_session_id == later_session.id
users[1].user_id.should == creator2.id
users[1].id.should == creator2.id
users[1].latency.should == 22 # (5 + 30 + 10) / 2
else
users[0].music_session_id.should == later_session.id

View File

@ -70,15 +70,20 @@ class ApiMusicSessionsController < ApiController
ActiveRecord::Base.transaction do
ActiveMusicSession.ams_init(current_user, client_id: params[:client_id])
# note that these queries must be actualized before the end of the transaction
# else the temporary tables created by ams_init will be gone. it would be better
# to have the caller wrap the whole thing in a transaction and then remove the
# .all calls here.
@music_sessions = ActiveMusicSession.ams_index(current_user,
client_id: params[:client_id],
genre: params[:genre],
lang: params[:lang],
keyword: params[:keyword],
offset: params[:offset],
limit: params[:limit])
limit: params[:limit]).all
# todo do something with saved music list ams_users_tmp?
@music_session_users = ActiveMusicSession.ams_users().all
end
end