Skip to content

Commit

Permalink
entries: fixed edit override issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phiros committed May 6, 2019
1 parent f57240a commit 95bc645
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 46 deletions.
16 changes: 2 additions & 14 deletions cmd/entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,7 @@ var entriesEditCommand = &cobra.Command{
return err
}

entry, err := application.MiteApi.TimeEntry(entryId)
if err != nil {
return err
}

// use retrieved values as defaults
command := domain.TimeEntryCommand{
Date: &entry.Date,
Minutes: &entry.Minutes,
Note: entry.Note,
ProjectId: entry.ProjectId,
ServiceId: entry.ServiceId,
}
command := domain.TimeEntryCommand{}

// override only fields affected by set parameters of edit
if editDate != "" {
Expand Down Expand Up @@ -257,7 +245,7 @@ var entriesEditCommand = &cobra.Command{
return err
}

entry, err = application.MiteApi.TimeEntry(entryId)
entry, err := application.MiteApi.TimeEntry(entryId)
if err != nil {
return err
}
Expand Down
35 changes: 3 additions & 32 deletions tests/features/entries.feature
Original file line number Diff line number Diff line change
Expand Up @@ -82,41 +82,12 @@ Feature: entries
52324 foo 2015-09-12 3h5m Mite Dokumentation
"""
Scenario: edit entries
Given A local mock server is setup for the http method "GET" and path "/time_entries/52324.json" which expects a body of:
"""
"""
And The mock server returns the following if the expectation is met:
Given A local mock server is setup for the http method "PATCH" and path "/time_entries/52324.json" which expects a body of:
"""
{
"time_entry": {
"id": 52324,
"minutes": 185,
"date_at": "2015-09-12",
"note": "foo",
"billable": true,
"locked": false,
"revenue": null,
"hourly_rate": 0,
"user_id": 211,
"user_name": "Fridolin Frei",
"project_id": 123,
"project_name": "Mite",
"service_id": 243,
"service_name": "Dokumentation",
"created_at": "2015-09-13T18:54:45+02:00",
"updated_at": "2015-09-13T18:54:45+02:00"
}
}
"""
And A local mock server is setup for the http method "PATCH" and path "/time_entries/52324.json" which expects a body of:
"""
{
"time_entry": {
"date_at": "2015-09-12",
"minutes": 200,
"note": "bar",
"service_id": 243,
"project_id": 123
"note": "bar"
}
}
"""
Expand Down Expand Up @@ -150,7 +121,7 @@ Feature: entries
}
"""
And Mite is setup to connect to this mock server
Then "-c .mite.toml entries edit -i 52324 -D 2015-09-12 -d 200m -p 123 -s 243 -n bar" should return the following:
Then "-c .mite.toml entries edit -i 52324 -d 200m -n bar" should return the following:
"""
id notes date time project service
-- ----- ---- ---- ------- -------
Expand Down

0 comments on commit 95bc645

Please sign in to comment.