Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

Commit

Permalink
Fixed based on client-side tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
assaf committed Mar 30, 2012
1 parent 40780c2 commit d1511a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions server/models/split_test.coffee
Expand Up @@ -48,7 +48,7 @@ class SplitTest
# Create a new split test with the given identifier. Throws exception is the # Create a new split test with the given identifier. Throws exception is the
# identifier is invalid. # identifier is invalid.
constructor: (id)-> constructor: (id)->
unless id && /^[\w]+$/.test(id) unless id && /^[\w\-]+$/.test(id)
throw new Error("Split test identifier may only contain alphanumeric, underscore and hyphen") throw new Error("Split test identifier may only contain alphanumeric, underscore and hyphen")
@_base_key = "#{SplitTest.NAMESPACE}.#{id}" @_base_key = "#{SplitTest.NAMESPACE}.#{id}"


Expand Down Expand Up @@ -172,7 +172,7 @@ class SplitTest
result = result =
participant: participant participant: participant
alternative: parseInt(alternative) alternative: parseInt(alternative)
joined: Date.create(score) joined: new Date(parseInt(score))


redis.hget "#{@_base_key}.outcomes", participant, (error, outcome)=> redis.hget "#{@_base_key}.outcomes", participant, (error, outcome)=>
return callback(error) if error return callback(error) if error
Expand All @@ -185,7 +185,7 @@ class SplitTest
# Get when participant compeleted this test # Get when participant compeleted this test
redis.zscore "#{@_base_key}.completed.#{alternative}", participant, (error, score)-> redis.zscore "#{@_base_key}.completed.#{alternative}", participant, (error, score)->
return callback(error) if error return callback(error) if error
result.completed = Date.create(score) result.completed = new Date(parseInt(score))
callback null, result callback null, result




Expand Down
12 changes: 8 additions & 4 deletions server/test/helper.coffee
Expand Up @@ -10,12 +10,16 @@ Activity = require("../models/activity")


Helper = Helper =
setup: (callback)-> setup: (callback)->
Async.series [ Async.parallel [
(done)-> (done)->
redis.flushdb done redis.flushdb(done)
, (done)-> , (done)->
server.listen 3003, done server.listen(3003, done)
], callback ], (error)->
if error
throw error
else
callback()


newIndex: (callback)-> newIndex: (callback)->
Activity.deleteIndex (error)-> Activity.deleteIndex (error)->
Expand Down

0 comments on commit d1511a1

Please sign in to comment.