Skip to content

Commit

Permalink
Fix bulk edit button test
Browse files Browse the repository at this point in the history
Co-authored-by: christinach <actspatial@gmail.com>
  • Loading branch information
hackartisan and christinach committed Feb 12, 2019
1 parent 4201489 commit 8aada76
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 53 deletions.
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/views/collections/_bulk_edit_button.html.erb
Original file line number Diff line number Diff line change
@@ -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' %>
45 changes: 45 additions & 0 deletions spec/features/bulk_edit_spec.rb
Original file line number Diff line number Diff line change
@@ -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
51 changes: 0 additions & 51 deletions spec/features/catalog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8aada76

Please sign in to comment.