Fix Geo::Fdw::GeoNode#job_artifacts guard clause

parent 75a095fe
...@@ -27,7 +27,7 @@ module Geo ...@@ -27,7 +27,7 @@ module Geo
end end
def job_artifacts def job_artifacts
Geo::Fdw::Ci::JobArtifact.all unless selective_sync? return Geo::Fdw::Ci::JobArtifact.all unless selective_sync?
query = Geo::Fdw::Ci::JobArtifact.project_id_in(projects).select(:id) query = Geo::Fdw::Ci::JobArtifact.project_id_in(projects).select(:id)
cte = Gitlab::SQL::CTE.new(:restricted_job_artifacts, query) cte = Gitlab::SQL::CTE.new(:restricted_job_artifacts, query)
......
...@@ -131,4 +131,24 @@ RSpec.describe Geo::Fdw::GeoNode, :geo, type: :model do ...@@ -131,4 +131,24 @@ RSpec.describe Geo::Fdw::GeoNode, :geo, type: :model do
end end
end end
end end
describe '#job_artifacts', :geo_fdw do
subject { described_class.find(node.id) }
context 'when selective sync is enabled' do
it 'applies a CTE statement' do
node.update!(selective_sync_type: 'namespaces')
expect(subject.job_artifacts.to_sql).to match(/WITH .+restricted_job_artifacts/)
end
end
context 'when selective sync is disabled' do
it 'doest not apply a CTE statement' do
node.update!(selective_sync_type: nil)
expect(subject.job_artifacts.to_sql).not_to match(/WITH .+restricted_job_artifacts/)
end
end
end
end end
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