Skip to content

Commit

Permalink
Merge pull request #119 from Brightscout/MI-2405
Browse files Browse the repository at this point in the history
[MI-2405] Fix bug: Store small case string for organization name and …
  • Loading branch information
raghavaggarwal2308 authored Nov 30, 2022
2 parents ebf7556 + 7e07ef9 commit 95880af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions server/plugin/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

"github.com/gorilla/mux"
"github.com/mattermost/mattermost-server/v5/model"
"golang.org/x/text/cases"
"golang.org/x/text/language"

"github.com/Brightscout/mattermost-plugin-azure-devops/server/constants"
"github.com/Brightscout/mattermost-plugin-azure-devops/server/serializers"
Expand Down Expand Up @@ -107,7 +109,7 @@ func (p *Plugin) handleLink(w http.ResponseWriter, r *http.Request) {
return
}

if _, isProjectLinked := p.IsProjectLinked(projectList, serializers.ProjectDetails{OrganizationName: body.Organization, ProjectName: body.Project}); isProjectLinked {
if _, isProjectLinked := p.IsProjectLinked(projectList, serializers.ProjectDetails{OrganizationName: strings.ToLower(body.Organization), ProjectName: cases.Title(language.Und).String(body.Project)}); isProjectLinked {
returnStatusWithMessage(w, http.StatusOK, constants.AlreadyLinkedProject)
return
}
Expand Down Expand Up @@ -136,8 +138,8 @@ func (p *Plugin) handleLink(w http.ResponseWriter, r *http.Request) {
project := serializers.ProjectDetails{
MattermostUserID: mattermostUserID,
ProjectID: response.ID,
ProjectName: response.Name,
OrganizationName: body.Organization,
ProjectName: cases.Title(language.Und).String(body.Project),
OrganizationName: strings.ToLower(body.Organization),
IsAdmin: isAdmin,
}

Expand Down
3 changes: 2 additions & 1 deletion server/plugin/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ func TestHandleLink(t *testing.T) {
mockedStore.EXPECT().GetAllProjects("mockMattermostUserID").Return(testCase.projectList, nil)
mockedStore.EXPECT().StoreProject(&serializers.ProjectDetails{
MattermostUserID: "mockMattermostUserID",
OrganizationName: "mockOrganization",
ProjectName: "Mockproject",
OrganizationName: "mockorganization",
}).Return(nil)
}

Expand Down

0 comments on commit 95880af

Please sign in to comment.