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

Cannot read property 'initialsFor' of undefined #46

Closed
stephanebruckert opened this issue Jan 5, 2018 · 7 comments
Closed

Cannot read property 'initialsFor' of undefined #46

stephanebruckert opened this issue Jan 5, 2018 · 7 comments

Comments

@stephanebruckert
Copy link

stephanebruckert commented Jan 5, 2018

Using "ember-initials": "~3.6.0" and "ember-cli": "2.17.1":

TypeError: Cannot read property 'initialsFor' of undefined
    at Class.createInitials (http://localhost:4200/assets/addon-tree-output/ember-initials/mixins/initials.js:62:1)
    at Class.<anonymous> (http://localhost:4200/assets/addon-tree-output/ember-initials/mixins/initials.js:28:1)
    at ComputedPropertyPrototype.get (http://localhost:4200/assets/ember-metal.js:3494:1)
    at get (http://localhost:4200/assets/ember-metal.js:2836:1)
    at RootPropertyReference.compute (http://localhost:4200/assets/ember-glimmer/utils/references.js:191:1)
    at RootPropertyReference.value (http://localhost:4200/assets/ember-glimmer/utils/references.js:58:1)
    at ReferenceCache.initialize (http://localhost:4200/assets/@glimmer/reference.js:395:1)
    at ReferenceCache.peek (http://localhost:4200/assets/@glimmer/reference.js:369:1)
    at DynamicAttribute.flush (http://localhost:4200/assets/@glimmer/runtime.js:1486:1)
    at ComponentElementOperations.flush (http://localhost:4200/assets/@glimmer/runtime.js:1312:1)
  createInitials() {
    return this.get('avatarsStore').initialsFor(this.initialsProperties());
  },

https://github.com/Exelord/ember-initials/blob/master/addon/mixins/initials.js#L73

3.5.0 is OK

@stephanebruckert stephanebruckert changed the title [Ember >= 2.17] Cannot read property 'initialsFor' of undefined Cannot read property 'initialsFor' of undefined Jan 5, 2018
@Exelord
Copy link
Member

Exelord commented Jan 5, 2018

Hmm, I upgraded the demo to 2.18 and there is no error. Are u using fastboot-app-server? Could you try with the latest master?

@stephanebruckert
Copy link
Author

stephanebruckert commented Jan 5, 2018

Maybe it's worth me saying that it only happens in my test (it was passing < 3.6.0) which is probably wrong now. I've just added this.inject.service('store'); but it still fails. Have you got any idea what could be wrong?

  • Same thing with master.
  • Not using fastboot-app-server.
  • Not doing anything special:
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('authenticated-navbar', 'Integration | Component | authenticated navbar', {
  integration: true,
  beforeEach: function() {
    this.inject.service('store');
  }
});

test('it renders', function(assert) {
  let currentUser = { fullname: 'John' };
  this.set('currentUser', currentUser);
  this.render(hbs`{{authenticated-navbar currentUser=currentUser}}`);
  // asserts
});
import Ember from 'ember';

const { Component, inject: { service } } = Ember;

export default Component.extend({
  currentUser: service('currentUser'),
  authManager: service('user'),

  didInsertElement() {
    this.$('[data-toggle="tooltip"]').tooltip();
  },

  actions: {
    invalidateSession() {
      this.get('authManager').invalidate();
    }
  }
});
{{ember-initials image=currentUser.avatar
                             name=currentUser.username
                             size=32}}

@Exelord
Copy link
Member

Exelord commented Jan 5, 2018

Oh, yeah.. that's because initializers are not executed in integration tests :/ Ok, I see the new container brings more issues than improvements. I will do a new release for a while.

@stephanebruckert
Copy link
Author

Ok I will use 3.5.0 for now. Thank you!

@Exelord
Copy link
Member

Exelord commented Jan 5, 2018

@stephanebruckert Please check out v3.6.1 :) I hope it will fix your problem now

@stephanebruckert
Copy link
Author

stephanebruckert commented Jan 8, 2018

Thanks for the revert! Back to ^latest

@Exelord
Copy link
Member

Exelord commented Jan 8, 2018

It wasn't a revert. I just rework it a little :)

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

No branches or pull requests

2 participants