hyrax 2.3.3 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +1 -1
  3. data/.github/stale.yml +19 -0
  4. data/README.md +2 -2
  5. data/app/actors/hyrax/actors/apply_permission_template_actor.rb +2 -4
  6. data/app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb +45 -0
  7. data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +96 -0
  8. data/app/actors/hyrax/actors/file_set_ordered_members_actor.rb +16 -0
  9. data/app/actors/hyrax/actors/ordered_members_actor.rb +28 -0
  10. data/app/assets/javascripts/hyrax/collections.js +2 -0
  11. data/app/assets/stylesheets/hyrax/_file-listing.scss +2 -1
  12. data/app/assets/stylesheets/hyrax/_work-show.scss +4 -0
  13. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +1 -1
  14. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +5 -2
  15. data/app/controllers/hyrax/dashboard/nest_collections_controller.rb +2 -9
  16. data/app/helpers/hyrax/batch_edits_helper.rb +0 -1
  17. data/app/helpers/hyrax/hyrax_helper_behavior.rb +1 -0
  18. data/app/helpers/hyrax/iiif_helper.rb +12 -0
  19. data/app/jobs/attach_files_to_work_with_ordered_members_job.rb +41 -0
  20. data/app/presenters/hyrax/work_show_presenter.rb +29 -2
  21. data/app/services/hyrax/permission_template_applicator.rb +48 -0
  22. data/app/views/hyrax/admin/collection_types/_form_settings.html.erb +1 -1
  23. data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
  24. data/app/views/hyrax/base/_form_rendering.html.erb +7 -5
  25. data/app/views/hyrax/base/_form_representative.html.erb +4 -2
  26. data/app/views/hyrax/base/_form_thumbnail.html.erb +4 -2
  27. data/app/views/hyrax/base/_member.html.erb +1 -1
  28. data/app/views/hyrax/base/_representative_media.html.erb +1 -4
  29. data/app/views/hyrax/base/_show_actions.html.erb +6 -4
  30. data/app/views/hyrax/base/iiif_viewers/_universal_viewer.html.erb +4 -0
  31. data/app/views/hyrax/base/show.html.erb +2 -2
  32. data/app/views/hyrax/dashboard/works/_default_group.html.erb +1 -1
  33. data/app/views/hyrax/file_sets/_file_set_title.erb +2 -2
  34. data/app/views/hyrax/homepage/_featured.html.erb +0 -3
  35. data/app/views/hyrax/my/_collection_action_menu.html.erb +1 -0
  36. data/app/views/hyrax/my/collections/_default_group.html.erb +1 -9
  37. data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
  38. data/app/views/hyrax/users/_activity_log.html.erb +1 -1
  39. data/config/locales/hyrax.de.yml +2 -0
  40. data/config/locales/hyrax.en.yml +2 -0
  41. data/config/locales/hyrax.es.yml +2 -0
  42. data/config/locales/hyrax.fr.yml +2 -0
  43. data/config/locales/hyrax.it.yml +2 -0
  44. data/config/locales/hyrax.pt-BR.yml +2 -0
  45. data/config/locales/hyrax.zh.yml +2 -0
  46. data/hyrax.gemspec +1 -0
  47. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +1 -1
  48. data/lib/generators/hyrax/templates/config/locales/hyrax.de.yml +1 -1
  49. data/lib/generators/hyrax/templates/config/locales/hyrax.en.yml +1 -1
  50. data/lib/generators/hyrax/templates/config/locales/hyrax.es.yml +1 -1
  51. data/lib/generators/hyrax/templates/config/locales/hyrax.fr.yml +1 -1
  52. data/lib/generators/hyrax/templates/config/locales/hyrax.it.yml +1 -1
  53. data/lib/generators/hyrax/templates/config/locales/hyrax.zh.yml +1 -1
  54. data/lib/hyrax/configuration.rb +1 -1
  55. data/lib/hyrax/transactions.rb +23 -0
  56. data/lib/hyrax/transactions/container.rb +63 -0
  57. data/lib/hyrax/transactions/create_work.rb +47 -0
  58. data/lib/hyrax/transactions/steps/apply_permission_template.rb +29 -0
  59. data/lib/hyrax/transactions/steps/ensure_admin_set.rb +23 -0
  60. data/lib/hyrax/transactions/steps/ensure_permission_template.rb +27 -0
  61. data/lib/hyrax/transactions/steps/save_work.rb +35 -0
  62. data/lib/hyrax/transactions/steps/set_default_admin_set.rb +25 -0
  63. data/lib/hyrax/transactions/steps/set_modified_date.rb +25 -0
  64. data/lib/hyrax/transactions/steps/set_uploaded_date.rb +28 -0
  65. data/lib/hyrax/version.rb +1 -1
  66. data/spec/actors/hyrax/actors/create_with_files_ordered_members_actor_spec.rb +41 -0
  67. data/spec/actors/hyrax/actors/create_with_remote_files_ordered_members_actor_spec.rb +49 -0
  68. data/spec/actors/hyrax/actors/file_set_ordered_members_actor_spec.rb +35 -0
  69. data/spec/actors/hyrax/actors/ordered_members_actor_spec.rb +59 -0
  70. data/spec/controllers/hyrax/embargoes_controller_spec.rb +2 -0
  71. data/spec/controllers/hyrax/generic_works_controller_spec.rb +6 -1
  72. data/spec/factories/generic_works.rb +6 -0
  73. data/spec/features/collection_multi_membership_spec.rb +6 -6
  74. data/spec/features/work_show_spec.rb +58 -5
  75. data/spec/helpers/hyrax/batch_edits_helper_spec.rb +4 -2
  76. data/spec/helpers/hyrax/iiif_helper_spec.rb +44 -0
  77. data/spec/hyrax/transactions/create_work_spec.rb +155 -0
  78. data/spec/hyrax/transactions/steps/apply_permission_template_spec.rb +72 -0
  79. data/spec/hyrax/transactions/steps/ensure_admin_set_spec.rb +25 -0
  80. data/spec/hyrax/transactions/steps/ensure_permission_template_spec.rb +33 -0
  81. data/spec/hyrax/transactions/steps/save_work_spec.rb +32 -0
  82. data/spec/hyrax/transactions/steps/set_default_admin_set_spec.rb +38 -0
  83. data/spec/hyrax/transactions/steps/set_modified_date_spec.rb +22 -0
  84. data/spec/hyrax/transactions/steps/set_uploaded_date_spec.rb +32 -0
  85. data/spec/jobs/attach_files_to_work_with_ordered_members_job_spec.rb +13 -0
  86. data/spec/presenters/hyrax/presenter_renderer_spec.rb +4 -2
  87. data/spec/presenters/hyrax/work_show_presenter_spec.rb +46 -2
  88. data/spec/services/hyrax/permission_template_applicator_spec.rb +69 -0
  89. data/spec/spec_helper.rb +13 -2
  90. data/spec/views/catalog/index.html.erb_spec.rb +7 -4
  91. data/spec/views/hyrax/admin/admin_sets/_show_actions.html.erb_spec.rb +2 -0
  92. data/spec/views/hyrax/admin/admin_sets/_show_document_list_row.html.erb_spec.rb +4 -1
  93. data/spec/views/hyrax/admin/admin_sets/index.html.erb_spec.rb +6 -2
  94. data/spec/views/hyrax/admin/admin_sets/index.json.erb_spec.rb +1 -2
  95. data/spec/views/hyrax/admin/collection_types/_form_metadata_admin_set.html.erb_spec.rb +1 -1
  96. data/spec/views/hyrax/admin/collection_types/_form_settings.html.erb_spec.rb +5 -26
  97. data/spec/views/hyrax/admin/collection_types/index.html.erb_spec.rb +26 -5
  98. data/spec/views/hyrax/admin/stats/show.html.erb_spec.rb +1 -0
  99. data/spec/views/hyrax/base/_attribute_rows.html.erb_spec.rb +5 -1
  100. data/spec/views/hyrax/base/_attributes.html.erb_spec.rb +1 -0
  101. data/spec/views/hyrax/base/_form_rendering.html.erb_spec.rb +5 -1
  102. data/spec/views/hyrax/base/_items.html.erb_spec.rb +2 -0
  103. data/spec/views/hyrax/base/_relationships.html.erb_spec.rb +2 -1
  104. data/spec/views/hyrax/base/_show_actions.html.erb_spec.rb +71 -0
  105. data/spec/views/hyrax/base/file_manager.html.erb_spec.rb +11 -14
  106. data/spec/views/hyrax/base/show.html.erb_spec.rb +2 -2
  107. data/spec/views/hyrax/base/show.json.jbuilder_spec.rb +3 -1
  108. data/spec/views/hyrax/collections/_show_document_list_row.html.erb_spec.rb +6 -1
  109. data/spec/views/hyrax/collections/_show_parent_collections.html.erb_spec.rb +5 -5
  110. data/spec/views/hyrax/collections/_subcollection_list.html.erb_spec.rb +1 -1
  111. data/spec/views/hyrax/collections/show.html.erb_spec.rb +3 -2
  112. data/spec/views/hyrax/dashboard/collections/_form_share.erb_spec.rb +1 -1
  113. data/spec/views/hyrax/dashboard/collections/_form_share_table.html.erb_spec.rb +1 -1
  114. data/spec/views/hyrax/dashboard/collections/_show_document_list_row.html.erb_spec.rb +6 -1
  115. data/spec/views/hyrax/dashboard/collections/_subcollection_list.html.erb_spec.rb +1 -1
  116. data/spec/views/hyrax/dashboard/collections/edit.html.erb_spec.rb +3 -1
  117. data/spec/views/hyrax/dashboard/profiles/show.html.erb_spec.rb +2 -3
  118. data/spec/views/hyrax/file_sets/_show_characterization_details.html.erb_spec.rb +1 -2
  119. data/spec/views/hyrax/file_sets/_single_use_links.html.erb_spec.rb +1 -2
  120. data/spec/views/hyrax/homepage/_sortable_featured.html.erb_spec.rb +1 -1
  121. data/spec/views/hyrax/my/_collection_action_menu.html.erb_spec.rb +5 -5
  122. data/spec/views/hyrax/my/collections/_list_collections.html.erb_spec.rb +11 -8
  123. data/spec/views/hyrax/users/index.html.erb_spec.rb +1 -0
  124. data/spec/views/hyrax/users/show.html.erb_spec.rb +3 -0
  125. data/template.rb +1 -1
  126. metadata +65 -3
  127. data/app/views/hyrax/dashboard/collections/_form_default_group_delt.html.erb +0 -27
