Commit 62919a17 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Update tests and associations

parent b828a98c
...@@ -13,15 +13,16 @@ class PipelineSerializer < BaseSerializer ...@@ -13,15 +13,16 @@ class PipelineSerializer < BaseSerializer
def represent(resource, opts = {}) def represent(resource, opts = {})
if resource.is_a?(ActiveRecord::Relation) if resource.is_a?(ActiveRecord::Relation)
resource = resource.includes(:project)
resource = resource.includes(:pending_builds, resource = resource.includes(:pending_builds,
:retryable_builds, :retryable_builds,
:cancelable_statuses, :cancelable_statuses,
:manual_actions, :manual_actions,
:artifacts) :artifacts,
:trigger_requests)
resource = resource.includes(pending_builds: :project) resource = resource.includes(pending_builds: :project)
resource = resource.includes(manual_actions: :project) resource = resource.includes(project: :namespace)
resource = resource.includes(artifacts: :project) resource = resource.includes(manual_actions: { project: :namespace })
resource = resource.includes(artifacts: { project: :namespace })
end end
if paginated? if paginated?
......
...@@ -101,6 +101,13 @@ describe PipelineSerializer do ...@@ -101,6 +101,13 @@ describe PipelineSerializer do
Ci::Pipeline::AVAILABLE_STATUSES.each do |status| Ci::Pipeline::AVAILABLE_STATUSES.each do |status|
create_pipeline(status) create_pipeline(status)
end end
RequestStore.begin!
end
after do
RequestStore.end!
RequestStore.clear!
end end
it "verifies number of queries" do it "verifies number of queries" do
......
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