Make page_description
less magical ✨
This commit is contained in:
parent
a298f69432
commit
43053c2e6f
4 changed files with 11 additions and 42 deletions
|
@ -27,7 +27,7 @@ module PageLayoutHelper
|
||||||
#
|
#
|
||||||
# Returns an HTML-safe String.
|
# Returns an HTML-safe String.
|
||||||
def page_description(description = nil)
|
def page_description(description = nil)
|
||||||
@page_description ||= page_description_default
|
@page_description ||= brand_title
|
||||||
|
|
||||||
if description.present?
|
if description.present?
|
||||||
@page_description = description.squish
|
@page_description = description.squish
|
||||||
|
@ -36,16 +36,6 @@ module PageLayoutHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Default value for page_description when one hasn't been defined manually by
|
|
||||||
# a view
|
|
||||||
def page_description_default
|
|
||||||
if @project
|
|
||||||
@project.description || brand_title
|
|
||||||
else
|
|
||||||
brand_title
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def page_image
|
def page_image
|
||||||
default = image_url('gitlab_logo.png')
|
default = image_url('gitlab_logo.png')
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
- page_title @group.name
|
- page_title @group.name
|
||||||
- header_title group_title(@group) unless header_title
|
- page_description @group.description
|
||||||
- sidebar "group" unless sidebar
|
- header_title group_title(@group) unless header_title
|
||||||
|
- sidebar "group" unless sidebar
|
||||||
|
|
||||||
= render template: "layouts/application"
|
= render template: "layouts/application"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
- page_title @project.name_with_namespace
|
- page_title @project.name_with_namespace
|
||||||
- header_title project_title(@project) unless header_title
|
- page_description @project.description
|
||||||
- sidebar "project" unless sidebar
|
- header_title project_title(@project) unless header_title
|
||||||
|
- sidebar "project" unless sidebar
|
||||||
|
|
||||||
- content_for :scripts_body_top do
|
- content_for :scripts_body_top do
|
||||||
- project = @target_project || @project
|
- project = @target_project || @project
|
||||||
|
|
|
@ -2,8 +2,8 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe PageLayoutHelper do
|
describe PageLayoutHelper do
|
||||||
describe 'page_description' do
|
describe 'page_description' do
|
||||||
it 'defaults to value returned by page_description_default helper' do
|
it 'defaults to value returned by brand_title helper' do
|
||||||
allow(helper).to receive(:page_description_default).and_return('Foo')
|
allow(helper).to receive(:brand_title).and_return('Foo')
|
||||||
|
|
||||||
expect(helper.page_description).to eq 'Foo'
|
expect(helper.page_description).to eq 'Foo'
|
||||||
end
|
end
|
||||||
|
@ -42,29 +42,6 @@ describe PageLayoutHelper do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'page_description_default' do
|
|
||||||
it 'uses Project description when available' do
|
|
||||||
project = double(description: 'Project Description')
|
|
||||||
assign(:project, project)
|
|
||||||
|
|
||||||
expect(helper.page_description_default).to eq 'Project Description'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'uses brand_title when Project description is nil' do
|
|
||||||
project = double(description: nil)
|
|
||||||
assign(:project, project)
|
|
||||||
|
|
||||||
expect(helper).to receive(:brand_title).and_return('Brand Title')
|
|
||||||
expect(helper.page_description_default).to eq 'Brand Title'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'falls back to brand_title' do
|
|
||||||
allow(helper).to receive(:brand_title).and_return('Brand Title')
|
|
||||||
|
|
||||||
expect(helper.page_description_default).to eq 'Brand Title'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'page_image' do
|
describe 'page_image' do
|
||||||
it 'defaults to the GitLab logo' do
|
it 'defaults to the GitLab logo' do
|
||||||
expect(helper.page_image).to end_with 'assets/gitlab_logo.png'
|
expect(helper.page_image).to end_with 'assets/gitlab_logo.png'
|
||||||
|
|
Loading…
Reference in a new issue