@@ -13,8 +13,12 @@ RSpec.describe "hyrax/admin/admin_sets/index.html.erb", type: :view do
13
13
  end
14
14
 
15
15
  context "when an admin set exists" do
16
- let(:admin_set) { build(:admin_set, id: '123', title: ['Example Admin Set'], creator: ['jdoe@example.com']) }
17
- let(:solr_doc) { SolrDocument.new(admin_set.to_solr) }
16
+ let(:solr_doc) do
17
+ SolrDocument.new(has_model_ssim: 'AdminSet',
18
+ id: 123,
19
+ title_tesim: ['Example Admin Set'],
20
+ creator_ssim: ['jdoe@example.com'])
21
+ end
18
22
  let(:admin_sets) { [solr_doc] }
19
23
  let(:presenter_class) { Hyrax::AdminSetPresenter }
20
24
  let(:presenter) { instance_double(presenter_class, total_items: 99) }
@@ -8,8 +8,7 @@ RSpec.describe "hyrax/admin/admin_sets/index.json.jbuilder" do
8
8
  end
9
9
 
10
10
  context "when an admin set exists" do
11
- let(:admin_set) { build(:admin_set, id: '123', title: ['Example Admin Set'], creator: ['jdoe@example.com'], description: ['Wat']) }
12
- let(:solr_doc) { SolrDocument.new(admin_set.to_solr) }
11
+ let(:solr_doc) { SolrDocument.new(id: '123', title_tesim: ['Example Admin Set'], description_tesim: ['Wat']) }
13
12
  let(:admin_sets) { [solr_doc] }
