PLT-7 fixing unit test for chunk 2 server

Этот коммит содержится в:
=Corey Hulen
2016-01-22 08:04:02 -06:00
родитель dd52e3f729
Коммит 518efd7d2e
3 изменённых файлов: 8 добавлений и 10 удалений

Просмотреть файл

@@ -53,7 +53,9 @@ func createPost(c *Context, w http.ResponseWriter, r *http.Request) {
if rp, err := CreatePost(c, post, true); err != nil { if rp, err := CreatePost(c, post, true); err != nil {
c.Err = err c.Err = err
if strings.Contains(c.Err.Message, "parameter") { if c.Err.Id == "api.post.create_post.root_id.app_error" ||
c.Err.Id == "api.post.create_post.channel_root_id.app_error" ||
c.Err.Id == "api.post.create_post.parent_id.app_error" {
c.Err.StatusCode = http.StatusBadRequest c.Err.StatusCode = http.StatusBadRequest
} }
@@ -75,15 +77,12 @@ func CreatePost(c *Context, post *model.Post, triggerWebhooks bool) (*model.Post
// Verify the parent/child relationships are correct // Verify the parent/child relationships are correct
if pchan != nil { if pchan != nil {
// somehow tests fail here if we use the commented lines
if presult := <-pchan; presult.Err != nil { if presult := <-pchan; presult.Err != nil {
//return nil, model.NewLocAppError("createPost", "api.post.create_post.root_id.app_error", nil, "") return nil, model.NewLocAppError("createPost", "api.post.create_post.root_id.app_error", nil, "")
return nil, model.NewAppError("createPost", "Invalid RootId parameter", "")
} else { } else {
list := presult.Data.(*model.PostList) list := presult.Data.(*model.PostList)
if len(list.Posts) == 0 || !list.IsChannelId(post.ChannelId) { if len(list.Posts) == 0 || !list.IsChannelId(post.ChannelId) {
//return nil, model.NewLocAppError("createPost", "api.post.create_post.channel_root_id.app_error", nil, "") return nil, model.NewLocAppError("createPost", "api.post.create_post.channel_root_id.app_error", nil, "")
return nil, model.NewAppError("createPost", "Invalid ChannelId for RootId parameter", "")
} }
if post.ParentId == "" { if post.ParentId == "" {
@@ -93,8 +92,7 @@ func CreatePost(c *Context, post *model.Post, triggerWebhooks bool) (*model.Post
if post.RootId != post.ParentId { if post.RootId != post.ParentId {
parent := list.Posts[post.ParentId] parent := list.Posts[post.ParentId]
if parent == nil { if parent == nil {
//return nil, model.NewLocAppError("createPost", "api.post.create_post.parent_id.app_error", nil, "") return nil, model.NewLocAppError("createPost", "api.post.create_post.parent_id.app_error", nil, "")
return nil, model.NewAppError("createPost", "Invalid ParentId parameter", "")
} }
} }
} }

Просмотреть файл

@@ -129,7 +129,7 @@ export default class CreateComment extends React.Component {
function handlePostError(err) { function handlePostError(err) {
let state = {}; let state = {};
if (err.message === 'Invalid RootId parameter') { if (err.id === 'api.post.create_post.root_id.app_error') {
PostStore.removePendingPost(post.channel_id, post.pending_post_id); PostStore.removePendingPost(post.channel_id, post.pending_post_id);
if ($('#post_deleted').length > 0) { if ($('#post_deleted').length > 0) {

Просмотреть файл

@@ -191,7 +191,7 @@ export default class CreatePost extends React.Component {
(err) => { (err) => {
const state = {}; const state = {};
if (err.message === 'Invalid RootId parameter') { if (err.id === 'api.post.create_post.root_id.app_error') {
if ($('#post_deleted').length > 0) { if ($('#post_deleted').length > 0) {
$('#post_deleted').modal('show'); $('#post_deleted').modal('show');
} }