kopia lustrzana https://github.com/c9/core
Changes signature of addTrait and adds filtering for test users
rodzic
7c80c14309
commit
973e6fc51d
|
@ -0,0 +1,20 @@
|
|||
if (define === undefined) {
|
||||
var define = function(fn) {
|
||||
fn(require, exports, module);
|
||||
};
|
||||
}
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var internalTestNames = ["c9test", "c9 test"];
|
||||
var regex = new RegExp(".*(" + internalTestNames.join("|") + ").*", "g");
|
||||
|
||||
function hasInternalTestName(name) {
|
||||
if (!name) return false;
|
||||
|
||||
return regex.test(name);
|
||||
}
|
||||
|
||||
module.exports = hasInternalTestName;
|
||||
});
|
|
@ -0,0 +1,47 @@
|
|||
"use strict";
|
||||
"use mocha";
|
||||
|
||||
require("c9/inline-mocha")(module);
|
||||
var assert = require("assert");
|
||||
var faker = require("faker");
|
||||
var hasInternalTestName= require("c9/has-internal-test-name");
|
||||
|
||||
describe("has-internal-test-name", function() {
|
||||
|
||||
it("returns false when undefined name", function() {
|
||||
var name;
|
||||
|
||||
assert.equal(false, hasInternalTestName(name), "should return false when name undefined");
|
||||
});
|
||||
|
||||
it("returns true when name contains c9test", function() {
|
||||
var name = "c9testjkdfkfd";
|
||||
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9test");
|
||||
|
||||
name = "c9test jjkdfhfkjfdh";
|
||||
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9test");
|
||||
|
||||
name = " c9testjhrrj";
|
||||
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9test");
|
||||
|
||||
name = " c9testjhrrj ffjh";
|
||||
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9test");
|
||||
});
|
||||
|
||||
it("returns true when name contains c9 test", function() {
|
||||
var name = "c9 test dkjfdgjhfgdfk";
|
||||
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9 test");
|
||||
|
||||
name = "c9 testdkjfdgjhfgdfk";
|
||||
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9 test");
|
||||
|
||||
name = " c9 test dkjfdgjhfgdfk ";
|
||||
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9 test");
|
||||
});
|
||||
|
||||
it("returns false when not internal user test name", function() {
|
||||
var name = faker.name.firstName();
|
||||
|
||||
assert.equal(false, hasInternalTestName(name), "should return false when name is not for internal testing");
|
||||
});
|
||||
});
|
|
@ -6,12 +6,14 @@ if (define === undefined) {
|
|||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
|
||||
var hasInternalDomain = require("c9/has-internal-domain");
|
||||
var hasInternalTestName = require("c9/has-internal-test-name");
|
||||
|
||||
function skipAnalytics(user) {
|
||||
if (!user) return true;
|
||||
if (user.id === -1) return true;
|
||||
if (hasInternalTestName(user.name)) return true;
|
||||
if (hasInternalDomain(user.email)) return true;
|
||||
return false;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue