diff --git a/frontend/app/components/wp-relations/wp-relations-create/empty-parents.template.html b/frontend/app/components/wp-relations/wp-relations-create/empty-parents.template.html index 0f7a6ef8ff..7ec779388b 100644 --- a/frontend/app/components/wp-relations/wp-relations-create/empty-parents.template.html +++ b/frontend/app/components/wp-relations/wp-relations-create/empty-parents.template.html @@ -22,8 +22,7 @@
+ execute="$ctrl.createRelation()"> diff --git a/frontend/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.directive.ts b/frontend/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.directive.ts index 2b33667924..fedf7b1d3b 100644 --- a/frontend/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.directive.ts +++ b/frontend/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.directive.ts @@ -55,8 +55,6 @@ export class WorkPackageRelationsHierarchyController { if (this.workPackage.children) { this.loadChildren(); } - - console.log('wp hierarchy', this.workPackage.addRelation); } public text = { diff --git a/frontend/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.service.ts b/frontend/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.service.ts index 0d555fbc15..3ae65aefae 100644 --- a/frontend/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.service.ts +++ b/frontend/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.service.ts @@ -48,13 +48,13 @@ export class WorkPackageRelationsHierarchyService { } public addExistingChildWp(workPackage, childWpId) { - let deferred = this.$q.defer(); + var deferred = this.$q.defer(); this.wpCacheService.loadWorkPackage(childWpId) .take(1) .subscribe(wpToBecomeChild => { - wpToBecomeChild.parentId = workPackage.id; - deferred.resolve(wpToBecomeChild.save()); + deferred.resolve(this.changeParent(wpToBecomeChild, workPackage.id)); }); + return deferred.promise; } diff --git a/spec/features/work_packages/details/details_relations_spec.rb b/spec/features/work_packages/details/details_relations_spec.rb index 39f00879b3..a88988b39b 100644 --- a/spec/features/work_packages/details/details_relations_spec.rb +++ b/spec/features/work_packages/details/details_relations_spec.rb @@ -51,7 +51,7 @@ describe 'Work package relations tab', js: true, selenium: true do it 'activates the change parent form' do - find('.wp-inline-create--add-link').click + find('.wp-inline-create--add-link', text: I18n.t('js.relation_buttons.add_parent')).click find('.inplace-edit--select').click input = find(:css, ".ui-select-search") @@ -61,7 +61,7 @@ describe 'Work package relations tab', js: true, selenium: true do input.send_keys [:down, :return] - save_button = find('.wp-relations--save a') + save_button = find(:xpath, ".//a[.//span//span[contains(concat(' ',@class,' '), ' icon-checkmark ')]]") save_button.click expect(page).to have_selector('.wp-relations-hierarchy-subject a', @@ -69,4 +69,44 @@ describe 'Work package relations tab', js: true, selenium: true do end end end + + describe 'create child relationship' do + let(:child) { FactoryGirl.create(:work_package, project: project) } + include_context 'ui-select helpers' + + let(:user_role) do + FactoryGirl.create :role, permissions: permissions + end + + let(:user) do + FactoryGirl.create :user, + member_in_project: project, + member_through_role: user_role + end + + context 'with permissions' do + let(:permissions) { %i(view_work_packages manage_subtasks) } + + it 'activates the add existing child form' do + + find('.wp-inline-create--add-link', text: I18n.t('js.relation_buttons.add_existing_child')).click + find('.inplace-edit--select').click + + input = find(:css, ".ui-select-search") + input.set(child.id) + + sleep(2) + + input.send_keys [:down, :return] + + save_button = find(:xpath, ".//a[.//span//span[contains(concat(' ',@class,' '), ' icon-checkmark ')]]") + save_button.click + + sleep(2) + + expect(page).to have_selector('.wp-relations-hierarchy-subject a', + text: "#{child.subject}") + end + end + end end