14
13
  let(:presenter_class) { Hyrax::AdminSetPresenter }
15
14
  let(:presenter) { instance_double(presenter_class, total_items: 99) }
@@ -1,5 +1,5 @@
1
1
  RSpec.describe 'hyrax/admin/collection_types/_form_metadata_admin_set.html.erb', type: :view do
2
- let(:collection_type) { create(:admin_set_collection_type) }
2
+ let(:collection_type) { stub_model(Hyrax::CollectionType) }
3
3
  let(:collection_type_form) { Hyrax::Forms::Admin::CollectionTypeForm.new }
4
4
 
5
5
  let(:form) do
@@ -14,6 +14,7 @@ RSpec.describe 'hyrax/admin/collection_types/_form_settings.html.erb', type: :vi
14
14
  ].freeze
15
15
 
16
16
  let(:collection_type_form) { Hyrax::Forms::Admin::CollectionTypeForm.new }
17
+ let(:collection_type) { stub_model(Hyrax::CollectionType) }
17
18
 
18
19
  let(:form) do
19
20
  view.simple_form_for(collection_type, url: '/update') do |fs_form|
@@ -22,16 +23,14 @@ RSpec.describe 'hyrax/admin/collection_types/_form_settings.html.erb', type: :vi
22
23
  end
23
24
 
