Skip to content

fix(app:seed): adding empty where clause for Sequelize destroy calls #944

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Login View', function() {

beforeEach(function(done) {
<% if (filters.mongooseModels) { %>UserModel.removeAsync()<% }
if (filters.sequelizeModels) { %>UserModel.destroy()<% } %>
if (filters.sequelizeModels) { %>UserModel.destroy({where: {}})<% } %>
.then(function() {
<% if (filters.mongooseModels) { %>return UserModel.createAsync(testUser);<% }
if (filters.sequelizeModels) { %>return UserModel.create(testUser);<% } %>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/e2e/account(auth)/login/login.spec(mocha).js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Login View', function() {
before(function() {
return UserModel
<% if (filters.mongooseModels) { %>.removeAsync()<% }
if (filters.sequelizeModels) { %>.destroy()<% } %>
if (filters.sequelizeModels) { %>.destroy({where: {}})<% } %>
.then(function() {
<% if (filters.mongooseModels) { %>return UserModel.createAsync(testUser);<% }
if (filters.sequelizeModels) { %>return UserModel.create(testUser);<% } %>
Expand All @@ -31,7 +31,7 @@ describe('Login View', function() {

after(function() {
<% if (filters.mongooseModels) { %>return UserModel.removeAsync();<% }
if (filters.sequelizeModels) { %>return UserModel.destroy();<% } %>
if (filters.sequelizeModels) { %>return UserModel.destroy({where: {}});<% } %>
});

it('should include login form with correct inputs and submit button', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Logout View', function() {

beforeEach(function(done) {
<% if (filters.mongooseModels) { %>UserModel.removeAsync()<% }
if (filters.sequelizeModels) { %>UserModel.destroy()<% } %>
if (filters.sequelizeModels) { %>UserModel.destroy({where: {}})<% } %>
.then(function() {
<% if (filters.mongooseModels) { %>return UserModel.createAsync(testUser);<% }
if (filters.sequelizeModels) { %>return UserModel.create(testUser);<% } %>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/e2e/account(auth)/logout/logout.spec(mocha).js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Logout View', function() {
beforeEach(function() {
return UserModel
<% if (filters.mongooseModels) { %>.removeAsync()<% }
if (filters.sequelizeModels) { %>.destroy()<% } %>
if (filters.sequelizeModels) { %>.destroy({where: {}})<% } %>
.then(function() {
<% if (filters.mongooseModels) { %>return UserModel.createAsync(testUser);<% }
if (filters.sequelizeModels) { %>return UserModel.create(testUser);<% } %>
Expand All @@ -31,7 +31,7 @@ describe('Logout View', function() {

after(function() {
<% if (filters.mongooseModels) { %>return UserModel.removeAsync();<% }
if (filters.sequelizeModels) { %>return UserModel.destroy();<% } %>
if (filters.sequelizeModels) { %>return UserModel.destroy({where: {}});<% } %>
})

describe('with local auth', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Signup View', function() {

it('should signup a new user, log them in, and redirecting to "/"', function(done) {
<% if (filters.mongooseModels) { %>UserModel.remove(function() {<% }
if (filters.sequelizeModels) { %>UserModel.destroy().then(function() {<% } %>
if (filters.sequelizeModels) { %>UserModel.destroy({where: {}}).then(function() {<% } %>
page.signup(testUser);

var navbar = require('../../components/navbar/navbar.po');
Expand Down
4 changes: 2 additions & 2 deletions app/templates/e2e/account(auth)/signup/signup.spec(mocha).js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Signup View', function() {

after(function() {
<% if (filters.mongooseModels) { %>return UserModel.removeAsync();<% }
if (filters.sequelizeModels) { %>return UserModel.destroy();<% } %>
if (filters.sequelizeModels) { %>return UserModel.destroy({where: {}});<% } %>
});

it('should include signup form with correct inputs and submit button', function() {
Expand All @@ -42,7 +42,7 @@ describe('Signup View', function() {

it('should signup a new user, log them in, and redirecting to "/"', function(done) {
<% if (filters.mongooseModels) { %>UserModel.remove(function() {<% }
if (filters.sequelizeModels) { %>UserModel.destroy().then(function() {<% } %>
if (filters.sequelizeModels) { %>UserModel.destroy({where: {}}).then(function() {<% } %>
page.signup(testUser);

var navbar = require('../../components/navbar/navbar.po');
Expand Down
2 changes: 1 addition & 1 deletion app/templates/server/api/thing/thing.controller(models).js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function removeEntity(res) {
return function(entity) {
if (entity) {
<% if (filters.mongooseModels) { %>return entity.removeAsync()<% }
if (filters.sequelizeModels) { %>return entity.destroy()<% } %>
if (filters.sequelizeModels) { %>return entity.destroy({where: {}})<% } %>
.then(function() {
return res.send(204);
});
Expand Down
4 changes: 2 additions & 2 deletions app/templates/server/api/user(auth)/user.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('User API:', function() {
// Clear users before testing
before(function(done) {
<% if (filters.mongooseModels) { %>User.remove(function() {<% }
if (filters.sequelizeModels) { %>User.destroy().then(function() {<% } %>
if (filters.sequelizeModels) { %>User.destroy({where: {}}).then(function() {<% } %>
<% if (filters.mongooseModels) { %>user = new User({<% }
if (filters.sequelizeModels) { %>user = User.build({<% } %>
name: 'Fake User',
Expand All @@ -36,7 +36,7 @@ describe('User API:', function() {
// Clear users after testing
after(function() {
<% if (filters.mongooseModels) { %>return User.remove().exec();<% }
if (filters.sequelizeModels) { %>return User.destroy();<% } %>
if (filters.sequelizeModels) { %>return User.destroy({where: {}});<% } %>
});

describe('GET /api/users/me', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ describe('User Model', function() {
before(function() {
// Sync and clear users before testing
User.sync().then(function() {
return User.destroy();
return User.destroy({where: {}});
});
});

afterEach(function() {
return User.destroy();
return User.destroy({where: {}});
});

it('should begin with no users', function() {
Expand Down
4 changes: 2 additions & 2 deletions app/templates/server/config/seed(models).js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var Thing = sqldb.Thing;
<% if (filters.mongooseModels) { %>Thing.find({}).removeAsync()<% }
if (filters.sequelizeModels) { %>Thing.sync()
.then(function() {
return Thing.destroy();
return Thing.destroy({where: {}});
})<% } %>
.then(function() {
<% if (filters.mongooseModels) { %>Thing.create({<% }
Expand Down Expand Up @@ -53,7 +53,7 @@ var Thing = sqldb.Thing;
<% if (filters.mongooseModels) { %>User.find({}).removeAsync()<% }
if (filters.sequelizeModels) { %>User.sync()
.then(function() {
User.destroy();
User.destroy({where: {}});
})<% } %>
.then(function() {
<% if (filters.mongooseModels) { %>User.createAsync({<% }
Expand Down