Skip to content

Commit 35cc99c

Browse files
committed
Fix test
1 parent 632daec commit 35cc99c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

models/issue_stopwatch.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,23 @@ func CreateIssueStopwatch(ctx context.Context, user *User, issue *Issue) error {
181181
}
182182

183183
// if another stopwatch is running: stop it
184-
exists, _, err := hasUserStopwatch(e, user.ID)
184+
exists, sw, err := hasUserStopwatch(e, user.ID)
185185
if err != nil {
186186
return err
187187
}
188188
if exists {
189-
return ErrIssueStopwatchAlreadyExist{
190-
UserID: user.ID,
191-
IssueID: issue.ID,
189+
issue, err := getIssueByID(e, sw.IssueID)
190+
if err != nil {
191+
return err
192+
}
193+
194+
if err := FinishIssueStopwatch(ctx, user, issue); err != nil {
195+
return err
192196
}
193197
}
194198

195199
// Create stopwatch
196-
var sw = &Stopwatch{
200+
sw = &Stopwatch{
197201
UserID: user.ID,
198202
IssueID: issue.ID,
199203
}

0 commit comments

Comments
 (0)