Skip to content

Commit

Permalink
[fix] admin create photo should allow empty string desc field
Browse files Browse the repository at this point in the history
  • Loading branch information
VecHK committed Dec 20, 2023
1 parent ef40873 commit 71ed362
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/app/controller/admin/photo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = app => {
ctx.validate({
member_id: { type: 'integer', required: true },
gallery_id: { type: 'integer', required: true },
desc: { type: 'string', required: true },
desc: { type: 'string', required: true, allowEmpty: true },
src: { type: 'string', required: true },
}, data);

Expand Down
5 changes: 4 additions & 1 deletion server/app/model/photo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ module.exports = app => {
const { INTEGER, VIRTUAL, STRING, TEXT } = app.Sequelize;

const Photo = app.model.define('photo', {
desc: TEXT,
desc: {
type: TEXT,
allowNull: false,
},

src: {
type: STRING(2048),
Expand Down
10 changes: 10 additions & 0 deletions server/test/admin-photo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ describe('controller/admin/photo', () => {
})
})

it('should successfully create a photo with empty string desc', async () => {
const member = await createMember(token, app, { qq_num: 22222 })
const gallery = await commonCreateGallery(token, app, {})
await createPhoto(token, app, {
gallery_id: gallery.id,
member_id: member.id,
desc: '',
})
})

it('should successfully get a photo infomation', async () => {
let globalQqNum = 8000
async function createRandomPhoto() {
Expand Down

0 comments on commit 71ed362

Please sign in to comment.