Skip to content

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

v2.7.0-beta.9

04 Jul 20:49
Compare
Choose a tag to compare
  • added an option to NOT convert errors when setting custom error response #215

    • factory guy allows you to use a simple style: {errors: {name: "Name too short"}}
    • Behind the scenes converts to another format for ember-data to consume.
      ( It is basically a json-api standard that is tedious to manually setup )
    • Examples:
      // This errors object will be automatically converted to ember-data friendly format for you
      let errors422 = {errors: {name: "Name too short"}};
      let mock = mockFind('profile').fails({status: 422, response: errors422}); 
    
      // the nice thing about the conversion is that you get nice error messages
      FactoryGuy.store.find('profile').then((profile) => {
        profile.get('errors.messages'); //=> ["Name too short"]
      });
    
      // Don't automatically convert these errors by using => convertErrors: false
      let errorsMine = {errors: [{detail: "Name too short", title: "I am short"}]};
      let mock = mockFind('profile').fails({status: 422, response: errorsMine, convertErrors: false}); 
  • rejiggered the settings in mockSetup for

    • mockjaxLogLevel
    • responseTime
    • logLevel
  • added warning when assigning traits that don't exist

v2.7.0-beta.8

30 Jun 13:36
Compare
Choose a tag to compare

v2.7.0-beta.7

30 Jun 13:37
Compare
Choose a tag to compare
  • added mockUpdate to FactoryGuy functions that are proxied in Scenario class

v2.7.0-beta.6

27 Jun 20:18
Compare
Choose a tag to compare
  • can now call mockUpdate with only modelName
    • mockUpdate('user') // make successful update on any user
    • previously you needed a modelName and id or a model instance
    • this helps in building scenarios in development where you might not know the id or might not care
    • NOTE: with only the modelName you can NOT use returns to pass back attributes or relationships
      since it is meant to be a general update and not specific.

v2.7.0-beta.5

23 Jun 20:45
Compare
Choose a tag to compare
  • Fixed using FactoryGuy.hasMany with splat arguments not working in factory definitions
import FactoryGuy from 'ember-data-factory-guy';

FactoryGuy.define('user', {
   traits: {
     withProjects: {
       // The typical hasMany usage is: FactoryGuy.hasMany('project', 3, 'big')
       // But that does not allow you to make different types of project. 
       // They will all be similar except for id

       // This is splat style arguments where each arg is and option for a different project 
       // It's the same style you can use for makeList and buildList 
       projects: FactoryGuy.hasMany('project', 'big', 'medium', 'small') 
       // makes 3 project that are all different 
     }
});

v2.7.0-beta.4

23 Jun 10:49
Compare
Choose a tag to compare
  • Updated logging to include the model name
  • Changed the Scenario.settings to use logLevel, instead of fgLogLevel
// file: app/scenarios/main.js
Scenario.settings({
  logLevel: 1, // 1 ( max for now )
});

// In test environment
// in any test file or setup

FactoryGuy.settings({logLevel: 1});     

What you will see in the logs:

[factory-guy] MockFindAll(user) {users: Array[2]}

v2.7.0-beta.3

21 Jun 15:14
Compare
Choose a tag to compare

Added new logging abilities to MockRequests

  • User Scenario.settings or FactoryGuy.settings
    • FactoryGuy.settings takes logLevel so you can get logging from mockRequests
    • Scenario.settings takes fgLogLevel and mockjaxLogLevel
    • Makes is really easy to see what was returned by FactoryGuy requests
// When using scenarios
// file: app/scenarios/main.js
Scenario.settings({
  mockjaxLogLevel: 1,  // 2, 3, 4 ( max )
  fgLogLevel: 1, // 1 ( max for now )
});
// In test environment
// in any test file or setup 
FactoryGuy.settings({logLevel: 1});     

What you will see in the logs:

[factory-guy] MockFindAllRequest {vehicles: Array[2]}

[factory-guy] MockQueryRequest {vehicles: Array[3]} queryParams: {style: "fast", color: "red"}

v2.7.0-beta.2

18 Jun 18:16
Compare
Choose a tag to compare
  • Minor fix to regex for finding scenarios/main file when loading scenarios

v2.7.0-beta.1

18 Jun 15:58
Compare
Choose a tag to compare
  • Can now use Factory Guy in development (thanks @taras for helping out! )

    • The biggest thing to hit factory guy since the invention of the toothbrush
    • You can set up scenarios for you pages that use all your factories from tests
      • In config/environment.js place a flag factoryGuy: true
          if (environment === 'development') {
             ENV.factoryGuy = true;
             ENV.locationType = 'auto';
             ENV.baseURL = '/';
          }
  • Place your scenarios in app/scenarios directory

    • Start by creating at least a scenarios/main.js file since this is the starting point
    • Your scenario classes should inherit from Scenario class
    • A Scenario class should declare a run method where you do things like:
      • include other scenarios
      • make your data or mock your requests using the typical FactoryGuy methods
        • these methods are all built into Scenario classes so you don't have to import them
      // file: app/scenarios/main.js
      import {Scenario} from 'ember-data-factory-guy';
      import Users from './users';
    
      export default class extends Scenario {
        run() { 
           this.include([Users]);
           this.mockFindAll('products', 3);
        }
      }
      // file: app/scenarios/users.js
      import {Scenario} from 'ember-data-factory-guy';
    
      export default class extends Scenario {
        run() {
          this.mockFindAll('user', 'boblike', 'normal');
          this.mockDelete('user');
        }
      }  

v2.6.7

15 Jun 13:46
Compare
Choose a tag to compare
  • make mocks check URI instead of URL #209
    • this allows you to add parameters to the url and still match the url for the ajax call if you don't want to match the parameters
  • made #get method ( to inspect payload ) available to all GET mocks including => mockQuery, mockQueryRecord
    • previously that #get method was only available to mockFind and mockFindAll
  • updated mockjax to 2.2.0
  • updated ember-data to 2.6.0