summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-06 13:42:18 +0100
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-06 13:42:18 +0100
commit66d03aae98cc0429d2ed75eac68025f447868479 (patch)
tree859cef0576726f1ecd7a6c0d4bc14c560ebe4f84
parent98f59fc20fdab2e4d0f8f06d615abb3922d766cb (diff)
downloadgitlab-ce-66d03aae98cc0429d2ed75eac68025f447868479.tar.gz
Fixed error handling
-rw-r--r--app/assets/javascripts/droplab/plugins/ajax.js8
-rw-r--r--app/assets/javascripts/droplab/plugins/ajax_filter.js2
-rw-r--r--app/assets/javascripts/filtered_search/dropdown_non_user.js7
-rw-r--r--app/assets/javascripts/filtered_search/dropdown_user.js7
-rw-r--r--spec/features/issues/filtered_search/dropdown_milestone_spec.rb14
5 files changed, 23 insertions, 15 deletions
diff --git a/app/assets/javascripts/droplab/plugins/ajax.js b/app/assets/javascripts/droplab/plugins/ajax.js
index f08b638fc62..12afe53ed76 100644
--- a/app/assets/javascripts/droplab/plugins/ajax.js
+++ b/app/assets/javascripts/droplab/plugins/ajax.js
@@ -1,9 +1,5 @@
/* 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() {
diff --git a/app/assets/javascripts/droplab/plugins/ajax_filter.js b/app/assets/javascripts/droplab/plugins/ajax_filter.js
index 7fe221e101f..cfd7e2ca189 100644
--- a/app/assets/javascripts/droplab/plugins/ajax_filter.js
+++ b/app/assets/javascripts/droplab/plugins/ajax_filter.js
@@ -68,7 +68,7 @@ const AjaxFilter = {
this._loadUrlData(url)
.then(function(data) {
self._loadData(data, config, self);
- }, config.onError);
+ }, config.onError).catch(config.onError);
}
},
diff --git a/app/assets/javascripts/filtered_search/dropdown_non_user.js b/app/assets/javascripts/filtered_search/dropdown_non_user.js
index 35c76dff79a..6296965b911 100644
--- a/app/assets/javascripts/filtered_search/dropdown_non_user.js
+++ b/app/assets/javascripts/filtered_search/dropdown_non_user.js
@@ -1,3 +1,5 @@
+/* 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),
diff --git a/app/assets/javascripts/filtered_search/dropdown_user.js b/app/assets/javascripts/filtered_search/dropdown_user.js
index 4f9f25c1f1b..38b5d315bcf 100644
--- a/app/assets/javascripts/filtered_search/dropdown_user.js
+++ b/app/assets/javascripts/filtered_search/dropdown_user.js
@@ -1,3 +1,5 @@
+/* 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 */
+ },
},
};
}
diff --git a/spec/features/issues/filtered_search/dropdown_milestone_spec.rb b/spec/features/issues/filtered_search/dropdown_milestone_spec.rb
index ce96a420699..cf5259b878d 100644
--- a/spec/features/issues/filtered_search/dropdown_milestone_spec.rb
+++ b/spec/features/issues/filtered_search/dropdown_milestone_spec.rb
@@ -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