-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep using old component for backwards compatibility
- Test components Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>
- Loading branch information
1 parent
4d5d149
commit 7d0ec28
Showing
6 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
<% Deprecation.warn(self, 'The partial _previous_next_doc.html.erb will be removed in 8.0. Render Blacklight::SearchContext::ServerItemPaginationComponent instead.') %> | ||
<%= render(Blacklight::SearchContext::ServerItemPaginationComponent.new(search_context: @search_context, search_session: search_session, current_document: @current_document)) %> | ||
<%= render(Blacklight::SearchContextComponent.new(search_context: @search_context, search_session: search_session)) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
spec/components/blacklight/search_context/server_item_pagination_component_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.describe Blacklight::SearchContext::ServerItemPaginationComponent, type: :component do | ||
subject(:render) { render_inline(instance) } | ||
|
||
let(:current_document_id) { 9 } | ||
let(:current_document) { SolrDocument.new(id: current_document_id) } | ||
let(:search_session) { { 'document_id' => current_document_id, 'counter' => 1, 'total' => '3' } } | ||
let(:instance) { described_class.new(search_context: search_context, search_session: search_session, current_document: current_document) } | ||
|
||
before do | ||
allow(controller).to receive(:search_session).and_return(search_session) | ||
allow(controller).to receive(:current_search_session).and_return(double(id: current_document_id)) | ||
controller.class.helper_method :search_session | ||
controller.class.helper_method :current_search_session | ||
end | ||
|
||
context 'when there is next and previous' do | ||
let(:search_context) { { next: next_doc, prev: prev_doc } } | ||
let(:prev_doc) { SolrDocument.new(id: '777') } | ||
let(:next_doc) { SolrDocument.new(id: '888') } | ||
|
||
before do | ||
# allow(controller).to receive(:controller_tracking_method).and_return('track_catalog_path') | ||
|
||
allow(controller).to receive_messages(controller_name: 'catalog', link_to_previous_document: '', link_to_next_document: '') | ||
end | ||
|
||
it "renders content" do | ||
expect(render.css('.page-links').to_html).not_to be_blank | ||
end | ||
end | ||
end |
31 changes: 31 additions & 0 deletions
31
spec/components/blacklight/search_context_component_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
RSpec.describe Blacklight::SearchContextComponent, type: :component do | ||
subject(:render) { render_inline(instance) } | ||
|
||
let(:current_document_id) { 9 } | ||
let(:search_session) { { 'document_id' => current_document_id, 'counter' => 1, 'total' => '3' } } | ||
let(:instance) { described_class.new(search_context: search_context, search_session: search_session) } | ||
|
||
before do | ||
allow(controller).to receive(:search_session).and_return(search_session) | ||
allow(controller).to receive(:current_search_session).and_return(double(id: current_document_id)) | ||
controller.class.helper_method :search_session | ||
controller.class.helper_method :current_search_session | ||
end | ||
|
||
context 'when there is next and previous' do | ||
let(:search_context) { { next: next_doc, prev: prev_doc } } | ||
let(:prev_doc) { SolrDocument.new(id: '777') } | ||
let(:next_doc) { SolrDocument.new(id: '888') } | ||
|
||
before do | ||
allow(controller).to receive_messages(controller_name: 'catalog', link_to_previous_document: '', link_to_next_document: '') | ||
end | ||
|
||
it "renders content" do | ||
expect(render.css('.page-links').to_html).not_to be_blank | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters