Этот коммит содержится в:
JoramWilander
2015-06-15 09:06:55 -04:00
родитель 6982a61f69
Коммит a281e962fc
3 изменённых файлов: 60 добавлений и 48 удалений

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

@@ -61,6 +61,7 @@ func createValetPost(c *Context, w http.ResponseWriter, r *http.Request) {
if !utils.Cfg.TeamSettings.AllowValet { if !utils.Cfg.TeamSettings.AllowValet {
c.Err = model.NewAppError("createValetPost", "The valet feature is currently turned off. Please contact your system administrator for details.", "") c.Err = model.NewAppError("createValetPost", "The valet feature is currently turned off. Please contact your system administrator for details.", "")
c.Err.StatusCode = http.StatusNotImplemented c.Err.StatusCode = http.StatusNotImplemented
return
} }
post := model.PostFromJson(r.Body) post := model.PostFromJson(r.Body)

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

@@ -147,6 +147,7 @@ func TestCreateValetPost(t *testing.T) {
channel2 := &model.Channel{DisplayName: "Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id} channel2 := &model.Channel{DisplayName: "Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id}
channel2 = Client.Must(Client.CreateChannel(channel2)).Data.(*model.Channel) channel2 = Client.Must(Client.CreateChannel(channel2)).Data.(*model.Channel)
if utils.Cfg.TeamSettings.AllowValet {
post1 := &model.Post{ChannelId: channel1.Id, Message: "#hashtag a" + model.NewId() + "a"} post1 := &model.Post{ChannelId: channel1.Id, Message: "#hashtag a" + model.NewId() + "a"}
rpost1, err := Client.CreateValetPost(post1) rpost1, err := Client.CreateValetPost(post1)
if err != nil { if err != nil {
@@ -204,6 +205,14 @@ func TestCreateValetPost(t *testing.T) {
if _, err = Client.DoPost("/channels/"+channel3.Id+"/create", "garbage"); err == nil { if _, err = Client.DoPost("/channels/"+channel3.Id+"/create", "garbage"); err == nil {
t.Fatal("should have been an error") t.Fatal("should have been an error")
} }
} else {
post1 := &model.Post{ChannelId: channel1.Id, Message: "#hashtag a" + model.NewId() + "a"}
_, err := Client.CreateValetPost(post1)
if err.StatusCode != http.StatusNotImplemented {
t.Fatal(err)
t.Fatal("Should have failed with 501 - Not Implemented")
}
}
} }
func TestUpdatePost(t *testing.T) { func TestUpdatePost(t *testing.T) {

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

@@ -157,10 +157,12 @@ func createTeamFromSignup(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
if utils.Cfg.TeamSettings.AllowValet {
CreateValet(c, rteam) CreateValet(c, rteam)
if c.Err != nil { if c.Err != nil {
return return
} }
}
InviteMembers(rteam, ruser, teamSignup.Invites) InviteMembers(rteam, ruser, teamSignup.Invites)