-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
"getModelPayload isProxy get add unwrap".w is not a function #196
Comments
can you provide more detail .. Need the model, the test, the factory .. etc .. can you put together a github repo that recreates this error ? it's way easier to diagnose and fix for me |
// addon/models/account-settings.js
import DS from 'ember-data';
export default DS.Model.extend({
menu_links: DS.attr(),
email: DS.attr('string')
});
// tests/factories/account-settings.js
import FactoryGuy from 'ember-data-factory-guy';
FactoryGuy.define('account-settings', {
default: {
menu_links: [
{ name: 'Cats', url: '/cats' },
{ name: 'Dogs', url: '/dogs', asterisk: false },
{ name: 'Cookies', url: '/cookies', asterisk: true },
{ name: 'Resources', url: '/resources', target: '_blank' }
],
email: '[email protected]'
}
});
// addon/components/nav-bar.js
import Ember from 'ember';
import layout from '../templates/components/nav-bar';
const { getOwner } = Ember;
let navbarControllerHelper = {
selector: 'header.navbar li.with_dropdown',
open(e) {
let $el;
Ember.$(this.selector).removeClass('open');
$el = Ember.$(e.target).closest('li').addClass('open');
return false;
},
closeOthers() {
return this.$els.removeClass('open');
},
init() {
let nav = this;
Ember.$(document.body).on(
'click.nav_dropdowns',
Ember.$.proxy(nav.closeOthers, nav)
);
this.$els = Ember.$(this.selector);
this.$els.each(function() {
return Ember.$(this).on(
'click.nav_dropdowns', '> a', Ember.$.proxy(nav.open, nav)
);
});
}
};
export default Ember.Component.extend({
layout: layout,
store: Ember.inject.service(),
init() {
this._super(...arguments);
this.set(
'hamburger',
this.get('store').queryRecord('hamburger', {})
);
this.set(
'accountSettings',
this.get('store').queryRecord('account-settings', {})
);
this.set(
'navbar_url',
getOwner(this).resolveRegistration('config:environment').APP.NAVBAR_URL
);
},
didInsertElement() {
navbarControllerHelper.init();
}
});
// tests/integration/components/nav-bar-test.js
import Ember from 'ember';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import startApp from '../../helpers/start-app';
import httpStubs from '../../helpers/http-stubs';
import Pretender from 'pretender';
import { make, mockQueryRecord } from 'ember-data-factory-guy';
let server;
var App, i18nSvc;
const { getOwner } = Ember;
moduleForComponent('nav-bar', 'Integration | Component | nav bar', {
integration: true,
beforeEach() {
App = startApp();
i18nSvc = this.container.lookup('service:i18n');
server = new Pretender();
},
afterEach() {
Ember.run(App, 'destroy');
server.shutdown();
}
});
test('it renders the Q-Apps logo header', function(assert) {
let accountSettings = make('account-settings');
mockQueryRecord('account-settings', {}).returns({model: accountSettings});
// custom helper method that I'm trying to replace with FactoryGuy
// httpStubs.stubAccountSettingsMenu(server, {data: null});
httpStubs.stubHamburgerMenu(server, {data: null});
this.render(hbs`{{nav-bar}}`);
andThen(function() {
assert.equal(
$.trim(this.$('header h1 a').html()),
i18nSvc.t('q-centrix-ember-components.navbar.qcentrix').string,
'error rendering logo'
);
});
}); I think that should be the relevant parts. If you need more info to diagnose, let me know and I'll put together a test repo on Monday. |
can you open console in your browser ( where ember application is running ) and run this: console.log([1,2,1].uniq()) and tell me what happens? |
I get |
ok .. the problem then is that you don't have prototype extensions enabled and the "".w() is a String.prototype exension from ember. |
Ahhhhhh that explains it. This is for an addon and I have ember-disable-prototype-extensions installed, which disables prototype extensions :) |
can you try the new version 2.5.4 ? I removed all the .w()'s .. and I hope that is all that is needed for this to work. Actually .. hold on .. need to fix more code that is using prototype extensions. |
Ok this time I installed that addon and caught a slew of other places I needed to fix. Now, version 2.5.5 is all set. |
Works for me, thanks! 👍 |
Awesome .. case closed. :) |
Trying to run the following code in a component integration test:
and am getting the error in the title. Looks like it's related to this line? Not sure what to do here.
Using ember-data-factory-guy version 2.5.3.
The text was updated successfully, but these errors were encountered: