0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Merge pull request #4808 from jaswilli/invite-error

Check all users when generating slug
This commit is contained in:
Sebastian Gierlinger 2015-01-16 11:52:44 +01:00
commit 8d43a7484a
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 () {