24
25
  before do
26
+ collection_type_form.collection_type = collection_type
25
27
  allow(view).to receive(:f).and_return(form)
26
28
  allow(form).to receive(:object).and_return(collection_type_form)
27
29
  end
28
30
 
29
31
  context 'for non-special collection types' do
30
- let(:collection_type) { create(:collection_type) }
31
-
32
32
  context "when collection_type.collections? is false" do
33
33
  before do
34
- collection_type_form.collection_type = collection_type
35
34
  allow(collection_type).to receive(:collections?).and_return(false)
36
35
  render
37
36
  end
@@ -69,35 +68,15 @@ RSpec.describe 'hyrax/admin/collection_types/_form_settings.html.erb', type: :vi
69
68
  end
70
69
  end
71
70
 
72
- context 'for admin set collection type' do
73
- let(:collection_type) { create(:admin_set_collection_type) }
74
-
75
- before do
76
- collection_type_form.collection_type = collection_type
77
- allow(collection_type).to receive(:collections?).and_return(false)
78
- render
79
- end
80
-
81
- INPUT_IDS.each do |id|
82
- it "renders the #{id} checkbox to be disabled" do
83
- match = rendered.match(/(<input.*id="#{id}".*)/)
84
- expect(match).not_to be_nil
85
- expect(match[1].index('disabled="disabled"')).not_to be_nil
86
- end
87
- end
88
- end
89
-
90
- context 'for user collection type' do
91
- let(:collection_type) { create(:user_collection_type) }
92
-
71
+ context 'when all_settings_disabled? is true (admin_set or user collection type)' do
93
72
  before do
94
- collection_type_form.collection_type = collection_type
73
+ allow(collection_type_form).to receive(:all_settings_disabled?).and_return(true)
95
74
  allow(collection_type).to receive(:collections?).and_return(false)
96
75
  render
97
76
  end
98
77
 
99
78
  INPUT_IDS.each do |id|
100
- it "renders the #{id} checkbox to be disabled" do
79
+ it "renders the disabled #{id} checkbox " do
101
80
  match = rendered.match(/(<input.*id="#{id}".*)/)
102
81
  expect(match).not_to be_nil
103
82
  expect(match[1].index('disabled="disabled"')).not_to be_nil
@@ -1,12 +1,33 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe 'hyrax/admin/collection_types/index.html.erb', type: :view, clean_repo: true do
3
+ RSpec.describe 'hyrax/admin/collection_types/index.html.erb', type: :view do
4
+ let(:user_collection_type) do
5
+ stub_model(Hyrax::CollectionType,
6
+ collections?: false,
7
+ title: 'User Collection')
8
+ end
9
+ let(:admin_set_collection_type) do
10
+ stub_model(Hyrax::CollectionType,
11
+ collections?: false,
12
+ title: 'Admin Set')
13
+ end
14
+ let(:custom1) do
15
+ stub_model(Hyrax::CollectionType,
16
+ collections?: false,
17
+ title: 'Test Title 1')
18
+ end
19
+ let(:custom2) do
20
+ stub_model(Hyrax::CollectionType,
21
+ collections?: false,
22
+ title: 'Test Title 2')
23
+ end
24
+
4
25
  before do
5
26
  assign(:collection_types, [
6
- create(:user_collection_type),
7
- create(:admin_set_collection_type),
8
- FactoryBot.create(:collection_type, title: 'Test Title 1'),
9
- FactoryBot.create(:collection_type, title: 'Test Title 2')
27
+ user_collection_type,
28
+ admin_set_collection_type,
29
+ custom1,
30
+ custom2
10
31
  ])
