Fix create spec

The wp-inline-create controller didn't properly update the cache
service for a newly created work package.

Also, a wrong reference was passed in the table service
pull/4471/head
Oliver Günther 8 years ago committed by Alex Dik
parent 8278772ca6
commit e337be7957
  1. 5
      frontend/app/components/wp-buttons/wp-inline-create-button/wp-inline-create-button.controller.ts
  2. 2
      frontend/app/components/wp-table/wp-table.directive.ts
  3. 6
      spec/features/work_packages/table/create_work_packages_spec.rb

@ -30,6 +30,7 @@ import {wpButtonsModule} from '../../../angular-modules';
import WorkPackageCreateButtonController from '../wp-create-button/wp-create-button.controller';
import {WorkPackageCreateService} from "../../wp-create/wp-create.service";
import {scopedObservable} from "../../../helpers/angular-rx-utils";
import {WorkPackageCacheService} from "../../work-packages/work-package-cache.service";
class WorkPackageInlineCreateButtonController extends WorkPackageCreateButtonController {
public query:op.Query;
@ -44,6 +45,7 @@ class WorkPackageInlineCreateButtonController extends WorkPackageCreateButtonCon
protected $element,
protected FocusHelper,
protected I18n,
protected wpCacheService:WorkPackageCacheService,
protected wpCreate:WorkPackageCreateService) {
super($state, I18n);
@ -68,7 +70,8 @@ class WorkPackageInlineCreateButtonController extends WorkPackageCreateButtonCon
}
public addWorkPackageRow() {
scopedObservable(this.$scope, this.wpCreate.createNewWorkPackage(this.projectIdentifier)).subscribe(wp => {
this.wpCreate.createNewWorkPackage(this.projectIdentifier).then(wp => {
this.wpCacheService.updateWorkPackage(wp);
this._wp = wp;
this._wp.inlineCreated = true;

@ -243,7 +243,7 @@ function wpTable(
/** Save callbacks for work package */
scope.onWorkPackageSave = function(workPackage, fields) {
$rootScope.$emit('workPackageSaved', this.workPackage);
$rootScope.$emit('workPackageSaved', workPackage);
$rootScope.$emit('workPackagesRefreshInBackground');
} ;
}

@ -69,6 +69,12 @@ describe 'inline create work package', js: true do
expect(page).to have_selector('.wp--row .subject', text: 'Some subject')
expect(page).to have_selector('.wp--row .subject', text: 'Another subject')
# safegurards
wp_table.dismiss_notification!
wp_table.expect_no_notification(
message: 'Successful update. Click here to open this work package in fullscreen view.'
)
# Cancel creation
expect(page).to have_selector('.wp--row.-new')
page.find('.wp-table--cancel-create-link').click

Loading…
Cancel
Save