0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-08 02:52:39 -05:00

Check all users when generating slug

No Issue
- Set 'status: all` when calling generateSlug from the user model
  so that all user slugs are checked for duplicates instead of
  only active users.
This commit is contained in:
Jason Williams 2015-01-16 06:56:53 +00:00
parent 3982e0f871
commit aee472eb65
2 changed files with 22 additions and 1 deletions

View file

@ -61,7 +61,7 @@ User = ghostBookshelf.Model.extend({
if (this.hasChanged('slug') || !this.get('slug')) {
// Generating a slug requires a db call to look for conflicting slugs
return ghostBookshelf.Model.generateSlug(User, this.get('slug') || this.get('name'),
{transacting: options.transacting, shortSlug: !this.get('slug')})
{status: 'all', transacting: options.transacting, shortSlug: !this.get('slug')})
.then(function (slug) {
self.set({slug: slug});
});

View file

@ -492,6 +492,27 @@ describe('Users API', function () {
done();
}).catch(done);
});
it('Can add two users with the same local-part in their email addresses', function (done) {
newUser.roles = [roleIdFor.author];
UserAPI.add({users: [newUser]}, _.extend({}, context.owner, {include: 'roles'}))
.then(function (response) {
checkAddResponse(response);
response.users[0].id.should.eql(8);
response.users[0].roles[0].name.should.equal('Author');
}).then(function () {
newUser.email = newUser.email.split('@')[0] + '@someotherdomain.com';
return UserAPI.add({users: [newUser]}, _.extend({}, context.owner, {include: 'roles'}))
.then(function (response) {
checkAddResponse(response);
response.users[0].id.should.eql(9);
response.users[0].roles[0].name.should.equal('Author');
done();
});
}).catch(done);
});
});
describe('Editor', function () {