Merge branch 'develop' of bitbucket.org:jamkazam/jam-cloud into develop

This commit is contained in:
Seth Call 2014-02-25 05:41:47 +00:00
commit 686a0980e6
3 changed files with 14 additions and 11 deletions

View File

@ -102,15 +102,15 @@ module JamRuby
errors.add(:music_session, ValidationMessages::CANT_JOIN_RECORDING_SESSION)
end
unless user.admin?
num_sessions = Connection.where(:user_id => user_id)
.where(["(music_session_id IS NOT NULL) AND (aasm_state != ?)",EXPIRED_STATE.to_s])
.count
if 0 < num_sessions
errors.add(:music_session, ValidationMessages::CANT_JOIN_MULTIPLE_SESSIONS)
return false;
end
end
# unless user.admin?
# num_sessions = Connection.where(:user_id => user_id)
# .where(["(music_session_id IS NOT NULL) AND (aasm_state != ?)",EXPIRED_STATE.to_s])
# .count
# if 0 < num_sessions
# errors.add(:music_session, ValidationMessages::CANT_JOIN_MULTIPLE_SESSIONS)
# return false;
# end
# end
return true
end

View File

@ -34,8 +34,10 @@ class JamRuby::Promotional < ActiveRecord::Base
aasm_state
end
def self.active_promotionals
self.where(:aasm_state => ACTIVE_STATE).limit(100)
def self.active(max_count=100)
rel = self.where(:aasm_state => ACTIVE_STATE)
rel = rel.limit(mc) if 0 < (mc = max_count.to_i)
rel
end
end

View File

@ -426,6 +426,7 @@ describe ConnectionManager do
end
it "join_music_session fails if user has music_session already active" do
pending
user_id = create_user("test", "user11", "user11@jamkazam.com")
user = User.find(user_id)