Commit c078c0a7 authored by Marc Shaw's avatar Marc Shaw

Merge branch '353992-fix-dashboard-filter-check' into 'master'

Fix filters presence check to take value into consideration

See merge request gitlab-org/gitlab!82462
parents cb83bdef 1b9dbdc9
......@@ -71,8 +71,8 @@ class DashboardController < Dashboard::ApplicationController
end
def check_filters_presence!
no_scalar_filters_set = finder_type.scalar_params.none? { |k| params.key?(k) }
no_array_filters_set = finder_type.array_params.none? { |k, _| params.key?(k) }
no_scalar_filters_set = finder_type.scalar_params.none? { |k| params[k].present? }
no_array_filters_set = finder_type.array_params.none? { |k, _| params[k].present? }
@no_filters_set = no_scalar_filters_set && no_array_filters_set
......
......@@ -98,11 +98,21 @@ RSpec.describe DashboardController do
context "no filters" do
let(:params) { {} }
it 'sets @no_filters_set to false' do
shared_examples_for 'no filters are set' do
it 'sets @no_filters_set to true' do
expect(assigns[:no_filters_set]).to eq(true)
end
end
it_behaves_like 'no filters are set'
context 'when key is present but value is not' do
let(:params) { { author_username: nil } }
it_behaves_like 'no filters are set'
end
end
context "scalar filters" do
let(:params) { { author_id: user.id } }
......
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