diff --git a/.eslintrc.js b/.eslintrc.js index 5e5e2e709..ec678c27b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -12,34 +12,10 @@ module.exports = { 'browser': true }, rules: { - 'comma-dangle': 'off', - 'spaced-comment': 'off', - 'object-shorthand': 'off', - 'quotes': 'off', - 'brace-style': 'off', - 'max-statements-per-line': 'off', - 'keyword-spacing': 'off', - 'no-var': 'off', - 'space-in-parens': 'off', - 'indent': 'off', - 'space-infix-ops': 'off', - 'operator-linebreak': 'off', - 'object-curly-spacing': 'off', - 'dot-notation': 'off', 'no-console': 'off', - 'prefer-template': 'off', - 'space-before-function-paren': 'off', - 'comma-spacing': 'off', - 'no-multiple-empty-lines': 'off', 'camelcase': 'off', - 'key-spacing': 'off', 'new-cap': 'off', - 'space-before-blocks': 'off', - 'ember-suave/no-const-outside-module-scope': 'off', - 'ember-suave/no-direct-property-access': 'off', - 'ember-suave/prefer-destructuring': 'off', 'ember-suave/require-access-in-comments': 'off', - 'ember-suave/require-const-for-ember-properties': 'off' }, globals: { 'server': true, diff --git a/app/abilities/organization.js b/app/abilities/organization.js index c7058b4a9..87eebe8de 100644 --- a/app/abilities/organization.js +++ b/app/abilities/organization.js @@ -2,10 +2,13 @@ import Ember from 'ember'; import { Ability } from 'ember-can'; const { - computed: { alias, empty, notEmpty, or } + computed: { alias, empty, notEmpty, or }, + inject: { service } } = Ember; export default Ability.extend({ + credentials: service(), + isAtLeastAdmin: or('membership.isAdmin', 'membership.isOwner'), userCanJoinOrganization: empty('membership'), userCanLeaveOrganization: or('membership.isContributor', 'membership.isAdmin'), @@ -18,5 +21,8 @@ export default Ability.extend({ canCreateIssueTask: true, canCreateIdeaTask: true, - canCreateTaskTask: alias('isAtLeastContributor') + canCreateTaskTask: alias('isAtLeastContributor'), + + membership: alias('credentials.currentUserMembership'), + organization: alias('model') }); diff --git a/app/adapters/application.js b/app/adapters/application.js index a2052bb05..f5e30cbd3 100644 --- a/app/adapters/application.js +++ b/app/adapters/application.js @@ -2,7 +2,9 @@ import DS from 'ember-data'; import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin'; import ENV from 'code-corps-ember/config/environment'; -export default DS.JSONAPIAdapter.extend(DataAdapterMixin, { +const { JSONAPIAdapter } = DS; + +export default JSONAPIAdapter.extend(DataAdapterMixin, { authorizer: 'authorizer:token', // TODO: Fix this once many-to-many lands in ember-cli-mirage @@ -10,5 +12,5 @@ export default DS.JSONAPIAdapter.extend(DataAdapterMixin, { // all possible cases coalesceFindRequests: true, - host: ENV.API_BASE_URL, + host: ENV.API_BASE_URL }); diff --git a/app/adapters/comment.js b/app/adapters/comment.js index 42bc595a3..6ca2042cb 100644 --- a/app/adapters/comment.js +++ b/app/adapters/comment.js @@ -1,10 +1,12 @@ import ApplicationAdapter from './application'; import Ember from 'ember'; +const { get } = Ember; + export default ApplicationAdapter.extend({ // need to delete slug and sluggedRouteSlug properties from the query. // otherwise, they will get auto-added to the end of our url - sortQueryParams: function(query) { + sortQueryParams(query) { query = query || {}; if (query.taskId) { delete query.taskId; @@ -14,28 +16,32 @@ export default ApplicationAdapter.extend({ } }, - urlForQuery: function(query) { + urlForQuery(query) { query = query || {}; // if there are slug and sluggedRouteSlug properties in the query, we // need to build the url as (prefix/)host/sluggedRouteSlug/slug if (query.taskId) { - var url = []; - var host = Ember.get(this, 'host'); - var prefix = this.urlPrefix(); + let url = []; + let host = get(this, 'host'); + let prefix = this.urlPrefix(); url.push(encodeURIComponent('tasks')); url.push(encodeURIComponent(query.taskId)); url.push(encodeURIComponent('comments')); - if (prefix) { url.unshift(prefix); } + if (prefix) { + url.unshift(prefix); + } url = url.join('/'); - if (!host && url) { url = '/' + url; } + if (!host && url) { + url = `/${url}`; + } return url; } else { return this._super.apply(arguments); } - }, + } }); diff --git a/app/adapters/project.js b/app/adapters/project.js index 61cf592fe..3fd49ef3b 100644 --- a/app/adapters/project.js +++ b/app/adapters/project.js @@ -1,10 +1,12 @@ import Ember from 'ember'; import ApplicationAdapter from './application'; +const { get } = Ember; + export default ApplicationAdapter.extend({ // need to delete properties from the query which we do not want to see // appended to the end of the url as parameters - sortQueryParams: function(query) { + sortQueryParams(query) { query = query || {}; if (query.slug) { @@ -17,21 +19,25 @@ export default ApplicationAdapter.extend({ return query; }, - urlForQuery: function(query) { + urlForQuery(query) { query = query || {}; if (query.sluggedRouteSlug) { - var url = []; - var host = Ember.get(this, 'host'); - var prefix = this.urlPrefix(); + let url = []; + let host = get(this, 'host'); + let prefix = this.urlPrefix(); url.push(encodeURIComponent(query.sluggedRouteSlug)); - url.push("projects"); + url.push('projects'); - if (prefix) { url.unshift(prefix); } + if (prefix) { + url.unshift(prefix); + } url = url.join('/'); - if (!host && url) { url = '/' + url; } + if (!host && url) { + url = `/${url}`; + } return url; } else { @@ -39,27 +45,31 @@ export default ApplicationAdapter.extend({ } }, - urlForQueryRecord: function(query) { + urlForQueryRecord(query) { query = query || {}; // if there are slug and sluggedRouteSlug properties in the query, we // need to build the url as (prefix/)host/sluggedRouteSlug/slug if (query.slug && query.sluggedRouteSlug) { - var url = []; - var host = Ember.get(this, 'host'); - var prefix = this.urlPrefix(); + let url = []; + let host = get(this, 'host'); + let prefix = this.urlPrefix(); url.push(encodeURIComponent(query.sluggedRouteSlug)); url.push(encodeURIComponent(query.slug)); - if (prefix) { url.unshift(prefix); } + if (prefix) { + url.unshift(prefix); + } url = url.join('/'); - if (!host && url) { url = '/' + url; } + if (!host && url) { + url = `/${url}`; + } return url; } else { return this._super.apply(arguments); } - }, + } }); diff --git a/app/adapters/slugged-route.js b/app/adapters/slugged-route.js index 9a9c9d63d..2e37adfb0 100644 --- a/app/adapters/slugged-route.js +++ b/app/adapters/slugged-route.js @@ -1,10 +1,12 @@ import Ember from 'ember'; import ApplicationAdapter from './application'; +const { get } = Ember; + export default ApplicationAdapter.extend({ // need to drop out the slug query parameter, // otherwise it will get auto-added to the end of the url - sortQueryParams: function(query) { + sortQueryParams(query) { query = query || {}; if (query.slug) { @@ -14,26 +16,30 @@ export default ApplicationAdapter.extend({ return query; }, - urlForQueryRecord: function(query) { + urlForQueryRecord(query) { query = query || {}; // if the query contains a slug property, then the URL for the slugged route // is formed as (prefix/)(host)/slug if (query.slug) { - var url = []; - var host = Ember.get(this, 'host'); - var prefix = this.urlPrefix(); + let url = []; + let host = get(this, 'host'); + let prefix = this.urlPrefix(); url.push(encodeURIComponent(query.slug)); - if (prefix) { url.unshift(prefix); } + if (prefix) { + url.unshift(prefix); + } url = url.join('/'); - if (!host && url) { url = '/' + url; } + if (!host && url) { + url = `/${url}`; + } return url; } else { return this._super.apply(arguments); } - }, + } }); diff --git a/app/adapters/task.js b/app/adapters/task.js index fd674113f..365f55e5f 100644 --- a/app/adapters/task.js +++ b/app/adapters/task.js @@ -11,7 +11,7 @@ const { export default ApplicationAdapter.extend({ // need to delete slug and sluggedRouteSlug properties from the query. // otherwise, they will get auto-added to the end of our url - sortQueryParams: function(query) { + sortQueryParams(query) { query = query || {}; // to preserve a clean url with just `&page=X` we only @@ -48,18 +48,22 @@ export default ApplicationAdapter.extend({ urlForQuery(query) { if (query.projectId) { - var url = []; - var host = get(this, 'host'); - var prefix = this.urlPrefix(); + let url = []; + let host = get(this, 'host'); + let prefix = this.urlPrefix(); url.push(encodeURIComponent('projects')); url.push(encodeURIComponent(query.projectId)); url.push(encodeURIComponent('tasks')); - if (prefix) { url.unshift(prefix); } + if (prefix) { + url.unshift(prefix); + } url = url.join('/'); - if (!host && url) { url = '/' + url; } + if (!host && url) { + url = `/${url}`; + } return url; } else { @@ -67,15 +71,15 @@ export default ApplicationAdapter.extend({ } }, - urlForQueryRecord: function(query) { + urlForQueryRecord(query) { query = query || {}; // if there are slug and sluggedRouteSlug properties in the query, we // need to build the url as (prefix/)host/sluggedRouteSlug/slug if (query.number && query.projectId) { - var url = []; - var host = get(this, 'host'); - var prefix = this.urlPrefix(); + let url = []; + let host = get(this, 'host'); + let prefix = this.urlPrefix(); url.push(encodeURIComponent('projects')); url.push(encodeURIComponent(query.projectId)); @@ -84,10 +88,14 @@ export default ApplicationAdapter.extend({ delete query.number; - if (prefix) { url.unshift(prefix); } + if (prefix) { + url.unshift(prefix); + } url = url.join('/'); - if (!host && url) { url = '/' + url; } + if (!host && url) { + url = `/${url}`; + } return url; } else { diff --git a/app/adapters/user.js b/app/adapters/user.js index 59135d300..b76d97634 100644 --- a/app/adapters/user.js +++ b/app/adapters/user.js @@ -19,18 +19,22 @@ export default ApplicationAdapter.extend({ }, urlForProfileEdit() { - var url = []; - var host = get(this, 'host'); - var prefix = this.urlPrefix(); + let url = []; + let host = get(this, 'host'); + let prefix = this.urlPrefix(); url.push(encodeURIComponent('users')); url.push(encodeURIComponent(get(this, 'currentUser.user.id'))); - if (prefix) { url.unshift(prefix); } + if (prefix) { + url.unshift(prefix); + } url = url.join('/'); - if (!host && url) { url = '/' + url; } + if (!host && url) { + url = `/${url}`; + } return url; - }, + } }); diff --git a/app/app.js b/app/app.js index 831ad6106..570bcc410 100644 --- a/app/app.js +++ b/app/app.js @@ -3,11 +3,13 @@ import Resolver from './resolver'; import loadInitializers from 'ember-load-initializers'; import config from './config/environment'; +const { Application } = Ember; + let App; Ember.MODEL_FACTORY_INJECTIONS = true; -App = Ember.Application.extend({ +App = Application.extend({ modulePrefix: config.modulePrefix, podModulePrefix: config.podModulePrefix, Resolver diff --git a/app/components/categories-list.js b/app/components/categories-list.js index a2e5d8517..ff3769d1c 100644 --- a/app/components/categories-list.js +++ b/app/components/categories-list.js @@ -1,5 +1,10 @@ import Ember from 'ember'; +const { + Component, + computed + } = Ember; + /** * `categories-list` composes the list of categories * @@ -13,7 +18,7 @@ import Ember from 'ember'; * @module Component * @extends Ember.Component */ -export default Ember.Component.extend({ +export default Component.extend({ classNames: ['categories-list'], /** @@ -31,5 +36,5 @@ export default Ember.Component.extend({ * @property sortedCategories * @type Array */ - sortedCategories: Ember.computed.sort('categories', 'sortByName'), + sortedCategories: computed.sort('categories', 'sortByName') }); diff --git a/app/components/category-item.js b/app/components/category-item.js index 318b1966e..e44d3cfbe 100644 --- a/app/components/category-item.js +++ b/app/components/category-item.js @@ -6,7 +6,7 @@ const { computed, get, inject: { service }, - set, + set } = Ember; /** @@ -102,7 +102,7 @@ export default Component.extend({ }).finally(() => { set(this, 'isLoading', false); }); - }, + } }, /** @@ -116,11 +116,11 @@ export default Component.extend({ let flashMessages = get(this, 'flashMessages'); flashMessages.clearMessages(); return flashMessages.add({ - message: message, + message, type: 'danger', fixed: true, sticky: false, - timeout: 5000, + timeout: 5000 }); - }, + } }); diff --git a/app/components/code-theme-selector.js b/app/components/code-theme-selector.js index c3ca0088a..f52a011c4 100644 --- a/app/components/code-theme-selector.js +++ b/app/components/code-theme-selector.js @@ -4,7 +4,7 @@ import { alias } from 'ember-computed'; const { Component, get, - inject: { service }, + inject: { service } } = Ember; /** @@ -40,5 +40,5 @@ export default Component.extend({ */ click() { get(this, 'codeTheme').toggle(); - }, + } }); diff --git a/app/components/comment-item.js b/app/components/comment-item.js index ba6404e17..b8f173fc9 100644 --- a/app/components/comment-item.js +++ b/app/components/comment-item.js @@ -7,7 +7,7 @@ const { get, inject: { service }, isEqual, - set, + set } = Ember; /** @@ -114,13 +114,13 @@ export default Component.extend({ component.set('isEditing', false); this._fetchMentions(comment); }).catch((error) => { - let payloadContainsValidationErrors = error.errors.some((error) => error.status === 422 ); + let payloadContainsValidationErrors = error.errors.some((error) => error.status === 422); if (!payloadContainsValidationErrors) { this.controllerFor('project.tasks.task').set('error', error); } }); - }, + } }, /** @@ -146,5 +146,5 @@ export default Component.extend({ _prefetchMentions(comment) { let body = get(this, 'mentionFetcher').prefetchBodyWithMentions(comment, 'comment'); set(this, 'commentBodyWithMentions', body); - }, + } }); diff --git a/app/components/create-comment-form.js b/app/components/create-comment-form.js index 20e98ac3e..d235e79a5 100644 --- a/app/components/create-comment-form.js +++ b/app/components/create-comment-form.js @@ -41,6 +41,6 @@ export default Component.extend({ let comment = get(this, 'comment'); this.sendAction('saveComment', comment); - }, - }, + } + } }); diff --git a/app/components/demo-categories.js b/app/components/demo-categories.js index 68a3d3c1f..5b0a21166 100644 --- a/app/components/demo-categories.js +++ b/app/components/demo-categories.js @@ -3,6 +3,7 @@ import { task, timeout } from 'ember-concurrency'; const { Component, + Object, observer, run: { later }, testing @@ -14,27 +15,27 @@ const CONCURRENCY_TIMEOUT = testing ? 0 : 1500; export default Component.extend({ categories: [ - Ember.Object.create({ - description: "You want to improve government responsiveness.", + Object.create({ + description: 'You want to improve government responsiveness.', isLoading: false, - name: "Government", + name: 'Government', selected: false, - slug: "government" + slug: 'government' }), - Ember.Object.create({ - description: "You want to improve tools for advancing science.", + Object.create({ + description: 'You want to improve tools for advancing science.', isLoading: false, - name: "Science", + name: 'Science', selected: false, - slug: "science" + slug: 'science' }), - Ember.Object.create({ - description: "You want to improve software tools and infrastructure.", + Object.create({ + description: 'You want to improve software tools and infrastructure.', isLoading: false, - name: "Technology", + name: 'Technology', selected: false, - slug: "technology" - }), + slug: 'technology' + }) ], classNames: ['demo-categories'], @@ -59,5 +60,5 @@ export default Component.extend({ category.set('isLoading', false); }, LOADING_TOGGLE); yield timeout(CONCURRENCY_TIMEOUT); - }).enqueue(), + }).enqueue() }); diff --git a/app/components/demo-category-item.js b/app/components/demo-category-item.js index b7584ba2c..5b69ce44c 100644 --- a/app/components/demo-category-item.js +++ b/app/components/demo-category-item.js @@ -1,5 +1,7 @@ import Ember from 'ember'; -export default Ember.Component.extend({ - classNames: ['category-item'], +const { Component } = Ember; + +export default Component.extend({ + classNames: ['category-item'] }); diff --git a/app/components/demo-projects.js b/app/components/demo-projects.js index 32694edd2..fa894f079 100644 --- a/app/components/demo-projects.js +++ b/app/components/demo-projects.js @@ -1,100 +1,105 @@ import Ember from 'ember'; -export default Ember.Component.extend({ +const { + Component, + Object +} = Ember; + +export default Component.extend({ classNames: ['demo-projects'], projects: [ - Ember.Object.create({ - title: "Code Corps", - description: "Building a better future together. Contribute to public software for social good.", - iconLargeUrl: "https://d3pgew4wbk2vb1.cloudfront.net/images/cc-demo.png", - organizationName: "Code Corps", + Object.create({ + title: 'Code Corps', + description: 'Building a better future together. Contribute to public software for social good.', + iconLargeUrl: 'https://d3pgew4wbk2vb1.cloudfront.net/images/cc-demo.png', + organizationName: 'Code Corps', categories: [ { - name: "Society", + name: 'Society', selected: false, - slug: "society" + slug: 'society' }, { - name: "Technology", + name: 'Technology', selected: true, - slug: "technology" - }, + slug: 'technology' + } ], skills: [ { - title: "Ember.js", - matched: true, + title: 'Ember.js', + matched: true }, { - title: "HTML", - matched: true, + title: 'HTML', + matched: true }, { - title: "Rails", - matched: true, + title: 'Rails', + matched: true }, { - title: "Ruby", - matched: true, + title: 'Ruby', + matched: true }, { - title: "Copywriting", - matched: false, + title: 'Copywriting', + matched: false }, { - title: "CSS", - matched: false, - }, - ], + title: 'CSS', + matched: false + } + ] }), - Ember.Object.create({ - title: "Movement", - description: "We help people elect their representatives and then hold them accountable.", - iconLargeUrl: "https://d3pgew4wbk2vb1.cloudfront.net/images/movement-demo.png", - organizationName: "Movement", + Object.create({ + title: 'Movement', + description: 'We help people elect their representatives and then hold them accountable.', + iconLargeUrl: 'https://d3pgew4wbk2vb1.cloudfront.net/images/movement-demo.png', + organizationName: 'Movement', categories: [ { - name: "Government", + name: 'Government', selected: true, - slug: "government" + slug: 'government' }, { - name: "Politics", + name: 'Politics', selected: false, - slug: "politics" + slug: 'politics' }, { - name: "Society", + name: 'Society', selected: false, - slug: "society" - }, + slug: 'society' + } ], skills: [ { - title: "Rails", - matched: true, + title: 'Rails', + matched: true }, { - title: "Ruby", - matched: true, + title: 'Ruby', + matched: true }, { - title: "Amazon S3", - matched: false, + title: 'Amazon S3', + matched: false }, { - title: "iOS", - matched: false, + title: 'iOS', + matched: false }, { - title: "PostgreSQL", - matched: false, + title: 'PostgreSQL', + matched: false }, { - title: "Swift", - matched: false, - }, - ], - }), - ], + title: 'Swift', + matched: false + } + ] + }) + ] }); diff --git a/app/components/demo-skills.js b/app/components/demo-skills.js index 068156080..b6787d6f2 100644 --- a/app/components/demo-skills.js +++ b/app/components/demo-skills.js @@ -3,55 +3,57 @@ import { task, timeout } from 'ember-concurrency'; const { Component, + Object, + observer, run: { later } } = Ember; export default Component.extend({ skills: [ - Ember.Object.create({ + Object.create({ isLoading: false, - title: "BASIC" + title: 'BASIC' }), - Ember.Object.create({ + Object.create({ isLoading: false, - title: "Copywriting" + title: 'Copywriting' }), - Ember.Object.create({ + Object.create({ isLoading: false, - title: "Ember.js" + title: 'Ember.js' }), - Ember.Object.create({ + Object.create({ isLoading: false, - title: "HTML" + title: 'HTML' }), - Ember.Object.create({ + Object.create({ isLoading: false, - title: "Python" + title: 'Python' }), - Ember.Object.create({ + Object.create({ isLoading: false, - title: "Rails" + title: 'Rails' }), - Ember.Object.create({ + Object.create({ isLoading: false, - title: "Ruby" + title: 'Ruby' }), - Ember.Object.create({ + Object.create({ isLoading: false, - title: "SEO" + title: 'SEO' }), - Ember.Object.create({ + Object.create({ isLoading: false, - title: "Sketch" + title: 'Sketch' }), - Ember.Object.create({ + Object.create({ isLoading: false, - title: "UX Design" - }), + title: 'UX Design' + }) ], classNames: ['demo-skills'], - _animateItems: Ember.observer('animated', function() { + _animateItems: observer('animated', function() { if (this.get('animated')) { let skills = this.get('skills'); let indexesToAnimate = [2, 3, 5, 6, 8, 9]; @@ -72,5 +74,5 @@ export default Component.extend({ skill.set('isLoading', false); }, 700); yield timeout(1000); - }).enqueue(), + }).enqueue() }); diff --git a/app/components/demo-tasks.js b/app/components/demo-tasks.js index 60af5e9ee..7370ec210 100644 --- a/app/components/demo-tasks.js +++ b/app/components/demo-tasks.js @@ -1,78 +1,83 @@ import Ember from 'ember'; import moment from 'moment'; -export default Ember.Component.extend({ +const { + Component, + Object +} = Ember; + +export default Component.extend({ classNames: ['demo-tasks'], tasks: [ - Ember.Object.create({ + Object.create({ insertedAt: moment().subtract(2, 'days'), number: 27, taskType: 'task', - title: "Improve the user experience of the landing page", + title: 'Improve the user experience of the landing page', user: { - username: "joshsmith" + username: 'joshsmith' }, skills: [ { - title: "Rails", - matched: true, + title: 'Rails', + matched: true }, { - title: "Ruby", - matched: true, + title: 'Ruby', + matched: true }, { - title: "Amazon S3", - matched: false, + title: 'Amazon S3', + matched: false }, { - title: "iOS", - matched: false, + title: 'iOS', + matched: false }, { - title: "PostgreSQL", - matched: false, + title: 'PostgreSQL', + matched: false }, { - title: "Swift", - matched: false, - }, - ], + title: 'Swift', + matched: false + } + ] }), - Ember.Object.create({ + Object.create({ insertedAt: moment().subtract(3, 'days'), number: 26, taskType: 'issue', title: "When signing up, there doesn't seem to be a GitHub option", user: { - username: "githubber" + username: 'githubber' }, skills: [ { - title: "Rails", - matched: true, + title: 'Rails', + matched: true }, { - title: "Ruby", - matched: true, + title: 'Ruby', + matched: true }, { - title: "Amazon S3", - matched: false, + title: 'Amazon S3', + matched: false }, { - title: "iOS", - matched: false, + title: 'iOS', + matched: false }, { - title: "PostgreSQL", - matched: false, + title: 'PostgreSQL', + matched: false }, { - title: "Swift", - matched: false, - }, - ], - }), + title: 'Swift', + matched: false + } + ] + }) ] }); diff --git a/app/components/drag-zone.js b/app/components/drag-zone.js index 8695e25cf..516fd5340 100644 --- a/app/components/drag-zone.js +++ b/app/components/drag-zone.js @@ -17,5 +17,5 @@ export default Component.extend({ dragOver() { get(this, 'dragState').dragging(); - }, + } }); diff --git a/app/components/editor-with-preview.js b/app/components/editor-with-preview.js index 18e6e06ee..2ff6e86eb 100644 --- a/app/components/editor-with-preview.js +++ b/app/components/editor-with-preview.js @@ -1,7 +1,7 @@ import Ember from 'ember'; import { equal, - or, + or } from 'ember-computed'; const { @@ -10,7 +10,9 @@ const { get, inject: { service }, isEmpty, + run, set, + String } = Ember; /** @@ -116,11 +118,11 @@ export default Component.extend({ @type String */ style: computed('height', function() { - const height = get(this, 'height'); + let height = get(this, 'height'); if (height) { - const css = "min-height: " + height + ";"; - return Ember.String.htmlSafe(css); + let css = `min-height: ${height};`; + return String.htmlSafe(css); } }), @@ -142,7 +144,7 @@ export default Component.extend({ */ didRender() { this._super(...arguments); - Ember.run.scheduleOnce('afterRender', this, '_attemptFocus'); + run.scheduleOnce('afterRender', this, '_attemptFocus'); }, /** @@ -198,7 +200,7 @@ export default Component.extend({ set(this, 'mode', 'previewing'); set(this, 'previewedOnce', true); this._fetchPreview(); - }, + } }, _fetchPreview() { @@ -212,8 +214,8 @@ export default Component.extend({ set(this, 'fetchingPreview', false); } else { let preview = get(this, 'store').createRecord('preview', { - markdown: markdown, - user: this.get('currentUser.user'), + markdown, + user: this.get('currentUser.user') }); preview.save().then((preview) => { this.get('mentionFetcher').fetchBodyWithMentions(preview, 'preview').then((body) => { @@ -242,5 +244,5 @@ export default Component.extend({ _focusTextarea() { this.$('textarea').focus(); set(this, 'textareaFocused', true); - }, + } }); diff --git a/app/components/error-formatter.js b/app/components/error-formatter.js index 2b83d0649..abcb8687e 100644 --- a/app/components/error-formatter.js +++ b/app/components/error-formatter.js @@ -40,5 +40,5 @@ export default Component.extend({ return (this.get('error.errors') || []).map((e) => { return `${e.title}: ${e.detail}`; }); - }), + }) }); diff --git a/app/components/error-wrapper.js b/app/components/error-wrapper.js index 27fec40b4..98ce64d8f 100644 --- a/app/components/error-wrapper.js +++ b/app/components/error-wrapper.js @@ -14,7 +14,7 @@ const { ## default usage ```Handlebars - {{error-wrapper model=model}} + {{error-wrapper error=model}} ``` @class error-wrapper @@ -34,7 +34,7 @@ export default Component.extend({ @type String */ errorClass: computed('is404', function() { - if(this.get('is404')) { + if (this.get('is404')) { return 'warning'; } else { return 'danger'; @@ -49,10 +49,10 @@ export default Component.extend({ */ // Map the HTTP status codes into an array or // an empty array if there are no such status codes - httpStatusCodes: computed('model', function() { - let model = this.get('model'); - if (model && model.hasOwnProperty('errors')) { - let errors = model.errors; + httpStatusCodes: computed('error', function() { + let error = this.get('error'); + if (error && error.hasOwnProperty('errors')) { + let { errors } = error; return errors.map(function(err) { return err.status; }); @@ -106,5 +106,5 @@ export default Component.extend({ updateBackground() { this.set('background.class', this.get('errorClass')); this.get('background').updateBackgroundClass(); - }, + } }); diff --git a/app/components/flash-messages.js b/app/components/flash-messages.js index dc7cc2407..24862aa6a 100644 --- a/app/components/flash-messages.js +++ b/app/components/flash-messages.js @@ -8,5 +8,5 @@ const { export default Component.extend({ classNames: ['flash'], - flashMessages: service(), + flashMessages: service() }); diff --git a/app/components/image-drop.js b/app/components/image-drop.js index c83cd4c58..87aff92ad 100644 --- a/app/components/image-drop.js +++ b/app/components/image-drop.js @@ -6,7 +6,8 @@ const { computed, computed: { alias, notEmpty, or }, inject: { service }, - on + on, + run } = Ember; export default Component.extend({ @@ -17,10 +18,10 @@ export default Component.extend({ 'active', 'circle:is-circular', 'isDraggingOnApp:is-dragging', - 'hasImage', + 'hasImage' ], droppedImage: null, - helpText: "Drop your image here.", + helpText: 'Drop your image here.', originalImage: null, appDragState: service('dragState'), @@ -31,7 +32,7 @@ export default Component.extend({ isDraggingOnApp: alias('appDragState.isDragging'), style: computed('droppedImage', 'originalImage', function() { - let backgroundStyle = ""; + let backgroundStyle = ''; if (this.get('droppedImage')) { backgroundStyle = `background-image: url(${this.get('droppedImage')});`; @@ -43,25 +44,25 @@ export default Component.extend({ }), setup: on('willInsertElement', function() { - const $input = this.$('input'); + let $input = this.$('input'); $input.on('change', (event) => { this.handleFileDrop(event.target.files[0]); }); }), convertImgToBase64URL(url, callback, outputFormat) { - var img = new Image(); + let img = new Image(); img.crossOrigin = 'Anonymous'; - img.onload = function(){ - var canvas = document.createElement('CANVAS'); - var ctx = canvas.getContext('2d'); - var dataURL; - canvas.height = this.height; - canvas.width = this.width; - ctx.drawImage(this, 0, 0); - dataURL = canvas.toDataURL(outputFormat); - callback(dataURL); - canvas = null; + img.onload = function() { + let canvas = document.createElement('CANVAS'); + let ctx = canvas.getContext('2d'); + let dataURL; + canvas.height = this.height; + canvas.width = this.width; + ctx.drawImage(this, 0, 0); + dataURL = canvas.toDataURL(outputFormat); + callback(dataURL); + canvas = null; }; img.src = url; }, @@ -102,15 +103,15 @@ export default Component.extend({ } this.set('file', file); - var reader = new FileReader(); + let reader = new FileReader(); reader.onload = (e) => { - var fileToUpload = e.target.result; - Ember.run(() => { + let fileToUpload = e.target.result; + run(() => { this.set('droppedImage', fileToUpload); this.dragEnded(); }); }; reader.readAsDataURL(file); - }, + } }); diff --git a/app/components/landing-subsection.js b/app/components/landing-subsection.js index 3a50f671f..427ad0a44 100644 --- a/app/components/landing-subsection.js +++ b/app/components/landing-subsection.js @@ -21,7 +21,7 @@ export default Component.extend(CanAnimateMixin, { }), style: computed('minHeight', function() { - let css = 'min-height: ' + this.get('minHeight') + 'px;'; + let css = `min-height: ${this.get('minHeight') }px;`; return htmlSafe(css); - }), + }) }); diff --git a/app/components/login-form.js b/app/components/login-form.js index 8f287eb41..9650d9afe 100644 --- a/app/components/login-form.js +++ b/app/components/login-form.js @@ -4,7 +4,7 @@ const { Component, get, inject: { service }, - set, + set } = Ember; /** @@ -42,9 +42,8 @@ export default Component.extend({ let credentials = this.getProperties('identification', 'password'); get(this, 'session').authenticate('authenticator:jwt', credentials).catch((reason) => { - console.log(reason); set(this, 'errors', reason.error || reason); }); - }, - }, + } + } }); diff --git a/app/components/member-list-item.js b/app/components/member-list-item.js index d2074fb2b..72350aa43 100644 --- a/app/components/member-list-item.js +++ b/app/components/member-list-item.js @@ -16,28 +16,28 @@ export default Component.extend({ approve(membership) { membership.set('role', 'contributor'); return membership.save().then(() => { - this._flashSuccess("Membership approved"); + this._flashSuccess('Membership approved'); }); }, deny(membership) { - if (confirm("Are you sure want to deny their membership?")) { + if (confirm('Are you sure want to deny their membership?')) { return membership.destroyRecord().then(() => { - this._flashSuccess("Membership denied"); + this._flashSuccess('Membership denied'); }); } - }, + } }, _flashSuccess(message) { - const flashMessages = get(this, 'flashMessages'); + let flashMessages = get(this, 'flashMessages'); flashMessages.clearMessages(); return flashMessages.add({ - message: message, + message, type: 'success', fixed: true, sticky: false, - timeout: 5000, + timeout: 5000 }); - }, + } }); diff --git a/app/components/navigation-menu.js b/app/components/navigation-menu.js index d71c99da6..6c241bf8e 100644 --- a/app/components/navigation-menu.js +++ b/app/components/navigation-menu.js @@ -43,5 +43,5 @@ export default Component.extend({ @property session @type Ember.Service */ - session: service(), + session: service() }); diff --git a/app/components/organization-header.js b/app/components/organization-header.js index 5c1e9a172..3f787eb2a 100644 --- a/app/components/organization-header.js +++ b/app/components/organization-header.js @@ -10,5 +10,5 @@ export default Component.extend({ classNameBindings: ['expanded'], expanded: false, - credentials: service(), + credentials: service() }); diff --git a/app/components/organization-menu.js b/app/components/organization-menu.js index 4377f268c..f99c3bb76 100644 --- a/app/components/organization-menu.js +++ b/app/components/organization-menu.js @@ -8,5 +8,5 @@ const { export default Component.extend({ classNames: ['organization-menu', 'horizontal-menu'], - credentials: service(), + credentials: service() }); diff --git a/app/components/organization-profile.js b/app/components/organization-profile.js index 786eac1c9..4e70c10ff 100644 --- a/app/components/organization-profile.js +++ b/app/components/organization-profile.js @@ -16,5 +16,5 @@ export default Component.extend({ didReceiveAttrs() { this._super(...arguments); this.get('credentials').set('currentOrganization', this.get('organization')); - }, + } }); diff --git a/app/components/organization-settings-form.js b/app/components/organization-settings-form.js index 641afd895..d7ce0983b 100644 --- a/app/components/organization-settings-form.js +++ b/app/components/organization-settings-form.js @@ -13,10 +13,10 @@ export default Component.extend({ actions: { save() { - const flashMessages = get(this, 'flashMessages'); + let flashMessages = get(this, 'flashMessages'); get(this, 'organization').save().then(() => { - flashMessages.success("Organization updated successfully"); + flashMessages.success('Organization updated successfully'); }); - }, - }, + } + } }); diff --git a/app/components/organization-settings-menu.js b/app/components/organization-settings-menu.js index 4f1d24918..15aff244c 100644 --- a/app/components/organization-settings-menu.js +++ b/app/components/organization-settings-menu.js @@ -9,5 +9,5 @@ export default Component.extend({ classNames: ['organization-settings-menu', 'settings-menu'], credentials: service(), - session: service(), + session: service() }); diff --git a/app/components/organization-settings.js b/app/components/organization-settings.js index 6e705e676..00d6fa37e 100644 --- a/app/components/organization-settings.js +++ b/app/components/organization-settings.js @@ -1,3 +1,5 @@ import Ember from 'ember'; -export default Ember.Component.extend({}); +const { Component } = Ember; + +export default Component.extend({}); diff --git a/app/components/pager-control.js b/app/components/pager-control.js index 10f1336d9..db59365a0 100644 --- a/app/components/pager-control.js +++ b/app/components/pager-control.js @@ -18,7 +18,7 @@ export default Component.extend({ totalPages: alias('options.totalPages'), totalRecords: alias('options.totalRecords'), - bounds: computed('centerPage', 'pagesToShow', 'totalPages', function () { + bounds: computed('centerPage', 'pagesToShow', 'totalPages', function() { let pagesToShow = this.get('pagesToShow'); let totalPages = this.get('totalPages'); @@ -44,7 +44,7 @@ export default Component.extend({ let pagesToShow = this.get('pagesToShow'); let minCenterPage = Math.ceil(pagesToShow / 2); - return (currentPage >= minCenterPage) ? currentPage: minCenterPage; + return (currentPage >= minCenterPage) ? currentPage : minCenterPage; }), nextPage: computed('currentPage', function() { @@ -52,14 +52,13 @@ export default Component.extend({ }), onLastPage: computed('currentPage', 'totalPages', 'hasOnePage', function() { - return this.get('currentPage') === this.get('totalPages') || - this.get('hasOnePage'); + return this.get('currentPage') === this.get('totalPages') || this.get('hasOnePage'); }), pages: computed('bounds', function() { let bounds = this.get('bounds'); - var pages = []; + let pages = []; for (let i = bounds.lower; i <= bounds.upper; i++) { pages.push(i); } @@ -69,5 +68,5 @@ export default Component.extend({ previousPage: computed('currentPage', function() { return this.get('currentPage') - 1; - }), + }) }); diff --git a/app/components/progress-bar-container.js b/app/components/progress-bar-container.js index f25c8099b..821e41fe5 100644 --- a/app/components/progress-bar-container.js +++ b/app/components/progress-bar-container.js @@ -1,7 +1,7 @@ import Ember from 'ember'; const { - Component, + Component } = Ember; /** @@ -18,5 +18,5 @@ const { @extends Ember.Component */ export default Component.extend({ - classNames: ['progress-bar-container'], + classNames: ['progress-bar-container'] }); diff --git a/app/components/progress-bar.js b/app/components/progress-bar.js index 752f1d873..da7bc60b3 100644 --- a/app/components/progress-bar.js +++ b/app/components/progress-bar.js @@ -3,7 +3,7 @@ import Ember from 'ember'; const { Component, String: { htmlSafe }, - computed, + computed } = Ember; /** @@ -33,9 +33,9 @@ export default Component.extend({ @type String */ style: computed('percentage', function() { - const percentage = this.get('percentage') || 0; - const css = 'width: ' + percentage + '%;'; + let percentage = this.get('percentage') || 0; + let css = `width: ${percentage}%;`; return htmlSafe(css); - }), + }) }); diff --git a/app/components/project-card-skills.js b/app/components/project-card-skills.js index 60b526f8a..e5eb62936 100644 --- a/app/components/project-card-skills.js +++ b/app/components/project-card-skills.js @@ -2,7 +2,7 @@ import Ember from 'ember'; const { Component, - set, + set } = Ember; /** @@ -71,6 +71,6 @@ export default Component.extend({ */ skillItemHidden() { set(this, 'showToggle', true); - }, - }, + } + } }); diff --git a/app/components/project-categories-list.js b/app/components/project-categories-list.js index 40efc60fd..3c4b7abeb 100644 --- a/app/components/project-categories-list.js +++ b/app/components/project-categories-list.js @@ -31,5 +31,5 @@ export default Component.extend({ @property sortedCategories @type Ember.Array */ - sortedCategories: sort('categories', 'sortByName'), + sortedCategories: sort('categories', 'sortByName') }); diff --git a/app/components/project-category-item.js b/app/components/project-category-item.js index 7bcb9569b..485b2419b 100644 --- a/app/components/project-category-item.js +++ b/app/components/project-category-item.js @@ -65,5 +65,5 @@ export default Component.extend({ let category = this.get('category'); let userCategories = this.get('userCategories'); return userCategories.findUserCategory(category); - }), + }) }); diff --git a/app/components/project-container.js b/app/components/project-container.js index 2d3a8fd57..a00646bd6 100644 --- a/app/components/project-container.js +++ b/app/components/project-container.js @@ -6,5 +6,5 @@ const { } = Ember; export default Component.extend({ - store: service(), + store: service() }); diff --git a/app/components/project-item.js b/app/components/project-item.js index b46712fdc..5c842334a 100644 --- a/app/components/project-item.js +++ b/app/components/project-item.js @@ -1,5 +1,7 @@ import Ember from 'ember'; -export default Ember.Component.extend({ - classNames: ['project-item'], +const { Component } = Ember; + +export default Component.extend({ + classNames: ['project-item'] }); diff --git a/app/components/project-list.js b/app/components/project-list.js index 520a39113..479e2d63c 100644 --- a/app/components/project-list.js +++ b/app/components/project-list.js @@ -1,5 +1,7 @@ import Ember from 'ember'; -export default Ember.Component.extend({ - classNames: ['project-list'], +const { Component } = Ember; + +export default Component.extend({ + classNames: ['project-list'] }); diff --git a/app/components/project-long-description.js b/app/components/project-long-description.js index 428c74b9f..24b78d351 100644 --- a/app/components/project-long-description.js +++ b/app/components/project-long-description.js @@ -3,7 +3,8 @@ import Ember from 'ember'; const { Component, computed: { or }, - inject: { service } + inject: { service }, + isPresent } = Ember; /** @@ -103,7 +104,7 @@ export default Component.extend({ }, _inferrIfAddingDescription() { - if (Ember.isPresent(this.get('project.longDescriptionBody'))) { + if (isPresent(this.get('project.longDescriptionBody'))) { this.set('descriptionIsBlank', false); } else { this.set('descriptionIsBlank', true); diff --git a/app/components/project-menu.js b/app/components/project-menu.js index a69da5ff9..7f33cafc9 100644 --- a/app/components/project-menu.js +++ b/app/components/project-menu.js @@ -37,5 +37,5 @@ export default Component.extend({ @property session @type Ember.Service */ - session: service(), + session: service() }); diff --git a/app/components/project-settings-form.js b/app/components/project-settings-form.js index a6e582f75..9e6485bbf 100644 --- a/app/components/project-settings-form.js +++ b/app/components/project-settings-form.js @@ -13,10 +13,11 @@ export default Component.extend({ actions: { save() { - const flashMessages = get(this, 'flashMessages'); + let flashMessages = get(this, 'flashMessages'); this.get('project').save().then(() => { - flashMessages.success("Project updated successfully"); + flashMessages.success('Project updated successfully'); }); - }, - }}); + } + } +}); diff --git a/app/components/project-settings-menu.js b/app/components/project-settings-menu.js index f022b9387..6e5e0ae8f 100644 --- a/app/components/project-settings-menu.js +++ b/app/components/project-settings-menu.js @@ -9,5 +9,5 @@ export default Component.extend({ classNames: ['project-settings-menu', 'settings-menu'], credentials: service(), - session: service(), + session: service() }); diff --git a/app/components/project-task-list.js b/app/components/project-task-list.js index 70efdce14..8dbfa72d3 100644 --- a/app/components/project-task-list.js +++ b/app/components/project-task-list.js @@ -92,17 +92,17 @@ export default Component.extend({ */ filterByStatus(status) { this.sendAction('filterByStatus', status); - }, + } }, _normalizeMeta(meta) { if (isPresent(meta)) { return { - currentPage: parseInt(meta["current_page"], 10), - pageSize: parseInt(meta["page_size"], 10), - totalPages: parseInt(meta["total_pages"], 10), - totalRecords: parseInt(meta["total_records"]) + currentPage: parseInt(meta.current_page, 10), + pageSize: parseInt(meta.page_size, 10), + totalPages: parseInt(meta.total_pages, 10), + totalRecords: parseInt(meta.total_records) }; } - }, + } }); diff --git a/app/components/role-item.js b/app/components/role-item.js index 4da5329a6..51d331764 100644 --- a/app/components/role-item.js +++ b/app/components/role-item.js @@ -45,18 +45,18 @@ export default Component.extend({ }).finally(() => { this.set('isLoading', false); }); - }, + } }, _flashError(message) { - const flashMessages = get(this, 'flashMessages'); + let flashMessages = get(this, 'flashMessages'); flashMessages.clearMessages(); return flashMessages.add({ - message: message, + message, type: 'danger', fixed: true, sticky: false, - timeout: 5000, + timeout: 5000 }); - }, + } }); diff --git a/app/components/scroll-top.js b/app/components/scroll-top.js index 1b0fb9070..4ed2d6c11 100644 --- a/app/components/scroll-top.js +++ b/app/components/scroll-top.js @@ -1,7 +1,9 @@ import Ember from 'ember'; -export default Ember.Component.extend({ +const { Component } = Ember; + +export default Component.extend({ click() { - window.scrollTo(0,0); - }, + window.scrollTo(0, 0); + } }); diff --git a/app/components/select-dropdown.js b/app/components/select-dropdown.js index 7a66bbfb9..8bdd133a9 100644 --- a/app/components/select-dropdown.js +++ b/app/components/select-dropdown.js @@ -1,12 +1,14 @@ import Ember from 'ember'; -export default Ember.Component.extend({ +const { Component } = Ember; + +export default Component.extend({ classNames: ['select-dropdown'], classNameBindings: ['selectedItem'], actions: { selectItem(item) { this.set('selectedItem', item); - }, - }, + } + } }); diff --git a/app/components/select-option.js b/app/components/select-option.js index 48a08aa5d..ed2ac58e7 100644 --- a/app/components/select-option.js +++ b/app/components/select-option.js @@ -6,7 +6,7 @@ const { } = Ember; export default Component.extend({ - attributeBindings: ['value','selected'], + attributeBindings: ['value', 'selected'], tagName: 'option', label: computed('optionLabelPath', 'item', function() { @@ -21,5 +21,5 @@ export default Component.extend({ value: computed('optionValuePath', 'item', function() { let value = this.get('optionValuePath'); return value && this.get(`item.${value}`); - }), + }) }); diff --git a/app/components/signup-email-input.js b/app/components/signup-email-input.js index ba59e9b3a..e53c12f2b 100644 --- a/app/components/signup-email-input.js +++ b/app/components/signup-email-input.js @@ -40,8 +40,7 @@ export default Component.extend({ checkAvailable() { let email = this.get('email'); this.sendRequest(email).then((result) => { - let available = result.available; - let valid = result.valid; + let { available, valid } = result; let validation = valid && available; this.set('cachedEmail', this.get('email')); @@ -63,7 +62,7 @@ export default Component.extend({ return this.get('ajax').request('/users/email_available', { method: 'GET', data: { - email: email + email } }); }, @@ -73,7 +72,7 @@ export default Component.extend({ if (this.get('isNotSameEmail')) { this.set('isChecking', true); } - }, + } }, _check() { @@ -92,5 +91,5 @@ export default Component.extend({ this.sendAction('emailValidated', false); this.set('isChecking', false); } - }, + } }); diff --git a/app/components/signup-form.js b/app/components/signup-form.js index 9fb873f76..337fa0e3b 100644 --- a/app/components/signup-form.js +++ b/app/components/signup-form.js @@ -45,7 +45,7 @@ export default Component.extend({ usernameValidated(result) { this.set('usernameValid', result); - }, + } }, _setError() { @@ -59,7 +59,7 @@ export default Component.extend({ }, _shakeButton() { - if(!this.get('hasError')) { + if (!this.get('hasError')) { this.set('hasError', true); later(this, function() { this.set('hasError', false); @@ -76,11 +76,11 @@ export default Component.extend({ this.get('user').save().then(() => { this._signIn(credentials); }).catch((error) => { - let payloadContainsValidationErrors = error.errors.some((error) => error.status === 422 ); + let payloadContainsValidationErrors = error.errors.some((error) => error.status === 422); if (!payloadContainsValidationErrors) { this.controllerFor('signup').set('error', error); } }); - }, + } }); diff --git a/app/components/signup-password-input.js b/app/components/signup-password-input.js index c88640708..85b85b21b 100644 --- a/app/components/signup-password-input.js +++ b/app/components/signup-password-input.js @@ -26,14 +26,14 @@ export default Component.extend({ return this.get('user.password') || ''; }), - strength: computed('password', function () { + strength: computed('password', function() { let password = this.get('password') || ''; return strength(password); }), strengthPercentage: computed('isValid', 'passwordLength', 'strength', function() { let isValid = this.get('isValid'); - var percentage = 0; + let percentage = 0; if (isValid) { let score = this.get('strength.score'); @@ -43,5 +43,5 @@ export default Component.extend({ } return percentage; - }), + }) }); diff --git a/app/components/signup-username-input.js b/app/components/signup-username-input.js index 4ce154e4a..cc4220e5e 100644 --- a/app/components/signup-username-input.js +++ b/app/components/signup-username-input.js @@ -197,8 +197,7 @@ export default Component.extend({ checkAvailable() { let username = this.get('username'); this.sendRequest(username).then((result) => { - let available = result.available; - let valid = result.valid; + let { available, valid } = result; let validation = valid && available; this.set('cachedUsername', this.get('username')); @@ -222,7 +221,7 @@ export default Component.extend({ return this.get('ajax').request('/users/username_available', { method: 'GET', data: { - username: username + username } }); }, @@ -239,7 +238,7 @@ export default Component.extend({ if (this.get('isNotSameUsername')) { this.set('isChecking', true); } - }, + } }, _check() { @@ -258,5 +257,5 @@ export default Component.extend({ this.sendAction('usernameValidated', false); this.set('isChecking', false); } - }, + } }); diff --git a/app/components/site-footer.js b/app/components/site-footer.js index e643822b2..4b13650f3 100644 --- a/app/components/site-footer.js +++ b/app/components/site-footer.js @@ -1,5 +1,7 @@ import Ember from 'ember'; -export default Ember.Component.extend({ +const { Component } = Ember; + +export default Component.extend({ classNames: ['site-footer'] }); diff --git a/app/components/skill-button.js b/app/components/skill-button.js index 49c106836..d1c5706db 100644 --- a/app/components/skill-button.js +++ b/app/components/skill-button.js @@ -33,6 +33,6 @@ export default Component.extend({ removeSkill(skill) { let userSkills = this.get('userSkills'); userSkills.removeSkill(skill); - }, - }, + } + } }); diff --git a/app/components/skill-list-item.js b/app/components/skill-list-item.js index 1e38d489d..9f02685ae 100644 --- a/app/components/skill-list-item.js +++ b/app/components/skill-list-item.js @@ -31,5 +31,5 @@ export default Component.extend({ if (elementBottom > parentBottom) { this.sendAction(); } - }, + } }); diff --git a/app/components/skill-list-items.js b/app/components/skill-list-items.js index 5ad8c93c2..e6174ff37 100644 --- a/app/components/skill-list-items.js +++ b/app/components/skill-list-items.js @@ -25,7 +25,9 @@ export default Component.extend({ let userSkillsService = get(this, 'userSkillsService'); if (userSkillsService) { let hasSkill = userSkillsService.hasSkill(skill); - if (hasSkill) { return skill; } + if (hasSkill) { + return skill; + } } }), @@ -36,6 +38,6 @@ export default Component.extend({ actions: { skillItemHidden() { this.sendAction('skillItemHidden'); - }, + } } }); diff --git a/app/components/slugged-route-model-details.js b/app/components/slugged-route-model-details.js index cbd73abe9..667a2c413 100644 --- a/app/components/slugged-route-model-details.js +++ b/app/components/slugged-route-model-details.js @@ -1,5 +1,7 @@ import Ember from 'ember'; -export default Ember.Component.extend({ - classNames: ['slugged-route-model-details'], +const { Component } = Ember; + +export default Component.extend({ + classNames: ['slugged-route-model-details'] }); diff --git a/app/components/submittable-textarea.js b/app/components/submittable-textarea.js index 5c32c01d8..872e7b608 100644 --- a/app/components/submittable-textarea.js +++ b/app/components/submittable-textarea.js @@ -1,22 +1,24 @@ import Ember from 'ember'; -export default Ember.TextArea.extend({ - keyDown: function(event) { +const { TextArea } = Ember; + +export default TextArea.extend({ + keyDown(event) { if (this._isValidCombination(event)) { event.preventDefault(); this.sendAction('modifiedSubmit'); } }, - _hasCorrectModifier: function(event) { + _hasCorrectModifier(event) { return event.ctrlKey || event.metaKey; }, - _isCorrectKeyCode: function(keyCode) { + _isCorrectKeyCode(keyCode) { return keyCode === 13; }, - _isValidCombination: function(event) { + _isValidCombination(event) { return this._hasCorrectModifier(event) && this._isCorrectKeyCode(event.keyCode); } }); diff --git a/app/components/task-comment-list.js b/app/components/task-comment-list.js index d25ef807e..fd1717346 100644 --- a/app/components/task-comment-list.js +++ b/app/components/task-comment-list.js @@ -1,5 +1,7 @@ import Ember from 'ember'; +const { Component } = Ember; + /** The task-comment-list component composes the list of comments for a task. @@ -13,6 +15,6 @@ import Ember from 'ember'; @module Component @extends Ember.Component */ -export default Ember.Component.extend({ +export default Component.extend({ classNames: ['task-comment-list'] }); diff --git a/app/components/task-details.js b/app/components/task-details.js index 6c5fab530..5a3567dd5 100644 --- a/app/components/task-details.js +++ b/app/components/task-details.js @@ -92,7 +92,6 @@ export default Component.extend({ this.set('isEditingBody', false); }, - /** Action that sets the corresponding task to edit mode. @@ -108,19 +107,12 @@ export default Component.extend({ @method saveTaskBody */ - saveTaskBody() { - const component = this; - const task = this.get('task'); + applyEditTask() { + let task = this.get('task'); - task.save().then((task) => { - component.set('isEditingBody', false); + this.get('saveTask')(task).then((task) => { + this.set('isEditingBody', false); this._fetchMentions(task); - }).catch((error) => { - let payloadContainsValidationErrors = error.errors.some((error) => error.status === 422 ); - - if (!payloadContainsValidationErrors) { - this.controllerFor('project.tasks.task').set('error', error); - } }); } }, @@ -138,7 +130,6 @@ export default Component.extend({ }); }, - /** Parses the body of text and prefetches mentions. @@ -147,8 +138,8 @@ export default Component.extend({ @private */ _prefetchMentions(task) { - const body = this.get('mentionFetcher').prefetchBodyWithMentions(task, 'task'); + let body = this.get('mentionFetcher').prefetchBodyWithMentions(task, 'task'); this.set('taskBodyWithMentions', body); - }, + } }); diff --git a/app/components/task-filter-dropdown.js b/app/components/task-filter-dropdown.js index 4a4d34eba..da56a84a3 100644 --- a/app/components/task-filter-dropdown.js +++ b/app/components/task-filter-dropdown.js @@ -1,5 +1,7 @@ import Ember from 'ember'; +const { Component } = Ember; + /** The task-filter-dropdown component composes the filter dropdown list that is used for selecting filters for the list of tasks. @@ -15,7 +17,7 @@ import Ember from 'ember'; @module Component @extends Ember.Component */ -export default Ember.Component.extend({ +export default Component.extend({ classNames: ['dropdown-menu'], tagName: 'ul', @@ -49,6 +51,6 @@ export default Ember.Component.extend({ */ hide() { this.sendAction('hide'); - }, + } } }); diff --git a/app/components/task-filter-type.js b/app/components/task-filter-type.js index 58ee03941..58c9aafc7 100644 --- a/app/components/task-filter-type.js +++ b/app/components/task-filter-type.js @@ -1,5 +1,7 @@ import Ember from 'ember'; +const { Component } = Ember; + /** The task-filter-type component composes the selected filter and dropdown list of selectable filters. It takes in a list of selectable filter types @@ -14,7 +16,7 @@ import Ember from 'ember'; @module Component @extends Ember.Component */ -export default Ember.Component.extend({ +export default Component.extend({ classNames: ['button-group', 'dropdown'], classNameBindings: ['active:menu-visible:menu-hidden'], @@ -56,6 +58,6 @@ export default Ember.Component.extend({ */ toggle() { this.toggleProperty('active'); - }, - }, + } + } }); diff --git a/app/components/task-header.js b/app/components/task-header.js index b9ed6a2b8..7d80f4fec 100644 --- a/app/components/task-header.js +++ b/app/components/task-header.js @@ -1,5 +1,7 @@ import Ember from 'ember'; +const { Component } = Ember; + /** The task-header component represents the header of a task. It is composed of the task icon & title. @@ -14,7 +16,7 @@ import Ember from 'ember'; @module Component @extends Ember.Component */ -export default Ember.Component.extend({ +export default Component.extend({ classNames: ['task-header'], classNameBindings: ['task.taskType'] }); diff --git a/app/components/task-item.js b/app/components/task-item.js index f4b34f2bb..7f053a0c1 100644 --- a/app/components/task-item.js +++ b/app/components/task-item.js @@ -1,5 +1,7 @@ import Ember from 'ember'; +const { Component } = Ember; + /** The task-item component is used to present a task in the list of tasks. @@ -13,7 +15,7 @@ import Ember from 'ember'; @module Component @extends Ember.Component */ -export default Ember.Component.extend({ +export default Component.extend({ classNames: ['task-item'], classNameBindings: ['task.taskType'] }); diff --git a/app/components/task-new-form.js b/app/components/task-new-form.js index d612f4e2c..44cb66094 100644 --- a/app/components/task-new-form.js +++ b/app/components/task-new-form.js @@ -38,9 +38,9 @@ export default Component.extend({ @type Object */ placeholders: { - task: "How can you describe the steps to complete the task so anyone can work on it?", + task: 'How can you describe the steps to complete the task so anyone can work on it?', issue: "What issue needs resolved? If it's a bug, how can anyone reproduce it?", - idea: "What's your idea? Be specific so people can give more accurate feedback.", + idea: "What's your idea? Be specific so people can give more accurate feedback." }, /** @@ -53,7 +53,7 @@ export default Component.extend({ placeholder: computed('task.taskType', function() { let taskType = this.get('task.taskType'); if (taskType) { - return this.get(`placeholders.$(taskType)`); + return this.get('placeholders.$(taskType)'); } }), @@ -68,6 +68,6 @@ export default Component.extend({ submit() { let task = this.get('task'); this.sendAction('saveTask', task); - }, - }, + } + } }); diff --git a/app/components/task-status-button.js b/app/components/task-status-button.js index aa9254854..0aebb9dbc 100644 --- a/app/components/task-status-button.js +++ b/app/components/task-status-button.js @@ -47,6 +47,6 @@ export default Component.extend({ let task = this.get('task'); task.set('status', 'open'); return task.save(); - }, + } } }); diff --git a/app/components/task-status.js b/app/components/task-status.js index 133513e9d..7849fa8a0 100644 --- a/app/components/task-status.js +++ b/app/components/task-status.js @@ -2,7 +2,7 @@ import Ember from 'ember'; const { Component, - computed: { alias }, + computed: { alias } } = Ember; /** @@ -21,5 +21,5 @@ const { export default Component.extend({ classNames: ['task-status-badge'], - status: alias('task.status'), + status: alias('task.status') }); diff --git a/app/components/task-title.js b/app/components/task-title.js index f81470878..5f9960608 100644 --- a/app/components/task-title.js +++ b/app/components/task-title.js @@ -2,7 +2,7 @@ import Ember from 'ember'; const { Component, - computed: { alias }, + computed, inject: { service } } = Ember; @@ -27,7 +27,7 @@ export default Component.extend({ @property canEdit @type Boolean */ - canEdit: alias('currentUserIsTaskAuthor'), + canEdit: computed.alias('currentUserIsTaskAuthor'), /** Returns the current user's ID. @@ -35,7 +35,7 @@ export default Component.extend({ @property currentUserId @type Number */ - currentUserId: alias('currentUser.user.id'), + currentUserId: computed.alias('currentUser.user.id'), /** Returns the task author's ID. @@ -43,7 +43,7 @@ export default Component.extend({ @property taskAuthorId @type Number */ - taskAuthorId: alias('task.user.id'), + taskAuthorId: computed.alias('task.user.id'), /** Consumes `currentUserId` and `taskAuthorId` and returns if the current user @@ -52,7 +52,7 @@ export default Component.extend({ @property currentUserIsTaskAuthor @type Boolean */ - currentUserIsTaskAuthor: Ember.computed('currentUserId', 'taskAuthorId', function() { + currentUserIsTaskAuthor: computed('currentUserId', 'taskAuthorId', function() { let userId = parseInt(this.get('currentUserId'), 10); let authorId = parseInt(this.get('taskAuthorId'), 10); return userId === authorId; @@ -61,7 +61,7 @@ export default Component.extend({ init() { this._super(...arguments); this.setProperties({ - isEditing: false, + isEditing: false }); }, @@ -93,21 +93,15 @@ export default Component.extend({ @method save */ - save() { + applyEdit() { let component = this; let task = this.get('task'); let newTitle = this.get('newTitle'); task.set('title', newTitle); - task.save().then(() => { + this.get('saveTask')(task).then(() => { component.set('isEditing', false); - }).catch((error) => { - let payloadContainsValidationErrors = error.errors.some((error) => error.status === 422 ); - - if (!payloadContainsValidationErrors) { - this.controllerFor('project.tasks.task').set('error', error); - } }); - }, - }, + } + } }); diff --git a/app/components/team-member.js b/app/components/team-member.js index c86c64895..a00b71797 100644 --- a/app/components/team-member.js +++ b/app/components/team-member.js @@ -11,5 +11,5 @@ export default Component.extend({ src: computed('imageSlug', function() { let imageSlug = this.get('imageSlug'); return `https://d3pgew4wbk2vb1.cloudfront.net/images/team/${imageSlug}.png`; - }), + }) }); diff --git a/app/components/user-dropdown.js b/app/components/user-dropdown.js index ac149e9bd..5149d99ff 100644 --- a/app/components/user-dropdown.js +++ b/app/components/user-dropdown.js @@ -10,13 +10,13 @@ export default Component.extend({ session: service(), - click: function() { + click() { this.sendAction(); }, actions: { - invalidateSession: function() { + invalidateSession() { this.get('session').invalidate(); - }, - }, + } + } }); diff --git a/app/components/user-menu.js b/app/components/user-menu.js index 2bc3e9306..a3092d2c6 100644 --- a/app/components/user-menu.js +++ b/app/components/user-menu.js @@ -27,9 +27,9 @@ export default Component.extend({ * * @method hide */ - hide: function() { + hide() { // Don't try to hide a destroyed menu component - if(this.get('isDestroyed')) { + if (this.get('isDestroyed')) { return; } this.set('hidden', true); @@ -40,8 +40,8 @@ export default Component.extend({ * * @method toggle */ - toggle: function() { + toggle() { this.toggleProperty('hidden'); - }, + } } }); diff --git a/app/components/user-organizations-list.js b/app/components/user-organizations-list.js index 1210b0b09..db4b64f7d 100644 --- a/app/components/user-organizations-list.js +++ b/app/components/user-organizations-list.js @@ -1,5 +1,7 @@ import Ember from 'ember'; -export default Ember.Component.extend({ - classNames: ['user-organizations-list'], +const { Component } = Ember; + +export default Component.extend({ + classNames: ['user-organizations-list'] }); diff --git a/app/components/user-settings-form.js b/app/components/user-settings-form.js index 4e9011dbb..3074ec521 100644 --- a/app/components/user-settings-form.js +++ b/app/components/user-settings-form.js @@ -13,11 +13,11 @@ export default Component.extend({ actions: { save() { - const flashMessages = get(this, 'flashMessages'); + let flashMessages = get(this, 'flashMessages'); this.get('user').save().then(function() { - flashMessages.success("Profile updated successfully"); + flashMessages.success('Profile updated successfully'); }); - }, + } } }); diff --git a/app/components/user-sidebar.js b/app/components/user-sidebar.js index 130df97c1..ce18742a1 100644 --- a/app/components/user-sidebar.js +++ b/app/components/user-sidebar.js @@ -1,5 +1,7 @@ import Ember from 'ember'; -export default Ember.Component.extend({ - classNames: ['user-sidebar'], +const { Component } = Ember; + +export default Component.extend({ + classNames: ['user-sidebar'] }); diff --git a/app/components/user-skills-input-item.js b/app/components/user-skills-input-item.js index 79f551b33..e4c1e8b33 100644 --- a/app/components/user-skills-input-item.js +++ b/app/components/user-skills-input-item.js @@ -30,5 +30,5 @@ export default Component.extend({ mouseEnter() { this.sendAction('hover', this.get('skill')); - }, + } }); diff --git a/app/components/user-skills-input.js b/app/components/user-skills-input.js index 92672567b..2fe729665 100644 --- a/app/components/user-skills-input.js +++ b/app/components/user-skills-input.js @@ -92,7 +92,7 @@ export default Component.extend({ selectSkill() { this._selectSkill(); - }, + } }, _reset() { @@ -110,7 +110,7 @@ export default Component.extend({ this.set('results', []); } else if (this.get('_isNewQuery')) { this.set('lastQuery', queryString); - store.query('skill', { query: queryString, limit: limit }).then((skills) => { + store.query('skill', { query: queryString, limit }).then((skills) => { this.set('results', skills); this.set('cursorAt', 0); this._updateSelected(); @@ -166,5 +166,5 @@ export default Component.extend({ item.set('selected', false); } }); - }, + } }); diff --git a/app/controllers/application.js b/app/controllers/application.js index 36e3d6748..360b68701 100644 --- a/app/controllers/application.js +++ b/app/controllers/application.js @@ -1,13 +1,17 @@ import Ember from 'ember'; -const { service } = Ember.inject; +const { + computed, + Controller, + inject: { service } +} = Ember; -export default Ember.Controller.extend({ +export default Controller.extend({ codeTheme: service(), onboarding: service(), session: service(), - isOnboarding: Ember.computed.alias('onboarding.isOnboarding'), + isOnboarding: computed.alias('onboarding.isOnboarding'), actions: { invalidateSession() { diff --git a/app/controllers/index.js b/app/controllers/index.js index a52d39ea9..0b27f4cfe 100644 --- a/app/controllers/index.js +++ b/app/controllers/index.js @@ -1,19 +1,21 @@ import Ember from 'ember'; -export default Ember.Controller.extend({ +const { Controller } = Ember; + +export default Controller.extend({ typedStrings: [ - "social good.", - "elections.", - "schools.", - "the environment.", - "science.", - "hospitals.", - "ending poverty.", - "political activism.", - "communities.", - "justice.", - "ending climate change.", - "families.", - "government.", - ], + 'social good.', + 'elections.', + 'schools.', + 'the environment.', + 'science.', + 'hospitals.', + 'ending poverty.', + 'political activism.', + 'communities.', + 'justice.', + 'ending climate change.', + 'families.', + 'government.' + ] }); diff --git a/app/controllers/project/tasks/index.js b/app/controllers/project/tasks/index.js index 85e519ee5..dae097ab2 100644 --- a/app/controllers/project/tasks/index.js +++ b/app/controllers/project/tasks/index.js @@ -1,39 +1,46 @@ import Ember from 'ember'; -export default Ember.Controller.extend({ +const { + computed, + Controller, + isEmpty, + Object +} = Ember; + +export default Controller.extend({ page: 1, taskStatus: 'open', taskType: null, types: [ - Ember.Object.create({ - name: "Tasks", - param: "task", - slug: "tasks", - selected: false, + Object.create({ + name: 'Tasks', + param: 'task', + slug: 'tasks', + selected: false }), - Ember.Object.create({ - name: "Issues", - param: "issue", - slug: "issues", - selected: false, - }), - Ember.Object.create({ - name: "Ideas", - param: "idea", - slug: "ideas", - selected: false, + Object.create({ + name: 'Issues', + param: 'issue', + slug: 'issues', + selected: false }), + Object.create({ + name: 'Ideas', + param: 'idea', + slug: 'ideas', + selected: false + }) ], - status: Ember.computed.alias('taskStatus'), + status: computed.alias('taskStatus'), - isFilteringClosedTasks: Ember.computed.equal('status', 'closed'), - isFilteringOpenTasks: Ember.computed.equal('status', 'open'), - isFilteredByType: Ember.computed.notEmpty('taskTypes'), - isFiltered: Ember.computed.or('isFilteredByType'), + isFilteringClosedTasks: computed.equal('status', 'closed'), + isFilteringOpenTasks: computed.equal('status', 'open'), + isFilteredByType: computed.notEmpty('taskTypes'), + isFiltered: computed.or('isFilteredByType'), - taskTypes: Ember.computed('taskType', function() { - var taskTypes; + taskTypes: computed('taskType', function() { + let taskTypes; let array = this.get('taskType'); if (array) { @@ -45,12 +52,12 @@ export default Ember.Controller.extend({ return taskTypes; }), - selectedTypes: Ember.computed('types', 'taskTypes', function() { + selectedTypes: computed('types', 'taskTypes', function() { let types = this.get('types'); types.forEach((type) => { let taskTypes = this.get('taskTypes'); - if(taskTypes.includes(type.get('param'))) { + if (taskTypes.includes(type.get('param'))) { type.set('selected', true); } else { type.set('selected', false); @@ -69,13 +76,13 @@ export default Ember.Controller.extend({ let taskTypes = this.get('taskTypes'); let typeParam = type.get('param'); - if(taskTypes.includes(typeParam)) { + if (taskTypes.includes(typeParam)) { taskTypes.removeObject(typeParam); } else { taskTypes.pushObject(typeParam); } - if(Ember.isEmpty(taskTypes)) { + if (isEmpty(taskTypes)) { this.set('taskType', null); } else { let types = taskTypes.join(','); @@ -89,11 +96,11 @@ export default Ember.Controller.extend({ let taskTypes = this.get('taskTypes'); let typeParam = type.get('param'); - if(taskTypes.includes(typeParam)) { + if (taskTypes.includes(typeParam)) { taskTypes.removeObject(typeParam); } - if(Ember.isEmpty(taskTypes)) { + if (isEmpty(taskTypes)) { this.set('taskType', null); } else { let types = taskTypes.join(','); @@ -105,6 +112,6 @@ export default Ember.Controller.extend({ filterByStatus(status) { this.set('taskStatus', status); - }, + } } }); diff --git a/app/controllers/start/expertise.js b/app/controllers/start/expertise.js index 75650a782..2d2240c1c 100644 --- a/app/controllers/start/expertise.js +++ b/app/controllers/start/expertise.js @@ -1,6 +1,11 @@ import Ember from 'ember'; import OnboardingControllerMixin from '../../mixins/onboarding-controller'; -export default Ember.Controller.extend(OnboardingControllerMixin, { - userRoles: Ember.inject.service(), +const { + Controller, + inject: { service } +} = Ember; + +export default Controller.extend(OnboardingControllerMixin, { + userRoles: service() }); diff --git a/app/controllers/start/hello.js b/app/controllers/start/hello.js index c6e1ce311..f12c5dd39 100644 --- a/app/controllers/start/hello.js +++ b/app/controllers/start/hello.js @@ -1,10 +1,15 @@ import Ember from 'ember'; import OnboardingControllerMixin from '../../mixins/onboarding-controller'; -export default Ember.Controller.extend(OnboardingControllerMixin, { - firstNameIsEmpty: Ember.computed.empty('model.firstName'), - lastNameIsEmpty: Ember.computed.empty('model.lastName'), - usersNameIsEmpty: Ember.computed.or('firstNameIsEmpty', 'lastNameIsEmpty'), +const { + computed, + Controller +} = Ember; + +export default Controller.extend(OnboardingControllerMixin, { + firstNameIsEmpty: computed.empty('model.firstName'), + lastNameIsEmpty: computed.empty('model.lastName'), + usersNameIsEmpty: computed.or('firstNameIsEmpty', 'lastNameIsEmpty'), actions: { /** diff --git a/app/controllers/start/interests.js b/app/controllers/start/interests.js index aea28f87e..7184c2120 100644 --- a/app/controllers/start/interests.js +++ b/app/controllers/start/interests.js @@ -1,6 +1,11 @@ import Ember from 'ember'; import OnboardingControllerMixin from '../../mixins/onboarding-controller'; -export default Ember.Controller.extend(OnboardingControllerMixin, { - userCategories: Ember.inject.service(), +const { + Controller, + inject: { service } +} = Ember; + +export default Controller.extend(OnboardingControllerMixin, { + userCategories: service() }); diff --git a/app/controllers/start/skills.js b/app/controllers/start/skills.js index fdab9b1ee..e6d5952be 100644 --- a/app/controllers/start/skills.js +++ b/app/controllers/start/skills.js @@ -1,9 +1,15 @@ import Ember from 'ember'; import OnboardingControllerMixin from '../../mixins/onboarding-controller'; -export default Ember.Controller.extend(OnboardingControllerMixin, { - currentUser: Ember.inject.service(), - userSkills: Ember.inject.service(), +const { + computed, + Controller, + inject: { service } +} = Ember; - user: Ember.computed.alias('currentUser.user'), +export default Controller.extend(OnboardingControllerMixin, { + currentUser: service(), + userSkills: service(), + + user: computed.alias('currentUser.user') }); diff --git a/app/helpers/capitalize.js b/app/helpers/capitalize.js index 260de9c08..f6e98b6a0 100644 --- a/app/helpers/capitalize.js +++ b/app/helpers/capitalize.js @@ -1,10 +1,15 @@ import Ember from 'ember'; +const { + isEmpty, + Helper +} = Ember; + export function capitalize([string]) { - if (Ember.isEmpty(string)) { + if (isEmpty(string)) { return; } return string.capitalize(); } -export default Ember.Helper.helper(capitalize); +export default Helper.helper(capitalize); diff --git a/app/helpers/end-with-period.js b/app/helpers/end-with-period.js index 0b628620d..3347ea929 100644 --- a/app/helpers/end-with-period.js +++ b/app/helpers/end-with-period.js @@ -1,5 +1,7 @@ import Ember from 'ember'; +const { Helper } = Ember; + export function endWithPeriod([string]) { let lastCharacter = string.slice(-1); if (lastCharacter !== '.') { @@ -8,4 +10,4 @@ export function endWithPeriod([string]) { return string; } -export default Ember.Helper.helper(endWithPeriod); +export default Helper.helper(endWithPeriod); diff --git a/app/helpers/highlight-substrings.js b/app/helpers/highlight-substrings.js index c97e91521..1f087b2f5 100644 --- a/app/helpers/highlight-substrings.js +++ b/app/helpers/highlight-substrings.js @@ -1,11 +1,13 @@ import Ember from 'ember'; +const { Helper } = Ember; + export function highlightSubstrings([string, substring]) { - let substrings = substring.split(" ").uniq(); - var positionsToAdd = []; - var newString = []; - var count = 0; - var strongTagLocations = []; + let substrings = substring.split(' ').uniq(); + let positionsToAdd = []; + let newString = []; + let count = 0; + let strongTagLocations = []; _findPositionsToAdd(positionsToAdd, string, substrings, newString); _assembleArrayOfStrings(positionsToAdd, newString, count, strongTagLocations); @@ -13,12 +15,12 @@ export function highlightSubstrings([string, substring]) { } function _findPositionsToAdd(positionsToAdd, string, substrings, newString) { - for (var i = 0; i < string.length; i++) { + for (let i = 0; i < string.length; i++) { newString.push(string.charAt(i)); - for (var e = 0; e < substrings.length; e++) { + for (let e = 0; e < substrings.length; e++) { let stringOfSize = string.substring(i, substrings[e].length + i).toLowerCase(); let substringToMatch = substrings[e].toLowerCase(); - if(stringOfSize === substringToMatch) { + if (stringOfSize === substringToMatch) { positionsToAdd.push({ index: i, stringLength: substringToMatch.length @@ -29,18 +31,18 @@ function _findPositionsToAdd(positionsToAdd, string, substrings, newString) { } function _assembleArrayOfStrings(positionsToAdd, newString, count, strongTagLocations) { - for (var i = 0; i < positionsToAdd.length; i++) { - var canProceed = true; + for (let i = 0; i < positionsToAdd.length; i++) { + let canProceed = true; let startIndex = positionsToAdd[i].index; - let stringLength = positionsToAdd[i].stringLength; + let { stringLength } = positionsToAdd[i]; let firstLocation = startIndex + count; let lastLocation = firstLocation + (stringLength + 1); canProceed = _checkIfLocationInLocations(firstLocation, strongTagLocations); if (canProceed) { - newString.splice(firstLocation, 0, ""); - newString.splice(lastLocation, 0, ""); + newString.splice(firstLocation, 0, ''); + newString.splice(lastLocation, 0, ''); strongTagLocations.push({ start: firstLocation, end: lastLocation }); count += 2; } @@ -48,15 +50,15 @@ function _assembleArrayOfStrings(positionsToAdd, newString, count, strongTagLoca } function _assembleOutputString(arrayOfStrings) { - var outputString = ""; - for (var i = 0; i < arrayOfStrings.length; i++) { + let outputString = ''; + for (let i = 0; i < arrayOfStrings.length; i++) { outputString += arrayOfStrings[i]; } return outputString; } function _checkIfLocationInLocations(location, locations) { - var result = true; + let result = true; locations.forEach((searchedLocation) => { if (location <= searchedLocation.end) { result = false; @@ -65,4 +67,4 @@ function _checkIfLocationInLocations(location, locations) { return result; } -export default Ember.Helper.helper(highlightSubstrings); +export default Helper.helper(highlightSubstrings); diff --git a/app/mixins/can-animate.js b/app/mixins/can-animate.js index 3aacceabe..825a8e7a0 100644 --- a/app/mixins/can-animate.js +++ b/app/mixins/can-animate.js @@ -1,13 +1,20 @@ import Ember from 'ember'; -export default Ember.Mixin.create({ +const { + $, + computed, + Mixin, + run +} = Ember; + +export default Mixin.create({ scrollTimeout: 100, boundingClientRect: 0, windowHeight: 0, windowWidth: 0, - canAnimate: Ember.computed('boundingClientRect', 'windowHeight', function() { - var rect, windowHeight; + canAnimate: computed('boundingClientRect', 'windowHeight', function() { + let rect, windowHeight; rect = this.get('boundingClientRect'); windowHeight = this.get('windowHeight'); return ( @@ -15,33 +22,33 @@ export default Ember.Mixin.create({ ); }), - _updateBoundingClientRect: function() { - var el; + _updateBoundingClientRect() { + let el; el = this.$()[0]; this.set('boundingClientRect', el.getBoundingClientRect()); }, _setup: (function() { - return Ember.run.scheduleOnce('afterRender', this, function() { + return run.scheduleOnce('afterRender', this, function() { this._updateBoundingClientRect(); this.set('windowHeight', window.innerHeight || document.documentElement.clientHeight); this.set('windowWidth', window.innerWidth || document.documentElement.clientWidth); }); }).on('didInsertElement'), - _scrollHandler: function() { - return Ember.run.debounce(this, '_updateBoundingClientRect', this.get('scrollTimeout')); + _scrollHandler() { + return run.debounce(this, '_updateBoundingClientRect', this.get('scrollTimeout')); }, _bindScroll: (function() { - var scrollHandler; + let scrollHandler; scrollHandler = this._scrollHandler.bind(this); - Ember.$(document).on('touchmove.scrollable', scrollHandler); - Ember.$(window).on('scroll.scrollable', scrollHandler); + $(document).on('touchmove.scrollable', scrollHandler); + $(window).on('scroll.scrollable', scrollHandler); }).on('didInsertElement'), _unbindScroll: (function() { - Ember.$(window).off('.scrollable'); - Ember.$(document).off('.scrollable'); + $(window).off('.scrollable'); + $(document).off('.scrollable'); }).on('willDestroyElement') }); diff --git a/app/mixins/contains-code.js b/app/mixins/contains-code.js new file mode 100644 index 000000000..a2586dae6 --- /dev/null +++ b/app/mixins/contains-code.js @@ -0,0 +1,39 @@ +import Ember from 'ember'; + +const { + computed, + Mixin +} = Ember; + +/** + * `contains-code` provides a computed property to the extended class + * that returns whether or not the `body` property contains `code` + * tags. + * + * ## default usage + * + * ``` + * import ContainsCodeMixin from 'code-corps/mixins/contains-code'; + * + * export default Model.extend(ContainsCodeMixin, { ... }); + * ``` + * + * @mixin contains-code + * @module mixin + */ +export default Mixin.create({ + + /** + * returns whether or not the `body` property contains `code` tags + * + * @property containsCode + * @type Boolean + */ + containsCode: computed('body', function() { + let body = this.get('body'); + if (body) { + return body.indexOf('') !== -1; + } + return false; + }) +}); diff --git a/app/mixins/onboarding-controller.js b/app/mixins/onboarding-controller.js index 5e6ced66b..2973dc975 100644 --- a/app/mixins/onboarding-controller.js +++ b/app/mixins/onboarding-controller.js @@ -1,10 +1,16 @@ import Ember from 'ember'; -export default Ember.Mixin.create({ - currentUser: Ember.inject.service(), - onboarding: Ember.inject.service(), +const { + computed, + inject: { service }, + Mixin +} = Ember; - user: Ember.computed.alias('currentUser.user'), +export default Mixin.create({ + currentUser: service(), + onboarding: service(), + + user: computed.alias('currentUser.user'), actions: { continue() { @@ -16,6 +22,6 @@ export default Ember.Mixin.create({ user.save().then(() => { this.transitionToRoute(nextRoute); }); - }, - }, + } + } }); diff --git a/app/mixins/onboarding-route.js b/app/mixins/onboarding-route.js index 0a3486967..a40efd226 100644 --- a/app/mixins/onboarding-route.js +++ b/app/mixins/onboarding-route.js @@ -1,8 +1,11 @@ import Ember from 'ember'; -const { service } = Ember.inject; +const { + inject: { service }, + Mixin +} = Ember; -export default Ember.Mixin.create({ +export default Mixin.create({ currentUser: service(), onboarding: service(), @@ -27,5 +30,5 @@ export default Ember.Mixin.create({ if (window.history) { window.history.forward(); } - }, + } }); diff --git a/app/models/category.js b/app/models/category.js index 44fe5af55..fc58bd90b 100644 --- a/app/models/category.js +++ b/app/models/category.js @@ -8,5 +8,5 @@ export default Model.extend({ slug: attr('string'), userCategories: hasMany('user-category', { async: true }), - projectCategories: hasMany('project-category', { async: true }), + projectCategories: hasMany('project-category', { async: true }) }); diff --git a/app/models/comment-user-mention.js b/app/models/comment-user-mention.js index 931c81617..4a124797b 100644 --- a/app/models/comment-user-mention.js +++ b/app/models/comment-user-mention.js @@ -1,9 +1,11 @@ -import DS from 'ember-data'; +import Model from 'ember-data/model'; +import attr from 'ember-data/attr'; +import { belongsTo } from 'ember-data/relationships'; -export default DS.Model.extend({ - indices: DS.attr('array'), - username: DS.attr('string'), +export default Model.extend({ + indices: attr('array'), + username: attr('string'), - comment: DS.belongsTo('comment', { async: true }), - user: DS.belongsTo('user', { async: true }) + comment: belongsTo('comment', { async: true }), + user: belongsTo('user', { async: true }) }); diff --git a/app/models/comment.js b/app/models/comment.js index c9f31ec13..138902340 100644 --- a/app/models/comment.js +++ b/app/models/comment.js @@ -1,23 +1,14 @@ import Model from 'ember-data/model'; import attr from 'ember-data/attr'; import { belongsTo, hasMany } from 'ember-data/relationships'; -import Ember from 'ember'; +import ContainsCodeMixin from '../mixins/contains-code'; -export default Model.extend({ +export default Model.extend(ContainsCodeMixin, { body: attr('string'), insertedAt: attr('date'), markdown: attr('string'), commentUserMentions: hasMany('comment-user-mention', { async: true }), task: belongsTo('task', { async: true }), - user: belongsTo('user', { async: true }), - - containsCode: Ember.computed('body', function() { - let body = this.get('body'); - if(body) { - return body.indexOf('') !== -1; - } else { - return false; - } - }), + user: belongsTo('user', { async: true }) }); diff --git a/app/models/organization-membership.js b/app/models/organization-membership.js index 567a9c557..5fa7d1170 100644 --- a/app/models/organization-membership.js +++ b/app/models/organization-membership.js @@ -1,14 +1,18 @@ +import Model from 'ember-data/model'; +import attr from 'ember-data/attr'; +import { belongsTo } from 'ember-data/relationships'; import Ember from 'ember'; -import DS from 'ember-data'; -export default DS.Model.extend({ - role: DS.attr(), +const { computed } = Ember; - member: DS.belongsTo('user', { async: true }), - organization: DS.belongsTo('organization', { async: true }), +export default Model.extend({ + role: attr(), - isAdmin: Ember.computed.equal('role', 'admin'), - isContributor: Ember.computed.equal('role', 'contributor'), - isOwner: Ember.computed.equal('role', 'owner'), - isPending: Ember.computed.equal('role', 'pending'), + member: belongsTo('user', { async: true }), + organization: belongsTo('organization', { async: true }), + + isAdmin: computed.equal('role', 'admin'), + isContributor: computed.equal('role', 'contributor'), + isOwner: computed.equal('role', 'owner'), + isPending: computed.equal('role', 'pending') }); diff --git a/app/models/organization.js b/app/models/organization.js index a1936a970..3f2d8140d 100644 --- a/app/models/organization.js +++ b/app/models/organization.js @@ -3,6 +3,8 @@ import attr from 'ember-data/attr'; import { hasMany } from 'ember-data/relationships'; import Ember from 'ember'; +const { computed } = Ember; + export default Model.extend({ base64IconData: attr(), description: attr(), @@ -14,7 +16,7 @@ export default Model.extend({ organizationMemberships: hasMany('organization-membership', { async: true }), projects: hasMany('project', { async: true }), - hasPendingMembers: Ember.computed.gt('pendingMembersCount', 0), - pendingMembersCount: Ember.computed.alias('pendingMemberships.length'), - pendingMemberships: Ember.computed.filterBy('organizationMemberships', 'isPending'), + hasPendingMembers: computed.gt('pendingMembersCount', 0), + pendingMembersCount: computed.alias('pendingMemberships.length'), + pendingMemberships: computed.filterBy('organizationMemberships', 'isPending') }); diff --git a/app/models/preview-user-mention.js b/app/models/preview-user-mention.js index e3e6eed62..0977fbf6c 100644 --- a/app/models/preview-user-mention.js +++ b/app/models/preview-user-mention.js @@ -7,5 +7,5 @@ export default Model.extend({ username: attr('string'), preview: belongsTo('preview', { async: true }), - user: belongsTo('user', { async: true }), + user: belongsTo('user', { async: true }) }); diff --git a/app/models/preview.js b/app/models/preview.js index 30a611ba8..6e52bf24a 100644 --- a/app/models/preview.js +++ b/app/models/preview.js @@ -7,5 +7,5 @@ export default Model.extend({ markdown: attr('string'), previewUserMentions: hasMany('preview-user-mention', { async: true }), - user: belongsTo('user', { async: true }), + user: belongsTo('user', { async: true }) }); diff --git a/app/models/project-category.js b/app/models/project-category.js index 7ec8496be..a8552ae67 100644 --- a/app/models/project-category.js +++ b/app/models/project-category.js @@ -3,5 +3,5 @@ import { belongsTo } from 'ember-data/relationships'; export default Model.extend({ category: belongsTo('category', { async: true }), - project: belongsTo('project', { async: true }), + project: belongsTo('project', { async: true }) }); diff --git a/app/models/project-skill.js b/app/models/project-skill.js index e7e6301ad..b9b6f6736 100644 --- a/app/models/project-skill.js +++ b/app/models/project-skill.js @@ -3,5 +3,5 @@ import { belongsTo } from 'ember-data/relationships'; export default Model.extend({ project: belongsTo('project', { async: true }), - skill: belongsTo('skill', { async: true }), + skill: belongsTo('skill', { async: true }) }); diff --git a/app/models/project.js b/app/models/project.js index 43fda80f9..1a860f1c3 100644 --- a/app/models/project.js +++ b/app/models/project.js @@ -3,6 +3,8 @@ import attr from 'ember-data/attr'; import { belongsTo, hasMany } from 'ember-data/relationships'; import Ember from 'ember'; +const { computed } = Ember; + export default Model.extend({ base64IconData: attr(), closedTasksCount: attr('number'), @@ -20,7 +22,7 @@ export default Model.extend({ projectCategories: hasMany('project-category', { async: true }), projectSkills: hasMany('project-skill', { async: true }), - hasOpenTasks: Ember.computed.gt('openTasksCount', 0), - hasPendingMembers: Ember.computed.alias('organization.hasPendingMembers'), - pendingMembersCount: Ember.computed.alias('organization.pendingMembersCount'), + hasOpenTasks: computed.gt('openTasksCount', 0), + hasPendingMembers: computed.alias('organization.hasPendingMembers'), + pendingMembersCount: computed.alias('organization.pendingMembersCount') }); diff --git a/app/models/role.js b/app/models/role.js index 648b50945..8e10576ad 100644 --- a/app/models/role.js +++ b/app/models/role.js @@ -3,6 +3,8 @@ import attr from 'ember-data/attr'; import { hasMany } from 'ember-data/relationships'; import Ember from 'ember'; +const { computed } = Ember; + export default Model.extend({ ability: attr(), kind: attr(), @@ -10,7 +12,7 @@ export default Model.extend({ userRoles: hasMany('user-role', { async: true }), - isCreative: Ember.computed.equal('kind', 'creative'), - isSupport: Ember.computed.equal('kind', 'support'), - isTechnology: Ember.computed.equal('kind', 'technology'), + isCreative: computed.equal('kind', 'creative'), + isSupport: computed.equal('kind', 'support'), + isTechnology: computed.equal('kind', 'technology') }); diff --git a/app/models/skill.js b/app/models/skill.js index e5e50a48c..b4042a99c 100644 --- a/app/models/skill.js +++ b/app/models/skill.js @@ -6,5 +6,5 @@ export default Model.extend({ title: attr(), // Virtual attribute - matched: attr('boolean'), + matched: attr('boolean') }); diff --git a/app/models/slugged-route.js b/app/models/slugged-route.js index 63a2ab510..c8bc2cced 100644 --- a/app/models/slugged-route.js +++ b/app/models/slugged-route.js @@ -6,5 +6,5 @@ export default Model.extend({ slug: attr('string'), organization: belongsTo('organization', { async: true }), - user: belongsTo('user', { async: true }), + user: belongsTo('user', { async: true }) }); diff --git a/app/models/task-user-mention.js b/app/models/task-user-mention.js index 7c8b0ae3c..0abd41fa2 100644 --- a/app/models/task-user-mention.js +++ b/app/models/task-user-mention.js @@ -7,5 +7,5 @@ export default Model.extend({ username: attr('string'), task: belongsTo('task', { async: true }), - user: belongsTo('user', { async: true }), + user: belongsTo('user', { async: true }) }); diff --git a/app/models/task.js b/app/models/task.js index 7af346d44..014ebc695 100644 --- a/app/models/task.js +++ b/app/models/task.js @@ -1,9 +1,9 @@ import Model from 'ember-data/model'; import attr from 'ember-data/attr'; import { belongsTo, hasMany } from 'ember-data/relationships'; -import Ember from 'ember'; +import ContainsCodeMixin from '../mixins/contains-code'; -export default Model.extend({ +export default Model.extend(ContainsCodeMixin, { body: attr(), insertedAt: attr('date'), likesCount: attr('number'), @@ -17,14 +17,5 @@ export default Model.extend({ commentUserMentions: hasMany('comment-user-mention', { asnyc: true }), taskUserMentions: hasMany('task-user-mention', { asnyc: true }), project: belongsTo('project', { async: true }), - user: belongsTo('user', { async: true }), - - containsCode: Ember.computed('body', function() { - let body = this.get('body'); - if(body) { - return body.indexOf('') !== -1; - } else { - return false; - } - }), + user: belongsTo('user', { async: true }) }); diff --git a/app/models/user-category.js b/app/models/user-category.js index c004f395d..5091c2129 100644 --- a/app/models/user-category.js +++ b/app/models/user-category.js @@ -3,5 +3,5 @@ import { belongsTo } from 'ember-data/relationships'; export default Model.extend({ category: belongsTo('category', { async: true }), - user: belongsTo('user', { async: true }), + user: belongsTo('user', { async: true }) }); diff --git a/app/models/user-role.js b/app/models/user-role.js index 0a2285655..9316cfb43 100644 --- a/app/models/user-role.js +++ b/app/models/user-role.js @@ -3,5 +3,5 @@ import { belongsTo } from 'ember-data/relationships'; export default Model.extend({ role: belongsTo('role', { async: true }), - user: belongsTo('user', { async: true }), + user: belongsTo('user', { async: true }) }); diff --git a/app/models/user-skill.js b/app/models/user-skill.js index fe3d3fe6d..de5450d13 100644 --- a/app/models/user-skill.js +++ b/app/models/user-skill.js @@ -3,5 +3,5 @@ import { belongsTo } from 'ember-data/relationships'; export default Model.extend({ skill: belongsTo('skill', { async: true }), - user: belongsTo('user', { async: true }), + user: belongsTo('user', { async: true }) }); diff --git a/app/models/user.js b/app/models/user.js index ce15c95da..2ebaf1af3 100644 --- a/app/models/user.js +++ b/app/models/user.js @@ -3,6 +3,8 @@ import attr from 'ember-data/attr'; import { hasMany } from 'ember-data/relationships'; import Ember from 'ember'; +const { computed } = Ember; + export default Model.extend({ base64PhotoData: attr(), biography: attr(), @@ -26,11 +28,11 @@ export default Model.extend({ userRoles: hasMany('user-role', { async: true }), userSkills: hasMany('user-skill', { async: true }), - atUsername: Ember.computed('username', function() { + atUsername: computed('username', function() { return `@${this.get('username')}`; }), - twitterUrl: Ember.computed('twitter', function() { + twitterUrl: computed('twitter', function() { return `https://twitter.com/${this.get('twitter')}`; - }), + }) }); diff --git a/app/router.js b/app/router.js index 424a96979..9b3a36e74 100644 --- a/app/router.js +++ b/app/router.js @@ -1,10 +1,17 @@ import Ember from 'ember'; import config from './config/environment'; -const Router = Ember.Router.extend({ +const { + get, + inject: { service }, + Router, + run +} = Ember; + +let AppRouter = Router.extend({ location: config.locationType, rootURL: config.rootURL, - metrics: Ember.inject.service(), + metrics: service(), didTransition() { this._super(...arguments); @@ -12,40 +19,50 @@ const Router = Ember.Router.extend({ }, _trackPage() { - Ember.run.scheduleOnce('afterRender', this, () => { - const page = document.location.pathname; - const title = this.getWithDefault('currentRouteName', 'unknown'); + run.scheduleOnce('afterRender', this, () => { + let page = document.location.pathname; + let title = this.getWithDefault('currentRouteName', 'unknown'); - Ember.get(this, 'metrics').trackPage({ page, title }); + get(this, 'metrics').trackPage({ page, title }); }); } }); -Router.map(function() { +AppRouter.map(function() { this.route('login'); this.route('organizations', function() { - this.route('slugged-route', { path: '/:slugged_route_slug' }, function() { + this.route('slugged-route', { + path: '/:slugged_route_slug' + }, function() { this.route('settings', function() { this.route('profile'); }); }); }); - this.route('project', { path: '/:slugged_route_slug/:project_slug' }, function() { + this.route('project', { + path: '/:slugged_route_slug/:project_slug' + }, function() { this.route('settings', function() { this.route('contributors'); this.route('profile'); }); this.route('tasks', function() { this.route('new'); - this.route('task', { path: '/:number' }); + this.route('task', { + path: '/:number' + }); }); }); - this.route('projects', { path: '/:slugged_route_slug/projects'}); + this.route('projects', { + path: '/:slugged_route_slug/projects' + }); - this.route('projects-list', { path: '/projects'}); + this.route('projects-list', { + path: '/projects' + }); this.route('settings', function() { this.route('profile'); @@ -60,13 +77,16 @@ Router.map(function() { this.route('skills'); }); - this.route('slugged-route', { path: '/:slugged_route_slug' }); + this.route('slugged-route', { + path: '/:slugged_route_slug' + }); + this.route('team'); this.route('about'); this.route('organization', function() { - this.route('settings', function() {}); + this.route('settings', function() { }); }); }); -export default Router; +export default AppRouter; diff --git a/app/routes/about.js b/app/routes/about.js index 26d9f3124..7e6eac3e8 100644 --- a/app/routes/about.js +++ b/app/routes/about.js @@ -1,4 +1,5 @@ import Ember from 'ember'; -export default Ember.Route.extend({ -}); +const { Route } = Ember; + +export default Route.extend({ }); diff --git a/app/routes/application.js b/app/routes/application.js index 8ec2146c4..8b1bd260a 100644 --- a/app/routes/application.js +++ b/app/routes/application.js @@ -2,16 +2,22 @@ import Ember from 'ember'; import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin'; import ENV from 'code-corps-ember/config/environment'; -const { service } = Ember.inject; - -export default Ember.Route.extend(ApplicationRouteMixin, { +const { + computed, + get, + inject: { service }, + isPresent, + Route +} = Ember; + +export default Route.extend(ApplicationRouteMixin, { currentUser: service(), flashMessages: service(), metrics: service(), onboarding: service(), - isOnboarding: Ember.computed.alias('onboarding.isOnboarding'), - onboardingRoute: Ember.computed.alias('onboarding.currentRoute'), + isOnboarding: computed.alias('onboarding.isOnboarding'), + onboardingRoute: computed.alias('onboarding.currentRoute'), headTags: [ { @@ -20,7 +26,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { rel: 'canonical', content: ENV.WEB_BASE_URL - }, + } }, { type: 'meta', @@ -28,7 +34,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { property: 'description', content: 'Contribute to software projects for social good. Give your time or money to help build software to better the arts, education, government, science, and more.' - }, + } }, { type: 'meta', @@ -36,7 +42,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { property: 'og:description', content: 'Contribute to software projects for social good. Give your time or money to help build software to better the arts, education, government, science, and more.' - }, + } }, { type: 'meta', @@ -44,7 +50,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { property: 'og:image', content: 'https://d3pgew4wbk2vb1.cloudfront.net/images/universal-card.png' - }, + } }, { type: 'meta', @@ -52,7 +58,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { property: 'og:site_name', content: 'Code Corps' - }, + } }, { type: 'meta', @@ -60,7 +66,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { property: 'og:title', content: 'Code Corps | Build a better future.' - }, + } }, { type: 'meta', @@ -68,7 +74,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { property: 'og:type', content: 'website' - }, + } }, { type: 'meta', @@ -76,7 +82,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { property: 'og:url', content: ENV.WEB_BASE_URL - }, + } }, { type: 'meta', @@ -84,7 +90,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { name: 'twitter:card', content: 'summary_large_image' - }, + } }, { type: 'meta', @@ -92,7 +98,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { name: 'twitter:creator', content: '@thecodecorps' - }, + } }, { type: 'meta', @@ -100,7 +106,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { name: 'twitter:creator:id', content: '4608917052' - }, + } }, { type: 'meta', @@ -108,7 +114,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { name: 'twitter:description', content: 'Contribute to software projects for social good. Give your time or money to help build software to better the arts, education, government, science, and more.' - }, + } }, { type: 'meta', @@ -116,7 +122,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { name: 'twitter:image', content: 'https://d3pgew4wbk2vb1.cloudfront.net/images/universal-card.png' - }, + } }, { type: 'meta', @@ -124,7 +130,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { name: 'twitter:site', content: '@thecodecorps' - }, + } }, { type: 'meta', @@ -132,7 +138,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { name: 'twitter:site:id', content: '4608917052' - }, + } }, { type: 'meta', @@ -140,8 +146,8 @@ export default Ember.Route.extend(ApplicationRouteMixin, { attrs: { name: 'twitter:title', content: 'Code Corps | Build a better future.' - }, - }, + } + } ], beforeModel(transition) { @@ -164,7 +170,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { }, actions: { - didTransition: function() { + didTransition() { // Clear flash messages on every transition this.get('flashMessages').clearMessages(); return true; // Bubble the event @@ -184,7 +190,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { error(e) { console.error(e); this.intermediateTransitionTo('application_error', e); - }, + } }, _abortAndFixHistory(transition) { @@ -199,7 +205,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { this.transitionTo(this.get('onboardingRoute')); } else { let attemptedTransition = this.get('session.attemptedTransition'); - if (Ember.isPresent(attemptedTransition)) { + if (isPresent(attemptedTransition)) { attemptedTransition.retry(); this.set('session.attemptedTransition', null); } else { @@ -227,7 +233,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, { }, _trackAuthentication() { - Ember.get(this, 'metrics').trackEvent({ + get(this, 'metrics').trackEvent({ event: 'Signed In' }); } diff --git a/app/routes/index.js b/app/routes/index.js index 5b7c2225c..433cec6c5 100644 --- a/app/routes/index.js +++ b/app/routes/index.js @@ -1,13 +1,16 @@ import Ember from 'ember'; -const { service } = Ember.inject; +const { + inject: { service }, + Route +} = Ember; -export default Ember.Route.extend({ +export default Route.extend({ session: service(), beforeModel() { if (this.get('session.isAuthenticated')) { this.transitionTo('projects-list'); } - }, + } }); diff --git a/app/routes/login.js b/app/routes/login.js index 29e193ce0..e227c79a3 100644 --- a/app/routes/login.js +++ b/app/routes/login.js @@ -1,5 +1,6 @@ import Ember from 'ember'; import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-route-mixin'; -export default Ember.Route.extend(UnauthenticatedRouteMixin, { -}); +const { Route } = Ember; + +export default Route.extend(UnauthenticatedRouteMixin, { }); diff --git a/app/routes/organizations/slugged-route.js b/app/routes/organizations/slugged-route.js index a729eeb81..ac9e188cd 100644 --- a/app/routes/organizations/slugged-route.js +++ b/app/routes/organizations/slugged-route.js @@ -1,8 +1,14 @@ import Ember from 'ember'; import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; -export default Ember.Route.extend(AuthenticatedRouteMixin, { - credentials: Ember.inject.service(), +const { + Route, + RSVP, + inject: { service } +} = Ember; + +export default Route.extend(AuthenticatedRouteMixin, { + credentials: service(), model(params) { return this.store.queryRecord('slugged-route', { @@ -18,7 +24,7 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { if (organization) { return this.get('credentials').setOrganization(organization); } else { - return Ember.RSVP.resolve(); + return RSVP.resolve(); } } }); diff --git a/app/routes/organizations/slugged-route/settings.js b/app/routes/organizations/slugged-route/settings.js index c2ebfd9ee..ce88e9b94 100644 --- a/app/routes/organizations/slugged-route/settings.js +++ b/app/routes/organizations/slugged-route/settings.js @@ -2,18 +2,23 @@ import Ember from 'ember'; import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; import { CanMixin } from 'ember-can'; -export default Ember.Route.extend(AuthenticatedRouteMixin, CanMixin, { - credentials: Ember.inject.service(), - session: Ember.inject.service(), +const { + Route, + inject: { service } +} = Ember; + +export default Route.extend(AuthenticatedRouteMixin, CanMixin, { + credentials: service(), + session: service(), beforeModel() { let organization = this.modelFor('organizations.slugged-route'); return this.get('credentials.currentUserMembershipPromise').then((membership) => { - if (this.cannot('manage organization', organization, { membership: membership })) { + if (this.cannot('manage organization', organization, { membership })) { return this.transitionTo('index'); } else { return this._super(...arguments); } }); - }, + } }); diff --git a/app/routes/project.js b/app/routes/project.js index 70a00ba56..aafb2c111 100644 --- a/app/routes/project.js +++ b/app/routes/project.js @@ -1,23 +1,28 @@ import Ember from 'ember'; -export default Ember.Route.extend({ - model: function(params) { +const { + Route, + inject: { service } +} = Ember; + +export default Route.extend({ + model(params) { return this.store.queryRecord('project', { slug: params.project_slug, sluggedRouteSlug: params.slugged_route_slug }, { reload: true }); }, - credentials: Ember.inject.service(), + credentials: service(), - afterModel: function(model) { + afterModel(model) { return model.get('organization').then((organization) => { this.get('credentials').setOrganization(organization); return this._super(...arguments); }); }, - serialize: function(model) { + serialize(model) { if (model) { return { slugged_route_slug: model.get('organization.slug'), @@ -26,5 +31,5 @@ export default Ember.Route.extend({ } else { return this._super(...arguments); } - }, + } }); diff --git a/app/routes/project/settings.js b/app/routes/project/settings.js index 5c3fe9152..5af81b0f4 100644 --- a/app/routes/project/settings.js +++ b/app/routes/project/settings.js @@ -2,15 +2,20 @@ import Ember from 'ember'; import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; import { CanMixin } from 'ember-can'; -export default Ember.Route.extend(AuthenticatedRouteMixin, CanMixin, { - credentials: Ember.inject.service(), - session: Ember.inject.service(), +const { + Route, + inject: { service } +} = Ember; + +export default Route.extend(AuthenticatedRouteMixin, CanMixin, { + credentials: service(), + session: service(), beforeModel() { if (this.get('session.isAuthenticated')) { let organization = this.modelFor('project.organization'); return this.get('credentials.currentUserMembershipPromise').then((membership) => { - if (this.cannot('manage organization', organization, { membership: membership })) { + if (this.cannot('manage organization', organization, { membership })) { return this.transitionTo('index'); } else { return this._super(...arguments); @@ -19,5 +24,5 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, CanMixin, { } else { return this._super(...arguments); } - }, + } }); diff --git a/app/routes/project/settings/contributors.js b/app/routes/project/settings/contributors.js index abcabab0d..4d6a2904f 100644 --- a/app/routes/project/settings/contributors.js +++ b/app/routes/project/settings/contributors.js @@ -1,8 +1,10 @@ import Ember from 'ember'; -export default Ember.Route.extend({ +const { Route } = Ember; + +export default Route.extend({ model() { let project = this.modelFor('project'); return project; - }, + } }); diff --git a/app/routes/project/tasks.js b/app/routes/project/tasks.js index 8da153e9b..4d6a2904f 100644 --- a/app/routes/project/tasks.js +++ b/app/routes/project/tasks.js @@ -1,8 +1,10 @@ import Ember from 'ember'; -export default Ember.Route.extend({ - model: function() { +const { Route } = Ember; + +export default Route.extend({ + model() { let project = this.modelFor('project'); return project; - }, + } }); diff --git a/app/routes/project/tasks/index.js b/app/routes/project/tasks/index.js index 56fdd5edf..1d306b915 100644 --- a/app/routes/project/tasks/index.js +++ b/app/routes/project/tasks/index.js @@ -1,6 +1,11 @@ import Ember from 'ember'; -export default Ember.Route.extend({ +const { + merge, + Route + } = Ember; + +export default Route.extend({ queryParams: { page: { refreshModel: true, scope: 'controller' }, taskType: { refreshModel: true, scope: 'controller' }, @@ -9,7 +14,7 @@ export default Ember.Route.extend({ model(params) { let project = this.modelFor('project'); - let fullParams = Ember.merge(params, { projectId: project.get('id') }); + let fullParams = merge(params, { projectId: project.get('id') }); return this.get('store').query('task', fullParams); }, @@ -22,10 +27,10 @@ export default Ember.Route.extend({ // and then later set to null, will have its value serialized as "null" (string) // we fix this here deserializeQueryParam(value, urlKey, defaultValueType) { - if (urlKey === 'status' && value === "null") { + if (urlKey === 'status' && value === 'null') { return null; } else { return this._super(value, urlKey, defaultValueType); } - }, + } }); diff --git a/app/routes/project/tasks/new.js b/app/routes/project/tasks/new.js index 62aa2b2f4..9a8a1b99a 100644 --- a/app/routes/project/tasks/new.js +++ b/app/routes/project/tasks/new.js @@ -1,17 +1,23 @@ -import { computed } from 'ember-can'; +import EmberCan from 'ember-can'; import Ember from 'ember'; import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; -export default Ember.Route.extend(AuthenticatedRouteMixin, { - credentials: Ember.inject.service(), - currentUser: Ember.inject.service(), +const { + computed, + Route, + inject: { service } +} = Ember; - ability: computed.ability('organization', 'currentUserMembership'), +export default Route.extend(AuthenticatedRouteMixin, { + credentials: service(), + currentUser: service(), - canCreateTask: Ember.computed.alias('ability.canCreateTaskTask'), - currentUserMembership: Ember.computed.alias('credentials.currentUserMembership'), + ability: EmberCan.computed.ability('organization', 'currentUserMembership'), - taskType: Ember.computed('canCreateTask', function() { + canCreateTask: computed.alias('ability.canCreateTaskTask'), + currentUserMembership: computed.alias('credentials.currentUserMembership'), + + taskType: computed('canCreateTask', function() { return this.get('canCreateTask') ? 'task' : 'issue'; }), @@ -23,7 +29,7 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { let newTask = this.store.createRecord('task', { project: model, user: this.get('currentUser.user'), - taskType: this.get('taskType'), + taskType: this.get('taskType') }); controller.set('task', newTask); }, @@ -33,12 +39,12 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { task.save().then((task) => { this.transitionTo('project.tasks.task', task.get('number')); }).catch((error) => { - let payloadContainsValidationErrors = error.errors.some((error) => error.status === 422 ); + let payloadContainsValidationErrors = error.errors.some((error) => error.status === 422); if (!payloadContainsValidationErrors) { this.controllerFor('project.tasks.new').set('error', error); } }); - }, - }, + } + } }); diff --git a/app/routes/project/tasks/task.js b/app/routes/project/tasks/task.js index b06e0292b..f4c50d1af 100644 --- a/app/routes/project/tasks/task.js +++ b/app/routes/project/tasks/task.js @@ -1,22 +1,29 @@ import Ember from 'ember'; -export default Ember.Route.extend({ - currentUser: Ember.inject.service(), +const { + Route, + RSVP, + inject: { service }, + isPresent +} = Ember; + +export default Route.extend({ + currentUser: service(), model(params) { let projectId = this.modelFor('project').id; let queryParams = { - projectId: projectId, + projectId, number: params.number }; let userId = this.get('currentUser.user.id'); - return Ember.RSVP.hash({ + return RSVP.hash({ task: this.store.queryRecord('task', queryParams), - user: Ember.isPresent(userId) ? this.store.find('user', userId) : null + user: isPresent(userId) ? this.store.find('user', userId) : null }).then((result) => { - return Ember.RSVP.hash({ + return RSVP.hash({ task: result.task, comment: this.store.createRecord('comment', { task: result.task, user: result.user }), comments: this.store.query('comment', { taskId: result.task.id }) @@ -32,17 +39,27 @@ export default Ember.Route.extend({ }, actions: { + save(task) { + return task.save().catch((error) => { + let payloadContainsValidationErrors = error.errors.some((error) => error.status === 422); + + if (!payloadContainsValidationErrors) { + this.controllerFor('project.tasks.task').set('error', error); + } + }); + }, + saveComment(comment) { let route = this; comment.save().then(() => { route.refresh(); }).catch((error) => { - let payloadContainsValidationErrors = error.errors.some((error) => error.status === 422 ); + let payloadContainsValidationErrors = error.errors.some((error) => error.status === 422); if (!payloadContainsValidationErrors) { this.controllerFor('project.tasks.task').set('error', error); } }); - }, - }, + } + } }); diff --git a/app/routes/projects-list.js b/app/routes/projects-list.js index 621acb3e7..1c8a3b44e 100644 --- a/app/routes/projects-list.js +++ b/app/routes/projects-list.js @@ -1,6 +1,8 @@ import Ember from 'ember'; -export default Ember.Route.extend({ +const { Route } = Ember; + +export default Route.extend({ model() { return this.store.findAll('project'); }, diff --git a/app/routes/projects.js b/app/routes/projects.js index 40fcb36fe..1f73cf767 100644 --- a/app/routes/projects.js +++ b/app/routes/projects.js @@ -1,6 +1,8 @@ import Ember from 'ember'; -export default Ember.Route.extend({ +const { Route } = Ember; + +export default Route.extend({ model(params) { return this.store.query('project', { sluggedRouteSlug: params.slugged_route_slug diff --git a/app/routes/settings.js b/app/routes/settings.js index cedc0ee81..6a68dfda2 100644 --- a/app/routes/settings.js +++ b/app/routes/settings.js @@ -1,11 +1,16 @@ import Ember from 'ember'; import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; -export default Ember.Route.extend(AuthenticatedRouteMixin, { - currentUser: Ember.inject.service(), +const { + Route, + inject: { service } +} = Ember; - model: function() { - var userId = this.get('currentUser.user.id'); +export default Route.extend(AuthenticatedRouteMixin, { + currentUser: service(), + + model() { + let userId = this.get('currentUser.user.id'); return this.store.find('user', userId); } }); diff --git a/app/routes/signup.js b/app/routes/signup.js index 29e193ce0..e227c79a3 100644 --- a/app/routes/signup.js +++ b/app/routes/signup.js @@ -1,5 +1,6 @@ import Ember from 'ember'; import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-route-mixin'; -export default Ember.Route.extend(UnauthenticatedRouteMixin, { -}); +const { Route } = Ember; + +export default Route.extend(UnauthenticatedRouteMixin, { }); diff --git a/app/routes/slugged-route.js b/app/routes/slugged-route.js index 67b52dd1d..04303356b 100644 --- a/app/routes/slugged-route.js +++ b/app/routes/slugged-route.js @@ -1,7 +1,13 @@ import Ember from 'ember'; -export default Ember.Route.extend({ - credentials: Ember.inject.service(), +const { + Route, + RSVP, + inject: { service } +} = Ember; + +export default Route.extend({ + credentials: service(), model(params) { return this.store.queryRecord('slugged-route', { @@ -14,7 +20,7 @@ export default Ember.Route.extend({ if (organization) { return this.get('credentials').setOrganization(organization); } else { - return Ember.RSVP.resolve(); + return RSVP.resolve(); } }); } diff --git a/app/routes/start.js b/app/routes/start.js index d8ef940e8..218aea244 100644 --- a/app/routes/start.js +++ b/app/routes/start.js @@ -2,5 +2,6 @@ import Ember from 'ember'; import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; import OnboardingRouteMixin from '../mixins/onboarding-route'; -export default Ember.Route.extend(OnboardingRouteMixin, AuthenticatedRouteMixin, { -}); +const { Route } = Ember; + +export default Route.extend(OnboardingRouteMixin, AuthenticatedRouteMixin, { }); diff --git a/app/routes/start/expertise.js b/app/routes/start/expertise.js index cafd4b4fc..438abfd06 100644 --- a/app/routes/start/expertise.js +++ b/app/routes/start/expertise.js @@ -1,8 +1,13 @@ import Ember from 'ember'; import OnboardingRouteMixin from '../../mixins/onboarding-route'; -export default Ember.Route.extend(OnboardingRouteMixin, { - currentUser: Ember.inject.service(), +const { + Route, + inject: { service } +} = Ember; + +export default Route.extend(OnboardingRouteMixin, { + currentUser: service(), beforeModel() { this._super(...arguments); @@ -12,5 +17,5 @@ export default Ember.Route.extend(OnboardingRouteMixin, { model() { return this.store.findAll('role'); - }, + } }); diff --git a/app/routes/start/hello.js b/app/routes/start/hello.js index 6e15e7505..a54e3f4ed 100644 --- a/app/routes/start/hello.js +++ b/app/routes/start/hello.js @@ -1,10 +1,15 @@ import Ember from 'ember'; import OnboardingRouteMixin from '../../mixins/onboarding-route'; -export default Ember.Route.extend(OnboardingRouteMixin, { - currentUser: Ember.inject.service(), +const { + Route, + inject: { service } +} = Ember; + +export default Route.extend(OnboardingRouteMixin, { + currentUser: service(), model() { return this.get('currentUser.user'); - }, + } }); diff --git a/app/routes/start/interests.js b/app/routes/start/interests.js index da242b119..3b37c6831 100644 --- a/app/routes/start/interests.js +++ b/app/routes/start/interests.js @@ -1,8 +1,10 @@ import Ember from 'ember'; import OnboardingRouteMixin from '../../mixins/onboarding-route'; -export default Ember.Route.extend(OnboardingRouteMixin, { +const { Route } = Ember; + +export default Route.extend(OnboardingRouteMixin, { model() { return this.store.findAll('category'); - }, + } }); diff --git a/app/routes/start/skills.js b/app/routes/start/skills.js index 9d25cbb50..5b086eb51 100644 --- a/app/routes/start/skills.js +++ b/app/routes/start/skills.js @@ -1,8 +1,10 @@ import Ember from 'ember'; import OnboardingRouteMixin from '../../mixins/onboarding-route'; -export default Ember.Route.extend(OnboardingRouteMixin, { +const { Route } = Ember; + +export default Route.extend(OnboardingRouteMixin, { model() { return this.get('currentUser.user.userSkills'); - }, + } }); diff --git a/app/routes/team.js b/app/routes/team.js index 26d9f3124..7e6eac3e8 100644 --- a/app/routes/team.js +++ b/app/routes/team.js @@ -1,4 +1,5 @@ import Ember from 'ember'; -export default Ember.Route.extend({ -}); +const { Route } = Ember; + +export default Route.extend({ }); diff --git a/app/serializers/application.js b/app/serializers/application.js index f88df6e90..38db645de 100644 --- a/app/serializers/application.js +++ b/app/serializers/application.js @@ -1,9 +1,11 @@ import DS from 'ember-data'; import { singularize } from 'ember-inflector'; -export default DS.JSONAPISerializer.extend({ +const { JSONAPISerializer } = DS; + +export default JSONAPISerializer.extend({ // Our Phoenix API uses singularized model names payloadKeyFromModelName(modelName) { return singularize(modelName); - }, + } }); diff --git a/app/serializers/task.js b/app/serializers/task.js index 448e50302..a8f885c79 100644 --- a/app/serializers/task.js +++ b/app/serializers/task.js @@ -1,7 +1,7 @@ import ApplicationSerializer from './application'; export default ApplicationSerializer.extend({ - serializeAttribute: function(snapshot, json, key, attribute) { + serializeAttribute(snapshot, json, key, attribute) { // for creating records, just regularly serialize the payload if (snapshot.record.get('isNew')) { this._super(snapshot, json, key, attribute); @@ -24,5 +24,5 @@ export default ApplicationSerializer.extend({ } } } - }, + } }); diff --git a/app/services/background.js b/app/services/background.js index bc155e8e2..dc9781578 100644 --- a/app/services/background.js +++ b/app/services/background.js @@ -1,17 +1,24 @@ import Ember from 'ember'; -export default Ember.Service.extend({ - reset: function() { - Ember.$('html').removeClass('warning danger'); +const { + $, + computed, + run, + Service +} = Ember; + +export default Service.extend({ + reset() { + $('html').removeClass('warning danger'); }, - setBackgroundClass: Ember.computed(function() { + setBackgroundClass: computed(function() { return () => { - Ember.$('html').addClass(this.get('class')); + $('html').addClass(this.get('class')); }; }), - updateBackgroundClass: function() { - Ember.run.once(this, this.get('setBackgroundClass')); - }, + updateBackgroundClass() { + run.once(this, this.get('setBackgroundClass')); + } }); diff --git a/app/services/code-theme.js b/app/services/code-theme.js index 8707dc7d1..bc0c57b85 100644 --- a/app/services/code-theme.js +++ b/app/services/code-theme.js @@ -1,19 +1,24 @@ import Ember from 'ember'; -export default Ember.Service.extend({ +const { + computed, + Service +} = Ember; + +export default Service.extend({ isLight: true, - isDark: Ember.computed.not('isLight'), + isDark: computed.not('isLight'), - className: Ember.computed('isLight', 'isDark', function() { - if(this.get('isLight')) { + className: computed('isLight', 'isDark', function() { + if (this.get('isLight')) { return 'light'; - } else if(this.get('isDark')) { + } else if (this.get('isDark')) { return 'dark'; } }), toggle() { this.toggleProperty('isLight'); - }, + } }); diff --git a/app/services/credentials.js b/app/services/credentials.js index e7172f59e..349eabfdb 100644 --- a/app/services/credentials.js +++ b/app/services/credentials.js @@ -1,28 +1,35 @@ import Ember from 'ember'; -export default Ember.Service.extend({ - currentUser: Ember.inject.service(), - store: Ember.inject.service(), +const { + computed, + inject: { service }, + RSVP, + Service +} = Ember; - user: Ember.computed.alias('currentUser.user'), +export default Service.extend({ + currentUser: service(), + store: service(), + + user: computed.alias('currentUser.user'), currentOrganization: null, - currentOrganizationMemberships: Ember.computed.alias('currentOrganization.organizationMemberships'), + currentOrganizationMemberships: computed.alias('currentOrganization.organizationMemberships'), - currentUserMembership: Ember.computed('currentOrganizationMemberships.isLoaded', 'user', function() { + currentUserMembership: computed('currentOrganizationMemberships.isLoaded', 'user', function() { let memberships = this.get('currentOrganizationMemberships'); let membership = memberships.find((item) => this.findMembership(item)); return membership; }), - currentUserMembershipPromise: Ember.computed('currentOrganizationMemberships', 'user', function() { + currentUserMembershipPromise: computed('currentOrganizationMemberships', 'user', function() { let memberships = this.get('currentOrganizationMemberships'); let fulfilled = this.get('currentOrganizationMemberships.isFulfilled'); if (fulfilled) { let membership = memberships.find((item) => this.findMembership(item)); - return Ember.RSVP.resolve(membership); + return RSVP.resolve(membership); } else { return memberships.then((memberships) => { let membership = memberships.find((item) => this.findMembership(item)); @@ -31,7 +38,7 @@ export default Ember.Service.extend({ } }), - findMembership: function(item) { + findMembership(item) { let itemMemberId = item.belongsTo('member').id(); let itemOrganizationId = item.belongsTo('organization').id(); let currentUserId = this.get('user.id'); @@ -44,9 +51,9 @@ export default Ember.Service.extend({ return this.get('currentOrganizationMemberships').reload(); }, - userIsMemberInOrganization: Ember.computed.notEmpty('currentUserMembership'), - userCanJoinOrganization: Ember.computed.empty('currentUserMembership'), + userIsMemberInOrganization: computed.notEmpty('currentUserMembership'), + userCanJoinOrganization: computed.empty('currentUserMembership'), - userCanManageOrganization: Ember.computed.alias('currentUserMembership.isAtLeastAdmin'), - userMembershipIsPending: Ember.computed.alias('currentUserMembership.isPending'), + userCanManageOrganization: computed.alias('currentUserMembership.isAtLeastAdmin'), + userMembershipIsPending: computed.alias('currentUserMembership.isPending') }); diff --git a/app/services/current-user.js b/app/services/current-user.js index 8036d1543..09c264171 100644 --- a/app/services/current-user.js +++ b/app/services/current-user.js @@ -1,16 +1,22 @@ import Ember from 'ember'; -const { inject: { service }, RSVP } = Ember; +const { + get, + inject: { service }, + isEmpty, + RSVP, + Service +} = Ember; -export default Ember.Service.extend({ +export default Service.extend({ metrics: service(), session: service(), store: service(), loadCurrentUser() { return new RSVP.Promise((resolve, reject) => { - const userId = this.get('session.session.authenticated.user_id'); - if (!Ember.isEmpty(userId)) { + let userId = this.get('session.session.authenticated.user_id'); + if (!isEmpty(userId)) { return this.get('store').findRecord('user', userId).then((user) => { this.set('user', user); this._identifyUser(user); @@ -24,7 +30,7 @@ export default Ember.Service.extend({ _identifyUser(user) { // Segment - Ember.get(this, 'metrics').identify({ + get(this, 'metrics').identify({ distinctId: user.get('id'), biography: user.get('biography'), insertedAt: user.get('insertedAt'), @@ -32,7 +38,7 @@ export default Ember.Service.extend({ name: user.get('name'), state: user.get('state'), username: user.get('username'), - website: user.get('website'), + website: user.get('website') }); - }, + } }); diff --git a/app/services/drag-state.js b/app/services/drag-state.js index 7cac15826..cf917228f 100644 --- a/app/services/drag-state.js +++ b/app/services/drag-state.js @@ -1,6 +1,8 @@ import Ember from 'ember'; -export default Ember.Service.extend({ +const { Service } = Ember; + +export default Service.extend({ isDragging: false, dragging() { @@ -9,5 +11,5 @@ export default Ember.Service.extend({ leaving() { this.set('isDragging', false); - }, + } }); diff --git a/app/services/mention-fetcher.js b/app/services/mention-fetcher.js index c975fdc15..15a4e2db0 100644 --- a/app/services/mention-fetcher.js +++ b/app/services/mention-fetcher.js @@ -1,13 +1,19 @@ import Ember from 'ember'; // import { parse } from 'code-corps-ember/utils/mention-parser'; -// NOTE: memtions are disabled until we reimplement them phoenix-side, so right now +// NOTE: mentions are disabled until we reimplement them phoenix-side, so right now // this service just returns the unmodified body -export default Ember.Service.extend({ - store: Ember.inject.service(), +const { + inject: { service }, + RSVP, + Service +} = Ember; - prefetchBodyWithMentions(record/*, type*/) { +export default Service.extend({ + store: service(), + + prefetchBodyWithMentions(record/* , type*/) { let body = record.get('body'); return body; @@ -19,7 +25,7 @@ export default Ember.Service.extend({ */ }, - fetchBodyWithMentions(record/*, type*/) { + fetchBodyWithMentions(record/* , type*/) { /* let store = this.get('store'); let mentionType = `${type}-user-mention`; @@ -32,6 +38,6 @@ export default Ember.Service.extend({ }); */ - return Ember.RSVP.resolve(record.get('body')); + return RSVP.resolve(record.get('body')); } }); diff --git a/app/services/navigation-menu.js b/app/services/navigation-menu.js index 365567ad1..c7685b043 100644 --- a/app/services/navigation-menu.js +++ b/app/services/navigation-menu.js @@ -1,19 +1,23 @@ import Ember from 'ember'; -const { service } = Ember.inject; +const { + computed, + inject: { service }, + Service +} = Ember; -export default Ember.Service.extend({ +export default Service.extend({ onboarding: service(), - isDefault: Ember.computed.equal('menuType', 'default'), - isOnboarding: Ember.computed.equal('menuType', 'onboarding'), + isDefault: computed.equal('menuType', 'default'), + isOnboarding: computed.equal('menuType', 'onboarding'), - menuType: Ember.computed('onboarding.isOnboarding', function() { + menuType: computed('onboarding.isOnboarding', function() { let isOnboarding = this.get('onboarding.isOnboarding'); if (isOnboarding) { return 'onboarding'; } else { return 'default'; } - }), + }) }); diff --git a/app/services/onboarding.js b/app/services/onboarding.js index c7f00017d..78b868d72 100644 --- a/app/services/onboarding.js +++ b/app/services/onboarding.js @@ -1,10 +1,14 @@ import Ember from 'ember'; -const { service } = Ember.inject; +const { + computed, + inject: { service }, + Service +} = Ember; -export default Ember.Service.extend({ +export default Service.extend({ currentUser: service(), - totalSteps: Ember.computed.alias('_steps.length'), + totalSteps: computed.alias('_steps.length'), _steps: [ { @@ -12,50 +16,52 @@ export default Ember.Service.extend({ state: 'signed_up', currentRoute: 'start.hello', nextRoute: 'start.interests', - nextStateTransition: 'edit_profile', + nextStateTransition: 'edit_profile' }, { number: 2, state: 'edited_profile', currentRoute: 'start.interests', nextRoute: 'start.expertise', - nextStateTransition: 'select_categories', + nextStateTransition: 'select_categories' }, { number: 3, state: 'selected_categories', currentRoute: 'start.expertise', nextRoute: 'start.skills', - nextStateTransition: 'select_roles', + nextStateTransition: 'select_roles' }, { number: 4, state: 'selected_roles', currentRoute: 'start.skills', nextRoute: 'projects-list', - nextStateTransition: 'select_skills', + nextStateTransition: 'select_skills' } ], - _currentStep: Ember.computed('currentUser.user.state', function() { + _currentStep: computed('currentUser.user.state', function() { let state = this.get('currentUser.user.state'); let steps = this.get('_steps'); - return steps.find((step) => { return step.state === state; }); + return steps.find((step) => { + return step.state === state; + }); }), - currentRoute: Ember.computed.alias('_currentStep.currentRoute'), - currentStepNumber: Ember.computed.alias('_currentStep.number'), - currentStepState: Ember.computed.alias('_currentStep.state'), - isEditingProfile: Ember.computed.equal('currentStepState', 'signed_up'), - isOnboarding: Ember.computed.or('isEditingProfile', 'isSelectingCategories', 'isSelectingRoles', 'isSelectingSkills'), - isSelectingCategories: Ember.computed.equal('currentStepState', 'edited_profile'), - isSelectingRoles: Ember.computed.equal('currentStepState', 'selected_categories'), - isSelectingSkills: Ember.computed.equal('currentStepState', 'selected_roles'), - nextRoute: Ember.computed.alias('_currentStep.nextRoute'), - nextStateTransition: Ember.computed.alias('_currentStep.nextStateTransition'), - routes: Ember.computed.mapBy('_steps', 'currentRoute'), + currentRoute: computed.alias('_currentStep.currentRoute'), + currentStepNumber: computed.alias('_currentStep.number'), + currentStepState: computed.alias('_currentStep.state'), + isEditingProfile: computed.equal('currentStepState', 'signed_up'), + isOnboarding: computed.or('isEditingProfile', 'isSelectingCategories', 'isSelectingRoles', 'isSelectingSkills'), + isSelectingCategories: computed.equal('currentStepState', 'edited_profile'), + isSelectingRoles: computed.equal('currentStepState', 'selected_categories'), + isSelectingSkills: computed.equal('currentStepState', 'selected_roles'), + nextRoute: computed.alias('_currentStep.nextRoute'), + nextStateTransition: computed.alias('_currentStep.nextStateTransition'), + routes: computed.mapBy('_steps', 'currentRoute'), - progressPercentage: Ember.computed('currentStepNumber', 'totalSteps', function() { + progressPercentage: computed('currentStepNumber', 'totalSteps', function() { return (this.get('currentStepNumber') / this.get('totalSteps')) * 100; - }), + }) }); diff --git a/app/services/session.js b/app/services/session.js index 6deec91f9..cf7faecba 100644 --- a/app/services/session.js +++ b/app/services/session.js @@ -1,3 +1,3 @@ -import ESASession from "ember-simple-auth/services/session"; +import ESASession from 'ember-simple-auth/services/session'; export default ESASession.extend(); diff --git a/app/services/user-categories.js b/app/services/user-categories.js index 39a7aa415..87926daa9 100644 --- a/app/services/user-categories.js +++ b/app/services/user-categories.js @@ -1,13 +1,19 @@ import Ember from 'ember'; -export default Ember.Service.extend({ - currentUser: Ember.inject.service(), - store: Ember.inject.service(), +const { + computed, + inject: { service }, + Service +} = Ember; - isEmpty: Ember.computed.empty('userCategories'), - user: Ember.computed.alias('currentUser.user'), +export default Service.extend({ + currentUser: service(), + store: service(), - userCategories: Ember.computed('user.userCategories', + isEmpty: computed.empty('userCategories'), + user: computed.alias('currentUser.user'), + + userCategories: computed('user.userCategories', 'user.userCategories.@each.category', 'user.userCategories.@each.user', function() { @@ -23,7 +29,7 @@ export default Ember.Service.extend({ return userCategory.save(); }, - findUserCategory: function(category) { + findUserCategory(category) { let userCategories = this.get('userCategories'); if (userCategories) { let userCategory = userCategories.find((item) => { @@ -40,5 +46,5 @@ export default Ember.Service.extend({ removeCategory(category) { let userCategory = this.findUserCategory(category); return userCategory.destroyRecord(); - }, + } }); diff --git a/app/services/user-roles.js b/app/services/user-roles.js index f13d249f3..85e5cf7b9 100644 --- a/app/services/user-roles.js +++ b/app/services/user-roles.js @@ -1,13 +1,19 @@ import Ember from 'ember'; -export default Ember.Service.extend({ - currentUser: Ember.inject.service(), - store: Ember.inject.service(), +const { + computed, + inject: { service }, + Service +} = Ember; - isEmpty: Ember.computed.empty('userRoles'), - user: Ember.computed.alias('currentUser.user'), +export default Service.extend({ + currentUser: service(), + store: service(), - userRoles: Ember.computed('user.userRoles', + isEmpty: computed.empty('userRoles'), + user: computed.alias('currentUser.user'), + + userRoles: computed('user.userRoles', 'user.userRoles.@each.role', 'user.userRoles.@each.user', function() { @@ -23,7 +29,7 @@ export default Ember.Service.extend({ return userRole.save(); }, - findUserRole: function(role) { + findUserRole(role) { let userRoles = this.get('userRoles'); let userRole = userRoles.find((item) => { let itemUserId = item.belongsTo('user').id(); @@ -38,5 +44,5 @@ export default Ember.Service.extend({ removeRole(role) { let userRole = this.findUserRole(role); return userRole.destroyRecord(); - }, + } }); diff --git a/app/services/user-skills.js b/app/services/user-skills.js index 2c77e22a6..226d31d2e 100644 --- a/app/services/user-skills.js +++ b/app/services/user-skills.js @@ -1,13 +1,20 @@ import Ember from 'ember'; -export default Ember.Service.extend({ - currentUser: Ember.inject.service(), - store: Ember.inject.service(), +const { + computed, + inject: { service }, + isEmpty, + Service +} = Ember; - isEmpty: Ember.computed.empty('userSkills'), - user: Ember.computed.alias('currentUser.user'), +export default Service.extend({ + currentUser: service(), + store: service(), - userSkills: Ember.computed('user.userSkills', + isEmpty: computed.empty('userSkills'), + user: computed.alias('currentUser.user'), + + userSkills: computed('user.userSkills', 'user.userSkills.@each.skill', 'user.userSkills.@each.user', function() { @@ -31,11 +38,11 @@ export default Ember.Service.extend({ let skillId = skill.get('id'); return (itemSkillId === skillId); }.bind(this)); - return !Ember.isEmpty(matchedSkill); + return !isEmpty(matchedSkill); } }, - findUserSkill: function(skill) { + findUserSkill(skill) { let userSkills = this.get('userSkills'); if (userSkills) { let userSkill = userSkills.find((item) => { @@ -52,5 +59,5 @@ export default Ember.Service.extend({ removeSkill(skill) { let userSkill = this.findUserSkill(skill); return userSkill.destroyRecord(); - }, + } }); diff --git a/app/templates/application-error.hbs b/app/templates/application-error.hbs index 9381f8cc6..b39011393 100644 --- a/app/templates/application-error.hbs +++ b/app/templates/application-error.hbs @@ -1 +1 @@ -{{error-wrapper model=model}} \ No newline at end of file +{{error-wrapper error=model}} diff --git a/app/templates/components/image-drop.hbs b/app/templates/components/image-drop.hbs index 5bb78637b..ac355f91f 100644 --- a/app/templates/components/image-drop.hbs +++ b/app/templates/components/image-drop.hbs @@ -6,4 +6,3 @@

{{helpText}}

-{{drop-zone}} \ No newline at end of file diff --git a/app/templates/components/organization-menu.hbs b/app/templates/components/organization-menu.hbs index 8505eba0f..dbf7a4ab6 100644 --- a/app/templates/components/organization-menu.hbs +++ b/app/templates/components/organization-menu.hbs @@ -2,7 +2,7 @@ {{#link-to 'slugged-route' organization.slug}}Projects{{/link-to}} -{{#if (can "manage organization" organization membership=credentials.currentUserMembership)}} +{{#if (can 'manage organization')}}
  • {{#link-to 'organizations.slugged-route.settings.profile' organization.slug}}Settings{{/link-to}}
  • diff --git a/app/templates/components/organization-settings-menu.hbs b/app/templates/components/organization-settings-menu.hbs index 7cbd648bf..587fdd3d7 100644 --- a/app/templates/components/organization-settings-menu.hbs +++ b/app/templates/components/organization-settings-menu.hbs @@ -1,6 +1,6 @@
      {{#if session.isAuthenticated}} - {{#if (can "manage organization" organization membership=credentials.currentUserMembership) }} + {{#if (can 'manage organization')}}
    • {{#link-to 'organizations.slugged-route.settings.profile' organization.slug}} Organization Profile @@ -8,4 +8,4 @@
    • {{/if}} {{/if}} -
    \ No newline at end of file + diff --git a/app/templates/components/task-details.hbs b/app/templates/components/task-details.hbs index 98d393cf8..64108fd2b 100644 --- a/app/templates/components/task-details.hbs +++ b/app/templates/components/task-details.hbs @@ -11,7 +11,7 @@ {{/each}}
    - +
    {{else}} diff --git a/app/templates/components/task-header.hbs b/app/templates/components/task-header.hbs index aceae747b..7e0d14452 100644 --- a/app/templates/components/task-header.hbs +++ b/app/templates/components/task-header.hbs @@ -1,2 +1,2 @@
    -{{task-title task=task}} +{{task-title task=task saveTask=saveTask}} diff --git a/app/templates/components/task-title.hbs b/app/templates/components/task-title.hbs index 67496dc7e..3d16b03c6 100644 --- a/app/templates/components/task-title.hbs +++ b/app/templates/components/task-title.hbs @@ -1,7 +1,7 @@ {{#if isEditing}}
    - +
    {{input type="text" value=newTitle name="title"}} {{#each task.errors.title as |error|}} diff --git a/app/templates/project/tasks/task.hbs b/app/templates/project/tasks/task.hbs index fc1d80a67..b1fd8f053 100644 --- a/app/templates/project/tasks/task.hbs +++ b/app/templates/project/tasks/task.hbs @@ -1,7 +1,7 @@ -{{task-header task=task saveTitle="saveTaskTitle"}} +{{task-header task=task saveTask=(route-action "save")}} {{task-status task=task}}
    - {{task-details task=task}} + {{task-details task=task saveTask=(route-action "save")}} {{task-comment-list comments=comments}}
    {{#create-comment-form comment=newComment saveComment='saveComment'}} diff --git a/app/transforms/array.js b/app/transforms/array.js index 722c8d2d6..5f747e7c5 100644 --- a/app/transforms/array.js +++ b/app/transforms/array.js @@ -1,22 +1,25 @@ import Ember from 'ember'; import DS from 'ember-data'; -export default DS.Transform.extend({ - deserialize: function (serialized) { - let type = Ember.typeOf(serialized); - return (type === "array") ? serialized : []; +const { typeOf } = Ember; +const { Transform } = DS; + +export default Transform.extend({ + deserialize(serialized) { + let type = typeOf(serialized); + return (type === 'array') ? serialized : []; }, - serialize: function (deserialized) { - let type = Ember.typeOf(deserialized); + serialize(deserialized) { + let type = typeOf(deserialized); if (type === 'array') { return deserialized; } else if (type === 'string') { - return deserialized.split(',').map(function (item) { + return deserialized.split(',').map(function(item) { return item.trim(); }); } else { return []; } - }, + } }); diff --git a/app/utils/mention-parser.js b/app/utils/mention-parser.js index 840d37014..121fe1b0d 100644 --- a/app/utils/mention-parser.js +++ b/app/utils/mention-parser.js @@ -1,7 +1,12 @@ import Ember from 'ember'; +const { + get, + isPresent +} = Ember; + function parse(body, mentions) { - if (Ember.isPresent(body) && Ember.isPresent(mentions)) { + if (isPresent(body) && isPresent(mentions)) { return _parseMentions(body, mentions); } else { return body; @@ -9,7 +14,7 @@ function parse(body, mentions) { } function _generateLink(mention) { - let username = Ember.get(mention, 'username'); + let username = get(mention, 'username'); return `@${username}`; } @@ -18,9 +23,8 @@ function _parseMentions(body, mentions) { let currentPosition = 0; mentions.forEach((mention) => { - let indices = Ember.get(mention, 'indices'); - let startIndex = indices[0]; - let endIndex = indices[1]; + let indices = get(mention, 'indices'); + let [startIndex, endIndex] = indices; parsedBody += body.slice(currentPosition, startIndex); parsedBody += _generateLink(mention); diff --git a/bower.json b/bower.json index ea9433472..bf2a02f08 100644 --- a/bower.json +++ b/bower.json @@ -6,8 +6,6 @@ "pace": "^1.0.2", "dom-ruler": "0.1.13", "es5-shim": "^4.5.9", - "FakeXMLHttpRequest": "^1.4.0", - "pretender": "^1.1.0", "Faker": "^3.1.0", "zxcvbn": "^4.3.0", "typed.js": "^1.1.1", diff --git a/config/ember-try.js b/config/ember-try.js new file mode 100644 index 000000000..71aac7a81 --- /dev/null +++ b/config/ember-try.js @@ -0,0 +1,44 @@ +module.exports = { + command: "ember exam --split=3 --weighted --parallel", + scenarios: [ + { + name: 'default', + bower: { + dependencies: { } + } + }, + { + name: 'ember-release', + bower: { + dependencies: { + 'ember': 'components/ember#release' + }, + resolutions: { + 'ember': 'release' + } + } + }, + { + name: 'ember-beta', + bower: { + dependencies: { + 'ember': 'components/ember#beta' + }, + resolutions: { + 'ember': 'beta' + } + } + }, + { + name: 'ember-canary', + bower: { + dependencies: { + 'ember': 'components/ember#canary' + }, + resolutions: { + 'ember': 'canary' + } + } + } + ] +}; diff --git a/docs/USAGE.md b/docs/USAGE.md index 26903f94f..adfa0e68d 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -37,6 +37,14 @@ We use [ember-exam](https://github.com/trentmwillis/ember-exam) for running test * `ember exam --random` will run the tests in a random order * `ember exam --filter='acceptance'` will only run acceptance tests. The same syntax can be used for other types of tests, such as `ember exam --filter='unit'` and `ember exam --filter='integration'` +We also take advantage of [ember-try](https://github.com/ember-cli/ember-try), which allows us to test against different versions of packages. We have a few set up in the [configuration file](../config/ember-try.js), which can be used as follows: +* `ember try:one default` will run the tests with everything currently listed in `package.json` and `bower.json` +* `ember try:one ember-release` will run the tests using the current release version of ember +* `ember try:one ember-beta` will run the tests using the current beta release of ember +* `ember try:one ember-canary` will run the tests using the current canary release of ember +* `ember try:each` will run all configurations in `config/ember-try.js` +You'll notice that all of these will run using `ember exam`. + ## Generating Documentation The Code Corps Ember application uses [YUIDoc](http://yui.github.io/yuidoc/) for documentation. diff --git a/mirage/config.js b/mirage/config.js index cea15d8fc..bfe6e738b 100644 --- a/mirage/config.js +++ b/mirage/config.js @@ -6,12 +6,12 @@ function generateCommentMentions(schema, comment) { matches.forEach((match) => { let username = match.substr(1); - let matchedUser = schema.users.where({ username: username }).models[0]; + let [matchedUser] = schema.users.where({ username }).models; if (matchedUser) { let startIndex = body.indexOf(match); let endIndex = startIndex + match.length - 1; schema.create('commentUserMention', { - username: username, + username, indices: [startIndex, endIndex], userId: matchedUser.id, commentId: comment.id, @@ -27,12 +27,12 @@ function generateTaskMentions(schema, task) { matches.forEach((match) => { let username = match.substr(1); - let matchedUser = schema.users.where({ username: username }).models[0]; + let [matchedUser] = schema.users.where({ username }).models; if (matchedUser) { let startIndex = body.indexOf(match); let endIndex = startIndex + match.length - 1; schema.taskUserMentions.create({ - username: username, + username, indices: [startIndex, endIndex], userId: matchedUser.id, taskId: task.id @@ -47,12 +47,12 @@ function generatePreviewMentions(schema, preview) { matches.forEach((match) => { let username = match.substr(1); - let matchedUser = schema.users.where({ username: username }).models[0]; + let [matchedUser] = schema.users.where({ username }); if (matchedUser) { let startIndex = body.indexOf(match); let endIndex = startIndex + match.length - 1; schema.previewUserMentions.create({ - username: username, + username, indices: [startIndex, endIndex], userId: matchedUser.id, previewId: preview.id @@ -65,20 +65,29 @@ function generatePreviewMentions(schema, preview) { const routes = [ 'categories', 'comment-user-mentions', 'comments', 'organizations', 'task-user-mentions', 'tasks', 'previews', 'projects', 'project-categories', - 'slugged-routes', 'user-categories', 'users', + 'slugged-routes', 'user-categories', 'users' ]; export default function() { - ///////////// - // Categories - ///////////// + /** + * Categories + */ // GET /categories - this.get('/categories'); + this.get('/categories', { coalesce: true }); - //////////////////////// - // Comment user mentions - //////////////////////// + // POST /categories + this.post('/categories'); + + // GET /categories/:id + this.get('/categories/:id'); + + // PATCH /categories + this.patch('/categories/:id'); + + /** + * Comment user mentions + */ // GET /comment-user-mentions this.get('/comment-user-mentions', (schema, request) => { @@ -87,12 +96,12 @@ export default function() { generateCommentMentions(schema, comment); - return schema.commentUserMentions.where({ commentId: commentId }); + return schema.commentUserMentions.where({ commentId }); }); - /////////// - // Comments - /////////// + /** + * Comments + */ // POST /comments this.post('/comments', function(schema) { @@ -103,6 +112,9 @@ export default function() { }); // GET /comments/:id + this.get('/comments/:id'); + + // PATCH /comments/:id this.patch('/comments/:id', function(schema) { let attrs = this.normalizedRequestAttrs(); let comment = schema.comments.find(attrs.id); @@ -120,9 +132,9 @@ export default function() { return comment; }); - /////////////////////////// - // Organization memberships - /////////////////////////// + /** + * Organization memberships + */ // GET /organization-memberships this.get('/organization-memberships', { coalesce: true }); @@ -130,26 +142,34 @@ export default function() { // POST /organization-memberships this.post('/organization-memberships'); - // DELETE /organization-memberships/:id - this.delete('/organization-memberships/:id'); - // GET /organization-memberships/:id this.get('/organization-memberships/:id'); // PATCH /organization-memberships/:id this.patch('/organization-memberships/:id'); - //////////////// - // Organizations - //////////////// + // DELETE /organization-memberships/:id + this.delete('/organization-memberships/:id'); + /** + * Organizations + */ + + // GET /organizations this.get('/organizations', { coalesce: true }); + // POST /organizations + this.post('/organizations'); + + // GET /organizations/:id this.get('/organizations/:id'); - /////////// - // Previews - /////////// + // PATCH /organizations/:id + this.patch('/organizations/:id'); + + /** + * Previews + */ // POST /previews this.post('/previews', function(schema) { @@ -159,9 +179,9 @@ export default function() { return schema.create('preview', attrs); }); - ///////////////////// - // Preview user mentions - ///////////////////// + /** + * Preview user mentions + */ // GET /preview-user-mentions this.get('/preview-user-mentions', (schema, request) => { @@ -170,43 +190,58 @@ export default function() { generatePreviewMentions(schema, preview); - return schema.previewUserMentions.where({ previewId: previewId }); + return schema.previewUserMentions.where({ previewId }); }); - ///////////////////// - // Project categories - ///////////////////// + /** + * Project categories + */ // GET /project-categories - this.get('/project-categories'); + this.get('/project-categories', { coalesce: true }); - // GET /project-categories + // POST /project-categories + this.post('/project-categories'); + + // GET /project-categories/:id this.get('/project-categories/:id'); - ///////////////// - // Project skills - ///////////////// + // DELETE /project-categories/:id + this.delete('/project-categories/:id'); - // GET /project-skills - this.get('/project-skills'); + /** + * Project skills + */ // GET /project-skills + this.get('/project-skills', { coalesce: true }); + + // POST /project-skills + this.post('/project-skills'); + + // GET /project-skills/:id this.get('/project-skills/:id'); - /////////// - // Projects - /////////// + // DELETE /project-skills/:id + this.delete('/project-skills/:id'); + + /** + * Projects + */ // GET /projects - this.get('/projects'); + this.get('/projects', { coalesce: true }); + + // POST /projects + this.post('/projects'); // GET /projects/:id this.get('/projects/:id'); // GET project/:id/tasks - this.get("/projects/:projectId/tasks", (schema, request) => { - let projectId = request.params.projectId; - let taskType = request.queryParams["task_type"]; + this.get('/projects/:projectId/tasks', (schema, request) => { + let { projectId } = request.params; + let taskType = request.queryParams.task_type; let taskStatus = request.queryParams.status; let pageNumber = parseInt(request.queryParams['page[page]']); @@ -214,10 +249,10 @@ export default function() { let project = schema.projects.find(projectId); - let tasks = project.tasks; + let { tasks } = project; if (taskType) { - tasks = tasks.filter((p) => p.taskType === taskType ); + tasks = tasks.filter((p) => p.taskType === taskType); } if (taskStatus) { @@ -233,10 +268,10 @@ export default function() { // hacky, but the only way I could find to pass in a mocked meta object // for our pagination tests tasksPage.meta = { - "total_records": tasks.models.length, - "total_pages": Math.ceil(tasks.models.length / pageSize), - "page_size": pageSize, - "current_page": pageNumber || 1 + 'total_records': tasks.models.length, + 'total_pages': Math.ceil(tasks.models.length / pageSize), + 'page_size': pageSize, + 'current_page': pageNumber || 1 }; return tasksPage; @@ -248,7 +283,9 @@ export default function() { let number = parseInt(request.params.number); let project = schema.projects.find(projectId); - let task = project.tasks.filter((p) => { return p.number === number; }).models[0]; + let [task] = project.tasks.filter((p) => { + return p.number === number; + }).models; task.comments.models.forEach((comment) => { generateCommentMentions(schema, comment); @@ -269,55 +306,81 @@ export default function() { return project; }); - //////// - // Roles - //////// + /** + * Roles + */ // GET /roles - this.get('/roles'); + this.get('/roles', { coalesce: true }); + + // POST /roles + this.post('/roles'); + + // GET /roles/:id + this.get('/roles/:id'); + + /** + * Role Skills + */ + + // GET /role-skills + this.get('/role-skills', { coalesce: true }); + + // POST /role-skills + this.post('/role-skills'); + + // GET /role-skills/:id + this.get('/role-skills/:id'); - /////////////////////////// - // Slugs and slugged routes - /////////////////////////// + // DELETE /role-skills/:id + this.delete('/role-skills/:id'); + + /** + * Slugs and slugged routes + */ // GET /:slug this.get('/:slug', (schema, request) => { if (routes.includes(request.params.slug)) { console.error('API route being caught in /:slug in mirage/config.js', request.params.slug); } - return schema.sluggedRoutes.where({'slug': request.params.slug }).models[0]; + return schema.sluggedRoutes.where({ 'slug': request.params.slug }).models[0]; }); // GET /:slug/projects this.get('/:slug/projects', (schema, request) => { - let slug = request.params.slug; - let organization = schema.organizations.where({ 'slug': slug }).models[0]; + let { slug } = request.params; + let [organization] = schema.organizations.where({ slug }).models; return organization.projects; }); // GET /:slug/:project_slug this.get('/:sluggedRouteSlug/:projectSlug', (schema, request) => { - let sluggedRouteSlug = request.params.sluggedRouteSlug; - let projectSlug = request.params.projectSlug; + let { sluggedRouteSlug, projectSlug } = request.params; - let sluggedRoute = schema.sluggedRoutes.where({ 'slug': sluggedRouteSlug }).models[0]; + let [sluggedRoute] = schema.sluggedRoutes.where({ 'slug': sluggedRouteSlug }).models; - return sluggedRoute.organization.projects.filter((p) => { return p.slug === projectSlug; }).models[0]; + return sluggedRoute.organization.projects.filter((p) => { + return p.slug === projectSlug; + }).models[0]; }); - ///////// - // Skills - ///////// + /** + * Skills + */ // GET /skills - this.get('/skills'); + this.get('/skills', { coalesce: true }); + + // POST /skills + this.post('/skills'); // GET /skills/:id this.get('/skills/:id'); - ///////////////////// - // Task user mentions - ///////////////////// + /** + * Task user mentions + */ // GET /task-user-mentions this.get('/task-user-mentions', (schema, request) => { @@ -326,12 +389,15 @@ export default function() { generateTaskMentions(schema, task); - return schema.taskUserMentions.where({ taskId: taskId }); + return schema.taskUserMentions.where({ taskId }); }); - //////// - // Tasks - //////// + /** + * Tasks + */ + + // GET /tasks + this.get('/tasks', { coalesce: true }); // POST /tasks this.post('/tasks', function(schema) { @@ -347,6 +413,9 @@ export default function() { return schema.create('task', attrs); }); + // GET /tasks/:id + this.get('/tasks/:id'); + // PATCH /tasks/:id this.patch('/tasks/:id', function(schema) { let attrs = this.normalizedRequestAttrs(); @@ -365,33 +434,32 @@ export default function() { // GET tasks/:number/comments this.get('/tasks/:taskId/comments', function(schema, request) { - let taskId = request.params.taskId; + let { taskId } = request.params; let task = schema.tasks.find(taskId); return task.comments; }); - //////// - // Token - //////// + /** + * Token + */ // POST /token this.post('/token', (db, request) => { - console.log(request); let json = JSON.parse(request.requestBody); - if(json.username === "volunteers@codecorps.org" && json.password === "password") { + if (json.username === 'volunteers@codecorps.org' && json.password === 'password') { return { // token encoded at https://jwt.io/ - token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXNzd29yZCI6InBhc3N3b3JkIiwidXNlcm5hbWUiOiJqb3NoQGNvZGVybHkuY29tIiwidXNlcl9pZCI6MSwiZXhwIjo3MjAwfQ.QVDyAznECIWL6DjDs9iPezvMmoPuzDqAl4bQ6CY-fCQ" + token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXNzd29yZCI6InBhc3N3b3JkIiwidXNlcm5hbWUiOiJqb3NoQGNvZGVybHkuY29tIiwidXNlcl9pZCI6MSwiZXhwIjo3MjAwfQ.QVDyAznECIWL6DjDs9iPezvMmoPuzDqAl4bQ6CY-fCQ' }; } else { - let errorDetail = "Your password doesn't match the email " + json.username + "."; + let errorDetail = `Your password doesn't match the email ${json.username}.`; return new Mirage.Response(401, {}, { errors: [ { - id: "UNAUTHORIZED", - title: "401 Unauthorized", + id: 'UNAUTHORIZED', + title: '401 Unauthorized', detail: errorDetail, status: 401 } @@ -400,9 +468,9 @@ export default function() { } }); - //////// - // Users - //////// + /** + * Users + */ this.get('/users', { coalesce: true }); @@ -429,7 +497,7 @@ export default function() { attrs.state = 'selected_skills'; break; default: - console.error("You added a transition without changing the state machine in Mirage."); + console.error('You added a transition without changing the state machine in Mirage.'); break; } @@ -448,12 +516,12 @@ export default function() { return { available: true, valid: true }; }); - ////////////////// - // User categories - ////////////////// + /** + * User categories + */ // GET /user-categories - this.get('/user-categories'); + this.get('/user-categories', { coalesce: true }); // POST /user-categories this.post('/user-categories'); @@ -464,26 +532,35 @@ export default function() { // DELETE /user-categories/:id this.delete('/user-categories/:id'); - ///////////// - // User roles - ///////////// + /** + * User roles + */ + + // GET /user-roles + this.get('/user-roles', { coalesce: true }); // POST /user-roles this.post('/user-roles'); - // DELETE /user-roles + // GET /user-roles + this.get('/user-roles/:id'); + + // DELETE /user-roles/:id this.delete('/user-roles/:id'); - ////////////// - // User skills - ////////////// + /** + * User skills + */ // GET /user-skills - this.get('/user-skills'); + this.get('/user-skills', { coalesce: true }); // POST /user-skills this.post('/user-skills'); + // GET /user-skills + this.get('/user-skills/:id'); + // DELETE /user-skills/:id this.delete('/user-skills/:id'); } diff --git a/mirage/factories/category.js b/mirage/factories/category.js index b772cffd6..fbc320072 100644 --- a/mirage/factories/category.js +++ b/mirage/factories/category.js @@ -3,5 +3,5 @@ import { Factory, faker } from 'ember-cli-mirage'; export default Factory.extend({ name() { return faker.name.jobArea(); - }, + } }); diff --git a/mirage/factories/comment.js b/mirage/factories/comment.js index f4961194e..77bb21bc9 100644 --- a/mirage/factories/comment.js +++ b/mirage/factories/comment.js @@ -1,5 +1,5 @@ import { Factory, faker } from 'ember-cli-mirage'; export default Factory.extend({ - body: faker.lorem.paragraph, + body: faker.lorem.paragraph }); diff --git a/mirage/factories/organization.js b/mirage/factories/organization.js index f2cdbd2e0..ff7ce0a2d 100644 --- a/mirage/factories/organization.js +++ b/mirage/factories/organization.js @@ -14,8 +14,8 @@ export default Factory.extend({ return faker.image.avatar(); }, slug() { - if(this.name) { + if (this.name) { return this.name.toLowerCase(); } - }, + } }); diff --git a/mirage/factories/project.js b/mirage/factories/project.js index 1e6b7428b..55493c194 100644 --- a/mirage/factories/project.js +++ b/mirage/factories/project.js @@ -1,6 +1,8 @@ import { Factory, faker } from 'ember-cli-mirage'; import Ember from 'ember'; +const { String } = Ember; + export default Factory.extend({ closedTasksCount: 0, description: faker.lorem.sentence, @@ -10,8 +12,8 @@ export default Factory.extend({ title: faker.name.title, slug() { - if(this.title) { - return Ember.String.underscore(this.title.toLowerCase()); + if (this.title) { + return String.underscore(this.title.toLowerCase()); } } }); diff --git a/mirage/factories/user.js b/mirage/factories/user.js index 4a60bdc20..1b3900b3c 100644 --- a/mirage/factories/user.js +++ b/mirage/factories/user.js @@ -8,5 +8,5 @@ export default Factory.extend({ twitter: faker.internet.domainWord, username: faker.internet.domainWord, website: faker.internet.url, - base64PhotoData: null, + base64PhotoData: null }); diff --git a/mirage/models/comment-user-mention.js b/mirage/models/comment-user-mention.js index 83fcb1752..2a51ee674 100644 --- a/mirage/models/comment-user-mention.js +++ b/mirage/models/comment-user-mention.js @@ -1,4 +1,4 @@ -import { Model, belongsTo, } from 'ember-cli-mirage'; +import { Model, belongsTo } from 'ember-cli-mirage'; export default Model.extend({ comment: belongsTo(), diff --git a/mirage/models/comment.js b/mirage/models/comment.js index 4c313eb3d..a6504e3b9 100644 --- a/mirage/models/comment.js +++ b/mirage/models/comment.js @@ -3,5 +3,5 @@ import { Model, belongsTo, hasMany } from 'ember-cli-mirage'; export default Model.extend({ commentUserMentions: hasMany(), task: belongsTo(), - user: belongsTo(), + user: belongsTo() }); diff --git a/mirage/models/organization-membership.js b/mirage/models/organization-membership.js index 8317935ba..d4f93c778 100644 --- a/mirage/models/organization-membership.js +++ b/mirage/models/organization-membership.js @@ -2,5 +2,5 @@ import { Model, belongsTo } from 'ember-cli-mirage'; export default Model.extend({ member: belongsTo('user'), - organization: belongsTo(), + organization: belongsTo() }); diff --git a/mirage/models/organization.js b/mirage/models/organization.js index 12cbf24be..1ead93192 100644 --- a/mirage/models/organization.js +++ b/mirage/models/organization.js @@ -2,5 +2,5 @@ import { Model, hasMany } from 'ember-cli-mirage'; export default Model.extend({ organizationMemberships: hasMany(), - projects: hasMany(), + projects: hasMany() }); diff --git a/mirage/models/preview-user-mention.js b/mirage/models/preview-user-mention.js index f2bf46995..1f1b504eb 100644 --- a/mirage/models/preview-user-mention.js +++ b/mirage/models/preview-user-mention.js @@ -1,4 +1,4 @@ -import { Model, belongsTo, } from 'ember-cli-mirage'; +import { Model, belongsTo } from 'ember-cli-mirage'; export default Model.extend({ preview: belongsTo(), diff --git a/mirage/models/preview.js b/mirage/models/preview.js index 7f5194013..6c4837606 100644 --- a/mirage/models/preview.js +++ b/mirage/models/preview.js @@ -2,5 +2,5 @@ import { Model, belongsTo, hasMany } from 'ember-cli-mirage'; export default Model.extend({ previewUserMentions: hasMany(), - user: belongsTo(), + user: belongsTo() }); diff --git a/mirage/models/project-category.js b/mirage/models/project-category.js index 5104f839f..cf0d26a7d 100644 --- a/mirage/models/project-category.js +++ b/mirage/models/project-category.js @@ -2,5 +2,5 @@ import { Model, belongsTo } from 'ember-cli-mirage'; export default Model.extend({ category: belongsTo(), - project: belongsTo(), + project: belongsTo() }); diff --git a/mirage/models/project-skill.js b/mirage/models/project-skill.js index f096507cb..cb59b2e54 100644 --- a/mirage/models/project-skill.js +++ b/mirage/models/project-skill.js @@ -2,5 +2,5 @@ import { Model, belongsTo } from 'ember-cli-mirage'; export default Model.extend({ project: belongsTo(), - skill: belongsTo(), + skill: belongsTo() }); diff --git a/mirage/models/project.js b/mirage/models/project.js index 9bdde836b..8f77b5acc 100644 --- a/mirage/models/project.js +++ b/mirage/models/project.js @@ -4,5 +4,5 @@ export default Model.extend({ organization: belongsTo(), tasks: hasMany(), projectCategories: hasMany(), - projectSkills: hasMany(), + projectSkills: hasMany() }); diff --git a/mirage/models/slugged-route.js b/mirage/models/slugged-route.js index 0481d9d14..4abeffaf2 100644 --- a/mirage/models/slugged-route.js +++ b/mirage/models/slugged-route.js @@ -2,5 +2,5 @@ import { Model, belongsTo } from 'ember-cli-mirage'; export default Model.extend({ organization: belongsTo(), - user: belongsTo(), + user: belongsTo() }); diff --git a/mirage/models/task-user-mention.js b/mirage/models/task-user-mention.js index d59536447..7234f1b54 100644 --- a/mirage/models/task-user-mention.js +++ b/mirage/models/task-user-mention.js @@ -1,4 +1,4 @@ -import { Model, belongsTo, } from 'ember-cli-mirage'; +import { Model, belongsTo } from 'ember-cli-mirage'; export default Model.extend({ task: belongsTo(), diff --git a/mirage/models/task.js b/mirage/models/task.js index 192448a58..e0c7bc672 100644 --- a/mirage/models/task.js +++ b/mirage/models/task.js @@ -5,5 +5,5 @@ export default Model.extend({ commentUserMentions: hasMany(), taskUserMentions: hasMany(), project: belongsTo(), - user: belongsTo(), + user: belongsTo() }); diff --git a/mirage/models/user-category.js b/mirage/models/user-category.js index baa6150d2..a32cd0f47 100644 --- a/mirage/models/user-category.js +++ b/mirage/models/user-category.js @@ -2,5 +2,5 @@ import { Model, belongsTo } from 'ember-cli-mirage'; export default Model.extend({ category: belongsTo(), - user: belongsTo(), + user: belongsTo() }); diff --git a/mirage/models/user-role.js b/mirage/models/user-role.js index 313faa4e5..ac2172d7f 100644 --- a/mirage/models/user-role.js +++ b/mirage/models/user-role.js @@ -2,5 +2,5 @@ import { Model, belongsTo } from 'ember-cli-mirage'; export default Model.extend({ role: belongsTo(), - user: belongsTo(), + user: belongsTo() }); diff --git a/mirage/models/user-skill.js b/mirage/models/user-skill.js index a7ecaee11..91e9024cb 100644 --- a/mirage/models/user-skill.js +++ b/mirage/models/user-skill.js @@ -2,5 +2,5 @@ import { Model, belongsTo } from 'ember-cli-mirage'; export default Model.extend({ skill: belongsTo(), - user: belongsTo(), + user: belongsTo() }); diff --git a/mirage/models/user.js b/mirage/models/user.js index 32b545708..13411a46e 100644 --- a/mirage/models/user.js +++ b/mirage/models/user.js @@ -4,5 +4,5 @@ export default Model.extend({ organizationMemberships: hasMany({ inverse: 'member' }), userCategories: hasMany(), userRoles: hasMany(), - UserSkills: hasMany(), + UserSkills: hasMany() }); diff --git a/mirage/scenarios/default.js b/mirage/scenarios/default.js index e07271cc9..0d2db8d3c 100644 --- a/mirage/scenarios/default.js +++ b/mirage/scenarios/default.js @@ -1,7 +1,11 @@ export default function(/* server */) { - // Seed your development database using your factories. This - // data will not be loaded in your tests. + /* + Seed your development database using your factories. + This data will not be loaded in your tests. - // server.createList('contact', 10); + Make sure to define a factory for each model you want to create. + */ + + // server.createList('post', 10); } diff --git a/mirage/serializers/application.js b/mirage/serializers/application.js index 6bf7e7ea3..6d47a3669 100644 --- a/mirage/serializers/application.js +++ b/mirage/serializers/application.js @@ -1,3 +1,4 @@ import { JSONAPISerializer } from 'ember-cli-mirage'; -export default JSONAPISerializer.extend(); +export default JSONAPISerializer.extend({ +}); diff --git a/mirage/serializers/comment.js b/mirage/serializers/comment.js index a49a3ea7f..859a2846d 100644 --- a/mirage/serializers/comment.js +++ b/mirage/serializers/comment.js @@ -1,5 +1,5 @@ import { JSONAPISerializer } from 'ember-cli-mirage'; export default JSONAPISerializer.extend({ - include: ['comment-user-mentions'], + include: ['comment-user-mentions'] }); diff --git a/package.json b/package.json index 8ee3ee5b8..e913b38e4 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "scripts": { "build": "ember build", "start": "ember server", - "test": "ember exam" + "test": "ember try:one default" }, "repository": "", "engines": { @@ -48,8 +48,8 @@ "ember-cli-ic-ajax": "1.0.0", "ember-cli-inject-live-reload": "^1.4.0", "ember-cli-meta-tags": "3.0.1", - "ember-cli-mirage": "^0.2.1", - "ember-cli-moment-shim": "2.1.0", + "ember-cli-mirage": "^0.2.2", + "ember-cli-moment-shim": "2.2.0", "ember-cli-neat": "0.0.5", "ember-cli-pace": "0.1.0", "ember-cli-page-object": "1.6.0", @@ -63,7 +63,7 @@ "ember-cli-uglify": "^1.2.0", "ember-click-outside": "0.1.2", "ember-composable-helpers": "1.1.2", - "ember-concurrency": "0.7.10", + "ember-concurrency": "^0.7.11", "ember-data": "^2.8.0", "ember-deferred-content": "0.2.0", "ember-disable-proxy-controllers": "^1.0.1", @@ -73,13 +73,14 @@ "ember-metrics": "0.6.3", "ember-modal-dialog": "0.8.8", "ember-moment": "7.0.0-beta.3", - "ember-page-title": "3.0.9", + "ember-page-title": "^3.0.10", "ember-resolver": "^2.0.3", + "ember-route-action-helper": "^2.0.0", "ember-simple-auth": "1.1.0", "ember-simple-auth-token": "^1.1.1", "ember-sinon": "0.5.1", "ember-tether": "0.3.1", - "ember-tooltips": "2.0.1", + "ember-tooltips": "2.3.1", "ember-truth-helpers": "1.2.0", "ember-typed": "0.1.3", "eslint-plugin-ember-suave": "^1.0.0", diff --git a/tests/acceptance/code-theme-test.js b/tests/acceptance/code-theme-test.js index 174a11bbd..c9f32b2f4 100644 --- a/tests/acceptance/code-theme-test.js +++ b/tests/acceptance/code-theme-test.js @@ -1,18 +1,8 @@ -import Ember from 'ember'; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import indexPage from '../pages/index'; -let application; - -module('Acceptance: Code Theme', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); +moduleForAcceptance('Acceptance | Code Theme'); test('Code theme class exists on the main container', function(assert) { assert.expect(1); diff --git a/tests/acceptance/contributors-test.js b/tests/acceptance/contributors-test.js index 01f3876f8..a057e4286 100644 --- a/tests/acceptance/contributors-test.js +++ b/tests/acceptance/contributors-test.js @@ -1,12 +1,8 @@ import { test } from 'qunit'; import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; -import startApp from '../helpers/start-app'; import { authenticateSession } from 'code-corps-ember/tests/helpers/ember-simple-auth'; import createProjectWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-project-with-slugged-route'; import page from '../pages/contributors'; -import Ember from 'ember'; - -let application; function buildURLParts(project_organization_slug, project_slug) { return { @@ -18,14 +14,7 @@ function buildURLParts(project_organization_slug, project_slug) { }; } -moduleForAcceptance('Acceptance: Contributors', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); +moduleForAcceptance('Acceptance: Contributors'); test('when not an admin on the project', function(assert) { assert.expect(1); @@ -41,7 +30,7 @@ test('when not an admin on the project', function(assert) { let contributorURLParts = buildURLParts(project.organization.slug, project.slug); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); page.visit(contributorURLParts.args); @@ -63,7 +52,7 @@ test('when only the owner is a contributor', function(assert) { let contributorURLParts = buildURLParts(project.organization.slug, project.slug); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); page.visit(contributorURLParts.args); @@ -119,7 +108,7 @@ test('when there are multiple contributors', function(assert) { let contributorURLParts = buildURLParts(project.organization.slug, project.slug); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); page.visit(contributorURLParts.args); @@ -146,7 +135,9 @@ test('when there are multiple contributors', function(assert) { assert.equal(page.pendingContributors.members().count, 1, 'Pending contributors has 1 member listed'); assert.equal(page.others.members().count, 2, 'Others has 2 members listed'); - window.confirm = function() { return true; }; + window.confirm = function() { + return true; + }; page.pendingContributors.members(0).denyMembership(); }); diff --git a/tests/acceptance/login-test.js b/tests/acceptance/login-test.js index 86dec6a86..9e0788dee 100644 --- a/tests/acceptance/login-test.js +++ b/tests/acceptance/login-test.js @@ -1,20 +1,10 @@ -import Ember from 'ember'; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import { authenticateSession } from 'code-corps-ember/tests/helpers/ember-simple-auth'; import loginPage from '../pages/login'; import signupPage from '../pages/signup'; -let application; - -module('Acceptance: Login', { - beforeEach: () => { - application = startApp(); - }, - afterEach: () => { - Ember.run(application, 'destroy'); - } -}); +moduleForAcceptance('Acceptance | Login'); test('Logging in', function(assert) { assert.expect(2); @@ -35,7 +25,7 @@ test('Logging in', function(assert) { test('Login failure', function(assert) { // Mirage expects volunteers@codecorps.org as default email - const ERROR_TEXT = "Your password doesn't match the email volunteers@codecorps.org."; + let ERROR_TEXT = "Your password doesn't match the email volunteers@codecorps.org."; assert.expect(2); @@ -55,7 +45,7 @@ test('When authenticated, redirects from login', function(assert) { assert.expect(1); let user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); loginPage.visit(); @@ -68,7 +58,7 @@ test('When authenticated, redirects from signup', function(assert) { assert.expect(1); let user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); signupPage.visit(); diff --git a/tests/acceptance/logout-test.js b/tests/acceptance/logout-test.js index 5cbc7bd2a..d52a85f24 100644 --- a/tests/acceptance/logout-test.js +++ b/tests/acceptance/logout-test.js @@ -1,30 +1,20 @@ -import Ember from "ember"; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import { authenticateSession } from 'code-corps-ember/tests/helpers/ember-simple-auth'; import indexPage from '../pages/index'; -let application; +moduleForAcceptance('Acceptance | Logout'); -module('Acceptance: Logout', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); - -test("Logging out", function(assert) { +test('Logging out', function(assert) { assert.expect(2); let user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); indexPage.visit(); andThen(function() { - assert.equal(indexPage.navMenu.userMenu.logOut.text, "Log out", "Page contains logout link"); + assert.equal(indexPage.navMenu.userMenu.logOut.text, 'Log out', 'Page contains logout link'); indexPage.navMenu.userMenu.logOut.click(); }); andThen(function() { - assert.equal(indexPage.navMenu.logIn.text, "Sign in", "Page contains login link"); + assert.equal(indexPage.navMenu.logIn.text, 'Sign in', 'Page contains login link'); }); }); diff --git a/tests/acceptance/navigation-test.js b/tests/acceptance/navigation-test.js index 1e967935b..336742bbc 100644 --- a/tests/acceptance/navigation-test.js +++ b/tests/acceptance/navigation-test.js @@ -1,44 +1,34 @@ -import Ember from "ember"; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import { authenticateSession } from 'code-corps-ember/tests/helpers/ember-simple-auth'; import createUserWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-user-with-slugged-route'; import indexPage from '../pages/index'; import signupPage from '../pages/signup'; import loginPage from '../pages/login'; -let application; +moduleForAcceptance('Acceptance | Navigation'); -module('Acceptance: Navigation', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); - -test("Logged out, can sign up", function(assert) { +test('Logged out, can sign up', function(assert) { assert.expect(2); indexPage.visit(); andThen(function() { - assert.equal(indexPage.navMenu.signUp.text, "Sign up", "Page contains sign up link"); + assert.equal(indexPage.navMenu.signUp.text, 'Sign up', 'Page contains sign up link'); indexPage.navMenu.signUp.click(); }); andThen(function() { - assert.ok(signupPage.form.isVisible, "Page contains sign up form"); + assert.ok(signupPage.form.isVisible, 'Page contains sign up form'); }); }); -test("Logged out, can sign in", function(assert) { +test('Logged out, can sign in', function(assert) { assert.expect(2); indexPage.visit(); andThen(function() { - assert.equal(indexPage.navMenu.logIn.text, "Sign in", "Page contains sign in link"); + assert.equal(indexPage.navMenu.logIn.text, 'Sign in', 'Page contains sign in link'); indexPage.navMenu.logIn.click(); }); andThen(function() { - assert.ok(loginPage.form.isVisible, "Page contains login form"); + assert.ok(loginPage.form.isVisible, 'Page contains login form'); }); }); @@ -46,7 +36,7 @@ test('Logged in, from user menu can visit profile', function(assert) { assert.expect(2); let user = createUserWithSluggedRoute(); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); indexPage.visit(); @@ -66,14 +56,14 @@ test('Logged in, from user menu can visit profile settings', function(assert) { assert.expect(2); let user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); indexPage.visit(); andThen(function() { indexPage.navMenu.userMenu.open(); }); andThen(function() { - assert.equal(indexPage.navMenu.userMenu.settingsLink.href, "/settings/profile", "Menu links to the profile settings"); + assert.equal(indexPage.navMenu.userMenu.settingsLink.href, '/settings/profile', 'Menu links to the profile settings'); indexPage.navMenu.userMenu.settingsLink.click(); }); andThen(function() { @@ -81,11 +71,11 @@ test('Logged in, from user menu can visit profile settings', function(assert) { }); }); -test("Logged in, from user menu can log out", function(assert) { +test('Logged in, from user menu can log out', function(assert) { assert.expect(1); let user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); indexPage.visit(); andThen(function() { @@ -95,6 +85,6 @@ test("Logged in, from user menu can log out", function(assert) { indexPage.navMenu.userMenu.logOut.click(); }); andThen(function() { - assert.equal(indexPage.navMenu.logIn.text, "Sign in", "Page contains sign in link"); + assert.equal(indexPage.navMenu.logIn.text, 'Sign in', 'Page contains sign in link'); }); }); diff --git a/tests/acceptance/onboarding-test.js b/tests/acceptance/onboarding-test.js index d1be70835..3c6b1ddc4 100644 --- a/tests/acceptance/onboarding-test.js +++ b/tests/acceptance/onboarding-test.js @@ -1,24 +1,14 @@ -import Ember from "ember"; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import { authenticateSession } from 'code-corps-ember/tests/helpers/ember-simple-auth'; -import onboardingPage from '../pages/onboarding'; -import indexPage from '../pages/index'; +import onboardingPage from 'code-corps-ember/tests/pages/onboarding'; +import indexPage from 'code-corps-ember/tests/pages/index'; -let application; +moduleForAcceptance('Acceptance | Onboarding'); -module('Acceptance: Onboarding', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); - -test('A user can onboard as expected', (assert) => { - let user = server.create('user', { username: 'test_user', state: 'signed_up' }); - server.create('category'); +test('A user can onboard as expected', function(assert) { + let user = server.create('user', { username: 'test_user', state: 'signed_up' }); + server.create('category'); server.create('role', { name: 'Backend Developer', ability: 'Backend Development', @@ -38,7 +28,7 @@ test('A user can onboard as expected', (assert) => { title: 'Ruby' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); indexPage.visit(); @@ -140,10 +130,10 @@ test('A user can onboard as expected', (assert) => { }); }); -test('A user cannot navigate away from the onboarding', (assert) => { +test('A user cannot navigate away from the onboarding', function(assert) { let user = server.create('user', { username: 'test_user', state: 'signed_up' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); indexPage.visit(); @@ -157,7 +147,7 @@ test('A user cannot navigate away from the onboarding', (assert) => { }); }); -test('A user cannot navigate to onboarding when signed out', (assert) => { +test('A user cannot navigate to onboarding when signed out', function(assert) { assert.expect(4); // TODO: Make this work with currentURL(), doesn't work with it right now @@ -176,10 +166,10 @@ test('A user cannot navigate to onboarding when signed out', (assert) => { }); }); -test('A user can submit name by hitting enter key on firstName input field', (assert) => { +test('A user can submit name by hitting enter key on firstName input field', function(assert) { let user = server.create('user', { username: 'test_user', state: 'signed_up' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); indexPage.visit(); @@ -200,10 +190,10 @@ test('A user can submit name by hitting enter key on firstName input field', (as }); }); -test('A user can submit name by hitting enter key on lastName input field', (assert) => { +test('A user can submit name by hitting enter key on lastName input field', function(assert) { let user = server.create('user', { username: 'test_user', state: 'signed_up' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); indexPage.visit(); @@ -224,10 +214,10 @@ test('A user can submit name by hitting enter key on lastName input field', (ass }); }); -test('A user cannot submit name by hitting enter key if firstName input field is blank', (assert) => { +test('A user cannot submit name by hitting enter key if firstName input field is blank', function(assert) { let user = server.create('user', { username: 'test_user', state: 'signed_up' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); indexPage.visit(); @@ -247,10 +237,10 @@ test('A user cannot submit name by hitting enter key if firstName input field is }); }); -test('A user cannot submit name by hitting enter key if lastName input field is blank', (assert) => { +test('A user cannot submit name by hitting enter key if lastName input field is blank', function(assert) { let user = server.create('user', { username: 'test_user', state: 'signed_up' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); indexPage.visit(); @@ -270,10 +260,10 @@ test('A user cannot submit name by hitting enter key if lastName input field is }); }); -test('The footer is hidden when onboarding', (assert) => { +test('The footer is hidden when onboarding', function(assert) { let user = server.create('user', { username: 'test_user', state: 'signed_up' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); indexPage.visit(); diff --git a/tests/acceptance/organization-projects-test.js b/tests/acceptance/organization-projects-test.js index 98575cc88..fe56f9d78 100644 --- a/tests/acceptance/organization-projects-test.js +++ b/tests/acceptance/organization-projects-test.js @@ -1,21 +1,11 @@ -import Ember from "ember"; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import organizationProjects from '../pages/organization-projects'; import createOrganizationWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-organization-with-slugged-route'; -let application; +moduleForAcceptance('Acceptance | Organization projects'); -module('Acceptance: Organization projects', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); - -test('It renders all the required ui elements', (assert) => { +test('It renders all the required ui elements', function(assert) { assert.expect(3); let organization = createOrganizationWithSluggedRoute(); diff --git a/tests/acceptance/organization-settings-profile-test.js b/tests/acceptance/organization-settings-profile-test.js index 031a383da..dd13a1f85 100644 --- a/tests/acceptance/organization-settings-profile-test.js +++ b/tests/acceptance/organization-settings-profile-test.js @@ -1,24 +1,14 @@ -import Ember from "ember"; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import { authenticateSession } from 'code-corps-ember/tests/helpers/ember-simple-auth'; import createOrganizationWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-organization-with-slugged-route'; import fillInFileInput from '../helpers/fill-in-file-input'; import removeDoubleQuotes from '../helpers/remove-double-quotes'; import organizationPage from '../pages/organization'; -let application; +moduleForAcceptance('Acceptance | Organization Settings – Profile'); -module('Acceptance: Organization Settings – Profile', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); - -test("it requires authentication", (assert) => { +test('it requires authentication', function(assert) { assert.expect(1); let organization = createOrganizationWithSluggedRoute(); @@ -29,10 +19,10 @@ test("it requires authentication", (assert) => { }); }); -test("it allows editing of organization profile", (assert) => { +test('it allows editing of organization profile', function(assert) { assert.expect(4); - var user = server.create('user'); + let user = server.create('user'); let organization = createOrganizationWithSluggedRoute(); @@ -42,7 +32,7 @@ test("it allows editing of organization profile", (assert) => { role: 'admin' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); organizationPage.visitSettingsProfile({ organization: organization.slug }); andThen(() => { @@ -58,7 +48,7 @@ test("it allows editing of organization profile", (assert) => { assert.equal(attrs.description, 'Lorem edit'); done(); - return this._getJsonApiDocForRequest(request, "organization"); + return this._getJsonApiDocForRequest(request, 'organization'); }); @@ -68,13 +58,13 @@ test("it allows editing of organization profile", (assert) => { }); }); -test("it allows editing of organization's image", (assert) => { +test("it allows editing of organization's image", function(assert) { assert.expect(4); let fileName = 'file.png'; - let droppedImageString = "data:image/png;base64,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"; + let droppedImageString = 'data:image/png;base64,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'; - var user = server.create('user'); + let user = server.create('user'); let organization = createOrganizationWithSluggedRoute(); @@ -84,7 +74,7 @@ test("it allows editing of organization's image", (assert) => { role: 'admin' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); organizationPage.visitSettingsProfile({ organization: organization.slug }); @@ -101,7 +91,7 @@ test("it allows editing of organization's image", (assert) => { assert.equal(attrs.base64IconData, droppedImageString); done(); - return this._getJsonApiDocForRequest(request, "organization"); + return this._getJsonApiDocForRequest(request, 'organization'); }); andThen(() => { diff --git a/tests/acceptance/organization-test.js b/tests/acceptance/organization-test.js index 7f5ad8e94..cfe3cad52 100644 --- a/tests/acceptance/organization-test.js +++ b/tests/acceptance/organization-test.js @@ -1,28 +1,23 @@ -import Ember from 'ember'; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import { authenticateSession } from 'code-corps-ember/tests/helpers/ember-simple-auth'; +import Ember from 'ember'; import createOrganizationWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-organization-with-slugged-route'; import organizationPage from '../pages/organization'; -let application; +const { + run +} = Ember; -module('Acceptance: Organization', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); +moduleForAcceptance('Acceptance | Organization'); -test("it displays the organization's details", (assert) => { +test("it displays the organization's details", function(assert) { assert.expect(7); let organization = server.create('organization', { description: 'Test description.' }); server.create('sluggedRoute', { slug: organization.slug, - organization, + organization }); server.createList('project', 3, { organization }); @@ -40,7 +35,7 @@ test("it displays the organization's details", (assert) => { }); }); -test('an admin can navigate to settings', (assert) => { +test('an admin can navigate to settings', function(assert) { assert.expect(3); let organization = createOrganizationWithSluggedRoute(); @@ -49,18 +44,18 @@ test('an admin can navigate to settings', (assert) => { server.create('organization-membership', { member: user, organization, - role: 'admin', + role: 'admin' }); // we assume authenticate session here. specific behavior regarding authentication and // showing/hiding of links is handled in the organization-menu component integration test - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); organizationPage.visitIndex({ organization: organization.slug }); andThen(() => { assert.ok(organizationPage.projectsMenuItemIsActive, 'The organization projects menu is active'); - Ember.run.next(() => { + run.next(() => { organizationPage.clickSettingsMenuItem(); andThen(() => { assert.ok(organizationPage.settingsMenuItemIsActive, 'The organization settings menu is active'); @@ -71,7 +66,7 @@ test('an admin can navigate to settings', (assert) => { }); -test('anyone can navigate to projects', (assert) => { +test('anyone can navigate to projects', function(assert) { assert.expect(2); let organization = createOrganizationWithSluggedRoute(); @@ -81,7 +76,7 @@ test('anyone can navigate to projects', (assert) => { // organization project list let user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); organizationPage.visitIndex({ organization: organization.slug }); diff --git a/tests/acceptance/profile-test.js b/tests/acceptance/profile-test.js index c26dc282e..798268cb4 100644 --- a/tests/acceptance/profile-test.js +++ b/tests/acceptance/profile-test.js @@ -1,22 +1,12 @@ -import Ember from 'ember'; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import createOrganizationWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-organization-with-slugged-route'; import createUserWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-user-with-slugged-route'; import userProfile from '../pages/user'; -let application; +moduleForAcceptance('Acceptance | Profile'); -module('Acceptance: Profile', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); - -test('it displays the user-details component with user details', (assert) => { +test('it displays the user-details component with user details', function(assert) { assert.expect(5); let user = createUserWithSluggedRoute(); @@ -34,7 +24,7 @@ test('it displays the user-details component with user details', (assert) => { }); }); -test('the user can navigate to an organization from the organizations list', (assert) => { +test('the user can navigate to an organization from the organizations list', function(assert) { assert.expect(2); let user = createUserWithSluggedRoute(); diff --git a/tests/acceptance/project-about-test.js b/tests/acceptance/project-about-test.js index 430b6e3ce..845de46a5 100644 --- a/tests/acceptance/project-about-test.js +++ b/tests/acceptance/project-about-test.js @@ -1,22 +1,12 @@ -import Ember from "ember"; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import { authenticateSession } from 'code-corps-ember/tests/helpers/ember-simple-auth'; import createOrganizationWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-organization-with-slugged-route'; import projectAboutPage from '../pages/project/about'; -let application; +moduleForAcceptance('Acceptance | Project - About'); -module('Acceptance: Project - About', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); - -test('When unauthenticated, and project has no long description, it shows proper UI', (assert) => { +test('When unauthenticated, and project has no long description, it shows proper UI', function(assert) { assert.expect(2); let organization = createOrganizationWithSluggedRoute(); let project = server.create('project', { @@ -36,7 +26,7 @@ test('When unauthenticated, and project has no long description, it shows proper }); }); -test('When unauthenticated, and project has long description, it shows the project long description', (assert) => { +test('When unauthenticated, and project has long description, it shows the project long description', function(assert) { assert.expect(2); let organization = createOrganizationWithSluggedRoute(); let project = server.create('project', { @@ -56,7 +46,7 @@ test('When unauthenticated, and project has long description, it shows the proje }); }); -test('When authenticated as admin, and project has no long description, it allows setting it', (assert) => { +test('When authenticated as admin, and project has no long description, it allows setting it', function(assert) { assert.expect(4); let user = server.create('user'); @@ -69,7 +59,7 @@ test('When authenticated as admin, and project has no long description, it allow organization }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); projectAboutPage.visit({ organization: organization.slug, @@ -89,7 +79,7 @@ test('When authenticated as admin, and project has no long description, it allow }); }); -test('When authenticated as admin, and project has long description, it allows editing it', (assert) => { +test('When authenticated as admin, and project has long description, it allows editing it', function(assert) { assert.expect(4); let user = server.create('user'); @@ -102,7 +92,7 @@ test('When authenticated as admin, and project has long description, it allows e organization }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); projectAboutPage.visit({ organization: organization.slug, diff --git a/tests/acceptance/project-settings-test.js b/tests/acceptance/project-settings-test.js index 2bd1431aa..2586020f2 100644 --- a/tests/acceptance/project-settings-test.js +++ b/tests/acceptance/project-settings-test.js @@ -1,22 +1,12 @@ -import Ember from "ember"; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import { authenticateSession } from 'code-corps-ember/tests/helpers/ember-simple-auth'; import createProjectWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-project-with-slugged-route'; import projectSettingsPage from '../pages/project/settings/profile'; -let application; +moduleForAcceptance('Acceptance | Project Settings - Profile'); -module('Acceptance: Project Settings - Profile', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); - -test("it requires authentication", (assert) => { +test('it requires authentication', function(assert) { assert.expect(1); let project = createProjectWithSluggedRoute(); @@ -31,10 +21,10 @@ test("it requires authentication", (assert) => { }); }); -test("it allows editing of project profile", (assert) => { +test('it allows editing of project profile', function(assert) { assert.expect(4); - var user = server.create('user'); + let user = server.create('user'); let project = createProjectWithSluggedRoute(); @@ -44,7 +34,7 @@ test("it allows editing of project profile", (assert) => { role: 'admin' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); projectSettingsPage.visit({ organization: project.organization.slug, @@ -67,21 +57,21 @@ test("it allows editing of project profile", (assert) => { assert.equal(attrs.description, 'Lorem edit'); done(); - return this._getJsonApiDocForRequest(request, "project"); + return this._getJsonApiDocForRequest(request, 'project'); }); andThen(() => { assert.ok(projectSettingsPage.successAlert.isVisible); - assert.equal(projectSettingsPage.successAlert.message, "Project updated successfully"); + assert.equal(projectSettingsPage.successAlert.message, 'Project updated successfully'); }); }); -test("it allows editing of project's image", (assert) => { +test("it allows editing of project's image", function(assert) { assert.expect(4); - let droppedImageString = "data:image/png;base64,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"; + let droppedImageString = 'data:image/png;base64,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'; - var user = server.create('user'); + let user = server.create('user'); let project = createProjectWithSluggedRoute(); @@ -91,7 +81,7 @@ test("it allows editing of project's image", (assert) => { role: 'admin' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); projectSettingsPage.visit({ organization: project.organization.slug, @@ -106,7 +96,7 @@ test("it allows editing of project's image", (assert) => { assert.equal(attrs.base64IconData, droppedImageString); done(); - return this._getJsonApiDocForRequest(request, "project"); + return this._getJsonApiDocForRequest(request, 'project'); }); andThen(() => { @@ -116,7 +106,7 @@ test("it allows editing of project's image", (assert) => { andThen(() => { assert.ok(projectSettingsPage.successAlert.isVisible); - assert.equal(projectSettingsPage.successAlert.message, "Project updated successfully"); + assert.equal(projectSettingsPage.successAlert.message, 'Project updated successfully'); assert.equal(projectSettingsPage.projectSettingsForm.imageDrop.backgroundImageData(), `url(${droppedImageString})`); }); }); diff --git a/tests/acceptance/project-test.js b/tests/acceptance/project-test.js index 4d4d9ea44..08194ee8c 100644 --- a/tests/acceptance/project-test.js +++ b/tests/acceptance/project-test.js @@ -1,26 +1,16 @@ -import Ember from "ember"; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import { authenticateSession } from 'code-corps-ember/tests/helpers/ember-simple-auth'; import createProjectWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-project-with-slugged-route'; import projectTasksIndexPage from '../pages/project/tasks/index'; -let application; +moduleForAcceptance('Acceptance | Project'); -module('Acceptance: Project', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); - -test('It renders navigation properly', (assert) => { +test('It renders navigation properly', function(assert) { assert.expect(2); let project = createProjectWithSluggedRoute(); - let organization = project.organization; + let { organization } = project; projectTasksIndexPage.visit({ organization: organization.slug, project: project.slug }); let aboutURL = `/${organization.slug}/${project.slug}`; let tasksURL = `${aboutURL}/tasks`; @@ -31,11 +21,11 @@ test('It renders navigation properly', (assert) => { }); }); -test('Navigation works', (assert) => { +test('Navigation works', function(assert) { assert.expect(6); let project = createProjectWithSluggedRoute(); - let organization = project.organization; + let { organization } = project; projectTasksIndexPage.visit({ organization: organization.slug, project: project.slug }); andThen(function() { @@ -54,12 +44,12 @@ test('Navigation works', (assert) => { }); }); -test('It renders all the required ui elements for task list', (assert) => { +test('It renders all the required ui elements for task list', function(assert) { assert.expect(4); let project = createProjectWithSluggedRoute(); server.createList('task', 5, { project }); - let organization = project.organization; + let { organization } = project; projectTasksIndexPage.visit({ organization: organization.slug, project: project.slug }); let tasksURL = `/${organization.slug}/${project.slug}/tasks`; @@ -74,11 +64,11 @@ test('It renders all the required ui elements for task list', (assert) => { }); }); -test('Task filtering by type works', (assert) => { +test('Task filtering by type works', function(assert) { assert.expect(4); let project = createProjectWithSluggedRoute(); - let organization = project.organization; + let { organization } = project; // we use server.createList so factories are used in creation server.createList('task', 1, { taskType: 'idea', project }); @@ -109,7 +99,7 @@ test('Task filtering by type works', (assert) => { }); }); -test('Task filtering by status works', (assert) => { +test('Task filtering by status works', function(assert) { assert.expect(8); let project = createProjectWithSluggedRoute(); @@ -180,7 +170,7 @@ test('Task paging links are correct', (assert) => { }); }); -test('Paging of tasks works', (assert) => { +test('Paging of tasks works', function(assert) { assert.expect(3); let project = createProjectWithSluggedRoute(); @@ -201,7 +191,7 @@ test('Paging of tasks works', (assert) => { }); }); -test('Paging and filtering of tasks combined works', (assert) => { +test('Paging and filtering of tasks combined works', function(assert) { assert.expect(9); let project = createProjectWithSluggedRoute(); @@ -250,7 +240,7 @@ test('Paging and filtering of tasks combined works', (assert) => { }); }); -test('Paging and filtering uses query parameters', (assert) => { +test('Paging and filtering uses query parameters', function(assert) { assert.expect(6); let project = createProjectWithSluggedRoute(); @@ -293,7 +283,7 @@ test('Paging and filtering uses query parameters', (assert) => { }); }); -test('A user can join the organization of the project', (assert) => { +test('A user can join the organization of the project', function(assert) { assert.expect(5); let project = createProjectWithSluggedRoute(); @@ -305,11 +295,10 @@ test('A user can join the organization of the project', (assert) => { andThen(() => { assert.equal(projectTasksIndexPage.projectDetails.signUpLink.text, 'Sign up', 'The link to sign up is present when logged out'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); visit(projectURL); }); - andThen(() => { let joinButton = projectTasksIndexPage.projectDetails.joinProjectButton; assert.equal(joinButton.text, 'Join project', 'The button to join is present when logged in'); @@ -319,8 +308,7 @@ test('A user can join the organization of the project', (assert) => { let done = assert.async(); server.post('/organization-memberships', (db, request) => { - let attributes = JSON.parse(request.requestBody).data.attributes; - let relationships = JSON.parse(request.requestBody).data.relationships; + let { attributes, relationships } = JSON.parse(request.requestBody).data; assert.equal(attributes.role, 'pending'); assert.equal(relationships.member.data.id, user.id); assert.equal(relationships.organization.data.id, project.organization.id); @@ -329,9 +317,9 @@ test('A user can join the organization of the project', (assert) => { return { data: { id: 1, - type: "organization-membership", - attributes: attributes, - relationships: relationships + type: 'organization-membership', + attributes, + relationships } }; }); diff --git a/tests/acceptance/projects-test.js b/tests/acceptance/projects-test.js index e036b2536..40d95ce3f 100644 --- a/tests/acceptance/projects-test.js +++ b/tests/acceptance/projects-test.js @@ -24,11 +24,11 @@ test('visiting /projects', function(assert) { }); }); -test('members are displayed correctly', (assert) => { +test('members are displayed correctly', function(assert) { let project = createProjectWithSluggedRoute(); - let organization = project.organization; + let { organization } = project; server.createList('organizationMembership', 10, { - role: "contributor", + role: 'contributor', organization }); diff --git a/tests/acceptance/settings-profile-test.js b/tests/acceptance/settings-profile-test.js index 472787dd2..38bedf6fd 100644 --- a/tests/acceptance/settings-profile-test.js +++ b/tests/acceptance/settings-profile-test.js @@ -1,21 +1,11 @@ -import Ember from "ember"; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import { authenticateSession } from 'code-corps-ember/tests/helpers/ember-simple-auth'; import settingsProfilePage from '../pages/settings-profile'; -let application; +moduleForAcceptance('Acceptance | Settings – Profile'); -module('Acceptance: Settings – Profile', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); - -test("it requires authentication", (assert) => { +test('it requires authentication', function(assert) { assert.expect(1); settingsProfilePage.visit(); @@ -24,23 +14,23 @@ test("it requires authentication", (assert) => { }); }); -test("it displays the user-settings-form component", (assert) => { +test('it displays the user-settings-form component', function(assert) { assert.expect(1); let user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); settingsProfilePage.visit(); andThen(() => { assert.ok(settingsProfilePage.userSettingsForm.isVisible); }); }); -test("it allows editing of users profile", (assert) => { +test('it allows editing of users profile', function(assert) { assert.expect(7); let user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); settingsProfilePage.visit(); @@ -65,22 +55,22 @@ test("it allows editing of users profile", (assert) => { assert.equal(attrs.biography, 'Lorem edit'); done(); - return this._getJsonApiDocForRequest(request, "user"); + return this._getJsonApiDocForRequest(request, 'user'); }); andThen(() => { assert.ok(settingsProfilePage.successAlert.isVisible); - assert.equal(settingsProfilePage.successAlert.message, "Profile updated successfully"); + assert.equal(settingsProfilePage.successAlert.message, 'Profile updated successfully'); }); }); -test("it allows editing of users image", (assert) => { +test('it allows editing of users image', function(assert) { assert.expect(4); - var user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + let user = server.create('user'); + authenticateSession(this.application, { user_id: user.id }); - let droppedImageString = "data:image/png;base64,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"; + let droppedImageString = 'data:image/png;base64,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'; settingsProfilePage.visit(); @@ -92,7 +82,7 @@ test("it allows editing of users image", (assert) => { assert.equal(attrs.base64PhotoData, droppedImageString); done(); - return this._getJsonApiDocForRequest(request, "user"); + return this._getJsonApiDocForRequest(request, 'user'); }); andThen(() => { @@ -102,7 +92,7 @@ test("it allows editing of users image", (assert) => { andThen(() => { assert.ok(settingsProfilePage.successAlert.isVisible); - assert.equal(settingsProfilePage.successAlert.message, "Profile updated successfully"); + assert.equal(settingsProfilePage.successAlert.message, 'Profile updated successfully'); assert.equal(settingsProfilePage.userSettingsForm.imageDrop.backgroundImageData(), `url(${droppedImageString})`); }); }); diff --git a/tests/acceptance/signup-test.js b/tests/acceptance/signup-test.js index b0c2468ed..27cb15f45 100644 --- a/tests/acceptance/signup-test.js +++ b/tests/acceptance/signup-test.js @@ -1,21 +1,11 @@ -import Ember from "ember"; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import indexPage from '../pages/index'; import signupPage from '../pages/signup'; -let application; +moduleForAcceptance('Acceptance | Signup'); -module('Acceptance: Signup', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); - -test('Signup form is accessible from the main site', (assert) => { +test('Signup form is accessible from the main site', function(assert) { assert.expect(2); indexPage.visit(); @@ -30,7 +20,7 @@ test('Signup form is accessible from the main site', (assert) => { }); }); -test('Successful signup', (assert) => { +test('Successful signup', function(assert) { assert.expect(6); signupPage.visit(); @@ -43,7 +33,7 @@ test('Successful signup', (assert) => { server.post('/users/', (db, request) => { let params = JSON.parse(request.requestBody).data.attributes; - params["state"] = "signed_up"; + params.state = 'signed_up'; assert.equal(params.username, 'username'); assert.equal(params.email, 'email@example.com'); @@ -65,8 +55,8 @@ test('Successful signup', (assert) => { signInDone(); return { - token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXNzd29yZCI6InBhc3N3b3JkIiwidXNlcm5hbWUiOiJqb3NoQGNvZGVybHkuY29tIiwidXNlcl9pZCI6MSwiZXhwIjo3MjAwfQ.QVDyAznECIWL6DjDs9iPezvMmoPuzDqAl4bQ6CY-fCQ", - user_id: 1, + token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXNzd29yZCI6InBhc3N3b3JkIiwidXNlcm5hbWUiOiJqb3NoQGNvZGVybHkuY29tIiwidXNlcl9pZCI6MSwiZXhwIjo3MjAwfQ.QVDyAznECIWL6DjDs9iPezvMmoPuzDqAl4bQ6CY-fCQ', + user_id: 1 }; }); @@ -75,7 +65,7 @@ test('Successful signup', (assert) => { }); }); -test('Failed signup due to invalid data stays on same page', (assert) => { +test('Failed signup due to invalid data stays on same page', function(assert) { assert.expect(1); signupPage.visit(); diff --git a/tests/acceptance/slugged-route-test.js b/tests/acceptance/slugged-route-test.js index e625d9ea9..5aedc55dd 100644 --- a/tests/acceptance/slugged-route-test.js +++ b/tests/acceptance/slugged-route-test.js @@ -1,22 +1,12 @@ -import Ember from "ember"; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import createOrganizationWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-organization-with-slugged-route'; import createUserWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-user-with-slugged-route'; import sluggedRoutePage from '../pages/slugged-route'; -let application; +moduleForAcceptance('Acceptance | Slugged Route'); -module('Acceptance: Slugged Route', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); - -test("It renders user details when the sluggedRoute model is a user", function(assert) { +test('It renders user details when the sluggedRoute model is a user', function(assert) { assert.expect(1); let user = createUserWithSluggedRoute(); @@ -28,7 +18,7 @@ test("It renders user details when the sluggedRoute model is a user", function(a }); }); -test("It renders organization profile when the sluggedRoute model is an organization", function(assert) { +test('It renders organization profile when the sluggedRoute model is an organization', function(assert) { assert.expect(1); let organization = createOrganizationWithSluggedRoute(); @@ -40,14 +30,14 @@ test("It renders organization profile when the sluggedRoute model is an organiza }); }); -test("It renders a 404 error when no slugged route exists", function(assert) { +test('It renders a 404 error when no slugged route exists', function(assert) { assert.expect(5); server.get('/no_slug', { errors: [{ - id: "RECORD_NOT_FOUND", - title: "Record not found", + id: 'RECORD_NOT_FOUND', + title: 'Record not found', detail: "Couldn't find SluggedRoute", status: 404 }] diff --git a/tests/acceptance/task-comments-test.js b/tests/acceptance/task-comments-test.js index 7328baa8a..a0b1734da 100644 --- a/tests/acceptance/task-comments-test.js +++ b/tests/acceptance/task-comments-test.js @@ -1,28 +1,18 @@ -import Ember from "ember"; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import { authenticateSession } from 'code-corps-ember/tests/helpers/ember-simple-auth'; import createProjectWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-project-with-slugged-route'; import Mirage from 'ember-cli-mirage'; import taskPage from '../pages/project/tasks/task'; -let application; +moduleForAcceptance('Acceptance | Task Comments'); -module('Acceptance: Task Comments', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); - -test('Task comments are displayed correctly', (assert) => { +test('Task comments are displayed correctly', function(assert) { assert.expect(1); let project = createProjectWithSluggedRoute(); - let organization = project.organization; + let { organization } = project; - let task = project.createTask({ title: "Test title", body: "Test body", taskType: "issue", number: 1 }); + let task = project.createTask({ title: 'Test title', body: 'Test body', taskType: 'issue', number: 1 }); server.createList('comment', 4, { taskId: task.id }); @@ -37,15 +27,15 @@ test('Task comments are displayed correctly', (assert) => { }); }); -test('A comment can be added to a task', (assert) => { +test('A comment can be added to a task', function(assert) { assert.expect(6); let project = createProjectWithSluggedRoute(); - let organization = project.organization; - let task = project.createTask({ title: "Test title", body: "Test body", taskType: "issue", number: 1 }); + let { organization } = project; + let task = project.createTask({ title: 'Test title', body: 'Test body', taskType: 'issue', number: 1 }); let user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); taskPage.visit({ organization: organization.slug, @@ -62,7 +52,7 @@ test('A comment can be added to a task', (assert) => { andThen(() => { assert.equal(server.schema.comments.all().models.length, 1, 'A new comment was created'); assert.equal(taskPage.comments().count, 1, 'The comment is being rendered'); - let comment = server.schema.comments.all().models[0]; + let [comment] = server.schema.comments.all().models; assert.equal(comment.markdown, 'Test markdown', 'New comment has the correct markdown'); assert.equal(comment.taskId, task.id, 'Correct task was assigned'); @@ -70,14 +60,14 @@ test('A comment can be added to a task', (assert) => { }); }); -test('Comment preview works during creation', (assert) => { +test('Comment preview works during creation', function(assert) { assert.expect(2); let user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); let project = createProjectWithSluggedRoute(); - let organization = project.organization; + let { organization } = project; let task = server.schema.tasks.create({ projectId: project.id, number: 1 }); @@ -101,11 +91,11 @@ test('Comment preview works during creation', (assert) => { }); // NOTE: Commented out due to comment user mentions being disabled until reimplemented in phoenix -/*test('Comment user mentions are being rendered during creation', (assert) => { +/* test('Comment user mentions are being rendered during creation', function(assert) { assert.expect(2); let user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); let project = createProjectWithSluggedRoute(); let organization = project.organization; @@ -138,14 +128,14 @@ test('Comment preview works during creation', (assert) => { }); });*/ -test('When comment creation fails due to validation, validation errors are displayed', (assert) => { +test('When comment creation fails due to validation, validation errors are displayed', function(assert) { let project = createProjectWithSluggedRoute(); - let organization = project.organization; + let { organization } = project; - let task = project.createTask({ title: "Test title", body: "Test body", taskType: "issue", number: 1 }); + let task = project.createTask({ title: 'Test title', body: 'Test body', taskType: 'issue', number: 1 }); let user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); taskPage.visit({ organization: organization.slug, @@ -163,17 +153,17 @@ test('When comment creation fails due to validation, validation errors are displ errors: [ { id: "VALIDATION_ERROR", - source: { pointer:"data/attributes/markdown" }, - detail:"is invalid", + source: { pointer: "data/attributes/markdown" }, + detail: "is invalid", status: 422 }, { - id:"VALIDATION_ERROR", - source: { pointer:"data/attributes/markdown" }, + id: "VALIDATION_ERROR", + source: { pointer: "data/attributes/markdown" }, detail: "can't be blank", status: 422 } - ]}); + ] }); }); @@ -185,14 +175,14 @@ test('When comment creation fails due to validation, validation errors are displ }); }); -test('When comment creation fails due to non-validation issues, the error is displayed', (assert) => { +test('When comment creation fails due to non-validation issues, the error is displayed', function(assert) { let project = createProjectWithSluggedRoute(); - let organization = project.organization; + let { organization } = project; - let task = project.createTask({ title: "Test title", body: "Test body", taskType: "issue", number: 1 }); + let task = project.createTask({ title: 'Test title', body: 'Test body', taskType: 'issue', number: 1 }); let user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); taskPage.visit({ organization: organization.slug, @@ -211,7 +201,7 @@ test('When comment creation fails due to non-validation issues, the error is dis { id: "UNKNOWN ERROR", title: "An unknown error", - detail:"Something happened", + detail: "Something happened", status: 400 } ] @@ -226,14 +216,14 @@ test('When comment creation fails due to non-validation issues, the error is dis }); }); -test('A comment can only be edited by the author', (assert) => { +test('A comment can only be edited by the author', function(assert) { assert.expect(2); let user = server.create('user'); let project = createProjectWithSluggedRoute(); - let organization = project.organization; + let { organization } = project; - let task = project.createTask({ title: "Test title", body: "Test body", taskType: "issue", number: 1 }); + let task = project.createTask({ title: 'Test title', body: 'Test body', taskType: 'issue', number: 1 }); server.createList('comment', 1, { task, user }); @@ -245,7 +235,7 @@ test('A comment can only be edited by the author', (assert) => { andThen(() => { assert.notOk(taskPage.commentItem.editLink.isVisible, 'Edit link is not rendered when logged out'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); taskPage.visit({ organization: organization.slug, project: project.slug, @@ -258,16 +248,16 @@ test('A comment can only be edited by the author', (assert) => { }); }); -test('Comment editing with preview works', (assert) => { +test('Comment editing with preview works', function(assert) { assert.expect(4); let user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); let project = createProjectWithSluggedRoute(); - let organization = project.organization; + let { organization } = project; - let task = project.createTask({ title: "Test title", body: "Test body", taskType: "issue", number: 1 }); + let task = project.createTask({ title: 'Test title', body: 'Test body', taskType: 'issue', number: 1 }); server.createList('comment', 1, { task, user }); @@ -302,11 +292,11 @@ test('Comment editing with preview works', (assert) => { }); // NOTE: Commented out due to comment user mentions being disabled until reimplemented in phoenix -/*test('Comment user mentions are being rendered during editing', (assert) => { +/* test('Comment user mentions are being rendered during editing', function(assert) { assert.expect(2); let user = server.create('user'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); let project = createProjectWithSluggedRoute(); let organization = project.organization; diff --git a/tests/acceptance/task-creation-test.js b/tests/acceptance/task-creation-test.js index bd0508f2f..d80850c2e 100644 --- a/tests/acceptance/task-creation-test.js +++ b/tests/acceptance/task-creation-test.js @@ -1,6 +1,5 @@ -import Ember from "ember"; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import { authenticateSession } from 'code-corps-ember/tests/helpers/ember-simple-auth'; import createProjectWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-project-with-slugged-route'; import Mirage from 'ember-cli-mirage'; @@ -8,22 +7,13 @@ import loginPage from '../pages/login'; import projectTasksIndexPage from '../pages/project/tasks/index'; import projectTasksNewPage from '../pages/project/tasks/new'; -let application; +moduleForAcceptance('Acceptance | Task Creation'); -module('Acceptance: Task Creation', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); - -test('Creating a task requires logging in', (assert) => { +test('Creating a task requires logging in', function(assert) { assert.expect(2); let project = createProjectWithSluggedRoute(); - let organization = project.organization; + let { organization } = project; projectTasksIndexPage.visit({ organization: organization.slug, project: project.slug }); @@ -43,13 +33,13 @@ test('Creating a task requires logging in', (assert) => { }); }); -test('A task can be successfully created', (assert) => { +test('A task can be successfully created', function(assert) { assert.expect(9); let user = server.schema.users.create({ username: 'test_user' }); let project = createProjectWithSluggedRoute(); - let organization = project.organization; - authenticateSession(application, { user_id: user.id }); + let { organization } = project; + authenticateSession(this.application, { user_id: user.id }); projectTasksIndexPage.visit({ organization: organization.slug, project: project.slug }); andThen(() => { @@ -65,7 +55,7 @@ test('A task can be successfully created', (assert) => { andThen(() => { assert.equal(server.schema.tasks.all().models.length, 1, 'A task has been created'); - let task = server.schema.tasks.all().models[0]; + let [task] = server.schema.tasks.all().models; assert.equal(task.title, 'A task title'); assert.equal(task.markdown, 'A task body'); @@ -80,13 +70,13 @@ test('A task can be successfully created', (assert) => { // TODO: Make sure we got redirected to the task route and task is properly rendered }); -test('Task preview works during creation', (assert) => { +test('Task preview works during creation', function(assert) { assert.expect(1); let user = server.schema.users.create({ username: 'test_user' }); let project = createProjectWithSluggedRoute(); - let organization = project.organization; - authenticateSession(application, { user_id: user.id }); + let { organization } = project; + authenticateSession(this.application, { user_id: user.id }); projectTasksNewPage.visit({ organization: organization.slug, project: project.slug }); @@ -101,7 +91,7 @@ test('Task preview works during creation', (assert) => { }); // NOTE: Commented out due to comment user mentions being disabled until reimplemented in phoenix -/*test('Task preview during creation renders user mentions', (assert) => { +/* test('Task preview during creation renders user mentions', function(assert) { assert.expect(1); let project = createProjectWithSluggedRoute(); @@ -122,13 +112,13 @@ test('Task preview works during creation', (assert) => { }); });*/ -test('When task creation succeeeds, the user is redirected to the task page for the new task', (assert) => { +test('When task creation succeeeds, the user is redirected to the task page for the new task', function(assert) { assert.expect(2); let user = server.schema.users.create({ username: 'test_user' }); let project = createProjectWithSluggedRoute(); - let organization = project.organization; - authenticateSession(application, { user_id: user.id }); + let { organization } = project; + authenticateSession(this.application, { user_id: user.id }); projectTasksIndexPage.visit({ organization: organization.slug, project: project.slug }); @@ -144,12 +134,12 @@ test('When task creation succeeeds, the user is redirected to the task page for }); }); -test('When task creation fails due to validation, validation errors are displayed', (assert) => { +test('When task creation fails due to validation, validation errors are displayed', function(assert) { assert.expect(1); let user = server.schema.users.create({ username: 'test_user' }); let project = createProjectWithSluggedRoute(); - let organization = project.organization; - authenticateSession(application, { user_id: user.id }); + let { organization } = project; + authenticateSession(this.application, { user_id: user.id }); projectTasksIndexPage.visit({ organization: organization.slug, project: project.slug }); @@ -164,28 +154,28 @@ test('When task creation fails due to validation, validation errors are displaye { id: "VALIDATION_ERROR", source: { pointer: "data/attributes/title" }, - detail:"is invalid", + detail: "is invalid", status: 422 }, { - id:"VALIDATION_ERROR", + id: "VALIDATION_ERROR", source: { pointer: "data/attributes/markdown" }, detail: "can't be blank", status: 422 }, { - id: "VALIDATION_ERROR", - source: { pointer: "data/attributes/task-type" }, - detail: "is invalid", + id: 'VALIDATION_ERROR', + source: { pointer: 'data/attributes/task-type' }, + detail: 'is invalid', status: 422 }, { - id: "VALIDATION_ERROR", - source: { pointer: "data/attributes/task-type" }, - detail: "can only be one of the specified values", + id: 'VALIDATION_ERROR', + source: { pointer: 'data/attributes/task-type' }, + detail: 'can only be one of the specified values', status: 422 } - ]}); + ] }); }); projectTasksNewPage.clickSubmit(); }); @@ -193,14 +183,14 @@ test('When task creation fails due to validation, validation errors are displaye andThen(() => assert.equal(projectTasksNewPage.errors().count, 4)); }); -test('When task creation fails due to non-validation issues, the error is displayed', (assert) => { +test('When task creation fails due to non-validation issues, the error is displayed', function(assert) { assert.expect(2); let user = server.schema.users.create({ username: 'test_user' }); let project = createProjectWithSluggedRoute(); - let organization = project.organization; - authenticateSession(application, { user_id: user.id }); + let { organization } = project; + authenticateSession(this.application, { user_id: user.id }); projectTasksIndexPage.visit({ organization: organization.slug, project: project.slug }); @@ -217,7 +207,7 @@ test('When task creation fails due to non-validation issues, the error is displa { id: "UNKNOWN ERROR", title: "An unknown error", - detail:"Something happened", + detail: "Something happened", status: 400 } ] diff --git a/tests/acceptance/task-editing-test.js b/tests/acceptance/task-editing-test.js index 130271f3b..f74b66370 100644 --- a/tests/acceptance/task-editing-test.js +++ b/tests/acceptance/task-editing-test.js @@ -1,29 +1,19 @@ -import Ember from "ember"; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; +import { test } from 'qunit'; +import moduleForAcceptance from 'code-corps-ember/tests/helpers/module-for-acceptance'; import { authenticateSession } from 'code-corps-ember/tests/helpers/ember-simple-auth'; import createOrganizationWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-organization-with-slugged-route'; import createProjectWithSluggedRoute from 'code-corps-ember/tests/helpers/mirage/create-project-with-slugged-route'; import taskPage from '../pages/project/tasks/task'; -let application; +moduleForAcceptance('Acceptance | Task Editing'); -module('Acceptance: Task Editing', { - beforeEach: function() { - application = startApp(); - }, - afterEach: function() { - Ember.run(application, 'destroy'); - } -}); - -test('Task editing requires logging in', (assert) => { +test('Task editing requires logging in', function(assert) { assert.expect(4); let project = createProjectWithSluggedRoute(); - let organization = project.organization; + let { organization } = project; let user = server.schema.users.create({ username: 'test_user' }); - let task = project.createTask({ title: "Test title", body: "Test body", taskType: "issue", number: 1 }); + let task = project.createTask({ title: 'Test title', body: 'Test body', taskType: 'issue', number: 1 }); task.user = user; task.save(); @@ -37,7 +27,7 @@ test('Task editing requires logging in', (assert) => { assert.notOk(taskPage.taskBody.editButton.isVisible, 'Body edit button is not rendered'); assert.notOk(taskPage.taskTitle.editButton.isVisible, 'Title edit button is not rendered'); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); taskPage.visit({ organization: organization.slug, project: project.slug, @@ -51,15 +41,15 @@ test('Task editing requires logging in', (assert) => { }); }); -test('A task body can be edited on its own', (assert) => { +test('A task body can be edited on its own', function(assert) { assert.expect(3); let user = server.schema.users.create({ username: 'test_user' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); let project = createProjectWithSluggedRoute(); - let organization = project.organization; - let task = project.createTask({ title: "Test title", body: "Test body", taskType: "issue", number: 1 }); + let { organization } = project; + let task = project.createTask({ title: 'Test title', body: 'Test body', taskType: 'issue', number: 1 }); task.user = user; task.save(); @@ -89,15 +79,15 @@ test('A task body can be edited on its own', (assert) => { }); }); -test('A task title can be edited on its own', (assert) => { +test('A task title can be edited on its own', function(assert) { assert.expect(4); let user = server.schema.users.create({ username: 'test_user' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); let project = createProjectWithSluggedRoute(); - let organization = project.organization; - let task = project.createTask({ title: "Test title", body: "Test body", taskType: "issue", number: 1 }); + let { organization } = project; + let task = project.createTask({ title: 'Test title', body: 'Test body', taskType: 'issue', number: 1 }); task.user = user; task.save(); @@ -126,7 +116,7 @@ test('A task title can be edited on its own', (assert) => { // NOTE: Commented out due to comment user mentions being disabled until reimplemented in phoenix /* -test('Mentions are rendered during editing in preview mode', (assert) => { +test('Mentions are rendered during editing in preview mode', function(assert) { assert.expect(1); let project = createProjectWithSluggedRoute(); @@ -167,11 +157,11 @@ test('Mentions are rendered during editing in preview mode', (assert) => { }); */ -test('A task can be opened or closed by the author', (assert) => { +test('A task can be opened or closed by the author', function(assert) { assert.expect(2); let user = server.schema.users.create({ username: 'test_user' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); let organization = createOrganizationWithSluggedRoute(); let project = server.create('project', { organization }); @@ -206,11 +196,11 @@ test('A task can be opened or closed by the author', (assert) => { }); }); -test('A task can be opened or closed by the organization admin', (assert) => { +test('A task can be opened or closed by the organization admin', function(assert) { assert.expect(2); let user = server.schema.users.create({ username: 'test_user' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); let organization = createOrganizationWithSluggedRoute(); let project = server.create('project', { organization }); @@ -222,7 +212,7 @@ test('A task can be opened or closed by the organization admin', (assert) => { project }); - server.schema.create('organization-membership', { organization, member: user, role: 'admin' }); + server.schema.create('organization-membership', { organization, member: user, role: 'admin' }); taskPage.visit({ organization: organization.slug, @@ -246,11 +236,11 @@ test('A task can be opened or closed by the organization admin', (assert) => { }); }); -test('A task cannot be opened or closed by someone else', (assert) => { +test('A task cannot be opened or closed by someone else', function(assert) { assert.expect(1); let user = server.schema.users.create({ username: 'test_user' }); - authenticateSession(application, { user_id: user.id }); + authenticateSession(this.application, { user_id: user.id }); let organization = createOrganizationWithSluggedRoute(); let project = server.create('project', { organization }); diff --git a/tests/helpers/destroy-app.js b/tests/helpers/destroy-app.js index 3a0114aae..21dfbf646 100644 --- a/tests/helpers/destroy-app.js +++ b/tests/helpers/destroy-app.js @@ -1,6 +1,8 @@ import Ember from 'ember'; +const { run } = Ember; + export default function destroyApp(application) { - Ember.run(application, 'destroy'); + run(application, 'destroy'); server.shutdown(); } diff --git a/tests/helpers/fill-in-file-input.js b/tests/helpers/fill-in-file-input.js index d86387c46..70b3fc736 100644 --- a/tests/helpers/fill-in-file-input.js +++ b/tests/helpers/fill-in-file-input.js @@ -12,14 +12,14 @@ export default function fillInFileInput(selector, file) { let event = jQuery.Event('change', { target: { files: [{ - name: name, type: type + name, type }] } }); // Stub readAsDataURL function let stub = sinon.stub(FileReader.prototype, 'readAsDataURL', function() { - this.onload({ target: { result: content }}); + this.onload({ target: { result: content } }); }); // Trigger event diff --git a/tests/helpers/has-attributes.js b/tests/helpers/has-attributes.js index 302104306..6655c2343 100644 --- a/tests/helpers/has-attributes.js +++ b/tests/helpers/has-attributes.js @@ -1,10 +1,11 @@ import QUnit from 'qunit'; /* This assertion will compare 2 arrays of attributes. - It first sorts both arrays and then compares each element. + It first convert the attributes Map to an Array, + then sorts both arrays and then compares each element. @method hasAttributes - @param {Array} actualAttributes + @param {Map} actualAttributes @param {Array} expectedAttributes */ function compareArrays(actualAttributes, expectedAttributes) { @@ -18,6 +19,11 @@ function compareArrays(actualAttributes, expectedAttributes) { QUnit.assert.hasAttributes = function(actualAttributes, expectedAttributes) { this.expect(2); - this.ok(actualAttributes.length === expectedAttributes.length, `should have ${expectedAttributes.length} attributes`); - this.ok(compareArrays(actualAttributes, expectedAttributes), 'should have the expected attributes'); + let actualAttributesArray = []; + actualAttributes.forEach(function(meta, name) { + actualAttributesArray.push(name); + }); + + this.ok(actualAttributesArray.length === expectedAttributes.length, `should have ${expectedAttributes.length} attributes`); + this.ok(compareArrays(actualAttributesArray, expectedAttributes), 'should have the expected attributes'); }; diff --git a/tests/helpers/mock-routing.js b/tests/helpers/mock-routing.js index ccf051dc4..d4b447828 100644 --- a/tests/helpers/mock-routing.js +++ b/tests/helpers/mock-routing.js @@ -1,10 +1,20 @@ import Ember from 'ember'; +const { Object } = Ember; + export default function mockRouting({ container }) { - container.registry.register('service:-routing', Ember.Object.extend({ - availableRoutes: function() { return ['index']; }, - hasRoute: function(name) { return name === 'index'; }, - isActiveForRoute: function() { return true; }, - generateURL: function(route) { return "/" + route; } + container.registry.register('service:-routing', Object.extend({ + availableRoutes() { + return ['index']; + }, + hasRoute(name) { + return name === 'index'; + }, + isActiveForRoute() { + return true; + }, + generateURL(route) { + return `/${route}`; + } })); } diff --git a/tests/helpers/relationship.js b/tests/helpers/relationship.js index 133bf7eff..4d601ed19 100644 --- a/tests/helpers/relationship.js +++ b/tests/helpers/relationship.js @@ -1,25 +1,27 @@ import { test } from 'ember-qunit'; import Ember from 'ember'; +const { get } = Ember; + // source: https://gist.github.com/he9qi/b6354a81a0672dc63294 export function testForHasMany(name, many) { - test('should have many ' + many, function(assert) { + test(`should have many ${many}`, function(assert) { assert.expect(2); - const Model = this.store().modelFor(name); - const relationship = Ember.get(Model, 'relationshipsByName').get(many); + let Model = this.store().modelFor(name); + let relationship = get(Model, 'relationshipsByName').get(many); - assert.equal(relationship.key, many, 'has relationship with ' + many); + assert.equal(relationship.key, many, `has relationship with ${many}`); assert.equal(relationship.kind, 'hasMany', 'kind of relationship is hasMany'); }); } export function testForBelongsTo(name, belongsTo) { - test('should belong to ' + belongsTo, function(assert) { + test(`should belong to ${belongsTo}`, function(assert) { assert.expect(2); - const Model = this.store().modelFor(name); - const relationship = Ember.get(Model, 'relationshipsByName').get(belongsTo); + let Model = this.store().modelFor(name); + let relationship = get(Model, 'relationshipsByName').get(belongsTo); - assert.equal(relationship.key, belongsTo, 'has relationship with ' + belongsTo); + assert.equal(relationship.key, belongsTo, `has relationship with ${belongsTo}`); assert.equal(relationship.kind, 'belongsTo', 'kind of relationship is belongsTo'); }); } diff --git a/tests/helpers/remove-double-quotes.js b/tests/helpers/remove-double-quotes.js index cbd6279fd..47e70705c 100644 --- a/tests/helpers/remove-double-quotes.js +++ b/tests/helpers/remove-double-quotes.js @@ -1,3 +1,3 @@ export default function removeDoubleQuotes(string) { - return string.replace(/"/g, ""); + return string.replace(/"/g, ''); } diff --git a/tests/helpers/start-app.js b/tests/helpers/start-app.js index e098f1d5b..2fafac447 100644 --- a/tests/helpers/start-app.js +++ b/tests/helpers/start-app.js @@ -2,13 +2,18 @@ import Ember from 'ember'; import Application from '../../app'; import config from '../../config/environment'; +const { + merge, + run +} = Ember; + export default function startApp(attrs) { let application; - let attributes = Ember.merge({}, config.APP); - attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; + let attributes = merge({}, config.APP); + attributes = merge(attributes, attrs); // use defaults, but you can override; - Ember.run(() => { + run(() => { application = Application.create(attributes); application.setupForTesting(); application.injectTestHelpers(); diff --git a/tests/helpers/stub-service.js b/tests/helpers/stub-service.js new file mode 100644 index 000000000..997fec733 --- /dev/null +++ b/tests/helpers/stub-service.js @@ -0,0 +1,23 @@ +import Ember from 'ember'; + +const { + Logger: { error }, + Service, + typeOf +} = Ember; + +let stubService = (scope, name, hash = {}) => { + if (typeOf(name) !== 'string') { + error('The name of the service must be a string'); + } + + if (typeOf(scope) !== 'object') { + error('You must pass the test object to the stubService helper'); + } + + let stubbedService = Service.extend(hash); + scope.register(`service:${name}`, stubbedService); + scope.inject.service(name, { as: name }); +}; + +export default stubService; diff --git a/tests/integration/components/categories-list-test.js b/tests/integration/components/categories-list-test.js index cdb8df4d5..74c100ae0 100644 --- a/tests/integration/components/categories-list-test.js +++ b/tests/integration/components/categories-list-test.js @@ -1,6 +1,9 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +const { K } = Ember; moduleForComponent('categories-list', 'Integration | Component | categories list', { integration: true @@ -9,10 +12,7 @@ moduleForComponent('categories-list', 'Integration | Component | categories list test('it renders the categories and sorts them by name', function(assert) { assert.expect(5); - let mockUserCategoriesService = Ember.Service.extend({ - findUserCategory: Ember.K, - }); - this.register('service:user-categories', mockUserCategoriesService); + stubService(this, 'user-categories', { findUserCategory: K }); let categories = [ { @@ -26,7 +26,7 @@ test('it renders the categories and sorts them by name', function(assert) { { id: 3, name: 'Alphabets' - }, + } ]; this.set('categories', categories); diff --git a/tests/integration/components/category-item-test.js b/tests/integration/components/category-item-test.js index 2ff996bd0..7b7c9f4ed 100644 --- a/tests/integration/components/category-item-test.js +++ b/tests/integration/components/category-item-test.js @@ -2,8 +2,14 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; import wait from 'ember-test-helpers/wait'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; -const { getOwner } = Ember; +const { + getOwner, + Object, + run, + RSVP +} = Ember; moduleForComponent('category-item', 'Integration | Component | category item', { integration: true, @@ -14,15 +20,15 @@ moduleForComponent('category-item', 'Integration | Component | category item', { let defaultCategoryId = 2; -let mockUserCategoriesService = Ember.Service.extend({ +let mockUserCategoriesService = { findUserCategory(category) { if (category.id === mockUserCategory.get('categoryId')) { return mockUserCategory; } }, addCategory(category) { - return new Ember.RSVP.Promise((fulfill) => { - Ember.run.next(() => { + return new RSVP.Promise((fulfill) => { + run.next(() => { mockUserCategory.set('categoryId', category.get('id')); getOwner(this).lookup('service:user-categories').set('userCategories', [mockUserCategory]); fulfill(); @@ -30,55 +36,55 @@ let mockUserCategoriesService = Ember.Service.extend({ }); }, removeCategory() { - return new Ember.RSVP.Promise((fulfill, reject) => { - Ember.run.next(() => { + return new RSVP.Promise((fulfill, reject) => { + run.next(() => { mockUserCategory.set('categoryId', null); getOwner(this).lookup('service:user-categories').set('userCategories', []); reject(); }); }); - }, -}); + } +}; -let mockUserCategoriesServiceForErrors = Ember.Service.extend({ +let mockUserCategoriesServiceForErrors = { findUserCategory(category) { if (category.id === mockUserCategory.get('categoryId')) { return mockUserCategory; } }, addCategory() { - return Ember.RSVP.reject(); + return RSVP.reject(); }, removeCategory() { - return Ember.RSVP.reject(); - }, -}); + return RSVP.reject(); + } +}; -let mockUserCategory = Ember.Object.create({ +let mockUserCategory = Object.create({ id: 1, categoryId: defaultCategoryId, - userId: 1, + userId: 1 }); -let unselectedCategory = Ember.Object.create({ +let unselectedCategory = Object.create({ id: 1, name: 'Technology', slug: 'technology', - description: 'You want to help technology.', + description: 'You want to help technology.' }); -let selectedCategory = Ember.Object.create({ +let selectedCategory = Object.create({ id: 2, name: 'Society', slug: 'society', - description: 'You want to help society.', + description: 'You want to help society.' }); test('it works for selecting unselected categories', function(assert) { let done = assert.async(); assert.expect(6); - this.register('service:user-categories', mockUserCategoriesService); + stubService(this, 'user-categories', mockUserCategoriesService); this.set('category', unselectedCategory); this.render(hbs`{{category-item category=category}}`); @@ -100,7 +106,7 @@ test('it works for removing selected categories', function(assert) { let done = assert.async(); assert.expect(4); - this.register('service:user-categories', mockUserCategoriesService); + stubService(this, 'user-categories', mockUserCategoriesService); this.set('category', selectedCategory); this.render(hbs`{{category-item category=category}}`); @@ -120,10 +126,10 @@ test('it creates a flash message on an error when adding', function(assert) { let done = assert.async(); assert.expect(7); - this.register('service:user-categories', mockUserCategoriesServiceForErrors); + stubService(this, 'user-categories', mockUserCategoriesServiceForErrors); this.set('category', unselectedCategory); - let mockFlashMessages = Ember.Service.extend({ + stubService(this, 'flash-messages', { clearMessages() { assert.ok(true); }, @@ -135,7 +141,6 @@ test('it creates a flash message on an error when adding', function(assert) { assert.equal(object.timeout, 5000); } }); - this.register('service:flash-messages', mockFlashMessages); this.render(hbs`{{category-item category=category}}`); @@ -150,10 +155,10 @@ test('it creates a flash message on an error when removing', function(assert) { let done = assert.async(); assert.expect(7); - this.register('service:user-categories', mockUserCategoriesServiceForErrors); + stubService(this, 'user-categories', mockUserCategoriesServiceForErrors); this.set('category', selectedCategory); - let mockFlashMessages = Ember.Service.extend({ + stubService(this, 'flash-messages', { clearMessages() { assert.ok(true); }, @@ -165,7 +170,6 @@ test('it creates a flash message on an error when removing', function(assert) { assert.equal(object.timeout, 5000); } }); - this.register('service:flash-messages', mockFlashMessages); this.render(hbs`{{category-item category=category}}`); @@ -180,7 +184,7 @@ test('it sets and unsets loading state when adding', function(assert) { let done = assert.async(); assert.expect(3); - this.register('service:user-categories', mockUserCategoriesService); + stubService(this, 'user-categories', mockUserCategoriesService); this.set('category', unselectedCategory); this.render(hbs`{{category-item category=category}}`); @@ -197,7 +201,7 @@ test('it sets and unsets loading state when adding', function(assert) { test('it sets and unsets loading state when removing', function(assert) { let done = assert.async(); - this.register('service:user-categories', mockUserCategoriesService); + stubService(this, 'user-categories', mockUserCategoriesService); assert.expect(3); this.set('category', selectedCategory); diff --git a/tests/integration/components/code-theme-selector-test.js b/tests/integration/components/code-theme-selector-test.js index 4ec668c15..2fa108548 100644 --- a/tests/integration/components/code-theme-selector-test.js +++ b/tests/integration/components/code-theme-selector-test.js @@ -1,6 +1,6 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; -import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; moduleForComponent('code-theme-selector', 'Integration | Component | code theme selector', { integration: true @@ -9,12 +9,11 @@ moduleForComponent('code-theme-selector', 'Integration | Component | code theme test('it toggles code theme service when clicked', function(assert) { assert.expect(1); - const codeThemeServiceStub = Ember.Service.extend({ + stubService(this, 'code-theme', { toggle() { assert.ok(true, 'Code theme service was called'); } }); - this.register('service:code-theme', codeThemeServiceStub); this.render(hbs`{{code-theme-selector}}`); this.$('.code-theme-selector').click(); @@ -23,10 +22,9 @@ test('it toggles code theme service when clicked', function(assert) { test('it has the class name from the service', function(assert) { assert.expect(1); - const codeThemeServiceStub = Ember.Service.extend({ + stubService(this, 'code-theme', { className: 'light' }); - this.register('service:code-theme', codeThemeServiceStub); this.render(hbs`{{code-theme-selector}}`); assert.ok(this.$('.code-theme-selector').hasClass('light')); diff --git a/tests/integration/components/comment-item-test.js b/tests/integration/components/comment-item-test.js index 59dc8302c..ecb415de9 100644 --- a/tests/integration/components/comment-item-test.js +++ b/tests/integration/components/comment-item-test.js @@ -1,55 +1,62 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; - -let mockMentionFetcher = Ember.Service.extend({ - fetchBodyWithMentions: Ember.RSVP.resolve, - prefetchBodyWithMentions: Ember.K -}); - -let mockStore = Ember.Service.extend({ - query () { - return Ember.RSVP.resolve([]); +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +const { + K, + Object, + RSVP +} = Ember; + +let mockMentionFetcher = { + fetchBodyWithMentions: RSVP.resolve, + prefetchBodyWithMentions: K +}; + +let mockStore = { + query() { + return RSVP.resolve([]); } -}); +}; -let mockCurrentUser = Ember.Service.extend({ +let mockCurrentUser = { user: { id: 1 } -}); +}; -let mockComment = Ember.Object.create({ +let mockComment = Object.create({ body: 'A body', user: { id: 1 }, save() { - return Ember.RSVP.resolve(); + return RSVP.resolve(); } }); -// let mockCommentWithMentions = Ember.Object.create({ +// let mockCommentWithMentions = Object.create({ // body: '

    Mentioning @user1 and @user2

    ', // user: { id: 1 }, // save() { -// return Ember.RSVP.resolve(); +// return RSVP.resolve(); // }, // commentUserMentions: [ -// Ember.Object.create({ indices: [14, 19], username: 'user1', user: { id: 1 } }), -// Ember.Object.create({ indices: [25, 30], username: 'user2', user: { id: 2 } }) +// Object.create({ indices: [14, 19], username: 'user1', user: { id: 1 } }), +// Object.create({ indices: [25, 30], username: 'user2', user: { id: 2 } }) // ] // }); moduleForComponent('comment-item', 'Integration | Component | comment item', { integration: true, beforeEach() { - this.register('service:store', mockStore); + stubService(this, 'store', mockStore); } }); test('it renders', function(assert) { assert.expect(1); - this.register('service:mention-fetcher', mockMentionFetcher); + stubService(this, 'mention-fetcher', mockMentionFetcher); this.set('comment', mockComment); this.render(hbs`{{comment-item comment=comment}}`); @@ -61,7 +68,7 @@ test('it renders all required comment elements properly', function(assert) { assert.expect(4); let user = { id: 1, username: 'tester' }; - let comment = Ember.Object.create({ id: 1, body: 'A comment', user, containsCode: true }); + let comment = Object.create({ id: 1, body: 'A comment', user, containsCode: true }); this.set('comment', comment); this.render(hbs`{{comment-item comment=comment}}`); @@ -75,8 +82,8 @@ test('it renders all required comment elements properly', function(assert) { test('it switches between editing and viewing mode', function(assert) { assert.expect(3); - this.register('service:mention-fetcher', mockMentionFetcher); - this.register('service:current-user', mockCurrentUser); + stubService(this, 'mention-fetcher', mockMentionFetcher); + stubService(this, 'current-user', mockCurrentUser); this.set('comment', mockComment); this.render(hbs`{{comment-item comment=comment}}`); @@ -94,11 +101,8 @@ test('it switches between editing and viewing mode', function(assert) { /* test('mentions are rendered on comment body in read-only mode', function(assert) { assert.expect(1); - this.set('comment', mockCommentWithMentions); - let expectedOutput = '

    Mentioning @user1 and @user2

    '; - this.render(hbs`{{comment-item comment=comment}}`); assert.equal(this.$('.comment-item .comment-body').html(), expectedOutput, 'Mentions are rendered'); }); diff --git a/tests/integration/components/create-comment-form-test.js b/tests/integration/components/create-comment-form-test.js index 4c8ecf516..344712b72 100644 --- a/tests/integration/components/create-comment-form-test.js +++ b/tests/integration/components/create-comment-form-test.js @@ -2,12 +2,16 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; import mockRouting from '../../helpers/mock-routing'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; -let mockSession = Ember.Service.extend({ - isAuthenticated: true -}); +const { + $, + Object +} = Ember; + +let mockSession = { isAuthenticated: true }; -let pressCtrlEnter = Ember.$.Event('keydown', { +let pressCtrlEnter = $.Event('keydown', { keyCode: 13, which: 13, ctrlKey: true @@ -30,7 +34,7 @@ test('it renders', function(assert) { test('it yelds to content', function(assert) { assert.expect(1); - this.register('service:session', mockSession); + stubService(this, 'session', mockSession); this.render(hbs`{{#create-comment-form}}Random content{{/create-comment-form}}`); let componentTextContent = this.$('form.create-comment-form').text().trim(); @@ -40,7 +44,7 @@ test('it yelds to content', function(assert) { test('it renders the proper elements', function(assert) { assert.expect(2); - this.register('service:session', mockSession); + stubService(this, 'session', mockSession); this.set('comment', {}); @@ -52,9 +56,9 @@ test('it renders the proper elements', function(assert) { test('it calls action when user clicks submit', function(assert) { assert.expect(1); - this.register('service:session', mockSession); + stubService(this, 'session', mockSession); - this.set('comment', Ember.Object.create({ markdown: 'Test markdown' })); + this.set('comment', Object.create({ markdown: 'Test markdown' })); this.on('saveComment', (comment) => { assert.equal(comment.markdown, 'Test markdown', 'Action was called with proper parameter'); }); @@ -66,9 +70,9 @@ test('it calls action when user clicks submit', function(assert) { test('it calls action when user hits ctrl+enter', function(assert) { assert.expect(1); - this.register('service:session', mockSession); + stubService(this, 'session', mockSession); - this.set('comment', Ember.Object.create({ markdown: 'Test markdown' })); + this.set('comment', Object.create({ markdown: 'Test markdown' })); this.on('saveComment', (comment) => { assert.equal(comment.markdown, 'Test markdown', 'Action was called with proper parameter'); }); diff --git a/tests/integration/components/editor-with-preview-test.js b/tests/integration/components/editor-with-preview-test.js index b8a61ea27..c735a4806 100644 --- a/tests/integration/components/editor-with-preview-test.js +++ b/tests/integration/components/editor-with-preview-test.js @@ -1,36 +1,43 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; -let mockPreview = Ember.Object.create({ +const { + $, + Object, + RSVP +} = Ember; + +let mockPreview = Object.create({ markdown: 'A **body**', body: 'A body', save() { - return Ember.RSVP.resolve(this); + return RSVP.resolve(this); } }); -let mockStore = Ember.Service.extend({ +let mockStore = { createRecord() { return mockPreview; } -}); +}; -let mockMentionFetcher = Ember.Service.extend({ +let mockMentionFetcher = { fetchBodyWithMentions() { - return Ember.RSVP.resolve('Lorem ipsum bla'); + return RSVP.resolve('Lorem ipsum bla'); } -}); +}; moduleForComponent('editor-with-preview', 'Integration | Component | editor with preview', { integration: true, beforeEach() { - this.register('service:store', mockStore); - this.register('service:mention-fetcher', mockMentionFetcher); + stubService(this, 'store', mockStore); + stubService(this, 'mention-fetcher', mockMentionFetcher); } }); -let pressCtrlEnter = Ember.$.Event('keydown', { +let pressCtrlEnter = $.Event('keydown', { keyCode: 13, which: 13, ctrlKey: true @@ -159,7 +166,7 @@ test('it sets the editor min-height to the editor height when previewing and sti this.$('.preview').click(); - let style = "min-height: " + height + ";"; + let style = `min-height: ${height};`; assert.equal(this.$('.editor-with-preview').attr('style'), style); }); @@ -176,22 +183,6 @@ test('it clears the editor style when previewing and done loading', function(ass assert.equal(this.$('.editor-with-preview')[0].hasAttribute('style'), false); }); -// test('it autoresizes to a max height of 350px', function(assert) { -// assert.expect(3); -// -// this.render(hbs`{{editor-with-preview input=input}}`); -// -// assert.equal(this.$('.editor-with-preview textarea').css('height'), '100px'); -// -// var text = ""; -// for(var i = 0; i < 100; i++) { text += "\n"; } -// this.set('input', text); -// assert.equal(this.$('.editor-with-preview textarea').css('height'), '350px'); -// -// this.set('input', ''); -// assert.equal(this.$('.editor-with-preview textarea').css('height'), '100px'); -// }); - test('it sends the modifiedSubmit action with ctrl+enter', function(assert) { assert.expect(2); diff --git a/tests/integration/components/error-formatter-test.js b/tests/integration/components/error-formatter-test.js index 492b509c3..a3f43fb14 100644 --- a/tests/integration/components/error-formatter-test.js +++ b/tests/integration/components/error-formatter-test.js @@ -2,6 +2,8 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +const { Object } = Ember; + moduleForComponent('error-formatter', 'Integration | Component | error formatter', { integration: true }); @@ -13,14 +15,14 @@ test('it renders', function(assert) { assert.equal(this.$('.error-formatter').length, 1, "The component's element renders"); }); -let mockResponseWithMultipleErrors = Ember.Object.create({ +let mockResponseWithMultipleErrors = Object.create({ errors: [ { title: 'First', detail: 'error' }, - { title: 'Second', detail: 'error' }, + { title: 'Second', detail: 'error' } ] }); -test('it displays a message for each error in the response', function (assert) { +test('it displays a message for each error in the response', function(assert) { assert.expect(3); this.set('error', mockResponseWithMultipleErrors); @@ -30,7 +32,7 @@ test('it displays a message for each error in the response', function (assert) { assert.equal(this.$('.error-formatter .error:eq(1)').text().trim(), 'Second: error', 'Second message is rendered'); }); -test('it displays a default message if there are no errors in the response', function (assert) { +test('it displays a default message if there are no errors in the response', function(assert) { assert.expect(2); this.set('error', {}); diff --git a/tests/integration/components/error-wrapper-test.js b/tests/integration/components/error-wrapper-test.js index 0675d87de..0febbc132 100644 --- a/tests/integration/components/error-wrapper-test.js +++ b/tests/integration/components/error-wrapper-test.js @@ -13,14 +13,14 @@ test('it renders', function(assert) { test('it renders all required elements for the 404 case', function(assert) { assert.expect(6); - var model = { + let error = { errors: [{ status: 404 }] }; - this.set('model', model); - this.render(hbs`{{error-wrapper model=model}}`); + this.set('model', error); + this.render(hbs`{{error-wrapper error=model}}`); assert.equal(this.$('.not-found-img').length, 1, 'The 404 image renders'); assert.equal(this.$('h1').text().trim(), '404 Error', 'The title renders'); @@ -33,14 +33,14 @@ test('it renders all required elements for the 404 case', function(assert) { test('it renders all required elements for the general error case', function(assert) { assert.expect(6); - var model = { + let error = { errors: [{ status: 500 }] }; - this.set('model', model); - this.render(hbs`{{error-wrapper model=model}}`); + this.set('model', error); + this.render(hbs`{{error-wrapper error=model}}`); assert.equal(this.$('.server-error-img').length, 1, 'The general error image renders'); assert.equal(this.$('h1').text().trim(), 'Server Error', 'The title renders'); diff --git a/tests/integration/components/flash-messages-test.js b/tests/integration/components/flash-messages-test.js index e5f127741..ed76568bc 100644 --- a/tests/integration/components/flash-messages-test.js +++ b/tests/integration/components/flash-messages-test.js @@ -2,6 +2,11 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +const { + getOwner, + run +} = Ember; + moduleForComponent('flash-messages', 'Integration | Component | flash messages', { integration: true }); @@ -9,13 +14,13 @@ moduleForComponent('flash-messages', 'Integration | Component | flash messages', test('it renders a fixed error message', function(assert) { this.render(hbs`{{flash-messages}}`); - Ember.run(() => { - Ember.getOwner(this).lookup('service:flash-messages').add({ - message: "Error message", + run(() => { + getOwner(this).lookup('service:flash-messages').add({ + message: 'Error message', type: 'danger', fixed: true, sticky: false, - timeout: 5000, + timeout: 5000 }); }); @@ -25,10 +30,10 @@ test('it renders a fixed error message', function(assert) { test('it renders a normal success message', function(assert) { this.render(hbs`{{flash-messages}}`); - Ember.run(() => { - Ember.getOwner(this).lookup('service:flash-messages').add({ - message: "Success message", - type: 'success', + run(() => { + getOwner(this).lookup('service:flash-messages').add({ + message: 'Success message', + type: 'success' }); }); diff --git a/tests/integration/components/image-drop-test.js b/tests/integration/components/image-drop-test.js index 1a0cf6e4e..116d664df 100644 --- a/tests/integration/components/image-drop-test.js +++ b/tests/integration/components/image-drop-test.js @@ -7,8 +7,8 @@ moduleForComponent('image-drop', 'Integration | Component | image drop', { integration: true }); -let originalImageString = "data:image/gif;base64,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"; -let droppedImageString = "data:image/png;base64,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"; +let originalImageString = 'data:image/gif;base64,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'; +let droppedImageString = 'data:image/png;base64,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'; test('it renders default state without a photo', function(assert) { // Set any properties with this.set('myProperty', 'value'); @@ -19,7 +19,7 @@ test('it renders default state without a photo', function(assert) { assert.equal(this.$('.image-drop').hasClass('active'), false); assert.equal(this.$('.image-drop').hasClass('is-dragging'), false); let style = this.$('.image-drop').css('background-image'); - assert.equal(style, "none"); + assert.equal(style, 'none'); }); test('it reacts to dragging on the application', function(assert) { diff --git a/tests/integration/components/member-list-item-test.js b/tests/integration/components/member-list-item-test.js index 241c9e975..56714a853 100644 --- a/tests/integration/components/member-list-item-test.js +++ b/tests/integration/components/member-list-item-test.js @@ -1,6 +1,12 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +const { + Object, + RSVP +} = Ember; let user = { name: 'Josh Smith', @@ -28,19 +34,19 @@ let user = { skill: { title: 'Ruby' } - }, + } ] }; function mockMembership(pending) { - let membership = Ember.Object.create({ + let membership = Object.create({ isPending: pending, destroyRecord() { - return Ember.RSVP.resolve(); + return RSVP.resolve(); }, save() { - return Ember.RSVP.resolve(); - }, + return RSVP.resolve(); + } }); return membership; } @@ -101,18 +107,18 @@ test('it does not render the buttons when not pending', function(assert) { test('it sends the approve action when clicking approve', function(assert) { assert.expect(7); - let membership = Ember.Object.create({ + let membership = Object.create({ isPending: true, save() { assert.ok(true); - return Ember.RSVP.resolve(); - }, + return RSVP.resolve(); + } }); this.set('membership', membership); this.set('user', user); - let mockFlashMessages = Ember.Service.extend({ + stubService(this, 'flash-messages', { clearMessages() { assert.ok(true); }, @@ -124,7 +130,6 @@ test('it sends the approve action when clicking approve', function(assert) { assert.equal(object.timeout, 5000); } }); - this.register('service:flash-messages', mockFlashMessages); this.render(hbs`{{member-list-item membership=membership user=user}}`); @@ -134,17 +139,19 @@ test('it sends the approve action when clicking approve', function(assert) { test('it sends the deny action when clicking deny', function(assert) { assert.expect(7); - window.confirm = function() { return true; }; + window.confirm = function() { + return true; + }; - let membership = Ember.Object.create({ + let membership = Object.create({ isPending: true, destroyRecord() { assert.ok(true); - return Ember.RSVP.resolve(); - }, + return RSVP.resolve(); + } }); - let mockFlashMessages = Ember.Service.extend({ + stubService(this, 'flash-messages', { clearMessages() { assert.ok(true); }, @@ -156,7 +163,6 @@ test('it sends the deny action when clicking deny', function(assert) { assert.equal(object.timeout, 5000); } }); - this.register('service:flash-messages', mockFlashMessages); this.set('membership', membership); this.set('user', user); diff --git a/tests/integration/components/navigation-menu-test.js b/tests/integration/components/navigation-menu-test.js index 7eb9f0504..d254f082d 100644 --- a/tests/integration/components/navigation-menu-test.js +++ b/tests/integration/components/navigation-menu-test.js @@ -1,9 +1,9 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; -import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; moduleForComponent('navigation-menu', 'Integration | Component | navigation menu', { - integration: true, + integration: true }); test('it renders elements for the default menu when logged out', function(assert) { @@ -17,10 +17,7 @@ test('it renders elements for the default menu when logged out', function(assert }); test('it renders elements for the default menu when logged in', function(assert) { - let mockSessionService = Ember.Service.extend({ - isAuthenticated: true - }); - this.register('service:session', mockSessionService); + stubService(this, 'session', { isAuthenticated: true }); this.render(hbs`{{navigation-menu}}`); @@ -32,16 +29,12 @@ test('it renders elements for the default menu when logged in', function(assert) }); test('it renders elements for the onboarding menu', function(assert) { - let mockNavigationMenuService = Ember.Service.extend({ - isOnboarding: true - }); - this.register('service:navigation-menu', mockNavigationMenuService); - let mockOnboardingService = Ember.Service.extend({ + stubService(this, 'navigation-menu', { isOnboarding: true }); + stubService(this, 'onboarding', { currentStepNumber: 1, totalSteps: 3, - progressPercentage: 100, + progressPercentage: 100 }); - this.register('service:onboarding', mockOnboardingService); this.render(hbs`{{navigation-menu}}`); diff --git a/tests/integration/components/organization-header-test.js b/tests/integration/components/organization-header-test.js index e1fb9343d..6729391d7 100644 --- a/tests/integration/components/organization-header-test.js +++ b/tests/integration/components/organization-header-test.js @@ -1,28 +1,29 @@ import Ember from 'ember'; import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +const { Object } = Ember; moduleForComponent('organization-header', 'Integration | Component | organization header', { integration: true, beforeEach() { - this.register('service:credentials', mockCredentials); + stubService(this, 'credentials', { + currentUserMembership: Object.create({ + member: user, + organization, + role: 'admin' + }) + }); } }); -let user = Ember.Object.create({}); -let organization = Ember.Object.create({ +let user = Object.create({}); +let organization = Object.create({ name: 'Test Organization', description: 'A test organization', iconThumbUrl: 'icon_thumb.png', - iconLargeUrl: 'icon_large.png', -}); - -let mockCredentials = Ember.Service.extend({ - currentUserMembership: Ember.Object.create({ - member: user, - organization, - role: "admin" - }) + iconLargeUrl: 'icon_large.png' }); test('it renders', function(assert) { @@ -40,11 +41,11 @@ test('it renders properly when not expanded', function(assert) { this.render(hbs`{{organization-header organization=organization}}`); - assert.notOk(this.$('.organization-header').hasClass('expanded'), "Does not have expanded class"); - assert.equal(this.$('img').attr('src'), 'icon_thumb.png', "Has a small image"); - assert.ok(this.$('img').hasClass('icon'), "Uses the small image class"); - assert.equal(this.$('h2').text().trim(), 'Test Organization', "Shows the name"); - assert.equal(this.$('p').length, 0, "Hides the description"); + assert.notOk(this.$('.organization-header').hasClass('expanded'), 'Does not have expanded class'); + assert.equal(this.$('img').attr('src'), 'icon_thumb.png', 'Has a small image'); + assert.ok(this.$('img').hasClass('icon'), 'Uses the small image class'); + assert.equal(this.$('h2').text().trim(), 'Test Organization', 'Shows the name'); + assert.equal(this.$('p').length, 0, 'Hides the description'); }); test('it renders properly when expanded', function(assert) { @@ -54,9 +55,9 @@ test('it renders properly when expanded', function(assert) { this.render(hbs`{{organization-header organization=organization expanded=true}}`); - assert.ok(this.$('.organization-header').hasClass('expanded'), "Has expanded class"); - assert.equal(this.$('img').attr('src'), 'icon_large.png', "Has a large image"); - assert.ok(this.$('img').hasClass('icon large'), "Uses the small image class"); - assert.equal(this.$('h2').text().trim(), 'Test Organization', "Shows the name"); - assert.equal(this.$('p').text().trim(), 'A test organization', "Shows the description"); + assert.ok(this.$('.organization-header').hasClass('expanded'), 'Has expanded class'); + assert.equal(this.$('img').attr('src'), 'icon_large.png', 'Has a large image'); + assert.ok(this.$('img').hasClass('icon large'), 'Uses the small image class'); + assert.equal(this.$('h2').text().trim(), 'Test Organization', 'Shows the name'); + assert.equal(this.$('p').text().trim(), 'A test organization', 'Shows the description'); }); diff --git a/tests/integration/components/organization-members-test.js b/tests/integration/components/organization-members-test.js index 4e8f359d9..32a5bb337 100644 --- a/tests/integration/components/organization-members-test.js +++ b/tests/integration/components/organization-members-test.js @@ -13,7 +13,6 @@ test('it renders', function(assert) { assert.equal(this.$('.organization-members').length, 1, 'The component\'s element is rendered'); }); - test('it renders an item for each member in the list', function(assert) { assert.expect(2); @@ -21,7 +20,7 @@ test('it renders an item for each member in the list', function(assert) { for (let i = 1; i <= 3; i++) { mockMembers.push({ id: i, - photoThumbUrl: `image_${i}.png`, + photoThumbUrl: `image_${i}.png` }); } diff --git a/tests/integration/components/organization-menu-test.js b/tests/integration/components/organization-menu-test.js index ae1f7a9f2..9450a5ebf 100644 --- a/tests/integration/components/organization-menu-test.js +++ b/tests/integration/components/organization-menu-test.js @@ -1,16 +1,16 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; -import Ember from 'ember'; import { Ability } from 'ember-can'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; moduleForComponent('organization-menu', 'Integration | Component | organization menu', { - integration: true, + integration: true }); test('it renders', function(assert) { assert.expect(1); - this.register('service:credentials', Ember.Service); + stubService(this, 'credentials'); this.render(hbs`{{organization-menu}}`); @@ -20,11 +20,7 @@ test('it renders', function(assert) { test('when user cannot manage organization the proper menu items are rendered', function(assert) { assert.expect(2); - let mockCredentials = Ember.Service.extend({ - userCanManageOrganization: false - }); - - this.register('service:credentials', mockCredentials); + stubService(this, 'credentials', { userCanManageOrganization: false }); this.register('ability:organization', Ability.extend({ canManage: false })); this.render(hbs`{{organization-menu}}`); @@ -36,11 +32,7 @@ test('when user cannot manage organization the proper menu items are rendered', test('when user can manage organization, the proper menu items are rendered', function(assert) { assert.expect(2); - let mockCredentials = Ember.Service.extend({ - userCanManageOrganization: true - }); - - this.register('service:credentials', mockCredentials); + stubService(this, 'credentials', { userCanManageOrganization: true }); this.register('ability:organization', Ability.extend({ canManage: true })); this.render(hbs`{{organization-menu}}`); diff --git a/tests/integration/components/organization-profile-test.js b/tests/integration/components/organization-profile-test.js index c0d390435..6b1db1e14 100644 --- a/tests/integration/components/organization-profile-test.js +++ b/tests/integration/components/organization-profile-test.js @@ -1,36 +1,36 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; -import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; moduleForComponent('organization-profile', 'Integration | Component | organization profile', { integration: true, beforeEach() { - this.register('service:credentials', Ember.Service); + stubService(this, 'credentials'); } }); let members = [ - { id: 1, }, - { id: 2, }, - { id: 3, } + { id: 1 }, + { id: 2 }, + { id: 3 } ]; let memberships = members.map((member) => { - return { id: member.id, member: member }; + return { id: member.id, member }; }); let projects = [ - { id: 1, }, - { id: 2, }, - { id: 3, } + { id: 1 }, + { id: 2 }, + { id: 3 } ]; let organization = { - name: "Test Organization", - description: "Test organization description", + name: 'Test Organization', + description: 'Test organization description', slug: 'test_organization', organizationMemberships: memberships, - projects: projects, + projects }; test('it renders all its elements', function(assert) { @@ -38,7 +38,6 @@ test('it renders all its elements', function(assert) { this.set('organization', organization); - this.render(hbs`{{organization-profile organization=organization}}`); assert.equal(this.$('.organization-profile').length, 1, 'The component itself renders'); diff --git a/tests/integration/components/organization-settings-form-test.js b/tests/integration/components/organization-settings-form-test.js index 263d1b1cf..757056e4e 100644 --- a/tests/integration/components/organization-settings-form-test.js +++ b/tests/integration/components/organization-settings-form-test.js @@ -1,6 +1,9 @@ import Ember from 'ember'; import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +const { RSVP } = Ember; moduleForComponent('organization-settings-form', 'Integration | Component | organization settings form', { integration: true @@ -8,7 +11,7 @@ moduleForComponent('organization-settings-form', 'Integration | Component | orga let organization = { name: 'Test Organization', - description: 'A test organization', + description: 'A test organization' }; test('it renders', function(assert) { @@ -37,19 +40,17 @@ test('it calls save on organization when save button is clicked', function(asser organization.save = function() { assert.ok(true, 'Save method was called on organization'); - return Ember.RSVP.resolve(); + return RSVP.resolve(); }; this.set('organization', organization); - const flashServiceStub = Ember.Service.extend({ + stubService(this, 'flash-messages', { success() { assert.ok(true, 'Flash message service was called'); } }); - this.register('service:flash-messages', flashServiceStub); - this.render(hbs`{{organization-settings-form organization=organization}}`); this.$('.save').click(); diff --git a/tests/integration/components/organization-settings-menu-test.js b/tests/integration/components/organization-settings-menu-test.js index 8723e74d5..230515367 100644 --- a/tests/integration/components/organization-settings-menu-test.js +++ b/tests/integration/components/organization-settings-menu-test.js @@ -1,6 +1,9 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +const { Object } = Ember; moduleForComponent('organization-settings-menu', 'Integration | Component | organization settings menu', { integration: true @@ -9,19 +12,14 @@ moduleForComponent('organization-settings-menu', 'Integration | Component | orga test('when authenticated and can manage organization, it renders properly', function(assert) { assert.expect(2); - let organization = Ember.Object.create({ id: 1 }); - let membership = Ember.Object.create({ + let organization = Object.create({ id: 1 }); + let membership = Object.create({ isAdmin: true, - organization, - }); - - let mockSession = Ember.Service.extend({ isAuthenticated: true }); - let mockCredentials = Ember.Service.extend({ - currentUserMembership: membership + organization }); - this.register('service:session', mockSession); - this.register('service:credentials', mockCredentials); + stubService(this, 'session', { isAuthenticated: true }); + stubService(this, 'credentials', { currentUserMembership: membership }); this.set('organization', organization); @@ -34,14 +32,11 @@ test('when authenticated and can manage organization, it renders properly', func test('when authenticated and cannot manage organization, it renders properly', function(assert) { assert.expect(2); - let organization = Ember.Object.create({ id: 1 }); - let membership = Ember.Object.create({ isAdmin: false, organization }); + let organization = Object.create({ id: 1 }); + let membership = Object.create({ isAdmin: false, organization }); - let mockSession = Ember.Service.extend({ isAuthenticated: true }); - let mockCredentials = Ember.Service.extend({ currentUserMembership: membership }); - - this.register('service:session', mockSession); - this.register('service:credentials', mockCredentials); + stubService(this, 'session', { isAuthenticated: true }); + stubService(this, 'credentials', { currentUserMembership: membership }); this.set('organization', organization); @@ -54,11 +49,9 @@ test('when authenticated and cannot manage organization, it renders properly', f test('when not authenticated, it renders properly', function(assert) { assert.expect(2); - let organization = Ember.Object.create({ id: 1 }); - - let mockSession = Ember.Service.extend({ isAuthenticated: false }); + let organization = Object.create({ id: 1 }); - this.register('service:session', mockSession); + stubService(this, 'session', { isAuthenticated: false }); this.set('organization', organization); diff --git a/tests/integration/components/organization-settings-test.js b/tests/integration/components/organization-settings-test.js index 6b2b92251..8bb067b1d 100644 --- a/tests/integration/components/organization-settings-test.js +++ b/tests/integration/components/organization-settings-test.js @@ -1,18 +1,17 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; -import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; moduleForComponent('organization-settings', 'Integration | Component | organization settings', { integration: true }); - test('it renders properly', function(assert) { assert.expect(3); - this.register('service:store', Ember.Service.extend({})); - this.register('service:session', Ember.Service.extend({})); - this.register('service:credentials', Ember.Service.extend({})); + stubService(this, 'store'); + stubService(this, 'session'); + stubService(this, 'credentials'); this.render(hbs`{{organization-settings}}`); diff --git a/tests/integration/components/pager-control-test.js b/tests/integration/components/pager-control-test.js index f7c315157..597a23902 100644 --- a/tests/integration/components/pager-control-test.js +++ b/tests/integration/components/pager-control-test.js @@ -28,7 +28,7 @@ test('it renders the correct control elements', function(assert) { assert.equal(this.$('.page:last').text().trim(), '5', 'Last rendered page button is page 5'); }); -test('If there is less than 5 pages of records in total, it only renders buttons for those pages', function (assert) { +test('If there is less than 5 pages of records in total, it only renders buttons for those pages', function(assert) { this.set('options', { pageSize: 5, totalRecords: 7, diff --git a/tests/integration/components/project-card-members-test.js b/tests/integration/components/project-card-members-test.js index 7ac5f6069..ef372d4ff 100644 --- a/tests/integration/components/project-card-members-test.js +++ b/tests/integration/components/project-card-members-test.js @@ -3,6 +3,8 @@ import { faker } from 'ember-cli-mirage'; import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; +const { Object } = Ember; + moduleForComponent('project-card-members', 'Integration | Component | project card members', { integration: true }); @@ -10,7 +12,7 @@ moduleForComponent('project-card-members', 'Integration | Component | project ca function createMembers(count) { let members = []; for (let i = 1; i <= count; i++) { - members.push(Ember.Object.create({ + members.push(Object.create({ photoThumbUrl: faker.internet.avatar() })); } diff --git a/tests/integration/components/project-card-skills.js b/tests/integration/components/project-card-skills.js index 82fc4d62a..f0636a7d4 100644 --- a/tests/integration/components/project-card-skills.js +++ b/tests/integration/components/project-card-skills.js @@ -1,20 +1,20 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; -import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; -let userSkillsService = Ember.Service.extend({ +let userSkillsService = { hasSkill(skill) { return skill; }, findUserSkill(skill) { return skill; - }, -}); + } +}; moduleForComponent('project-card-ksills', 'Integration | Component | project card skills', { integration: true, beforeEach() { - this.register('service:user-skills', userSkillsService); + stubService(this, 'user-skills', userSkillsService); } }); @@ -35,7 +35,7 @@ test('it shows expander and toggles for lots of skills', function(assert) { assert.expect(11); let skills = []; - for(var i = 1; i <= 100; i++) { + for (let i = 1; i <= 100; i++) { skills.pushObject({ title: `Skill ${i}` }); diff --git a/tests/integration/components/project-card-test.js b/tests/integration/components/project-card-test.js index 9fb2f79d7..0019e37da 100644 --- a/tests/integration/components/project-card-test.js +++ b/tests/integration/components/project-card-test.js @@ -2,11 +2,17 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import startMirage from '../../helpers/setup-mirage-for-integration'; import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +const { K } = Ember; moduleForComponent('project-card', 'Integration | Component | project card', { integration: true, setup() { startMirage(this.container); + }, + afterEach() { + server.shutdown(); } }); @@ -14,7 +20,7 @@ test('it renders', function(assert) { let project = server.create('project'); let organization = server.create('organization'); let user = server.create('user'); - let membership = server.create('organization-membership', { member: user, organization}); + let membership = server.create('organization-membership', { member: user, organization }); let projectCategory = server.create('project-category', { project }); let mockedProject = { @@ -26,14 +32,10 @@ test('it renders', function(assert) { name: organization.name, organizationMemberships: [membership] }, - projectCategories: [projectCategory], + projectCategories: [projectCategory] }; - let mockUserCategoriesService = Ember.Service.extend({ - findUserCategory: Ember.K, - }); - this.register('service:user-categories', mockUserCategoriesService); - + stubService(this, 'user-categories', { findUserCategory: K }); this.set('project', mockedProject); this.render(hbs`{{project-card project=project}}`); diff --git a/tests/integration/components/project-categories-list-test.js b/tests/integration/components/project-categories-list-test.js index 3377b36d5..52209c46c 100644 --- a/tests/integration/components/project-categories-list-test.js +++ b/tests/integration/components/project-categories-list-test.js @@ -1,6 +1,9 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +const { K } = Ember; moduleForComponent('project-categories-list', 'Integration | Component | project categories list', { integration: true @@ -18,16 +21,13 @@ let categories = [ { id: 3, name: 'Alphabets' - }, + } ]; test('it renders the categories and sorts them by name', function(assert) { assert.expect(4); - let mockUserCategoriesService = Ember.Service.extend({ - findUserCategory: Ember.K, - }); - this.register('service:user-categories', mockUserCategoriesService); + stubService(this, 'user-categories', { findUserCategory: K }); this.set('categories', categories); this.render(hbs`{{project-categories-list categories=categories}}`); diff --git a/tests/integration/components/project-category-item-test.js b/tests/integration/components/project-category-item-test.js index 221dfd1cd..aceb0f34d 100644 --- a/tests/integration/components/project-category-item-test.js +++ b/tests/integration/components/project-category-item-test.js @@ -1,36 +1,40 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +const { + Object, + run +} = Ember; moduleForComponent('project-category-item', 'Integration | Component | project category item', { integration: true, beforeEach() { - this.register('service:user-categories', mockUserCategoriesService); - }, -}); - -let mockUserCategoriesService = Ember.Service.extend({ - findUserCategory(category) { - if (category.id === mockUserCategory.get('categoryId')) { - return mockUserCategory; - } - }, + stubService(this, 'user-categories', { + findUserCategory(category) { + if (category.id === mockUserCategory.get('categoryId')) { + return mockUserCategory; + } + } + }); + } }); -let mockUserCategory = Ember.Object.create({ +let mockUserCategory = Object.create({ id: 1, categoryId: 2, - userId: 1, + userId: 1 }); test('it works for unselected categories', function(assert) { assert.expect(6); let category = { - id: 1, - name: 'Technology', - slug: 'technology', - description: 'You want to help technology.', + id: 1, + name: 'Technology', + slug: 'technology', + description: 'You want to help technology.' }; this.set('category', category); @@ -38,22 +42,24 @@ test('it works for unselected categories', function(assert) { assert.ok(this.$('.interest-icon').hasClass('technology')); assert.notOk(this.$('.interest-icon').hasClass('selected')); - assert.ok(this.$('li').hasClass('ember-tooltip-target')); + assert.ok(this.$('li').hasClass('ember-tooltip-or-popover-target')); assert.equal(this.$('.ember-tooltip').text().trim(), 'Technology'); - assert.equal(this.$('.ember-tooltip').attr('aria-hidden'), "true"); + assert.equal(this.$('.ember-tooltip').attr('aria-hidden'), 'true'); - Ember.run(() => { this.$('li').trigger('mouseenter'); }); - assert.equal(this.$('.ember-tooltip').attr('aria-hidden'), "false"); + run(() => { + this.$('li').trigger('mouseenter'); + }); + assert.equal(this.$('.ember-tooltip').attr('aria-hidden'), 'false'); }); test('it works for selected categories', function(assert) { assert.expect(6); let category = { - id: 2, - name: 'Society', - slug: 'society', - description: 'You want to help society.', + id: 2, + name: 'Society', + slug: 'society', + description: 'You want to help society.' }; this.set('category', category); @@ -61,10 +67,12 @@ test('it works for selected categories', function(assert) { assert.ok(this.$('.interest-icon').hasClass('society')); assert.ok(this.$('.interest-icon').hasClass('selected')); - assert.ok(this.$('li').hasClass('ember-tooltip-target')); + assert.ok(this.$('li').hasClass('ember-tooltip-or-popover-target')); assert.equal(this.$('.ember-tooltip').text().trim(), 'Society'); - assert.equal(this.$('.ember-tooltip').attr('aria-hidden'), "true"); + assert.equal(this.$('.ember-tooltip').attr('aria-hidden'), 'true'); - Ember.run(() => { this.$('li').trigger('mouseenter'); }); - assert.ok(this.$('.ember-tooltip').attr('aria-hidden'), "false"); + run(() => { + this.$('li').trigger('mouseenter'); + }); + assert.ok(this.$('.ember-tooltip').attr('aria-hidden'), 'false'); }); diff --git a/tests/integration/components/project-container-test.js b/tests/integration/components/project-container-test.js index 127f9153f..ea5f84186 100644 --- a/tests/integration/components/project-container-test.js +++ b/tests/integration/components/project-container-test.js @@ -11,5 +11,5 @@ test('it renders properly', function(assert) { this.render(hbs`{{project-container}}`); assert.equal(this.$('.project-details').length, 1, 'The details render'); - assert.equal(this.$('.project-menu').length, 1 , 'The menu renders'); + assert.equal(this.$('.project-menu').length, 1, 'The menu renders'); }); diff --git a/tests/integration/components/project-details-test.js b/tests/integration/components/project-details-test.js index 1a4d70fcc..71e806d1b 100644 --- a/tests/integration/components/project-details-test.js +++ b/tests/integration/components/project-details-test.js @@ -6,6 +6,9 @@ moduleForComponent('project-details', 'Integration | Component | project details integration: true, setup() { startMirage(this.container); + }, + afterEach() { + server.shutdown(); } }); diff --git a/tests/integration/components/project-item-test.js b/tests/integration/components/project-item-test.js index f8cbaa900..6a432e2ea 100644 --- a/tests/integration/components/project-item-test.js +++ b/tests/integration/components/project-item-test.js @@ -19,7 +19,7 @@ test('it renders the correct UI elements', function(assert) { this.set('project', { iconThumbUrl: 'icon.png', title: 'A project', - description: 'A description', + description: 'A description' }); this.render(hbs`{{project-item project=project}}`); diff --git a/tests/integration/components/project-list-test.js b/tests/integration/components/project-list-test.js index 5ea8cd76b..dde77daf2 100644 --- a/tests/integration/components/project-list-test.js +++ b/tests/integration/components/project-list-test.js @@ -13,7 +13,6 @@ test('it renders', function(assert) { assert.equal(this.$('.project-list').length, 1, 'The component\'s element is rendered'); }); - test('it renders an item for each project in the list', function(assert) { assert.expect(1); diff --git a/tests/integration/components/project-long-description-test.js b/tests/integration/components/project-long-description-test.js index 5470211b5..29d4dbd00 100644 --- a/tests/integration/components/project-long-description-test.js +++ b/tests/integration/components/project-long-description-test.js @@ -1,32 +1,36 @@ import Ember from 'ember'; import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +const { + Object, + RSVP +} = Ember; moduleForComponent('project-long-description', 'Integration | Component | project long description', { - integration: true, - beforeEach() { - this.register('service:credentials', Ember.Service.extend({})); - } + integration: true }); -let credentialsWithAdminMembership = Ember.Service.extend({ - currentUserMembership: Ember.Object.create({ +let credentialsWithAdminMembership = { + currentUserMembership: Object.create({ isAdmin: true }) -}); +}; -let projectWithDescription = Ember.Object.create({ +let projectWithDescription = Object.create({ longDescriptionBody: 'A body', longDescriptionMarkdown: 'A **body**' }); -let blankProject = Ember.Object.create({ +let blankProject = Object.create({ longDescriptionBody: null, longDescriptionMarkdown: null }); test('it renders properly when decription is blank and the user cannot add to it', function(assert) { assert.expect(3); + stubService(this, 'credentials'); this.set('project', blankProject); this.render(hbs`{{project-long-description project=project}}`); @@ -40,7 +44,7 @@ test('it renders properly when description is blank and the user can add to it', assert.expect(3); this.set('project', blankProject); - this.register('service:credentials', credentialsWithAdminMembership); + stubService(this, 'credentials', credentialsWithAdminMembership); this.render(hbs`{{project-long-description project=project}}`); @@ -51,6 +55,7 @@ test('it renders properly when description is blank and the user can add to it', test('it renders properly when description is present and user cannot edit', function(assert) { assert.expect(6); + stubService(this, 'credentials'); this.set('project', projectWithDescription); @@ -68,7 +73,7 @@ test('it renders properly when description is present and user can edit', functi assert.expect(4); this.set('project', projectWithDescription); - this.register('service:credentials', credentialsWithAdminMembership); + stubService(this, 'credentials', credentialsWithAdminMembership); this.render(hbs`{{project-long-description project=project}}`); @@ -81,15 +86,15 @@ test('it renders properly when description is present and user can edit', functi test('it is possible to add a description', function(assert) { assert.expect(1); - let savableProject = Ember.Object.create(blankProject, { + let savableProject = Object.create(blankProject, { save() { assert.ok(true); - return Ember.RSVP.resolve(this); + return RSVP.resolve(this); } }); this.set('project', savableProject); - this.register('service:credentials', credentialsWithAdminMembership); + stubService(this, 'credentials', credentialsWithAdminMembership); this.render(hbs`{{project-long-description project=project}}`); @@ -99,15 +104,15 @@ test('it is possible to add a description', function(assert) { test('it is possible to edit a description', function(assert) { assert.expect(3); - let savableProject = Ember.Object.create(projectWithDescription, { + let savableProject = Object.create(projectWithDescription, { save() { assert.ok(true); - return Ember.RSVP.resolve(this); + return RSVP.resolve(this); } }); this.set('project', savableProject); - this.register('service:credentials', credentialsWithAdminMembership); + stubService(this, 'credentials', credentialsWithAdminMembership); this.render(hbs`{{project-long-description project=project}}`); assert.equal(this.$('.editor-with-preview').length, 0, 'The editor is not shown, since we are in read mode'); diff --git a/tests/integration/components/project-menu-test.js b/tests/integration/components/project-menu-test.js index df25fa313..7c7cea451 100644 --- a/tests/integration/components/project-menu-test.js +++ b/tests/integration/components/project-menu-test.js @@ -1,19 +1,19 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; -import Ember from 'ember'; import { Ability } from 'ember-can'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; moduleForComponent('project-menu', 'Integration | Component | project menu', { integration: true, beforeEach() { - this.register('service:credentials', Ember.Service.extend({})); + stubService(this, 'credentials'); } }); test('when not authenticated, it renders properly', function(assert) { assert.expect(5); - this.register('service:session', Ember.Service.extend({ isAuthenticated: false })); + stubService(this, 'session', { isAuthenticated: false }); this.render(hbs`{{project-menu}}`); @@ -28,7 +28,7 @@ test('when not authenticated, it renders properly', function(assert) { test('it renders the task count when it has tasks', function(assert) { assert.expect(1); - this.register('service:session', Ember.Service.extend({ isAuthenticated: false })); + stubService(this, 'session', { isAuthenticated: false }); this.set('project', { hasOpenTasks: true, openTasksCount: 7 @@ -42,7 +42,7 @@ test('it renders the task count when it has tasks', function(assert) { test('it does not render the task count when it has no tasks', function(assert) { assert.expect(1); - this.register('service:session', Ember.Service.extend({ isAuthenticated: false })); + stubService(this, 'session', { isAuthenticated: false }); this.set('project', { hasOpenTasks: false, openTasksCount: 0 @@ -56,7 +56,7 @@ test('it does not render the task count when it has no tasks', function(assert) test('when authenticated, and user cannot manage organization, it renders properly', function(assert) { assert.expect(5); - this.register('service:session', Ember.Service.extend({ isAuthenticated: true })); + stubService(this, 'session', { isAuthenticated: true }); this.register('ability:organization', Ability.extend({ canManage: false })); this.render(hbs`{{project-menu}}`); @@ -71,7 +71,7 @@ test('when authenticated, and user cannot manage organization, it renders proper test('when authenticated, and user can manage organization, it renders properly', function(assert) { assert.expect(5); - this.register('service:session', Ember.Service.extend({ isAuthenticated: true })); + stubService(this, 'session', { isAuthenticated: true }); this.register('ability:organization', Ability.extend({ canManage: true })); this.render(hbs`{{project-menu}}`); @@ -86,7 +86,7 @@ test('when authenticated, and user can manage organization, it renders properly' test('when authenticated, and user can manage organization, and project has pending members', function(assert) { assert.expect(1); - this.register('service:session', Ember.Service.extend({ isAuthenticated: true })); + stubService(this, 'session', { isAuthenticated: true }); this.register('ability:organization', Ability.extend({ canManage: true })); let project = { hasPendingMembers: true, pendingMembersCount: 7 }; this.set('project', project); @@ -99,7 +99,7 @@ test('when authenticated, and user can manage organization, and project has pend test('when authenticated, and user can manage organization, and project has no pending members', function(assert) { assert.expect(1); - this.register('service:session', Ember.Service.extend({ isAuthenticated: true })); + stubService(this, 'session', { isAuthenticated: true }); this.register('ability:organization', Ability.extend({ canManage: true })); let project = { hasPendingMembers: false, pendingMembersCount: 0 }; this.set('project', project); diff --git a/tests/integration/components/project-settings-form-test.js b/tests/integration/components/project-settings-form-test.js index 655fd7399..823cfda95 100644 --- a/tests/integration/components/project-settings-form-test.js +++ b/tests/integration/components/project-settings-form-test.js @@ -1,6 +1,9 @@ import Ember from 'ember'; import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +const { RSVP } = Ember; moduleForComponent('project-settings-form', 'Integration | Component | project settings form', { integration: true @@ -8,7 +11,7 @@ moduleForComponent('project-settings-form', 'Integration | Component | project s let project = { title: 'Test Organization', - description: 'A test project', + description: 'A test project' }; test('it renders', function(assert) { @@ -37,19 +40,17 @@ test('it calls save on project when save button is clicked', function(assert) { project.save = function() { assert.ok(true, 'Save method was called on project'); - return Ember.RSVP.resolve(); + return RSVP.resolve(); }; this.set('project', project); - const flashServiceStub = Ember.Service.extend({ + stubService(this, 'flash-messages', { success() { assert.ok(true, 'Flash message service was called'); } }); - this.register('service:flash-messages', flashServiceStub); - this.render(hbs`{{project-settings-form project=project}}`); this.$('.save').click(); diff --git a/tests/integration/components/project-settings-menu-test.js b/tests/integration/components/project-settings-menu-test.js index f8725cbf0..cf18d235c 100644 --- a/tests/integration/components/project-settings-menu-test.js +++ b/tests/integration/components/project-settings-menu-test.js @@ -1,23 +1,23 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +const { Object } = Ember; moduleForComponent('project-settings-menu', 'Integration | Component | project settings menu', { integration: true }); -let organization = Ember.Object.create({ id: 1 }); -let project = Ember.Object.create({ organization }); +let organization = Object.create({ id: 1 }); +let project = Object.create({ organization }); test('when authenticated and can manage organization, it renders properly', function(assert) { assert.expect(4); - let membership = Ember.Object.create({ isAdmin: true, organization }); - let mockSession = Ember.Service.extend({ isAuthenticated: true }); - let mockCredentials = Ember.Service.extend({ currentUserMembership: membership }); - - this.register('service:session', mockSession); - this.register('service:credentials', mockCredentials); + let membership = Object.create({ isAdmin: true, organization }); + stubService(this, 'session', { isAuthenticated: true }); + stubService(this, 'credentials', { currentUserMembership: membership }); this.set('project', project); @@ -32,12 +32,9 @@ test('when authenticated and can manage organization, it renders properly', func test('when authenticated and cannot manage organization, it renders properly', function(assert) { assert.expect(2); - let membership = Ember.Object.create({ isAdmin: false, organization }); - let mockSession = Ember.Service.extend({ isAuthenticated: true }); - let mockCredentials = Ember.Service.extend({ currentUserMembership: membership }); - - this.register('service:session', mockSession); - this.register('service:credentials', mockCredentials); + let membership = Object.create({ isAdmin: false, organization }); + stubService(this, 'session', { isAuthenticated: true }); + stubService(this, 'credentials', { currentUserMembership: membership }); this.set('project', project); @@ -50,9 +47,7 @@ test('when authenticated and cannot manage organization, it renders properly', f test('when not authenticated, it renders properly', function(assert) { assert.expect(2); - let mockSession = Ember.Service.extend({ isAuthenticated: false }); - - this.register('service:session', mockSession); + stubService(this, 'session', { isAuthenticated: false }); this.set('project', project); diff --git a/tests/integration/components/project-task-list-test.js b/tests/integration/components/project-task-list-test.js index 767257ff9..a0f064850 100644 --- a/tests/integration/components/project-task-list-test.js +++ b/tests/integration/components/project-task-list-test.js @@ -2,7 +2,7 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; moduleForComponent('project-task-list', 'Integration | Component | project task list', { - integration: true, + integration: true }); test('it renders', function(assert) { @@ -21,7 +21,7 @@ test('it renders a message if the task count is 0', function(assert) { assert.equal(this.$('.empty').length, 1, 'The message is rendered'); assert.equal(this.$('.empty .empty-icon.box-icon').length, 1, 'The icon is rendered'); assert.equal(this.$('.empty h3').text().trim(), "Here's where the magic happens."); - assert.equal(this.$('.empty button').text().trim(), "Create a task"); + assert.equal(this.$('.empty button').text().trim(), 'Create a task'); }); test('it renders a message if the task count is 0 and tasks are filtered', function(assert) { @@ -36,10 +36,10 @@ test('it renders a message if the task count is 0 and tasks are filtered', funct }); test('it renders a task item for each task', function(assert) { - const tasks = [ - { id: 1, }, - { id: 2, }, - { id: 3, } + let tasks = [ + { id: 1 }, + { id: 2 }, + { id: 3 } ]; this.set('tasks', tasks); diff --git a/tests/integration/components/role-item-test.js b/tests/integration/components/role-item-test.js index 353c6e955..b8ba77a58 100644 --- a/tests/integration/components/role-item-test.js +++ b/tests/integration/components/role-item-test.js @@ -2,27 +2,26 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; import wait from 'ember-test-helpers/wait'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; -const { getOwner } = Ember; - -moduleForComponent('role-item', 'Integration | Component | role item', { - integration: true, - beforeEach() { - mockUserRole.set('roleId', defaultRoleId); - } -}); +const { + getOwner, + Object, + RSVP, + run +} = Ember; let defaultRoleId = 2; -let mockUserRolesService = Ember.Service.extend({ +let mockUserRolesService = { findUserRole(role) { if (role.id === mockUserRole.get('roleId')) { return mockUserRole; } }, addRole(role) { - return new Ember.RSVP.Promise((fulfill) => { - Ember.run.next(() => { + return new RSVP.Promise((fulfill) => { + run.next(() => { mockUserRole.set('roleId', role.get('id')); getOwner(this).lookup('service:user-roles').set('userRoles', [mockUserRole]); fulfill(); @@ -30,55 +29,62 @@ let mockUserRolesService = Ember.Service.extend({ }); }, removeRole() { - return new Ember.RSVP.Promise((fulfill, reject) => { - Ember.run.next(() => { + return new RSVP.Promise((fulfill, reject) => { + run.next(() => { mockUserRole.set('roleId', null); getOwner(this).lookup('service:user-roles').set('userRoles', []); reject(); }); }); - }, -}); + } +}; -let mockUserRolesServiceForErrors = Ember.Service.extend({ +let mockUserRolesServiceForErrors = { findUserRole(role) { if (role.id === mockUserRole.get('roleId')) { return mockUserRole; } }, addRole() { - return Ember.RSVP.reject(); + return RSVP.reject(); }, removeRole() { - return Ember.RSVP.reject(); - }, -}); + return RSVP.reject(); + } +}; -let mockUserRole = Ember.Object.create({ +let mockUserRole = Object.create({ id: 1, roleId: defaultRoleId, - userId: 1, + userId: 1 }); -let unselectedRole = Ember.Object.create({ +let unselectedRole = Object.create({ id: 1, name: 'Backend Developer', ability: 'Backend Development', - kind: 'technology', + kind: 'technology' }); -let selectedRole = Ember.Object.create({ +let selectedRole = Object.create({ id: 2, name: 'Mobile Developer', ability: 'Mobile Development', - kind: 'technology', + kind: 'technology' +}); + +moduleForComponent('role-item', 'Integration | Component | role item', { + integration: true, + beforeEach() { + mockUserRole.set('roleId', defaultRoleId); + } }); test('it works for selecting unselected roles', function(assert) { let done = assert.async(); assert.expect(3); - this.register('service:user-roles', mockUserRolesService); + stubService(this, 'user-roles', mockUserRolesService); this.set('role', unselectedRole); this.render(hbs`{{role-item role=role}}`); @@ -97,7 +103,7 @@ test('it works for removing selected roles', function(assert) { let done = assert.async(); assert.expect(3); - this.register('service:user-roles', mockUserRolesService); + stubService(this, 'user-roles', mockUserRolesService); this.set('role', selectedRole); this.render(hbs`{{role-item role=role}}`); @@ -116,10 +122,10 @@ test('it creates a flash message on an error when adding', function(assert) { let done = assert.async(); assert.expect(7); - this.register('service:user-roles', mockUserRolesServiceForErrors); + stubService(this, 'user-roles', mockUserRolesServiceForErrors); this.set('role', unselectedRole); - let mockFlashMessages = Ember.Service.extend({ + stubService(this, 'flash-messages', { clearMessages() { assert.ok(true); }, @@ -131,7 +137,6 @@ test('it creates a flash message on an error when adding', function(assert) { assert.equal(object.timeout, 5000); } }); - this.register('service:flash-messages', mockFlashMessages); this.render(hbs`{{role-item role=role}}`); @@ -146,10 +151,10 @@ test('it creates a flash message on an error when removing', function(assert) { let done = assert.async(); assert.expect(7); - this.register('service:user-roles', mockUserRolesServiceForErrors); + stubService(this, 'user-roles', mockUserRolesServiceForErrors); this.set('role', selectedRole); - let mockFlashMessages = Ember.Service.extend({ + stubService(this, 'flash-messages', { clearMessages() { assert.ok(true); }, @@ -161,7 +166,6 @@ test('it creates a flash message on an error when removing', function(assert) { assert.equal(object.timeout, 5000); } }); - this.register('service:flash-messages', mockFlashMessages); this.render(hbs`{{role-item role=role}}`); @@ -176,7 +180,7 @@ test('it sets and unsets loading state when adding', function(assert) { let done = assert.async(); assert.expect(3); - this.register('service:user-roles', mockUserRolesService); + stubService(this, 'user-roles', mockUserRolesService); this.set('role', unselectedRole); this.render(hbs`{{role-item role=role}}`); @@ -193,7 +197,7 @@ test('it sets and unsets loading state when adding', function(assert) { test('it sets and unsets loading state when removing', function(assert) { let done = assert.async(); - this.register('service:user-roles', mockUserRolesService); + stubService(this, 'user-roles', mockUserRolesService); assert.expect(3); this.set('role', selectedRole); diff --git a/tests/integration/components/signup-email-input-test.js b/tests/integration/components/signup-email-input-test.js index e582f88fc..5432c50d8 100644 --- a/tests/integration/components/signup-email-input-test.js +++ b/tests/integration/components/signup-email-input-test.js @@ -4,10 +4,15 @@ import Ember from 'ember'; import startMirage from '../../helpers/setup-mirage-for-integration'; import wait from 'ember-test-helpers/wait'; +const { run } = Ember; + moduleForComponent('signup-email-input', 'Integration | Component | signup email input', { integration: true, setup() { startMirage(this.container); + }, + afterEach() { + server.shutdown(); } }); @@ -24,17 +29,17 @@ test('it shows suggestions when invalid', function(assert) { assert.expect(5); server.get('/users/email_available', () => { - return { valid: false, available: true }; + return { valid: false, available: true }; }); this.on('emailValidated', (result) => { - Ember.run.next(() => { + run.next(() => { assert.equal(result, false); }); }); this.render(hbs`{{signup-email-input user=user emailValidated="emailValidated"}}`); - this.set('user', { email: 'incomplete@'}); + this.set('user', { email: 'incomplete@' }); wait().then(() => { assert.equal(this.$('.suggestions p').hasClass('ok'), false); @@ -50,17 +55,17 @@ test('it shows suggestions when unavailable', function(assert) { assert.expect(5); server.get('/users/email_available', () => { - return { valid: true, available: false }; + return { valid: true, available: false }; }); this.on('emailValidated', (result) => { - Ember.run.next(() => { + run.next(() => { assert.equal(result, false); }); }); this.render(hbs`{{signup-email-input user=user emailValidated="emailValidated"}}`); - this.set('user', { email: 'taken@gmail.com'}); + this.set('user', { email: 'taken@gmail.com' }); wait().then(() => { assert.equal(this.$('.suggestions p').hasClass('ok'), false); @@ -76,17 +81,17 @@ test('it shows ok when valid and available', function(assert) { assert.expect(4); server.get('/users/email_available', () => { - return { valid: true, available: true }; + return { valid: true, available: true }; }); this.on('emailValidated', (result) => { - Ember.run.next(() => { + run.next(() => { assert.equal(result, true); }); }); this.render(hbs`{{signup-email-input user=user emailValidated="emailValidated"}}`); - this.set('user', { email: 'available@gmail.com'}); + this.set('user', { email: 'available@gmail.com' }); wait().then(() => { assert.equal(this.$('.suggestions p').hasClass('ok'), true); @@ -101,18 +106,18 @@ test('it resets to invalid when deleted', function(assert) { assert.expect(4); server.get('/users/email_available', () => { - return { valid: true, available: true }; + return { valid: true, available: true }; }); this.on('emailValidated', (result) => { - Ember.run.next(() => { + run.next(() => { assert.equal(result, false); }); }); - this.set('user', { email: 'available@gmail.com'}); + this.set('user', { email: 'available@gmail.com' }); this.render(hbs`{{signup-email-input user=user emailValidated="emailValidated"}}`); - this.set('user', { email: ''}); + this.set('user', { email: '' }); wait().then(() => { assert.equal(this.$('.suggestions p').hasClass('ok'), false); diff --git a/tests/integration/components/signup-form-test.js b/tests/integration/components/signup-form-test.js index e0c7e6e43..e5b850571 100644 --- a/tests/integration/components/signup-form-test.js +++ b/tests/integration/components/signup-form-test.js @@ -15,7 +15,6 @@ test('it renders', function(assert) { assert.equal(this.$('.signup-form').length, 1); }); - test('it renders required ui elements', function(assert) { this.render(hbs`{{signup-form}}`); diff --git a/tests/integration/components/signup-password-input-test.js b/tests/integration/components/signup-password-input-test.js index 9fda08772..9265bfcf1 100644 --- a/tests/integration/components/signup-password-input-test.js +++ b/tests/integration/components/signup-password-input-test.js @@ -12,7 +12,7 @@ test('it shows nothing when empty', function(assert) { }); test('it shows suggestions when needed', function(assert) { - this.set('user', { password: 'password'}); + this.set('user', { password: 'password' }); this.render(hbs`{{signup-password-input user=user}}`); assert.equal(this.$('p').hasClass('ok'), true); @@ -23,14 +23,14 @@ test('it shows suggestions when needed', function(assert) { test('it shows password strength', function(assert) { // https://xkcd.com/936/ - this.set('user', { password: 'correcthorsebatterystaple'}); + this.set('user', { password: 'correcthorsebatterystaple' }); this.render(hbs`{{signup-password-input user=user}}`); assert.equal(this.$('.progress-bar').attr('style'), 'width: 100%;'); }); test('it shows minimum length error', function(assert) { - this.set('user', { password: 'p'}); + this.set('user', { password: 'p' }); this.render(hbs`{{signup-password-input user=user}}`); assert.equal(this.$('p').hasClass('not-ok'), true); diff --git a/tests/integration/components/signup-username-input-test.js b/tests/integration/components/signup-username-input-test.js index 06d8d4cc0..1bb984427 100644 --- a/tests/integration/components/signup-username-input-test.js +++ b/tests/integration/components/signup-username-input-test.js @@ -4,10 +4,15 @@ import Ember from 'ember'; import startMirage from '../../helpers/setup-mirage-for-integration'; import wait from 'ember-test-helpers/wait'; +const { run } = Ember; + moduleForComponent('signup-username-input', 'Integration | Component | signup username input', { integration: true, setup() { startMirage(this.container); + }, + afterEach() { + server.shutdown(); } }); @@ -24,17 +29,17 @@ test('it shows suggestions when invalid', function(assert) { assert.expect(5); server.get('/users/username_available', () => { - return { valid: false, available: true }; + return { valid: false, available: true }; }); this.on('usernameValidated', (result) => { - Ember.run.next(() => { + run.next(() => { assert.equal(result, false); }); }); this.render(hbs`{{signup-username-input user=user usernameValidated="usernameValidated"}}`); - this.set('user', { username: 'lots--of--hypens'}); + this.set('user', { username: 'lots--of--hypens' }); wait().then(() => { assert.equal(this.$('.suggestions p').hasClass('ok'), false); @@ -50,17 +55,17 @@ test('it shows suggestions when unavailable', function(assert) { assert.expect(5); server.get('/users/username_available', () => { - return { valid: true, available: false }; + return { valid: true, available: false }; }); this.on('usernameValidated', (result) => { - Ember.run.next(() => { + run.next(() => { assert.equal(result, false); }); }); this.render(hbs`{{signup-username-input user=user usernameValidated="usernameValidated"}}`); - this.set('user', { username: 'taken'}); + this.set('user', { username: 'taken' }); wait().then(() => { assert.equal(this.$('.suggestions p').hasClass('ok'), false); @@ -76,17 +81,17 @@ test('it shows ok when valid and available', function(assert) { assert.expect(4); server.get('/users/username_available', () => { - return { valid: true, available: true }; + return { valid: true, available: true }; }); this.on('usernameValidated', (result) => { - Ember.run.next(() => { + run.next(() => { assert.equal(result, true); }); }); this.render(hbs`{{signup-username-input user=user usernameValidated="usernameValidated"}}`); - this.set('user', { username: 'available'}); + this.set('user', { username: 'available' }); wait().then(() => { assert.equal(this.$('.suggestions p').hasClass('ok'), true); @@ -101,18 +106,18 @@ test('it resets to invalid when deleted', function(assert) { assert.expect(4); server.get('/users/username_available', () => { - return { valid: true, available: true }; + return { valid: true, available: true }; }); this.on('usernameValidated', (result) => { - Ember.run.next(() => { + run.next(() => { assert.equal(result, false); }); }); - this.set('user', { username: 'available'}); + this.set('user', { username: 'available' }); this.render(hbs`{{signup-username-input user=user usernameValidated="usernameValidated"}}`); - this.set('user', { username: ''}); + this.set('user', { username: '' }); wait().then(() => { assert.equal(this.$('.suggestions p').hasClass('ok'), false); diff --git a/tests/integration/components/skill-button-test.js b/tests/integration/components/skill-button-test.js index 4172fcdc9..0b495089a 100644 --- a/tests/integration/components/skill-button-test.js +++ b/tests/integration/components/skill-button-test.js @@ -1,6 +1,6 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; -import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; moduleForComponent('skill-button', 'Integration | Component | skill button', { integration: true @@ -64,12 +64,11 @@ test('it responds to hovering', function(assert) { test('it removes the skill when clicking', function(assert) { let skill = { title: 'Ruby' }; - let mockUserSkillsService = Ember.Service.extend({ + stubService(this, 'user-skills', { removeSkill(removedSkill) { assert.deepEqual(skill, removedSkill); } }); - this.register('service:user-skills', mockUserSkillsService); this.set('skill', skill); this.render(hbs`{{skill-button skill=skill}}`); this.$('button').click(); diff --git a/tests/integration/components/skill-list-item-test.js b/tests/integration/components/skill-list-item-test.js index f8bd27311..7a92d05b2 100644 --- a/tests/integration/components/skill-list-item-test.js +++ b/tests/integration/components/skill-list-item-test.js @@ -1,20 +1,18 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; -import Ember from 'ember'; - -let userSkillsService = Ember.Service.extend({ - hasSkill(skill) { - return skill; - }, - findUserSkill(skill) { - return skill; - }, -}); +import stubService from 'code-corps-ember/tests/helpers/stub-service'; moduleForComponent('skill-list-item', 'Integration | Component | skill list item', { integration: true, beforeEach() { - this.register('service:user-skills', userSkillsService); + stubService(this, 'user-skills', { + hasSkill(skill) { + return skill; + }, + findUserSkill(skill) { + return skill; + } + }); } }); diff --git a/tests/integration/components/skill-list-items-test.js b/tests/integration/components/skill-list-items-test.js index 4a4a2a8f9..be7514a8a 100644 --- a/tests/integration/components/skill-list-items-test.js +++ b/tests/integration/components/skill-list-items-test.js @@ -1,37 +1,38 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; -let userSkillsService = Ember.Service.extend({ - hasSkill(queriedSkill) { - return queriedSkill === skills[1]; - }, - findUserSkill(queriedSkill) { - if (queriedSkill === skills[1]) { - return queriedSkill; - } - } -}); +const { Object } = Ember; let skills = [ - Ember.Object.create({ - title: "Rails" - }), - Ember.Object.create({ - title: "HTML" + Object.create({ + title: 'Rails' }), - Ember.Object.create({ - title: "Ruby" + Object.create({ + title: 'HTML' }), - Ember.Object.create({ - title: "Ember.js" + Object.create({ + title: 'Ruby' }), + Object.create({ + title: 'Ember.js' + }) ]; moduleForComponent('skill-list-items', 'Integration | Component | skill list items', { integration: true, beforeEach() { - this.register('service:user-skills', userSkillsService); + stubService(this, 'user-skills', { + hasSkill(queriedSkill) { + return queriedSkill === skills[1]; + }, + findUserSkill(queriedSkill) { + if (queriedSkill === skills[1]) { + return queriedSkill; + } + } + }); } }); diff --git a/tests/integration/components/slugged-route-model-details-test.js b/tests/integration/components/slugged-route-model-details-test.js index 3ec67af95..e8a71eff9 100644 --- a/tests/integration/components/slugged-route-model-details-test.js +++ b/tests/integration/components/slugged-route-model-details-test.js @@ -1,12 +1,12 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; -import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; moduleForComponent('slugged-route-model-details', 'Integration | Component | slugged route model details', { integration: true, beforeEach() { - this.register('service:credentials', Ember.Service); - }, + stubService(this, 'credentials'); + } }); test('it renders', function(assert) { @@ -25,7 +25,6 @@ test('when the slugged route is an organization, it renders the organization com assert.equal(this.$('.organization-profile').length, 1); }); - test('when the slugged route is a user, it renders the user component', function(assert) { assert.expect(1); diff --git a/tests/integration/components/submittable-textarea-test.js b/tests/integration/components/submittable-textarea-test.js index 8addef67f..81223b4b9 100644 --- a/tests/integration/components/submittable-textarea-test.js +++ b/tests/integration/components/submittable-textarea-test.js @@ -2,17 +2,19 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +const { $ } = Ember; + moduleForComponent('submittable-textarea', 'Integration | Component | submittable textarea', { integration: true }); -let pressCtrlEnter = Ember.$.Event('keydown', { +let pressCtrlEnter = $.Event('keydown', { keyCode: 13, which: 13, ctrlKey: true }); -let pressCmdEnter = Ember.$.Event('keydown', { +let pressCmdEnter = $.Event('keydown', { keyCode: 13, which: 13, metaKey: true diff --git a/tests/integration/components/task-comment-list-test.js b/tests/integration/components/task-comment-list-test.js index 83b85230d..ba2c65cc6 100644 --- a/tests/integration/components/task-comment-list-test.js +++ b/tests/integration/components/task-comment-list-test.js @@ -1,17 +1,21 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; -let mockStore = Ember.Service.extend({ - query () { - return Ember.RSVP.resolve([]); - } -}); +const { + Object, + RSVP +} = Ember; moduleForComponent('task-comment-list', 'Integration | Component | task comment list', { integration: true, beforeEach() { - this.register('service:store', mockStore); + stubService(this, 'store', { + query() { + return RSVP.resolve([]); + } + }); } }); @@ -25,9 +29,9 @@ test('It renders a list of comments if there are comments', function(assert) { assert.expect(1); let comments = [ - Ember.Object.create({ body: "Comment 1" }), - Ember.Object.create({ body: "Comment 2" }), - Ember.Object.create({ body: "Comment 3" }) + Object.create({ body: 'Comment 1' }), + Object.create({ body: 'Comment 2' }), + Object.create({ body: 'Comment 3' }) ]; this.set('comments', comments); diff --git a/tests/integration/components/task-details-test.js b/tests/integration/components/task-details-test.js index b61fb6afc..6a7ea961f 100644 --- a/tests/integration/components/task-details-test.js +++ b/tests/integration/components/task-details-test.js @@ -1,91 +1,93 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; -let mockMentionFetcher = Ember.Service.extend({ - fetchBodyWithMentions: Ember.RSVP.resolve, - prefetchBodyWithMentions: Ember.K -}); +const { + K, + Object, + RSVP +} = Ember; + +let mockMentionFetcher = { + fetchBodyWithMentions: RSVP.resolve, + prefetchBodyWithMentions: K +}; -let mockCurrentUser = Ember.Service.extend({ +let mockCurrentUser = { user: { id: 1 } -}); +}; -let mockStore = Ember.Service.extend({ +let mockStore = { query() { - return Ember.RSVP.resolve([]); + return RSVP.resolve([]); } -}); +}; -let mockTask = Ember.Object.create({ +let mockTask = Object.create({ title: 'A task', body: 'A body', containsCode: true, taskType: 'issue', user: { id: 1 }, save() { - return Ember.RSVP.resolve(); + return RSVP.resolve(); } }); -// let mockTaskWithMentions = Ember.Object.create({ +// let mockTaskWithMentions = Object.create({ // title: 'A task with mentions', // body: '

    Mentioning @user1 and @user2

    ', // save() { -// return Ember.RSVP.resolve(); +// return RSVP.resolve(); // }, // taskUserMentions: [ -// Ember.Object.create({ indices: [14, 19], username: 'user1', user: { id: 1 } }), -// Ember.Object.create({ indices: [25, 30], username: 'user2', user: { id: 2 } }) +// Object.create({ indices: [14, 19], username: 'user1', user: { id: 1 } }), +// Object.create({ indices: [25, 30], username: 'user2', user: { id: 2 } }) // ] // }); moduleForComponent('task-details', 'Integration | Component | task details', { integration: true, beforeEach() { - this.register('service:current-user', mockCurrentUser); - this.register('service:store', mockStore); + stubService(this, 'current-user', mockCurrentUser); + stubService(this, 'store', mockStore); } }); test('it renders', function(assert) { - this.register('service:mention-fetcher', mockMentionFetcher); + stubService(this, 'mention-fetcher', mockMentionFetcher); this.render(hbs`{{task-details}}`); assert.equal(this.$('.task-details').length, 1, 'The component\'s element is rendered'); }); - test('it renders all the ui elements properly bound', function(assert) { this.set('task', mockTask); - let mockMentionFetcher = Ember.Service.extend({ + stubService(this, 'mention-fetcher', { prefetchBodyWithMentions() { return 'A body'; } }); - this.register('service:mention-fetcher', mockMentionFetcher); - this.render(hbs`{{task-details task=task}}`); assert.equal(this.$('.task-details .comment-body').text().trim(), 'A body', 'Body is correctly bound and rendered'); assert.equal(this.$('.task-details .code-theme-selector').length, 1); }); -test('the task body is rendered as unescaped html', function (assert) { - let mockMentionFetcher = Ember.Service.extend({ +test('the task body is rendered as unescaped html', function(assert) { + stubService(this, 'mention-fetcher', { prefetchBodyWithMentions() { return 'A body with a strong element'; } }); - this.register('service:mention-fetcher', mockMentionFetcher); - this.set('task', mockTask); this.render(hbs`{{task-details task=task}}`); @@ -96,7 +98,7 @@ test('user can switch between view and edit mode for task body', function(assert assert.expect(3); this.set('task', mockTask); - this.register('service:mention-fetcher', mockMentionFetcher); + stubService(this, 'mention-fetcher', mockMentionFetcher); this.render(hbs`{{task-details task=task}}`); assert.equal(this.$('.task-body .edit').length, 1, 'The edit button is rendered'); @@ -108,6 +110,32 @@ test('user can switch between view and edit mode for task body', function(assert assert.equal(this.$('.task-body .edit').length, 1, 'The edit button is rendered'); }); +test('it saves', function(assert) { + assert.expect(2); + + this.set('task', mockTask); + stubService(this, 'mention-fetcher', { + fetchBodyWithMentions(task) { + return RSVP.resolve(task.body); + }, + prefetchBodyWithMentions() { + return 'A body'; + } + }); + + this.on('route-save', (task) => { + task.set('body', 'A new body'); + return RSVP.resolve(task); + }); + + this.render(hbs`{{task-details task=task saveTask=(action 'route-save')}}`); + assert.equal(this.$('.task-details .comment-body').text().trim(), 'A body', 'The original body is correct'); + + this.$('.task-body .edit').click(); + this.$('.task-body .editor-with-preview textarea').val('A new body').trigger('change'); + this.$('.task-body .save').click(); + assert.equal(this.$('.task-details .comment-body').text().trim(), 'A new body', 'The body is saved'); +}); // NOTE: Commented out due to comment user mentions being disabled until reimplemented in phoenix /* test('mentions are rendered on task body in read-only mode', function(assert) { diff --git a/tests/integration/components/task-filter-dropdown-test.js b/tests/integration/components/task-filter-dropdown-test.js index 845cb8cf9..3621e010a 100644 --- a/tests/integration/components/task-filter-dropdown-test.js +++ b/tests/integration/components/task-filter-dropdown-test.js @@ -2,29 +2,31 @@ import Ember from 'ember'; import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; +const { Object } = Ember; + moduleForComponent('task-filter-dropdown', 'Integration | Component | task filter dropdown', { integration: true }); let types = [ - Ember.Object.create({ - name: "Tasks", - param: "task", - slug: "tasks", - selected: true, - }), - Ember.Object.create({ - name: "Issues", - param: "issue", - slug: "issues", - selected: false, + Object.create({ + name: 'Tasks', + param: 'task', + slug: 'tasks', + selected: true }), - Ember.Object.create({ - name: "Ideas", - param: "idea", - slug: "ideas", - selected: false, + Object.create({ + name: 'Issues', + param: 'issue', + slug: 'issues', + selected: false }), + Object.create({ + name: 'Ideas', + param: 'idea', + slug: 'ideas', + selected: false + }) ]; test('it renders', function(assert) { @@ -36,7 +38,7 @@ test('it renders all required elements', function(assert) { this.set('selectedTypes', types); this.render(hbs`{{task-filter-dropdown field='type' selectedFilters=selectedTypes}}`); - let firstType = types[0]; + let [firstType] = types; assert.equal(this.$('.dropdown-header p').text(), 'Filter by type ×', 'Header text renders'); assert.equal(this.$('.dropdown-header a.close').length, 1, 'Close link renders'); @@ -52,7 +54,7 @@ test('it sends filterByType action with the right type when clicking a link', fu this.render(hbs`{{task-filter-dropdown selectedFilters=selectedTypes filterBy="filterByType"}}`); this.set('selectedTypes', types); - let firstType = types[0]; + let [firstType] = types; this.on('filterByType', function(type) { assert.equal(type, firstType); diff --git a/tests/integration/components/task-filter-type-test.js b/tests/integration/components/task-filter-type-test.js index 6ab779598..902611cc7 100644 --- a/tests/integration/components/task-filter-type-test.js +++ b/tests/integration/components/task-filter-type-test.js @@ -2,29 +2,31 @@ import Ember from 'ember'; import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; +const { Object } = Ember; + moduleForComponent('task-filter-type', 'Integration | Component | task filter type', { integration: true }); let types = [ - Ember.Object.create({ - name: "Tasks", - param: "task", - slug: "tasks", - selected: true, - }), - Ember.Object.create({ - name: "Issues", - param: "issue", - slug: "issues", - selected: false, + Object.create({ + name: 'Tasks', + param: 'task', + slug: 'tasks', + selected: true }), - Ember.Object.create({ - name: "Ideas", - param: "idea", - slug: "ideas", - selected: false, + Object.create({ + name: 'Issues', + param: 'issue', + slug: 'issues', + selected: false }), + Object.create({ + name: 'Ideas', + param: 'idea', + slug: 'ideas', + selected: false + }) ]; test('it renders', function(assert) { @@ -46,7 +48,7 @@ test('it sends filterByType action with the right type when clicking a link', fu this.render(hbs`{{task-filter-type selectedTypes=selectedTypes filterByType="filterByType"}}`); this.set('selectedTypes', types); - let firstType = types[0]; + let [firstType] = types; this.on('filterByType', function(type) { assert.equal(type, firstType); diff --git a/tests/integration/components/task-header-test.js b/tests/integration/components/task-header-test.js index 5585e5cba..7c613ec85 100644 --- a/tests/integration/components/task-header-test.js +++ b/tests/integration/components/task-header-test.js @@ -2,13 +2,18 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; -let mockTask = Ember.Object.create({ +const { + Object, + RSVP +} = Ember; + +let mockTask = Object.create({ title: 'A task', body: 'A body', number: 12, taskType: 'issue', save() { - return Ember.RSVP.resolve(); + return RSVP.resolve(); } }); diff --git a/tests/integration/components/task-item-test.js b/tests/integration/components/task-item-test.js index 7b7257bee..82cfd6709 100644 --- a/tests/integration/components/task-item-test.js +++ b/tests/integration/components/task-item-test.js @@ -13,7 +13,7 @@ test('it renders', function(assert) { test('it renders all required elements', function(assert) { assert.expect(3); - var task = { + let task = { title: 'Clean the house', taskType: 'task' }; @@ -26,7 +26,6 @@ test('it renders all required elements', function(assert) { assert.equal(this.$('.task-icon').length, 1, 'The task icon renders'); }); - test('it renders with correct task-type class', function(assert) { this.set('task', { taskType: 'task' }); this.render(hbs`{{task-item task=task}}`); diff --git a/tests/integration/components/task-new-form-test.js b/tests/integration/components/task-new-form-test.js index d98eac391..a4c05d59d 100644 --- a/tests/integration/components/task-new-form-test.js +++ b/tests/integration/components/task-new-form-test.js @@ -1,17 +1,17 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +const { Object } = Ember; moduleForComponent('task-new-form', 'Integration | Component | task new form', { - integration: true, - beforeEach() { - this.register('service:credentials', Ember.Service.extend({ currentUserMembership: null })); - } + integration: true }); test('it renders', function(assert) { assert.expect(1); - + stubService(this, 'credentials', { currentUserMembership: null }); this.render(hbs`{{task-new-form}}`); assert.equal(this.$('.task-new-form').length, 1, 'The component\'s element renders'); @@ -19,6 +19,7 @@ test('it renders', function(assert) { test('it renders proper ui elements, properly bound', function(assert) { assert.expect(8); + stubService(this, 'credentials', { currentUserMembership: null }); let task = { title: 'A task', @@ -26,7 +27,7 @@ test('it renders proper ui elements, properly bound', function(assert) { taskType: 'idea' }; - let placeholder = "Test placeholder"; + let placeholder = 'Test placeholder'; this.set('task', task); this.set('placeholder', placeholder); @@ -44,8 +45,9 @@ test('it renders proper ui elements, properly bound', function(assert) { test('it triggers an action when the task is saved', function(assert) { assert.expect(2); + stubService(this, 'credentials', { currentUserMembership: null }); - let task = Ember.Object.create({ id: 1 }); + let task = Object.create({ id: 1 }); this.set('task', task); this.on('saveTask', (task) => { @@ -61,9 +63,9 @@ test('it triggers an action when the task is saved', function(assert) { test('it renders only idea and issue task type options if user is not at least a contributor to the organization', function(assert) { assert.expect(3); - this.register('service:credentials', Ember.Service.extend({ + stubService(this, 'credentials', { currentUserMembership: { isContributor: false, isAdmin: false, isOwner: false } - })); + }); this.render(hbs`{{task-new-form task=task placeholder=placeholder}}`); @@ -75,9 +77,9 @@ test('it renders only idea and issue task type options if user is not at least a test('it renders all task type options if user is at least contributor', function(assert) { assert.expect(3); - this.register('service:credentials', Ember.Service.extend({ + stubService(this, 'credentials', { currentUserMembership: { isContributor: true } - })); + }); this.render(hbs`{{task-new-form task=task placeholder=placeholder}}`); diff --git a/tests/integration/components/task-status-button-test.js b/tests/integration/components/task-status-button-test.js index 458a199ee..e629a14f1 100644 --- a/tests/integration/components/task-status-button-test.js +++ b/tests/integration/components/task-status-button-test.js @@ -2,6 +2,8 @@ import Ember from 'ember'; import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; +const { Object } = Ember; + moduleForComponent('task-status-button', 'Integration | Component | task status button', { integration: true }); @@ -13,11 +15,10 @@ test('it renders', function(assert) { assert.equal(this.$('.task-status-button').length, 1, 'The element renders'); }); - test('when task is open, it renders the button to close it', function(assert) { assert.expect(4); - let mockTask = Ember.Object.create({ + let mockTask = Object.create({ status: 'open', set(property, value) { assert.equal(property, 'status', 'Status is set to closed'); @@ -38,7 +39,7 @@ test('when task is open, it renders the button to close it', function(assert) { test('when task is closed, it renders the button to open it', function(assert) { assert.expect(4); - let mockTask = Ember.Object.create({ + let mockTask = Object.create({ status: 'closed', set(property, value) { assert.equal(property, 'status', 'Status is set to open'); diff --git a/tests/integration/components/task-title-test.js b/tests/integration/components/task-title-test.js index e1a7897fb..ee2cdad8e 100644 --- a/tests/integration/components/task-title-test.js +++ b/tests/integration/components/task-title-test.js @@ -1,37 +1,41 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; -let mockCurrentUser = Ember.Service.extend({ +const { + Object, + RSVP +} = Ember; + +let mockCurrentUser = { user: { id: 1 } -}); +}; -let mockDifferentUser = Ember.Service.extend({ +let mockDifferentUser = { user: { id: 2 } -}); +}; -let mockTask = Ember.Object.create({ +let mockTask = Object.create({ title: 'Original title', body: 'A body', number: 12, taskType: 'issue', user: { - id: 1, + id: 1 }, save() { this.set('title', this.get('title')); - return Ember.RSVP.resolve(); + return RSVP.resolve(); } }); moduleForComponent('task-title', 'Integration | Component | task title', { - integration: true, - beforeEach() { - } + integration: true }); test('it renders', function(assert) { @@ -41,18 +45,17 @@ test('it renders', function(assert) { }); test('it is not editable if not the right user', function(assert) { - this.register('service:current-user', mockDifferentUser); + stubService(this, 'current-user', mockDifferentUser); assert.expect(1); this.render(hbs`{{task-title}}`); assert.equal(this.$('.task-title .edit').length, 0); }); - test('it switches between edit and view mode', function(assert) { assert.expect(8); - this.register('service:current-user', mockCurrentUser); + stubService(this, 'current-user', mockCurrentUser); this.set('task', mockTask); this.render(hbs`{{task-title task=task}}`); @@ -72,10 +75,13 @@ test('it switches between edit and view mode', function(assert) { test('it saves', function(assert) { assert.expect(2); - this.register('service:current-user', mockCurrentUser); + stubService(this, 'current-user', mockCurrentUser); this.set('task', mockTask); - this.render(hbs`{{task-title task=task}}`); + this.on('applyEdit', () => { + return RSVP.resolve(); + }); + this.render(hbs`{{task-title task=task saveTask=(action "applyEdit")}}`); assert.equal(this.$('.task-title .title').text().trim(), 'Original title #12', 'The original title is right'); @@ -85,14 +91,3 @@ test('it saves', function(assert) { assert.equal(this.$('.task-title .title').text().trim(), 'Edited title #12', 'The tile title is saved'); }); - -// test('it resets the input element when editing is cancelled and then restarted', function(assert) { -// assert.expect(1); -// this.set('task', mockTask); -// this.render(hbs`{{task-title task=task}}`); -// this.$('.task-title .edit').click(); -// this.$('.task-title input[name=title]').val('Edited title').trigger('change'); -// this.$('.task-title .cancel').click(); -// this.$('.task-title .edit').click(); -// assert.equal(this.$('.task-title input[name=title]').val(), 'Original title', 'Input is back to the original value'); -// }); diff --git a/tests/integration/components/user-dropdown-test.js b/tests/integration/components/user-dropdown-test.js index 312fad9d9..22dd16c75 100644 --- a/tests/integration/components/user-dropdown-test.js +++ b/tests/integration/components/user-dropdown-test.js @@ -2,20 +2,25 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +const { + computed, + Object +} = Ember; + moduleForComponent('user-dropdown', 'Integration | Component | user dropdown', { integration: true }); -const stubUser = Ember.Object.extend({ +const stubUser = Object.extend({ id: 1, username: 'tester', photoThumbUrl: '/assets/images/twitter.png', - atUsername: Ember.computed('username', function() { + atUsername: computed('username', function() { return `@${this.get('username')}`; }), - twitterUrl: Ember.computed('twitter', function() { + twitterUrl: computed('twitter', function() { return `https://twitter.com/${this.get('twitter')}`; }) }).create(); diff --git a/tests/integration/components/user-menu-test.js b/tests/integration/components/user-menu-test.js index 733da9026..e1a0aa1a2 100644 --- a/tests/integration/components/user-menu-test.js +++ b/tests/integration/components/user-menu-test.js @@ -2,22 +2,27 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; -const stubUser = Ember.Object.extend({ +const { + computed, + Object +} = Ember; + +const stubUser = Object.extend({ id: 1, username: 'tester', photoThumbUrl: '/assets/images/twitter.png', - atUsername: Ember.computed('username', function() { + atUsername: computed('username', function() { return `@${this.get('username')}`; }), - twitterUrl: Ember.computed('twitter', function() { + twitterUrl: computed('twitter', function() { return `https://twitter.com/${this.get('twitter')}`; }) }).create(); moduleForComponent('user-menu', 'Integration | Component | user menu', { - integration: true, + integration: true }); test('it renders properly', function(assert) { diff --git a/tests/integration/components/user-organizations-list-test.js b/tests/integration/components/user-organizations-list-test.js index 26273d374..71db48fb5 100644 --- a/tests/integration/components/user-organizations-list-test.js +++ b/tests/integration/components/user-organizations-list-test.js @@ -19,14 +19,14 @@ test('with no organizations renders all required elements', function(assert) { this.set('organizations', []); this.set('user', { - username: "JoshSmith" + username: 'JoshSmith' }); this.render(hbs`{{user-organizations-list user=user organizations=organizations}}`); assert.equal(this.$('.user-organizations-list').length, 1, 'Component\'s element is rendered'); - assert.equal(this.$('h2').text(), "Organizations", 'The header renders'); - assert.equal(this.$('.empty-state strong').text(), "JoshSmith", 'Component\'s element is rendered'); + assert.equal(this.$('h2').text(), 'Organizations', 'The header renders'); + assert.equal(this.$('.empty-state strong').text(), 'JoshSmith', 'Component\'s element is rendered'); }); test('with several organizations renders all required elements', function(assert) { @@ -39,20 +39,20 @@ test('with several organizations renders all required elements', function(assert name: `Organization ${i}`, slug: `organization_${i}`, description: `Organization ${i} description`, - iconThumbUrl: `/icon_${i}.png`, + iconThumbUrl: `/icon_${i}.png` }); } this.set('organizations', mockOrganizations); this.set('user', { - username: "JoshSmith" + username: 'JoshSmith' }); this.render(hbs`{{user-organizations-list user=user organizations=organizations}}`); assert.equal(this.$('.user-organizations-list').length, 1, 'Component\'s element is rendered'); - assert.equal(this.$('h2').text(), "Organizations", 'The header renders'); + assert.equal(this.$('h2').text(), 'Organizations', 'The header renders'); assert.equal(this.$('li').length, 3, 'All organization items render'); assert.equal(this.$('li:first h3').text().trim(), 'Organization 1', 'The organization header renders'); assert.equal(this.$('li:first p').text().trim(), 'Organization 1 description', 'The organization description renders'); diff --git a/tests/integration/components/user-settings-form-test.js b/tests/integration/components/user-settings-form-test.js index d6e4b88f8..07497ad43 100644 --- a/tests/integration/components/user-settings-form-test.js +++ b/tests/integration/components/user-settings-form-test.js @@ -1,6 +1,9 @@ import Ember from 'ember'; import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +const { RSVP } = Ember; moduleForComponent('user-settings-form', 'Integration | Component | user settings form', { integration: true @@ -19,7 +22,7 @@ let user = { lastName: 'User', twitter: '@testuser', website: 'example.com', - biography: 'A test user', + biography: 'A test user' }; test('it renders form elements properly', function(assert) { @@ -43,20 +46,17 @@ test('it calls save on user when save button is clicked', function(assert) { user.save = function() { assert.ok(true, 'Save method was called on user'); - return Ember.RSVP.resolve(); + return RSVP.resolve(); }; this.set('user', user); - const flashServiceStub = Ember.Service.extend({ + stubService(this, 'flash-messages', { success() { assert.ok(true, 'Flash message service was called'); } }); - this.register('service:flash-messages', flashServiceStub); - - this.render(hbs`{{user-settings-form user=user}}`); this.$('.save').click(); diff --git a/tests/integration/components/user-sidebar-test.js b/tests/integration/components/user-sidebar-test.js index 5c1929b50..764de461f 100644 --- a/tests/integration/components/user-sidebar-test.js +++ b/tests/integration/components/user-sidebar-test.js @@ -6,6 +6,9 @@ moduleForComponent('user-sidebar', 'Integration | Component | user sidebar', { integration: true, setup() { startMirage(this.container); + }, + afterEach() { + server.shutdown(); } }); @@ -31,7 +34,7 @@ function mockUser() { website: 'https://codecorps.org', // TODO: remove this because it's a computed property and // Mirage doesn't do a great job with that - twitterUrl: 'https://twitter.com/joshsmith', + twitterUrl: 'https://twitter.com/joshsmith' }; server.schema.users.create(user); return user; @@ -46,12 +49,12 @@ test('it renders all required elements', function(assert) { this.render(hbs`{{user-sidebar user=user}}`); assert.equal(this.$('.user-sidebar').length, 1, 'Component\'s element is rendered'); - assert.equal(this.$('h2 .name').text(), "Josh Smith", 'Their name renders'); - assert.equal(this.$('h2 .username').text(), "JoshSmith", 'Their username renders'); - assert.equal(this.$('li.twitter').text().trim(), "@joshsmith", 'Their twitter handler renders'); - assert.equal(this.$('li.twitter a').attr('href'), "https://twitter.com/joshsmith", 'The twitter link renders'); - assert.equal(this.$('li.website').text().trim(), "https://codecorps.org", 'Their website renders'); - assert.equal(this.$('li.website a').attr('href'), "https://codecorps.org", 'The website link renders'); + assert.equal(this.$('h2 .name').text(), 'Josh Smith', 'Their name renders'); + assert.equal(this.$('h2 .username').text(), 'JoshSmith', 'Their username renders'); + assert.equal(this.$('li.twitter').text().trim(), '@joshsmith', 'Their twitter handler renders'); + assert.equal(this.$('li.twitter a').attr('href'), 'https://twitter.com/joshsmith', 'The twitter link renders'); + assert.equal(this.$('li.website').text().trim(), 'https://codecorps.org', 'Their website renders'); + assert.equal(this.$('li.website a').attr('href'), 'https://codecorps.org', 'The website link renders'); }); test('it does not show some details if blank', function(assert) { @@ -76,5 +79,5 @@ test('it sets the name to username if name is blank', function(assert) { this.render(hbs`{{user-sidebar user=user}}`); - assert.equal(this.$('h2 .name').text(), "joshsmith"); + assert.equal(this.$('h2 .name').text(), 'joshsmith'); }); diff --git a/tests/integration/components/user-skills-input-item-test.js b/tests/integration/components/user-skills-input-item-test.js index 96ee6815a..a101b7034 100644 --- a/tests/integration/components/user-skills-input-item-test.js +++ b/tests/integration/components/user-skills-input-item-test.js @@ -1,28 +1,29 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; -let userSkillsService = Ember.Service.extend({ - findUserSkill(queriedSkill) { - if (queriedSkill === skill) { - return skill; - } - } -}); +const { Object } = Ember; -let skill = Ember.Object.create({ +let skill = Object.create({ selected: true, - title: "Ruby on Rails" + title: 'Ruby on Rails' }); moduleForComponent('user-skills-input-item', 'Integration | Component | user skills input item', { integration: true, beforeEach() { - this.register('service:user-skills', userSkillsService); + stubService(this, 'user-skills', { + findUserSkill(queriedSkill) { + if (queriedSkill === skill) { + return skill; + } + } + }); } }); -let query = "ru on r"; +let query = 'ru on r'; test('it renders as selected with the highlighted string', function(assert) { this.set('skill', skill); diff --git a/tests/integration/components/user-skills-input-test.js b/tests/integration/components/user-skills-input-test.js index 87de7bd41..350e32a66 100644 --- a/tests/integration/components/user-skills-input-test.js +++ b/tests/integration/components/user-skills-input-test.js @@ -2,30 +2,37 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; import jQuery from 'jquery'; - -let mockStore = Ember.Service.extend({ - query () { - return Ember.RSVP.resolve([ - Ember.Object.create({ title: "Ruby" }), - Ember.Object.create({ title: "Ruby on Rails" }), +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +const { + Object, + K, + RSVP +} = Ember; + +let mockStore = { + query() { + return RSVP.resolve([ + Object.create({ title: 'Ruby' }), + Object.create({ title: 'Ruby on Rails' }) ]); } -}); +}; -let mockUserSkillsService = Ember.Service.extend({ +let mockUserSkillsService = { findUserSkill() { - return Ember.K; + return K; }, removeSkill() { - return Ember.K; - }, -}); + return K; + } +}; moduleForComponent('user-skills-input', 'Integration | Component | user skills input', { integration: true, beforeEach() { - this.register('service:store', mockStore); - this.register('service:user-skills', mockUserSkillsService); + stubService(this, 'store', mockStore); + stubService(this, 'user-skills', mockUserSkillsService); } }); @@ -187,13 +194,10 @@ test('it selects the skill when clicking it', function(assert) { test('it does nothing when there are no results', function(assert) { assert.expect(1); - let emptyStore = Ember.Service.extend({ - query () { - return Ember.RSVP.resolve([]); - } - }); - - this.register('service:store', emptyStore); + let query = function() { + return RSVP.resolve([]); + }; + this.set('store.query', query); this.render(hbs`{{user-skills-input query=query}}`); diff --git a/tests/pages/components/comment-item.js b/tests/pages/components/comment-item.js index e995a52ba..ade7a918e 100644 --- a/tests/pages/components/comment-item.js +++ b/tests/pages/components/comment-item.js @@ -1,7 +1,7 @@ import { clickable, collection, - fillable, + fillable } from 'ember-cli-page-object'; export default { @@ -27,7 +27,7 @@ export default { clickPreview: clickable('.preview'), - markdown: fillable('textarea[name=markdown]'), + markdown: fillable('textarea[name=markdown]') }, errors: collection({ diff --git a/tests/pages/components/create-comment-form.js b/tests/pages/components/create-comment-form.js index 60a494c98..12be81c01 100644 --- a/tests/pages/components/create-comment-form.js +++ b/tests/pages/components/create-comment-form.js @@ -1,7 +1,7 @@ import { clickable, collection, - fillable, + fillable } from 'ember-cli-page-object'; export default { @@ -18,7 +18,7 @@ export default { clickPreview: clickable('.preview'), - markdown: fillable('textarea[name=markdown]'), + markdown: fillable('textarea[name=markdown]') }, errors: collection({ diff --git a/tests/pages/components/editor-with-preview.js b/tests/pages/components/editor-with-preview.js index 752ad8321..c36c6cfc1 100644 --- a/tests/pages/components/editor-with-preview.js +++ b/tests/pages/components/editor-with-preview.js @@ -2,5 +2,5 @@ import { } from 'ember-cli-page-object'; export default { - scope: '.editor-with-preview', + scope: '.editor-with-preview' }; diff --git a/tests/pages/components/error-wrapper.js b/tests/pages/components/error-wrapper.js index a324ebcce..e7f35bfa7 100644 --- a/tests/pages/components/error-wrapper.js +++ b/tests/pages/components/error-wrapper.js @@ -1,6 +1,6 @@ import { clickable, - text, + text } from 'ember-cli-page-object'; export default { @@ -10,6 +10,6 @@ export default { title: { scope: 'h1', - text: text(), - }, + text: text() + } }; diff --git a/tests/pages/components/login-form.js b/tests/pages/components/login-form.js index c2c2541b0..07e30c5a0 100644 --- a/tests/pages/components/login-form.js +++ b/tests/pages/components/login-form.js @@ -5,14 +5,14 @@ import { } from 'ember-cli-page-object'; export default { - scope: '.login-form', + scope: '.login-form', username: fillable('#identification'), password: fillable('#password'), - submit: clickable('#login'), + submit: clickable('#login'), - errors: collection({ - itemScope: 'p.error', + errors: collection({ + itemScope: 'p.error' }), loginSuccessfully() { diff --git a/tests/pages/components/navigation-menu.js b/tests/pages/components/navigation-menu.js index e6fefed7a..6f564eed3 100644 --- a/tests/pages/components/navigation-menu.js +++ b/tests/pages/components/navigation-menu.js @@ -27,6 +27,6 @@ export default { }, logOut: { scope: 'a.logout' - }, + } } }; diff --git a/tests/pages/components/organization-profile.js b/tests/pages/components/organization-profile.js index fa6146169..7e52d08f8 100644 --- a/tests/pages/components/organization-profile.js +++ b/tests/pages/components/organization-profile.js @@ -1,3 +1,3 @@ export default { - scope: '.organization-profile', + scope: '.organization-profile' }; diff --git a/tests/pages/components/pager-control.js b/tests/pages/components/pager-control.js index cce34a3b0..41548d28b 100644 --- a/tests/pages/components/pager-control.js +++ b/tests/pages/components/pager-control.js @@ -1,6 +1,6 @@ import { attribute, - collection, + collection } from 'ember-cli-page-object'; export default { @@ -14,12 +14,12 @@ export default { pages: collection({ itemScope: '.page', item: { - href: attribute('href'), + href: attribute('href') } }), previousPage: { scope: '.previous-page', href: attribute('href') - }, + } }; diff --git a/tests/pages/components/project-card.js b/tests/pages/components/project-card.js index b12d78c62..e94354c3a 100644 --- a/tests/pages/components/project-card.js +++ b/tests/pages/components/project-card.js @@ -11,6 +11,6 @@ export default { members: collection({ scope: '.project-card-members', - itemScope: 'li.member', - }), + itemScope: 'li.member' + }) }; diff --git a/tests/pages/components/project-details.js b/tests/pages/components/project-details.js index 36dd17317..25b1e6fba 100644 --- a/tests/pages/components/project-details.js +++ b/tests/pages/components/project-details.js @@ -7,11 +7,11 @@ export default { joinProjectButton: { scope: '.join-project button', - href: attribute('href'), + href: attribute('href') }, signUpLink: { scope: '.join-project a', - href: attribute('href'), + href: attribute('href') } }; diff --git a/tests/pages/components/project-list.js b/tests/pages/components/project-list.js index 2be76dde2..83058ef9b 100644 --- a/tests/pages/components/project-list.js +++ b/tests/pages/components/project-list.js @@ -1,6 +1,6 @@ import { attribute, - collection, + collection } from 'ember-cli-page-object'; export default { @@ -9,7 +9,7 @@ export default { items: collection({ itemScope: '.project-item', item: { - href: attribute('href', 'a:eq(0)'), + href: attribute('href', 'a:eq(0)') } }) }; diff --git a/tests/pages/components/project-long-description.js b/tests/pages/components/project-long-description.js index 838fc6c7a..928ddc82d 100644 --- a/tests/pages/components/project-long-description.js +++ b/tests/pages/components/project-long-description.js @@ -2,7 +2,7 @@ import { clickable, fillable, hasClass, - text, + text } from 'ember-cli-page-object'; export default { @@ -14,7 +14,7 @@ export default { textarea: fillable('textarea'), editButton: { - scope: 'button[name=edit]', + scope: 'button[name=edit]' }, longDescription: { @@ -25,7 +25,7 @@ export default { paragraph: { scope: 'p', - text: text(), + text: text() } - }, + } }; diff --git a/tests/pages/components/project-settings-form.js b/tests/pages/components/project-settings-form.js index bdd532e3a..206d212c5 100644 --- a/tests/pages/components/project-settings-form.js +++ b/tests/pages/components/project-settings-form.js @@ -1,7 +1,7 @@ import { clickable, fillable, - findElement, + findElement } from 'ember-cli-page-object'; import fillInFileInput from '../../helpers/fill-in-file-input'; @@ -19,13 +19,13 @@ export default { scope: '.image-drop', dropFile(content) { - fillInFileInput(`${this.scope} input`, { name: 'file.png', content: content }); + fillInFileInput(`${this.scope} input`, { name: 'file.png', content }); }, backgroundImageData() { let $el = findElement(this); let backgroundImageData = $el.css('background-image'); return removeDoubleQuotes(backgroundImageData); - }, - }, + } + } }; diff --git a/tests/pages/components/project-task-list.js b/tests/pages/components/project-task-list.js index 117ed1dd9..1099130f3 100644 --- a/tests/pages/components/project-task-list.js +++ b/tests/pages/components/project-task-list.js @@ -1,6 +1,6 @@ import { attribute, - collection, + collection } from 'ember-cli-page-object'; export default { @@ -14,8 +14,8 @@ export default { scope: '.task-item', itemScope: 'a', item: { - href: attribute('href'), - }, + href: attribute('href') + } }), tasks: collection({ diff --git a/tests/pages/components/user-details.js b/tests/pages/components/user-details.js index 39cf8735a..4739bf09e 100644 --- a/tests/pages/components/user-details.js +++ b/tests/pages/components/user-details.js @@ -1,6 +1,6 @@ import { attribute, - text, + text } from 'ember-cli-page-object'; export default { @@ -12,7 +12,7 @@ export default { link: { scope: 'a', href: attribute('href'), - text: text(), + text: text() } }, website: { @@ -21,7 +21,7 @@ export default { link: { scope: 'a', href: attribute('href'), - text: text(), + text: text() } - }, + } }; diff --git a/tests/pages/components/user-settings-form.js b/tests/pages/components/user-settings-form.js index 3abd1b2a7..bac7c1186 100644 --- a/tests/pages/components/user-settings-form.js +++ b/tests/pages/components/user-settings-form.js @@ -1,7 +1,7 @@ import { clickable, fillable, - findElement, + findElement } from 'ember-cli-page-object'; import fillInFileInput from '../../helpers/fill-in-file-input'; @@ -22,13 +22,13 @@ export default { scope: '.image-drop', dropFile(content) { - fillInFileInput(`${this.scope} input`, { name: 'file.png', content: content }); + fillInFileInput(`${this.scope} input`, { name: 'file.png', content }); }, backgroundImageData() { let $el = findElement(this); let backgroundImageData = $el.css('background-image'); return removeDoubleQuotes(backgroundImageData); - }, - }, + } + } }; diff --git a/tests/pages/login.js b/tests/pages/login.js index ae003592d..61f044fd4 100644 --- a/tests/pages/login.js +++ b/tests/pages/login.js @@ -1,6 +1,6 @@ import { create, - visitable, + visitable } from 'ember-cli-page-object'; import form from './components/login-form'; import navMenu from './components/navigation-menu'; @@ -9,5 +9,5 @@ export default create({ visit: visitable('/login'), form, - navMenu, + navMenu }); diff --git a/tests/pages/onboarding.js b/tests/pages/onboarding.js index 44f9c4dc5..025fe3907 100644 --- a/tests/pages/onboarding.js +++ b/tests/pages/onboarding.js @@ -7,7 +7,7 @@ import { hasClass, text, triggerable, - visitable, + visitable } from 'ember-cli-page-object'; import userSkillsInput from './components/user-skills-input'; import navMenu from './components/navigation-menu'; @@ -24,7 +24,7 @@ export default create({ lastNameEnter: triggerable('keyup', '[name="lastName"]', { eventProperties: { keyCode: 13 } }), clickCategoryItem: clickable('.category-item button'), footer: { - scope: '.site-footer', + scope: '.site-footer' }, startButton: { diff --git a/tests/pages/project/settings/profile.js b/tests/pages/project/settings/profile.js index 8ddc9fac9..a5caec555 100644 --- a/tests/pages/project/settings/profile.js +++ b/tests/pages/project/settings/profile.js @@ -1,7 +1,7 @@ import { create, text, - visitable, + visitable } from 'ember-cli-page-object'; import projectSettingsForm from '../../components/project-settings-form'; @@ -10,8 +10,8 @@ export default create({ successAlert: { scope: '.alert-success', - message: text('p'), + message: text('p') }, - projectSettingsForm, + projectSettingsForm }); diff --git a/tests/pages/projects.js b/tests/pages/projects.js index 20c23987f..f6ebebd5c 100644 --- a/tests/pages/projects.js +++ b/tests/pages/projects.js @@ -7,5 +7,5 @@ import projectCard from './components/project-card'; export default create({ visit: visitable('/projects'), - projectCard, + projectCard }); diff --git a/tests/pages/settings-profile.js b/tests/pages/settings-profile.js index ca180527a..a6fa50408 100644 --- a/tests/pages/settings-profile.js +++ b/tests/pages/settings-profile.js @@ -1,7 +1,7 @@ import { create, text, - visitable, + visitable } from 'ember-cli-page-object'; import userSettingsForm from './components/user-settings-form'; @@ -10,8 +10,8 @@ export default create({ successAlert: { scope: '.alert-success', - message: text('p'), + message: text('p') }, - userSettingsForm, + userSettingsForm }); diff --git a/tests/pages/user.js b/tests/pages/user.js index 4e901017f..2f93884ad 100644 --- a/tests/pages/user.js +++ b/tests/pages/user.js @@ -3,7 +3,7 @@ import { clickable, collection, create, - visitable, + visitable } from 'ember-cli-page-object'; import userDetails from './components/user-details'; @@ -15,9 +15,9 @@ export default create({ itemScope: 'h3 a', item: { click: clickable(), - href: attribute('href'), - }, + href: attribute('href') + } }), - userDetails, + userDetails }); diff --git a/tests/unit/abilities/organization-test.js b/tests/unit/abilities/organization-test.js index a097bdc51..e210c68dd 100644 --- a/tests/unit/abilities/organization-test.js +++ b/tests/unit/abilities/organization-test.js @@ -7,6 +7,6 @@ moduleFor('ability:organization', 'Unit | Ability | organization', { // Replace this with your real tests. test('it exists', function(assert) { - var ability = this.subject(); + let ability = this.subject(); assert.ok(ability); }); diff --git a/tests/unit/abilities/task-test.js b/tests/unit/abilities/task-test.js index b5e87ecc3..3654ecadb 100644 --- a/tests/unit/abilities/task-test.js +++ b/tests/unit/abilities/task-test.js @@ -1,39 +1,40 @@ import Ember from 'ember'; import { moduleFor, test } from 'ember-qunit'; -moduleFor('ability:task', 'Unit | Ability | task', { -}); +const { Object } = Ember; + +moduleFor('ability:task', 'Unit | Ability | task', { }); test('it can edit task if user is the task author', function(assert) { let ability = this.subject({ - model: Ember.Object.create({ user: Ember.Object.create({ id: 1 }) }), - currentUser: Ember.Object.create({ user: Ember.Object.create({ id: 1 }) }) + model: Object.create({ user: Object.create({ id: 1 }) }), + currentUser: Object.create({ user: Object.create({ id: 1 }) }) }); assert.ok(ability.get('canEdit')); }); test('it cannot edit task if user is not the task author', function(assert) { let ability = this.subject({ - model: Ember.Object.create({ user: Ember.Object.create({ id: 1 }) }), - currentUser: Ember.Object.create({ user: Ember.Object.create({ id: 2 }) }) + model: Object.create({ user: Object.create({ id: 1 }) }), + currentUser: Object.create({ user: Object.create({ id: 2 }) }) }); assert.notOk(ability.get('canEdit')); }); test('it can edit task if user is at least admin in organization', function(assert) { let ability = this.subject({ - credentials: Ember.Object.create({ - currentUserMembership: Ember.Object.create({ isAdmin: true }) - }), + credentials: Object.create({ + currentUserMembership: Object.create({ isAdmin: true }) + }) }); assert.ok(ability.get('canEdit')); }); test('it cannot edit task if user is not at least admin in organization', function(assert) { let ability = this.subject({ - credentials: Ember.Object.create({ - currentUserMembership: Ember.Object.create({ isAdmin: false }), - }), + credentials: Object.create({ + currentUserMembership: Object.create({ isAdmin: false }) + }) }); assert.notOk(ability.get('canEdit')); }); diff --git a/tests/unit/helpers/highlight-substrings-test.js b/tests/unit/helpers/highlight-substrings-test.js index 506dd3a7c..6fd8ece6f 100644 --- a/tests/unit/helpers/highlight-substrings-test.js +++ b/tests/unit/helpers/highlight-substrings-test.js @@ -6,8 +6,8 @@ module('Unit | Helper | highlight substrings'); test('it replaces searched strings with strong tags', function(assert) { assert.expect(1); - let string = "Apache HTTP Server"; - let query = "ht tt tp"; + let string = 'Apache HTTP Server'; + let query = 'ht tt tp'; let expectedOutput = 'Apache HTTP Server'; assert.equal(highlightSubstrings([string, query]), expectedOutput); diff --git a/tests/unit/mixins/can-animate-test.js b/tests/unit/mixins/can-animate-test.js index 9ab81b691..b9f4c9242 100644 --- a/tests/unit/mixins/can-animate-test.js +++ b/tests/unit/mixins/can-animate-test.js @@ -2,11 +2,13 @@ import Ember from 'ember'; import CanAnimateMixin from 'code-corps-ember/mixins/can-animate'; import { module, test } from 'qunit'; +const { Object } = Ember; + module('Unit | Mixin | can animate'); // Replace this with your real tests. test('it works', function(assert) { - let CanAnimateObject = Ember.Object.extend(CanAnimateMixin); + let CanAnimateObject = Object.extend(CanAnimateMixin); let subject = CanAnimateObject.create(); assert.ok(subject); }); diff --git a/tests/unit/mixins/contains-code-test.js b/tests/unit/mixins/contains-code-test.js new file mode 100644 index 000000000..2e3c32fa9 --- /dev/null +++ b/tests/unit/mixins/contains-code-test.js @@ -0,0 +1,44 @@ +import Ember from 'ember'; +import Model from 'ember-data/model'; +import attr from 'ember-data/attr'; +import ContainsCodeMixin from 'code-corps-ember/mixins/contains-code'; +import { moduleFor, test } from 'ember-qunit'; + +const { + getOwner, + run +} = Ember; + +moduleFor('mixin:contains-code', 'Unit | Mixin | contains code mixin', { + subject(record) { + let ContainsCodeMixinObject = Model.extend(ContainsCodeMixin, { + body: attr('string') + }); + this.register('model:contains-code-mixin-object', ContainsCodeMixinObject); + return run(() => { + let store = getOwner(this).lookup('service:store'); + return store.createRecord('contains-code-mixin-object', record || {}); + }); + } +}); + +test('it works', function(assert) { + let subject = this.subject(); + assert.ok(subject); +}); + +test('it returns true "code" tag is present', function(assert) { + assert.expect(1); + + let model = this.subject({ body: 'Hello, world!' }); + + assert.equal(model.get('containsCode'), true); +}); + +test('it returns false if "code" tag is absent', function(assert) { + assert.expect(1); + + let model = this.subject({ body: 'Hello, world!' }); + + assert.equal(model.get('containsCode'), false); +}); diff --git a/tests/unit/mixins/onboarding-controller-test.js b/tests/unit/mixins/onboarding-controller-test.js index e02d2d647..d0fb17a23 100644 --- a/tests/unit/mixins/onboarding-controller-test.js +++ b/tests/unit/mixins/onboarding-controller-test.js @@ -2,11 +2,13 @@ import Ember from 'ember'; import OnboardingControllerMixin from 'code-corps-ember/mixins/onboarding-controller'; import { module, test } from 'qunit'; +const { Object } = Ember; + module('Unit | Mixin | onboarding controller'); // Replace this with your real tests. test('it works', function(assert) { - let OnboardingControllerObject = Ember.Object.extend(OnboardingControllerMixin); + let OnboardingControllerObject = Object.extend(OnboardingControllerMixin); let subject = OnboardingControllerObject.create(); assert.ok(subject); }); diff --git a/tests/unit/mixins/onboarding-route-test.js b/tests/unit/mixins/onboarding-route-test.js index 5f2c2832e..2b15c6ce5 100644 --- a/tests/unit/mixins/onboarding-route-test.js +++ b/tests/unit/mixins/onboarding-route-test.js @@ -2,11 +2,13 @@ import Ember from 'ember'; import OnboardingRouteMixin from 'code-corps-ember/mixins/onboarding-route'; import { module, test } from 'qunit'; +const { Object } = Ember; + module('Unit | Mixin | onboarding route'); // Replace this with your real tests. test('it works', function(assert) { - let OnboardingRouteObject = Ember.Object.extend(OnboardingRouteMixin); + let OnboardingRouteObject = Object.extend(OnboardingRouteMixin); let subject = OnboardingRouteObject.create(); assert.ok(subject); }); diff --git a/tests/unit/models/category-test.js b/tests/unit/models/category-test.js index 76fcf7bf4..9e148a324 100644 --- a/tests/unit/models/category-test.js +++ b/tests/unit/models/category-test.js @@ -1,10 +1,16 @@ import { moduleForModel, test } from 'ember-qunit'; import { testForHasMany } from '../../helpers/relationship'; import '../../helpers/has-attributes'; +import Ember from 'ember'; + +const { get } = Ember; moduleForModel('category', 'Unit | Model | category', { // Specify the other units that are required for this test. - needs: ['model:user-category', 'model:project-category'] + needs: [ + 'model:project-category', + 'model:user-category' + ] }); test('it exists', function(assert) { @@ -14,12 +20,13 @@ test('it exists', function(assert) { }); test('it should have all its attributes', function(assert) { - let category = this.subject(); - let actualAttributes = Object.keys(category.toJSON()); + let model = this.store().modelFor('category'); + let actualAttributes = get(model, 'attributes'); + let expectedAttributes = [ - "description", - "name", - "slug", + 'description', + 'name', + 'slug' ]; assert.hasAttributes(actualAttributes, expectedAttributes); diff --git a/tests/unit/models/comment-test.js b/tests/unit/models/comment-test.js index 265aaf7f9..66f5c2c94 100644 --- a/tests/unit/models/comment-test.js +++ b/tests/unit/models/comment-test.js @@ -1,13 +1,16 @@ import { moduleForModel, test } from 'ember-qunit'; import { testForBelongsTo, testForHasMany } from '../../helpers/relationship'; import '../../helpers/has-attributes'; +import Ember from 'ember'; + +const { get } = Ember; moduleForModel('comment', 'Unit | Model | comment', { // Specify the other units that are required for this test. needs: [ + 'model:comment-user-mention', 'model:task', - 'model:user', - 'model:comment-user-mention' + 'model:user' ] }); @@ -18,14 +21,13 @@ test('it exists', function(assert) { }); test('it has all of its attributes', function(assert) { - let comment = this.subject(); - let actualAttributes = Object.keys(comment.toJSON()); + let model = this.store().modelFor('comment'); + let actualAttributes = get(model, 'attributes'); + let expectedAttributes = [ - "body", - "insertedAt", - "markdown", - "task", - "user", + 'body', + 'insertedAt', + 'markdown' ]; assert.hasAttributes(actualAttributes, expectedAttributes); diff --git a/tests/unit/models/comment-user-mention-test.js b/tests/unit/models/comment-user-mention-test.js index 0ac17bd59..f46c1f2c9 100644 --- a/tests/unit/models/comment-user-mention-test.js +++ b/tests/unit/models/comment-user-mention-test.js @@ -1,8 +1,15 @@ import { moduleForModel, test } from 'ember-qunit'; +import '../../helpers/has-attributes'; +import Ember from 'ember'; + +const { get } = Ember; moduleForModel('comment-user-mention', 'Unit | Model | comment user mention', { // Specify the other units that are required for this test. - needs: ['model:comment', 'model:user'] + needs: [ + 'model:comment', + 'model:user' + ] }); test('it exists', function(assert) { @@ -10,3 +17,15 @@ test('it exists', function(assert) { // let store = this.store(); assert.ok(!!model); }); + +test('it should have all of its attributes', function(assert) { + let model = this.store().modelFor('comment-user-mention'); + let actualAttributes = get(model, 'attributes'); + + let expectedAttributes = [ + 'indices', + 'username' + ]; + + assert.hasAttributes(actualAttributes, expectedAttributes); +}); diff --git a/tests/unit/models/organization-membership-test.js b/tests/unit/models/organization-membership-test.js index 4c9bf0a10..0c4fe640c 100644 --- a/tests/unit/models/organization-membership-test.js +++ b/tests/unit/models/organization-membership-test.js @@ -1,17 +1,20 @@ import { moduleForModel, test } from 'ember-qunit'; import { testForBelongsTo } from '../../helpers/relationship'; -import Ember from 'ember'; import '../../helpers/has-attributes'; +import Ember from 'ember'; const { get, set, - run, + run } = Ember; moduleForModel('organization-membership', 'Unit | Model | organization membership', { // Specify the other units that are required for this test. - needs: ['model:user', 'model:organization'] + needs: [ + 'model:organization', + 'model:user' + ] }); test('it exists', function(assert) { @@ -21,12 +24,11 @@ test('it exists', function(assert) { }); test('it should have all of its attributes', function(assert) { - let organizationMembership = this.subject(); - let actualAttributes = Object.keys(organizationMembership.toJSON()); + let model = this.store().modelFor('organization-membership'); + let actualAttributes = get(model, 'attributes'); + let expectedAttributes = [ - "member", - "organization", - "role", + 'role' ]; assert.hasAttributes(actualAttributes, expectedAttributes); diff --git a/tests/unit/models/organization-test.js b/tests/unit/models/organization-test.js index 3a56134b4..2b6253d82 100644 --- a/tests/unit/models/organization-test.js +++ b/tests/unit/models/organization-test.js @@ -1,8 +1,20 @@ import { moduleForModel, test } from 'ember-qunit'; +import { testForHasMany } from '../../helpers/relationship'; +import '../../helpers/has-attributes'; +import Ember from 'ember'; + +const { + get, + run +} = Ember; moduleForModel('organization', 'Unit | Model | organization', { // Specify the other units that are required for this test. - needs: ['model:project', 'model:user', 'model:organization-membership'] + needs: [ + 'model:organization-membership', + 'model:project', + 'model:user' + ] }); test('it exists', function(assert) { @@ -10,3 +22,36 @@ test('it exists', function(assert) { // let store = this.store(); assert.ok(!!model); }); + +test('it should have all of its attributes', function(assert) { + let model = this.store().modelFor('organization'); + let actualAttributes = get(model, 'attributes'); + + let expectedAttributes = [ + 'base64IconData', + 'description', + 'iconLargeUrl', + 'iconThumbUrl', + 'name', + 'slug' + ]; + + assert.hasAttributes(actualAttributes, expectedAttributes); +}); + +testForHasMany('organization', 'organizationMemberships'); +testForHasMany('organization', 'projects'); + +test('it should have computed properties for its organization\'s members', function(assert) { + assert.expect(2); + + let store = this.store(); + let model = this.subject(); + + run(function() { + store.createRecord('organization-membership', { organization: model, role: 'pending' }); + }); + + assert.equal(model.get('pendingMembersCount'), 1, 'pendingMembersCount should return 1'); + assert.equal(model.get('hasPendingMembers'), true, 'hasPendingMembers should return true'); +}); diff --git a/tests/unit/models/preview-test.js b/tests/unit/models/preview-test.js index 585573ddc..0f4b454d7 100644 --- a/tests/unit/models/preview-test.js +++ b/tests/unit/models/preview-test.js @@ -1,14 +1,16 @@ import { moduleForModel, test } from 'ember-qunit'; -import Ember from 'ember'; +import { testForBelongsTo, testForHasMany } from '../../helpers/relationship'; import '../../helpers/has-attributes'; +import Ember from 'ember'; -const { - get, -} = Ember; +const { get } = Ember; moduleForModel('preview', 'Unit | Model | preview', { // Specify the other units that are required for this test. - needs: ['model:user', 'model:preview-user-mention'] + needs: [ + 'model:preview-user-mention', + 'model:user' + ] }); test('it exists', function(assert) { @@ -18,33 +20,16 @@ test('it exists', function(assert) { }); test('it should have all of its attributes', function(assert) { - let preview = this.subject(); - let actualAttributes = Object.keys(preview.toJSON()); - let expectedAttributes = [ - "body", - "markdown", - "user" - ]; - - assert.hasAttributes(actualAttributes, expectedAttributes); -}); + let model = this.store().modelFor('preview'); + let actualAttributes = get(model, 'attributes'); -test('should belong to a user', function(assert) { - assert.expect(2); + let expectedAttributes = [ + 'body', + 'markdown' + ]; - const preview = this.store().modelFor('preview'); - const relationship = get(preview, 'relationshipsByName').get('user'); - - assert.equal(relationship.key, 'user', 'has relationship with user'); - assert.equal(relationship.kind, 'belongsTo', 'kind of relationship is belongsTo'); + assert.hasAttributes(actualAttributes, expectedAttributes); }); -test('should have many preview-user-mention', function(assert) { - assert.expect(2); - - const preview = this.store().modelFor('preview'); - const relationship = get(preview, 'relationshipsByName').get('previewUserMentions'); - - assert.equal(relationship.key, 'previewUserMentions', 'has relationship with preview-user-mention'); - assert.equal(relationship.kind, 'hasMany', 'kind of relationship is hasMany'); -}); +testForBelongsTo('preview', 'user'); +testForHasMany('preview', 'previewUserMentions'); diff --git a/tests/unit/models/preview-user-mention-test.js b/tests/unit/models/preview-user-mention-test.js index 1940aec70..7c5808d15 100644 --- a/tests/unit/models/preview-user-mention-test.js +++ b/tests/unit/models/preview-user-mention-test.js @@ -1,8 +1,15 @@ import { moduleForModel, test } from 'ember-qunit'; +import '../../helpers/has-attributes'; +import Ember from 'ember'; + +const { get } = Ember; moduleForModel('preview-user-mention', 'Unit | Model | preview user mention', { // Specify the other units that are required for this test. - needs: ['model:preview', 'model:user'] + needs: [ + 'model:preview', + 'model:user' + ] }); test('it exists', function(assert) { @@ -10,3 +17,15 @@ test('it exists', function(assert) { // let store = this.store(); assert.ok(!!model); }); + +test('it should have all of its attributes', function(assert) { + let model = this.store().modelFor('preview-user-mention'); + let actualAttributes = get(model, 'attributes'); + + let expectedAttributes = [ + 'indices', + 'username' + ]; + + assert.hasAttributes(actualAttributes, expectedAttributes); +}); diff --git a/tests/unit/models/project-category-test.js b/tests/unit/models/project-category-test.js index 3fc00ca50..28f2a3a1c 100644 --- a/tests/unit/models/project-category-test.js +++ b/tests/unit/models/project-category-test.js @@ -1,9 +1,5 @@ import { moduleForModel, test } from 'ember-qunit'; -import Ember from 'ember'; - -const { - get, -} = Ember; +import { testForBelongsTo } from '../../helpers/relationship'; moduleForModel('project-category', 'Unit | Model | project category', { // Specify the other units that are required for this test. @@ -16,22 +12,5 @@ test('it exists', function(assert) { assert.ok(!!model); }); -test('it should belong to a category', function(assert) { - assert.expect(2); - - const projectCategory = this.store().modelFor('project-category'); - const relationship = get(projectCategory, 'relationshipsByName').get('category'); - - assert.equal(relationship.key, 'category', 'has relationship with category'); - assert.equal(relationship.kind, 'belongsTo', 'kind of relationship is belongsTo'); -}); - -test('it should belong to a project', function(assert) { - assert.expect(2); - - const projectCategory = this.store().modelFor('project-category'); - const relationship = get(projectCategory, 'relationshipsByName').get('project'); - - assert.equal(relationship.key, 'project', 'has relationship with project'); - assert.equal(relationship.kind, 'belongsTo', 'kind of relationship is belongsTo'); -}); +testForBelongsTo('project-category', 'category'); +testForBelongsTo('project-category', 'project'); diff --git a/tests/unit/models/project-skill-test.js b/tests/unit/models/project-skill-test.js index fa96b71b3..2c80a7cee 100644 --- a/tests/unit/models/project-skill-test.js +++ b/tests/unit/models/project-skill-test.js @@ -1,9 +1,5 @@ import { moduleForModel, test } from 'ember-qunit'; -import Ember from 'ember'; - -const { - get, -} = Ember; +import { testForBelongsTo } from '../../helpers/relationship'; moduleForModel('project-skill', 'Unit | Model | project skill', { // Specify the other units that are required for this test. @@ -16,22 +12,5 @@ test('it exists', function(assert) { assert.ok(!!model); }); -test('should belong to a project', function(assert) { - assert.expect(2); - - const projectSkill = this.store().modelFor('project-skill'); - const relationship = get(projectSkill, 'relationshipsByName').get('project'); - - assert.equal(relationship.key, 'project', 'has relationship with project'); - assert.equal(relationship.kind, 'belongsTo', 'kind of relationship is belongsTo'); -}); - -test('should belong to a skill', function(assert) { - assert.expect(2); - - const projectSkill = this.store().modelFor('project-skill'); - const relationship = get(projectSkill, 'relationshipsByName').get('skill'); - - assert.equal(relationship.key, 'skill', 'has relationship with skill'); - assert.equal(relationship.kind, 'belongsTo', 'kind of relationship is belongsTo'); -}); +testForBelongsTo('project-skill', 'project'); +testForBelongsTo('project-skill', 'skill'); diff --git a/tests/unit/models/project-test.js b/tests/unit/models/project-test.js index def71b718..a3ac1dce5 100644 --- a/tests/unit/models/project-test.js +++ b/tests/unit/models/project-test.js @@ -3,11 +3,21 @@ import { testForBelongsTo, testForHasMany } from '../../helpers/relationship'; import '../../helpers/has-attributes'; import Ember from 'ember'; +const { + get, + run +} = Ember; + moduleForModel('project', 'Unit | Model | project', { // Specify the other units that are required for this test. - needs: ['model:project-category', 'model:organization', - 'model:organization-membership', 'model:user', - 'model:task', 'model:project-skill'] + needs: [ + 'model:organization', + 'model:organization-membership', + 'model:project-category', + 'model:project-skill', + 'model:task', + 'model:user' + ] }); test('it exists', function(assert) { @@ -16,20 +26,20 @@ test('it exists', function(assert) { }); test('it should have all of its attributes', function(assert) { - let model = this.subject(); - let actualAttributes = Object.keys(model.toJSON()); + let model = this.store().modelFor('project'); + let actualAttributes = get(model, 'attributes'); + let expectedAttributes = [ - "base64IconData", - "closedTasksCount", - "description", - "iconLargeUrl", - "iconThumbUrl", - "longDescriptionBody", - "longDescriptionMarkdown", - "openTasksCount", - "organization", - "slug", - "title", + 'base64IconData', + 'closedTasksCount', + 'description', + 'iconLargeUrl', + 'iconThumbUrl', + 'longDescriptionBody', + 'longDescriptionMarkdown', + 'openTasksCount', + 'slug', + 'title' ]; assert.hasAttributes(actualAttributes, expectedAttributes); @@ -54,9 +64,9 @@ test('it should have computed properties for its organization\'s members', funct let _this = this; let project; - Ember.run(function(){ + run(function() { let organization = _this.store().createRecord('organization'); - _this.store().createRecord('organization-membership', { organization, role: 'pending'}); + _this.store().createRecord('organization-membership', { organization, role: 'pending' }); project = _this.subject({ organization }); }); diff --git a/tests/unit/models/skill-test.js b/tests/unit/models/skill-test.js index 079164679..790faf670 100644 --- a/tests/unit/models/skill-test.js +++ b/tests/unit/models/skill-test.js @@ -1,4 +1,8 @@ import { moduleForModel, test } from 'ember-qunit'; +import '../../helpers/has-attributes'; +import Ember from 'ember'; + +const { get } = Ember; moduleForModel('skill', 'Unit | Model | skill', { // Specify the other units that are required for this test. @@ -12,13 +16,14 @@ test('it exists', function(assert) { }); test('it should have all of its attributes', function(assert) { - let model = this.subject(); - let actualAttributes = Object.keys(model.toJSON()); - let expectedAttributes = [ - "description", - "matched", - "title", - ]; + let model = this.store().modelFor('skill'); + let actualAttributes = get(model, 'attributes'); + + let expectedAttributes = [ + 'description', + 'matched', + 'title' + ]; - assert.hasAttributes(actualAttributes, expectedAttributes); + assert.hasAttributes(actualAttributes, expectedAttributes); }); diff --git a/tests/unit/models/slugged-route-test.js b/tests/unit/models/slugged-route-test.js index f28864226..04be9ad34 100644 --- a/tests/unit/models/slugged-route-test.js +++ b/tests/unit/models/slugged-route-test.js @@ -1,10 +1,16 @@ import { moduleForModel, test } from 'ember-qunit'; import { testForBelongsTo } from '../../helpers/relationship'; import '../../helpers/has-attributes'; +import Ember from 'ember'; + +const { get } = Ember; moduleForModel('slugged-route', 'Unit | Model | slugged-route', { // Specify the other units that are required for this test. - needs: ['model:organization', 'model:user'] + needs: [ + 'model:organization', + 'model:user' + ] }); test('it exists', function(assert) { @@ -14,12 +20,11 @@ test('it exists', function(assert) { }); test('should have all of its attributes', function(assert) { - let sluggedRoute = this.subject(); - let actualAttributes = Object.keys(sluggedRoute.toJSON()); + let model = this.store().modelFor('slugged-route'); + let actualAttributes = get(model, 'attributes'); + let expectedAttributes = [ - "organization", - "slug", - "user", + 'slug' ]; assert.hasAttributes(actualAttributes, expectedAttributes); diff --git a/tests/unit/models/task-test.js b/tests/unit/models/task-test.js index 9ed2745ff..5b2e65222 100644 --- a/tests/unit/models/task-test.js +++ b/tests/unit/models/task-test.js @@ -1,15 +1,18 @@ import { moduleForModel, test } from 'ember-qunit'; import { testForBelongsTo, testForHasMany } from '../../helpers/relationship'; import '../../helpers/has-attributes'; +import Ember from 'ember'; + +const { get } = Ember; moduleForModel('task', 'Unit | Model | task', { // Specify the other units that are required for this test. needs: [ - 'model:project', - 'model:user', 'model:comment', 'model:comment-user-mention', - 'model:task-user-mention' + 'model:project', + 'model:task-user-mention', + 'model:user' ] }); @@ -20,20 +23,18 @@ test('it exists', function(assert) { }); test('it should have all of its attributes', function(assert) { - let task = this.subject(); - let actualAttributes = Object.keys(task.toJSON()); + let model = this.store().modelFor('task'); + let actualAttributes = get(model, 'attributes'); + let expectedAttributes = [ - "body", - "commentUserMentions", - "insertedAt", - "likesCount", - "markdown", - "number", - "project", - "status", - "taskType", - "title", - "user", + 'body', + 'insertedAt', + 'likesCount', + 'markdown', + 'number', + 'status', + 'taskType', + 'title' ]; assert.hasAttributes(actualAttributes, expectedAttributes); diff --git a/tests/unit/models/task-user-mention-test.js b/tests/unit/models/task-user-mention-test.js index 375c8fa45..00b32bd0a 100644 --- a/tests/unit/models/task-user-mention-test.js +++ b/tests/unit/models/task-user-mention-test.js @@ -1,8 +1,17 @@ import { moduleForModel, test } from 'ember-qunit'; +import '../../helpers/has-attributes'; +import Ember from 'ember'; + +const { + get +} = Ember; moduleForModel('task-user-mention', 'Unit | Model | task user mention', { // Specify the other units that are required for this test. - needs: ['model:task', 'model:user'] + needs: [ + 'model:task', + 'model:user' + ] }); test('it exists', function(assert) { @@ -10,3 +19,15 @@ test('it exists', function(assert) { // let store = this.store(); assert.ok(!!model); }); + +test('it should have all of its attributes', function(assert) { + let model = this.store().modelFor('task-user-mention'); + let actualAttributes = get(model, 'attributes'); + + let expectedAttributes = [ + 'indices', + 'username' + ]; + + assert.hasAttributes(actualAttributes, expectedAttributes); +}); diff --git a/tests/unit/models/user-skill-test.js b/tests/unit/models/user-skill-test.js index 040ea8771..107ac5e1a 100644 --- a/tests/unit/models/user-skill-test.js +++ b/tests/unit/models/user-skill-test.js @@ -1,9 +1,5 @@ import { moduleForModel, test } from 'ember-qunit'; -import Ember from 'ember'; - -const { - get, -} = Ember; +import { testForBelongsTo } from '../../helpers/relationship'; moduleForModel('user-skill', 'Unit | Model | user skill', { // Specify the other units that are required for this test. @@ -16,22 +12,5 @@ test('it exists', function(assert) { assert.ok(!!model); }); -test('it should belong to a skill', function(assert) { - assert.expect(2); - - const userSkill = this.store().modelFor('user-skill'); - const relationship = get(userSkill, 'relationshipsByName').get('skill'); - - assert.equal(relationship.key, 'skill', 'has relationship with skill'); - assert.equal(relationship.kind, 'belongsTo', 'kind of relationship is belongsTo'); -}); - -test('it should belong to a user', function(assert) { - assert.expect(2); - - const userSkill = this.store().modelFor('user-skill'); - const relationship = get(userSkill, 'relationshipsByName').get('user'); - - assert.equal(relationship.key, 'user', 'has relationship with user'); - assert.equal(relationship.kind, 'belongsTo', 'kind of relationship is belongsTo'); -}); +testForBelongsTo('user-skill', 'skill'); +testForBelongsTo('user-skill', 'user'); diff --git a/tests/unit/models/user-test.js b/tests/unit/models/user-test.js index a6509eedb..8e1326dfe 100644 --- a/tests/unit/models/user-test.js +++ b/tests/unit/models/user-test.js @@ -1,6 +1,9 @@ import { moduleForModel, test } from 'ember-qunit'; import { testForHasMany } from '../../helpers/relationship'; import '../../helpers/has-attributes'; +import Ember from 'ember'; + +const { get } = Ember; moduleForModel('user', 'Unit | Model | user', { // Specify the other units that are required for this test. @@ -20,24 +23,25 @@ test('it exists', function(assert) { }); test('it has all of its attributes', function(assert) { - let user = this.subject(); - let actualAttributes = Object.keys(user.toJSON()); + let model = this.store().modelFor('user'); + let actualAttributes = get(model, 'attributes'); + let expectedAttributes = [ - "base64PhotoData", - "biography", - "email", - "firstName", - "insertedAt", - "lastName", - "name", - "password", - "photoLargeUrl", - "photoThumbUrl", - "state", - "stateTransition", - "twitter", - "username", - "website", + 'base64PhotoData', + 'biography', + 'email', + 'firstName', + 'insertedAt', + 'lastName', + 'name', + 'password', + 'photoLargeUrl', + 'photoThumbUrl', + 'state', + 'stateTransition', + 'twitter', + 'username', + 'website' ]; assert.hasAttributes(actualAttributes, expectedAttributes); diff --git a/tests/unit/routes/application-test.js b/tests/unit/routes/application-test.js index 11d5627ac..05b487577 100644 --- a/tests/unit/routes/application-test.js +++ b/tests/unit/routes/application-test.js @@ -1,20 +1,22 @@ import { moduleFor, test } from 'ember-qunit'; import Ember from 'ember'; +const { getOwner } = Ember; + moduleFor('route:application', 'Unit | Route | application', { // Specify the other units that are required for this test. needs: [ 'service:flash-messages', 'service:metrics', - 'service:session', + 'service:session' ] }); test('it clears flash messages on transition', function(assert) { assert.expect(2); - const typesUsed = ['success']; - const flashMessages = Ember.getOwner(this).lookup('service:flash-messages'); + let typesUsed = ['success']; + let flashMessages = getOwner(this).lookup('service:flash-messages'); flashMessages.registerTypes(typesUsed); let route = this.subject(); diff --git a/tests/unit/services/current-user-test.js b/tests/unit/services/current-user-test.js index bd99393b0..ebc09af27 100644 --- a/tests/unit/services/current-user-test.js +++ b/tests/unit/services/current-user-test.js @@ -1,6 +1,11 @@ import { moduleFor, test } from 'ember-qunit'; import Ember from 'ember'; +const { + Object, + RSVP +} = Ember; + moduleFor('service:current-user', 'Unit | Service | current user', { // Specify the other units that are required for this test. needs: ['service:session'] @@ -26,7 +31,7 @@ test('it sets the user when there is a user', function(assert) { }, store: { findRecord() { - return Ember.RSVP.resolve(Ember.Object.create({ id: 1 })); + return RSVP.resolve(Object.create({ id: 1 })); } }, session: { @@ -50,8 +55,8 @@ test('it rejects when the user is not returned from the store', function(assert) assert.expect(1); let service = this.subject({ store: { - find: function() { - return Ember.RSVP.reject(); + find() { + return RSVP.reject(); } }, session: { diff --git a/tests/unit/services/mention-fetcher-test.js b/tests/unit/services/mention-fetcher-test.js index 90116b79c..e8a86f9ff 100644 --- a/tests/unit/services/mention-fetcher-test.js +++ b/tests/unit/services/mention-fetcher-test.js @@ -1,5 +1,5 @@ // import Ember from 'ember'; -import { moduleFor /*, test */ } from 'ember-qunit'; +import { moduleFor /* , test */ } from 'ember-qunit'; moduleFor('service:mention-fetcher', 'Unit | Service | mention fetcher', { }); diff --git a/tests/unit/services/navigation-menu-test.js b/tests/unit/services/navigation-menu-test.js index b19f345db..a4a5aa1ce 100644 --- a/tests/unit/services/navigation-menu-test.js +++ b/tests/unit/services/navigation-menu-test.js @@ -20,7 +20,7 @@ test('it isOnboarding when the user is onboarding', function(assert) { let service = this.subject({ onboarding: { isOnboarding: true - }, + } }); assert.ok(service.get('isOnboarding')); diff --git a/tests/unit/services/onboarding-test.js b/tests/unit/services/onboarding-test.js index 90ea4013b..bdfd1d0ce 100644 --- a/tests/unit/services/onboarding-test.js +++ b/tests/unit/services/onboarding-test.js @@ -1,29 +1,30 @@ import { moduleFor, test } from 'ember-qunit'; import Ember from 'ember'; +const { isPresent } = Ember; + moduleFor('service:onboarding', 'Unit | Service | onboarding', { // Specify the other units that are required for this test. - needs: ['service:current-user', 'service:session'], + needs: ['service:current-user', 'service:session'] }); test('it has number, state, currentRoute, and nextRoute defined in each step', function(assert) { let service = this.subject(); let steps = service.get('_steps'); let totalSteps = service.get('totalSteps'); - const numberOfKeys = 5; + let numberOfKeys = 5; assert.expect(totalSteps * numberOfKeys); - for(var i = 0; i < totalSteps; i++) { - assert.ok(Ember.isPresent(steps[i].number)); - assert.ok(Ember.isPresent(steps[i].state)); - assert.ok(Ember.isPresent(steps[i].currentRoute)); - assert.ok(Ember.isPresent(steps[i].nextRoute)); - assert.ok(Ember.isPresent(steps[i].nextStateTransition)); + for (let i = 0; i < totalSteps; i++) { + assert.ok(isPresent(steps[i].number)); + assert.ok(isPresent(steps[i].state)); + assert.ok(isPresent(steps[i].currentRoute)); + assert.ok(isPresent(steps[i].nextRoute)); + assert.ok(isPresent(steps[i].nextStateTransition)); } }); - test('it returns the number of steps', function(assert) { let service = this.subject({ currentUser: { @@ -146,7 +147,7 @@ test('it knows the onboarding routes', function(assert) { assert.expect(totalSteps); - for(var i = 0; i < totalSteps; i++) { - assert.ok(routes.contains(steps[i].currentRoute)); + for (let i = 0; i < totalSteps; i++) { + assert.ok(routes.includes(steps[i].currentRoute)); } }); diff --git a/tests/unit/transforms/array-test.js b/tests/unit/transforms/array-test.js index eddd617a3..39b5f29dc 100644 --- a/tests/unit/transforms/array-test.js +++ b/tests/unit/transforms/array-test.js @@ -11,19 +11,17 @@ test('it exists', function(assert) { assert.ok(transform); }); - test('it serializes properly', function(assert) { assert.expect(4); let transform = this.subject(); - assert.deepEqual(transform.serialize(['a','b','c','d']), ['a','b','c','d'], 'Arrays are serialized into arrays'); + assert.deepEqual(transform.serialize(['a', 'b', 'c', 'd']), ['a', 'b', 'c', 'd'], 'Arrays are serialized into arrays'); assert.deepEqual(transform.serialize('a, b , c, d'), ['a', 'b', 'c', 'd'], 'Strings of items with "," separaters are serialized into arrays with the items trimmed'); assert.deepEqual(transform.serialize(1), [], 'Numbers are serialized into an empty array'); assert.deepEqual(transform.serialize(true), [], 'Booleans are serialized into an empty array'); }); - test('it deserializes properly', function(assert) { assert.expect(2); diff --git a/tests/unit/utils/mention-parser-test.js b/tests/unit/utils/mention-parser-test.js index 03552c861..25ef1d53e 100644 --- a/tests/unit/utils/mention-parser-test.js +++ b/tests/unit/utils/mention-parser-test.js @@ -2,6 +2,8 @@ import { parse } from 'code-corps-ember/utils/mention-parser'; import { module, test } from 'qunit'; import Ember from 'ember'; +const { Object } = Ember; + module('Unit | Utility | mention parser'); test('it replaces all "@username" mention strings with links to the user profile', function(assert) { @@ -10,13 +12,13 @@ test('it replaces all "@username" mention strings with links to the user profile let body = '

    Mentioning @user1 and @user2

    '; let mentions = [ - Ember.Object.create({ + Object.create({ indices: [14, 19], username: 'user1', user: { id: 1 } }), - Ember.Object.create({ + Object.create({ indices: [25, 30], username: 'user2', user: { id: 2 }