Skip to content

Commit

Permalink
#54: Set remainder flag for first activity
Browse files Browse the repository at this point in the history
  • Loading branch information
kaklakariada committed Dec 5, 2020
1 parent a988279 commit 5223006
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ See [Release](https://github.com/itsallcode/white-rabbit/releases/tag/v1.2.0) /
### Added

* [#52](https://github.com/itsallcode/white-rabbit/issues/52): Improve keyboard usage for autocomplete text fields, immediately show proposals.
* [#54](https://github.com/itsallcode/white-rabbit/issues/54): First added activity has the remainder flag set.

## [1.1.0] 2020-11-29

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ public Activity add()
{
day.setActivities(new ArrayList<>());
}
final boolean isFirstActivity = getActivities().findAny().isEmpty();

final JsonActivity jsonActivity = new JsonActivity();
jsonActivity.setProjectId("");
jsonActivity.setDuration(Duration.ZERO);
final int newRowIndex = day.getActivities().size();
day.getActivities().add(jsonActivity);

return wrapActivity(jsonActivity, newRowIndex);
final Activity wrappedActivity = wrapActivity(jsonActivity, newRowIndex);
wrappedActivity.setRemainderActivity(isFirstActivity);
return wrappedActivity;
}

public List<Activity> getAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,29 @@ void addWhenActivitiesAreNull()
assertThat(jsonDay.getActivities()).hasSize(1);
}

@Test
void firstAddedActivityHasRemainderFlag()
{
final DayActivities activities = create();
jsonDay.setActivities(new ArrayList<>());

final Activity newActivity = activities.add();

assertThat(newActivity.isRemainderActivity()).as("remainder").isTrue();
}

@Test
void secondAddedActivityDoesNotHaveRemainderFlag()
{
final DayActivities activities = create();
jsonDay.setActivities(new ArrayList<>());

activities.add();
final Activity newActivity = activities.add();

assertThat(newActivity.isRemainderActivity()).as("remainder").isFalse();
}

@Test
void addIncrementsRowIndex()
{
Expand Down

0 comments on commit 5223006

Please sign in to comment.