Skip to content

Commit

Permalink
Fix fetched? check in PerformTaskJob
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Oct 30, 2018
1 parent 05edc21 commit 73b9e5e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Expand Up @@ -56,6 +56,9 @@ Style/DoubleNegation:
Style/Next:
Enabled: false

Style/EmptyMethod:
Enabled: false

Metrics/LineLength:
Exclude:
- config/routes.rb
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/shipit/perform_task_job.rb
Expand Up @@ -60,7 +60,7 @@ def perform_task
end

def checkout_repository
unless @commands.fetched?(@task.until_commit)
unless @commands.fetched?(@task.until_commit).tap(&:run).success?
@task.acquire_git_cache_lock do
capture! @commands.fetch
end
Expand Down
11 changes: 10 additions & 1 deletion test/jobs/perform_task_job_test.rb
Expand Up @@ -2,6 +2,15 @@

module Shipit
class PerformTaskJobTest < ActiveSupport::TestCase
class FakeSuccessfulCommand
def run
end

def success?
true
end
end

setup do
@job = PerformTaskJob.new
@deploy = shipit_deploys(:shipit_pending)
Expand All @@ -14,7 +23,7 @@ class PerformTaskJobTest < ActiveSupport::TestCase
@commands = stub(:commands)
Commands.expects(:for).with(@deploy).returns(@commands)

@commands.expects(:fetched?).once.returns(true)
@commands.expects(:fetched?).once.returns(FakeSuccessfulCommand.new)
@commands.expects(:clone).returns([]).once
@commands.expects(:checkout).with(@deploy.until_commit).once
@commands.expects(:install_dependencies).returns([]).once
Expand Down

0 comments on commit 73b9e5e

Please sign in to comment.