spec/controllers/hyrax/my/collections_controller_spec.rb in hyrax-1.1.1 vs spec/controllers/hyrax/my/collections_controller_spec.rb in hyrax-2.0.0.beta1
- old
+ new
@@ -1,29 +1,36 @@
-describe Hyrax::My::CollectionsController, type: :controller do
+RSpec.describe Hyrax::My::CollectionsController, type: :controller do
describe "logged in user" do
describe "#index" do
- let(:user) { create(:user) }
- let(:other) { create(:user) }
+ 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
- build(:public_collection, user: user, id: 1).update_index
- build(:public_collection, user: user, id: 2).update_index
- build(:public_collection, user: user, id: 3).update_index
- unrelated_collection.update_index
end
- let(:unrelated_collection) { build(:public_collection, user: other, id: 4) }
- it "shows only collections I own and paginates the results" do
+ it "shows the search results and sets breadcrumbs" do
+ expect(controller).to receive(:search_results).with(ActionController::Parameters).and_return([response, doc_list])
+
+ expect(controller).to receive(:add_breadcrumb).with('Home', root_path(locale: 'en'))
+ expect(controller).to receive(:add_breadcrumb).with('Administration', dashboard_path(locale: 'en'))
+ expect(controller).to receive(:add_breadcrumb).with('Collections', my_collections_path(locale: 'en'))
+
get :index, params: { per_page: 2 }
expect(assigns[:document_list].length).to eq 2
- expect(assigns[:document_list].map(&:id)).not_to include(unrelated_collection)
- get :index, params: { per_page: 2, page: 2 }
- expect(assigns[:document_list].length).to be >= 1
end
end
+ end
- describe "#search_facet_path" do
- subject { controller.send(:search_facet_path, id: 'keyword_sim') }
- it { is_expected.to eq "/dashboard/collections/facet/keyword_sim?locale=en" }
- 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" }
+ end
+
+ describe "#search_builder_class" do
+ subject { controller.search_builder_class }
+
+ it { is_expected.to eq Hyrax::My::CollectionsSearchBuilder }
end
end