diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-13 00:10:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-13 00:10:06 +0000 |
commit | 3827baae078970c1027461f01df090b885370c55 (patch) | |
tree | 65a0471270565047d0cb18de33a989f297fbde18 /spec/helpers | |
parent | 14245e7755fb19d2429aa6a85273097a6b2eb43f (diff) | |
download | gitlab-ce-3827baae078970c1027461f01df090b885370c55.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/branches_helper_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/helpers/branches_helper_spec.rb b/spec/helpers/branches_helper_spec.rb new file mode 100644 index 00000000000..1f7bf25afcd --- /dev/null +++ b/spec/helpers/branches_helper_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe BranchesHelper do + describe '#access_levels_data' do + subject { helper.access_levels_data(access_levels) } + + context 'when access_levels is nil' do + let(:access_levels) { nil } + + it { is_expected.to be_empty } + end + + context 'when access levels are provided' do + let(:protected_branch) { create(:protected_branch, :developers_can_merge, :maintainers_can_push) } + + let(:merge_level) { protected_branch.merge_access_levels.first } + let(:push_level) { protected_branch.push_access_levels.first } + let(:access_levels) { [merge_level, push_level] } + + it 'returns the correct array' do + expected_array = [ + { id: merge_level.id, type: :role, access_level: Gitlab::Access::DEVELOPER }, + { id: push_level.id, type: :role, access_level: Gitlab::Access::MAINTAINER } + ] + + expect(subject).to eq(expected_array) + end + end + end +end |