11
32
  render
12
33
  end
@@ -12,6 +12,7 @@ RSpec.describe "hyrax/admin/stats/show.html.erb", type: :view do
12
12
 
13
13
  context 'locales' do
14
14
  before do
15
+ allow(presenter).to receive(:active_users).and_return([])
15
16
  render
16
17
  end
17
18
  it 'includes a default locale hidden input' do
@@ -7,7 +7,11 @@ RSpec.describe 'hyrax/base/_attribute_rows.html.erb', type: :view do
7
7
  related_url: [url],
8
8
  rights_statement: [rights_statement_uri])
9
9
  end
10
- let(:solr_document) { SolrDocument.new(work.to_solr) }
10
+ let(:solr_document) do
11
+ SolrDocument.new(has_model_ssim: 'GenericWork',
12
+ rights_statement_tesim: [rights_statement_uri],
13
+ related_url_tesim: [url])
14
+ end
11
15
  let(:presenter) { Hyrax::WorkShowPresenter.new(solr_document, ability) }
12
16
 
13
17
  let(:page) do
@@ -21,6 +21,7 @@ RSpec.describe 'hyrax/base/_attributes.html.erb' do
21
21
  let(:doc) { Nokogiri::HTML(rendered) }
22
22
 
23
23
  before do
24
+ allow(presenter).to receive(:member_of_collection_presenters).and_return([])
24
25
  allow(view).to receive(:dom_class) { '' }
25
26
 
26
27
  render 'hyrax/base/attributes', presenter: presenter
@@ -1,6 +1,6 @@
1
1
  RSpec.describe 'hyrax/base/_form_rendering.html.erb', type: :view do
2
2
  let(:ability) { double }
3
- let(:work) { create(:work_with_one_file) }
3
+ let(:work) { stub_model(GenericWork, new_record?: false) }
4
4
  let(:form) do
5
5
  Hyrax::GenericWorkForm.new(work, ability, controller)
6
6
  end
@@ -12,6 +12,10 @@ RSpec.describe 'hyrax/base/_form_rendering.html.erb', type: :view do
12
12
  Capybara::Node::Simple.new(rendered)
13
13
  end
14
14
 
15
+ before do
16
+ allow(form).to receive(:select_files).and_return([{ '123' => 'File one' }])
17
+ end
18
+
15
19
  it 'has a rendering_ids field' do
16
20
  expect(page).to have_selector("select#generic_work_rendering_ids", count: 1)
17
21
  end
@@ -40,6 +40,8 @@ RSpec.describe 'hyrax/base/_items.html.erb', type: :view do
40
40
  expect(Flipflop).to receive(:hide_private_items?).and_return(:flipflop)
41
41
  allow(presenter).to receive(:list_of_item_ids_to_display).and_return(member_list)
42
42
  allow(presenter).to receive(:member_presenters_for).with(member_list).and_return(member_list)
43
+ allow(presenter).to receive(:ordered_ids).and_return([])
44
+
43
45
  allow(ability).to receive(:can?).with(:read, child1.id).and_return true
44
46
  allow(ability).to receive(:can?).with(:read, child2.id).and_return false
45
47
  allow(ability).to receive(:can?).with(:read, child3.id).and_return true
@@ -77,13 +77,14 @@ RSpec.describe 'hyrax/base/relationships', type: :view do
77
77
  it "renders using attribute_to_html" do
78
78
  allow(controller).to receive(:current_user).and_return(user)
79
79
  allow(solr_doc).to receive(:member_of_collection_ids).and_return([])
80
+ allow(presenter).to receive(:grouped_presenters).and_return({})
80
81
  expect(presenter).to receive(:attribute_to_html).with(:admin_set, render_as: :faceted, html_dl: true)
81
82
  render 'hyrax/base/relationships', presenter: presenter
82
83
  end
83
84
 
84
85
  it "skips admin sets if user not logged in" do
85
86
  allow(controller).to receive(:current_user).and_return(nil)
