refactor: 💡 Remove session recording type check and update name (#179)
This commit is contained in:
1 parent
62ec3fe914
commit
811025bccb
4 files changed
+5
-46
No files matched your search
@@ -14,7 +14,7 @@ export default class ChannelRecordingAbility extends ModelAbility {
|
||||
@service abilities;
|
||||
|
||||
// =permissions
|
||||
get canDownloadAsciicast() {
|
||||
get canGetAsciicast() {
|
||||
const sessionRecording = this.model.connection_recording.session_recording;
|
||||
const sessionRecordingAbility = this.abilities.abilityFor(
|
||||
'session-recording',
|
||||
|
||||
@@ -29,6 +29,6 @@ export default class SessionRecordingAbility extends ModelAbility {
|
||||
}
|
||||
|
||||
get canDownload() {
|
||||
return this.model.isSSH && this.hasAuthorizedAction('download');
|
||||
return this.hasAuthorizedAction('download');
|
||||
}
|
||||
}
|
||||
@@ -38,10 +38,7 @@ module('Unit | Ability | channel-recording', function (hooks) {
|
||||
});
|
||||
|
||||
assert.true(
|
||||
canService.can(
|
||||
'downloadAsciicast channel-recording',
|
||||
channelRecordingModel
|
||||
)
|
||||
canService.can('getAsciicast channel-recording', channelRecordingModel)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -64,10 +61,7 @@ module('Unit | Ability | channel-recording', function (hooks) {
|
||||
});
|
||||
|
||||
assert.false(
|
||||
canService.can(
|
||||
'downloadAsciicast channel-recording',
|
||||
channelRecordingModel
|
||||
)
|
||||
canService.can('getAsciicast channel-recording', channelRecordingModel)
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,5 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import { TYPE_SESSION_RECORDING_SSH } from 'api/models/session-recording';
|
||||
|
||||
module('Unit | Ability | session-recording', function (hooks) {
|
||||
setupTest(hooks);
|
||||
@@ -18,21 +17,19 @@ module('Unit | Ability | session-recording', function (hooks) {
|
||||
assert.ok(ability);
|
||||
});
|
||||
|
||||
test('can download when an ssh recording has download authorization', function (assert) {
|
||||
test('can download when a recording has download authorization', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
const recordingWithAuthorizedAction = store.createRecord(
|
||||
'session-recording',
|
||||
{
|
||||
authorized_actions: ['download'],
|
||||
type: TYPE_SESSION_RECORDING_SSH,
|
||||
}
|
||||
);
|
||||
const recordingWithoutAuthorizedAction = store.createRecord(
|
||||
'session-recording',
|
||||
{
|
||||
authorized_actions: [],
|
||||
type: TYPE_SESSION_RECORDING_SSH,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -49,36 +46,4 @@ module('Unit | Ability | session-recording', function (hooks) {
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
test('cannot download when a recording is not ssh type', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
const recordingWithAuthorizedAction = store.createRecord(
|
||||
'session-recording',
|
||||
{
|
||||
authorized_actions: ['download'],
|
||||
type: 'unknown',
|
||||
}
|
||||
);
|
||||
const recordingWithoutAuthorizedAction = store.createRecord(
|
||||
'session-recording',
|
||||
{
|
||||
authorized_actions: [],
|
||||
type: 'unknown',
|
||||
}
|
||||
);
|
||||
|
||||
assert.false(
|
||||
canService.can(
|
||||
'download session-recording',
|
||||
recordingWithAuthorizedAction
|
||||
)
|
||||
);
|
||||
assert.false(
|
||||
canService.can(
|
||||
'download session-recording',
|
||||
recordingWithoutAuthorizedAction
|
||||
)
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user