Skip to content

Commit

Permalink
Billing status should be forced to string
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwoberts committed Sep 26, 2024
1 parent 261bcf4 commit c2ba9fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/services/userlist/userlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import (
"strconv"

"github.com/getfider/fider/app/models/cmd"
"github.com/getfider/fider/app/models/dto"
"github.com/getfider/fider/app/models/enum"
"github.com/getfider/fider/app/models/query"
"github.com/getfider/fider/app/pkg/bus"
"github.com/getfider/fider/app/pkg/env"
"github.com/getfider/fider/app/pkg/errors"
"github.com/getfider/fider/app/pkg/log"
)

// Company represents a company in UserList.com. It contains information about the company,
Expand Down Expand Up @@ -143,7 +145,7 @@ func updateUserListCompany(ctx context.Context, c *cmd.UserListUpdateCompany) er

if c.BillingStatus > 0 {
company.Properties = map[string]interface{}{
"billing_status": c.BillingStatus,
"billing_status": c.BillingStatus.String(),
}
}

Expand Down Expand Up @@ -219,6 +221,10 @@ func pushUserListUpdate(obj interface{}, ctx context.Context) error {
return errors.Wrap(err, "Failed to send userlist update")
}

log.Infof(ctx, "Userlist HTTP post complete with status @{status}. Header was @{ResponseHeader}. Body was @{ResponseBody}", dto.Props{
"status": req.ResponseStatusCode, "ResponseHeader": req.ResponseHeader, "ResponseBody": string(req.ResponseBody),
})

if req.ResponseStatusCode >= 300 {
return errors.New("unexpected status code while updating userlist: %d", req.ResponseStatusCode)
}
Expand Down
3 changes: 3 additions & 0 deletions app/services/userlist/userlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ func TestUpdateTenant_BillingStatusUpdatedIfSet(t *testing.T) {
containsBillingStatus := strings.Contains(string(body), "billing_status")
Expect(containsBillingStatus).IsTrue()

// Also check we're using the enum string, not the int value
Expect(strings.Contains(string(body), "billing_status\":\"active\"")).IsTrue()

}

func TestUpdateTenant_BillingStatusNotUpdatedIfNotSet(t *testing.T) {
Expand Down

0 comments on commit c2ba9fd

Please sign in to comment.