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:
authorStan Hu <stanhu@gmail.com>2019-09-03 19:38:08 +0300
committerStan Hu <stanhu@gmail.com>2019-09-03 19:38:08 +0300
commit3d8d394c9741fc41d272b970d257743079ef621c (patch)
tree410accf1a4ec4825652b22a5f985b13e8fd1c483
parent4bf01ce52fc91445d44cd0e993770c030ad53a68 (diff)
parentd5dc50392df3eff21a0b2771174f89f54e0b15f8 (diff)
Merge branch '13988-add-rails-helpers' into 'master'
Add new RailsHelpers module for specs Closes #66688 See merge request gitlab-org/gitlab-ce!32309
-rw-r--r--spec/lib/gitlab/favicon_spec.rb8
-rw-r--r--spec/lib/gitlab_spec.rb8
-rw-r--r--spec/support/helpers/rails_helpers.rb7
3 files changed, 16 insertions, 7 deletions
diff --git a/spec/lib/gitlab/favicon_spec.rb b/spec/lib/gitlab/favicon_spec.rb
index 23de12f12f8..63c26e29d73 100644
--- a/spec/lib/gitlab/favicon_spec.rb
+++ b/spec/lib/gitlab/favicon_spec.rb
@@ -1,14 +1,16 @@
require 'spec_helper'
RSpec.describe Gitlab::Favicon, :request_store do
+ include RailsHelpers
+
describe '.main' do
it 'defaults to favicon.png' do
- allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('production'))
+ stub_rails_env('production')
expect(described_class.main).to match_asset_path '/assets/favicon.png'
end
it 'has blue favicon for development', unless: Gitlab.ee? do
- allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development'))
+ stub_rails_env('development')
expect(described_class.main).to match_asset_path '/assets/favicon-blue.png'
end
@@ -24,7 +26,7 @@ RSpec.describe Gitlab::Favicon, :request_store do
context 'asset host' do
before do
- allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('production'))
+ stub_rails_env('production')
end
it 'returns a relative url when the asset host is not configured' do
diff --git a/spec/lib/gitlab_spec.rb b/spec/lib/gitlab_spec.rb
index 1fc363460ae..74d4b12a070 100644
--- a/spec/lib/gitlab_spec.rb
+++ b/spec/lib/gitlab_spec.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
-
-require_dependency 'gitlab'
+require 'spec_helper'
describe Gitlab do
+ include RailsHelpers
+
describe '.root' do
it 'returns the root path of the app' do
expect(described_class.root).to eq(Pathname.new(File.expand_path('../..', __dir__)))
@@ -113,7 +113,7 @@ describe Gitlab do
it 'is true when dev env' do
allow(described_class).to receive_messages(com?: false, org?: false)
- allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development'))
+ stub_rails_env('development')
expect(described_class.dev_env_org_or_com?).to eq true
end
diff --git a/spec/support/helpers/rails_helpers.rb b/spec/support/helpers/rails_helpers.rb
new file mode 100644
index 00000000000..e1875b2fb15
--- /dev/null
+++ b/spec/support/helpers/rails_helpers.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+module RailsHelpers
+ def stub_rails_env(env_name)
+ allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new(env_name))
+ end
+end