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:
authorSean McGivern <sean@gitlab.com>2019-02-22 13:46:00 +0300
committerSean McGivern <sean@gitlab.com>2019-02-22 13:46:00 +0300
commit695df38fce2893becfd858d9e96f2f4d648af2f2 (patch)
tree9f695eba7dbf063b1aa8e7e594fd0211e8a0ed8f /spec/helpers
parent6fa88ed77e1693cda845efe49bf2c9a77aed2e4f (diff)
parent28e1739a3fd8c93e4805fe0053faf820cec4e1bc (diff)
Merge branch '55057-system-message-to-core' into 'master'
Port EE System Header And Footer feature to CE Closes #55057 See merge request gitlab-org/gitlab-ce!25241
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/appearances_helper_spec.rb76
1 files changed, 76 insertions, 0 deletions
diff --git a/spec/helpers/appearances_helper_spec.rb b/spec/helpers/appearances_helper_spec.rb
new file mode 100644
index 00000000000..8d717b968dd
--- /dev/null
+++ b/spec/helpers/appearances_helper_spec.rb
@@ -0,0 +1,76 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe AppearancesHelper do
+ before do
+ user = create(:user)
+ allow(helper).to receive(:current_user).and_return(user)
+ end
+
+ describe '#header_message' do
+ it 'returns nil when header message field is not set' do
+ create(:appearance)
+
+ expect(helper.header_message).to be_nil
+ end
+
+ context 'when header message is set' do
+ it 'includes current message' do
+ message = "Foo bar"
+ create(:appearance, header_message: message)
+
+ expect(helper.header_message).to include(message)
+ end
+ end
+ end
+
+ describe '#footer_message' do
+ it 'returns nil when footer message field is not set' do
+ create(:appearance)
+
+ expect(helper.footer_message).to be_nil
+ end
+
+ context 'when footer message is set' do
+ it 'includes current message' do
+ message = "Foo bar"
+ create(:appearance, footer_message: message)
+
+ expect(helper.footer_message).to include(message)
+ end
+ end
+ end
+
+ describe '#brand_image' do
+ let!(:appearance) { create(:appearance, :with_logo) }
+
+ context 'when there is a logo' do
+ it 'returns a path' do
+ expect(helper.brand_image).to match(%r(img data-src="/uploads/-/system/appearance/.*png))
+ end
+ end
+
+ context 'when there is a logo but no associated upload' do
+ before do
+ # Legacy attachments were not tracked in the uploads table
+ appearance.logo.upload.destroy
+ appearance.reload
+ end
+
+ it 'falls back to using the original path' do
+ expect(helper.brand_image).to match(%r(img data-src="/uploads/-/system/appearance/.*png))
+ end
+ end
+ end
+
+ describe '#brand_title' do
+ it 'returns the default CE title when no appearance is present' do
+ allow(helper)
+ .to receive(:current_appearance)
+ .and_return(nil)
+
+ expect(helper.brand_title).to eq('GitLab Community Edition')
+ end
+ end
+end