Skip to content

Commit

Permalink
Merge 9338090 into 696f7c4
Browse files Browse the repository at this point in the history
  • Loading branch information
iceiilin committed May 9, 2018
2 parents 696f7c4 + 9338090 commit 769b18e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/models/lookup.js
Expand Up @@ -95,6 +95,7 @@ function LookupModelFactory (
assert.string(node, 'node');
assert.string(macAddress, 'macAddress');

macAddress = macAddress.toLowerCase();
var query = { macAddress: macAddress };
var options = {
new: true,
Expand Down Expand Up @@ -129,6 +130,7 @@ function LookupModelFactory (

var self = this;

macAddress = macAddress.toLowerCase();
return self.findOne({ macAddress: macAddress }).then(function (record) {
if (record) {
return self.update(
Expand All @@ -145,6 +147,7 @@ function LookupModelFactory (
});
},
setIp: function(ipAddress, macAddress) {
macAddress = macAddress.toLowerCase();
switch(dbType) {
case 'mongo':
return this.setIpMongo(ipAddress, macAddress);
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/models/lookup-spec.js
Expand Up @@ -186,7 +186,7 @@ describe('Models.Lookup', function () {
'macAddress'
).then(function () {
expect(waterline.lookups.findAndModifyMongo).to.have.been.calledOnce;
var query = { macAddress: 'macAddress' };
var query = { macAddress: 'macaddress' };
var update = { $set: { node: waterline.lookups.mongo.objectId('node') }};
expect(waterline.lookups.findAndModifyMongo.firstCall.args[0])
.to.deep.equal(query);
Expand All @@ -212,7 +212,7 @@ describe('Models.Lookup', function () {
'proxy',
'macAddress'
).then(function () {
expect(findOne).to.have.been.calledWith({ macAddress: 'macAddress' });
expect(findOne).to.have.been.calledWith({ macAddress: 'macaddress' });
expect(update).to.have.been.calledWith({ id: 'id' }, { proxy: 'proxy' });
});
});
Expand All @@ -224,7 +224,7 @@ describe('Models.Lookup', function () {
'proxy',
'macAddress'
)).to.be.rejectedWith(Errors.NotFoundError).then(function () {
expect(findOne).to.have.been.calledWith({ macAddress: 'macAddress' });
expect(findOne).to.have.been.calledWith({ macAddress: 'macaddress' });
});
});
});
Expand Down

0 comments on commit 769b18e

Please sign in to comment.