Quantcast
Viewing all articles
Browse latest Browse all 4828

Get current model data in acceptance test

@JordanRDesigns wrote:

I am trying to access the model being returned after visiting a url in an acceptance test.

I am not outputting any of it to a template since I will be taking some of it and storing it to local storage using an addon. So I can't using find() to find an element on the page and check it's contents to determine if what I want is being returned.

I started a stack overflow here http://stackoverflow.com/questions/33701930/get-model-of-route-after-visiting-it-in-acceptance-test

But haven't received an answer that helps explain how to do this. I could really use some help as this is sort of blocking me from continuing (unless I drop trying to follow TDD)

So far I have tried a few things, and in the stack overflow I have tried this

test('Returns a user', function(assert) {
  // Generate a user
  var user = server.create('user',{first_name: 'Jordan'});
  // Visit the index page with the users short_url
  visit('/' + user.short_url);
  var route = this.application.__container__.lookup('route:index');

  // Assert that the model the user we created by checking the first name we passed in
  assert.equal(route.model.first_name,'Jordan','Model returns user with first name Jordan');
});

But I can't seem to get the model from that container lookup.

Can someone help me understand how I would do this?

Posts: 10

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles