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:
authorKushal Pandya <kushalspandya@gmail.com>2018-12-24 13:25:21 +0300
committerKushal Pandya <kushalspandya@gmail.com>2019-01-22 11:37:46 +0300
commit9cce812af9e409d83f3c50b9453f3cd63bcfbe71 (patch)
tree34788fa7068310906808ec3f524258508226c668
parent60d3fe5804ccb17f0069b51464f5aa3dcc5f63d5 (diff)
Add `client_detection` helper to add browser and plaform flags
-rw-r--r--app/helpers/application_helper.rb11
-rw-r--r--spec/helpers/application_helper_spec.rb15
2 files changed, 26 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 82bb2d1a805..9efa84b02f0 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -268,6 +268,17 @@ module ApplicationHelper
_('You are on a read-only GitLab instance.')
end
+ def client_class_list
+ "gl-browser-#{browser.id} gl-platform-#{browser.platform.id}"
+ end
+
+ def client_js_flags
+ {
+ "is#{browser.id.to_s.titlecase}": true,
+ "is#{browser.platform.id.to_s.titlecase}": true
+ }
+ end
+
def autocomplete_data_sources(object, noteable_type)
return {} unless object && noteable_type
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 4135f31e051..b81249a1e29 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -168,6 +168,21 @@ describe ApplicationHelper do
end
end
+ describe '#client_class_list' do
+ it 'returns string containing CSS classes representing client browser and platform' do
+ class_list = helper.client_class_list
+ expect(class_list).to eq('gl-browser-generic gl-platform-other')
+ end
+ end
+
+ describe '#client_js_flags' do
+ it 'returns map containing JS flags representing client browser and platform' do
+ flags_list = helper.client_js_flags
+ expect(flags_list[:isGeneric]).to eq(true)
+ expect(flags_list[:isOther]).to eq(true)
+ end
+ end
+
describe '#autocomplete_data_sources' do
let(:project) { create(:project) }
let(:noteable_type) { Issue }