Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Short circuit when 'force' param is present.

  • Loading branch information...
commit 745feb999648782a7bccbceb1daecfc83af210d5 1 parent ff454d8
Mike Dirolf authored March 26, 2013
2  sixpack.js
@@ -81,7 +81,7 @@
81 81
                 }
82 82
             }
83 83
             if (force != null && _in_array(alternatives, force)) {
84  
-                params.force = force;
  84
+                return callback(null, {"status": "ok", "alternative": {"name": force}, "experiment": {"version": 0, "name": experiment_name}, "client_id": this.client_id});
85 85
             }
86 86
             if (this.ip_address) {
87 87
                 params.ip_address = this.ip_address;
13  test/sixpack-test.js
@@ -12,6 +12,19 @@ describe("Sixpack", function () {
12 12
         });
13 13
     });
14 14
 
  15
+    it("should return an alternative for simple_participate with force", function (done) {
  16
+        var sixpack = require('../');
  17
+        sixpack.simple_participate("show-bieber", ["trolled", "not-trolled"], "mike", "trolled", function(err, alt) {
  18
+            if (err) throw err;
  19
+            expect(alt).to.equal("trolled");
  20
+            sixpack.simple_participate("show-bieber", ["trolled", "not-trolled"], "mike", "not-trolled", function(err, alt) {
  21
+                if (err) throw err;
  22
+                expect(alt).to.equal("not-trolled");
  23
+                done();
  24
+            });
  25
+        });
  26
+    });
  27
+
15 28
     it("should auto generate a client_id", function (done) {
16 29
         var sixpack = require('../');
17 30
         sixpack.simple_participate("show_bieber", ["trolled", "not-trolled"], function(err, alt) {

0 notes on commit 745feb9

Please sign in to comment.
Something went wrong with that request. Please try again.