86
- allow(solr_doc).to receive(:member_of_collection_ids).and_return([])
87
+ allow(presenter).to receive(:member_of_collection_presenters).and_return([])
87
88
  expect(presenter).not_to receive(:attribute_to_html).with(:admin_set, render_as: :faceted)
88
89
  render 'hyrax/base/relationships', presenter: presenter
89
90
  end
@@ -13,6 +13,7 @@ RSpec.describe 'hyrax/base/_show_actions.html.erb', type: :view do
13
13
 
14
14
  context "as an unregistered user" do
15
15
  before do
16
+ allow(presenter).to receive(:show_deposit_for?).with(anything).and_return(false)
16
17
  allow(presenter).to receive(:editor?).and_return(false)
17
18
  render 'hyrax/base/show_actions.html.erb', presenter: presenter
18
19
  end
@@ -25,6 +26,7 @@ RSpec.describe 'hyrax/base/_show_actions.html.erb', type: :view do
25
26
 
26
27
  context "as an editor" do
27
28
  before do
29
+ allow(presenter).to receive(:show_deposit_for?).with(anything).and_return(true)
28
30
  allow(presenter).to receive(:editor?).and_return(true)
29
31
  end
30
32
  context "when the work does not contain children" do
@@ -75,4 +77,73 @@ RSpec.describe 'hyrax/base/_show_actions.html.erb', type: :view do
75
77
  end
76
78
  end
77
79
  end
80
+
81
+ context "when user CAN deposit to at least one collection" do
82
+ before do
83
+ allow(presenter).to receive(:show_deposit_for?).with(anything).and_return(true)
84
+ allow(presenter).to receive(:member_presenters).and_return([])
85
+ end
86
+
87
+ context "and user is editor" do
88
+ before do
89
+ allow(presenter).to receive(:editor?).and_return(true)
90
+ render 'hyrax/base/show_actions.html.erb', presenter: presenter
91
+ end
92
+
93
+ it "shows editor related buttons" do
94
+ expect(rendered).not_to have_link 'File Manager'
95
+ expect(rendered).to have_link 'Edit'
96
+ expect(rendered).to have_link 'Delete'
97
+ expect(rendered).to have_button 'Add to collection'
98
+ end
99
+ end
100
+
101
+ context "and user is viewer" do
102
+ before do
103
+ allow(presenter).to receive(:editor?).and_return(false)
104
+ render 'hyrax/base/show_actions.html.erb', presenter: presenter
105
+ end
106
+ it "shows only Add to collection link" do
107
+ expect(rendered).not_to have_link 'File Manager'
108
+ expect(rendered).not_to have_link 'Edit'
109
+ expect(rendered).not_to have_link 'Delete'
110
+ expect(rendered).to have_button 'Add to collection'
111
+ end
112
+ end
113
+ end
114
+
115
+ context "when user can NOT deposit to any collections" do
116
+ before do
117
+ allow(presenter).to receive(:show_deposit_for?).with(anything).and_return(false)
118
+ allow(presenter).to receive(:member_presenters).and_return([])
119
+ end
120
+
121
+ context "and user is editor" do
122
+ before do
123
+ allow(presenter).to receive(:editor?).and_return(true)
124
+ render 'hyrax/base/show_actions.html.erb', presenter: presenter
125
+ end
126
+
127
+ it "shows editor related buttons" do
128
+ expect(rendered).not_to have_link 'File Manager'
129
+ expect(rendered).to have_link 'Edit'
130
+ expect(rendered).to have_link 'Delete'
131
+ expect(rendered).not_to have_button 'Add to collection'
132
+ end
133
+ end
134
+
135
+ context "and user is viewer" do
136
+ before do
137
+ allow(presenter).to receive(:editor?).and_return(false)
138
+ render 'hyrax/base/show_actions.html.erb', presenter: presenter
139
+ end
140
+
141
+ it "shows only Add to collection link" do
142
+ expect(rendered).not_to have_link 'File Manager'
143
+ expect(rendered).not_to have_link 'Edit'
144
+ expect(rendered).not_to have_link 'Delete'
145
+ expect(rendered).not_to have_button 'Add to collection'
146
+ end
147
+ end
148
+ end
78
149
  end
@@ -4,27 +4,24 @@ RSpec.describe "hyrax/base/file_manager.html.erb" do
4
4
  let(:member) { Hyrax::WorkShowPresenter.new(solr_doc_work, nil) }
