>
<%= link_to t('hyrax.dashboard.my.works'), hyrax.my_works_path, data: { turbolinks: false } %>
diff --git a/config/locales/hyrax.en.yml b/config/locales/hyrax.en.yml
index 0bd951bcd1..094c9d61c3 100644
--- a/config/locales/hyrax.en.yml
+++ b/config/locales/hyrax.en.yml
@@ -655,6 +655,7 @@ en:
edit_admin_set: "Edit collection" # use same term for admin sets and collections
edit_collection: "Edit collection"
edit_collection_deny: "You do not have sufficient privileges to edit this collection."
+ edit_selected: "Edit Selected"
edit_work: "Edit Work"
highlight: "Highlight Work on Profile"
nesting_not_allowed: "Collections of this type do not support nesting."
diff --git a/spec/controllers/hyrax/batch_edits_controller_spec.rb b/spec/controllers/hyrax/batch_edits_controller_spec.rb
index 3e0bf6beff..ab53ee2f8d 100644
--- a/spec/controllers/hyrax/batch_edits_controller_spec.rb
+++ b/spec/controllers/hyrax/batch_edits_controller_spec.rb
@@ -10,11 +10,13 @@
describe "#edit" do
let(:one) { create(:work, creator: ["Fred"], title: ["abc"], language: ['en']) }
let(:two) { create(:work, creator: ["Wilma"], title: ["abc2"], publisher: ['Rand McNally'], language: ['en'], resource_type: ['bar']) }
+ let(:three) { create(:work, creator: ["Dino"], title: ["abc3"]) }
before do
- controller.batch = [one.id, two.id]
+ controller.batch = [one.id, two.id, three.id]
expect(controller).to receive(:can?).with(:edit, one.id).and_return(true)
expect(controller).to receive(:can?).with(:edit, two.id).and_return(true)
+ expect(controller).to receive(:can?).with(:edit, three.id).and_return(false)
end
it "is successful" do
@@ -29,19 +31,25 @@
describe "update" do
let(:user) { build(:user) }
let!(:one) do
- create(:generic_work, creator: ["Fred"], title: ["abc"], language: ['en'], user: user)
+ create(:work, creator: ["Fred"], title: ["abc"], language: ['en'], user: user)
end
let!(:two) do
- create(:generic_work, creator: ["Fred"], title: ["abc"], language: ['en'], user: user)
+ create(:work, creator: ["Fred"], title: ["abc"], language: ['en'], user: user)
end
+
+ let!(:three) do
+ create(:work, creator: ["Fred"], title: ["abc"], language: ['en'])
+ end
+
let(:mycontroller) { "hyrax/my/works" }
before do
# TODO: why aren't we just submitting batch_document_ids[] as a parameter?
- controller.batch = [one.id, two.id]
+ controller.batch = [one.id, two.id, three.id]
expect(controller).to receive(:can?).with(:edit, one.id).and_return(true)
expect(controller).to receive(:can?).with(:edit, two.id).and_return(true)
+ expect(controller).to receive(:can?).with(:edit, three.id).and_return(false)
end
it "is successful" do
@@ -49,6 +57,7 @@
expect(response).to redirect_to(dashboard_path(locale: 'en'))
expect { GenericWork.find(one.id) }.to raise_error(Ldp::Gone)
expect { GenericWork.find(two.id) }.to raise_error(Ldp::Gone)
+ expect(GenericWork).to exist(three.id)
end
it "redirects to the return controller" do
@@ -61,6 +70,7 @@
expect(response).to be_redirect
expect(GenericWork.find(one.id).subject).to eq ["zzz"]
expect(GenericWork.find(two.id).subject).to eq ["zzz"]
+ expect(GenericWork.find(three.id).subject).to be_empty
end
it "updates permissions" do
@@ -68,6 +78,7 @@
expect(response).to be_redirect
expect(GenericWork.find(one.id).visibility).to eq "authenticated"
expect(GenericWork.find(two.id).visibility).to eq "authenticated"
+ expect(GenericWork.find(three.id).visibility).to eq "restricted"
end
end
diff --git a/spec/controllers/hyrax/dashboard/collections_controller_spec.rb b/spec/controllers/hyrax/dashboard/collections_controller_spec.rb
index faa4b2cb60..7e50f9909b 100644
--- a/spec/controllers/hyrax/dashboard/collections_controller_spec.rb
+++ b/spec/controllers/hyrax/dashboard/collections_controller_spec.rb
@@ -74,7 +74,7 @@
it "adds docs to the collection and adds the collection id to the documents in the collection" do
post :create, params: {
- batch_document_ids: [asset1.id],
+ batch_document_ids: [asset1.id, unowned_asset.id],
collection: collection_attrs
}
diff --git a/spec/features/dashboard/collection_spec.rb b/spec/features/dashboard/collection_spec.rb
index 42ba0a0cd6..ba76c917e1 100644
--- a/spec/features/dashboard/collection_spec.rb
+++ b/spec/features/dashboard/collection_spec.rb
@@ -201,7 +201,7 @@
it "attaches the works", :js do
visit '/dashboard/my/works'
first('input#check_all').click
- click_button "Add to Collection" # opens the modal
+ click_button "Add to collection" # opens the modal
# since there is only one collection, it's not necessary to choose a radio button
click_button "Update Collection"
expect(page).to have_content "Works in this Collection"
@@ -460,14 +460,14 @@
visit "/dashboard/collections/#{collection1.id}"
click_link 'Add existing works'
first('input#check_all').click
- click_button "Add to Collection"
+ click_button "Add to collection"
expect(page).to have_css("input#id_#{collection1.id}[checked='checked']")
expect(page).not_to have_css("input#id_#{collection2.id}[checked='checked']")
visit "/dashboard/collections/#{collection2.id}"
click_link 'Add existing works'
first('input#check_all').click
- click_button "Add to Collection"
+ click_button "Add to collection"
expect(page).not_to have_css("input#id_#{collection1.id}[checked='checked']")
expect(page).to have_css("input#id_#{collection2.id}[checked='checked']")
diff --git a/spec/helpers/hyrax/dashboard_helper_behavior_spec.rb b/spec/helpers/hyrax/dashboard_helper_behavior_spec.rb
index 52e1004f09..625b65d3cb 100644
--- a/spec/helpers/hyrax/dashboard_helper_behavior_spec.rb
+++ b/spec/helpers/hyrax/dashboard_helper_behavior_spec.rb
@@ -17,17 +17,6 @@
end
end
- describe "#on_my_works" do
- it "returns false when the controller isn't my works" do
- allow(helper).to receive(:params).and_return(controller: "hyrax/my/collections")
- expect(helper).not_to be_on_my_works
- end
- it "returns true when the controller is my works" do
- allow(helper).to receive(:params).and_return(controller: "hyrax/my/works")
- expect(helper).to be_on_my_works
- end
- end
-
describe "#number_of_works" do
let(:conn) { ActiveFedora::SolrService.instance.conn }
let(:user1) { User.new(email: "abc@test") }
diff --git a/spec/views/hyrax/my/_search_header.html.erb_spec.rb b/spec/views/hyrax/my/_search_header.html.erb_spec.rb
index 7908e20b8c..9238ea8883 100644
--- a/spec/views/hyrax/my/_search_header.html.erb_spec.rb
+++ b/spec/views/hyrax/my/_search_header.html.erb_spec.rb
@@ -12,25 +12,23 @@
context "on my works page" do
before do
- allow(view).to receive(:on_my_works?).and_return(true)
+ view.lookup_context.prefixes.push "hyrax/my/works"
render 'hyrax/my/search_header', current_tab: 'works'
end
it "has buttons" do
expect(rendered).to have_selector('input[value="Delete Selected"]')
- expect(rendered).to have_selector('button', text: 'Add to Collection')
+ expect(rendered).to have_selector('button', text: 'Add to collection')
expect(rendered).to have_selector('input[value="Edit Selected"]')
end
end
- context "not on my works page (i.e. one of the collections index pages)" do
+ context "on my collections page" do
before do
- allow(view).to receive(:on_my_works?).and_return(false)
+ view.lookup_context.prefixes.push "hyrax/my/collections"
render 'hyrax/my/search_header', current_tab: 'shared'
end
it "has buttons" do
- expect(rendered).not_to have_selector('input[value="Delete Selected"]')
- expect(rendered).not_to have_selector('button', text: 'Add to Collection')
- expect(rendered).not_to have_selector('input[value="Edit Selected"]')
+ expect(rendered).to have_selector('button', text: 'Delete collections')
end
end
end