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:
authorMartin Wortschack <mwortschack@gitlab.com>2018-12-19 22:37:08 +0300
committerMartin Wortschack <mwortschack@gitlab.com>2018-12-19 22:37:25 +0300
commit26c740715013a38629011df51e6cf07b3cf12f34 (patch)
treea4227a34b8d0155cd823b94300c9f22f0355314d /spec/helpers/projects_helper_spec.rb
parent9ead13b8ebb5ae05bd1dd6c656bb0d56bb680c3a (diff)
Add test for compact mode and for helpers
- add tests for merge_request_count - add tests for show_issue_count - add tests for explore_projects_tab - change interface for show_merge_request_count and show_issue_count
Diffstat (limited to 'spec/helpers/projects_helper_spec.rb')
-rw-r--r--spec/helpers/projects_helper_spec.rb110
1 files changed, 110 insertions, 0 deletions
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index 486416c3370..edd680ee1d1 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -519,4 +519,114 @@ describe ProjectsHelper do
expect(helper.legacy_render_context({})).to be_empty
end
end
+
+ describe '#explore_projects_tab?' do
+ subject { helper.explore_projects_tab? }
+
+ it 'returns true when on the "All" tab under "Explore projects"' do
+ allow(@request).to receive(:path) { explore_projects_path }
+
+ expect(subject).to be_truthy
+ end
+
+ it 'returns true when on the "Trending" tab under "Explore projects"' do
+ allow(@request).to receive(:path) { trending_explore_projects_path }
+
+ expect(subject).to be_truthy
+ end
+
+ it 'returns true when on the "Starred" tab under "Explore projects"' do
+ allow(@request).to receive(:path) { starred_explore_projects_path }
+
+ expect(subject).to be_truthy
+ end
+
+ it 'returns false when on the "Your projects" tab' do
+ allow(@request).to receive(:path) { dashboard_projects_path }
+
+ expect(subject).to be_falsey
+ end
+ end
+
+ describe '#show_merge_request_count' do
+ context 'when the feature flag is enabled' do
+ before do
+ stub_feature_flags(project_list_show_mr_count: true)
+ end
+
+ it 'returns true if compact mode is disabled' do
+ expect(helper.show_merge_request_count?).to be_truthy
+ end
+
+ it 'returns false if compact mode is enabled' do
+ expect(helper.show_merge_request_count?(compact_mode: true)).to be_falsey
+ end
+ end
+
+ context 'when the feature flag is disabled' do
+ before do
+ stub_feature_flags(project_list_show_mr_count: false)
+ end
+
+ it 'always returns false' do
+ expect(helper.show_merge_request_count?(disabled: false)).to be_falsy
+ expect(helper.show_merge_request_count?(disabled: true)).to be_falsy
+ end
+ end
+
+ context 'disabled flag' do
+ before do
+ stub_feature_flags(project_list_show_mr_count: true)
+ end
+
+ it 'returns false if disabled flag is true' do
+ expect(helper.show_merge_request_count?(disabled: true)).to be_falsey
+ end
+
+ it 'returns true if disabled flag is false' do
+ expect(helper.show_merge_request_count?).to be_truthy
+ end
+ end
+ end
+
+ describe '#show_issue_count?' do
+ context 'when the feature flag is enabled' do
+ before do
+ stub_feature_flags(project_list_show_issue_count: true)
+ end
+
+ it 'returns true if compact mode is disabled' do
+ expect(helper.show_issue_count?).to be_truthy
+ end
+
+ it 'returns false if compact mode is enabled' do
+ expect(helper.show_issue_count?(compact_mode: true)).to be_falsey
+ end
+ end
+
+ context 'when the feature flag is disabled' do
+ before do
+ stub_feature_flags(project_list_show_issue_count: false)
+ end
+
+ it 'always returns false' do
+ expect(helper.show_issue_count?(disabled: false)).to be_falsy
+ expect(helper.show_issue_count?(disabled: true)).to be_falsy
+ end
+ end
+
+ context 'disabled flag' do
+ before do
+ stub_feature_flags(project_list_show_issue_count: true)
+ end
+
+ it 'returns false if disabled flag is true' do
+ expect(helper.show_issue_count?(disabled: true)).to be_falsey
+ end
+
+ it 'returns true if disabled flag is false' do
+ expect(helper.show_issue_count?).to be_truthy
+ end
+ end
+ end
end