5
5
  let(:solr_doc) do
6
6
  SolrDocument.new(
7
- resource.to_solr.merge(
8
- id: "test",
9
- title_tesim: ["Test"],
10
- thumbnail_path_ss: "/test/image/path.jpg",
11
- label_tesim: ["file_name.tif"]
12
- )
7
+ id: "test",
8
+ title_tesim: ["Test"],
9
+ thumbnail_path_ss: "/test/image/path.jpg",
10
+ label_tesim: ["file_name.tif"],
11
+ has_model_ssim: 'FileSet'
13
12
  )
14
13
  end
15
14
  let(:solr_doc_work) do
16
15
  SolrDocument.new(
17
- resource.to_solr.merge(
18
- id: "work",
19
- title_tesim: ["Work"],
20
- thumbnail_path_ss: "/test/image/path.jpg",
21
- label_tesim: ["work"]
22
- )
16
+ id: "work",
17
+ has_model_ssim: 'GenericWork',
18
+ title_tesim: ["Work"],
19
+ thumbnail_path_ss: "/test/image/path.jpg",
20
+ label_tesim: ["work"]
23
21
  )
24
22
  end
25
- let(:resource) { build(:file_set) }
26
23
 
27
- let(:parent) { build(:generic_work) }
24
+ let(:parent) { stub_model(GenericWork, title: ["Test title"]) }
28
25
 
29
26
  let(:form) do
30
27
  Hyrax::Forms::FileManagerForm.new(parent, nil)
@@ -69,9 +69,9 @@ RSpec.describe 'hyrax/base/show.html.erb', type: :view do
69
69
  expect(page).to have_content 'Foobar'
70
70
  end
71
71
 
72
- describe 'UniversalViewer integration' do
72
+ describe 'IIIF viewer integration' do
73
73
  before do
74
- allow(presenter).to receive(:universal_viewer?).and_return(viewer_enabled)
74
+ allow(presenter).to receive(:iiif_viewer?).and_return(viewer_enabled)
75
75
  render template: 'hyrax/base/show.html.erb'
76
76
  end
77
77
 
@@ -1,5 +1,7 @@
1
1
  RSpec.describe 'hyrax/base/show.json.jbuilder' do
2
- let(:curation_concern) { build(:generic_work) }
2
+ let(:curation_concern) do
3
+ stub_model(GenericWork, title: ['Test title'])
4
+ end
3
5
 
4
6
  before do
5
7
  allow(curation_concern).to receive(:etag).and_return('W/"87f79d2244ded4239ad1f0e822c8429b1e72b66c"')
@@ -2,7 +2,12 @@ RSpec.describe 'hyrax/collections/_show_document_list_row.html.erb', type: :view
2
2
  let(:user) { create(:user) }
3
3
 
4
4
  let(:work) do
5
- create(:work, user: user, creator: ["ggm"], title: ['One Hundred Years of Solitude'])
5
+ mock_model(GenericWork, label: 'One Hundred Years of Solitude', date_uploaded: '1999',
6
+ collection?: true, visibility: 'open',
7
+ title: ['One Hundred Years of Solitude'],
8
+ depositor: user,
9
+ edit_groups: [],
10
+ creator: ["ggm"])
6
11
  end
7
12
 
8
13
  let(:collection) { mock_model(Collection, title: 'My awesome collection', members: [work]) }
@@ -11,11 +11,11 @@ RSpec.describe 'hyrax/collections/_show_parent_collections.html.erb', type: :vie
11
11
  let(:ability) { double }
12
12
  let(:solr_document) { SolrDocument.new(collection_doc) }
13
13
  let(:presenter) { Hyrax::CollectionPresenter.new(solr_document, ability) }
14
- let(:collection1) { build(:collection, id: 'col1', title: ['col1']) }
15
- let(:collection2) { build(:collection, id: 'col2', title: ['col2']) }
16
- let(:collection3) { build(:collection, id: 'col3', title: ['col3']) }
17
- let(:collection4) { build(:collection, id: 'col4', title: ['col4']) }
18
- let(:collection5) { build(:collection, id: 'col5', title: ['col5']) }
14
+ let(:collection1) { stub_model(Collection, id: 'col1', title: ['col1']) }
15
+ let(:collection2) { stub_model(Collection, id: 'col2', title: ['col2']) }
16
+ let(:collection3) { stub_model(Collection, id: 'col3', title: ['col3']) }
17
+ let(:collection4) { stub_model(Collection, id: 'col4', title: ['col4']) }
18
+ let(:collection5) { stub_model(Collection, id: 'col5', title: ['col5']) }
19
19
  let(:parent_collections) { double(Object, documents: parent_docs, response: { "numFound" => parent_docs.size }, total_pages: 1) }
