mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-02-23 03:45:47 -05:00
When migrations are disabled via `[repository].DISABLE_MIGRATIONS = true`, on organisation pages next to the 'New repository' button, the 'New migration' button is still shown. This is caused by a logic error in the templates: instead of checking for disabled migrations, it checks for disabled pull mirrors. This patch fixes that to use `DisableMigrations` instead of `DisableNewPullMirrors`. Signed-off-by: Daniel Baumann <daniel@debian.org> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6851 Reviewed-by: Beowulf <beowulf@beocode.eu> Reviewed-by: 0ko <0ko@noreply.codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Daniel Baumann <daniel@debian.org> Co-committed-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
fad28141fa
commit
816cd117f7
2 changed files with 32 additions and 1 deletions
|
@ -23,7 +23,7 @@
|
|||
{{if .CanCreateOrgRepo}}
|
||||
<div class="center aligned">
|
||||
<a class="ui primary button tw-mb-1" href="{{AppSubUrl}}/repo/create?org={{.Org.ID}}">{{ctx.Locale.Tr "new_repo.link"}}</a>
|
||||
{{if not .DisableNewPullMirrors}}
|
||||
{{if not .DisableMigrations}}
|
||||
<a class="ui primary button tw-mb-1" href="{{AppSubUrl}}/repo/migrate?org={{.Org.ID}}&mirror=1">{{ctx.Locale.Tr "new_migrate.link"}}</a>
|
||||
{{end}}
|
||||
</div>
|
||||
|
|
|
@ -15,7 +15,9 @@ import (
|
|||
"code.gitea.io/gitea/models/unit"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -266,3 +268,32 @@ func TestOwnerTeamUnit(t *testing.T) {
|
|||
|
||||
unittest.AssertExistsAndLoadBean(t, &organization.TeamUnit{TeamID: 1, Type: unit.TypeIssues, AccessMode: perm.AccessModeOwner})
|
||||
}
|
||||
|
||||
func TestOrgNewMigrationButton(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
migrateSelector := `a[href^="/repo/migrate?org="]`
|
||||
|
||||
session := loginUser(t, "user2")
|
||||
t.Run("Migration disabled", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
defer test.MockVariableValue(&setting.Repository.DisableMigrations, true)()
|
||||
|
||||
req := NewRequest(t, "GET", "/org3")
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
htmlDoc.AssertElement(t, migrateSelector, false)
|
||||
})
|
||||
|
||||
t.Run("Migration enabled", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
defer test.MockVariableValue(&setting.Repository.DisableMigrations, false)()
|
||||
|
||||
req := NewRequest(t, "GET", "/org3")
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
htmlDoc.AssertElement(t, migrateSelector, true)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue