Skip to content

Commit

Permalink
chore: update to latest eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Kirkpatrick authored and Tom Kirkpatrick committed May 4, 2017
1 parent ed89c12 commit 0e3b956
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use strict'

const deprecate = require('depd')('loopback-ds-readonly-mixin')
const readOnly = require('./read-only')

module.exports = function mixin(app) {
'use strict'
app.loopback.modelBuilder.mixins.define = deprecate.function(app.loopback.modelBuilder.mixins.define,
'app.modelBuilder.mixins.define: Use mixinSources instead ' +
'see https://github.com/fullcube/loopback-ds-readonly-mixin#mixinsources')
Expand Down
6 changes: 3 additions & 3 deletions lib/read-only.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict'

const debug = require('debug')('loopback:mixin:readonly')

module.exports = Model => {
'use strict'

debug('ReadOnly mixin for Model %s', Model.modelName)

Model.on('attached', () => {
Model.stripReadOnlyProperties = (modelName, ctx, next) => {
debug('stripReadOnlyProperties for model %s (via remote method %o)', modelName, ctx.methodString)
const body = ctx.req.body
const { body } = ctx.req

if (!body) {
return next()
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"condition-circle": "^1.5.0",
"coveralls": "^2.13.0",
"dirty-chai": "^1.2.2",
"eslint": "^3.19.0",
"eslint-config-fullcube": "^2.0.0",
"loopback": "^3.6.0",
"loopback-boot": "^2.24.0",
Expand Down
20 changes: 10 additions & 10 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const lt = require('loopback-testing')
const chai = require('chai')
const expect = chai.expect
const TestDataBuilder = lt.TestDataBuilder
const ref = TestDataBuilder.ref
const lt = require('loopback-testing')
const request = require('supertest')

const { TestDataBuilder, TestDataBuilder: { ref } } = lt
const { expect } = chai

chai.use(require('dirty-chai'))

// Create a new loopback app.
Expand Down Expand Up @@ -191,17 +191,17 @@ describe('loopback datasource readonly property (mixin sources.js)', function()
})

describe('updateAll', function() {
lt.beforeEach.givenModel('Product', { name: 'book 1', type: 'book', status: 'disabled' }, 'book1')
lt.beforeEach.givenModel('Product', { name: 'book 2', type: 'book', status: 'pending' }, 'book2')
lt.beforeEach.givenModel('Product', { name: 'book 1', type: 'book', status: 'disabled' }, 'bookOne')
lt.beforeEach.givenModel('Product', { name: 'book 2', type: 'book', status: 'pending' }, 'bookTwo')
it('should not change readonly properties with bulk updates', function() {
return json('post', '/api/products/update')
.query({ where: { type: 'book' } })
.send({ status: 'disabled' })
.expect(200)
.then(() => app.models.Product.findById(this.book1.id))
.then(book1 => expect(book1.status).to.equal('disabled'))
.then(() => app.models.Product.findById(this.book2.id))
.then(book2 => expect(book2.status).to.equal('pending'))
.then(() => app.models.Product.findById(this.bookOne.id))
.then(bookOne => expect(bookOne.status).to.equal('disabled'))
.then(() => app.models.Product.findById(this.bookTwo.id))
.then(bookTwo => expect(bookTwo.status).to.equal('pending'))
})
})

Expand Down

0 comments on commit 0e3b956

Please sign in to comment.