-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
the issue in #5522 is that search filters for collections aren't working correctly on `.koppie` (when collections have `model_name` other than `Collection`). the relevant controller specs were completely stubbed on all the related behavior. this unstubs them so there's a narrow test that fails related to the issue.
- Loading branch information
tamsin johnson
committed
Aug 30, 2023
1 parent
0fb3829
commit 285a5a0
Showing
3 changed files
with
47 additions
and
21 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,37 +1,57 @@ | ||
# frozen_string_literal: true | ||
RSpec.describe Hyrax::My::CollectionsController, type: :controller do | ||
describe "logged in user" do | ||
describe "#index" do | ||
let(:user) { create(:user) } | ||
let(:response) { instance_double(Blacklight::Solr::Response, response: { 'numFound' => 3 }) } | ||
let(:doc_list) { [double(id: 123), double(id: 456)] } | ||
|
||
before do | ||
sign_in user | ||
end | ||
RSpec.describe Hyrax::My::CollectionsController, :clean_repo, type: :controller do | ||
context "with a logged in user" do | ||
let(:user) { FactoryBot.create(:user) } | ||
|
||
it "shows the search results and sets breadcrumbs" do | ||
allow_any_instance_of(Hyrax::SearchService).to receive(:search_results).and_return([response, doc_list]) | ||
before { sign_in(user) } | ||
|
||
describe "#index" do | ||
it "sets breadcrumbs" do | ||
expect(controller).to receive(:add_breadcrumb).with('Home', root_path(locale: 'en')) | ||
expect(controller).to receive(:add_breadcrumb).with('Dashboard', dashboard_path(locale: 'en')) | ||
expect(controller).to receive(:add_breadcrumb).with('Collections', my_collections_path(locale: 'en')) | ||
get :index, params: { per_page: 1 } | ||
end | ||
|
||
it "shows empty results with no collections" do | ||
get :index, params: { per_page: 1 } | ||
|
||
get :index, params: { per_page: 2 } | ||
expect(assigns[:document_list].length).to eq 2 | ||
expect(assigns[:document_list]).to be_empty | ||
end | ||
|
||
context "with collections deposited by user" do | ||
let!(:user_collections) do | ||
[FactoryBot.valkyrie_create(:hyrax_collection, user: user), | ||
FactoryBot.valkyrie_create(:hyrax_collection, user: user)] | ||
end | ||
|
||
let!(:other_collections) do | ||
[FactoryBot.valkyrie_create(:hyrax_collection), | ||
FactoryBot.valkyrie_create(:hyrax_collection)] | ||
end | ||
|
||
it "shows only user collections" do | ||
get :index, params: { per_page: 10 } | ||
|
||
expect(assigns[:document_list]) | ||
.to contain_exactly(have_attributes(id: user_collections.first.id), | ||
have_attributes(id: user_collections.last.id)) | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe "#search_facet_path" do | ||
subject { controller.send(:search_facet_path, id: 'keyword_sim') } | ||
|
||
it { is_expected.to eq "/dashboard/my/collections/facet/keyword_sim?locale=en" } | ||
it do | ||
expect(controller.send(:search_facet_path, id: 'keyword_sim')) | ||
.to eq "/dashboard/my/collections/facet/keyword_sim?locale=en" | ||
end | ||
end | ||
|
||
describe "#search_builder_class" do | ||
subject { controller.blacklight_config.search_builder_class } | ||
|
||
it { is_expected.to eq Hyrax::My::CollectionsSearchBuilder } | ||
it 'has a default search builder class'do | ||
expect(controller.blacklight_config.search_builder_class) | ||
.to eq Hyrax::My::CollectionsSearchBuilder | ||
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