Skip to content

Commit

Permalink
Add spec to check permission on target project for branch package step
Browse files Browse the repository at this point in the history
  • Loading branch information
krauselukas committed Sep 23, 2021
1 parent 625b3b0 commit c7e83a8
Show file tree
Hide file tree
Showing 6 changed files with 200 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions src/api/spec/models/workflow/step/branch_package_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,19 @@
it { expect { subject.call }.to(change(EventSubscription, :count).from(0).to(2)) }
end

RSpec.shared_context 'fails with insufficient write permission on target project' do
let(:step_instructions) do
{
source_project: package.project.name,
source_package: package.name,
target_project: 'project_without_maintainer_rights'
}
end
let!(:project_without_permission) { create(:project, name: 'project_without_maintainer_rights') }

it { expect { subject.call }.to raise_error(BranchPackage::Errors::CanNotBranchPackageNoPermission) }
end

describe '#call' do
let(:project) { create(:project, name: 'foo_project', maintainer: user) }
let(:package) { create(:package_with_file, name: 'bar_package', project: project) }
Expand Down Expand Up @@ -204,6 +217,7 @@
it_behaves_like 'successful new PR or MR event'
it_behaves_like 'failed when source_package does not exist'
it_behaves_like 'failed without branch permissions'
it_behaves_like 'fails with insufficient write permission on target project'
end

context 'for an updated PR event' do
Expand Down Expand Up @@ -279,6 +293,7 @@
it_behaves_like 'successful new PR or MR event'
it_behaves_like 'failed when source_package does not exist'
it_behaves_like 'failed without branch permissions'
it_behaves_like 'fails with insufficient write permission on target project'
end

context 'for an updated MR event' do
Expand Down

0 comments on commit c7e83a8

Please sign in to comment.