Skip to content

Commit

Permalink
Monkey patch factory guy handleFind for STI tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
pairing committed May 7, 2015
1 parent 7e62de5 commit 49d4c4f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
11 changes: 0 additions & 11 deletions client/tests/addons/add-author-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ import startApp from "tahi/tests/helpers/start-app";
import FactoryGuy from "ember-data-factory-guy";
import TestHelper from "ember-data-factory-guy/factory-guy-test-helper";

TestHelper.mapFind = function(modelName, json) {
let responseJson = {};
if ((/Task/).test(modelName)) {
responseJson["tasks"] = json;
} else {
responseJson[Ember.String.pluralize(modelName)] = json;
}
return responseJson;
};


let App, paper, phase, task;

module("Integration: adding an author", {
Expand Down
11 changes: 0 additions & 11 deletions client/tests/addons/inviting-an-editor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ import startApp from "tahi/tests/helpers/start-app";
import FactoryGuy from "ember-data-factory-guy";
import TestHelper from "ember-data-factory-guy/factory-guy-test-helper";


TestHelper.mapFind = function(modelName, json) {
let responseJson = {};
if ((/Task/).test(modelName)) {
responseJson["tasks"] = json;
} else {
responseJson[Ember.String.pluralize(modelName)] = json;
}
return responseJson;
};

let App, paper, phase, task, inviteeEmail;

module("Integration: inviting an editor", {
Expand Down
14 changes: 14 additions & 0 deletions client/tests/helpers/start-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import chosenHelpers from './chosen-helpers';
import customAssertions from './custom-assertions';

import Factory from './factory';
import TestHelper from "ember-data-factory-guy/factory-guy-test-helper";

export default function startApp(attrs) {
var application;
Expand All @@ -30,6 +31,19 @@ export default function startApp(attrs) {

window.currentUserData = {user: currentUser};

TestHelper.reopen({
mapFind: function(modelName, json) {
var responseJson = {};
// hack to work around
// https://github.com/danielspaniel/ember-data-factory-guy/issues/82
if ((/Task/).test(modelName)) {
modelName = 'task';
}
responseJson[Ember.String.pluralize(modelName)] = json;
return responseJson;
}
});

Ember.run(function() {
application = Application.create(attributes);
application.setupForTesting();
Expand Down

0 comments on commit 49d4c4f

Please sign in to comment.