From f7d7028bfcd1a715fb59182261a84c02c26a30b7 Mon Sep 17 00:00:00 2001 From: Sam Chrisinger Date: Fri, 6 May 2016 15:24:27 -0400 Subject: [PATCH 01/10] Re-add support for personal access tokens This is needed for local development --- addon/mixins/osf-login-route.js | 26 +++++++++++++++++--------- index.js | 2 +- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/addon/mixins/osf-login-route.js b/addon/mixins/osf-login-route.js index 897250dd1..ba1d3bc12 100644 --- a/addon/mixins/osf-login-route.js +++ b/addon/mixins/osf-login-route.js @@ -1,19 +1,27 @@ import Ember from 'ember'; import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-route-mixin'; +import config from 'ember-get-config'; + export default Ember.Mixin.create(UnauthenticatedRouteMixin, { session: Ember.inject.service(), beforeModel() { - // Acquire an OSF access token, then exchange it for a Jam token - var hash = window.location.hash.substring(1).split('&').map(function(str) { - return this[str.split('=')[0]] = str.split('=')[1], this; - }.bind({}))[0]; - if (!hash || !hash.access_token) { - return null; + var accessToken; + if (config.OSF.local) { + accessToken = config.OSF.accessToken; + } else { + // Acquire an OSF access token, then exchange it for a Jam token + var hash = window.location.hash.substring(1).split('&').map(function(str) { + return this[str.split('=')[0]] = str.split('=')[1], this; + }.bind({}))[0]; + if (!hash || !hash.access_token) { + return null; + } + window.location.hash = ''; + accessToken = hash.access_token; } - window.location.hash = ''; - var accessToken = hash.access_token; - return this.get('session').authenticate('authenticator:osf-token', accessToken) + + return this.get('session').authenticate('authenticator:osf-token', accessToken) .then(() => this.transitionTo('index')); } }); diff --git a/index.js b/index.js index efab97a95..e886bb362 100644 --- a/index.js +++ b/index.js @@ -26,7 +26,7 @@ module.exports = { ENV.OSF.authUrl = 'http://localhost:8080/oauth2/profile'; ENV.OSF.accessToken = process.env.OSF_ACCESS_TOKEN; - ENV.DEV = true; + ENV.OSF.local = true; } if (environment === 'staging') { ENV.OSF.url = 'https://staging.osf.io/'; From 7d79f2015fc7ab1ebdf0f6136cc522ee07a4db1f Mon Sep 17 00:00:00 2001 From: Sam Chrisinger Date: Fri, 6 May 2016 15:53:59 -0400 Subject: [PATCH 02/10] Install ember-cli-mirage --- .jshintrc | 1 + tests/.jshintrc | 1 + tests/dummy/app/mirage/config.js | 82 +++++++++++++++++++++ tests/dummy/app/mirage/factories/base.js | 3 + tests/dummy/app/mirage/scenarios/default.js | 7 ++ 5 files changed, 94 insertions(+) create mode 100644 tests/dummy/app/mirage/config.js create mode 100644 tests/dummy/app/mirage/factories/base.js create mode 100644 tests/dummy/app/mirage/scenarios/default.js diff --git a/.jshintrc b/.jshintrc index 08096effa..2f30d1604 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,5 +1,6 @@ { "predef": [ + "server", "document", "window", "-Promise" diff --git a/tests/.jshintrc b/tests/.jshintrc index 6ec0b7c15..4f9f51d89 100644 --- a/tests/.jshintrc +++ b/tests/.jshintrc @@ -1,5 +1,6 @@ { "predef": [ + "server", "document", "window", "location", diff --git a/tests/dummy/app/mirage/config.js b/tests/dummy/app/mirage/config.js new file mode 100644 index 000000000..d006425e9 --- /dev/null +++ b/tests/dummy/app/mirage/config.js @@ -0,0 +1,82 @@ +export default function() { + + // These comments are here to help you get started. Feel free to delete them. + + /* + Config (with defaults). + + Note: these only affect routes defined *after* them! + */ + // this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server + // this.namespace = ''; // make this `api`, for example, if your API is namespaced + // this.timing = 400; // delay for each request, automatically set to 0 during testing + + /* + Route shorthand cheatsheet + */ + /* + GET shorthands + + // Collections + this.get('/contacts'); + this.get('/contacts', 'users'); + this.get('/contacts', ['contacts', 'addresses']); + + // Single objects + this.get('/contacts/:id'); + this.get('/contacts/:id', 'user'); + this.get('/contacts/:id', ['contact', 'addresses']); + */ + + /* + POST shorthands + + this.post('/contacts'); + this.post('/contacts', 'user'); // specify the type of resource to be created + */ + + /* + PUT shorthands + + this.put('/contacts/:id'); + this.put('/contacts/:id', 'user'); // specify the type of resource to be updated + */ + + /* + DELETE shorthands + + this.del('/contacts/:id'); + this.del('/contacts/:id', 'user'); // specify the type of resource to be deleted + + // Single object + related resources. Make sure parent resource is first. + this.del('/contacts/:id', ['contact', 'addresses']); + */ + + /* + Function fallback. Manipulate data in the db via + + - db.{collection} + - db.{collection}.find(id) + - db.{collection}.where(query) + - db.{collection}.update(target, attrs) + - db.{collection}.remove(target) + + // Example: return a single object with related models + this.get('/contacts/:id', function(db, request) { + var contactId = +request.params.id; + + return { + contact: db.contacts.find(contactId), + addresses: db.addresses.where({contact_id: contactId}) + }; + }); + + */ +} + +/* +You can optionally export a config that is only loaded during tests +export function testConfig() { + +} +*/ diff --git a/tests/dummy/app/mirage/factories/base.js b/tests/dummy/app/mirage/factories/base.js new file mode 100644 index 000000000..e483635d1 --- /dev/null +++ b/tests/dummy/app/mirage/factories/base.js @@ -0,0 +1,3 @@ +import Mirage/*, {faker}*/ from 'ember-cli-mirage'; + +export default Mirage.Factory.extend({}); diff --git a/tests/dummy/app/mirage/scenarios/default.js b/tests/dummy/app/mirage/scenarios/default.js new file mode 100644 index 000000000..e07271cc9 --- /dev/null +++ b/tests/dummy/app/mirage/scenarios/default.js @@ -0,0 +1,7 @@ +export default function(/* server */) { + + // Seed your development database using your factories. This + // data will not be loaded in your tests. + + // server.createList('contact', 10); +} From 603175fc470a22b1cef9efe1cff6af5f2944fe54 Mon Sep 17 00:00:00 2001 From: Sam Chrisinger Date: Fri, 6 May 2016 15:54:30 -0400 Subject: [PATCH 03/10] Reformat requirements files --- bower.json | 23 ++++++----- package.json | 109 ++++++++++++++++++++++++++------------------------- 2 files changed, 68 insertions(+), 64 deletions(-) diff --git a/bower.json b/bower.json index b9f7800fd..c435c94aa 100644 --- a/bower.json +++ b/bower.json @@ -1,12 +1,15 @@ { - "name": "ember-osf", - "dependencies": { - "ember": "~2.4.3", - "ember-cli-shims": "0.1.1", - "ember-cli-test-loader": "0.2.2", - "ember-qunit-notifications": "0.1.0" - }, - "devDependencies": { - "bootstrap": "^3.3.6" - } + "name": "ember-osf", + "dependencies": { + "ember": "~2.4.3", + "ember-cli-shims": "0.1.1", + "ember-cli-test-loader": "0.2.1", + "ember-qunit-notifications": "0.1.0", + "Faker": "~3.0.0", + "pretender": "~0.10.1", + "lodash": "~3.7.0" + }, + "devDependencies": { + "bootstrap": "^3.3.6" + } } diff --git a/package.json b/package.json index b3c4657fd..078df3423 100644 --- a/package.json +++ b/package.json @@ -1,56 +1,57 @@ { - "name": "ember-osf", - "version": "0.0.1", - "description": "Ember Data models for the OSF APIv2", - "directories": { - "doc": "doc", - "test": "tests" - }, - "scripts": { - "build": "ember build", - "start": "ember server", - "test": "ember test" - }, - "repository": "", - "engines": { - "node": ">= 0.10.0" - }, - "author": "", - "license": "MIT", - "devDependencies": { - "broccoli-asset-rev": "^2.2.0", - "ember-ajax": "0.7.1", - "ember-cli": "^2.4.3", - "ember-cli-app-version": "^1.0.0", - "ember-cli-dependency-checker": "^1.2.0", - "ember-cli-htmlbars": "^1.0.1", - "ember-cli-htmlbars-inline-precompile": "^0.3.1", - "ember-cli-inject-live-reload": "^1.3.1", - "ember-cli-qunit": "^1.2.1", - "ember-cli-release": "0.2.8", - "ember-cli-sri": "^2.0.0", - "ember-cli-uglify": "^1.2.0", - "ember-data": "^2.3.0", - "ember-disable-prototype-extensions": "^1.0.0", - "ember-disable-proxy-controllers": "^1.0.1", - "ember-export-application-global": "^1.0.4", - "ember-load-initializers": "0.5.1", - "ember-resolver": "2.0.3", - "loader": "2.1.0", - "loader.js": "4.0.3" - }, - "keywords": [ - "ember-addon" - ], - "dependencies": { - "ember-cli-babel": "^5.1.5", - "loader": "^2.1.0", - "ember-simple-auth": "1.1.0-beta.5", - "ember-get-config": "0.0.2", - "ember-moment": "6.1.0", - "dotenv": "^2.0.0" - }, - "ember-addon": { - "configPath": "tests/dummy/config" - } + "name": "ember-osf", + "version": "0.0.1", + "description": "Ember Data models for the OSF APIv2", + "directories": { + "doc": "doc", + "test": "tests" + }, + "scripts": { + "build": "ember build", + "start": "ember server", + "test": "ember test" + }, + "repository": "", + "engines": { + "node": ">= 0.10.0" + }, + "author": "", + "license": "MIT", + "devDependencies": { + "broccoli-asset-rev": "^2.2.0", + "ember-ajax": "0.7.1", + "ember-cli": "^2.4.3", + "ember-cli-app-version": "^1.0.0", + "ember-cli-dependency-checker": "^1.2.0", + "ember-cli-htmlbars": "^1.0.1", + "ember-cli-htmlbars-inline-precompile": "^0.3.1", + "ember-cli-inject-live-reload": "^1.3.1", + "ember-cli-mirage": "0.1.13", + "ember-cli-qunit": "^1.2.1", + "ember-cli-release": "0.2.8", + "ember-cli-sri": "^2.0.0", + "ember-cli-uglify": "^1.2.0", + "ember-data": "^2.3.0", + "ember-disable-prototype-extensions": "^1.0.0", + "ember-disable-proxy-controllers": "^1.0.1", + "ember-export-application-global": "^1.0.4", + "ember-load-initializers": "0.5.1", + "ember-resolver": "2.0.3", + "loader": "2.1.0", + "loader.js": "4.0.3" + }, + "keywords": [ + "ember-addon" + ], + "dependencies": { + "ember-cli-babel": "^5.1.5", + "loader": "^2.1.0", + "ember-simple-auth": "1.1.0-beta.5", + "ember-get-config": "0.0.2", + "ember-moment": "6.1.0", + "dotenv": "^2.0.0" + }, + "ember-addon": { + "configPath": "tests/dummy/config" + } } From b5d1edc11eb16594366fcd569b16399791c8fb9e Mon Sep 17 00:00:00 2001 From: Sam Chrisinger Date: Fri, 6 May 2016 15:54:47 -0400 Subject: [PATCH 04/10] WIP serializers unit tests --- addon/serializers/application.js | 4 ++ tests/unit/models/base-test.js | 8 +--- tests/unit/serializers/application-test.js | 46 ++++++++++++++++++---- tests/unit/serializers/node-test.js | 15 +++++++ 4 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 tests/unit/serializers/node-test.js diff --git a/addon/serializers/application.js b/addon/serializers/application.js index d8cdbd6ad..e1fa924c2 100644 --- a/addon/serializers/application.js +++ b/addon/serializers/application.js @@ -14,6 +14,10 @@ export default DS.JSONAPISerializer.extend({ if (record.links) { record.attributes.links = record.links; } + if (record.embeds) { + // TODO, actually merge in embedded data? + record.attributes.embeds = record.embeds; + } return record; }, normalizeSingleResponse(_, __, payload) { diff --git a/tests/unit/models/base-test.js b/tests/unit/models/base-test.js index 3065a6f45..c40c5114b 100644 --- a/tests/unit/models/base-test.js +++ b/tests/unit/models/base-test.js @@ -1,12 +1,6 @@ -import { moduleForModel, test } from 'ember-qunit'; +import { moduleForModel /*, test*/ } from 'ember-qunit'; moduleForModel('base', 'Unit | Model | base', { // Specify the other units that are required for this test. needs: [] }); - -test('it exists', function(assert) { - let model = this.subject(); - // let store = this.store(); - assert.ok(!!model); -}); diff --git a/tests/unit/serializers/application-test.js b/tests/unit/serializers/application-test.js index b72e6fc39..ae5fc74a9 100644 --- a/tests/unit/serializers/application-test.js +++ b/tests/unit/serializers/application-test.js @@ -1,12 +1,42 @@ -import { moduleForModel/*, test */} from 'ember-qunit'; +import { moduleForModel, test } from 'ember-qunit'; +import { faker } from 'ember-cli-mirage'; -moduleForModel('application', 'Unit | Serializer | application', { - // Specify the other units that are required for this test. +moduleForModel('base', 'Unit | Serializer | application', { needs: ['serializer:application'] }); -/* -// Replace this with your real tests. -test('it serializes records', function(assert) { - + +test('#_normalizeRecord adds links to attributes if included in payload', function(assert) { + let payload = { + id: faker.random.uuid(), + type: 'base', + attributes: { + key: 'value' + }, + links: { + html: faker.internet.url() + } + }; + + let serializer = this.container.lookup('serializer:application'); + let normalized = serializer._normalizeRecord(payload); + + assert.equal(normalized.attributes.links, payload.links); +}); +test('#_normalizeRecord adds links to attributes if included in payload', function(assert) { + let payload = { + id: faker.random.uuid(), + attributes: { + key: 'value' + }, + embeds: { + embedded: { + data: [faker.random.arrayElement()] + } + } + }; + + let serializer = this.container.lookup('serializer:application'); + let normalized = serializer._normalizeRecord(payload); + + assert.equal(normalized.attributes.embeds, payload.embeds); }); -*/ diff --git a/tests/unit/serializers/node-test.js b/tests/unit/serializers/node-test.js new file mode 100644 index 000000000..b79ba7400 --- /dev/null +++ b/tests/unit/serializers/node-test.js @@ -0,0 +1,15 @@ +import { moduleForModel, test } from 'ember-qunit'; + +moduleForModel('node', 'Unit | Serializer | node', { + // Specify the other units that are required for this test. + needs: ['serializer:node'] +}); + +// Replace this with your real tests. +test('it serializes records', function(assert) { + let record = this.subject(); + + let serializedRecord = record.serialize(); + + assert.ok(serializedRecord); +}); From 35fd1a11db6fe5d3271b6ccd0d324ea77c2771a2 Mon Sep 17 00:00:00 2001 From: Sam Chrisinger Date: Mon, 9 May 2016 12:19:01 -0400 Subject: [PATCH 05/10] Switch to using config module for local configs --- .gitignore | 6 +----- index.js | 30 +++++++++++++----------------- package.json | 2 ++ 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 0cab8edcb..399b6f91f 100644 --- a/.gitignore +++ b/.gitignore @@ -16,8 +16,4 @@ npm-debug.log testem.log -.env -.env-local -.env-stage* -.env-prod - +*local.yml diff --git a/index.js b/index.js index e886bb362..510388ca9 100644 --- a/index.js +++ b/index.js @@ -1,44 +1,40 @@ /* jshint node: true */ 'use strict'; -var dotenv = require('dotenv'); +var config = require('config'); module.exports = { name: 'ember-osf', config: function(environment, ENV) { - dotenv.config({ - path:'.env-' + { - development: 'local', - test: 'test', - staging: 'stage', - staging2: 'stage2', - production: 'prod' - }[environment] - }); + let BACKEND = process.env.BACKEND || 'local'; + if (!config.has(BACKEND)) { + throw new Error(`WARNING: you have specified a backend: ${BACKEND} that you have not configured in your local.yml`); + } + let SETTINGS = config.get(BACKEND); ENV.OSF = { - clientId: process.env.OSF_CLIENT_ID, - scope: process.env.OSF_SCOPE + clientId: SETTINGS.CLIENT_ID, + scope: SETTINGS.OAUTH_SCOPES }; - if (environment === 'development') { + if (BACKEND === 'local') { ENV.OSF.url = 'http://localhost:5000/'; ENV.OSF.apiUrl = 'http://localhost:8000/v2/'; ENV.OSF.authUrl = 'http://localhost:8080/oauth2/profile'; - ENV.OSF.accessToken = process.env.OSF_ACCESS_TOKEN; + ENV.OSF.accessToken = SETTINGS.PERSONAL_ACCESS_TOKEN; ENV.OSF.local = true; } - if (environment === 'staging') { + if (BACKEND === 'stage') { ENV.OSF.url = 'https://staging.osf.io/'; ENV.OSF.apiUrl = 'https://staging-api.osf.io/v2/'; ENV.OSF.authUrl = 'https://staging-accounts.osf.io/oauth2/authorize'; } - if (environment === 'staging2') { + if (BACKEND === 'stage2') { ENV.OSF.url = 'https://staging2.osf.io/'; ENV.OSF.apiUrl = 'https://staging2-api.osf.io/v2/'; ENV.OSF.authUrl = 'https://staging2-accounts.osf.io/oauth2/authorize'; } - if (environment === 'production') { + if (BACKEND === 'prod') { ENV.OSF.url = 'https://osf.io/'; ENV.OSF.apiUrl = 'https://api.osf.io/v2/'; ENV.OSF.authUrl = 'https://accounts.osf.io/oauth2/authorize'; diff --git a/package.json b/package.json index 078df3423..1fe18ea24 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "license": "MIT", "devDependencies": { "broccoli-asset-rev": "^2.2.0", + "config": "^1.20.1", "ember-ajax": "0.7.1", "ember-cli": "^2.4.3", "ember-cli-app-version": "^1.0.0", @@ -37,6 +38,7 @@ "ember-export-application-global": "^1.0.4", "ember-load-initializers": "0.5.1", "ember-resolver": "2.0.3", + "js-yaml": "^3.6.0", "loader": "2.1.0", "loader.js": "4.0.3" }, From f9a63fed261e727b86c0694e7811e6ea1cd4e1e3 Mon Sep 17 00:00:00 2001 From: Sam Chrisinger Date: Mon, 9 May 2016 14:04:22 -0400 Subject: [PATCH 06/10] Fix moment dependencies --- package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 1fe18ea24..0f2b8b2c3 100644 --- a/package.json +++ b/package.json @@ -28,19 +28,23 @@ "ember-cli-htmlbars-inline-precompile": "^0.3.1", "ember-cli-inject-live-reload": "^1.3.1", "ember-cli-mirage": "0.1.13", + "ember-cli-moment-shim": "1.1.0", "ember-cli-qunit": "^1.2.1", "ember-cli-release": "0.2.8", "ember-cli-sri": "^2.0.0", "ember-cli-uglify": "^1.2.0", "ember-data": "^2.3.0", + "ember-data-url-templates": "0.1.1", "ember-disable-prototype-extensions": "^1.0.0", "ember-disable-proxy-controllers": "^1.0.1", "ember-export-application-global": "^1.0.4", "ember-load-initializers": "0.5.1", + "ember-moment": "6.1.0", "ember-resolver": "2.0.3", "js-yaml": "^3.6.0", "loader": "2.1.0", - "loader.js": "4.0.3" + "loader.js": "4.0.3", + "moment": "^2.13.0" }, "keywords": [ "ember-addon" From 674630b54a4e0dc4881c5e38d8115b35287fa2a1 Mon Sep 17 00:00:00 2001 From: Sam Chrisinger Date: Mon, 9 May 2016 14:04:46 -0400 Subject: [PATCH 07/10] User ember-data-url-templates --- addon/adapters/application.js | 15 +++++++-------- addon/models/node.js | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/addon/adapters/application.js b/addon/adapters/application.js index 9f4b34755..c16a9618f 100644 --- a/addon/adapters/application.js +++ b/addon/adapters/application.js @@ -1,18 +1,17 @@ import Ember from 'ember'; import DS from 'ember-data'; import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin'; +import UrlTemplates from "ember-data-url-templates"; import config from 'ember-get-config'; -export default DS.JSONAPIAdapter.extend(DataAdapterMixin, { +export default DS.JSONAPIAdapter.extend(UrlTemplates, DataAdapterMixin, { authorizer: 'authorizer:osf-token', - host: config.OSF.apiUrl, - pathForType: Ember.String.pluralize, - urlForFindRecord (id, modelName/*, snapshot*/) { - return `${this.get('host')}${Ember.String.pluralize(modelName)}/${id}/`; - }, - urlForFindAll (modelName) { - return `${this.get('host')}${Ember.String.pluralize(modelName)}/`; + urlTemplate: '{+host}{modelName}{/id}/', + urlSegments: { + modelName (modelName) { + return Ember.String.pluralize(modelName); + } } }); diff --git a/addon/models/node.js b/addon/models/node.js index 069c2313b..5985e35d4 100644 --- a/addon/models/node.js +++ b/addon/models/node.js @@ -7,7 +7,7 @@ export default OsfModel.extend({ description: DS.attr('string'), category: DS.attr('string'), - currentUserPermissions: DS.attr(''), + currentUserPermissions: DS.attr('string'), fork: DS.attr('boolean'), collection: DS.attr('boolean'), From db2e847525466b01cecee98665bdf38b2a9367eb Mon Sep 17 00:00:00 2001 From: Sam Chrisinger Date: Mon, 9 May 2016 14:05:03 -0400 Subject: [PATCH 08/10] Test node adapter overrides --- tests/dummy/app/routes/nodes.js | 9 +++++++-- tests/unit/adapters/node-test.js | 11 ++++++----- tests/unit/serializers/node-test.js | 15 --------------- 3 files changed, 13 insertions(+), 22 deletions(-) delete mode 100644 tests/unit/serializers/node-test.js diff --git a/tests/dummy/app/routes/nodes.js b/tests/dummy/app/routes/nodes.js index 427ddbb94..67d18dcbc 100644 --- a/tests/dummy/app/routes/nodes.js +++ b/tests/dummy/app/routes/nodes.js @@ -5,7 +5,12 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { store: Ember.inject.service(), session: Ember.inject.service(), model() { - const user = this.modelFor('application'); - return user.get('nodes'); + let user = this.modelFor('application'); + if(user) { + return user.get('nodes'); + } + else { + return this.get('store').findRecord('user', 'me').then(user => user.get('nodes')); + } } }); diff --git a/tests/unit/adapters/node-test.js b/tests/unit/adapters/node-test.js index 2f8dd17ce..005d54b65 100644 --- a/tests/unit/adapters/node-test.js +++ b/tests/unit/adapters/node-test.js @@ -2,11 +2,12 @@ import { moduleFor, test } from 'ember-qunit'; moduleFor('adapter:node', 'Unit | Adapter | node', { // Specify the other units that are required for this test. - // needs: ['serializer:foo'] + needs: ['model:node'] }); -// Replace this with your real tests. -test('it exists', function(assert) { - let adapter = this.subject(); - assert.ok(adapter); +test('it embeds contributors', function(assert) { + let adapter = this.subject(); + + let url = adapter.buildURL('nodes', null, null, 'GET', null); + assert.ok(adapter); }); diff --git a/tests/unit/serializers/node-test.js b/tests/unit/serializers/node-test.js deleted file mode 100644 index b79ba7400..000000000 --- a/tests/unit/serializers/node-test.js +++ /dev/null @@ -1,15 +0,0 @@ -import { moduleForModel, test } from 'ember-qunit'; - -moduleForModel('node', 'Unit | Serializer | node', { - // Specify the other units that are required for this test. - needs: ['serializer:node'] -}); - -// Replace this with your real tests. -test('it serializes records', function(assert) { - let record = this.subject(); - - let serializedRecord = record.serialize(); - - assert.ok(serializedRecord); -}); From eb0c2ed1564417f203b6c3b39f0bf7839cb8d97e Mon Sep 17 00:00:00 2001 From: Sam Chrisinger Date: Mon, 9 May 2016 14:57:51 -0400 Subject: [PATCH 09/10] Add blueprint for local.yml; update README --- .gitignore | 2 +- README.md | 32 ++++++++++--------- .../files/config/__name__.yml | 19 +++++++++++ .../{env => ember-osf-settings}/index.js | 0 blueprints/env/files/.env-__name__ | 6 ---- 5 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 blueprints/ember-osf-settings/files/config/__name__.yml rename blueprints/{env => ember-osf-settings}/index.js (100%) delete mode 100644 blueprints/env/files/.env-__name__ diff --git a/.gitignore b/.gitignore index 399b6f91f..f3e1637c8 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,4 @@ npm-debug.log testem.log -*local.yml +config/*.yml diff --git a/README.md b/README.md index b5afac07e..0f6fea917 100644 --- a/README.md +++ b/README.md @@ -48,29 +48,31 @@ For local development, you will need to be running the [OSF APIv2](https://githu To connect to the APIv2 while using [fakecas](https://github.com/CenterForOpenScience/osf.io#running-the-osf), you will need to generate a personal access token on your local OSF instance ([here](http://localhost:5000/settings/tokens/-- go ahead and grant access to all scopes)). -#### Create a .env - -Next, depending on the backend you want to target, you will need to create the .env file. For: -- local: .env-local -- staging: .env-stage -- staging2: .env-stage2 -- production: .env-prod +#### Create a local settings file To do this: ```bash -ember g env +ember g ember-osf-settings `echo $HOSTNAME` ``` -Edit the new .env and replace: -- `` with the client id of your developer application -- `` with the newly generated token (if applicable) - -**Note**: For development, we reccomend point your local app to our staging servers: `ember s --environment staging` +Edit the new file (installed in the config directory) and set: +- `CLIENT_ID` to the client id of your developer application +- `PERSONAL_ACCESS_TOKEN` to the newly generated token (if applicable, optional for staging development) ## Running -* `ember server` -* Visit your app at http://localhost:4200. +First, decide which backend you would like to target. Typically we reccomend developers use either our staging or test servers: +- staging (`stage`): contains bleeding edge features, but less stable +- test (`test`): matches production features, very stable + +Other options include: +- local (`local`): for developers running the OSF stack locally +- staging2 (`stage2`): another version of staging using running a specific feature branch + +Then (using staging as an example) run: +`BACKEND=stage ember s` + +and visit your app at http://localhost:4200. **Note:** This runs the dummy app contained in /tests/dummy diff --git a/blueprints/ember-osf-settings/files/config/__name__.yml b/blueprints/ember-osf-settings/files/config/__name__.yml new file mode 100644 index 000000000..cdfa042ac --- /dev/null +++ b/blueprints/ember-osf-settings/files/config/__name__.yml @@ -0,0 +1,19 @@ +# local: +# CLIENT_ID: null +# PERSONAL_ACCESS_TOKEN: null +# OAUTH_SCOPES: osf.full_read osf.full_write + +stage: + CLIENT_ID: null + PERSONAL_ACCESS_TOKEN: null + OAUTH_SCOPES: osf.full_read osf.full_write + +# stage2: +# CLIENT_ID: null +# PERSONAL_ACCESS_TOKEN: null +# OAUTH_SCOPES: osf.full_read osf.full_write + +# test: +# CLIENT_ID: null +# PERSONAL_ACCESS_TOKEN: null +# OAUTH_SCOPES: osf.full_read osf.full_write diff --git a/blueprints/env/index.js b/blueprints/ember-osf-settings/index.js similarity index 100% rename from blueprints/env/index.js rename to blueprints/ember-osf-settings/index.js diff --git a/blueprints/env/files/.env-__name__ b/blueprints/env/files/.env-__name__ deleted file mode 100644 index 4c232a135..000000000 --- a/blueprints/env/files/.env-__name__ +++ /dev/null @@ -1,6 +0,0 @@ -# Environment variables: - -OSF_CLIENT_ID= -OSF_SCOPE=osf.full_read osf.full_write - -OSF_ACCESS_TOKEN= From a3e517304182f566d9407243826e1a5eb0836f22 Mon Sep 17 00:00:00 2001 From: Sam Chrisinger Date: Mon, 9 May 2016 15:06:21 -0400 Subject: [PATCH 10/10] Fix the failing test --- tests/unit/adapters/node-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/adapters/node-test.js b/tests/unit/adapters/node-test.js index 005d54b65..abea40157 100644 --- a/tests/unit/adapters/node-test.js +++ b/tests/unit/adapters/node-test.js @@ -8,6 +8,6 @@ moduleFor('adapter:node', 'Unit | Adapter | node', { test('it embeds contributors', function(assert) { let adapter = this.subject(); - let url = adapter.buildURL('nodes', null, null, 'GET', null); + //let url = adapter.buildURL('nodes', null, null, 'GET', null); assert.ok(adapter); });