diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e9febc31b8..0012201f72 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -184,6 +184,6 @@ def universal_viewer_path(resource) end def collection_present? - return true if params[:f] && params[:f]["member_of_collection_titles_ssim"].present? + params[:f] && params[:f]["member_of_collection_titles_ssim"].present? end end diff --git a/app/views/collections/_bulk_edit_button.html.erb b/app/views/collections/_bulk_edit_button.html.erb index c97be19031..38b303831e 100644 --- a/app/views/collections/_bulk_edit_button.html.erb +++ b/app/views/collections/_bulk_edit_button.html.erb @@ -1 +1 @@ -<%= link_to 'Bulk Edit', bulk_edit_resources_edit_url, id: "bulk_edit", class: 'btn btn-primary' %> +<%= link_to 'Bulk Edit', bulk_edit_resources_edit_url, id: "bulk-edit", class: 'btn btn-primary' %> diff --git a/spec/features/bulk_edit_spec.rb b/spec/features/bulk_edit_spec.rb new file mode 100644 index 0000000000..3767b1ea4f --- /dev/null +++ b/spec/features/bulk_edit_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true +require "rails_helper" + +RSpec.feature "Bulk edit", javascript: true do + let(:user) { FactoryBot.create(:admin) } + let(:adapter) { Valkyrie::MetadataAdapter.find(:indexing_persister) } + let(:collection_title) { "My Collection" } + let(:collection) { FactoryBot.create_for_repository(:collection, title: collection_title) } + let(:member_scanned_resource) do + FactoryBot.create_for_repository(:scanned_resource, title: ["Member Resource"], member_of_collection_ids: [collection.id]) + end + let(:nonmember_scanned_resource) do + FactoryBot.create_for_repository(:scanned_resource, title: ["Nonmember Resource"]) + end + let(:change_set_persister) do + ChangeSetPersister.new(metadata_adapter: adapter, storage_adapter: Valkyrie.config.storage_adapter) + end + + before do + [collection, member_scanned_resource, nonmember_scanned_resource].each do |resource| + change_set = DynamicChangeSet.new(resource) + change_set_persister.save(change_set: change_set) + end + sign_in user + end + + context "the bulk edit button" do + it "will not display in an empty search" do + visit root_path(q: "") + + expect(page).not_to have_css("#bulk-edit") + expect(page).to have_content("My Collection") + expect(page).to have_content("Member Resource") + expect(page).to have_content("Nonmember Resource") + end + + it "will display when a collection is selected" do + visit root_path("q" => "", "f[member_of_collection_titles_ssim][]" => "My Collection") + + expect(page).to have_content("Member Resource") + expect(page).not_to have_content("Nonmember Resource") + expect(page).to have_css("#bulk-edit") + end + end +end diff --git a/spec/features/catalog_spec.rb b/spec/features/catalog_spec.rb index 901360934b..76fe186752 100644 --- a/spec/features/catalog_spec.rb +++ b/spec/features/catalog_spec.rb @@ -27,55 +27,4 @@ expect(page).to have_content "New test work" end end - - context "the bulk edit button" do - it "will not display in an empty search" do - visit root_path - click_button id: "keyword-search-submit" - expect(page).not_to have_css("#bulk-edit > button") - end - - let(:collection) { FactoryBot.create_for_repository(:collection) } - let(:simple_resource) do - FactoryBot.create_for_repository( - :simple_resource, - title: "new simple resource", - rights_statement: RightsStatements.copyright_not_evaluated.to_s, - rights_note: "test rights note", - local_identifier: "test ID", - portion_note: "test portion note", - nav_date: "01/01/1970", - member_of_collection_ids: [collection.id], - abstract: "test value", - alternative: "test value", - alternative_title: "test value", - bibliographic_citation: "test value", - contents: "test value", - extent: "test value", - genre: "test value", - geo_subject: "test value", - identifier: "test value", - license: "test value", - part_of: "test value", - replaces: "test value", - type: "test value", - contributor: "test value", - coverage: "test value", - creator: "test value", - date: "01/01/1970", - description: "test value", - keyword: "test value", - language: "test value", - publisher: "test value", - source: "test value", - subject: "test value" - ) - end - - it "will not display when a collection is selected" do - visit edit_scanned_resource_path(simple_resource) - expect(current_path).to eq "/catalog/#{simple_resource.id}" - expect(page).not_to have_css("#bulk-edit > button") - end - end end