Skip to content

Commit

Permalink
test 6 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vayras committed May 24, 2024
1 parent 1d29bec commit fe8cf59
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cypress/support/objects/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export const Bounties = [
title: 'Phase 1 Bounty 1',
ticket_url: 'http://ticket.url',
workspace_uuid: 'workspace-uuid-123',
phase_uuid: Phases[0].uuid,
phase_uuid: Phases[1].uuid,
phase_priority: 0,
description: 'Detailed bug description',
wanted_type: 'Bugfix',
Expand Down Expand Up @@ -187,7 +187,7 @@ export const Bounties = [
assignee: '',
ticket_url: '',
workspace_uuid: Workspaces[0].uuid,
phase_uuid: Phases[0].uuid,
phase_uuid: Phases[2].uuid,
phase_priority: 1,
description: 'detailed bounty description',
wanted_type: 'Web development',
Expand Down Expand Up @@ -215,7 +215,7 @@ export const Bounties = [
assignee: '',
ticket_url: '',
workspace_uuid: Workspaces[0].uuid,
phase_uuid: Phases[0].uuid,
phase_uuid: Phases[1].uuid,
phase_priority: 2,
description: 'detailed bounty description',
wanted_type: 'Web development',
Expand Down Expand Up @@ -243,7 +243,7 @@ export const Bounties = [
assignee: '',
ticket_url: '',
workspace_uuid: Workspaces[0].uuid,
phase_uuid: Phases[0].uuid,
phase_uuid: Phases[1].uuid,
phase_priority: 3,
description: 'detailed bounty description',
wanted_type: 'Web development',
Expand Down Expand Up @@ -271,7 +271,7 @@ export const Bounties = [
assignee: '',
ticket_url: '',
workspace_uuid: Workspaces[0].uuid,
phase_uuid: Phases[0].uuid,
phase_uuid: Phases[2].uuid,
phase_priority: 4,
description: 'detailed bounty description',
wanted_type: 'Web development',
Expand Down
6 changes: 6 additions & 0 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -1727,3 +1727,9 @@ func (db database) DeleteUserInvoiceData(payment_request string) UserInvoiceData
db.db.Where("payment_request = ?", payment_request).Delete(&ms)
return ms
}

func (db database) CheckPhaseIDExist(uuid string) bool {
var count int64
db.db.Model(&FeaturePhase{}).Where("uuid = ?", uuid).Count(&count)
return count > 0
}
1 change: 1 addition & 0 deletions db/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,5 @@ type Database interface {
DeleteFeatureStoryByUuid(featureUuid, storyUuid string) error
DeleteFeatureByUuid(uuid string) error
GetBountyByFeatureAndPhaseUuid(featureUuid string, phaseUuid string) (Bounty, error)
CheckPhaseIDExist(uuid string) bool
}
6 changes: 6 additions & 0 deletions handlers/bounty.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ func (h *bountyHandler) CreateOrEditBounty(w http.ResponseWriter, r *http.Reques
return
}

if !h.db.CheckPhaseIDExist(*bounty.PhaseUuid) {
w.WriteHeader(http.StatusBadRequest)
json.NewEncoder(w).Encode("phase Id does not exist")
return
}

if bounty.Title == "" {
w.WriteHeader(http.StatusBadRequest)
json.NewEncoder(w).Encode("Title is a required field")
Expand Down
46 changes: 46 additions & 0 deletions mocks/Database.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fe8cf59

Please sign in to comment.