Skip to content

Releases: adopted-ember-addons/ember-data-factory-guy

v3.2.1

14 Jul 22:19
Compare
Choose a tag to compare
  • BREAKING change for links syntax
  • You can setup data AND links for your async relationship
  • Need special care with multiple traits setting links
  FactoryGuy.define('user', {
    traits: {
      withCompanyLink(f): {
        // since you can assign many different links with different traits,
        // you should Object.assign so that you add to the links hash rather 
        // than set it directly ( assuming you want to use this feature ) 
        f.links = Object.assign({company: `/users/${f.id}/company`}, f.links);
      },
      withPropertiesLink(f) {  
        f.links = Object.assign({properties: `/users/${f.id}/properties`}, f.links); 
      }
    }
  });

  let company = make('company')
 // Setting a company model AND links for your async company relationship 
  let user = make('user', 'withCompanyLink', 'withPropertiesLink', {company});

 // both links are setup 
  user.hasMany('properties').link(); // => "/users/1/properties"
  user.belongsTo('company').link(); // => "/users/1/company"

  // the company async relationship has a company AND link to fetch it again 
  user.get('company.content') // => company
  // when you reload that relationship 
  user.belongsTo('company').reload() // would use that link "/users/1/company" to reload company 

Sorry to change this syntax, but the syntax and behaviour now exactly matches how Ember Data handles links,
and this give you way more power than previous versions of FactoryGuy allowed you to have.

v3.2.0

07 Jul 11:55
Compare
Choose a tag to compare
  • bump Ember Data and friends to 3.2
  • clean up helper utilities to no longer use __container__ and just use owner

v3.1.7

06 Jul 22:33
Compare
Choose a tag to compare
  • made parseUrl more robust ( was affecting mockLinks update from v.3.1.6 )

v3.1.6

06 Jul 22:14
Compare
Choose a tag to compare
  • Improve mockLinks to handle url with query parameters.
    • links are kind of a black box that you can not touch very easily, and the mockLinks helper allows you to mock a links relationship, but now that works for links with query parameters so life is better again

Example:

    let propertiesLink = '/users/1/properties?dudes=2',
        user           = make('user', {properties: {links: propertiesLink}}),
        json           = buildList('property', 1),
        mockProperties = mockLinks(user, 'properties').returns({json});

      const properties = await user.properties.toArray(); // 1 property model 
  • mockLinks automatically breaks that url apart into the url and query params for you

  • alternatively you could use mock

  mock({url: '/users/1/properties/'}).withParams({dudes: 2}).returns(json);

v3.1.5

03 Jul 11:06
Compare
Choose a tag to compare

Example:

let noUsers1 = makeList('user', 0);  
let noUsers2 = makeList('user', 0, 'with_hats', {name: 'Pat'});

Both of these now correctly give you no users ( empty list )

v3.1.4

26 Jun 10:25
Compare
Choose a tag to compare
  • mock ( used for mocking any url ) can now handle query parameters

Example:

    const type       = 'GET',
          url        = '/api/get-stuff',
          whatsUp    = {whats: 'up'},
          message    = {message: 'nothing much doc'}

    let theMock = mock({url}).withParams(whatsUp).returns(message);
    let json = await Ember.$.ajax({type, url, data: whatsUp});
    json // => {message: 'nothing much doc'}

v3.1.3

31 May 20:34
Compare
Choose a tag to compare
  • fixes #344 to pass in request body when matching mockUpdates with function @roschaefer
    mockCreate('project').match(requestBody => {
      return requestBody.data.attributes.title === 'titleToMatch';
    });

v3.1.2

15 May 14:18
Compare
Choose a tag to compare
  • setting query params before handler sets up url to fix #343

v3.1.1

29 Apr 18:47
Compare
Choose a tag to compare

v3.1.0

11 Apr 12:05
Compare
Choose a tag to compare
  • bump ember source/ data / cli to 3.1