Skip to content

Commit

Permalink
Merge pull request zendesk#503 from zendesk/grosser/buddy
Browse files Browse the repository at this point in the history
rename buddy check period to redeploy_timeout
  • Loading branch information
grosser committed Jul 2, 2015
2 parents c79bb5f + ca19059 commit 424da15
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/deploy_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def stop!(deploy)
private

def latest_approved_deploy(reference, project)
Deploy.where(reference: reference).where('buddy_id is NOT NULL AND started_at > ?', BuddyCheck.period.hours.ago)
Deploy.where(reference: reference).where('buddy_id is NOT NULL AND started_at > ?', BuddyCheck.grace_period.ago)
.includes(:stage)
.where(stages: {project_id: project})
.detect { |d| d.production? && !d.bypassed_approval? }
Expand Down
5 changes: 3 additions & 2 deletions lib/policies/buddy_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ def bypass_email_address
ENV["BYPASS_EMAIL"]
end

def period
(ENV["BUDDY_CHECK_GRACE_PERIOD"].presence || "4").to_i
# how long can the same commit be deployed ?
def grace_period
(ENV["BUDDY_CHECK_GRACE_PERIOD"].presence || "4").to_i.hours
end

def bypass_jira_email_address
Expand Down
3 changes: 1 addition & 2 deletions test/models/deploy_service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ def create_previous_deploy(ref, stage, successful: true)

it "does not start the deploy, if past grace period" do
service.expects(:confirm_deploy!).never
travel (BuddyCheck.period).hour + 1.minute do
travel BuddyCheck.grace_period + 1.minute do
service.deploy!(stage_production_2, reference: ref1)
end
end

end

describe "if similar deploy was bypassed" do
Expand Down

0 comments on commit 424da15

Please sign in to comment.