Skip to content

Commit

Permalink
Merge branch 'master' into filter-by-tags-with-fields-param
Browse files Browse the repository at this point in the history
  • Loading branch information
iamigo committed Jul 20, 2017
2 parents 8cb8445 + 94a40ef commit c1b05ea
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 2 deletions.
5 changes: 5 additions & 0 deletions db/model/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ module.exports = function bot(seq, dataTypes) {
validate: { isUrl: true },
comment: 'The URL to load bot',
},
ui: {
type: dataTypes.BLOB,
allowNull: true,
comment: 'The packaged UI of the bot',
},
active: {
type: dataTypes.BOOLEAN,
defaultValue: false,
Expand Down
2 changes: 1 addition & 1 deletion tests/api/v1/bots/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe(`api: POST ${path}`, () => {
});

afterEach(u.forceDelete);
afterEach(tu.forceDeleteUser);
after(tu.forceDeleteToken);

describe('POST bot', () => {
it('Pass, post bot', (done) => {
Expand Down
6 changes: 6 additions & 0 deletions tests/api/v1/bots/uiBlob
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<body>
</body>
</html>
<script>
<script>
6 changes: 6 additions & 0 deletions tests/api/v1/bots/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@
*/
'use strict';

const path = require('path');
const fs = require('fs');
const tu = require('../../../testUtils');

const testStartTime = new Date();
const n = `${tu.namePrefix}TestBot`;
const n2 = n+'NonActive';
const mt = path.join(__dirname, './uiBlob');
const uiBlob = fs.readFileSync(mt);

const standard = {
name: n,
url: 'http://www.bar.com',
ui: uiBlob,
active: true,
actions: [
{
Expand Down Expand Up @@ -92,6 +97,7 @@ const standard = {
const nonActive = {
name: n2,
url: 'http://www.bar.com',
ui: uiBlob,
active: false,
actions: [
{
Expand Down
6 changes: 6 additions & 0 deletions tests/db/model/bot/uiBlob
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<body>
</body>
</html>
<script>
</script>
1 change: 1 addition & 0 deletions tests/db/model/bot/uiBlob2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
18 changes: 18 additions & 0 deletions tests/db/model/bot/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const expect = require('chai').expect;
const tu = require('../../../testUtils');
const u = require('./utils');
const Bot = tu.db.Bot;
const fs = require('fs');
const path = require('path');
const uiBlob = fs.readFileSync(path.join(__dirname, './uiBlob'));
const uiBlob2 = fs.readFileSync(path.join(__dirname, './uiBlob2'));

describe('db: bot: update: ', () => {
beforeEach((done) => {
Expand Down Expand Up @@ -48,6 +52,20 @@ describe('db: bot: update: ', () => {
.catch(done);
});

it('ok, bot ui updated', (done) => {
Bot.findOne({ where: { name: u.name } })
.then((o) => {
expect(o.ui.length).to.equal(uiBlob.length);
return o.update({ ui: uiBlob2 });
})
.then(() => Bot.findOne({ where: { name: u.name } }))
.then((o) => {
expect(o.ui.length).to.equal(uiBlob2.length);
done();
})
.catch(done);
});

it('fail, bot url bad', (done) => {
Bot.findOne({ where: { name: u.name } })
.then((o) => o.update({ url: 'noURL' }))
Expand Down
7 changes: 6 additions & 1 deletion tests/db/model/bot/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@
* tests/db/model/bot/utils.js
*/
'use strict';

const path = require('path');
const fs = require('fs');
const tu = require('../../../testUtils');

const testStartTime = new Date();
const n = `${tu.namePrefix}TestBot`;
const n2 = n+'NonActive';
const mt = path.join(__dirname, './uiBlob');
const uiBlob = fs.readFileSync(mt);

const standard = {
name: n,
url: 'http://www.bar.com',
ui: uiBlob,
active: true,
actions: [
{
Expand Down Expand Up @@ -92,6 +96,7 @@ const standard = {
const nonActive = {
name: n2,
url: 'http://www.bar.com',
ui: uiBlob,
active: false,
actions: [
{
Expand Down

0 comments on commit c1b05ea

Please sign in to comment.