hyrax 2.1.0.rc1 → 2.1.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/CONTRIBUTING.md +6 -6
- data/README.md +18 -8
- data/app/assets/javascripts/hyrax/app.js.erb +1 -1
- data/app/assets/javascripts/hyrax/collections.js +16 -13
- data/app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee +12 -0
- data/app/assets/stylesheets/hyrax/dashboard.scss +4 -0
- data/app/controllers/hyrax/dashboard/collections_controller.rb +4 -7
- data/app/controllers/hyrax/my_controller.rb +1 -0
- data/app/helpers/hyrax/collections_helper.rb +9 -0
- data/app/models/sipity/workflow.rb +6 -7
- data/app/presenters/hyrax/work_show_presenter.rb +4 -1
- data/app/services/hyrax/adapters/nesting_index_adapter.rb +1 -0
- data/app/services/hyrax/collection_types/create_service.rb +2 -2
- data/app/services/hyrax/file_set_fixity_check_service.rb +1 -1
- data/app/views/hyrax/dashboard/collections/_form.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_form_for_select_collection.html.erb +11 -6
- data/app/views/hyrax/dashboard/collections/_modal_parent_collection_remove_deny.html.erb +14 -0
- data/app/views/hyrax/dashboard/collections/_show_add_items_actions.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_show_parent_collection_row.html.erb +11 -1
- data/app/views/hyrax/dashboard/collections/show.html.erb +1 -0
- data/app/views/hyrax/my/collections/_modal_collection_types_to_create.html.erb +1 -1
- data/app/views/hyrax/my/collections/index.html.erb +8 -2
- data/app/views/hyrax/my/works/_tabs.html.erb +1 -2
- data/app/views/hyrax/my/works/index.html.erb +11 -0
- data/config/locales/hyrax.de.yml +19 -8
- data/config/locales/hyrax.en.yml +14 -3
- data/config/locales/hyrax.es.yml +13 -2
- data/config/locales/hyrax.fr.yml +13 -2
- data/config/locales/hyrax.it.yml +13 -2
- data/config/locales/hyrax.pt-BR.yml +13 -2
- data/config/locales/hyrax.zh.yml +13 -2
- data/hyrax.gemspec +1 -1
- data/lib/generators/hyrax/templates/db/migrate/20170810190549_update_collection_type_column_options.rb.erb +9 -1
- data/lib/hyrax/version.rb +1 -1
- data/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +2 -3
- data/spec/features/collection_multi_membership_spec.rb +32 -33
- data/spec/features/dashboard/all_works.rb +2 -1
- data/spec/features/dashboard/collection_spec.rb +35 -13
- data/spec/features/work_show_spec.rb +6 -6
- data/spec/helpers/hyrax/collections_helper_spec.rb +16 -0
- data/spec/models/sipity/workflow_spec.rb +9 -0
- data/spec/presenters/hyrax/work_show_presenter_spec.rb +2 -2
- data/spec/services/hyrax/adapters/nesting_index_adapter_spec.rb +7 -3
- data/spec/services/hyrax/collection_types/create_service_spec.rb +2 -2
- data/spec/services/hyrax/collections_service_spec.rb +1 -1
- data/spec/services/hyrax/file_set_fixity_check_service_spec.rb +13 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/optional_example.rb +16 -0
- data/spec/support/selectors.rb +15 -1
- data/spec/views/hyrax/dashboard/collections/_form_for_select_collection.html.erb_spec.rb +13 -21
- data/spec/views/hyrax/dashboard/collections/_show_add_items_actions.html.erb_spec.rb +5 -3
- data/spec/views/hyrax/dashboard/collections/_show_parent_collection_row.html.erb_spec.rb +35 -15
- data/spec/views/hyrax/my/collections/index.html.erb_spec.rb +34 -0
- data/spec/views/hyrax/my/works/index.html.erb_spec.rb +3 -0
- data/template.rb +1 -1
- metadata +15 -4
@@ -1,4 +1,4 @@
|
|
1
|
-
RSpec.describe "As an admin user I should be able to see all works" do
|
1
|
+
RSpec.describe "As an admin user I should be able to see all works", :clean_repo do
|
2
2
|
let!(:work1) { create(:work, title: ['Testing #1'], admin_set: adminset, member_of_collections: [collection]) }
|
3
3
|
let!(:work2) { create(:work, title: ['Testing #2'], admin_set: adminset, member_of_collections: [collection]) }
|
4
4
|
let(:collection) { build(:collection_lw, with_solr_document: true) }
|
@@ -18,5 +18,6 @@ RSpec.describe "As an admin user I should be able to see all works" do
|
|
18
18
|
expect(page).to have_link(collection.title.first, class: 'facet_select')
|
19
19
|
expect(page).to have_button('Admin Set')
|
20
20
|
expect(page).to have_link(adminset.title.first, class: 'facet_select')
|
21
|
+
expect(page).to have_content("2 works in the repository")
|
21
22
|
end
|
22
23
|
end
|
@@ -36,7 +36,7 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
|
|
36
36
|
visit '/dashboard/my/collections'
|
37
37
|
end
|
38
38
|
|
39
|
-
it "has page title, does not have tabs,
|
39
|
+
it "has page title, does not have tabs, lists only user's collections, and displays number of collections in the respository" do
|
40
40
|
expect(page).to have_content 'Collections'
|
41
41
|
expect(page).not_to have_link 'All Collections'
|
42
42
|
within('section.tabs-row') do
|
@@ -47,6 +47,7 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
|
|
47
47
|
expect(page).to have_link(admin_set_b.title.first)
|
48
48
|
expect(page).not_to have_link(collection3.title.first)
|
49
49
|
expect(page).not_to have_link(admin_set_a.title.first)
|
50
|
+
expect(page).to have_content("3 collections you own in the repository")
|
50
51
|
end
|
51
52
|
|
52
53
|
it "has collection type and visibility filters" do
|
@@ -256,6 +257,11 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
|
|
256
257
|
expect(page).to have_content title
|
257
258
|
expect(page).to have_content description
|
258
259
|
end
|
260
|
+
|
261
|
+
it "has properly formed collection type buttons" do
|
262
|
+
expect(page).not_to have_selector("input[data-path$='collections/new&collection_type_id=1']")
|
263
|
+
expect(page).to have_selector("input[data-path$='collections/new?locale=en&collection_type_id=1']")
|
264
|
+
end
|
259
265
|
end
|
260
266
|
|
261
267
|
context 'when user can create collections of one type' do
|
@@ -357,7 +363,9 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
|
|
357
363
|
|
358
364
|
context 'and collection is empty' do
|
359
365
|
it 'and user confirms delete, deletes the collection', :js do
|
360
|
-
|
366
|
+
within("table#collections-list-table") do
|
367
|
+
expect(page).to have_content(empty_collection.title.first)
|
368
|
+
end
|
361
369
|
check_tr_data_attributes(empty_collection.id, 'collection')
|
362
370
|
# check that modal data attributes haven't been added yet
|
363
371
|
expect(page).not_to have_selector("div[data-id='#{empty_collection.id}']")
|
@@ -370,11 +378,15 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
|
|
370
378
|
within("div#collection-empty-to-delete-modal") do
|
371
379
|
click_button('Delete')
|
372
380
|
end
|
373
|
-
|
381
|
+
within("table#collections-list-table") do
|
382
|
+
expect(page).not_to have_content(empty_collection.title.first)
|
383
|
+
end
|
374
384
|
end
|
375
385
|
|
376
386
|
it 'and user cancels, does NOT delete the collection', :js do
|
377
|
-
|
387
|
+
within("table#collections-list-table") do
|
388
|
+
expect(page).to have_content(collection.title.first)
|
389
|
+
end
|
378
390
|
check_tr_data_attributes(empty_collection.id, 'collection')
|
379
391
|
# check that modal data attributes haven't been added yet
|
380
392
|
expect(page).not_to have_selector("div[data-id='#{empty_collection.id}']")
|
@@ -388,13 +400,17 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
|
|
388
400
|
within("div#collection-empty-to-delete-modal") do
|
389
401
|
click_button('Cancel')
|
390
402
|
end
|
391
|
-
|
403
|
+
within("table#collections-list-table") do
|
404
|
+
expect(page).to have_content(collection.title.first)
|
405
|
+
end
|
392
406
|
end
|
393
407
|
end
|
394
408
|
|
395
409
|
context 'and collection is not empty' do
|
396
410
|
it 'and user confirms delete, deletes the collection', :js do
|
397
|
-
|
411
|
+
within("table#collections-list-table") do
|
412
|
+
expect(page).to have_content(collection.title.first)
|
413
|
+
end
|
398
414
|
check_tr_data_attributes(collection.id, 'collection')
|
399
415
|
within("#document_#{collection.id}") do
|
400
416
|
first('button.dropdown-toggle').click
|
@@ -405,11 +421,15 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
|
|
405
421
|
within("div#collection-to-delete-modal") do
|
406
422
|
find('button.modal-delete-button').click
|
407
423
|
end
|
408
|
-
|
424
|
+
within("table#collections-list-table") do
|
425
|
+
expect(page).not_to have_content(collection.title.first)
|
426
|
+
end
|
409
427
|
end
|
410
428
|
|
411
429
|
it 'and user cancels, does NOT delete the collection', :js do
|
412
|
-
|
430
|
+
within("table#collections-list-table") do
|
431
|
+
expect(page).to have_content(collection.title.first)
|
432
|
+
end
|
413
433
|
within("#document_#{collection.id}") do
|
414
434
|
first('button.dropdown-toggle').click
|
415
435
|
first('.itemtrash').click
|
@@ -419,7 +439,9 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
|
|
419
439
|
within("div#collection-to-delete-modal") do
|
420
440
|
click_button('Cancel')
|
421
441
|
end
|
422
|
-
|
442
|
+
within("table#collections-list-table") do
|
443
|
+
expect(page).to have_content(collection.title.first)
|
444
|
+
end
|
423
445
|
end
|
424
446
|
end
|
425
447
|
end
|
@@ -611,15 +633,15 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
|
|
611
633
|
click_link 'Add existing works'
|
612
634
|
first('input#check_all').click
|
613
635
|
click_button "Add to collection"
|
614
|
-
expect(page).to
|
615
|
-
expect(page).
|
636
|
+
expect(page).to have_selector "#member_of_collection_ids[value=\"#{collection1.id}\"]", visible: false
|
637
|
+
expect(page).to have_selector "#member_of_collection_label[value=\"#{collection1.title.first}\"]"
|
616
638
|
|
617
639
|
visit "/dashboard/collections/#{collection2.id}"
|
618
640
|
click_link 'Add existing works'
|
619
641
|
first('input#check_all').click
|
620
642
|
click_button "Add to collection"
|
621
|
-
expect(page).
|
622
|
-
expect(page).to
|
643
|
+
expect(page).to have_selector "#member_of_collection_ids[value=\"#{collection2.id}\"]", visible: false
|
644
|
+
expect(page).to have_selector "#member_of_collection_label[value=\"#{collection2.title.first}\"]"
|
623
645
|
|
624
646
|
click_button "Save changes"
|
625
647
|
expect(page).to have_content(work1.title.first)
|
@@ -1,4 +1,6 @@
|
|
1
1
|
RSpec.describe "display a work as its owner" do
|
2
|
+
include Selectors::Dashboard
|
3
|
+
|
2
4
|
let(:work_path) { "/concern/generic_works/#{work.id}" }
|
3
5
|
|
4
6
|
before do
|
@@ -44,13 +46,11 @@ RSpec.describe "display a work as its owner" do
|
|
44
46
|
expect(find('div.viewer:first')['data-uri']).to eq "/concern/generic_works/#{work.id}/manifest"
|
45
47
|
end
|
46
48
|
|
47
|
-
it "add work to a collection", js: true do
|
49
|
+
it "add work to a collection", clean_repo: true, js: true do
|
50
|
+
optional 'ability to get capybara to find css select2-result (see Issue #3038)' if ENV['TRAVIS']
|
48
51
|
click_button "Add to collection" # opens the modal
|
49
|
-
|
50
|
-
|
51
|
-
choose collection.title.first # selects the collection
|
52
|
-
click_button 'Save changes'
|
53
|
-
end
|
52
|
+
select_member_of_collection(collection)
|
53
|
+
click_button 'Save changes'
|
54
54
|
|
55
55
|
# forwards to collection show page
|
56
56
|
expect(page).to have_content collection.title.first
|
@@ -98,4 +98,20 @@ RSpec.describe Hyrax::CollectionsHelper do
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
101
|
+
|
102
|
+
describe '#append_collection_type_url' do
|
103
|
+
let(:url) { "http://example.com" }
|
104
|
+
context "when a provided url has no querystring" do
|
105
|
+
it 'returns the url with added collection_type_id' do
|
106
|
+
expect(append_collection_type_url(url, '1')).to eq "#{url}?collection_type_id=1"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "when a provided url has an existing querystring" do
|
111
|
+
let(:url) { "http://example.com?bob=ross" }
|
112
|
+
it 'return the url with added collection_type_id' do
|
113
|
+
expect(append_collection_type_url(url, '1')).to eq "#{url}&collection_type_id=1"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
101
117
|
end
|
@@ -22,6 +22,15 @@ module Sipity
|
|
22
22
|
let!(:other_permission_template) { create(:permission_template) }
|
23
23
|
let!(:active_workflow) { create(:workflow, active: true, permission_template_id: permission_template.id) }
|
24
24
|
|
25
|
+
context 'selecting already active workflow' do
|
26
|
+
it 'makes no change' do
|
27
|
+
inactive_workflow = create(:workflow, permission_template_id: permission_template.id)
|
28
|
+
described_class.activate!(permission_template: permission_template, workflow_id: active_workflow.id)
|
29
|
+
expect(active_workflow.reload).to be_active
|
30
|
+
expect(inactive_workflow.reload).not_to be_active
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
25
34
|
it 'raises an exception if you do not pass a workflow_id nor workflow_name' do
|
26
35
|
expect do
|
27
36
|
described_class.activate!(permission_template: other_permission_template)
|
@@ -47,7 +47,7 @@ RSpec.describe Hyrax::WorkShowPresenter do
|
|
47
47
|
let(:id_present) { false }
|
48
48
|
let(:representative_presenter) { double('representative', present?: false) }
|
49
49
|
let(:image_boolean) { false }
|
50
|
-
let(:iiif_enabled) {
|
50
|
+
let(:iiif_enabled) { true }
|
51
51
|
let(:file_set_presenter) { Hyrax::FileSetPresenter.new(solr_document, ability) }
|
52
52
|
let(:file_set_presenters) { [file_set_presenter] }
|
53
53
|
let(:read_permission) { true }
|
@@ -77,7 +77,7 @@ RSpec.describe Hyrax::WorkShowPresenter do
|
|
77
77
|
context 'with non-image representative_presenter' do
|
78
78
|
let(:id_present) { true }
|
79
79
|
let(:representative_presenter) { double('representative', present?: true) }
|
80
|
-
let(:image_boolean) {
|
80
|
+
let(:image_boolean) { false }
|
81
81
|
|
82
82
|
it { is_expected.to be false }
|
83
83
|
end
|
@@ -38,12 +38,16 @@ RSpec.describe Hyrax::Adapters::NestingIndexAdapter do
|
|
38
38
|
describe '.find_index_document_by' do
|
39
39
|
subject { described_class.find_index_document_by(id: id) }
|
40
40
|
|
41
|
-
context 'with
|
41
|
+
context 'with id not in solr, it builds from Fedora' do
|
42
42
|
let(:id) { 'so-very-missing-no-document-here' }
|
43
|
+
let(:document) { double("Document", id: id, fetch: nil) }
|
44
|
+
let(:object) { double("Object_to_reindex", id: id, to_solr: document) }
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
+
before do
|
47
|
+
allow(ActiveFedora::Base).to receive(:find).with(id).and_return(object)
|
46
48
|
end
|
49
|
+
|
50
|
+
it { is_expected.to be_a(Samvera::NestingIndexer::Documents::IndexDocument) }
|
47
51
|
end
|
48
52
|
|
49
53
|
context 'with a found id' do
|
@@ -43,7 +43,7 @@ RSpec.describe Hyrax::CollectionTypes::CreateService do
|
|
43
43
|
expect(ct.machine_id).to eq(Hyrax::CollectionType::ADMIN_SET_MACHINE_ID)
|
44
44
|
expect(ct.title).to eq(Hyrax::CollectionType::ADMIN_SET_DEFAULT_TITLE)
|
45
45
|
expect(ct.description).to eq('An aggregation of works that is intended to help with administrative control. Admin Sets provide a way of defining behaviors and policies around a set of works.')
|
46
|
-
expect(ct.badge_color).to eq('#
|
46
|
+
expect(ct.badge_color).to eq('#405060')
|
47
47
|
expect(ct).not_to be_nestable
|
48
48
|
expect(ct).not_to be_brandable
|
49
49
|
expect(ct).not_to be_discoverable
|
@@ -63,7 +63,7 @@ RSpec.describe Hyrax::CollectionTypes::CreateService do
|
|
63
63
|
expect(ct.machine_id).to eq(Hyrax::CollectionType::USER_COLLECTION_MACHINE_ID)
|
64
64
|
expect(ct.title).to eq(Hyrax::CollectionType::USER_COLLECTION_DEFAULT_TITLE)
|
65
65
|
expect(ct.description).to eq('A User Collection can be created by any user to organize their works.')
|
66
|
-
expect(ct.badge_color).to eq('#
|
66
|
+
expect(ct.badge_color).to eq('#705070')
|
67
67
|
expect(ct).to be_nestable
|
68
68
|
expect(ct).to be_brandable
|
69
69
|
expect(ct).to be_discoverable
|
@@ -38,7 +38,7 @@ RSpec.describe Hyrax::CollectionsService do
|
|
38
38
|
context "with read access" do
|
39
39
|
let(:access) { :read }
|
40
40
|
|
41
|
-
it "returns
|
41
|
+
it "returns four collections" do
|
42
42
|
expect(subject.map(&:id)).to match_array [collection1.id, collection2.id, collection3.id, collection4.id]
|
43
43
|
end
|
44
44
|
end
|
@@ -49,6 +49,19 @@ RSpec.describe Hyrax::FileSetFixityCheckService do
|
|
49
49
|
specify 'returns a single result' do
|
50
50
|
expect(subject.length).to eq(1)
|
51
51
|
end
|
52
|
+
describe 'non-versioned file with latest version only' do
|
53
|
+
let(:service_by_object) { described_class.new(f, async_jobs: false, latest_version_only: true) }
|
54
|
+
|
55
|
+
before do
|
56
|
+
allow(f.original_file).to receive(:has_versions?).and_return(false)
|
57
|
+
end
|
58
|
+
|
59
|
+
subject { service_by_object.send(:fixity_check_file, f.original_file) }
|
60
|
+
|
61
|
+
specify 'returns a single result' do
|
62
|
+
expect(subject.length).to eq(1)
|
63
|
+
end
|
64
|
+
end
|
52
65
|
end
|
53
66
|
|
54
67
|
describe '#fixity_check_file_version' do
|
data/spec/spec_helper.rb
CHANGED
@@ -226,6 +226,7 @@ RSpec.configure do |config|
|
|
226
226
|
config.include Capybara::RSpecMatchers, type: :input
|
227
227
|
config.include InputSupport, type: :input
|
228
228
|
config.include FactoryBot::Syntax::Methods
|
229
|
+
config.include OptionalExample
|
229
230
|
|
230
231
|
config.infer_spec_type_from_file_location!
|
231
232
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module OptionalExample
|
2
|
+
RSpec.configure do |config|
|
3
|
+
config.after do |example|
|
4
|
+
if example.metadata[:optional] && (RSpec::Core::Pending::PendingExampleFixedError === example.display_exception) # rubocop:disable Style/CaseEquality
|
5
|
+
ex = example.display_exception
|
6
|
+
example.display_exception = nil
|
7
|
+
example.execution_result.pending_exception = ex
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def optional(message)
|
13
|
+
RSpec.current_example.metadata[:optional] = true
|
14
|
+
pending(message)
|
15
|
+
end
|
16
|
+
end
|
data/spec/support/selectors.rb
CHANGED
@@ -21,7 +21,8 @@ module Selectors
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
# For use with javascript collection selector that allows for searching for an existing collection.
|
24
|
+
# For use with javascript collection selector that allows for searching for an existing collection from works relationship tab.
|
25
|
+
# Adds the collection and validates that the collection is listed in the Collection Relationship table once added.
|
25
26
|
# @param [Collection] collection to select
|
26
27
|
def select_collection(collection)
|
27
28
|
first('a.select2-choice').click
|
@@ -35,6 +36,19 @@ module Selectors
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
39
|
+
|
40
|
+
# For use with javascript collection selector that allows for searching for an existing collection from add to collection modal.
|
41
|
+
# Does not save the selection. The calling test is expected to click Save and validate the collection membership was added to the work.
|
42
|
+
# @param [Collection] collection to select
|
43
|
+
def select_member_of_collection(collection)
|
44
|
+
find('#s2id_member_of_collection_ids').click
|
45
|
+
find('.select2-input').set(collection.title.first)
|
46
|
+
sleep 10
|
47
|
+
expect(page).to have_css('.select2-result')
|
48
|
+
within ".select2-result" do
|
49
|
+
find("span", text: collection.title.first).click
|
50
|
+
end
|
51
|
+
end
|
38
52
|
end
|
39
53
|
|
40
54
|
module NewTransfers
|
@@ -17,7 +17,7 @@ RSpec.describe 'hyrax/dashboard/collections/_form_for_select_collection.html.erb
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
let(:
|
20
|
+
let(:page) { Capybara::Node::Simple.new(rendered) }
|
21
21
|
|
22
22
|
before do
|
23
23
|
# Stub route because view specs don't handle engine routes
|
@@ -27,29 +27,21 @@ RSpec.describe 'hyrax/dashboard/collections/_form_for_select_collection.html.erb
|
|
27
27
|
allow(view).to receive(:user_collections).and_return(solr_collections)
|
28
28
|
end
|
29
29
|
|
30
|
-
it "
|
30
|
+
it "uses autocomplete" do
|
31
31
|
render
|
32
|
-
|
33
|
-
expect(collection_ids).to eql(["id_1237", "id_1234", "id_1235", "id_1236"])
|
34
|
-
expect(rendered).to have_selector("label", text: 'Title 1')
|
35
|
-
expect(rendered).not_to have_selector("label", text: "[\"Title 1\"]")
|
32
|
+
expect(page).to have_selector('input[data-autocomplete-url="/authorities/search/collections?access=deposit"]')
|
36
33
|
end
|
37
34
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
expect(rendered).not_to have_selector "#id_#{collections[0][:id]}[checked='checked']"
|
42
|
-
expect(rendered).not_to have_selector "#id_#{collections[1][:id]}[checked='checked']"
|
43
|
-
expect(rendered).not_to have_selector "#id_#{collections[3][:id]}[checked='checked']"
|
44
|
-
expect(rendered).to have_selector "#id_#{collections[2][:id]}[checked='checked']"
|
45
|
-
end
|
35
|
+
context 'when a collection is specified' do
|
36
|
+
let(:collection_id) { collections[2][:id] }
|
37
|
+
let(:collection_label) { collections[2]["title_tesim"] }
|
46
38
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
39
|
+
it "selects the right collection when instructed to do so" do
|
40
|
+
assign(:add_works_to_collection, collection_id)
|
41
|
+
assign(:add_works_to_collection_label, collection_label)
|
42
|
+
render
|
43
|
+
expect(page).to have_selector "#member_of_collection_ids[value=\"#{collection_id}\"]", visible: false
|
44
|
+
expect(page).to have_selector "#member_of_collection_label", text: collection_label
|
45
|
+
end
|
54
46
|
end
|
55
47
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
RSpec.describe 'hyrax/dashboard/collections/_show_add_items_actions.html.erb', type: :view do
|
2
|
-
let(:presenter) { double('Hyrax::CollectionPresenter', solr_document: solr_document, id: '123') }
|
2
|
+
let(:presenter) { double('Hyrax::CollectionPresenter', solr_document: solr_document, id: '123', title: 'Collection 1') }
|
3
3
|
let(:solr_document) { double('Solr Document') }
|
4
4
|
let(:can_deposit) { true }
|
5
5
|
|
@@ -14,7 +14,8 @@ RSpec.describe 'hyrax/dashboard/collections/_show_add_items_actions.html.erb', t
|
|
14
14
|
|
15
15
|
it 'renders add_existing_works_to_collection link' do
|
16
16
|
render
|
17
|
-
expect(rendered).to have_css(".btn[href='#{hyrax.my_works_path(add_works_to_collection: presenter.id
|
17
|
+
expect(rendered).to have_css(".btn[href='#{hyrax.my_works_path(add_works_to_collection: presenter.id,
|
18
|
+
add_works_to_collection_label: presenter.title)}']")
|
18
19
|
end
|
19
20
|
it 'renders add_new_work_to_collection link' do
|
20
21
|
render
|
@@ -26,7 +27,8 @@ RSpec.describe 'hyrax/dashboard/collections/_show_add_items_actions.html.erb', t
|
|
26
27
|
|
27
28
|
it 'does not render add_works_to_collection link' do
|
28
29
|
render
|
29
|
-
expect(rendered).not_to have_css(".actions-controls-collections .btn[href='#{hyrax.my_works_path(add_works_to_collection: presenter.id
|
30
|
+
expect(rendered).not_to have_css(".actions-controls-collections .btn[href='#{hyrax.my_works_path(add_works_to_collection: presenter.id,
|
31
|
+
add_works_to_collection_label: presenter.title)}']")
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -9,33 +9,53 @@ RSpec.describe 'hyrax/dashboard/collections/_show_parent_collection_row.html.erb
|
|
9
9
|
let(:document) { SolrDocument.new(parent_collection_doc) }
|
10
10
|
let(:subject) { render('show_parent_collection_row.html.erb', id: child_collection.id, document: document) }
|
11
11
|
|
12
|
-
context 'when user
|
12
|
+
context 'when user cannot edit the child collection' do
|
13
13
|
before do
|
14
|
+
allow(view).to receive(:can?).with(:edit, child_collection.id).and_return(false)
|
14
15
|
allow(view).to receive(:can?).with(:edit, document.id).and_return(true)
|
15
16
|
end
|
16
17
|
|
17
|
-
it 'shows link to collection title
|
18
|
+
it 'does shows link to collection title but not the remove button' do
|
18
19
|
subject
|
19
20
|
expect(rendered).to have_link(document.title.first)
|
20
|
-
expect(rendered).
|
21
|
-
|
22
|
-
|
23
|
-
it "renders the proper data attributes on list element" do
|
24
|
-
expect(subject).to have_selector(:css, 'li[data-post-url="/dashboard/collections/123/remove_parent/999"]')
|
25
|
-
expect(subject).to have_selector(:css, 'li[data-id="123"]')
|
26
|
-
expect(subject).to have_selector(:css, 'li[data-parent-id="999"]')
|
21
|
+
expect(rendered).not_to have_button("Remove")
|
22
|
+
expect(rendered).not_to have_link("Remove")
|
27
23
|
end
|
28
24
|
end
|
29
25
|
|
30
|
-
context '
|
26
|
+
context 'when user can edit the child collection' do
|
31
27
|
before do
|
32
|
-
allow(view).to receive(:can?).with(:edit,
|
28
|
+
allow(view).to receive(:can?).with(:edit, child_collection.id).and_return(true)
|
33
29
|
end
|
34
30
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
context 'and user can edit the parent collection' do
|
32
|
+
before do
|
33
|
+
allow(view).to receive(:can?).with(:edit, document.id).and_return(true)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'shows link to collection title and active remove button' do
|
37
|
+
subject
|
38
|
+
expect(rendered).to have_link(document.title.first)
|
39
|
+
expect(rendered).to have_button("Remove")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "renders the proper data attributes on list element" do
|
43
|
+
expect(subject).to have_selector(:css, 'li[data-post-url="/dashboard/collections/123/remove_parent/999"]')
|
44
|
+
expect(subject).to have_selector(:css, 'li[data-id="123"]')
|
45
|
+
expect(subject).to have_selector(:css, 'li[data-parent-id="999"]')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'and user cannot edit the parent collection' do
|
50
|
+
before do
|
51
|
+
allow(view).to receive(:can?).with(:edit, document.id).and_return(false)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'shows link to collection title and active remove link' do
|
55
|
+
subject
|
56
|
+
expect(rendered).to have_link(document.title.first)
|
57
|
+
expect(rendered).to have_link("Remove")
|
58
|
+
end
|
39
59
|
end
|
40
60
|
end
|
41
61
|
end
|