Skip to content

Added new field subCategory to productTemplates to support Addons #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions migrations/20181226_productTemplates_subCategory.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--
-- UPDATE EXISTING TABLES:
-- product_templates:
-- added column `subCategory`

--
-- product_templates

-- Add new column
ALTER TABLE product_templates ADD COLUMN "subCategory" character varying(45);
-- Update new column
UPDATE projects SET "subCategory"="category" WHERE "subCategory" is NULL;
-- Set not null
ALTER TABLE projects ALTER COLUMN "subCategory" SET NOT NULL;
1 change: 1 addition & 0 deletions src/models/productTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = (sequelize, DataTypes) => {
name: { type: DataTypes.STRING(255), allowNull: false },
productKey: { type: DataTypes.STRING(45), allowNull: false },
category: { type: DataTypes.STRING(45), allowNull: false },
subCategory: { type: DataTypes.STRING(45), allowNull: false },
icon: { type: DataTypes.STRING(255), allowNull: false },
brief: { type: DataTypes.STRING(45), allowNull: false },
details: { type: DataTypes.STRING(255), allowNull: false },
Expand Down
1 change: 1 addition & 0 deletions src/routes/metadata/list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const productTemplates = [
name: 'name 1',
productKey: 'productKey 1',
category: 'category',
subCategory: 'category',
icon: 'http://example.com/icon1.ico',
brief: 'brief 1',
details: 'details 1',
Expand Down
2 changes: 2 additions & 0 deletions src/routes/milestoneTemplates/clone.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const productTemplates = [
name: 'name 1',
productKey: 'productKey 1',
category: 'category',
subCategory: 'category',
icon: 'http://example.com/icon1.ico',
brief: 'brief 1',
details: 'details 1',
Expand Down Expand Up @@ -47,6 +48,7 @@ const productTemplates = [
name: 'name 2',
productKey: 'productKey 2',
category: 'category',
subCategory: 'category',
icon: 'http://example.com/icon1.ico',
brief: 'brief 2',
details: 'details 2',
Expand Down
2 changes: 2 additions & 0 deletions src/routes/milestoneTemplates/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const productTemplates = [
name: 'name 1',
productKey: 'productKey 1',
category: 'category',
subCategory: 'category',
icon: 'http://example.com/icon1.ico',
brief: 'brief 1',
details: 'details 1',
Expand Down Expand Up @@ -48,6 +49,7 @@ const productTemplates = [
name: 'template 2',
productKey: 'productKey 2',
category: 'category',
subCategory: 'category',
icon: 'http://example.com/icon2.ico',
brief: 'brief 2',
details: 'details 2',
Expand Down
2 changes: 2 additions & 0 deletions src/routes/milestoneTemplates/delete.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const productTemplates = [
name: 'name 1',
productKey: 'productKey 1',
category: 'category',
subCategory: 'category',
icon: 'http://example.com/icon1.ico',
brief: 'brief 1',
details: 'details 1',
Expand Down Expand Up @@ -73,6 +74,7 @@ const productTemplates = [
name: 'template 2',
productKey: 'productKey 2',
category: 'category',
subCategory: 'category',
icon: 'http://example.com/icon2.ico',
brief: 'brief 2',
details: 'details 2',
Expand Down
2 changes: 2 additions & 0 deletions src/routes/milestoneTemplates/get.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const productTemplates = [
name: 'name 1',
productKey: 'productKey 1',
category: 'category',
subCategory: 'category',
icon: 'http://example.com/icon1.ico',
brief: 'brief 1',
details: 'details 1',
Expand Down Expand Up @@ -48,6 +49,7 @@ const productTemplates = [
name: 'template 2',
productKey: 'productKey 2',
category: 'category',
subCategory: 'category',
icon: 'http://example.com/icon2.ico',
brief: 'brief 2',
details: 'details 2',
Expand Down
2 changes: 2 additions & 0 deletions src/routes/milestoneTemplates/list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const productTemplates = [
name: 'name 1',
productKey: 'productKey 1',
category: 'category',
subCategory: 'category',
icon: 'http://example.com/icon1.ico',
brief: 'brief 1',
details: 'details 1',
Expand Down Expand Up @@ -48,6 +49,7 @@ const productTemplates = [
name: 'template 2',
productKey: 'productKey 2',
category: 'category',
subCategory: 'category',
icon: 'http://example.com/icon2.ico',
brief: 'brief 2',
details: 'details 2',
Expand Down
2 changes: 2 additions & 0 deletions src/routes/milestoneTemplates/update.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const productTemplates = [
name: 'name 1',
productKey: 'productKey 1',
category: 'category',
subCategory: 'category',
icon: 'http://example.com/icon1.ico',
brief: 'brief 1',
details: 'details 1',
Expand Down Expand Up @@ -48,6 +49,7 @@ const productTemplates = [
name: 'template 2',
productKey: 'productKey 2',
category: 'category',
subCategory: 'category',
icon: 'http://example.com/icon2.ico',
brief: 'brief 2',
details: 'details 2',
Expand Down
1 change: 1 addition & 0 deletions src/routes/phases/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ describe('Project Phases', () => {
name: 'name 1',
productKey: 'productKey 1',
category: 'generic',
subCategory: 'generic',
icon: 'http://example.com/icon1.ico',
brief: 'brief 1',
details: 'details 1',
Expand Down
1 change: 1 addition & 0 deletions src/routes/productTemplates/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const schema = {
param: Joi.object().keys({
id: Joi.any().strip(),
category: Joi.string().max(45).required(),
subCategory: Joi.string().max(45).required(),
name: Joi.string().max(255).required(),
productKey: Joi.string().max(45).required(),
icon: Joi.string().max(255).required(),
Expand Down
1 change: 1 addition & 0 deletions src/routes/productTemplates/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('CREATE product template', () => {
name: 'name 1',
productKey: 'productKey 1',
category: 'generic',
subCategory: 'generic',
icon: 'http://example.com/icon1.ico',
brief: 'brief 1',
details: 'details 1',
Expand Down
1 change: 1 addition & 0 deletions src/routes/productTemplates/delete.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('DELETE product template', () => {
name: 'name 1',
productKey: 'productKey 1',
category: 'generic',
subCategory: 'generic',
icon: 'http://example.com/icon1.ico',
brief: 'brief 1',
details: 'details 1',
Expand Down
1 change: 1 addition & 0 deletions src/routes/productTemplates/get.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('GET product template', () => {
name: 'name 1',
productKey: 'productKey 1',
category: 'generic',
subCategory: 'generic',
icon: 'http://example.com/icon1.ico',
brief: 'brief 1',
details: 'details 1',
Expand Down
7 changes: 5 additions & 2 deletions src/routes/productTemplates/list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import testUtil from '../../tests/util';
const validateProductTemplates = (count, resJson, expectedTemplates) => {
resJson.should.have.length(count);
resJson.forEach((pt, idx) => {
pt.should.have.all.keys('id', 'name', 'productKey', 'category', 'icon', 'brief', 'details', 'aliases',
'template', 'disabled', 'hidden', 'createdBy', 'createdAt', 'updatedBy', 'updatedAt');
pt.should.have.all.keys('id', 'name', 'productKey', 'category', 'subCategory', 'icon', 'brief', 'details',
'aliases', 'template', 'disabled', 'hidden', 'createdBy', 'createdAt', 'updatedBy', 'updatedAt');
pt.should.not.have.all.keys('deletedAt', 'deletedBy');
pt.name.should.be.eql(expectedTemplates[idx].name);
pt.productKey.should.be.eql(expectedTemplates[idx].productKey);
pt.category.should.be.eql(expectedTemplates[idx].category);
pt.subCategory.should.be.eql(expectedTemplates[idx].subCategory);
pt.icon.should.be.eql(expectedTemplates[idx].icon);
pt.brief.should.be.eql(expectedTemplates[idx].brief);
pt.details.should.be.eql(expectedTemplates[idx].details);
Expand All @@ -38,6 +39,7 @@ describe('LIST product templates', () => {
name: 'name 1',
productKey: 'productKey-1',
category: 'generic',
subCategory: 'generic',
icon: 'http://example.com/icon1.ico',
brief: 'brief 1',
details: 'details 1',
Expand Down Expand Up @@ -73,6 +75,7 @@ describe('LIST product templates', () => {
name: 'template 2',
productKey: 'productKey-2',
category: 'concrete',
subCategory: 'concrete',
icon: 'http://example.com/icon2.ico',
brief: 'brief 2',
details: 'details 2',
Expand Down
1 change: 1 addition & 0 deletions src/routes/productTemplates/update.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('UPDATE product template', () => {
name: 'name 1',
productKey: 'productKey 1',
category: 'generic',
subCategory: 'generic',
icon: 'http://example.com/icon1.ico',
brief: 'brief 1',
details: 'details 1',
Expand Down
1 change: 1 addition & 0 deletions src/routes/projectUpgrade/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ describe('Project upgrade', () => {
name: 'name 1',
productKey: 'a product key',
category: 'category',
subCategory: 'category',
icon: 'http://example.com/icon1.ico',
brief: 'brief 1',
details: 'details 1',
Expand Down
3 changes: 3 additions & 0 deletions src/routes/projects/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('Project create', () => {
name: 'template 1',
productKey: 'productKey-1',
category: 'generic',
subCategory: 'generic',
icon: 'http://example.com/icon2.ico',
brief: 'brief 1',
details: 'details 1',
Expand All @@ -51,6 +52,7 @@ describe('Project create', () => {
name: 'template 2',
productKey: 'productKey-2',
category: 'generic',
subCategory: 'generic',
icon: 'http://example.com/icon2.ico',
brief: 'brief 2',
details: 'details 2',
Expand All @@ -64,6 +66,7 @@ describe('Project create', () => {
name: 'template 3',
productKey: 'productKey-3',
category: 'generic',
subCategory: 'generic',
icon: 'http://example.com/icon3.ico',
brief: 'brief 3',
details: 'details 3',
Expand Down
1 change: 1 addition & 0 deletions src/routes/timelines/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const productTemplates = [
name: 'name 1',
productKey: 'productKey 1',
category: 'generic',
subCategory: 'generic',
icon: 'http://example.com/icon1.ico',
brief: 'brief 1',
details: 'details 1',
Expand Down
1 change: 1 addition & 0 deletions src/tests/seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ models.sequelize.sync({ force: true })
name: 'name 1',
productKey: 'productKey 1',
category: 'category',
subCategory: 'category',
icon: 'http://example.com/icon1.ico',
question: 'question 1',
info: 'info 1',
Expand Down