Commit 66d03aae authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Fixed error handling

parent 98f59fc2
/* eslint-disable */
function droplabAjaxException(message) {
this.message = message;
}
const Ajax = {
_loadUrlData: function _loadUrlData(url) {
var self = this;
......@@ -58,9 +54,7 @@ const Ajax = {
this._loadUrlData(config.endpoint)
.then(function(d) {
self._loadData(d, config, self);
}, config.onError).catch(function(e) {
throw new droplabAjaxException(e.message || e);
});
}, config.onError).catch(config.onError);
}
},
destroy: function() {
......
......@@ -68,7 +68,7 @@ const AjaxFilter = {
this._loadUrlData(url)
.then(function(data) {
self._loadData(data, config, self);
}, config.onError);
}, config.onError).catch(config.onError);
}
},
......
/* global Flash */
import Ajax from '~/droplab/plugins/ajax';
import Filter from '~/droplab/plugins/filter';
......@@ -13,6 +15,11 @@ require('./filtered_search_dropdown');
endpoint,
method: 'setData',
loadingTemplate: this.loadingTemplate,
onError() {
/* eslint-disable no-new */
new Flash('An error occured fetching the dropdown data.');
/* eslint-enable no-new */
},
},
Filter: {
filterFunction: gl.DropdownUtils.filterWithSymbol.bind(null, this.symbol, input),
......
/* global Flash */
import AjaxFilter from '~/droplab/plugins/ajax_filter';
require('./filtered_search_dropdown');
......@@ -18,6 +20,11 @@ require('./filtered_search_dropdown');
},
searchValueFunction: this.getSearchInput.bind(this),
loadingTemplate: this.loadingTemplate,
onError() {
/* eslint-disable no-new */
new Flash('An error occured fetching the dropdown data.');
/* eslint-enable no-new */
},
},
};
}
......
......@@ -65,7 +65,7 @@ describe 'Dropdown milestone', :feature, :js do
it 'should load all the milestones when opened' do
filtered_search.set('milestone:')
expect(dropdown_milestone_size).to be > 0
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 6)
end
end
......@@ -84,37 +84,37 @@ describe 'Dropdown milestone', :feature, :js do
it 'filters by name' do
filtered_search.send_keys('v1')
expect(dropdown_milestone_size).to eq(1)
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
end
it 'filters by case insensitive name' do
filtered_search.send_keys('V1')
expect(dropdown_milestone_size).to eq(1)
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
end
it 'filters by name with symbol' do
filtered_search.send_keys('%v1')
expect(dropdown_milestone_size).to eq(1)
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
end
it 'filters by case insensitive name with symbol' do
filtered_search.send_keys('%V1')
expect(dropdown_milestone_size).to eq(1)
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
end
it 'filters by special characters' do
filtered_search.send_keys('(+')
expect(dropdown_milestone_size).to eq(1)
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
end
it 'filters by special characters with symbol' do
filtered_search.send_keys('%(+')
expect(dropdown_milestone_size).to eq(1)
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment