Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show versions that are active when delete_version_after is configured #7685

Merged
merged 1 commit into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ui/app/models/secret-v2-version.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Secret from './secret';
import DS from 'ember-data';
import { bool } from '@ember/object/computed';
import { computed } from '@ember/object';

const { attr, belongsTo } = DS;

Expand All @@ -12,7 +12,11 @@ export default Secret.extend({
path: attr('string'),
deletionTime: attr('string'),
createdTime: attr('string'),
deleted: bool('deletionTime'),
deleted: computed('deletionTime', function() {
const deletionTime = new Date(this.get('deletionTime'));
const now = new Date();
return deletionTime <= now;
}),
destroyed: attr('boolean'),
currentVersion: attr('number'),
});
31 changes: 31 additions & 0 deletions ui/tests/unit/models/secret-v2-version-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { run } from '@ember/runloop';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('Unit | Model | secret-v2-version', function(hooks) {
setupTest(hooks);

test('deleted is true for a past deletionTime', function(assert) {
let model;
run(() => {
model = run(() =>
this.owner.lookup('service:store').createRecord('secret-v2-version', {
deletionTime: '2000-10-14T00:00:00.000000Z',
})
);
assert.equal(model.get('deleted'), true);
});
});

test('deleted is false for a future deletionTime', function(assert) {
let model;
run(() => {
model = run(() =>
this.owner.lookup('service:store').createRecord('secret-v2-version', {
deletionTime: '2999-10-14T00:00:00.000000Z',
})
);
assert.equal(model.get('deleted'), false);
});
});
});