Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-2
Этот коммит содержится в:
@@ -154,15 +154,13 @@ func convertChannelToPrivate(c *Context, w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
if !c.App.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
|
||||
c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM)
|
||||
return
|
||||
}
|
||||
|
||||
oldPublicChannel, err := c.App.GetChannel(c.Params.ChannelId)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
} else if !c.App.SessionHasPermissionToTeam(c.Session, oldPublicChannel.TeamId, model.PERMISSION_MANAGE_TEAM) {
|
||||
c.SetPermissionError(model.PERMISSION_MANAGE_TEAM)
|
||||
return
|
||||
} else if oldPublicChannel.Type == model.CHANNEL_PRIVATE {
|
||||
c.Err = model.NewAppError("convertChannelToPrivate", "api.channel.convert_channel_to_private.private_channel_error", nil, "", http.StatusBadRequest)
|
||||
return
|
||||
|
||||
@@ -915,10 +915,13 @@ func TestConvertChannelToPrivate(t *testing.T) {
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.LoginTeamAdmin()
|
||||
_, resp = Client.ConvertChannelToPrivate(publicChannel.Id)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
rchannel, resp := Client.ConvertChannelToPrivate(publicChannel.Id)
|
||||
CheckOKStatus(t, resp)
|
||||
if rchannel.Type != model.CHANNEL_PRIVATE {
|
||||
t.Fatal("channel should be converted from public to private")
|
||||
}
|
||||
|
||||
rchannel, resp := th.SystemAdminClient.ConvertChannelToPrivate(privateChannel.Id)
|
||||
rchannel, resp = th.SystemAdminClient.ConvertChannelToPrivate(privateChannel.Id)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
if rchannel != nil {
|
||||
t.Fatal("should not return a channel")
|
||||
@@ -930,7 +933,8 @@ func TestConvertChannelToPrivate(t *testing.T) {
|
||||
t.Fatal("should not return a channel")
|
||||
}
|
||||
|
||||
rchannel, resp = th.SystemAdminClient.ConvertChannelToPrivate(publicChannel.Id)
|
||||
publicChannel2 := th.CreatePublicChannel()
|
||||
rchannel, resp = th.SystemAdminClient.ConvertChannelToPrivate(publicChannel2.Id)
|
||||
CheckOKStatus(t, resp)
|
||||
if rchannel.Type != model.CHANNEL_PRIVATE {
|
||||
t.Fatal("channel should be converted from public to private")
|
||||
|
||||
@@ -512,15 +512,18 @@ func TestGetAnalyticsOld(t *testing.T) {
|
||||
CheckNoError(t, resp)
|
||||
|
||||
found := false
|
||||
found2 := false
|
||||
for _, row := range rows {
|
||||
if row.Name == "unique_user_count" {
|
||||
found = true
|
||||
} else if row.Name == "inactive_user_count" {
|
||||
found2 = true
|
||||
assert.True(t, row.Value >= 0)
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
t.Fatal("should return unique user count")
|
||||
}
|
||||
assert.True(t, found, "should return unique user count")
|
||||
assert.True(t, found2, "should return inactive user count")
|
||||
|
||||
_, resp = th.SystemAdminClient.GetAnalyticsOld("post_counts_day", "")
|
||||
CheckNoError(t, resp)
|
||||
@@ -531,9 +534,15 @@ func TestGetAnalyticsOld(t *testing.T) {
|
||||
_, resp = th.SystemAdminClient.GetAnalyticsOld("extra_counts", "")
|
||||
CheckNoError(t, resp)
|
||||
|
||||
_, resp = th.SystemAdminClient.GetAnalyticsOld("", th.BasicTeam.Id)
|
||||
rows, resp = th.SystemAdminClient.GetAnalyticsOld("", th.BasicTeam.Id)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
for _, row := range rows {
|
||||
if row.Name == "inactive_user_count" {
|
||||
assert.Equal(t, float64(-1), row.Value, "inactive user count should be -1 when team specified")
|
||||
}
|
||||
}
|
||||
|
||||
rows2, resp2 := th.SystemAdminClient.GetAnalyticsOld("standard", "")
|
||||
CheckNoError(t, resp2)
|
||||
assert.Equal(t, "total_websocket_connections", rows2[5].Name)
|
||||
|
||||
Ссылка в новой задаче
Block a user