Skip to content

Bugfix add validation to stop_date field in project#277

Merged
kbeker merged 1 commit intomasterfrom
bugfix-add-project-stop-date-validation
Jun 6, 2019
Merged

Bugfix add validation to stop_date field in project#277
kbeker merged 1 commit intomasterfrom
bugfix-add-project-stop-date-validation

Conversation

@Szymiks
Copy link
Contributor

@Szymiks Szymiks commented Jun 4, 2019

Resolves: #241

I think that removed test is useless because in opinion it is already tested by django, but you guys could say more about it :) Thanks!

@Szymiks Szymiks added the bug Something isn't working label Jun 4, 2019
@Szymiks Szymiks added this to the next_release milestone Jun 4, 2019
@Szymiks Szymiks self-assigned this Jun 4, 2019
def clean(self) -> None:
super().clean()
if self.stop_date is not None:
if self.start_date > self.stop_date:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be one-line condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

project.members.add(self.member)
self.assertTrue(project.members.all().filter(email=self.member.email).exists())

def test_project_model_end_date_could_not_be_before_start_day(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could_not_be => should_not_be

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol what I wrote.. 🗡️ Done

with self.assertRaises(ValidationError):
project.full_clean()
project.save()
self.assertTrue(not Project.objects.all().exists())
Copy link
Contributor

@rwrzesien rwrzesien Jun 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use self.assertFalse().

You should also check the response message, if you have caught ValidationError from the right reasons

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@rwrzesien rwrzesien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general, but some improvements can be applied.

@kbeker kbeker force-pushed the bugfix-add-project-stop-date-validation branch from 3a1c442 to 753f679 Compare June 6, 2019 10:13
@kbeker kbeker merged commit 753f679 into master Jun 6, 2019
@kbeker kbeker deleted the bugfix-add-project-stop-date-validation branch June 6, 2019 10:22
@kbeker kbeker changed the title Bugfix - Add validation to stop_date field in project Bugfix add validation to stop_date field in project Jun 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project can end even before it started

4 participants