Skip to content

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

v2.18.0

04 Mar 11:44
Compare
Choose a tag to compare
  • update to Ember Data 2.18 now that this issue is fixed

v2.16.0

04 Mar 11:45
Compare
Choose a tag to compare
  • update to Ember Data 2.16 now that this issue is fixed

v2.15.0

04 Mar 11:45
Compare
Choose a tag to compare
  • update to Ember Data 2.15 now that this issue is fixed

v3.0.0

03 Mar 18:57
Compare
Choose a tag to compare
  • update to Ember Data 3.0 now that this issue is fixed
  • you can / could use factory guy v2.13 for ED 2.13+ or use factory guy v3.0 for ED 2.13+ if you want

v2.13.27

21 Feb 23:38
Compare
Choose a tag to compare
  • adding the method attributesFor to allow you to make attributes for a model
  • use the traits and object override format just like with build/make
  • For now the relationships are NOT available. That will have to wait for future release .. so stay tuned

Example:

import { attributesFor } from 'ember-data-factory-guy';

let attrs = attributesFor('user'); // => 
  /**
  {
    "name": "User1",
    "style": "normal"
  };
 */

 attrs = attributesFor('user' , 'silly'); // => 
  /**
  {
    "name": "User1",
    "style": "silly"
  };
 */

v2.13.26

19 Feb 11:46
Compare
Choose a tag to compare
  • fixes #328 @Turbo87
  • adds new setupFactoryGuy(hooks) method for use in tests ( acceptance, integration, unit )

Sample usage:

module('Acceptance | User View', function(hooks) {
  setupApplicationTest(hooks);
  setupFactoryGuy(hooks);

  test("blah blah", async function(assert) {
     await visit('work');
     assert.ok('bah was spoken');
  });
});

v2.13.25

16 Feb 00:54
Compare
Choose a tag to compare
  • mock now allows for inline returns
 let users = buildList('user', 4);
 let userMock = mock({url: '/users'}).returns(users);

v2.13.24

16 Feb 00:49
Compare
Choose a tag to compare

Streamline manualSetup usage to only need this:

hooks.beforeEach(async function() {
  manualSetup(this);  // <= easy peasy  
]);

Add support for links tags in a payload ( for async belongsTo/hasMany relationships )

  • Links can be setup in factories
import FactoryGuy from 'ember-data-factory-guy';

FactoryGuy.define("user", {
  default: { // the () around the links objects is needed
    company: (f) => ({links: `/users/${f.id}/company`})
  },
  traits: {
    // luckily traits can use functions, so the settup is easy 
    propertiesLink: (f) => {
      f.properties = {links: `/users/${f.id}/properties`}
    }
  }
});
  • or, you can pass the links values when you make / build a model like:
let user1 = make('user', {properties: {links: '/users/1/properties'}});
let user2 = build('user', {properties: {links: '/users/2/properties'}});
  • Then use mock and build / buildList to return a payload
let user = make('user', 'propertiesLink');
let propertiesLink = user.hasMany('properties').link();
let noProperties = buildList('property', 0);

mock({url: propertiesLink}).returns(noProperties);  
  • For future I would like to have a nicer way to mock those links
    • [ Open to ideas ]
// maybe something like this ?? 
let user = make('user', 'propertiesLink');
let noProperties = buildList('property', 0);

mockLinks(user,  'properties').returns(noProperties);

v2.13.22

04 Jan 17:12
Compare
Choose a tag to compare
  • allow traits to be functions, for example
FactoryGuy.define("project", {
  default: {
    title: (f) => `Project ${f.id}`
  },
  traits: {
    //  this trait is a function
    // note that the fixure is passed in that will have 
    // default attributes like id at a minimum and in this 
    // case also a title ( `Project 1` ) which is default
    medium: (f) => {  
      f.title = `Medium Project ${f.id}`
    },
    goofy: (f) => {  
      f.title = `Goofy ${f.title}`
    }
  }
});

So, when you make / build a project like:

let project =  make('project', 'medium');
project.get('title'); //=> 'Medium Project 1'

let project2 =  build('project', 'goofy');
project2.get('title'); //=> 'Goofy Project 2'

Your trait function assigns the title as you described in the function

v2.13.21

04 Jan 17:16
Compare
Choose a tag to compare
  • fixing use of mockCreate when used with new model

This used to break with using json-api adapter/serializer

let user = makeNew('user')
mockCreate(user);