Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Padding method always ensures music is queued

  • Loading branch information...
commit 91d5d92b79436cca4b28c72bef6b0f81f388425e 1 parent 8a3233b
Zach Holman holman authored
2  app/models/office.rb
View
@@ -35,7 +35,7 @@ def self.user_string
#
# Returns the String configuration value for `office_url`.
def self.url
- Play.config['office_url']
+ Play.config.office_url
end
end
end
11 app/models/queue.rb
View
@@ -67,6 +67,8 @@ def self.clear
#
# Returns nothing.
def self.clean
+ pad
+
ids = Play::Queue.playlist.tracks.get.map{ |record| record.persistent_ID.get }
current = Play::Player.now_playing.id
position = ids.index(current)
@@ -77,6 +79,15 @@ def self.clean
end
end
+ # Pad the queue with songs.
+ #
+ # Returns nothing.
+ def self.pad
+ if Play::Queue.songs.size < 3
+ add_song Song.new(Play::Player.app.tracks.any.get.persistent_ID.get)
+ end
+ end
+
# The songs currently in the Queue.
#
# Returns an Array of Songs.
3  app/models/user.rb
View
@@ -27,7 +27,7 @@ class User
#
# Returns the User.
def initialize(login,email)
- @login = login
+ @login = login.downcase
@email = email
end
@@ -47,6 +47,7 @@ def self.create(login,email)
#
# Returns the User, nil if no User found.
def self.find(login)
+ login.downcase!
return nil if !$redis.sismember(KEY, login)
email = $redis.get "#{KEY}:#{login}:email"
3  app/play.rb
View
@@ -8,7 +8,8 @@ def self.config
OpenStruct.new \
:secret => yaml['gh_secret'],
:client_id => yaml['gh_key'],
- :stream_url => yaml['stream_url']
+ :stream_url => yaml['stream_url'],
+ :office_url => yaml['office_url']
end
private
7 test/office_test.rb
View
@@ -4,11 +4,6 @@
setup do
end
- test "url returns config office_url" do
- Play.expects(:config).returns({'office_url' => 'http://zachholman.com'})
- assert_equal 'http://zachholman.com', Office.url
- end
-
test "user string returns a string o' user data" do
object = "lol"
object.stubs(:read).returns("holman,kneath")
@@ -19,7 +14,7 @@
test "users are returned based on office string" do
holman = User.create 'holman', 'zach@example.com'
kneath = User.create 'kneath', 'kyle@example.com'
-
+
Office.stubs(:user_string).returns("holman,defunkt")
assert_equal ['holman'], Office.users.map{|user| user.login}
end
Please sign in to comment.
Something went wrong with that request. Please try again.