Fixing update_roles when project point ? exists but is not null
parent
edea9ff28b
commit
3d96ce81bb
|
@ -224,16 +224,17 @@ class Project(ProjectDefaults, TaggedMixin, models.Model):
|
||||||
user_stories = self.user_stories.all()
|
user_stories = self.user_stories.all()
|
||||||
|
|
||||||
# Get point instance that represent a null/undefined
|
# Get point instance that represent a null/undefined
|
||||||
# The current model allows dulplicate values. Because
|
# The current model allows duplicate values. Because
|
||||||
# of it, we should get all poins with None as value
|
# of it, we should get all poins with None as value
|
||||||
# and use the first one.
|
# and use the first one.
|
||||||
# In case of that not exists, creates one for avoid
|
# In case of that not exists, creates one for avoid
|
||||||
# unxpected errors.
|
# unexpected errors.
|
||||||
none_points = list(self.points.filter(value=None))
|
none_points = list(self.points.filter(value=None))
|
||||||
if none_points:
|
if none_points:
|
||||||
null_points_value = none_points[0]
|
null_points_value = none_points[0]
|
||||||
else:
|
else:
|
||||||
null_points_value = Points.objects.create(name="?", value=None, project=self)
|
name = slugify_uniquely_for_queryset("?", self.points.all(), slugfield="name")
|
||||||
|
null_points_value = Points.objects.create(name=name, value=None, project=self)
|
||||||
|
|
||||||
for us in user_stories:
|
for us in user_stories:
|
||||||
usroles = Role.objects.filter(role_points__in=us.role_points.all()).distinct()
|
usroles = Role.objects.filter(role_points__in=us.role_points.all()).distinct()
|
||||||
|
|
|
@ -84,7 +84,6 @@ def test_issue_status_slug_generation(client):
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert response.data["slug"] == "new-status"
|
assert response.data["slug"] == "new-status"
|
||||||
|
|
||||||
|
|
||||||
def test_points_name_duplicated(client):
|
def test_points_name_duplicated(client):
|
||||||
point_1 = f.PointsFactory()
|
point_1 = f.PointsFactory()
|
||||||
point_2 = f.PointsFactory(project=point_1.project)
|
point_2 = f.PointsFactory(project=point_1.project)
|
||||||
|
@ -96,3 +95,10 @@ def test_points_name_duplicated(client):
|
||||||
response = client.json.patch(url, json.dumps(data))
|
response = client.json.patch(url, json.dumps(data))
|
||||||
assert response.status_code == 400
|
assert response.status_code == 400
|
||||||
assert response.data["name"][0] == "Name duplicated for the project"
|
assert response.data["name"][0] == "Name duplicated for the project"
|
||||||
|
|
||||||
|
def test_update_points_when_not_null_values_for_points(client):
|
||||||
|
points = f.PointsFactory(name="?", value="6")
|
||||||
|
role = f.RoleFactory(project=points.project, computable=True)
|
||||||
|
assert points.project.points.filter(value__isnull=True).count() == 0
|
||||||
|
points.project.update_role_points()
|
||||||
|
assert points.project.points.filter(value__isnull=True).count() == 1
|
||||||
|
|
Loading…
Reference in New Issue