From e14fa80c5a15ac779883adbba4cb79a1c9d646e7 Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Fri, 24 Aug 2018 14:47:55 +0200 Subject: [PATCH 01/15] Render past successful deploys on the releases overview It's valuable to be able to see at a glance whether a given release has been successfully deployed to a stage in the past, e.g. when you want to know if a build stage has completed. --- app/helpers/application_helper.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7ac922a9b2..4ae10eef5b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -326,9 +326,17 @@ def link_to_chart(name, values) def deployed_or_running_list(stages, reference) html = "".html_safe stages.each do |stage| - next unless deploy = stage.deployed_or_running_deploy - next unless deploy.references?(reference) - label = (deploy.active? ? "label-warning" : "label-success") + next unless deploy = stage.deploys.where(reference: reference).last + + label = if deploy == stage.last_successful_deploy + "label-success" + elsif deploy == stage.active_deploy + "label-warning" + elsif deploy.succeeded? + # Deploy is neither active nor is it the last successful one, but it + # succeeded in the past. + "label-default" + end text = "".html_safe text << stage.name From dafb8966d0b744d6a64e5c99cee0b81e9d8dbbdb Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Fri, 24 Aug 2018 15:21:45 +0200 Subject: [PATCH 02/15] Fixes --- app/helpers/application_helper.rb | 13 ++++++++----- test/helpers/application_helper_test.rb | 14 +++++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4ae10eef5b..6b69bec0d1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -326,16 +326,19 @@ def link_to_chart(name, values) def deployed_or_running_list(stages, reference) html = "".html_safe stages.each do |stage| - next unless deploy = stage.deploys.where(reference: reference).last + # The first deploy is the most recent one. + next unless deploy = stage.deploys.where(reference: reference).first - label = if deploy == stage.last_successful_deploy - "label-success" + if deploy == stage.last_successful_deploy + label = "label-success" elsif deploy == stage.active_deploy - "label-warning" + label = "label-warning" elsif deploy.succeeded? # Deploy is neither active nor is it the last successful one, but it # succeeded in the past. - "label-default" + label = "label-default" + else + next end text = "".html_safe diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 655ac68a1d..a096a7d3fb 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -705,11 +705,23 @@ def render assert html.html_safe? end - it "renders succeeded deploys" do + it "renders current, succeeded deploys" do html = deployed_or_running_list(stage_list, "staging") html.must_equal "Staging " end + it "renders past, succeeded deploys" do + # This deploy will be newer. + stages(:test_staging).deploys.create!( + project: projects(:test), + reference: "asdfjkadfsjk", + job: jobs(:succeeded_test), + ) + + html = deployed_or_running_list(stage_list, "staging") + html.must_equal "Staging " + end + it "ignores failed deploys" do deploys(:succeeded_test).job.update_column(:status, 'failed') html = deployed_or_running_list(stage_list, "staging") From 0be72f74dae177e5b10c9d0e797e817518166a74 Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Mon, 27 Aug 2018 12:31:22 +0200 Subject: [PATCH 03/15] Fix the logic --- app/helpers/application_helper.rb | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6b69bec0d1..a3c3b02a7d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -322,21 +322,25 @@ def link_to_chart(name, values) link_to icon_tag('signal'), url, target: :blank end - # show which stages this reference is deploy(ed+ing) to + # Show which stages this reference has been or is currently being deployed to. def deployed_or_running_list(stages, reference) html = "".html_safe stages.each do |stage| # The first deploy is the most recent one. - next unless deploy = stage.deploys.where(reference: reference).first + deploy = stage.deploys.where(reference: reference).first - if deploy == stage.last_successful_deploy - label = "label-success" - elsif deploy == stage.active_deploy + next if deploy.nil? + + if deploy.running? label = "label-warning" elsif deploy.succeeded? - # Deploy is neither active nor is it the last successful one, but it - # succeeded in the past. - label = "label-default" + if deploy == stage.last_deploy + label = "label-success" + else + # Deploy is neither active nor is it the last successful one, but it + # succeeded in the past. + label = "label-default" + end else next end From 5fa1cc0b220d36ac7b3272b10afb944de9fc07e7 Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Mon, 27 Aug 2018 12:39:34 +0200 Subject: [PATCH 04/15] Make the test more clear Don't use a reference that's identical to the stage name, that's confusing. --- test/helpers/application_helper_test.rb | 28 ++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index a096a7d3fb..0f330c713a 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -698,6 +698,15 @@ def render describe "#deployed_or_running_list" do let(:stage_list) { [stages(:test_staging)] } + let!(:deploy) { create_deploy "v1" } + + def create_deploy(reference) + stages(:test_staging).deploys.create!( + project: projects(:test), + reference: reference, + job: jobs(:succeeded_test), + ) + end it "produces safe output" do html = deployed_or_running_list([], "foo") @@ -706,37 +715,32 @@ def render end it "renders current, succeeded deploys" do - html = deployed_or_running_list(stage_list, "staging") + html = deployed_or_running_list(stage_list, "v1") html.must_equal "Staging " end it "renders past, succeeded deploys" do # This deploy will be newer. - stages(:test_staging).deploys.create!( - project: projects(:test), - reference: "asdfjkadfsjk", - job: jobs(:succeeded_test), - ) + create_deploy "v2" - html = deployed_or_running_list(stage_list, "staging") + html = deployed_or_running_list(stage_list, "v1") html.must_equal "Staging " end it "ignores failed deploys" do - deploys(:succeeded_test).job.update_column(:status, 'failed') - html = deployed_or_running_list(stage_list, "staging") + deploys(:succeeded_test).job.update_column(:status, "failed") + html = deployed_or_running_list(stage_list, "v1") html.must_equal "" end it "ignores non-matching deploys" do - deploys(:succeeded_test).update_column(:reference, 'nope') - html = deployed_or_running_list(stage_list, "staging") + html = deployed_or_running_list(stage_list, "yolo") html.must_equal "" end it "shows active deploys" do deploys(:succeeded_test).job.update_column(:status, 'running') - html = deployed_or_running_list(stage_list, "staging") + html = deployed_or_running_list(stage_list, "v1") html.must_equal "Staging " end end From 05ed49c629a256e8ec6de948b4e49f526de01cb6 Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Mon, 27 Aug 2018 12:43:59 +0200 Subject: [PATCH 05/15] Add test to avoid introducing new queries --- test/helpers/application_helper_test.rb | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 0f330c713a..d85b7a1865 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -728,7 +728,7 @@ def create_deploy(reference) end it "ignores failed deploys" do - deploys(:succeeded_test).job.update_column(:status, "failed") + deploy.job.update_column(:status, "failed") html = deployed_or_running_list(stage_list, "v1") html.must_equal "" end @@ -739,10 +739,30 @@ def create_deploy(reference) end it "shows active deploys" do - deploys(:succeeded_test).job.update_column(:status, 'running') + deploy.job.update_column(:status, 'running') html = deployed_or_running_list(stage_list, "v1") html.must_equal "Staging " end + + it "uses 3 queries when the deploy is the most recent one on the stage" do + assert_sql_queries 3 do + deployed_or_running_list(stage_list, "v1") + end + end + + it "uses 2 queries if the deploy is currently running" do + deploy.job.update_column(:status, "running") + + assert_sql_queries 2 do + deployed_or_running_list(stage_list, "v1") + end + end + + it "uses 1 query if there have been no deploys of that reference" do + assert_sql_queries 1 do + deployed_or_running_list(stage_list, "yolo") + end + end end describe "#check_box_section" do From cbf600cff8073456db41ecd9c7bf7b5f60fb23a5 Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Mon, 27 Aug 2018 13:34:44 +0200 Subject: [PATCH 06/15] Rubocop fix --- test/helpers/application_helper_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index d85b7a1865..79f16d8e6c 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -704,7 +704,7 @@ def create_deploy(reference) stages(:test_staging).deploys.create!( project: projects(:test), reference: reference, - job: jobs(:succeeded_test), + job: jobs(:succeeded_test) ) end From 7b74fe58dfc44ed7ba8492a4fe4f55ac783c134f Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Mon, 27 Aug 2018 15:19:06 +0200 Subject: [PATCH 07/15] Simplify HTML generation --- app/helpers/application_helper.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a3c3b02a7d..ee2454b529 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -324,33 +324,33 @@ def link_to_chart(name, values) # Show which stages this reference has been or is currently being deployed to. def deployed_or_running_list(stages, reference) - html = "".html_safe - stages.each do |stage| + pieces = stages.map do |stage| # The first deploy is the most recent one. deploy = stage.deploys.where(reference: reference).first - next if deploy.nil? - - if deploy.running? - label = "label-warning" + label = if deploy.nil? + nil + elsif deploy.running? + "label-warning" elsif deploy.succeeded? if deploy == stage.last_deploy - label = "label-success" + "label-success" else # Deploy is neither active nor is it the last successful one, but it # succeeded in the past. - label = "label-default" + "label-default" end else - next + nil end - text = "".html_safe - text << stage.name - html << content_tag(:span, text, class: "label #{label} release-stage") - html << " " + if label.present? + text = stage.name.html_safe + content_tag(:span, text, class: "label #{label} release-stage") + end end - html + + safe_join(pieces, " ") end def check_box_section(section_title, help_text, object, method, collection) From 77378b157aba28b33264a6a9a656d4b2ec97cb28 Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Mon, 27 Aug 2018 15:36:31 +0200 Subject: [PATCH 08/15] Rubocop fix --- app/helpers/application_helper.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ee2454b529..6f1d45920b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -340,8 +340,6 @@ def deployed_or_running_list(stages, reference) # succeeded in the past. "label-default" end - else - nil end if label.present? From 472863c288400be5918677ca28be450c71ddeadb Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Mon, 27 Aug 2018 15:37:55 +0200 Subject: [PATCH 09/15] Fix test --- test/helpers/application_helper_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 79f16d8e6c..57cfa49829 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -716,7 +716,7 @@ def create_deploy(reference) it "renders current, succeeded deploys" do html = deployed_or_running_list(stage_list, "v1") - html.must_equal "Staging " + html.must_equal "Staging" end it "renders past, succeeded deploys" do @@ -724,7 +724,7 @@ def create_deploy(reference) create_deploy "v2" html = deployed_or_running_list(stage_list, "v1") - html.must_equal "Staging " + html.must_equal "Staging" end it "ignores failed deploys" do @@ -741,7 +741,7 @@ def create_deploy(reference) it "shows active deploys" do deploy.job.update_column(:status, 'running') html = deployed_or_running_list(stage_list, "v1") - html.must_equal "Staging " + html.must_equal "Staging" end it "uses 3 queries when the deploy is the most recent one on the stage" do From e52df042b21a9946fd456bfa9b480c530559ed9c Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Tue, 28 Aug 2018 13:27:08 +0200 Subject: [PATCH 10/15] Feedback fixes --- app/helpers/application_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6f1d45920b..88ffab6e9d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -342,8 +342,9 @@ def deployed_or_running_list(stages, reference) end end - if label.present? - text = stage.name.html_safe + if label + text = "".html_safe + text << stage.name content_tag(:span, text, class: "label #{label} release-stage") end end From 4b13fa6d3e38476fb7f54cdb782a653c1dbea0de Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Tue, 28 Aug 2018 14:13:45 +0200 Subject: [PATCH 11/15] Optimize the loading of deploys per release --- app/helpers/application_helper.rb | 5 +-- app/models/deploy.rb | 14 ++++++++ test/models/deploy_test.rb | 55 +++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 88ffab6e9d..ff096ce5b9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -324,9 +324,10 @@ def link_to_chart(name, values) # Show which stages this reference has been or is currently being deployed to. def deployed_or_running_list(stages, reference) + deploys = Deploy.of_reference_in_stages(reference, stages) + pieces = stages.map do |stage| - # The first deploy is the most recent one. - deploy = stage.deploys.where(reference: reference).first + deploy = deploys[stage] label = if deploy.nil? nil diff --git a/app/models/deploy.rb b/app/models/deploy.rb index 1faecc22d3..06152a981a 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -171,6 +171,20 @@ def self.after(deploy) where("#{table_name}.id > ?", deploy.id) end + def self.in_stages(stages) + where(stage_id: stages.map(&:id)) + end + + # Returns a Hash of Stage => Deploy for the given reference and stages. + def self.of_reference_in_stages(reference, stages) + where(reference: reference).in_stages(stages).group(:stage_id).map do |deploy| + # Don't trigger another query in order to fetch the stage. + stage = stages.find { |stage| stage.id == deploy.stage_id } + + [stage, deploy] + end.to_h + end + def self.expired threshold = BuddyCheck.time_limit.ago stale = where(buddy_id: nil).joins(:job).where(jobs: {status: 'pending'}).where("jobs.created_at < ?", threshold) diff --git a/test/models/deploy_test.rb b/test/models/deploy_test.rb index 37bb6ef859..ad34099e29 100644 --- a/test/models/deploy_test.rb +++ b/test/models/deploy_test.rb @@ -656,6 +656,52 @@ def deploy end end + describe "#in_stages" do + it "shows only deploys in the specified stages" do + stage1 = create_stage!(name: "stage1") + stage2 = create_stage!(name: "stage2") + + deploy1 = create_deploy!(stage: stage1) + deploy2 = create_deploy!(stage: stage2) + deploy3 = create_deploy!(stage: stage1) + + Deploy.in_stages([stage1]).pluck(:id).sort.must_equal [deploy1.id, deploy3.id].sort + end + end + + describe "#of_reference_in_stages" do + it "returns the latest deploy with the given reference in the specified stages" do + stage1 = create_stage!(name: "stage1") + stage2 = create_stage!(name: "stage2") + stage3 = create_stage!(name: "stage3") + + deploy1 = create_deploy!(stage: stage1, reference: "v42") + deploy2 = create_deploy!(stage: stage1, reference: "v42") + deploy3 = create_deploy!(stage: stage2, reference: "v42") + deploy4 = create_deploy!(stage: stage3, reference: "v42") + + expected = { + stage1 => deploy2, + stage2 => deploy3 + } + + Deploy.of_reference_in_stages("v42", [stage1, stage2]).must_equal expected + end + + it "uses a single query" do + stage1 = create_stage!(name: "stage1") + stage2 = create_stage!(name: "stage2") + + create_deploy!(stage: stage1, reference: "v42") + create_deploy!(stage: stage1, reference: "v42") + create_deploy!(stage: stage2, reference: "v42") + + assert_sql_queries 1 do + Deploy.of_reference_in_stages("v42", [stage1, stage2]) + end + end + end + describe "#as_json" do it "includes simple methods status" do deploy.as_json.fetch("status").must_equal "succeeded" @@ -690,4 +736,13 @@ def create_job!(attrs = {}) Job.create!(default_attrs.merge(attrs)) end + + def create_stage!(attrs = {}) + default_attrs = { + project: project, + name: "some-stage" + } + + Stage.create!(default_attrs.merge(attrs)) + end end From fcd7d967c418da164db7c3b2545219a7ddc4405d Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Tue, 28 Aug 2018 14:47:41 +0200 Subject: [PATCH 12/15] Rubocop fix --- test/models/deploy_test.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/models/deploy_test.rb b/test/models/deploy_test.rb index ad34099e29..e30cf1f6c8 100644 --- a/test/models/deploy_test.rb +++ b/test/models/deploy_test.rb @@ -675,14 +675,14 @@ def deploy stage2 = create_stage!(name: "stage2") stage3 = create_stage!(name: "stage3") + create_deploy!(stage: stage1, reference: "v42") deploy1 = create_deploy!(stage: stage1, reference: "v42") - deploy2 = create_deploy!(stage: stage1, reference: "v42") - deploy3 = create_deploy!(stage: stage2, reference: "v42") - deploy4 = create_deploy!(stage: stage3, reference: "v42") + deploy2 = create_deploy!(stage: stage2, reference: "v42") + create_deploy!(stage: stage3, reference: "v42") expected = { - stage1 => deploy2, - stage2 => deploy3 + stage1 => deploy1, + stage2 => deploy2 } Deploy.of_reference_in_stages("v42", [stage1, stage2]).must_equal expected From af6e1079634c93aee3090ba05cd9f75c17f5fbf4 Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Tue, 28 Aug 2018 14:57:25 +0200 Subject: [PATCH 13/15] Fix the lookup method We need two queries. --- app/models/deploy.rb | 12 +++++++++++- test/models/deploy_test.rb | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/models/deploy.rb b/app/models/deploy.rb index 06152a981a..4a5a735b57 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -177,7 +177,17 @@ def self.in_stages(stages) # Returns a Hash of Stage => Deploy for the given reference and stages. def self.of_reference_in_stages(reference, stages) - where(reference: reference).in_stages(stages).group(:stage_id).map do |deploy| + # Group by stage, then select the latest deploy id. + deploys_and_stages = where(reference: reference). + in_stages(stages). + group(:stage_id). + select("MAX(id) AS id, stage_id") + + # Fetch the actual deploys. + deploys = Deploy.where(id: deploys_and_stages.map(&:id)) + + # Map to a hash of stage => deploy entries. + deploys.map do |deploy| # Don't trigger another query in order to fetch the stage. stage = stages.find { |stage| stage.id == deploy.stage_id } diff --git a/test/models/deploy_test.rb b/test/models/deploy_test.rb index e30cf1f6c8..1eeae31f86 100644 --- a/test/models/deploy_test.rb +++ b/test/models/deploy_test.rb @@ -688,7 +688,7 @@ def deploy Deploy.of_reference_in_stages("v42", [stage1, stage2]).must_equal expected end - it "uses a single query" do + it "uses only two queries" do stage1 = create_stage!(name: "stage1") stage2 = create_stage!(name: "stage2") @@ -696,7 +696,7 @@ def deploy create_deploy!(stage: stage1, reference: "v42") create_deploy!(stage: stage2, reference: "v42") - assert_sql_queries 1 do + assert_sql_queries 2 do Deploy.of_reference_in_stages("v42", [stage1, stage2]) end end From f1f63422346a37913ce50d8dc95ac2f76055541e Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Wed, 29 Aug 2018 12:36:59 +0200 Subject: [PATCH 14/15] Inline `in_stages` --- app/models/deploy.rb | 6 +----- test/models/deploy_test.rb | 13 ------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/app/models/deploy.rb b/app/models/deploy.rb index 4a5a735b57..b54abe0e7a 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -171,15 +171,11 @@ def self.after(deploy) where("#{table_name}.id > ?", deploy.id) end - def self.in_stages(stages) - where(stage_id: stages.map(&:id)) - end - # Returns a Hash of Stage => Deploy for the given reference and stages. def self.of_reference_in_stages(reference, stages) # Group by stage, then select the latest deploy id. deploys_and_stages = where(reference: reference). - in_stages(stages). + where(stage_id: stages.map(&:id)). group(:stage_id). select("MAX(id) AS id, stage_id") diff --git a/test/models/deploy_test.rb b/test/models/deploy_test.rb index 1eeae31f86..199194cbf8 100644 --- a/test/models/deploy_test.rb +++ b/test/models/deploy_test.rb @@ -656,19 +656,6 @@ def deploy end end - describe "#in_stages" do - it "shows only deploys in the specified stages" do - stage1 = create_stage!(name: "stage1") - stage2 = create_stage!(name: "stage2") - - deploy1 = create_deploy!(stage: stage1) - deploy2 = create_deploy!(stage: stage2) - deploy3 = create_deploy!(stage: stage1) - - Deploy.in_stages([stage1]).pluck(:id).sort.must_equal [deploy1.id, deploy3.id].sort - end - end - describe "#of_reference_in_stages" do it "returns the latest deploy with the given reference in the specified stages" do stage1 = create_stage!(name: "stage1") From 6ff52b374bb656faf2be498eaf6b489b76170dcf Mon Sep 17 00:00:00 2001 From: Daniel Schierbeck Date: Wed, 29 Aug 2018 17:36:19 +0200 Subject: [PATCH 15/15] Update the query counts --- test/helpers/application_helper_test.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 57cfa49829..9ba216346b 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -744,22 +744,22 @@ def create_deploy(reference) html.must_equal "Staging" end - it "uses 3 queries when the deploy is the most recent one on the stage" do - assert_sql_queries 3 do + it "uses 4 queries when the deploy is the most recent one on the stage" do + assert_sql_queries 4 do deployed_or_running_list(stage_list, "v1") end end - it "uses 2 queries if the deploy is currently running" do + it "uses 3 queries if the deploy is currently running" do deploy.job.update_column(:status, "running") - assert_sql_queries 2 do + assert_sql_queries 3 do deployed_or_running_list(stage_list, "v1") end end - it "uses 1 query if there have been no deploys of that reference" do - assert_sql_queries 1 do + it "uses 2 queries if there have been no deploys of that reference" do + assert_sql_queries 2 do deployed_or_running_list(stage_list, "yolo") end end