summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-02-26 22:17:50 -0800
committerStan Hu <stanhu@gmail.com>2019-02-26 23:01:09 -0800
commit43ac2a964ffe5f2713cb3093b4192216ec8525ad (patch)
tree2bcf0a78410dda2e8fc76885442c1b56d599d9b6
parent7765e6ec108f1c159e5b38d2048d4095861f6288 (diff)
downloadgitlab-ce-43ac2a964ffe5f2713cb3093b4192216ec8525ad.tar.gz
Add pagination spec and improve filtering of null values
-rw-r--r--app/assets/javascripts/environments/mixins/environments_mixin.js8
-rw-r--r--spec/features/projects/environments/environments_spec.rb17
2 files changed, 23 insertions, 2 deletions
diff --git a/app/assets/javascripts/environments/mixins/environments_mixin.js b/app/assets/javascripts/environments/mixins/environments_mixin.js
index 49b36143d17..9d83840c87c 100644
--- a/app/assets/javascripts/environments/mixins/environments_mixin.js
+++ b/app/assets/javascripts/environments/mixins/environments_mixin.js
@@ -44,8 +44,8 @@ export default {
this.isLoading = false;
// Prevent the absence of the nested flag from causing mismatches
- const response = _.omit(resp.config.params, _.isUndefined);
- const request = _.omit(this.requestData, _.isUndefined);
+ const response = this.filterNilValues(resp.config.params);
+ const request = this.filterNilValues(this.requestData);
if (_.isEqual(response, request)) {
this.store.storeAvailableCount(resp.data.available_count);
@@ -55,6 +55,10 @@ export default {
}
},
+ filterNilValues(obj) {
+ return _.omit(obj, value => _.isUndefined(value) || _.isNull(value));
+ },
+
/**
* Handles URL and query parameter changes.
* When the user uses the pagination or the tabs,
diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb
index 0c517d5f490..66c6545204b 100644
--- a/spec/features/projects/environments/environments_spec.rb
+++ b/spec/features/projects/environments/environments_spec.rb
@@ -38,6 +38,23 @@ describe 'Environments page', :js do
end
end
+ describe 'with environments spanning multiple pages', :js do
+ before do
+ allow(Kaminari.config).to receive(:default_per_page).and_return(3)
+ create_list(:environment, 4, project: project, state: :available)
+ end
+
+ it 'should render second page of pipelines' do
+ visit_environments(project, scope: 'available')
+
+ find('.js-next-button').click
+ wait_for_requests
+
+ expect(page).to have_selector('.gl-pagination .page', count: 2)
+ expect(find('.gl-pagination .page-item.active .page-link').text).to eq("2")
+ end
+ end
+
describe 'in stopped tab page' do
it 'should show no environments' do
visit_environments(project, scope: 'stopped')