Verified Commit f2e3e04e authored by Anton Kuligin's avatar Anton Kuligin Committed by GitLab
Browse files

feat: add automatic_rebase_enabled to project structs

Changelog: Improvements
parent 3262069c
Loading
Loading
Loading
Loading
+2 −0
Changes for projects.go: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -475,6 +475,7 @@ type Project struct {
	AutocloseReferencedIssues                 bool                                        `json:"autoclose_referenced_issues"`
	SuggestionCommitMessage                   string                                      `json:"suggestion_commit_message"`
	SquashOption                              SquashOptionValue                           `json:"squash_option"`
	AutomaticRebaseEnabled                    bool                                        `json:"automatic_rebase_enabled"`
	EnforceAuthChecksOnUploads                bool                                        `json:"enforce_auth_checks_on_uploads,omitempty"`
	SharedWithGroups                          []ProjectSharedWithGroup                    `json:"shared_with_groups"`
	Statistics                                *Statistics                                 `json:"statistics"`
@@ -1104,6 +1105,7 @@ type EditProjectOptions struct {
	AutoDevopsEnabled                         *bool                                        `url:"auto_devops_enabled,omitempty" json:"auto_devops_enabled,omitempty"`
	AutoDuoCodeReviewEnabled                  *bool                                        `url:"auto_duo_code_review_enabled,omitempty" json:"auto_duo_code_review_enabled,omitempty"`
	AutocloseReferencedIssues                 *bool                                        `url:"autoclose_referenced_issues,omitempty" json:"autoclose_referenced_issues,omitempty"`
	AutomaticRebaseEnabled                    *bool                                        `url:"automatic_rebase_enabled,omitempty" json:"automatic_rebase_enabled,omitempty"`
	Avatar                                    *ProjectAvatar                               `url:"-" json:"avatar,omitempty"`
	BuildCoverageRegex                        *string                                      `url:"build_coverage_regex,omitempty" json:"build_coverage_regex,omitempty"`
	BuildGitStrategy                          *string                                      `url:"build_git_strategy,omitempty" json:"build_git_strategy,omitempty"`
+42 −0
Changes for projects_test.go: 42 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -65,6 +65,22 @@ func TestListProjects(t *testing.T) {
			`[{"id":1, "protect_merge_request_pipelines": false},{"id":2}]`,
			[]*Project{{ID: 1, ProtectMergeRequestPipelines: false}, {ID: 2}},
		},
		{
			// GIVEN a project response with automatic_rebase_enabled set to true
			// WHEN the response is deserialized
			// THEN the field should be true
			"with automatic_rebase_enabled true",
			`[{"id":1, "automatic_rebase_enabled": true},{"id":2}]`,
			[]*Project{{ID: 1, AutomaticRebaseEnabled: true}, {ID: 2}},
		},
		{
			// GIVEN a project response with automatic_rebase_enabled set to false
			// WHEN the response is deserialized
			// THEN the field should be false
			"with automatic_rebase_enabled false",
			`[{"id":1, "automatic_rebase_enabled": false},{"id":2}]`,
			[]*Project{{ID: 1, AutomaticRebaseEnabled: false}, {ID: 2}},
		},
	}

	for _, testCase := range testCases {
@@ -500,6 +516,32 @@ func TestEditProjectWithReviewerAssignmentStrategy(t *testing.T) {
	assert.Equal(t, CodeOwnersReviewerAssignmentStrategy, project.ReviewerAssignmentStrategy)
}

func TestEditProjectWithAutomaticRebaseEnabled(t *testing.T) {
	t.Parallel()
	mux, client := setup(t)

	opt := &EditProjectOptions{
		AutomaticRebaseEnabled: new(true),
	}

	mux.HandleFunc("/api/v4/projects/1", func(w http.ResponseWriter, r *http.Request) {
		testMethod(t, r, http.MethodPut)
		testBodyJSON(t, r, map[string]any{
			"automatic_rebase_enabled": true,
		})

		fmt.Fprint(w, `{
			"id": 1,
			"automatic_rebase_enabled": true
		}`)
	})

	project, resp, err := client.Projects.EditProject(1, opt)
	assert.NoError(t, err)
	assert.Equal(t, http.StatusOK, resp.StatusCode)
	assert.True(t, project.AutomaticRebaseEnabled)
}

func TestListStarredProjects(t *testing.T) {
	t.Parallel()
	mux, client := setup(t)