diff --git a/app/services/ci/collect_pipeline_analytics_service_base.rb b/app/services/ci/collect_pipeline_analytics_service_base.rb index 121a62df906758ecbef0291c0b5e707a5519244e..91afdf22ec2d4e03c9c99c28db8beb7827e29ca9 100644 --- a/app/services/ci/collect_pipeline_analytics_service_base.rb +++ b/app/services/ci/collect_pipeline_analytics_service_base.rb @@ -38,7 +38,7 @@ def execute private def allowed? - current_user&.can?(:read_ci_cd_analytics, container) + Ability.allowed?(current_user, :read_ci_cd_analytics, container) end def clickhouse_model diff --git a/spec/graphql/resolvers/ci/pipeline_analytics_resolver_spec.rb b/spec/graphql/resolvers/ci/pipeline_analytics_resolver_spec.rb index 5d4b462a447c980dfda4d043930e66079293f6f4..30707d837b7ce91d05cbd6e26ec2eacd7a841426 100644 --- a/spec/graphql/resolvers/ci/pipeline_analytics_resolver_spec.rb +++ b/spec/graphql/resolvers/ci/pipeline_analytics_resolver_spec.rb @@ -119,6 +119,12 @@ def resolve_statistics(container, args) project.update!(public_builds: true) end + context 'when user is anonymous' do + let(:current_user) { nil } + + it_behaves_like 'returns the pipeline analytics for a given container' + end + context 'when user is not a member' do let(:current_user) { create(:user) }