Skip to content

Commit

Permalink
Merge pull request #4223 from pangratz/run-tests-in-production
Browse files Browse the repository at this point in the history
Run tests in production
  • Loading branch information
bmac committed Mar 13, 2016
2 parents f45849d + c86ce5e commit b3eb9c0
Show file tree
Hide file tree
Showing 33 changed files with 171 additions and 97 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ script:
- ./bin/lint-features
- npm run-script test
- npm run-script test:optional-features
- npm run-script test:production
- npm run-script node-tests
after_success:
- npm run-script production
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ test_script:
- npm version
- cmd: npm run test
- cmd: npm run test:optional-features
- cmd: npm run test:production
- cmd: npm run node-tests

# Don't actually build.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"test": "ember try:testall",
"node-tests": "node node-tests/nodetest-runner.js",
"test:optional-features": "ember test --environment=test-optional-features",
"test:production": "ember test --environment=production",
"bower": "bower install",
"production": "ember build --environment=production"
},
Expand Down
16 changes: 16 additions & 0 deletions tests/helpers/test-in-debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { runInDebug } from 'ember-data/-private/debug';
import { test, skip } from 'qunit';

export default function testInDebug() {
let isDebug = false;

runInDebug(function() {
isDebug = true;
});

if (isDebug) {
test(...arguments);
} else {
skip(...arguments);
}
}
3 changes: 2 additions & 1 deletion tests/integration/adapter/find-all-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {createStore} from 'dummy/tests/helpers/store';
import setupStore from 'dummy/tests/helpers/store';
import Ember from 'ember';
import testInDebug from 'dummy/tests/helpers/test-in-debug';
import {module, test} from 'qunit';
import DS from 'ember-data';

Expand Down Expand Up @@ -145,7 +146,7 @@ test("When all records for a type are requested, records that are created on the
assert.equal(allRecords.objectAt(0).get('name'), "Carsten Nielsen", "the first item in the record array is Carsten Nielsen");
});

