Skip to content

Commit

Permalink
Adapt workflow model and yaml to workflow service specs
Browse files Browse the repository at this point in the history
We pass now the whole workflow run object instead of only the
corresponding id.
  • Loading branch information
krauselukas committed Apr 19, 2022
1 parent 078fcb2 commit 4aa2452
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/api/spec/models/token/workflow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
let(:scm_webhook) { ScmWebhook.new(payload: github_extractor_payload) }
let(:yaml_downloader) { Workflows::YAMLDownloader.new(scm_webhook.payload, token: workflow_token) }
let(:yaml_file) { File.expand_path(Rails.root.join('spec/support/files/workflows.yml')) }
let(:yaml_to_workflows_service) { Workflows::YAMLToWorkflowsService.new(yaml_file: yaml_file, scm_webhook: scm_webhook, token: workflow_token, workflow_run_id: workflow_run.id) }
let(:yaml_to_workflows_service) { Workflows::YAMLToWorkflowsService.new(yaml_file: yaml_file, scm_webhook: scm_webhook, token: workflow_token, workflow_run: workflow_run) }
let(:workflow) do
Workflow.new(scm_webhook: scm_webhook, token: workflow_token,
workflow_instructions: { steps: [branch_package: { source_project: 'home:Admin', source_package: 'ctris', target_project: 'dev:tools' }] })
Expand All @@ -87,7 +87,7 @@
allow(Workflows::YAMLDownloader).to receive(:new).with(scm_webhook.payload, token: workflow_token).and_return(yaml_downloader)
allow(yaml_downloader).to receive(:call).and_return(yaml_file)
allow(Workflows::YAMLToWorkflowsService).to receive(:new).with(yaml_file: yaml_file, scm_webhook: scm_webhook, token: workflow_token,
workflow_run_id: workflow_run.id).and_return(yaml_to_workflows_service)
workflow_run: workflow_run).and_return(yaml_to_workflows_service)
allow(yaml_to_workflows_service).to receive(:call).and_return(workflows)
allow(ScmInitialStatusReporter).to receive(:new).and_return(proc { true })
end
Expand Down Expand Up @@ -138,7 +138,7 @@
let(:scm_webhook) { ScmWebhook.new(payload: github_extractor_payload) }
let(:yaml_downloader) { Workflows::YAMLDownloader.new(scm_webhook.payload, token: workflow_token) }
let(:yaml_file) { File.expand_path(Rails.root.join('spec/support/files/workflows.yml')) }
let(:yaml_to_workflows_service) { Workflows::YAMLToWorkflowsService.new(yaml_file: yaml_file, scm_webhook: scm_webhook, token: workflow_token, workflow_run_id: workflow_run.id) }
let(:yaml_to_workflows_service) { Workflows::YAMLToWorkflowsService.new(yaml_file: yaml_file, scm_webhook: scm_webhook, token: workflow_token, workflow_run: workflow_run) }
let(:workflows) { [Workflow.new(scm_webhook: scm_webhook, token: workflow_token, workflow_instructions: {})] }

before do
Expand All @@ -147,7 +147,7 @@
allow(Workflows::YAMLDownloader).to receive(:new).with(scm_webhook.payload, token: workflow_token).and_return(yaml_downloader)
allow(yaml_downloader).to receive(:call).and_return(yaml_file)
allow(Workflows::YAMLToWorkflowsService).to receive(:new).with(yaml_file: yaml_file, scm_webhook: scm_webhook, token: workflow_token,
workflow_run_id: workflow_run.id).and_return(yaml_to_workflows_service)
workflow_run: workflow_run).and_return(yaml_to_workflows_service)
allow(yaml_to_workflows_service).to receive(:call).and_return(workflows)
end

Expand Down
2 changes: 1 addition & 1 deletion src/api/spec/models/workflow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let!(:workflow_run) { create(:workflow_run, token: token) }

subject do
described_class.new(workflow_instructions: yaml, scm_webhook: ScmWebhook.new(payload: extractor_payload), token: token, workflow_run_id: workflow_run.id)
described_class.new(workflow_instructions: yaml, scm_webhook: ScmWebhook.new(payload: extractor_payload), token: token, workflow_run: workflow_run)
end

describe '#call' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

describe '#call' do
subject do
Workflows::YAMLToWorkflowsService.new(yaml_file: workflows_yml_file, scm_webhook: ScmWebhook.new(payload: payload), token: token, workflow_run_id: workflow_run.id).call
Workflows::YAMLToWorkflowsService.new(yaml_file: workflows_yml_file, scm_webhook: ScmWebhook.new(payload: payload), token: token, workflow_run: workflow_run).call
end

context 'it supports many workflows' do
Expand Down

0 comments on commit 4aa2452

Please sign in to comment.