Skip to content

Commit

Permalink
Add test for title prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Jan 12, 2022
1 parent 4e66f28 commit 124a32b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/components/blacklight/document_title_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<header class="documentHeader row">
<%= content_tag @as, class: @classes do %>
<% before_title.each do |t| %>
<% before_titles.each do |t| %>
<%= t %>
<% end %>
<%= counter -%><%= title -%>
<% after_title.each do |t| %>
<% after_titles.each do |t| %>
<%= t %>
<% end %>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions app/components/blacklight/document_title_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

module Blacklight
class DocumentTitleComponent < ::ViewComponent::Base
renders_many :before_title
renders_many :after_title
renders_many :before_titles
renders_many :after_titles
renders_many :actions

# rubocop:disable Metrics/ParameterLists
Expand Down
14 changes: 14 additions & 0 deletions spec/components/blacklight/document_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,18 @@ def call
component.partial { 'Partials' }
expect(rendered).to have_content 'Partials'
end

context 'with before_title' do
subject(:component) do
described_class.new(presenter: view_context.document_presenter(document)) do |component|
component.title do |c|
c.before_title { 'Prefix!' }
end
end
end

it 'shows the prefix' do
expect(rendered).to have_content "Prefix!"
end
end
end

0 comments on commit 124a32b

Please sign in to comment.