test('When all records are requested, assert the payload is not blank', (assert) => {
testInDebug('When all records are requested, assert the payload is not blank', (assert) => {
env.registry.register('adapter:person', DS.Adapter.extend({
findAll: () => Ember.RSVP.resolve({})
}));
Expand Down
7 changes: 4 additions & 3 deletions tests/integration/adapter/find-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import setupStore from 'dummy/tests/helpers/store';
import Ember from 'ember';
import testInDebug from 'dummy/tests/helpers/test-in-debug';
import {module, test} from 'qunit';
import DS from 'ember-data';

Expand Down Expand Up @@ -29,7 +30,7 @@ module("integration/adapter/find - Finding Records", {
}
});

test("It raises an assertion when `undefined` is passed as id (#1705)", (assert) => {
testInDebug("It raises an assertion when `undefined` is passed as id (#1705)", (assert) => {
assert.expectAssertion(() => {
store.find('person', undefined);
}, "You cannot pass `undefined` as id to the store's find method");
Expand Down Expand Up @@ -130,7 +131,7 @@ test("When a single record is requested, and the promise is rejected, the record
});
});

test('When a single record is requested, and the payload is blank', (assert) => {
testInDebug('When a single record is requested, and the payload is blank', (assert) => {
env.registry.register('adapter:person', DS.Adapter.extend({
findRecord: () => Ember.RSVP.resolve({})
}));
Expand All @@ -140,7 +141,7 @@ test('When a single record is requested, and the payload is blank', (assert) =>
}, /the adapter's response did not have any data/);
});

test('When multiple records are requested, and the payload is blank', (assert) => {
testInDebug('When multiple records are requested, and the payload is blank', (assert) => {
env.registry.register('adapter:person', DS.Adapter.extend({
coalesceFindRequests: true,
findMany: () => Ember.RSVP.resolve({})
Expand Down
7 changes: 4 additions & 3 deletions tests/integration/adapter/queries-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import setupStore from 'dummy/tests/helpers/store';
import Ember from 'ember';

import testInDebug from 'dummy/tests/helpers/test-in-debug';
import {module, test} from 'qunit';

import DS from 'ember-data';
Expand Down Expand Up @@ -28,13 +29,13 @@ module("integration/adapter/queries - Queries", {
}
});

test("It raises an assertion when no type is passed", function(assert) {
testInDebug("It raises an assertion when no type is passed", function(assert) {
assert.expectAssertion(function() {
store.query();
}, "You need to pass a type to the store's query method");
});

test("It raises an assertion when no query hash is passed", function(assert) {
testInDebug("It raises an assertion when no query hash is passed", function(assert) {
assert.expectAssertion(function() {
store.query('person');
}, "You need to pass a query hash to the store's query method");
Expand All @@ -56,7 +57,7 @@ test("When a query is made, the adapter should receive a record array it can pop
}));
});

test("The store asserts when query is made and the adapter responses with a single record.", function(assert) {
testInDebug("The store asserts when query is made and the adapter responses with a single record.", function(assert) {
env = setupStore({ person: Person, adapter: DS.RESTAdapter });
store = env.store;
adapter = env.adapter;
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/adapter/rest-adapter-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import setupStore from 'dummy/tests/helpers/store';
import Ember from 'ember';

import testInDebug from 'dummy/tests/helpers/test-in-debug';
import {module, test} from 'qunit';

import DS from 'ember-data';
Expand Down Expand Up @@ -1326,7 +1327,7 @@ test("queryRecord - returning an array picks the first one but saves all records
}));
});

test("queryRecord - returning an empty array errors", function(assert) {
testInDebug("queryRecord - returning an empty array errors", function(assert) {
ajaxResponse({
post: []
});
Expand Down Expand Up @@ -1876,7 +1877,7 @@ test('findBelongsTo - passes buildURL the requestType', function(assert) {
}));
});

test('coalesceFindRequests assert.warns if the expected records are not returned in the coalesced request', function(assert) {
testInDebug('coalesceFindRequests assert.warns if the expected records are not returned in the coalesced request', function(assert) {
Comment.reopen({ post: DS.belongsTo('post', { async: false }) });
Post.reopen({ comments: DS.hasMany('comment', { async: true }) });

Expand Down
5 changes: 3 additions & 2 deletions tests/integration/inverse-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import setupStore from 'dummy/tests/helpers/store';
import Ember from 'ember';

import testInDebug from 'dummy/tests/helpers/test-in-debug';
import {module, test} from 'qunit';

import DS from 'ember-data';
Expand Down Expand Up @@ -98,7 +99,7 @@ test("Returns null if inverse relationship it is manually set with a different r
assert.equal(User.inverseFor('job', store), null, 'There is no inverse');
});

test("Errors out if you define 2 inverses to the same model", function(assert) {
testInDebug("Errors out if you define 2 inverses to the same model", function(assert) {
Job.reopen({
user: belongsTo('user', { inverse: 'job', async: false }),
owner: belongsTo('user', { inverse: 'job', async: false })
Expand All @@ -125,7 +126,7 @@ test("Caches findInverseFor return value", function(assert) {
assert.equal(inverseForUser, Job.inverseFor('user', store), 'Inverse cached succesfully');
});

test("Errors out if you do not define an inverse for a reflexive relationship", function(assert) {
testInDebug("Errors out if you do not define an inverse for a reflexive relationship", function(assert) {

//Maybe store is evaluated lazily, so we need this :(
assert.expectWarning(function() {
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/references/belongs-to-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import DS from 'ember-data';
import Ember from 'ember';
import setupStore from 'dummy/tests/helpers/store';
import testInDebug from 'dummy/tests/helpers/test-in-debug';
import { module, test } from 'qunit';
import isEnabled from 'ember-data/-private/features';

Expand Down Expand Up @@ -251,7 +252,7 @@ if (isEnabled("ds-references")) {
});
});

test("push(record) asserts for invalid type", function(assert) {
testInDebug("push(record) asserts for invalid type", function(assert) {
var person, anotherPerson;
run(function() {
person = env.store.push({
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/references/has-many-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import DS from 'ember-data';
import Ember from 'ember';
import setupStore from 'dummy/tests/helpers/store';
import testInDebug from 'dummy/tests/helpers/test-in-debug';
import { module, test } from 'qunit';
import isEnabled from 'ember-data/-private/features';

Expand Down Expand Up @@ -202,7 +203,7 @@ if (isEnabled("ds-references")) {
});
});

test("push(array) asserts polymorphic type", function(assert) {
testInDebug("push(array) asserts polymorphic type", function(assert) {
var family;
run(function() {
family = env.store.push({
Expand Down
9 changes: 5 additions & 4 deletions tests/integration/relationships/belongs-to-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import setupStore from 'dummy/tests/helpers/store';
import Ember from 'ember';
import isEnabled from 'ember-data/-private/features';

import testInDebug from 'dummy/tests/helpers/test-in-debug';
import {module, test} from 'qunit';

import DS from 'ember-data';
Expand Down Expand Up @@ -130,7 +131,7 @@ test("The store can materialize a non loaded monomorphic belongsTo association",
});
});

test("Only a record of the same type can be used with a monomorphic belongsTo relationship", function(assert) {
testInDebug("Only a record of the same type can be used with a monomorphic belongsTo relationship", function(assert) {
assert.expect(1);
env.adapter.shouldBackgroundReloadRecord = () => false;
run(function() {
Expand Down Expand Up @@ -161,7 +162,7 @@ test("Only a record of the same type can be used with a monomorphic belongsTo re
});
});

test("Only a record of the same base type can be used with a polymorphic belongsTo relationship", function(assert) {
testInDebug("Only a record of the same base type can be used with a polymorphic belongsTo relationship", function(assert) {
env.adapter.shouldBackgroundReloadRecord = () => false;
assert.expect(1);
run(function() {
Expand Down Expand Up @@ -727,7 +728,7 @@ test("Destroying a record with an unloaded aync belongsTo association does not f
run(post, 'destroyRecord');
});

test("A sync belongsTo errors out if the record is unlaoded", function(assert) {
testInDebug("A sync belongsTo errors out if the record is unlaoded", function(assert) {
var message;
run(function() {
message = env.store.push({
Expand Down Expand Up @@ -833,7 +834,7 @@ test("Rollbacking attributes for a deleted record restores implicit relationship
assert.equal(book.get('author'), author, 'Book has an author after rollback attributes');
});

test("Passing a model as type to belongsTo should not work", function(assert) {
testInDebug("Passing a model as type to belongsTo should not work", function(assert) {
assert.expect(1);

assert.expectAssertion(function() {
Expand Down
11 changes: 6 additions & 5 deletions tests/integration/relationships/has-many-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import setupStore from 'dummy/tests/helpers/store';
import Ember from 'ember';

import testInDebug from 'dummy/tests/helpers/test-in-debug';
import {module, test} from 'qunit';

import DS from 'ember-data';
Expand Down Expand Up @@ -1201,7 +1202,7 @@ test("Polymorphic relationships with a hasMany is set up correctly on both sides
assert.equal(get(email, 'posts.length'), 1, "The inverse has many is set up correctly on the email side.");
});

test("A record can't be created from a polymorphic hasMany relationship", function(assert) {
testInDebug("A record can't be created from a polymorphic hasMany relationship", function(assert) {
env.adapter.shouldBackgroundReloadRecord = () => false;
run(function() {
env.store.push({
Expand All @@ -1228,7 +1229,7 @@ test("A record can't be created from a polymorphic hasMany relationship", functi
});
});

test("Only records of the same type can be added to a monomorphic hasMany relationship", function(assert) {
testInDebug("Only records of the same type can be added to a monomorphic hasMany relationship", function(assert) {
assert.expect(1);
env.adapter.shouldBackgroundReloadRecord = () => false;
run(function() {
Expand Down Expand Up @@ -1260,7 +1261,7 @@ test("Only records of the same type can be added to a monomorphic hasMany relati
});
});

test("Only records of the same base type can be added to a polymorphic hasMany relationship", function(assert) {
testInDebug("Only records of the same base type can be added to a polymorphic hasMany relationship", function(assert) {
assert.expect(2);
env.adapter.shouldBackgroundReloadRecord = () => false;
run(function() {
Expand Down Expand Up @@ -1606,7 +1607,7 @@ test("When an unloaded record is added to the hasMany, it gets fetched once the
});
});

test("A sync hasMany errors out if there are unlaoded records in it", function(assert) {
testInDebug("A sync hasMany errors out if there are unlaoded records in it", function(assert) {
var post;
run(function() {
env.store.push({
Expand Down Expand Up @@ -2042,7 +2043,7 @@ test("ManyArray notifies the array observers and flushes bindings when adding",
});
});

test("Passing a model as type to hasMany should not work", function(assert) {
testInDebug("Passing a model as type to hasMany should not work", function(assert) {
assert.expect(1);

assert.expectAssertion(function() {
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/relationships/inverse-relationships-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {createStore} from 'dummy/tests/helpers/store';
import setupStore from 'dummy/tests/helpers/store';
import Ember from 'ember';

import testInDebug from 'dummy/tests/helpers/test-in-debug';
import {module, test} from 'qunit';

import DS from 'ember-data';
Expand Down Expand Up @@ -424,7 +425,7 @@ test("When a record's polymorphic belongsTo relationship is set, it can specify
assert.equal(post.get('everyoneWeKnowMessages.length'), 0, "everyoneWeKnowMessages has no posts");
});

test("Inverse relationships that don't exist throw a nice error for a hasMany", function(assert) {
testInDebug("Inverse relationships that don't exist throw a nice error for a hasMany", function(assert) {
User = DS.Model.extend();
Comment = DS.Model.extend();

Expand All @@ -446,7 +447,7 @@ test("Inverse relationships that don't exist throw a nice error for a hasMany",
}, /We found no inverse relationships by the name of 'testPost' on the 'comment' model/);
});

test("Inverse relationships that don't exist throw a nice error for a belongsTo", function(assert) {
testInDebug("Inverse relationships that don't exist throw a nice error for a belongsTo", function(assert) {
User = DS.Model.extend();
Comment = DS.Model.extend();

Expand Down
3 changes: 2 additions & 1 deletion tests/integration/relationships/one-to-one-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import setupStore from 'dummy/tests/helpers/store';
import Ember from 'ember';

import testInDebug from 'dummy/tests/helpers/test-in-debug';
import {module, test} from 'qunit';

import DS from 'ember-data';
Expand Down Expand Up @@ -498,7 +499,7 @@ test("Setting a BelongsTo to a promise works when the promise returns null- asyn
});


test("Setting a BelongsTo to a promise that didn't come from a relationship errors out", function(assert) {
testInDebug("Setting a BelongsTo to a promise that didn't come from a relationship errors out", function(assert) {
var stanley, igor;
run(function() {
stanley = store.push({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import setupStore from 'dummy/tests/helpers/store';
import Ember from 'ember';

import testInDebug from 'dummy/tests/helpers/test-in-debug';
import {module, test} from 'qunit';

import DS from 'ember-data';
Expand Down Expand Up @@ -122,7 +123,7 @@ test("Setting the polymorphic belongsTo gets propagated to the inverse side - as
});
});

test("Setting the polymorphic belongsTo with an object that does not implement the mixin errors out", function(assert) {
testInDebug("Setting the polymorphic belongsTo with an object that does not implement the mixin errors out", function(assert) {
var user, video;
run(function() {
store.push({
Expand Down Expand Up @@ -193,7 +194,7 @@ test("Setting the polymorphic belongsTo gets propagated to the inverse side - mo
}
});

test("Setting the polymorphic belongsTo with an object that does not implement the mixin errors out - model injections true", function(assert) {
testInDebug("Setting the polymorphic belongsTo with an object that does not implement the mixin errors out - model injections true", function(assert) {
var injectionValue = Ember.MODEL_FACTORY_INJECTIONS;
Ember.MODEL_FACTORY_INJECTIONS = true;

Expand Down
Loading

0 comments on commit b3eb9c0

Please sign in to comment.