Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destroy the subject in teardown #18

Merged
merged 1 commit into from
Feb 22, 2015

Conversation

CodeOfficer
Copy link
Contributor

I'm not sure what there is to test here so I didn't add any tests yet.

Currently the container is destroyed which takes care of destroying any dependencies brought in by needs but the subject is never properly town down. This makes sure that happens.

@rwjblue
Copy link
Member

rwjblue commented Feb 21, 2015

I'd like to see the following test near the end of https://github.com/switchfly/ember-test-helpers/blob/master/tests/test-module-test.js:

moduleFor('component:x-foo', 'component:x-foo -- created subjects are cleaned up', {
  beforeSetup: function() {
    setupRegistry();
  },

  afterTeardown: function() {
    var subject = this.cache.subject;

    ok(subject.isDestroyed);
  }
});

test("subject's created in a test are destroyed", function() {
  this.subject();
});

moduleFor('component:x-foo', 'component:x-foo -- uncreated subjects do not error', {
  beforeSetup: function() {
    setupRegistry();
  }
});

test("subject's created in a test are destroyed", function() {
  expect(0);
});

var subject = this.cache.subject;

if (subject) {
Ember.run(subject, 'destroy');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible that subject does not have a destroy method so you will probably want to do something like:

Ember.run(function() {
  Ember.tryInvoke(subject, 'destroy');
});

@CodeOfficer
Copy link
Contributor Author

^_^

@rwjblue
Copy link
Member

rwjblue commented Feb 22, 2015

❤️

@rwjblue
Copy link
Member

rwjblue commented Feb 22, 2015

I'm 👍, but I'll give @dgeb a chance to chime in...

dgeb added a commit that referenced this pull request Feb 22, 2015
@dgeb dgeb merged commit 9ae95dc into emberjs:master Feb 22, 2015
@dgeb
Copy link
Member

dgeb commented Feb 22, 2015

Looks great - thanks @CodeOfficer!

@rwjblue
Copy link
Member

rwjblue commented Feb 22, 2015

released in v0.3.4 of ember-test-helpers and v0.2.10 of ember-qunit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants