diff options
Diffstat (limited to 'spec/helpers/issues_helper_spec.rb')
-rw-r--r-- | spec/helpers/issues_helper_spec.rb | 98 |
1 files changed, 96 insertions, 2 deletions
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index 62d94b59c2a..6a6808cd8d2 100644 --- a/spec/helpers/issues_helper_spec.rb +++ b/spec/helpers/issues_helper_spec.rb @@ -5,6 +5,8 @@ require 'spec_helper' RSpec.describe IssuesHelper, feature_category: :team_planning do include Features::MergeRequestHelpers + let_it_be(:user) { create(:user) } + let_it_be(:group) { create(:group) } let_it_be(:project) { create(:project) } let_it_be_with_reload(:issue) { create(:issue, project: project) } @@ -47,7 +49,6 @@ RSpec.describe IssuesHelper, feature_category: :team_planning do describe '#award_state_class' do let!(:upvote) { create(:award_emoji) } let(:awardable) { upvote.awardable } - let(:user) { upvote.user } before do allow(helper).to receive(:can?) do |*args| @@ -264,7 +265,6 @@ RSpec.describe IssuesHelper, feature_category: :team_planning do end describe '#group_issues_list_data' do - let(:group) { create(:group) } let(:current_user) { double.as_null_object } it 'returns expected result' do @@ -303,6 +303,7 @@ RSpec.describe IssuesHelper, feature_category: :team_planning do allow(helper).to receive(:current_user).and_return(current_user) allow(helper).to receive(:image_path).and_return('#') allow(helper).to receive(:url_for).and_return('#') + stub_feature_flags(issue_date_filter: false) expected = { autocomplete_award_emojis_path: autocomplete_award_emojis_path, @@ -311,6 +312,7 @@ RSpec.describe IssuesHelper, feature_category: :team_planning do dashboard_milestones_path: dashboard_milestones_path(format: :json), empty_state_with_filter_svg_path: '#', empty_state_without_filter_svg_path: '#', + has_issue_date_filter_feature: 'false', initial_sort: current_user&.user_preference&.issues_sort, is_public_visibility_restricted: Gitlab::CurrentSettings.restricted_visibility_levels ? 'false' : '', is_signed_in: current_user.present?.to_s, @@ -433,4 +435,96 @@ RSpec.describe IssuesHelper, feature_category: :team_planning do end end end + + describe '#has_issue_date_filter_feature?' do + subject(:has_issue_date_filter_feature) { helper.has_issue_date_filter_feature?(namespace, namespace.owner) } + + context 'when namespace is a group project' do + let_it_be(:namespace) { create(:project, namespace: group) } + + it { is_expected.to be_truthy } + + context 'when feature flag is disabled' do + before do + stub_feature_flags(issue_date_filter: false) + end + + it { is_expected.to be_falsey } + end + + context 'when feature flag enabled for group' do + before do + stub_feature_flags(issue_date_filter: [group]) + end + + it { is_expected.to be_truthy } + end + + context 'when feature flag enabled for user' do + before do + stub_feature_flags(issue_date_filter: [namespace.owner]) + end + + it { is_expected.to be_truthy } + end + end + + context 'when namespace is a group' do + let_it_be(:namespace) { group } + + subject(:has_issue_date_filter_feature) { helper.has_issue_date_filter_feature?(namespace, user) } + + before_all do + namespace.add_reporter(user) + end + + it { is_expected.to be_truthy } + + context 'when feature flag is disabled' do + before do + stub_feature_flags(issue_date_filter: false) + end + + it { is_expected.to be_falsey } + end + + context 'when feature flag enabled for group' do + before do + stub_feature_flags(issue_date_filter: [group]) + end + + it { is_expected.to be_truthy } + end + + context 'when feature flag enabled for user' do + before do + stub_feature_flags(issue_date_filter: [user]) + end + + it { is_expected.to be_truthy } + end + end + + context 'when namespace is a user project' do + let_it_be(:namespace) { project } + + it { is_expected.to be_truthy } + + context 'when feature flag is disabled' do + before do + stub_feature_flags(issue_date_filter: false) + end + + it { is_expected.to be_falsey } + end + + context 'when feature flag enabled for user' do + before do + stub_feature_flags(issue_date_filter: [project.owner]) + end + + it { is_expected.to be_truthy } + end + end + end end |