20
20
 
21
21
  before do
@@ -1,6 +1,6 @@
1
1
  RSpec.describe 'hyrax/collections/_subcollection_list.html.erb', type: :view do
2
2
  let(:subject) { render('subcollection_list.html.erb', collection: subcollection) }
3
- let(:collection) { build(:named_collection, id: '123') }
3
+ let(:collection) { stub_model(Collection, id: '123') }
4
4
 
5
5
  context 'when subcollection list is empty' do
6
6
  let(:subcollection) { nil }
@@ -16,11 +16,12 @@ RSpec.describe 'hyrax/collections/show.html.erb', type: :view do
16
16
  allow(view).to receive(:can?).with(:destroy, document).and_return(false)
17
17
  allow(presenter).to receive(:collection_type_is_nestable?).and_return(true)
18
18
  allow(presenter).to receive(:total_items).and_return(0)
19
+ allow(presenter).to receive(:total_viewable_items).and_return(0)
20
+ allow(presenter).to receive(:banner_file).and_return("banner.gif")
21
+ allow(presenter).to receive(:logo_record).and_return([{ linkurl: "logo link url", alttext: "logo alt text", file_location: "logo.gif" }])
19
22
  assign(:subcollection_count, 0)
20
23
  assign(:parent_collection_count, 0)
21
24
  assign(:members_count, 0)
22
- allow(presenter).to receive(:banner_file).and_return("banner.gif")
23
- allow(presenter).to receive(:logo_record).and_return([{ linkurl: "logo link url", alttext: "logo alt text", file_location: "logo.gif" }])
24
25
  allow(ability).to receive(:user_groups).and_return([])
25
26
  allow(ability).to receive(:current_user).and_return(build(:user, id: nil, email: ""))
26
27
  assign(:presenter, presenter)
@@ -6,7 +6,7 @@ RSpec.describe 'hyrax/dashboard/collections/_form_share.html.erb', type: :view d
6
6
  to_key: template.to_key,
7
7
  access_grants: template.access_grants)
8
8
  end
9
- let(:collection) { create(:collection, collection_type_settings: :sharable_no_work_permissions) }
9
+ let(:collection) { stub_model(Collection, share_applies_to_new_works?: false) }
10
10
 
11
11
  before do
12
12
  assign(:collection, collection)
@@ -2,7 +2,7 @@ RSpec.describe 'hyrax/dashboard/collections/_form_share_table.html.erb', type: :
2
2
  let(:template) { stub_model(Hyrax::PermissionTemplate) }
3
3
  let(:user) { create(:user) }
4
4
  let(:access_grant) { stub_model(Hyrax::PermissionTemplateAccess) }
5
- let(:collection) { create(:collection, collection_type_settings: :sharable_no_work_permissions) }
5
+ let(:collection) { stub_model(Collection, share_applies_to_new_works?: false) }
6
6
  let(:pt_form) do
7
7
  instance_double(Hyrax::Forms::PermissionTemplateForm,
8
8
  model_name: template.model_name,
@@ -2,7 +2,12 @@ RSpec.describe 'hyrax/dashboard/collections/_show_document_list_row.html.erb', t
2
2
  let(:user) { create(:user) }
3
3
 
4
4
  let(:work) do
5
- create(:work, user: user, creator: ["ggm"], title: ['One Hundred Years of Solitude'])
5
+ mock_model(GenericWork, label: 'One Hundred Years of Solitude', date_uploaded: '1999',
6
+ collection?: true, visibility: 'open',
7
+ title: ['One Hundred Years of Solitude'],
8
+ depositor: user,
9
+ edit_groups: [],
10
+ creator: ["ggm"])
6
11
  end
7
12
 
8
13
  let(:collection) { mock_model(Collection, title: 'My awesome collection', members: [work]) }