Skip to content

Commit 3ee5d15

Browse files
committed
fix tests and languages
1 parent d6d0151 commit 3ee5d15

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

integrations/editor_test.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
5151
// Check if master branch has been locked successfully
5252
flashCookie := session.GetCookie("macaron_flash")
5353
assert.NotNil(t, flashCookie)
54-
assert.EqualValues(t, "success%3DBranch%2Bprotect%2Boptions%2Bchanged%2Bsuccessfully.", flashCookie.Value)
54+
assert.EqualValues(t, "success%3DBranch%2Bmaster%2Bprotect%2Boptions%2Bchanged%2Bsuccessfully.", flashCookie.Value)
5555

5656
// Request editor page
5757
req = NewRequest(t, "GET", "/user2/repo1/_new/master/")
@@ -73,6 +73,20 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
7373
resp = session.MakeRequest(t, req, http.StatusOK)
7474
// Check body for error message
7575
assert.Contains(t, string(resp.Body), "Can not commit to protected branch 'master'.")
76+
77+
// remove the protected branch
78+
csrf = GetCSRF(t, session, "/user2/repo1/settings/branches")
79+
// Change master branch to protected
80+
req = NewRequestWithValues(t, "POST", "/user2/repo1/settings/branches/master", map[string]string{
81+
"_csrf": csrf,
82+
"protected": "off",
83+
})
84+
resp = session.MakeRequest(t, req, http.StatusFound)
85+
// Check if master branch has been locked successfully
86+
flashCookie = session.GetCookie("macaron_flash")
87+
assert.NotNil(t, flashCookie)
88+
assert.EqualValues(t, "success%3DBranch%2Bmaster%2Bprotect%2Boptions%2Bremoved%2Bsuccessfully", flashCookie.Value)
89+
7690
}
7791

7892
func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePath string) *TestResponse {

integrations/integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func MakeRequest(t testing.TB, req *http.Request, expectedStatus int) *TestRespo
269269
mac.ServeHTTP(respWriter, req)
270270
if expectedStatus != NoExpectedStatus {
271271
assert.EqualValues(t, expectedStatus, respWriter.HeaderCode,
272-
"Request URL: %s", req.URL.String())
272+
"Request URL: %s %s", req.URL.String(), buffer.String())
273273
}
274274
return &TestResponse{
275275
HeaderCode: respWriter.HeaderCode,

options/locale/locale_en-US.ini

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,6 @@ settings.protected_branch_can_push_no=You can not push
948948
settings.branch_protection = Branch Protection for <b>%s</b>
949949
settings.protect_this_branch = Protect this branch
950950
settings.protect_this_branch_desc = Disable force pushes and prevent deletion.
951-
settings.update_protect_branch_success = Branch protect options changed successfully.
952951
settings.protect_whitelist_committers = Whitelist who can push to this branch
953952
settings.protect_whitelist_committers_desc = Add users or teams to this branch's whitelist. Whitelisted users bypass the typical push restrictions.
954953
settings.protect_whitelist_users = Users who can push to this branch
@@ -957,9 +956,8 @@ settings.protect_whitelist_teams = Teams whose members can push to this branch.
957956
settings.protect_whitelist_search_teams = Search teams
958957
settings.add_protected_branch=Enable protection
959958
settings.delete_protected_branch=Disable protection
960-
settings.add_protected_branch_success=%s Locked successfully
961-
settings.add_protected_branch_failed= %s Locked failed
962-
settings.remove_protected_branch_success=%s Unlocked successfully
959+
settings.update_protect_branch_success = Branch %s protect options changed successfully.
960+
settings.remove_protected_branch_success= Branch %s protect options removed successfully
963961
settings.protected_branch_deletion=To delete a protected branch
964962
settings.protected_branch_deletion_desc=Anyone with write permissions will be able to push directly to this branch. Are you sure?
965963
settings.default_branch_desc = The default branch is considered the "base" branch in your repository against which all pull requests and code commits are automatically made, unless you specify a different branch.

routers/repo/setting_protected_branch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func SettingsProtectedBranchPost(ctx *context.Context, f auth.ProtectBranchForm)
171171
ctx.Handle(500, "UpdateProtectBranch", err)
172172
return
173173
}
174-
ctx.Flash.Success(ctx.Tr("repo.settings.update_protect_branch_success"))
174+
ctx.Flash.Success(ctx.Tr("repo.settings.update_protect_branch_success", branch))
175175
ctx.Redirect(fmt.Sprintf("%s/settings/branches/%s", ctx.Repo.RepoLink, branch))
176176
} else {
177177
if protectBranch != nil {
@@ -180,7 +180,7 @@ func SettingsProtectedBranchPost(ctx *context.Context, f auth.ProtectBranchForm)
180180
return
181181
}
182182
}
183-
ctx.Flash.Success(ctx.Tr("repo.settings.remove_protected_branch_success"))
183+
ctx.Flash.Success(ctx.Tr("repo.settings.remove_protected_branch_success", branch))
184184
ctx.Redirect(fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink))
185185
}
186186
}

0 commit comments

Comments
 (0)