Merge pull request #433 from travis-ci/update-ember

Update Ember.js to 2.2.0 and Ember Data to 2.3.0
This commit is contained in:
Piotr Sarnacki 2016-01-14 13:22:32 +01:00
commit 8eaee33d6d
31 changed files with 220 additions and 201 deletions

View File

@ -1,8 +1,8 @@
import DS from 'ember-data';
import config from 'travis/config/environment';
import Ember from 'ember';
import ActiveModelAdapter from 'active-model-adapter';
export default DS.ActiveModelAdapter.extend({
export default ActiveModelAdapter.extend({
auth: Ember.inject.service(),
host: config.apiEndpoint,
coalesceFindRequests: true,

View File

@ -1,8 +1,8 @@
import Ember from 'ember';
import DS from 'ember-data';
import config from 'travis/config/environment';
import RESTAdapter from 'ember-data/adapters/rest';
export default DS.RESTAdapter.extend({
export default RESTAdapter.extend({
auth: Ember.inject.service(),
host: config.apiEndpoint,

View File

@ -1,5 +1,5 @@
import Ember from 'ember';
import Resolver from 'ember/resolver';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember/load-initializers';
import config from './config/environment';

View File

@ -1,4 +1,5 @@
import Ember from 'ember';
import config from 'travis/config/environment';
export default Ember.Controller.extend({
actions: {

View File

@ -8,14 +8,14 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="/images/favicon.png" />
{{content-for 'head'}}
{{content-for "head"}}
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,800' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="assets/vendor.css">
<link rel="stylesheet" href="assets/travis.css">
<link rel="mask-icon" href="images/favicon.svg" color="black">
{{content-for 'head-footer'}}
{{content-for "head-footer"}}
</head>
<body>
<noscript>
@ -30,12 +30,12 @@
</div>
</div>
</noscript>
{{content-for 'body'}}
{{content-for "body"}}
<script src="assets/vendor.js"></script>
<script src="assets/travis.js"></script>
{{content-for 'body-footer'}}
{{content-for "body-footer"}}
<a href="javascript:void(0)" class="feedback-button" id="userlikeCustomTab" data-right="20" data-bottom="50" data-orientation="top">Do you have a question?</a>
</body>

View File

@ -1,13 +1,13 @@
import Ember from 'ember';
import DS from 'ember-data';
import attr from 'ember-data/attr';
import Model from 'travis/models/model';
export default Model.extend({
name: DS.attr(),
type: DS.attr(),
avatarUrl: DS.attr(),
reposCount: DS.attr('number'),
subscribed: DS.attr('boolean'),
education: DS.attr('boolean'),
name: attr(),
type: attr(),
avatarUrl: attr(),
reposCount: attr('number'),
subscribed: attr('boolean'),
education: attr('boolean'),
loginBinding: 'id'
});

View File

@ -1,12 +1,13 @@
import Ember from 'ember';
import Model from 'travis/models/model';
import DS from 'ember-data';
import attr from 'ember-data/attr';
import { hasMany, belongsTo } from 'ember-data/relationships';
export default Model.extend({
name: DS.attr('string'),
defaultBranch: DS.attr('boolean'),
lastBuild: DS.belongsTo('build'),
name: attr('string'),
defaultBranch: attr('boolean'),
lastBuild: belongsTo('build'),
builds: DS.hasMany('builds', { inverse: 'branch' }),
repo: DS.belongsTo('repo', { inverse: 'defaultBranch' })
builds: hasMany('builds', { inverse: 'branch' }),
repo: belongsTo('repo', { inverse: 'defaultBranch' })
});

View File

@ -1,11 +1,11 @@
import Ember from 'ember';
import DS from 'ember-data';
import Model from 'travis/models/model';
import attr from 'ember-data/attr';
var indexOf = [].indexOf;
var Broadcast = Model.extend({
message: DS.attr(),
message: attr(),
toObject() {
return {

View File

@ -3,38 +3,39 @@ import configKeysMap from 'travis/utils/keys-map';
import Ember from 'ember';
import Model from 'travis/models/model';
import DurationCalculations from 'travis/utils/duration-calculations';
import DS from 'ember-data';
import Config from 'travis/config/environment';
import attr from 'ember-data/attr';
import { hasMany, belongsTo } from 'ember-data/relationships';
var Build;
if (Config.useV3API) {
Build = DS.Model.extend(DurationCalculations, {
branch: DS.belongsTo('branch', { async: false, inverse: 'builds' }),
Build = Model.extend(DurationCalculations, {
branch: belongsTo('branch', { async: false, inverse: 'builds' }),
branchName: Ember.computed.alias('branch.name')
});
} else {
Build = DS.Model.extend(DurationCalculations, {
Build = Model.extend(DurationCalculations, {
branchName: Ember.computed.alias('commit.branch')
});
}
Build.reopen({
ajax: Ember.inject.service(),
state: DS.attr(),
number: DS.attr('number'),
message: DS.attr('string'),
_duration: DS.attr('number'),
_config: DS.attr('object'),
_startedAt: DS.attr(),
_finishedAt: DS.attr('string'),
pullRequest: DS.attr('boolean'),
pullRequestTitle: DS.attr(),
pullRequestNumber: DS.attr('number'),
eventType: DS.attr('string'),
repo: DS.belongsTo('repo', { async: true }),
commit: DS.belongsTo('commit', { async: false }),
jobs: DS.hasMany('job', { async: true }),
state: attr(),
number: attr('number'),
message: attr('string'),
_duration: attr('number'),
_config: attr('object'),
_startedAt: attr(),
_finishedAt: attr('string'),
pullRequest: attr('boolean'),
pullRequestTitle: attr(),
pullRequestNumber: attr('number'),
eventType: attr('string'),
repo: belongsTo('repo', { async: true }),
commit: belongsTo('commit', { async: false }),
jobs: hasMany('job', { async: true }),
config: function() {
var config;

View File

@ -2,22 +2,23 @@ import Ember from 'ember';
import Model from 'travis/models/model';
import Build from 'travis/models/build';
import { gravatarImage } from 'travis/utils/urls';
import DS from 'ember-data';
import attr from 'ember-data/attr';
import { hasMany, belongsTo } from 'ember-data/relationships';
export default Model.extend({
sha: DS.attr(),
branch: DS.attr(),
message: DS.attr(),
compareUrl: DS.attr(),
authorName: DS.attr(),
authorEmail: DS.attr(),
committerName: DS.attr(),
committerEmail: DS.attr(),
committedAt: DS.attr(),
committerAvatarUrl: DS.attr(),
authorAvatarUrl: DS.attr(),
sha: attr(),
branch: attr(),
message: attr(),
compareUrl: attr(),
authorName: attr(),
authorEmail: attr(),
committerName: attr(),
committerEmail: attr(),
committedAt: attr(),
committerAvatarUrl: attr(),
authorAvatarUrl: attr(),
build: DS.belongsTo('build'),
build: belongsTo('build'),
subject: function() {
return this.get('message').split("\n", 1)[0];

View File

@ -1,10 +1,11 @@
import Ember from 'ember';
import Model from 'travis/models/model';
import DS from 'ember-data';
import attr from 'ember-data/attr';
import { hasMany, belongsTo } from 'ember-data/relationships';
export default Model.extend({
name: DS.attr(),
value: DS.attr(),
"public": DS.attr('boolean'),
repo: DS.belongsTo('repo', { async: true })
name: attr(),
value: attr(),
"public": attr('boolean'),
repo: belongsTo('repo', { async: true })
});

View File

@ -1,15 +1,16 @@
import Ember from 'ember';
import Model from 'travis/models/model';
import config from 'travis/config/environment';
import DS from 'ember-data';
import attr from 'ember-data/attr';
import { hasMany, belongsTo } from 'ember-data/relationships';
export default Model.extend({
name: DS.attr(),
ownerName: DS.attr(),
description: DS.attr(),
active: DS.attr('boolean'),
admin: DS.attr('boolean'),
"private": DS.attr('boolean'),
name: attr(),
ownerName: attr(),
description: attr(),
active: attr('boolean'),
admin: attr('boolean'),
"private": attr('boolean'),
account: function() {
return this.get('slug').split('/')[0];

View File

@ -4,25 +4,26 @@ import Ember from 'ember';
import Model from 'travis/models/model';
import Log from 'travis/models/log';
import DurationCalculations from 'travis/utils/duration-calculations';
import DS from 'ember-data';
import attr from 'ember-data/attr';
import { hasMany, belongsTo } from 'ember-data/relationships';
export default Model.extend(DurationCalculations, {
ajax: Ember.inject.service(),
logId: DS.attr(),
queue: DS.attr(),
state: DS.attr(),
number: DS.attr(),
_startedAt: DS.attr(),
_finishedAt: DS.attr(),
allowFailure: DS.attr('boolean'),
tags: DS.attr(),
repositoryPrivate: DS.attr(),
repositorySlug: DS.attr(),
_config: DS.attr('object'),
logId: attr(),
queue: attr(),
state: attr(),
number: attr(),
_startedAt: attr(),
_finishedAt: attr(),
allowFailure: attr('boolean'),
tags: attr(),
repositoryPrivate: attr(),
repositorySlug: attr(),
_config: attr('object'),
repo: DS.belongsTo('repo', { async: true }),
build: DS.belongsTo('build', { async: true }),
commit: DS.belongsTo('commit', { async: true }),
repo: belongsTo('repo', { async: true }),
build: belongsTo('build', { async: true }),
commit: belongsTo('commit', { async: true }),
branch: Ember.computed.alias('build.branch'),
branchName: Ember.computed.alias('build.branchName'),

View File

@ -1,2 +1,3 @@
import DS from 'ember-data';
export default DS.Model.extend();
import Model from 'ember-data/model';
export default Model.extend();

View File

@ -3,14 +3,15 @@ import Model from 'travis/models/model';
import { durationFrom as durationFromHelper } from 'travis/utils/helpers';
import Build from 'travis/models/build';
import Config from 'travis/config/environment';
import DS from 'ember-data';
import Ember from 'ember';
import attr from 'ember-data/attr';
import { hasMany, belongsTo } from 'ember-data/relationships';
var Repo;
if (Config.useV3API) {
Repo = Model.extend({
defaultBranch: DS.belongsTo('branch', {
defaultBranch: belongsTo('branch', {
async: false
}),
lastBuild: Ember.computed.oneWay('defaultBranch.lastBuild'),
@ -23,13 +24,13 @@ if (Config.useV3API) {
});
} else {
Repo = Model.extend({
lastBuildNumber: DS.attr('number'),
lastBuildState: DS.attr(),
lastBuildStartedAt: DS.attr(),
lastBuildFinishedAt: DS.attr(),
_lastBuildDuration: DS.attr('number'),
lastBuildLanguage: DS.attr(),
lastBuildId: DS.attr('number'),
lastBuildNumber: attr('number'),
lastBuildState: attr(),
lastBuildStartedAt: attr(),
lastBuildFinishedAt: attr(),
_lastBuildDuration: attr('number'),
lastBuildLanguage: attr(),
lastBuildId: attr('number'),
lastBuildHash: function() {
return {
@ -60,11 +61,11 @@ if (Config.useV3API) {
Repo.reopen({
ajax: Ember.inject.service(),
slug: DS.attr(),
description: DS.attr(),
"private": DS.attr('boolean'),
githubLanguage: DS.attr(),
active: DS.attr(),
slug: attr(),
description: attr(),
"private": attr('boolean'),
githubLanguage: attr(),
active: attr(),
withLastBuild() {
return this.filter(function(repo) {

View File

@ -1,22 +1,23 @@
import Ember from 'ember';
import Model from 'travis/models/model';
import DS from 'ember-data';
import attr from 'ember-data/attr';
import { hasMany, belongsTo } from 'ember-data/relationships';
export default Model.extend({
created_at: DS.attr(),
event_type: DS.attr(),
result: DS.attr(),
message: DS.attr(),
headCommit: DS.attr(),
baseCommit: DS.attr(),
branchName: DS.attr(),
tagName: DS.attr(),
pullRequest: DS.attr('boolean'),
pullRequestTitle: DS.attr(),
pullRequestNumber: DS.attr('number'),
repo: DS.belongsTo('repo', { async: true }),
commit: DS.belongsTo('commit', { async: true }),
build: DS.belongsTo('build', { async: true }),
created_at: attr(),
event_type: attr(),
result: attr(),
message: attr(),
headCommit: attr(),
baseCommit: attr(),
branchName: attr(),
tagName: attr(),
pullRequest: attr('boolean'),
pullRequestTitle: attr(),
pullRequestNumber: attr('number'),
repo: belongsTo('repo', { async: true }),
commit: belongsTo('commit', { async: true }),
build: belongsTo('build', { async: true }),
isAccepted: function() {
// For some reason some of the requests have a null result beside the fact that

View File

@ -1,10 +1,11 @@
import Ember from 'ember';
import DS from 'ember-data';
import Model from 'travis/models/model';
import attr from 'ember-data/attr';
import { hasMany, belongsTo } from 'ember-data/relationships';
export default Model.extend({
value: DS.attr(),
description: DS.attr(),
fingerprint: DS.attr(),
value: attr(),
description: attr(),
fingerprint: attr(),
isCustom: true
});

View File

@ -1,7 +1,8 @@
import Ember from 'ember';
import Model from 'travis/models/model';
import config from 'travis/config/environment';
import DS from 'ember-data';
import attr from 'ember-data/attr';
import { hasMany, belongsTo } from 'ember-data/relationships';
export default Model.extend({
ajax: Ember.inject.service(),
@ -9,14 +10,14 @@ export default Model.extend({
// TODO: this totally not should be needed here
sessionStorage: Ember.inject.service(),
name: DS.attr(),
email: DS.attr(),
login: DS.attr(),
token: DS.attr(),
gravatarId: DS.attr(),
isSyncing: DS.attr('boolean'),
syncedAt: DS.attr(),
repoCount: DS.attr('number'),
name: attr(),
email: attr(),
login: attr(),
token: attr(),
gravatarId: attr(),
isSyncing: attr('boolean'),
syncedAt: attr(),
repoCount: attr('number'),
fullName: function() {
return this.get('name') || this.get('login');

View File

@ -1,4 +1,3 @@
import DS from 'ember-data';
import V2FallbackSerializer from 'travis/serializers/v2_fallback';
export default V2FallbackSerializer.extend({

View File

@ -4,18 +4,10 @@ import V2FallbackSerializer from 'travis/serializers/v2_fallback';
var Serializer = V2FallbackSerializer.extend({
isNewSerializerAPI: true,
attrs: {
_config: {
key: 'config'
},
_finished_at: {
key: 'finished_at'
},
_started_at: {
key: 'started_at'
},
_duration: {
key: 'duration'
}
_config: { key: 'config' },
_finishedAt: { key: 'finished_at' },
_startedAt: { key: 'started_at' },
_duration: { key: 'duration' }
},
extractRelationships: function(modelClass, resourceHash) {

View File

@ -5,8 +5,8 @@ export default V2FallbackSerializer.extend({
isNewSerializerAPI: true,
attrs: {
_config: { key: 'config' },
_finished_at: { key: 'finished_at' },
_started_at: { key: 'started_at' }
_finishedAt: { key: 'finished_at' },
_startedAt: { key: 'started_at' }
},
keyForV2Relationship(key, typeClass, method) {

View File

@ -1,5 +1,5 @@
import Ember from 'ember';
import DS from 'ember-data';
import JSONSerializer from 'ember-data/serializers/json';
var traverse = function(object, callback) {
if(!object) {
@ -24,7 +24,7 @@ var traverse = function(object, callback) {
}
};
export default DS.JSONSerializer.extend({
export default JSONSerializer.extend({
isNewSerializerAPI: true,
extractRelationship(type, hash) {
@ -137,12 +137,8 @@ export default DS.JSONSerializer.extend({
return { data, included };
},
keyForAttribute(key, method) {
if(method === 'deserialize') {
return Ember.String.underscore(key);
} else {
return Ember.String.camelize(key);
}
keyForAttribute(key) {
return Ember.String.underscore(key);
},
_fixReferences(payload) {

View File

@ -1,15 +1,14 @@
{
"name": "travis",
"dependencies": {
"ember": "1.13.10",
"ember-cli-shims": "0.0.6",
"ember-cli-test-loader": "0.2.1",
"ember-data": "1.13.15",
"ember": "2.2.0",
"ember-cli-shims": "0.1.0",
"ember-cli-test-loader": "0.2.2",
"ember-load-initializers": "0.1.7",
"ember-qunit": "0.4.16",
"ember-qunit-notifications": "0.1.0",
"jquery": "~1.11.3",
"loader.js": "ember-cli/loader.js#3.2.1",
"loader.js": "^3.5.0",
"qunit": "~1.20.0",
"visibilityjs": "~1.2.1",
"JavaScript-MD5": "~1.1.0",
@ -18,5 +17,8 @@
"pusher": "~2.2.3",
"pretender": "0.1.0",
"ember-resolver": "~0.1.20"
},
"resolutions": {
"ember": "2.2.0"
}
}

View File

@ -22,5 +22,12 @@ window.deprecationWorkflow.config = {
{ handler: "log", matchMessage: "Using DS.Snapshot.get() is deprecated. Use .attr(), .belongsTo() or .hasMany() instead." },
{ handler: "log", matchMessage: "The filter API will be moved into a plugin soon. To enable store.filter using an environment flag, or to use an alternative, you can visit the ember-data-filter addon page" },
{ handler: "log", matchMessage: "Ember.View is deprecated. Consult the Deprecations Guide for a migration strategy." },
// TODO
{ handler: "silence", matchMessage: new RegExp("The `initialize` method for Application initializer .*? should take only one argument - `App`, an instance of an `Application`.") },
{ handler: "silence", matchMessage: "Using `ApplicationInstance.container.lookup` is deprecated. Please use `ApplicationInstance.lookup` instead." },
{ handler: "silence", matchMessage: "this.resource() is deprecated. Use this.route('name', { resetNamespace: true }, function () {}) instead." },
{ handler: "silence", matchMessage: new RegExp("the component:.*? test module is implicitly running in unit test mode, which will change to integration test mode by default in an upcoming version of ember-test-helpers. Add `unit: true` or a `needs:[]` list to explicitly opt in to unit test mode.") },
{ handler: "silence", matchMessage: "this.append() is deprecated. Please use this.render() or this.$() instead." }
]
};

View File

@ -19,29 +19,31 @@
"author": "",
"license": "MIT",
"devDependencies": {
"active-model-adapter": "2.0.3",
"broccoli-asset-rev": "^2.2.0",
"broccoli-sass": "0.6.6",
"ember-cli": "1.13.12",
"ember-ajax": "0.7.1",
"ember-cli": "2.2.0-beta.6",
"ember-cli-app-version": "^1.0.0",
"ember-cli-autoprefixer": "^0.3.0",
"ember-cli-babel": "5.1.5",
"ember-cli-dependency-checker": "^1.1.0",
"ember-cli-dependency-checker": "^1.2.0",
"ember-cli-deprecation-workflow": "0.1.5",
"ember-cli-document-title": "0.2.0",
"ember-cli-htmlbars": "1.0.1",
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
"ember-cli-ic-ajax": "0.2.4",
"ember-cli-inject-live-reload": "^1.3.1",
"ember-cli-inline-images": "^0.0.4",
"ember-cli-pretender": "0.3.1",
"ember-cli-qunit": "^1.0.4",
"ember-cli-qunit": "^1.1.0",
"ember-cli-release": "0.2.8",
"ember-cli-sauce": "^1.1.0",
"ember-cli-uglify": "1.2.0",
"ember-data": "1.13.15",
"ember-data": "^2.3.0",
"ember-data-filter": "1.13.0",
"ember-disable-proxy-controllers": "^1.0.1",
"ember-export-application-global": "^1.0.4",
"ember-resolver": "^2.0.3",
"ember-try": "0.0.7",
"emberx-select": "2.0.2"
}

View File

@ -1,4 +1,4 @@
import Resolver from 'ember/resolver';
import Resolver from 'ember-resolver';
import config from '../../config/environment';
const resolver = Resolver.create();

View File

@ -7,8 +7,8 @@
<meta name="description" content="Travis CI - Continuous Integration - Test and Deploy with Confidence">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{content-for 'head'}}
{{content-for 'test-head'}}
{{content-for "head"}}
{{content-for "test-head"}}
<link rel="stylesheet" href="assets/vendor.css">
<link rel="stylesheet" href="assets/travis.css">
@ -23,21 +23,21 @@
}
</style>
{{content-for 'head-footer'}}
{{content-for 'test-head-footer'}}
{{content-for "head-footer"}}
{{content-for "test-head-footer"}}
</head>
<body>
{{content-for 'body'}}
{{content-for 'test-body'}}
{{content-for "body"}}
{{content-for "test-body"}}
<script src="testem.js"></script>
<script src="assets/vendor.js"></script>
<script src="assets/test-support.js"></script>
<script src="assets/travis.js"></script>
<script src="testem.js"></script>
<script src="assets/tests.js"></script>
<script src="assets/test-loader.js"></script>
{{content-for 'body-footer'}}
{{content-for 'test-body-footer'}}
{{content-for "body-footer"}}
{{content-for "test-body-footer"}}
</body>
</html>

View File

@ -2,6 +2,7 @@ import Ember from 'ember';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import fillIn from '../../helpers/fill-in';
import DS from 'ember-data';
moduleForComponent('add-env-var', 'Integration | Component | add env-var', {
@ -11,12 +12,14 @@ moduleForComponent('add-env-var', 'Integration | Component | add env-var', {
test('it adds an env var on submit', function(assert) {
assert.expect(6);
var store = this.container.lookup('store:main');
assert.equal(store.all('envVar').get('length'), 0, 'precond: store should be empty');
// this shouldn't be needed, probably some bug in tests setup with new ember-data
this.registry.register('transform:boolean', DS.BooleanTransform);
var store = this.container.lookup('service:store');
assert.equal(store.peekAll('envVar').get('length'), 0, 'precond: store should be empty');
var repo;
Ember.run(function() {
repo = store.push('repo', {id: 1, slug: 'travis-ci/travis-web'});
repo = store.push({ data: { id: 1, type: 'repo', attributes: { slug: 'travis-ci/travis-web'}}});
});
this.set('repo', repo);
@ -28,9 +31,9 @@ test('it adds an env var on submit', function(assert) {
this.$('.form-submit').click();
assert.equal(store.all('envVar').get('length'), 1, 'env var should be added to store');
assert.equal(store.peekAll('envVar').get('length'), 1, 'env var should be added to store');
var envVar = store.all('envVar').objectAt(0);
var envVar = store.peekAll('envVar').objectAt(0);
assert.equal(envVar.get('name'), 'FOO', 'name should be set for the env var');
assert.equal(envVar.get('value'), 'bar', 'value should be set for the env var');
@ -62,12 +65,13 @@ test('it shows an error if no name is present', function(assert) {
test('it adds a public env var on submit', function(assert) {
assert.expect(6);
var store = this.container.lookup('store:main');
assert.equal(store.all('envVar').get('length'), 0, 'precond: store should be empty');
this.registry.register('transform:boolean', DS.BooleanTransform);
var store = this.container.lookup('service:store');
assert.equal(store.peekAll('envVar').get('length'), 0, 'precond: store should be empty');
var repo;
Ember.run(function() {
repo = store.push('repo', {id: 1, slug: 'travis-ci/travis-web'});
repo = store.push({data: { id: 1, type: 'repo', attributes: { slug: 'travis-ci/travis-web'}}});
});
this.set('repo', repo);
@ -81,9 +85,9 @@ test('it adds a public env var on submit', function(assert) {
this.$('.form-submit').click();
assert.equal(store.all('envVar').get('length'), 1, 'env var should be added to store');
assert.equal(store.peekAll('envVar').get('length'), 1, 'env var should be added to store');
var envVar = store.all('envVar').objectAt(0);
var envVar = store.peekAll('envVar').objectAt(0);
assert.equal(envVar.get('name'), 'FOO', 'name should be set for the env var');
assert.equal(envVar.get('value'), 'bar', 'value should be set for the env var');

View File

@ -2,7 +2,7 @@ import Ember from 'ember';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import fillIn from '../../helpers/fill-in';
import DS from 'ember-data';
moduleForComponent('add-ssh-key', 'Integration | Component | add ssh-key', {
integration: true
@ -11,18 +11,19 @@ moduleForComponent('add-ssh-key', 'Integration | Component | add ssh-key', {
test('it adds an ssh key on submit', function(assert) {
assert.expect(6);
var store = this.container.lookup('store:main');
this.registry.register('transform:boolean', DS.BooleanTransform);
var store = this.container.lookup('service:store');
var repo;
Ember.run(function() {
repo = store.push('repo', {id: 1, slug: 'travis-ci/travis-web'});
repo = store.push({data: { id: 1, type: 'repo', attributes: { slug: 'travis-ci/travis-web'}}});
});
this.set('repo', repo);
this.render(hbs`{{add-ssh-key repo=repo sshKeyAdded="sshKeyAdded"}}`);
var sshKey = store.all('ssh_key').objectAt(0);
var sshKey = store.peekAll('ssh_key').objectAt(0);
assert.ok(! sshKey.get('description'), 'description should be blank');
assert.ok(! sshKey.get('value'), 'value should be blank');
@ -45,18 +46,19 @@ test('it adds an ssh key on submit', function(assert) {
test('it throws an error if value for ssh key is blank', function(assert) {
assert.expect(5);
var store = this.container.lookup('store:main');
this.registry.register('transform:boolean', DS.BooleanTransform);
var store = this.container.lookup('service:store');
var repo;
Ember.run(function() {
repo = store.push('repo', {id: 1, slug: 'travis-ci/travis-web'});
repo = store.push({data: { id: 1, type: 'repo', attributes: { slug: 'travis-ci/travis-web'}}});
});
this.set('repo', repo);
this.render(hbs`{{add-ssh-key repo=repo sshKeyAdded="sshKeyAdded"}}`);
var sshKey = store.all('ssh_key').objectAt(0);
var sshKey = store.peekAll('ssh_key').objectAt(0);
assert.ok(! sshKey.get('description'), 'description should be blank');
assert.ok(! sshKey.get('value'), 'value should be blank');

View File

@ -2,6 +2,7 @@ import Ember from 'ember';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import fillIn from '../../helpers/fill-in';
import DS from 'ember-data';
moduleForComponent('env-var', 'Integration | Component | env-var', {
@ -11,9 +12,10 @@ moduleForComponent('env-var', 'Integration | Component | env-var', {
test('it renders an env-var with private value', function(assert) {
assert.expect(2);
var store = this.container.lookup('store:main');
this.registry.register('transform:boolean', DS.BooleanTransform);
var store = this.container.lookup('service:store');
Ember.run(() => {
var envVar = store.push('envVar', {id: 1, name: 'foo', value: 'bar', public: false});
var envVar = store.push({data: { id: 1, type: 'env-var', attributes: { name: 'foo', value: 'bar', public: false}}});
this.set('envVar', envVar);
});
@ -27,23 +29,24 @@ test('it renders an env-var with private value', function(assert) {
test('it renders an env-var with public value', function(assert) {
assert.expect(2);
var store = this.container.lookup('store:main');
this.registry.register('transform:boolean', DS.BooleanTransform);
var store = this.container.lookup('service:store');
Ember.run(() => {
var envVar = store.push('envVar', {id: 1, name: 'foo', value: 'bar', public: true});
var envVar = store.push({data: { id: 1, type: 'env-var', attributes: { name: 'foo', value: 'bar', public: true}}});
this.set('envVar', envVar);
});
this.render(hbs`{{env-var envVar=envVar}}`);
assert.equal(this.$('.env-var-name').text(), 'foo', 'name should be displayed');
assert.equal(this.$('.env-var-value input').val(), 'bar', 'value should be hidden');
assert.equal(this.$('.env-var-value input').val(), 'bar', 'value should not be hidden');
});
// test('it deletes an env-var', function(assert) {
// assert.expect(2);
// var store = this.container.lookup('store:main');
// var store = this.container.lookup('service:store');
// Ember.run(() => {
// var envVar = store.push('envVar', {id: 1, name: 'foo', value: 'bar', public: true});
// this.set('envVar', envVar);
@ -51,10 +54,10 @@ test('it renders an env-var with public value', function(assert) {
// this.render(hbs`{{env-var envVar=envVar}}`);
// assert.equal(store.all('envVar').get('length'), 1, 'precond: store should have an env-var');
// assert.equal(store.peekAll('envVar').get('length'), 1, 'precond: store should have an env-var');
// this.$('.env-var-action a').click();
// assert.equal(store.all('envVar').get('length'), 0, 'env-var should be deleted');
// assert.equal(store.peekAll('envVar').get('length'), 0, 'env-var should be deleted');
// });

View File

@ -11,7 +11,7 @@ moduleForComponent('ssh-key', 'Integration | Component | ssh-key', {
test('it renders the default ssh key if no custom key is set', function(assert) {
assert.expect(2);
var store = this.container.lookup('store:main');
var store = this.container.lookup('service:store');
var key = Ember.Object.create({fingerprint: 'fingerprint'});
this.set('key', key);
@ -25,11 +25,11 @@ test('it renders the default ssh key if no custom key is set', function(assert)
test('it renders the custom ssh key if custom key is set', function(assert) {
assert.expect(2);
var store = this.container.lookup('store:main');
var store = this.container.lookup('service:store');
var key;
Ember.run(function() {
key = store.push('sshKey', {description: 'fookey', fingerprint: 'somethingthing', id: 1});
key = store.push({data: { id: 1, type: 'ssh-key', attributes: { description: 'fookey', fingerprint: 'somethingthing' }}});
});
this.set('key', key);
@ -44,11 +44,11 @@ test('it renders the custom ssh key if custom key is set', function(assert) {
test('it deletes a custom key if permissions are right', function(assert) {
assert.expect(1);
var store = this.container.lookup('store:main');
var store = this.container.lookup('service:store');
var key;
Ember.run(function() {
key = store.push('sshKey', {description: 'fookey', fingerprint: 'somethingthing', id: 1});
key = store.push({data: { id: 1, type: 'ssh-key', attributes: { description: 'fookey', fingerprint: 'somethingthing' }}});
});
this.set('key', key);
@ -67,11 +67,11 @@ test('it deletes a custom key if permissions are right', function(assert) {
test('it does not delete the custom key if permissions are insufficient', function(assert) {
assert.expect(1);
var store = this.container.lookup('store:main');
var store = this.container.lookup('service:store');
var key;
Ember.run(function() {
key = store.push('sshKey', {description: 'fookey', fingerprint: 'somethingthing', id: 1});
key = store.push({data: { id: 1, type: 'ssh-key', attributes: { description: 'fookey', fingerprint: 'somethingthing' }}});
});
this.set('key', key);