Skip to content

Commit

Permalink
Merge branch 'hotfix/0.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mfraezz committed Mar 1, 2018
2 parents 313aa8f + 13cf21f commit a674ada
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 10 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.3.1] - 2018-03-01
### Added
- Tests for download URL for branded and un-branded providers

### Fixed
- Download URL on preprint-detail page to work for admin and moderators on pre-moderation

## [0.3.0] - 2018-01-10
### Changed
- Update `action` to `review-action` to reflect changes in OSF's API and ember-osf
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/preprints/provider/preprint-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default Controller.extend({
i18n: service(),
theme: service(),
toast: service(),
store: service(),

queryParams: { chosenFile: 'file' },

Expand All @@ -49,11 +50,12 @@ export default Controller.extend({
},
}),

fileDownloadURL: computed('model', function() {
fileDownloadURL: computed('preprint', function() {
const { location: { origin } } = window;
return [
origin,
this.get('model.id'),
this.get('theme.id') !== 'osf' ? `preprints/${this.get('theme.id')}` : null,
this.get('preprint.id'),
'download',
].filter(part => !!part).join('/');
}),
Expand Down
52 changes: 44 additions & 8 deletions tests/unit/controllers/preprints/provider/preprint-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,28 +280,64 @@ test('submitDecision action', function (assert) {
});
});

test('fileDownloadURL computed property', function (assert) {
test('fileDownloadURL computed property - non-branded provider', function (assert) {
this.inject.service('store');
this.inject.service('theme');

this.theme.id = 'osf';

const ctrl = this.subject();

run(() => {
const origin = 'http://localhost:4200';
const provider = this.store.createRecord('preprint-provider', {
name: 'osf',
reviewsWorkflow: 'pre-moderation',
});

const window = { location: { origin } };
const node = this.store.createRecord('node', {
description: 'test description',
});

ctrl.set('window', window);
const preprint = this.store.createRecord('preprint', {
provider,
node,
});

ctrl.setProperties({ preprint });
ctrl.set('preprint.id', '6gtu');

assert.strictEqual(ctrl.get('fileDownloadURL'), 'http://localhost:4201/6gtu/download');
});
});

test('fileDownloadURL computed property - branded provider', function(assert) {
this.inject.service('store');
this.inject.service('theme');

this.theme.id = 'engrxiv';

const ctrl = this.subject();

run(() => {
const provider = this.store.createRecord('preprint-provider', {
name: 'engrxiv',
reviewsWorkflow: 'pre-moderation',
});

const node = this.store.createRecord('node', {
description: 'test description',
});

const model = this.store.createRecord('preprint', { node });
const preprint = this.store.createRecord('preprint', {
provider,
node,
});

ctrl.setProperties({ model });
ctrl.set('model.id', '6gtu');
ctrl.setProperties({ preprint });
ctrl.set('preprint.id', '6gtu');

assert.strictEqual(ctrl.get('fileDownloadURL'), 'http://localhost:4201/6gtu/download');
const { location: { origin } } = window;

assert.strictEqual(ctrl.get('fileDownloadURL'), `${origin}/preprints/engrxiv/6gtu/download`);
});
});

0 comments on commit a674ada

Please sign in to comment.