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

Fixing tests for Ember Data 1.0.0-beta.5 #30

Merged
merged 21 commits into from
Feb 13, 2014
Merged

Fixing tests for Ember Data 1.0.0-beta.5 #30

merged 21 commits into from
Feb 13, 2014

Conversation

kurko
Copy link
Collaborator

@kurko kurko commented Jan 3, 2014

This PR has a bunch of changes required to work with the new architecture used since ED entered beta.

  • Fix find() tests
  • Fix findMany() tests (this one is tough)
  • Fix findQuery() tests
  • Fix findAll() tests
  • Fix createRecord() tests
  • Fix updateRecord() tests
  • Fix deleteRecords() tests
  • Fix bulkCommits() tests (not sure this one is needed anymore)
  • Fix load has many tests
  • Fix load belongs to tests
  • Fix save relationship tests
  • Refactor crazy helpers
  • Remove memoized variables that prevent data from being truly stored (closes Relations lost on page reload #23)

@kurko
Copy link
Collaborator Author

kurko commented Jan 3, 2014

@fivetanley @rpflorence ping

// 1. findMany is a private method
// 2. DS.FixtureAdapter doesn't test it directly
// test('findMany', function() {
// lists = store.findMany('list', Ember.A(['l1', 'l3']), App.List);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm still struggling with this test. Can't make it pass nor understand why. Basically, ED throws all sorts of errors.

I'm thinking about removing this test, given no other adapter tests it directly. Then I'll probably Unit test the method in another test namespace.

@kurko kurko mentioned this pull request Jan 19, 2014

store = DS.Store.create({adapter: adapter});
// 1. findMany is a private method
// 2. DS.FixtureAdapter doesn't test it directly
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with these statements as being pretty good reasons to just delete this test and check off "Fix findMany() tests (this one is tough)".

@amiel
Copy link
Contributor

amiel commented Jan 20, 2014

For "Refactor crazy helpers", is there anything in particular you are looking for? I just deleted a bunch of unused stuff. I figure it's ok-ish now (see carnesmedia/ember-localstorage-adapter@22cf6d162fa87f70175be9e397ae4fb4e5b00011)

@kurko
Copy link
Collaborator Author

kurko commented Jan 20, 2014

Yeah, I'd remove the helpers that make reading tests harder. I personally don't like assertStoredList, for example, because you don't know what's really being tested unless you go check that helper. I agree reusability is important, but I think tests should be as explicit as possible.

Regardless of that, I think these changes in the helpers are definitely not as important as making the tests pass. I'll trust your judgement on this one.

@amiel
Copy link
Contributor

amiel commented Jan 21, 2014

FYI: there are a bunch of changes in kurko#1

@kurko
Copy link
Collaborator Author

kurko commented Jan 22, 2014

Thanks for the hard work, @amiel! Are the tests passing? (I'm going to download it tonight and run them)

bjarkehs and others added 2 commits January 31, 2014 22:20
Fix to handle when localStorage hasn't been initialized
@kurko
Copy link
Collaborator Author

kurko commented Feb 1, 2014

Ok, so I unchecked load hasMany because it's broken (at least for me). Also, given we're on a shared branch, remember to not change history of commits.

@kurko
Copy link
Collaborator Author

kurko commented Feb 1, 2014

Guys, good news! All tests are finally passing locally. I want to thank @amiel and @bjarkehs immensely for the hard work. After all this coordinated effort, seeing the final result is what makes me love open source.

Now, before merging, I'd like to ask you guys to review this code. Also, we need to change the README with things like "{async: true}" is not needed and some other things. It's late here, so I won't do it now. I'm also going to push a fix for the phantomjs runner.js file, that's broken since forever.

Thank you.

@kurko
Copy link
Collaborator Author

kurko commented Feb 1, 2014

Although fixing TravisCI is out of the scope of this PR, merging the runner.js file into master wouldn't serve us anything, given all tests are failing.

@amiel
Copy link
Contributor

amiel commented Feb 3, 2014

YAY! Thanks @bjarkehs and @kurko!

@amiel
Copy link
Contributor

amiel commented Feb 3, 2014

Is there anything left to do for this pull-request?

@kurko
Copy link
Collaborator Author

kurko commented Feb 3, 2014

I'll review it tonight and then update the README.

}
},

extractSingle: function(store, type, payload) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We should probably add a comment here on why we're extracting it the way we're doing it.

@fivetanley
Copy link
Collaborator

To everyone helping out, you have my deepest gratitude. I'll give this a formal review as soon as I can, hopefully tomorrow morning before work. I am so happy tears are running down my face.

bjarkehs and others added 2 commits February 5, 2014 10:27
… the model isn't added to localStorage already
Issues with localStorage when empty and when creatingRecords
@bjarkehs bjarkehs mentioned this pull request Feb 10, 2014
@bjarkehs
Copy link
Contributor

I'm not sure if this is a bug with the adapter or my code, but I'm getting the error:

Assertion failed: You looked up the 'hours' relationship on '<App.Order:ember356:jbti6>' but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.hasMany({ async: true })`)

In order for this to make sense I have the following models defined:

App.Order = DS.Model.extend({
    navision: DS.attr('number'),
    user: DS.belongsTo('user'),
    hours: DS.hasMany('hour'),
    materials: DS.hasMany('material'),
    services: DS.hasMany('service')
});
App.Hour = DS.Model.extend({
    web_id: DS.attr('number'),
    amount: DS.attr('number'),
    overtime1: DS.attr('number'),
    overtime2: DS.attr('number'),
    date: DS.attr('string'),
    order: DS.belongsTo('order')
});

I'd think that since everything is local we might as well fetch it all? When I console.log the order object I can access the hours through _data and then hours, so I'm not entirely sure where it goes wrong. Anyone with some insight on this?

kurko added a commit that referenced this pull request Feb 13, 2014
Fixing tests for Ember Data 1.0.0-beta.5
@kurko kurko merged commit bd9611c into locks:master Feb 13, 2014
@kurko kurko deleted the fixing_jj_abrams_lens_glare branch February 13, 2014 12:55
@kurko
Copy link
Collaborator Author

kurko commented Feb 13, 2014

Merged this. Finding new issues and opening PRs will be easier now. I copied master into a branch called pre-beta.

@bjarkehs is that error occurring in the tests? If so, have you registered the App.Hour model in the store? Maybe could you open a new issue?

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.

Relations lost on page reload
4 participants