diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-15 15:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-15 15:10:13 +0300 |
commit | a19ad7fa983054d09b35c5fe0bdf853acc55a1bc (patch) | |
tree | ef738162fc764760efd75d03b6d1014490b09f14 /spec/helpers | |
parent | 6fe7ad3526d2b84160129f4989e8f9ebfe8ef6b7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/issues_helper_spec.rb | 96 |
1 files changed, 94 insertions, 2 deletions
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index 2bc6dff26fa..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 @@ -435,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 |