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/form_helper_spec.rb')
-rw-r--r--spec/helpers/form_helper_spec.rb81
1 files changed, 77 insertions, 4 deletions
diff --git a/spec/helpers/form_helper_spec.rb b/spec/helpers/form_helper_spec.rb
index c9c8c6b13b6..4b76c370810 100644
--- a/spec/helpers/form_helper_spec.rb
+++ b/spec/helpers/form_helper_spec.rb
@@ -3,6 +3,82 @@
require 'spec_helper'
RSpec.describe FormHelper do
+ include Devise::Test::ControllerHelpers
+
+ describe '#dropdown_max_select' do
+ context "with the :limit_reviewer_and_assignee_size feature flag on" do
+ it 'correctly returns the max amount of reviewers or assignees to allow' do
+ max = MergeRequest::MAX_NUMBER_OF_ASSIGNEES_OR_REVIEWERS
+
+ expect(helper.dropdown_max_select({}))
+ .to eq(max)
+ expect(helper.dropdown_max_select({ 'max-select'.to_sym => 5 }))
+ .to eq(5)
+ expect(helper.dropdown_max_select({ 'max-select'.to_sym => max + 5 }))
+ .to eq(max)
+ end
+ end
+
+ context "with the :limit_reviewer_and_assignee_size feature flag off" do
+ before do
+ stub_feature_flags(limit_reviewer_and_assignee_size: false)
+ end
+
+ it 'correctly returns the max amount of reviewers or assignees to allow' do
+ expect(helper.dropdown_max_select({}))
+ .to eq(nil)
+ expect(helper.dropdown_max_select({ 'max-select'.to_sym => 5 }))
+ .to eq(5)
+ expect(helper.dropdown_max_select({ 'max-select'.to_sym => 120 }))
+ .to eq(120)
+ end
+ end
+ end
+
+ describe '#reviewers_dropdown_options' do
+ let(:merge_request) { build(:merge_request) }
+
+ context "with the :limit_reviewer_and_assignee_size feature flag on" do
+ context "with multiple reviewers" do
+ it 'correctly returns the max amount of reviewers or assignees to allow' do
+ allow(helper).to receive(:merge_request_supports_multiple_reviewers?).and_return(true)
+
+ expect(helper.reviewers_dropdown_options(merge_request)[:data][:'max-select'])
+ .to eq(MergeRequest::MAX_NUMBER_OF_ASSIGNEES_OR_REVIEWERS)
+ end
+ end
+
+ context "with only 1 reviewer" do
+ it 'correctly returns the max amount of reviewers or assignees to allow' do
+ expect(helper.reviewers_dropdown_options(merge_request)[:data][:'max-select'])
+ .to eq(1)
+ end
+ end
+ end
+
+ context "with the :limit_reviewer_and_assignee_size feature flag off" do
+ before do
+ stub_feature_flags(limit_reviewer_and_assignee_size: false)
+ end
+
+ context "with multiple reviewers" do
+ it 'correctly returns the max amount of reviewers or assignees to allow' do
+ allow(helper).to receive(:merge_request_supports_multiple_reviewers?).and_return(true)
+
+ expect(helper.reviewers_dropdown_options(merge_request)[:data][:'max-select'])
+ .to eq(nil)
+ end
+ end
+
+ context "with only 1 reviewer" do
+ it 'correctly returns the max amount of reviewers or assignees to allow' do
+ expect(helper.reviewers_dropdown_options(merge_request)[:data][:'max-select'])
+ .to eq(1)
+ end
+ end
+ end
+ end
+
describe 'form_errors' do
it 'returns nil when model has no errors' do
model = double(errors: [])
@@ -13,10 +89,7 @@ RSpec.describe FormHelper do
it 'renders an appropriately styled alert div' do
model = double(errors: errors_stub('Error 1'))
- expect(helper.form_errors(model, pajamas_alert: false))
- .to include('<div class="alert alert-danger" id="error_explanation">')
-
- expect(helper.form_errors(model, pajamas_alert: true))
+ expect(helper.form_errors(model))
.to include(
'<div class="gl-alert gl-mb-5 gl-alert-danger gl-alert-not-dismissible" id="error_explanation" role="alert">'
)