summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeinrich Lee Yu <hleeyu@gmail.com>2018-11-07 13:25:08 +0800
committerHeinrich Lee Yu <hleeyu@gmail.com>2018-11-13 15:27:42 +0800
commit26b9d8fe25e83ac36fe8b397addc40b986a965c0 (patch)
treefbbe5c0ec4db80cc4ce80b96b457b88c936c543b
parent91d88d10c7a5608309e83969723409d95d1a34b5 (diff)
downloadgitlab-ce-26b9d8fe25e83ac36fe8b397addc40b986a965c0.tar.gz
Add helper tests
-rw-r--r--app/helpers/search_helper.rb2
-rw-r--r--spec/helpers/search_helper_spec.rb35
2 files changed, 36 insertions, 1 deletions
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index c46516e463b..80cc568820a 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -179,7 +179,7 @@ module SearchHelper
elsif @group.present?
@group.full_path
else
- root_dashboard_path
+ 'dashboard'
end
end
diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb
index 8bfd520528f..4945749f524 100644
--- a/spec/helpers/search_helper_spec.rb
+++ b/spec/helpers/search_helper_spec.rb
@@ -135,5 +135,40 @@ describe SearchHelper do
expect(search_filter_input_options('')[:data]['base-endpoint']).to eq("/groups#{group_path(@group)}")
end
end
+
+ context 'dashboard' do
+ it 'does not include group-id and project-id' do
+ expect(search_filter_input_options('')[:data]['project-id']).to eq(nil)
+ expect(search_filter_input_options('')[:data]['group-id']).to eq(nil)
+ end
+
+ it 'includes dashboard base-endpoint' do
+ expect(search_filter_input_options('')[:data]['base-endpoint']).to eq("/dashboard")
+ end
+ end
+ end
+
+ describe 'search_history_storage_prefix' do
+ context 'project' do
+ it 'returns project full_path' do
+ @project = create(:project, :repository)
+
+ expect(search_history_storage_prefix).to eq(@project.full_path)
+ end
+ end
+
+ context 'group' do
+ it 'returns group full_path' do
+ @group = create(:group, :nested, name: 'group-name')
+
+ expect(search_history_storage_prefix).to eq(@group.full_path)
+ end
+ end
+
+ context 'dashboard' do
+ it 'returns dashboard' do
+ expect(search_history_storage_prefix).to eq("dashboard")
+ end
+ end
end
end