1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
# frozen_string_literal: true
describe Octokit::Client::ActionsWorkflows do
before do
Octokit.reset!
@client = oauth_client
end
describe '.workflows', :vcr do
it 'returns the repository workflows' do
@client.workflows(@test_repo)
assert_requested :get, github_url("/repos/#{@test_repo}/actions/workflows")
end
it 'paginates the results' do
@client.per_page = 1
allow(@client).to receive(:paginate).and_call_original
workflows = @client.workflows(@test_repo)
expect(@client).to have_received(:paginate)
expect(workflows.total_count).to eq(2)
expect(workflows.workflows.count).to eq(1)
end
it 'auto-paginates the results' do
@client.auto_paginate = true
@client.per_page = 1
allow(@client).to receive(:paginate).and_call_original
workflows = @client.workflows(@test_repo)
expect(@client).to have_received(:paginate)
expect(workflows.total_count).to eq(2)
expect(workflows.workflows.count).to eq(2)
end
end # .workflows
describe '.workflow', :vcr do
it 'returns the repository workflows' do
workflow_file_name = 'simple_workflow.yml'
request = stub_get("/repos/#{@test_repo}/actions/workflows/#{workflow_file_name}")
@client.workflow(@test_repo, workflow_file_name)
assert_requested request
end
end # .workflow
describe '.workflow_dispatch', :vcr do
it 'creates a workflow dispatch event' do
workflow_file_name = 'simple_workflow.yml'
request = stub_post("/repos/#{@test_repo}/actions/workflows/#{workflow_file_name}/dispatches")
@client.workflow_dispatch(@test_repo, workflow_file_name, 'main')
assert_requested request
end
end # .workflow_dispatch
describe '.workflow_enable' do
it 'enables a workflow' do
workflow_file_name = 'simple_workflow.yml'
request = stub_put("/repos/#{@test_repo}/actions/workflows/#{workflow_file_name}/enable")
@client.workflow_enable(@test_repo, workflow_file_name)
assert_requested request
end
end # .workflow_enable
describe '.workflow_disable' do
it 'disables a workflow' do
workflow_file_name = 'simple_workflow.yml'
request = stub_put("/repos/#{@test_repo}/actions/workflows/#{workflow_file_name}/disable")
@client.workflow_disable(@test_repo, workflow_file_name)
assert_requested request
end
end # .workflow_disable
end
|