diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-04-12 14:39:08 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-04-12 17:30:11 -0400 |
commit | 2e13f6c326b920f1b78ca592dc1b938b62d5eef3 (patch) | |
tree | b536c21c52bae383c19c2408f29ac451aa417273 | |
parent | 2c9894d457cac2f15331081a4f6974e0803fead3 (diff) | |
download | gitlab-ce-2e13f6c326b920f1b78ca592dc1b938b62d5eef3.tar.gz |
Add `Gitlab.com?` methodrs-gitlab-com-check
To be used as a feature flag for GitLab.com-only features, such as
welcome emails.
We will be careful to only use this to disable features or functionality
that do not make sense for any installations that aren't GitLab.com. We
will not use this to restrict features from other installations or keep
them "exclusive" to GitLab.com.
-rw-r--r-- | lib/gitlab.rb | 3 | ||||
-rw-r--r-- | spec/lib/gitlab_spec.rb | 17 |
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/gitlab.rb b/lib/gitlab.rb index 6108697bc20..7479e729db1 100644 --- a/lib/gitlab.rb +++ b/lib/gitlab.rb @@ -1,4 +1,7 @@ require 'gitlab/git' module Gitlab + def self.com? + Gitlab.config.gitlab.url == 'https://gitlab.com' + end end diff --git a/spec/lib/gitlab_spec.rb b/spec/lib/gitlab_spec.rb new file mode 100644 index 00000000000..c59dfea5c55 --- /dev/null +++ b/spec/lib/gitlab_spec.rb @@ -0,0 +1,17 @@ +require 'rails_helper' + +describe Gitlab, lib: true do + describe '.com?' do + it 'is true when on GitLab.com' do + stub_config_setting(url: 'https://gitlab.com') + + expect(described_class.com?).to eq true + end + + it 'is false when not on GitLab.com' do + stub_config_setting(url: 'http://example.com') + + expect(described_class.com?).to eq false + end + end +end |