diff options
Diffstat (limited to 'spec/helpers/routing/pseudonymization_helper_spec.rb')
-rw-r--r-- | spec/helpers/routing/pseudonymization_helper_spec.rb | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/spec/helpers/routing/pseudonymization_helper_spec.rb b/spec/helpers/routing/pseudonymization_helper_spec.rb index 10563502555..a28a86d1f53 100644 --- a/spec/helpers/routing/pseudonymization_helper_spec.rb +++ b/spec/helpers/routing/pseudonymization_helper_spec.rb @@ -6,6 +6,7 @@ RSpec.describe ::Routing::PseudonymizationHelper do let_it_be(:group) { create(:group) } let_it_be(:subgroup) { create(:group, parent: group) } let_it_be(:project) { create(:project, group: group) } + let_it_be(:subproject) { create(:project, group: subgroup) } let_it_be(:issue) { create(:issue, project: project) } let(:merge_request) { create(:merge_request, source_project: project) } @@ -56,16 +57,16 @@ RSpec.describe ::Routing::PseudonymizationHelper do end context 'with controller for groups with subgroups and project' do - let(:masked_url) { "http://test.host/namespace:#{subgroup.id}/project:#{project.id}"} + let(:masked_url) { "http://test.host/namespace:#{subgroup.id}/project:#{subproject.id}"} before do allow(helper).to receive(:group).and_return(subgroup) - allow(helper.project).to receive(:namespace).and_return(subgroup) + allow(helper).to receive(:project).and_return(subproject) allow(Rails.application.routes).to receive(:recognize_path).and_return({ controller: 'projects', action: 'show', namespace_id: subgroup.name, - id: project.name + id: subproject.name }) end @@ -129,6 +130,29 @@ RSpec.describe ::Routing::PseudonymizationHelper do end end + describe 'when it raises exception' do + context 'calls error tracking' do + before do + controller.request.path = '/dashboard/issues' + controller.request.query_string = 'assignee_username=root' + allow(Rails.application.routes).to receive(:recognize_path).and_return({ + controller: 'dashboard', + action: 'issues' + }) + end + + it 'sends error to sentry and returns nil' do + allow(helper).to receive(:mask_params).with(anything).and_raise(ActionController::RoutingError, 'Some routing error') + + expect(Gitlab::ErrorTracking).to receive(:track_exception).with( + ActionController::RoutingError, + url: '/dashboard/issues?assignee_username=root').and_call_original + + expect(helper.masked_page_url).to be_nil + end + end + end + describe 'when feature flag is disabled' do before do stub_feature_flags(mask_page_urls: false) |