diff options
Diffstat (limited to 'spec/helpers/form_helper_spec.rb')
-rw-r--r-- | spec/helpers/form_helper_spec.rb | 68 |
1 files changed, 59 insertions, 9 deletions
diff --git a/spec/helpers/form_helper_spec.rb b/spec/helpers/form_helper_spec.rb index 4b76c370810..14ff5d97057 100644 --- a/spec/helpers/form_helper_spec.rb +++ b/spec/helpers/form_helper_spec.rb @@ -6,35 +6,85 @@ RSpec.describe FormHelper do include Devise::Test::ControllerHelpers describe '#dropdown_max_select' do + let(:feature_flag) { :limit_reviewer_and_assignee_size } + context "with the :limit_reviewer_and_assignee_size feature flag on" do + before do + stub_feature_flags(feature_flag => true) + end + it 'correctly returns the max amount of reviewers or assignees to allow' do - max = MergeRequest::MAX_NUMBER_OF_ASSIGNEES_OR_REVIEWERS + max = Issuable::MAX_NUMBER_OF_ASSIGNEES_OR_REVIEWERS - expect(helper.dropdown_max_select({})) + expect(helper.dropdown_max_select({}, feature_flag)) .to eq(max) - expect(helper.dropdown_max_select({ 'max-select'.to_sym => 5 })) + expect(helper.dropdown_max_select({ 'max-select'.to_sym => 5 }, feature_flag)) .to eq(5) - expect(helper.dropdown_max_select({ 'max-select'.to_sym => max + 5 })) + expect(helper.dropdown_max_select({ 'max-select'.to_sym => max + 5 }, feature_flag)) .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) + stub_feature_flags(feature_flag => false) end it 'correctly returns the max amount of reviewers or assignees to allow' do - expect(helper.dropdown_max_select({})) + expect(helper.dropdown_max_select({}, feature_flag)) .to eq(nil) - expect(helper.dropdown_max_select({ 'max-select'.to_sym => 5 })) + expect(helper.dropdown_max_select({ 'max-select'.to_sym => 5 }, feature_flag)) .to eq(5) - expect(helper.dropdown_max_select({ 'max-select'.to_sym => 120 })) + expect(helper.dropdown_max_select({ 'max-select'.to_sym => 120 }, feature_flag)) .to eq(120) end end end + describe '#assignees_dropdown_options' do + let(:merge_request) { build(:merge_request) } + + context "with the :limit_assignees_per_issuable feature flag on" do + context "with multiple assignees" do + it 'correctly returns the max amount of assignees to allow' do + allow(helper).to receive(:merge_request_supports_multiple_assignees?).and_return(true) + + expect(helper.assignees_dropdown_options(:merge_request)[:data][:'max-select']) + .to eq(Issuable::MAX_NUMBER_OF_ASSIGNEES_OR_REVIEWERS) + end + end + + context "with only 1 assignee" do + it 'correctly returns the max amount of assignees to allow' do + expect(helper.assignees_dropdown_options(:merge_request)[:data][:'max-select']) + .to eq(1) + end + end + end + + context "with the :limit_assignees_per_issuable feature flag off" do + before do + stub_feature_flags(limit_assignees_per_issuable: false) + end + + context "with multiple assignees" do + it 'correctly returns the max amount of assignees to allow' do + allow(helper).to receive(:merge_request_supports_multiple_assignees?).and_return(true) + + expect(helper.assignees_dropdown_options(:merge_request)[:data][:'max-select']) + .to eq(nil) + end + end + + context "with only 1 assignee" do + it 'correctly returns the max amount of assignees to allow' do + expect(helper.assignees_dropdown_options(:merge_request)[:data][:'max-select']) + .to eq(1) + end + end + end + end + describe '#reviewers_dropdown_options' do let(:merge_request) { build(:merge_request) } @@ -44,7 +94,7 @@ RSpec.describe FormHelper 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) + .to eq(Issuable::MAX_NUMBER_OF_ASSIGNEES_OR_REVIEWERS) end end |