From bfdff4699c919a293e6459732b07f4a68b881fdb Mon Sep 17 00:00:00 2001 From: mhirtie Date: Mon, 30 Mar 2015 14:13:46 +0300 Subject: [PATCH] Fix showing of parents on details pane. --- .../view_models/parent-relations-handler.js | 5 +- .../integration/mocks/work-packages/819.json | 3 +- .../mocks/work-packages/819_patch.json | 4 +- .../integration/mocks/work-packages/820.json | 1045 +++++++++++++++-- .../integration/mocks/work-packages/822.json | 5 - .../mocks/work-packages/822_form.json | 3 +- .../parent-relations-handler-spec.js | 66 ++ .../parent-relations-handler-test.js | 83 ++ 8 files changed, 1078 insertions(+), 136 deletions(-) create mode 100644 frontend/tests/integration/specs/work-packages/details-pane/relations/parent-relations-handler-spec.js create mode 100644 frontend/tests/unit/tests/work_packages/view_models/parent-relations-handler-test.js diff --git a/frontend/app/work_packages/view_models/parent-relations-handler.js b/frontend/app/work_packages/view_models/parent-relations-handler.js index be57263004..4d64b71237 100644 --- a/frontend/app/work_packages/view_models/parent-relations-handler.js +++ b/frontend/app/work_packages/view_models/parent-relations-handler.js @@ -28,7 +28,10 @@ module.exports = function(CommonRelationsHandler, WorkPackageService, ApiHelper) { function ParentRelationsHandler(workPackage, parents, relationsId) { - var handler = new CommonRelationsHandler(workPackage, parents, relationsId); + var relations = parents.filter(function(parent) { + return parent.props.id !== workPackage.props.id; + }), + handler = new CommonRelationsHandler(workPackage, relations, relationsId); handler.type = "parent"; handler.addRelation = undefined; diff --git a/frontend/tests/integration/mocks/work-packages/819.json b/frontend/tests/integration/mocks/work-packages/819.json index c453636116..04a2dacae9 100644 --- a/frontend/tests/integration/mocks/work-packages/819.json +++ b/frontend/tests/integration/mocks/work-packages/819.json @@ -96,7 +96,8 @@ "title": "Add comment" }, "parent": { - "href": null + "href": "/api/v3/work_packages/820", + "title": "asd" }, "timeEntries": { "href": "/work_packages/819/time_entries", diff --git a/frontend/tests/integration/mocks/work-packages/819_patch.json b/frontend/tests/integration/mocks/work-packages/819_patch.json index ac8c6b1a29..55e839a28e 100644 --- a/frontend/tests/integration/mocks/work-packages/819_patch.json +++ b/frontend/tests/integration/mocks/work-packages/819_patch.json @@ -82,7 +82,7 @@ "title": "Add comment" }, "parent": { - "href": "/api/v3/work_packages/54", + "href": "/api/v3/work_packages/820", "title": "asd" }, "timeEntries": { @@ -112,7 +112,7 @@ "estimatedTime": "PT0S", "spentTime": "PT0S", "percentageDone": 0, - "parentId": 54, + "parentId": 820, "createdAt": "2014-11-05T15:56:53Z", "updatedAt": "2014-11-21T08:48:57Z", "customProperties": [ diff --git a/frontend/tests/integration/mocks/work-packages/820.json b/frontend/tests/integration/mocks/work-packages/820.json index b001894007..31ea442f3d 100644 --- a/frontend/tests/integration/mocks/work-packages/820.json +++ b/frontend/tests/integration/mocks/work-packages/820.json @@ -97,159 +97,954 @@ "type": "text/html", "title": "Time entries" }, - "category": { - "href": null - }, - "priority": { - "href": "/api/v3/priorities/2", - "title": "Normal" - }, "project": { "href": "/api/v3/projects/1", "title": "Seeded Project" }, - "version": { - "href": "/api/v3/versions/2" - }, - "log_costs": { - "href": "/work_packages/820/cost_entries/new", - "type": "text/html", - "title": "Log costs on veritatis voluptas hic qui praesentium tempora illum omnis" - }, - "costObject": { - "href": null - }, - "costsByType": { - "href": "/api/v3/work_packages/820/summarized_costs_by_type" - }, - "customField8": { - "href": null + "schema": { + "href": "/api/v3/work_packages/schemas/1-7" + } + }, + "id": 820, + "lockVersion": 119, + "subject": "66666", + "type": "Feature", + "description": { + "format": "textile", + "html": "

#54
2

", + "raw": "#54\n2" + }, + "priority": "Normal", + "startDate": "2014-10-23T00:00:00+00:00", + "dueDate": "2014-12-27T00:00:00+00:00", + "estimatedTime": "PT0S", + "spentTime": "PT0S", + "percentageDone": 0, + "parentId": 54, + "createdAt": "2014-11-05T15:56:53Z", + "updatedAt": "2014-11-21T08:48:57Z", + "customProperties": [ + { + "name": "dolorum quidem", + "format": "text", + "value": null }, - "customField11": { - "href": null + { + "name": "aut mollitia", + "format": "text", + "value": null }, - "customField12": { - "href": null + { + "name": "est exercitationem", + "format": "text", + "value": null } - }, + ], "_embedded": { - "type": { - "_type": "Type", - "_links": { - "self": { - "href": "/api/v3/types/5", - "title": "Phase" - } - }, - "id": 5, - "name": "Phase", - "color": "#66CC99", - "position": 4, - "isDefault": true, - "isMilestone": false, - "createdAt": "2015-02-13T10:08:52+00:00", - "updatedAt": "2015-02-13T10:08:52+00:00" - }, "status": { - "_type": "Status", - "_links": { - "self": { - "href": "/api/v3/statuses/1", - "title": "new" - } - }, - "id": 1, - "name": "new", - "isClosed": false, - "isDefault": true, - "defaultDoneRatio": null, - "position": 1 + "name": "open", + "isClosed": false + }, + "priority": { + "name": "high" }, "author": { "_type": "User", "_links": { "self": { "href": "/api/v3/users/5", - "title": "Alexandrine Heidenreich" + "title": "Freida Fay - Christine6938" } }, "id": 5, - "login": "Kari4599", + "login": "Christine6938", "subtype": "User", - "firstName": "Alexandrine", - "lastName": "Heidenreich", - "name": "Alexandrine Heidenreich", - "email": "marlene_gibson@hyatthane.name", + "firstName": "Freida", + "lastName": "Fay", + "name": "Freida Fay", + "email": "elwyn_dickens@gulgowskicasper.biz", "avatar": "", - "createdAt": "2015-02-13T10:09:05+00:00", - "updatedAt": "2015-02-13T10:09:05+00:00", - "status": "active" + "createdAt": "2014-11-05T15:56:820Z", + "updatedAt": "2014-11-05T15:56:820Z", + "status": 1 }, - "priority": { - "_type": "Priority", - "_links": { - "self": { - "href": "/api/v3/priorities/2", - "title": "Normal" - } + "activities": [ + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/315", + "title": "315" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/3", + "title": "Anonymous - " + }, + "update": { + "href": "/api/v3/activities/315", + "method": "patch", + "title": "315" + } + }, + "id": 315, + "comment": "", + "rawComment": "", + "details": [ + "Type set to Feature", + "Project set to Seeded Project", + "Subject set to praesentium repellendus nam officia velit voluptas voluptas quasi", + "Description set (/journals/315/diff/description)", + "Due date set to 12/27/2014", + "Status set to new", + "Priority set to Normal", + "Author set to Freida Fay", + "% done changed from 0 to 0", + "Start date set to 10/23/2014" + ], + "htmlDetails": [ + "Type set to Feature", + "Project set to Seeded Project", + "Subject set to praesentium repellendus nam officia velit voluptas voluptas quasi", + "Description set (Details)", + "Due date set to 12/27/2014", + "Status set to new", + "Priority set to Normal", + "Author set to Freida Fay", + "% done changed from 0 to 0", + "Start date set to 10/23/2014" + ], + "version": 1, + "createdAt": "2014-11-05T15:56:53Z" }, - "id": 2, - "name": "Normal", - "position": 2, - "isDefault": true, - "isActive": true - }, - "version": { - "_type": "Version", - "_links": { - "self": { - "href": "/api/v3/versions/2", - "title": "v2" + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/500", + "title": "500" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/500", + "method": "patch", + "title": "500" + } + }, + "id": 500, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/500/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 2, + "createdAt": "2014-11-10T12:31:10Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/501", + "title": "501" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/501", + "method": "patch", + "title": "501" + } }, - "definingProject": { - "href": null + "id": 501, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/501/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 3, + "createdAt": "2014-11-10T12:31:53Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/502", + "title": "502" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/502", + "method": "patch", + "title": "502" + } }, - "availableInProjects": { - "href": "/api/v3/versions/2/projects" - } + "id": 502, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/502/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 4, + "createdAt": "2014-11-10T12:31:59Z" }, - "id": 2, - "name": "v2", - "description": { - "format": "plain", - "raw": "", - "html": "" - }, - "startDate": "2015-02-02", - "endDate": null, - "status": "open", - "createdAt": "2015-02-18T14:53:17+00:00", - "updatedAt": "2015-02-18T14:53:17+00:00" - }, - "project": { - "_type": "Project", - "_links": { - "self": { - "href": "/api/v3/projects/1", - "title": "Seeded Project" + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/503", + "title": "503" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/503", + "method": "patch", + "title": "503" + } }, - "categories": { - "href": "/api/v3/projects/1/categories" + "id": 503, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/503/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 5, + "createdAt": "2014-11-10T12:32:21Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/504", + "title": "504" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/504", + "method": "patch", + "title": "504" + } }, - "versions": { - "href": "/api/v3/projects/1/versions" - } + "id": 504, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/504/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 6, + "createdAt": "2014-11-10T12:32:27Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/505", + "title": "505" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/505", + "method": "patch", + "title": "505" + } + }, + "id": 505, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/505/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 7, + "createdAt": "2014-11-10T12:32:31Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/506", + "title": "506" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/506", + "method": "patch", + "title": "506" + } + }, + "id": 506, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/506/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 8, + "createdAt": "2014-11-10T12:32:40Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/507", + "title": "507" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/507", + "method": "patch", + "title": "507" + } + }, + "id": 507, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/507/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 9, + "createdAt": "2014-11-10T12:32:45Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/511", + "title": "511" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/511", + "method": "patch", + "title": "511" + } + }, + "id": 511, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/511/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 10, + "createdAt": "2014-11-10T14:10:51Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/512", + "title": "512" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/512", + "method": "patch", + "title": "512" + } + }, + "id": 512, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/512/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 11, + "createdAt": "2014-11-10T14:42:50Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/513", + "title": "513" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/513", + "method": "patch", + "title": "513" + } + }, + "id": 513, + "comment": "", + "rawComment": "", + "details": [ + "Description deleted (/journals/513/diff/description)" + ], + "htmlDetails": [ + "Description deleted (Details)" + ], + "version": 12, + "createdAt": "2014-11-10T14:44:11Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/514", + "title": "514" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/514", + "method": "patch", + "title": "514" + } + }, + "id": 514, + "comment": "", + "rawComment": "", + "details": [ + "Description set (/journals/514/diff/description)" + ], + "htmlDetails": [ + "Description set (Details)" + ], + "version": 13, + "createdAt": "2014-11-10T14:44:21Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/515", + "title": "515" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/515", + "method": "patch", + "title": "515" + } + }, + "id": 515, + "comment": "", + "rawComment": "", + "details": [ + "Description deleted (/journals/515/diff/description)" + ], + "htmlDetails": [ + "Description deleted (Details)" + ], + "version": 14, + "createdAt": "2014-11-10T14:47:36Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/516", + "title": "516" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/516", + "method": "patch", + "title": "516" + } + }, + "id": 516, + "comment": "", + "rawComment": "", + "details": [ + "Description set (/journals/516/diff/description)" + ], + "htmlDetails": [ + "Description set (Details)" + ], + "version": 15, + "createdAt": "2014-11-10T14:820:47Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/517", + "title": "517" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/517", + "method": "patch", + "title": "517" + } + }, + "id": 517, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/517/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 16, + "createdAt": "2014-11-10T14:53:17Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/518", + "title": "518" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/518", + "method": "patch", + "title": "518" + } + }, + "id": 518, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/518/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 17, + "createdAt": "2014-11-10T15:17:34Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/8203", + "title": "8203" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/8203", + "method": "patch", + "title": "8203" + } + }, + "id": 8203, + "comment": "", + "rawComment": "", + "details": [ + "Subject changed from praesentium repellendus nam officia velit voluptas voluptas quasi to praesentium repellendus nam officia velit voluptas voluptas quasivv" + ], + "htmlDetails": [ + "Subject changed from praesentium repellendus nam officia velit voluptas voluptas quasi to praesentium repellendus nam officia velit voluptas voluptas quasivv" + ], + "version": 18, + "createdAt": "2014-11-12T12:59:25Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/531", + "title": "531" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/531", + "method": "patch", + "title": "531" + } + }, + "id": 531, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/531/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 19, + "createdAt": "2014-11-12T13:42:54Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/533", + "title": "533" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/533", + "method": "patch", + "title": "533" + } + }, + "id": 533, + "comment": "", + "rawComment": "", + "details": [ + "Parent set to 232aa22" + ], + "htmlDetails": [ + "Parent set to 232aa22" + ], + "version": 20, + "createdAt": "2014-11-12T16:16:51Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/535", + "title": "535" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/535", + "method": "patch", + "title": "535" + } + }, + "id": 535, + "comment": "", + "rawComment": "", + "details": [ + "Parent changed from 232aa22 to asd" + ], + "htmlDetails": [ + "Parent changed from 232aa22 to asd" + ], + "version": 21, + "createdAt": "2014-11-12T16:19:01Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/536", + "title": "536" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/536", + "method": "patch", + "title": "536" + } + }, + "id": 536, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/536/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 22, + "createdAt": "2014-11-12T16:23:26Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/537", + "title": "537" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/537", + "method": "patch", + "title": "537" + } + }, + "id": 537, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/537/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 23, + "createdAt": "2014-11-13T12:23:49Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/539", + "title": "539" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/539", + "method": "patch", + "title": "539" + } + }, + "id": 539, + "comment": "", + "rawComment": "", + "details": [ + "Subject changed from praesentium repellendus nam officia velit voluptas voluptas quasivv to 23123123" + ], + "htmlDetails": [ + "Subject changed from praesentium repellendus nam officia velit voluptas voluptas quasivv to 23123123" + ], + "version": 24, + "createdAt": "2014-11-17T14:03:47Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/540", + "title": "540" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/540", + "method": "patch", + "title": "540" + } + }, + "id": 540, + "comment": "", + "rawComment": "", + "details": [ + "Subject changed from 23123123 to 3q4e4" + ], + "htmlDetails": [ + "Subject changed from 23123123 to 3q4e4" + ], + "version": 25, + "createdAt": "2014-11-17T14:07:43Z" + }, + { + "_type": "Activity", + "_links": { + "self": { + "href": "/api/v3/activities/541", + "title": "541" + }, + "workPackage": { + "href": "/api/v3/work_packages/820", + "title": "66666" + }, + "user": { + "href": "/api/v3/users/1", + "title": "OpenProject Admin - admin" + }, + "update": { + "href": "/api/v3/activities/541", + "method": "patch", + "title": "541" + } + }, + "id": 541, + "comment": "", + "rawComment": "", + "details": [ + "Description changed (/journals/541/diff/description)" + ], + "htmlDetails": [ + "Description changed (Details)" + ], + "version": 26, + "createdAt": "2014-11-17T14:08:20Z" }, - "id": 1, - "identifier": "seeded_project", - "name": "Seeded Project", - "description": "Voluptatibus omnis accusantium autem qui est. Sed soluta cupiditate quaerat. Voluptatem ipsam quod qui sit id. Iusto earum numquam quia aut. Ad quia autem. Eveniet non est. Praesentium rerum et vitae provident vel.", - "homepage": "", - "createdAt": "2015-02-13T10:08:53+00:00", - "updatedAt": "2015-02-13T10:08:53+00:00", - "type": null - }, - "activities": [ { "_type": "Activity", "_links": { diff --git a/frontend/tests/integration/mocks/work-packages/822.json b/frontend/tests/integration/mocks/work-packages/822.json index 061d84b11c..52fccc45f4 100644 --- a/frontend/tests/integration/mocks/work-packages/822.json +++ b/frontend/tests/integration/mocks/work-packages/822.json @@ -85,10 +85,6 @@ "method": "post", "title": "Add comment" }, - "parent": { - "href": "/api/v3/work_packages/54", - "title": "asdsadd" - }, "timeEntries": { "href": "/work_packages/822/time_entries", "type": "text/html", @@ -114,7 +110,6 @@ "estimatedTime": "PT0S", "spentTime": "PT12H", "percentageDone": 0, - "parentId": 54, "createdAt": "2014-11-05T15:56:53Z", "updatedAt": "2014-12-04T09:48:50Z", "customProperties": [ diff --git a/frontend/tests/integration/mocks/work-packages/822_form.json b/frontend/tests/integration/mocks/work-packages/822_form.json index 0ec4a5e94c..b5f33a239f 100644 --- a/frontend/tests/integration/mocks/work-packages/822_form.json +++ b/frontend/tests/integration/mocks/work-packages/822_form.json @@ -39,8 +39,7 @@ }, "lockVersion": 145, "subject": "66666os=", - "rawDescription": "", - "parentId": 54 + "rawDescription": "" }, "schema": { "_type": { diff --git a/frontend/tests/integration/specs/work-packages/details-pane/relations/parent-relations-handler-spec.js b/frontend/tests/integration/specs/work-packages/details-pane/relations/parent-relations-handler-spec.js new file mode 100644 index 0000000000..808d1991f9 --- /dev/null +++ b/frontend/tests/integration/specs/work-packages/details-pane/relations/parent-relations-handler-spec.js @@ -0,0 +1,66 @@ +//-- copyright +// OpenProject is a project management system. +// Copyright (C) 2012-2015 the OpenProject Foundation (OPF) +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License version 3. +// +// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +// Copyright (C) 2006-2013 Jean-Philippe Lang +// Copyright (C) 2010-2013 the ChiliProject Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See doc/COPYRIGHT.rdoc for more details. +//++ + +var expect = require('../../../../spec_helper.js').expect, + detailsPaneHelper = require('../details-pane-helper.js'); + +describe('Details pane', function() { + describe('relations tab', function() { + context('has parent', function() { + var parentsSlide; + beforeEach(function () { + detailsPaneHelper.loadPane(819, 'relations'); + parentsSlide = element(by.css('[handler="wpParent"] [execute-on-enter]')); + parentsSlide.click(); + browser.waitForAngular(); + }); + + it('shows', function() { + element(by.repeater('relation in handler.relations')).then(function(relation) { + expect(relation).to.be.defined; + }); + }); + }); + + context('does not have parent', function() { + var parentsSlide; + beforeEach(function () { + detailsPaneHelper.loadPane(822, 'relations'); + parentsSlide = element(by.css('[handler="wpParent"] [execute-on-enter]')); + parentsSlide.click(); + browser.waitForAngular(); + }); + + iit('shows "No realtion exists"', function() { + element.all(by.repeater('relation in handler.relations')).count().then(function(count) { + expect(count).to.eq(0); + }); + }); + }); + }); +}); \ No newline at end of file diff --git a/frontend/tests/unit/tests/work_packages/view_models/parent-relations-handler-test.js b/frontend/tests/unit/tests/work_packages/view_models/parent-relations-handler-test.js new file mode 100644 index 0000000000..4db117d54b --- /dev/null +++ b/frontend/tests/unit/tests/work_packages/view_models/parent-relations-handler-test.js @@ -0,0 +1,83 @@ +//-- copyright +// OpenProject is a project management system. +// Copyright (C) 2012-2015 the OpenProject Foundation (OPF) +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License version 3. +// +// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +// Copyright (C) 2006-2013 Jean-Philippe Lang +// Copyright (C) 2010-2013 the ChiliProject Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See doc/COPYRIGHT.rdoc for more details. +//++ + +/*jshint expr: true*/ + +describe('ParentRelationsHandler', function() { + var ParentRelationsHandler, + relationsHandler, + workPackage; + + beforeEach(module('openproject')); + + beforeEach(inject(function($injector) { + ParentRelationsHandler = $injector.get('ParentRelationsHandler'); + })); + + beforeEach(function() { + workPackage = { + links: { + delete: { href: 'deleteMeLink' }, + update: { href: 'updateMeLink' }, + log_time: { href: 'log_timeMeLink' }, + }, + props: { + id: 20 + } + }; + }); + + describe('initializing', function() { + it('does not contain itself in relations', function() { + var relations = [{ + props: { + id: 20 + } + }]; + relationsHandler = new ParentRelationsHandler(workPackage, relations, 'parent'); + + expect(relationsHandler.relations.length).to.eq(0); + }); + + it('does contains only parents not itself', function() { + var relations = [{ + props: { + id: 20 + } + }, { + props: { + id: 21 + } + }]; + relationsHandler = new ParentRelationsHandler(workPackage, relations, 'parent'); + + expect(relationsHandler.relations.length).to.eq(1); + expect(relationsHandler.relations[0].props.id).to.eq(21); + }); + }); +});