Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/branches_helper_spec.rb')
-rw-r--r--spec/helpers/branches_helper_spec.rb32
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