Permalink
Browse files

Short circuit when 'force' param is present.

  • Loading branch information...
1 parent ff454d8 commit 745feb999648782a7bccbceb1daecfc83af210d5 @mdirolf mdirolf committed Mar 26, 2013
Showing with 14 additions and 1 deletion.
  1. +1 −1 sixpack.js
  2. +13 −0 test/sixpack-test.js
View
2 sixpack.js
@@ -81,7 +81,7 @@
}
}
if (force != null && _in_array(alternatives, force)) {
- params.force = force;
+ return callback(null, {"status": "ok", "alternative": {"name": force}, "experiment": {"version": 0, "name": experiment_name}, "client_id": this.client_id});
}
if (this.ip_address) {
params.ip_address = this.ip_address;
View
13 test/sixpack-test.js
@@ -12,6 +12,19 @@ describe("Sixpack", function () {
});
});
+ it("should return an alternative for simple_participate with force", function (done) {
+ var sixpack = require('../');
+ sixpack.simple_participate("show-bieber", ["trolled", "not-trolled"], "mike", "trolled", function(err, alt) {
+ if (err) throw err;
+ expect(alt).to.equal("trolled");
+ sixpack.simple_participate("show-bieber", ["trolled", "not-trolled"], "mike", "not-trolled", function(err, alt) {
+ if (err) throw err;
+ expect(alt).to.equal("not-trolled");
+ done();
+ });
+ });
+ });
+
it("should auto generate a client_id", function (done) {
var sixpack = require('../');
sixpack.simple_participate("show_bieber", ["trolled", "not-trolled"], function(err, alt) {

0 comments on commit 745feb9

Please sign in to comment.