Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
use updateDocumentTitle action instead of calling private `updateTi…
Browse files Browse the repository at this point in the history
…tle` observer method
  • Loading branch information
kevinansfield committed Jan 21, 2019
1 parent ccf0b35 commit 350b911
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 47 deletions.
2 changes: 1 addition & 1 deletion app/controllers/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ export default Controller.extend({
yield this.get('autosave').perform();
}

this.get('target').updateTitle();
this.send('updateDocumentTitle');
}),

generateSlug: task(function* () {
Expand Down
46 changes: 0 additions & 46 deletions tests/unit/controllers/editor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('Unit: Controller: editor', function () {
'controller:application',
'service:feature',
'service:notifications',
// 'service:router',
'service:slugGenerator',
'service:session',
'service:ui'
Expand Down Expand Up @@ -90,9 +89,6 @@ describe('Unit: Controller: editor', function () {
expect(controller.get('post.titleScratch')).to.not.be.ok;

controller.set('post.titleScratch', 'test');
controller.set('target', {
updateTitle: () => {}
});

run(() => {
controller.get('saveTitle').perform();
Expand Down Expand Up @@ -120,9 +116,6 @@ describe('Unit: Controller: editor', function () {
expect(controller.get('post.titleScratch')).to.not.be.ok;

controller.set('post.titleScratch', 'New Title');
controller.set('target', {
updateTitle: () => {}
});

run(() => {
controller.get('saveTitle').perform();
Expand Down Expand Up @@ -154,9 +147,6 @@ describe('Unit: Controller: editor', function () {
expect(controller.get('post.titleScratch')).to.not.be.ok;

controller.set('post.titleScratch', 'test');
controller.set('target', {
updateTitle: () => {}
});

run(() => {
controller.get('saveTitle').perform();
Expand Down Expand Up @@ -184,41 +174,6 @@ describe('Unit: Controller: editor', function () {
expect(controller.get('post.title')).to.not.be.ok;

controller.set('post.titleScratch', 'title');
controller.set('target', {
updateTitle: () => {}
});

run(() => {
controller.get('saveTitle').perform();
});

wait().then(() => {
expect(controller.get('post.titleScratch')).to.equal('title');
expect(controller.get('post.slug')).to.not.be.ok;
done();
});
});

it('should invoke updateTitle after the title has changed', function (done) {
let controller = this.subject();

run(() => {
controller.set('generateSlug', task(function * () {
expect(false, 'generateSlug should not be called').to.equal(true);
yield RSVP.resolve();
}));
controller.set('post', EmberObject.create({isNew: false}));
});

expect(controller.get('post.isNew')).to.be.false;
expect(controller.get('post.title')).to.not.be.ok;

let updateTitleCalled = false;

controller.set('post.titleScratch', 'title');
controller.set('target', {
updateTitle: () => updateTitleCalled = true
});

run(() => {
controller.get('saveTitle').perform();
Expand All @@ -227,7 +182,6 @@ describe('Unit: Controller: editor', function () {
wait().then(() => {
expect(controller.get('post.titleScratch')).to.equal('title');
expect(controller.get('post.slug')).to.not.be.ok;
expect(updateTitleCalled).to.be.true;
done();
});
});
Expand Down

0 comments on commit 350b911

Please sign in to comment.