Skip to content

Commit

Permalink
remove template functionality in condition builder
Browse files Browse the repository at this point in the history
  • Loading branch information
forrert committed Apr 9, 2017
1 parent fa9a66f commit 605e5f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
7 changes: 0 additions & 7 deletions lib/conditionbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ var _ = require('lodash'),
promise = require('promise'),
util = require('./util.js');

var templateOptions = {
interpolate: /{{([\s\S]+?)}}/g
};

var getParameters = function(modelProviders, target) {
var parameters = {target: target};
_.reduce(modelProviders, function(parameters, modelProvider) {
Expand Down Expand Up @@ -62,9 +58,6 @@ ConditionBuilder.prototype.getPromise = function() {
return getRulesPromise(this.securityManager, parameters, this.rules)
.then(function(conditions) {
return domain.aggregateConditions(conditions);
}).then(function(condition) {
var template = JSON.stringify(condition);
return JSON.parse(_.template(template, templateOptions)(parameters));
});
} else {
return util.promisify(domain.aggregateConditions([]));
Expand Down
6 changes: 3 additions & 3 deletions test/policy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,22 +201,22 @@ describe('Policy Spec:', function() {
aRule = {userId: '{{userId}}'},
anotherRule = {date: {$gt: '{{today}}'}};

it('replaces a parameter in rule', function(done) {
xit('replaces a parameter in rule', function(done) {
var policy = new policyCtor([aModelProvider], securityManager);
policy.addRule(aModel, aPermission, aRule);
var condition = policy.getCondition(aModel, aPermission);

assertCondition(condition, {userId: 'joe'}, done);
});
it('replaces multiple parameters in rules', function(done) {
xit('replaces multiple parameters in rules', function(done) {
var policy = new policyCtor([aModelProvider, anotherModelProvider], securityManager);
policy.addRule(aModel, aPermission, aRule);
policy.addRule(aModel, aPermission, anotherRule);
var condition = policy.getCondition(aModel, aPermission);

assertCondition(condition, {$or: [{userId: aUserId}, {date: {$gt: aDate}}]}, done);
});
it('throws an exception if a parameter is absent', function(done) {
xit('throws an exception if a parameter is absent', function(done) {
var policy = new policyCtor([aModelProvider], securityManager);
var aRuleWithAbsentParameter = {userId: '{{adminId}}'};

Expand Down

0 comments on commit 605e5f6

Please sign in to comment.