ericchaves
7 Apr 2012, 6:46 AM
Hi Folks,
I'm using Jasmine (actually Jasmine-Species) to learn Sencha Touch 2 through test code snippets. I wrote a model with some validations and some associations and so far code is running ok.
I don't want to define the proxy in the model itself, since I believe that the decision of which kind of store/proxy to use should be handled by the controller.
Now I'd like to save some model instances in session storage so I can inspect it but somehow I'm failing to do it. I have tried to it in several different ways all ending in error messages. I tried to create the store before creating an instance of the model like this:
var user, id, errors;
var store = Ext.create('Ext.data.Store', {
model: 'User'
,proxy: {
type: 'sessionstorage'
,id : 'testProxy'
,autoload: true
,reader: {
type: 'json'
}
}
});
beforeEach(function() {
user = Ext.create('QPay.model.User', {username: 'ericchaves', email: 'eric+teste@craftti.com.br', password: '123456'});
});
This end-up with a error message saying that the my model does not exists but if I try to create a model instance it is created without problem.
I also tried to create the store after creating an model instance:
user = Ext.create('QPay.model.User', {username: 'ericchaves', email: 'eric+teste@craftti.com.br', password: '123456'});
var store = Ext.create('Ext.data.Store', {
model: 'User'
,proxy: {
type: 'sessionstorage'
,id : 'testProxy'
,autoload: true
,reader: {
type: 'json'
}
}
});
var idStore = user.identities();
id = idStore.add({CPF: '12345678901', fullName: 'Eric Chaves'});
user.save();
In this case when I call user.save() I got two error messages: the first saying that the Model user does not exists and second saying that I'm trying to save I model without a proxy in it.
What am I doing wrong here? How should I do to crate a store during runtime and use it with my models?
Thanks in advance,
Eric
I'm using Jasmine (actually Jasmine-Species) to learn Sencha Touch 2 through test code snippets. I wrote a model with some validations and some associations and so far code is running ok.
I don't want to define the proxy in the model itself, since I believe that the decision of which kind of store/proxy to use should be handled by the controller.
Now I'd like to save some model instances in session storage so I can inspect it but somehow I'm failing to do it. I have tried to it in several different ways all ending in error messages. I tried to create the store before creating an instance of the model like this:
var user, id, errors;
var store = Ext.create('Ext.data.Store', {
model: 'User'
,proxy: {
type: 'sessionstorage'
,id : 'testProxy'
,autoload: true
,reader: {
type: 'json'
}
}
});
beforeEach(function() {
user = Ext.create('QPay.model.User', {username: 'ericchaves', email: 'eric+teste@craftti.com.br', password: '123456'});
});
This end-up with a error message saying that the my model does not exists but if I try to create a model instance it is created without problem.
I also tried to create the store after creating an model instance:
user = Ext.create('QPay.model.User', {username: 'ericchaves', email: 'eric+teste@craftti.com.br', password: '123456'});
var store = Ext.create('Ext.data.Store', {
model: 'User'
,proxy: {
type: 'sessionstorage'
,id : 'testProxy'
,autoload: true
,reader: {
type: 'json'
}
}
});
var idStore = user.identities();
id = idStore.add({CPF: '12345678901', fullName: 'Eric Chaves'});
user.save();
In this case when I call user.save() I got two error messages: the first saying that the Model user does not exists and second saying that I'm trying to save I model without a proxy in it.
What am I doing wrong here? How should I do to crate a store during runtime and use it with my models?
Thanks in advance,
Eric