[FIX] Mixed case channel slugs (#9449)

pull/11536/head
Luca Zimmermann 7 years ago committed by Diego Sampaio
parent 4802ed112d
commit d876e1c911
  1. 3
      packages/rocketchat-lib/lib/getValidRoomName.js
  2. 14
      tests/end-to-end/api/02-channels.js
  3. 4
      tests/end-to-end/api/03-groups.js

@ -1,7 +1,7 @@
import s from 'underscore.string';
RocketChat.getValidRoomName = function getValidRoomName(displayName, rid = '') {
let slugifiedName = displayName;
let slugifiedName = s.slugify(displayName);
if (RocketChat.settings.get('UI_Allow_room_names_with_special_chars')) {
const room = RocketChat.models.Rooms.findOneByDisplayName(displayName);
@ -12,7 +12,6 @@ RocketChat.getValidRoomName = function getValidRoomName(displayName, rid = '') {
throw new Meteor.Error('error-duplicate-channel-name', `A channel with name '${ displayName }' exists`, { function: 'RocketChat.getValidRoomName', channel_name: displayName });
}
}
slugifiedName = s.slugify(displayName);
}
let nameValidation;

@ -437,14 +437,14 @@ describe('[Channels]', function() {
.set(credentials)
.send({
roomId: channel._id,
name: `EDITED${ apiPublicChannelName }`
name: `edited${ apiPublicChannelName }`
})
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.nested.property('channel._id');
expect(res.body).to.have.nested.property('channel.name', `EDITED${ apiPublicChannelName }`);
expect(res.body).to.have.nested.property('channel.name', `edited${ apiPublicChannelName }`);
expect(res.body).to.have.nested.property('channel.t', 'c');
expect(res.body).to.have.nested.property('channel.msgs', roomInfo.channel.msgs + 1);
})
@ -478,7 +478,7 @@ describe('[Channels]', function() {
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.nested.property('channel._id');
expect(res.body).to.have.nested.property('channel.name', `EDITED${ apiPublicChannelName }`);
expect(res.body).to.have.nested.property('channel.name', `edited${ apiPublicChannelName }`);
expect(res.body).to.have.nested.property('channel.t', 'c');
})
.end(done);
@ -681,7 +681,7 @@ describe('[Channels]', function() {
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.nested.property('channel._id');
expect(res.body).to.have.nested.property('channel.name', `EDITED${ apiPublicChannelName }`);
expect(res.body).to.have.nested.property('channel.name', `edited${ apiPublicChannelName }`);
expect(res.body).to.have.nested.property('channel.t', 'c');
expect(res.body).to.have.nested.property('channel.msgs', roomInfo.channel.msgs);
})
@ -702,7 +702,7 @@ describe('[Channels]', function() {
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.nested.property('channel._id');
expect(res.body).to.have.nested.property('channel.name', `EDITED${ apiPublicChannelName }`);
expect(res.body).to.have.nested.property('channel.name', `edited${ apiPublicChannelName }`);
expect(res.body).to.have.nested.property('channel.t', 'c');
expect(res.body).to.have.nested.property('channel.msgs', roomInfo.channel.msgs);
})
@ -743,7 +743,7 @@ describe('[Channels]', function() {
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.nested.property('channel._id');
expect(res.body).to.have.nested.property('channel.name', `EDITED${ apiPublicChannelName }`);
expect(res.body).to.have.nested.property('channel.name', `edited${ apiPublicChannelName }`);
expect(res.body).to.have.nested.property('channel.t', 'c');
expect(res.body).to.have.nested.property('channel.msgs', roomInfo.channel.msgs + 1);
})
@ -764,7 +764,7 @@ describe('[Channels]', function() {
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.nested.property('channel._id');
expect(res.body).to.have.nested.property('channel.name', `EDITED${ apiPublicChannelName }`);
expect(res.body).to.have.nested.property('channel.name', `edited${ apiPublicChannelName }`);
expect(res.body).to.have.nested.property('channel.t', 'p');
expect(res.body).to.have.nested.property('channel.msgs', roomInfo.channel.msgs + 1);
})

@ -371,14 +371,14 @@ describe('[Groups]', function() {
.set(credentials)
.send({
roomId: group._id,
name: `EDITED${ apiPrivateChannelName }`
name: `edited${ apiPrivateChannelName }`
})
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.nested.property('group._id');
expect(res.body).to.have.nested.property('group.name', `EDITED${ apiPrivateChannelName }`);
expect(res.body).to.have.nested.property('group.name', `edited${ apiPrivateChannelName }`);
expect(res.body).to.have.nested.property('group.t', 'p');
expect(res.body).to.have.nested.property('group.msgs', roomInfo.group.msgs + 1);
})

Loading…
Cancel
Save