US #55: Custom fields - Fix a bug with the 🐯s

remotes/origin/enhancement/email-actions
David Barragán Merino 2015-02-20 13:55:20 +01:00
parent 61c973057a
commit 47a4c5e0e7
4 changed files with 24 additions and 13 deletions

View File

@ -59,7 +59,7 @@ class Migration(migrations.Migration):
migrations.RunSQL( migrations.RunSQL(
""" """
CREATE TRIGGER "update_userstorycustomvalues_after_remove_userstorycustomattribute" CREATE TRIGGER "update_userstorycustomvalues_after_remove_userstorycustomattribute"
BEFORE DELETE ON custom_attributes_userstorycustomattribute AFTER DELETE ON custom_attributes_userstorycustomattribute
FOR EACH ROW FOR EACH ROW
EXECUTE PROCEDURE clean_key_in_custom_attributes_values('custom_attributes_userstorycustomattributesvalues'); EXECUTE PROCEDURE clean_key_in_custom_attributes_values('custom_attributes_userstorycustomattributesvalues');
""", """,
@ -72,7 +72,7 @@ class Migration(migrations.Migration):
migrations.RunSQL( migrations.RunSQL(
""" """
CREATE TRIGGER "update_taskcustomvalues_after_remove_taskcustomattribute" CREATE TRIGGER "update_taskcustomvalues_after_remove_taskcustomattribute"
BEFORE DELETE ON custom_attributes_taskcustomattribute AFTER DELETE ON custom_attributes_taskcustomattribute
FOR EACH ROW FOR EACH ROW
EXECUTE PROCEDURE clean_key_in_custom_attributes_values('custom_attributes_taskcustomattributesvalues'); EXECUTE PROCEDURE clean_key_in_custom_attributes_values('custom_attributes_taskcustomattributesvalues');
""", """,
@ -85,7 +85,7 @@ class Migration(migrations.Migration):
migrations.RunSQL( migrations.RunSQL(
""" """
CREATE TRIGGER "update_issuecustomvalues_after_remove_issuecustomattribute" CREATE TRIGGER "update_issuecustomvalues_after_remove_issuecustomattribute"
BEFORE DELETE ON custom_attributes_issuecustomattribute AFTER DELETE ON custom_attributes_issuecustomattribute
FOR EACH ROW FOR EACH ROW
EXECUTE PROCEDURE clean_key_in_custom_attributes_values('custom_attributes_issuecustomattributesvalues'); EXECUTE PROCEDURE clean_key_in_custom_attributes_values('custom_attributes_issuecustomattributesvalues');
""", """,

View File

@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.db.transaction import atomic
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from taiga.base.utils import json from taiga.base.utils import json
@ -171,12 +172,11 @@ def test_issue_custom_attributes_values_delete_issue(client):
# Test tristres triggers :-P # Test tristres triggers :-P
######################################################### #########################################################
def test_trigger_update_issuecustomvalues_afeter_remove_issuecustomattribute(): def test_trigger_update_issuecustomvalues_afeter_remove_issuecustomattribute(client):
issue = f.IssueFactory() issue = f.IssueFactory()
member = f.MembershipFactory(user=issue.project.owner, member = f.MembershipFactory(user=issue.project.owner,
project=issue.project, project=issue.project,
is_owner=True) is_owner=True)
custom_attr_1 = f.IssueCustomAttributeFactory(project=issue.project) custom_attr_1 = f.IssueCustomAttributeFactory(project=issue.project)
ct1_id = "{}".format(custom_attr_1.id) ct1_id = "{}".format(custom_attr_1.id)
custom_attr_2 = f.IssueCustomAttributeFactory(project=issue.project) custom_attr_2 = f.IssueCustomAttributeFactory(project=issue.project)
@ -189,8 +189,12 @@ def test_trigger_update_issuecustomvalues_afeter_remove_issuecustomattribute():
assert ct1_id in custom_attrs_val.attributes_values.keys() assert ct1_id in custom_attrs_val.attributes_values.keys()
assert ct2_id in custom_attrs_val.attributes_values.keys() assert ct2_id in custom_attrs_val.attributes_values.keys()
custom_attr_2.delete() url = reverse("issue-custom-attributes-detail", kwargs={"pk": custom_attr_2.pk})
custom_attrs_val = custom_attrs_val.__class__.objects.get(id=custom_attrs_val.id) client.login(member.user)
response = client.json.delete(url)
assert response.status_code == 204
custom_attrs_val = custom_attrs_val.__class__.objects.get(id=custom_attrs_val.id)
assert not custom_attr_2.__class__.objects.filter(pk=custom_attr_2.pk).exists()
assert ct1_id in custom_attrs_val.attributes_values.keys() assert ct1_id in custom_attrs_val.attributes_values.keys()
assert ct2_id not in custom_attrs_val.attributes_values.keys() assert ct2_id not in custom_attrs_val.attributes_values.keys()

View File

@ -172,7 +172,7 @@ def test_task_custom_attributes_values_delete_task(client):
# Test tristres triggers :-P # Test tristres triggers :-P
######################################################### #########################################################
def test_trigger_update_taskcustomvalues_afeter_remove_taskcustomattribute(): def test_trigger_update_taskcustomvalues_afeter_remove_taskcustomattribute(client):
task = f.TaskFactory() task = f.TaskFactory()
member = f.MembershipFactory(user=task.project.owner, member = f.MembershipFactory(user=task.project.owner,
project=task.project, project=task.project,
@ -191,8 +191,12 @@ def test_trigger_update_taskcustomvalues_afeter_remove_taskcustomattribute():
assert ct1_id in custom_attrs_val.attributes_values.keys() assert ct1_id in custom_attrs_val.attributes_values.keys()
assert ct2_id in custom_attrs_val.attributes_values.keys() assert ct2_id in custom_attrs_val.attributes_values.keys()
custom_attr_2.delete() url = reverse("task-custom-attributes-detail", kwargs={"pk": custom_attr_2.pk})
custom_attrs_val = custom_attrs_val.__class__.objects.get(id=custom_attrs_val.id) client.login(member.user)
response = client.json.delete(url)
assert response.status_code == 204
custom_attrs_val = custom_attrs_val.__class__.objects.get(id=custom_attrs_val.id)
assert not custom_attr_2.__class__.objects.filter(pk=custom_attr_2.pk).exists()
assert ct1_id in custom_attrs_val.attributes_values.keys() assert ct1_id in custom_attrs_val.attributes_values.keys()
assert ct2_id not in custom_attrs_val.attributes_values.keys() assert ct2_id not in custom_attrs_val.attributes_values.keys()

View File

@ -150,7 +150,7 @@ def test_userstory_custom_attributes_values_update_with_error_invalid_key(client
# Test tristres triggers :-P # Test tristres triggers :-P
######################################################### #########################################################
def test_trigger_update_userstorycustomvalues_afeter_remove_userstorycustomattribute(): def test_trigger_update_userstorycustomvalues_afeter_remove_userstorycustomattribute(client):
user_story = f.UserStoryFactory() user_story = f.UserStoryFactory()
member = f.MembershipFactory(user=user_story.project.owner, member = f.MembershipFactory(user=user_story.project.owner,
project=user_story.project, project=user_story.project,
@ -169,8 +169,11 @@ def test_trigger_update_userstorycustomvalues_afeter_remove_userstorycustomattri
assert ct1_id in custom_attrs_val.attributes_values.keys() assert ct1_id in custom_attrs_val.attributes_values.keys()
assert ct2_id in custom_attrs_val.attributes_values.keys() assert ct2_id in custom_attrs_val.attributes_values.keys()
custom_attr_2.delete() url = reverse("userstory-custom-attributes-detail", kwargs={"pk": custom_attr_2.pk})
custom_attrs_val = custom_attrs_val.__class__.objects.get(id=custom_attrs_val.id) client.login(member.user)
response = client.json.delete(url)
assert response.status_code == 204
custom_attrs_val = custom_attrs_val.__class__.objects.get(id=custom_attrs_val.id)
assert ct1_id in custom_attrs_val.attributes_values.keys() assert ct1_id in custom_attrs_val.attributes_values.keys()
assert ct2_id not in custom_attrs_val.attributes_values.keys() assert ct2_id not in custom_attrs_val.attributes_values.keys()