Skip to content

Commit

Permalink
use an array to lookup capabilities paths so that commas aren't an is…
Browse files Browse the repository at this point in the history
…sue (#4398)
  • Loading branch information
meirish authored Apr 20, 2018
1 parent 2cca855 commit 1ad67cb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ui/app/adapters/capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default ApplicationAdapter.extend({
},

findRecord(store, type, id) {
return this.ajax(this.buildURL(type), 'POST', { data: { path: id } }).catch(e => {
return this.ajax(this.buildURL(type), 'POST', { data: { paths: [id] } }).catch(e => {
if (e instanceof DS.AdapterError) {
Ember.set(e, 'policyPath', 'sys/capabilities-self');
}
Expand Down
17 changes: 17 additions & 0 deletions ui/tests/acceptance/policies-acl-old-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,20 @@ test('policies', function(assert) {
);
});
});

test('it properly fetches policies when the name ends in a ,', function(assert) {
const policyString = 'path "*" { capabilities = ["update"]}';
const policyName = `symbol,.`;

page.visit({ type: 'acl' });
// new policy creation
click('[data-test-policy-create-link]');
fillIn('[data-test-policy-input="name"]', policyName);
andThen(() => {
find('.CodeMirror').get(0).CodeMirror.setValue(policyString);
});
click('[data-test-policy-save]');
andThen(() => {
assert.equal(find('[data-test-policy-edit-toggle]').length, 1, 'shows the edit toggle');
});
});
2 changes: 1 addition & 1 deletion ui/tests/unit/adapters/capabilities-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ test('calls the correct url', function(assert) {

adapter.findRecord(null, 'capabilities', 'foo');
assert.equal('/v1/sys/capabilities-self', url, 'calls the correct URL');
assert.deepEqual({ path: 'foo' }, options.data, 'data params OK');
assert.deepEqual({ paths: ['foo'] }, options.data, 'data params OK');
assert.equal('POST', method, 'method OK');
});

0 comments on commit 1ad67cb

Please sign in to comment.