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
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+ require 'hyrax/transactions'
4
+
5
+ RSpec.describe Hyrax::Transactions::Steps::EnsureAdminSet do
6
+ subject(:step) { described_class.new }
7
+ let(:work) { build(:generic_work) }
8
+
9
+ describe '#call' do
10
+ context 'without an admin set' do
11
+ it 'is a failure' do
12
+ expect(step.call(work).failure).to eq :no_admin_set_id
13
+ end
14
+ end
15
+
16
+ context 'with an admin set' do
17
+ let(:admin_set) { create(:admin_set) }
18
+ let(:work) { build(:generic_work, admin_set_id: admin_set.id) }
19
+
20
+ it 'is a success' do
21
+ expect(step.call(work)).to be_success
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+ require 'hyrax/transactions'
4
+
5
+ RSpec.describe Hyrax::Transactions::Steps::EnsurePermissionTemplate do
6
+ subject(:step) { described_class.new }
7
+ let(:work) { build(:generic_work) }
8
+
9
+ describe '#call' do
10
+ context 'without an admin_set' do
11
+ it 'is a failure' do
12
+ expect(step.call(work).failure).to eq :no_permission_template
13
+ end
14
+ end
15
+
16
+ context 'with an admin_set' do
17
+ let(:work) { build(:generic_work, admin_set: admin_set) }
18
+ let(:admin_set) { create(:admin_set, with_permission_template: true) }
19
+
20
+ it 'is success' do
21
+ expect(step.call(work)).to be_success
22
+ end
23
+
24
+ context 'missing PermissionTemplate' do
25
+ let(:admin_set) { create(:admin_set, with_permission_template: false) }
26
+
27
+ it 'fails with missing template' do
28
+ expect(step.call(work).failure).to eq :no_permission_template
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+ require 'hyrax/transactions'
4
+
5
+ RSpec.describe Hyrax::Transactions::Steps::SaveWork do
6
+ subject(:step) { described_class.new }
7
+ let(:work) { build(:generic_work) }
8
+
9
+ describe '#call' do
10
+ it 'is success' do
11
+ expect(step.call(work)).to be_success
12
+ end
13
+
14
+ it 'persists the work' do
15
+ expect { step.call(work) }
16
+ .to change { work.persisted? }
17
+ .to true
18
+ end
19
+
20
+ context 'if the work is invalid' do
21
+ let(:work) { build(:invalid_generic_work) }
22
+
23
+ it 'returns failure' do
24
+ expect(step.call(work)).to be_failure
25
+ end
26
+
27
+ it 'gives errors about the work' do
28
+ expect(step.call(work).failure).to eq work.errors
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+ require 'hyrax/transactions'
4
+
5
+ RSpec.describe Hyrax::Transactions::Steps::SetDefaultAdminSet do
6
+ subject(:step) { described_class.new }
7
+ let(:work) { build(:generic_work) }
8
+
9
+ describe '#call' do
10
+ let(:admin_set_id) { AdminSet.find_or_create_default_admin_set_id }
11
+
12
+ it 'is success' do
13
+ expect(step.call(work)).to be_success
14
+ end
15
+
16
+ it 'sets the default admin_set' do
17
+ expect { step.call(work) }
18
+ .to change { work.admin_set&.id }
19
+ .from(nil)
20
+ .to(admin_set_id)
21
+ end
22
+
23
+ context 'when the work has an admin_set' do
24
+ let(:admin_set) { create(:admin_set) }
25
+ let(:work) { build(:generic_work, admin_set: admin_set) }
26
+
27
+ it 'is success' do
28
+ expect(step.call(work)).to be_success
29
+ end
30
+
31
+ it 'does not change the admin_set' do
32
+ expect { step.call(work) }
33
+ .not_to change { work.admin_set&.id }
34
+ .from(admin_set.id)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+ require 'hyrax/transactions'
4
+
5
+ RSpec.describe Hyrax::Transactions::Steps::SetModifiedDate do
6
+ subject(:step) { described_class.new }
7
+ let(:work) { build(:generic_work) }
8
+
9
+ let(:xmas) { DateTime.parse('2018-12-25 11:30').iso8601 }
10
+
11
+ before { allow(Hyrax::TimeService).to receive(:time_in_utc).and_return(xmas) }
12
+
13
+ describe '#call' do
14
+ it 'is success' do
15
+ expect(step.call(work)).to be_success
16
+ end
17
+
18
+ it 'sets the modified date' do
19
+ expect { step.call(work) }.to change { work.date_modified }.to xmas
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+ require 'hyrax/transactions'
4
+
5
+ RSpec.describe Hyrax::Transactions::Steps::SetUploadedDate do
6
+ subject(:step) { described_class.new }
7
+ let(:work) { build(:generic_work) }
8
+ let(:xmas) { DateTime.parse('2018-12-25 11:30').iso8601 }
9
+
10
+ before { allow(Hyrax::TimeService).to receive(:time_in_utc).and_return(xmas) }
11
+
12
+ describe '#call' do
13
+ it 'is success' do
14
+ expect(step.call(work)).to be_success
15
+ end
16
+
17
+ it 'sets the uploaded date' do
18
+ expect { step.call(work) }.to change { work.date_uploaded }.to xmas
19
+ end
20
+
21
+ context 'when a modified date exists' do
22
+ let(:work) { build(:generic_work, date_modified: xmas_past) }
23
+ let(:xmas_past) { DateTime.parse('2009-12-25 11:30').iso8601 }
24
+
25
+ it 'sets the uploaded date to the modified date' do
26
+ expect { step.call(work) }
27
+ .to change { work.date_uploaded }
28
+ .to work.date_modified
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,13 @@
1
+ RSpec.describe AttachFilesToWorkWithOrderedMembersJob, perform_enqueued: [AttachFilesToWorkWithOrderedMembersJob] do
2
+ let(:file1) { File.open(fixture_path + '/world.png') }
3
+ let(:file2) { File.open(fixture_path + '/image.jp2') }
4
+ let(:uploaded_file1) { build(:uploaded_file, file: file1) }
5
+ let(:uploaded_file2) { build(:uploaded_file, file: file2) }
6
+ let(:generic_work) { create(:public_generic_work) }
7
+
8
+ it "attaches files and passes ordered_members to OrderedMembersActor" do
9
+ expect(Hyrax::Actors::OrderedMembersActor).to receive(:new).with([FileSet, FileSet], User).and_return(Hyrax::Actors::OrderedMembersActor)
10
+ expect(Hyrax::Actors::OrderedMembersActor).to receive(:attach_ordered_members_to_work).with(generic_work)
11
+ described_class.perform_now(generic_work, [uploaded_file1, uploaded_file2])
12
+ end
13
+ end
@@ -1,7 +1,9 @@
1
1
  RSpec.describe Hyrax::PresenterRenderer, type: :view do
2
- let(:work) { GenericWork.new }
3
2
  let(:ability) { double }
4
- let(:document) { SolrDocument.new(work.to_solr) }
3
+ let(:document) { SolrDocument.new(data) }
4
+ let(:data) do
5
+ { id: '123', date_created_tesim: 'foo', date_uploaded_tesim: 'bar', has_model_ssim: 'GenericWork' }
6
+ end
5
7
  let(:presenter) { Hyrax::WorkShowPresenter.new(document, ability) }
6
8
  let(:renderer) { described_class.new(presenter, view) }
7
9
 
@@ -45,7 +45,7 @@ RSpec.describe Hyrax::WorkShowPresenter do
45
45
  it { is_expected.to eq 'http://example.org/concern/generic_works/888888/manifest' }
46
46
  end
47
47
 
48
- describe '#universal_viewer?' do
48
+ describe '#iiif_viewer?' do
49
49
  let(:id_present) { false }
50
50
  let(:representative_presenter) { double('representative', present?: false) }
51
51
  let(:image_boolean) { false }
@@ -64,7 +64,7 @@ RSpec.describe Hyrax::WorkShowPresenter do
64
64
  allow(Hyrax.config).to receive(:iiif_image_server?).and_return(iiif_enabled)
65
65
  end
66
66
 
67
- subject { presenter.universal_viewer? }
67
+ subject { presenter.iiif_viewer? }
68
68
 
69
69
  context 'with no representative_id' do
70
70
  it { is_expected.to be false }
@@ -533,4 +533,48 @@ RSpec.describe Hyrax::WorkShowPresenter do
533
533
  end
534
534
  end
535
535
  end
536
+
537
+ describe "#show_deposit_for?" do
538
+ subject { presenter }
539
+
540
+ context "when user has depositable collections" do
541
+ let(:user_collections) { double }
542
+
543
+ it "returns true" do
544
+ expect(subject.show_deposit_for?(collections: user_collections)).to be true
545
+ end
546
+ end
547
+
548
+ context "when user does not have depositable collections" do
549
+ let(:user_collections) { nil }
550
+
551
+ context "and user can create a collection" do
552
+ before do
553
+ allow(ability).to receive(:can?).with(:create_any, Collection).and_return(true)
554
+ end
555
+
556
+ it "returns true" do
557
+ expect(subject.show_deposit_for?(collections: user_collections)).to be true
558
+ end
559
+ end
560
+
561
+ context "and user can NOT create a collection" do
562
+ before do
563
+ allow(ability).to receive(:can?).with(:create_any, Collection).and_return(false)
564
+ end
565
+
566
+ it "returns false" do
567
+ expect(subject.show_deposit_for?(collections: user_collections)).to be false
568
+ end
569
+ end
570
+ end
571
+ end
572
+
573
+ describe '#iiif_viewer' do
574
+ subject { presenter.iiif_viewer }
575
+
576
+ it 'defaults to universal viewer' do
577
+ expect(subject).to be :universal_viewer
578
+ end
579
+ end
536
580
  end
@@ -0,0 +1,69 @@
1
+ RSpec.describe Hyrax::PermissionTemplateApplicator do
2
+ subject(:applicator) { described_class.new(template: template) }
3
+ let(:manage_groups) { ['edit_group_1', 'edit_group_2'] }
4
+ let(:manage_users) { ['moomin', 'snork'] }
5
+ let(:template) { :not_a_template }
6
+ let(:view_groups) { ['read_group_1', 'read_group_2'] }
7
+ let(:view_users) { ['snufkin', 'too-ticky'] }
8
+ let(:work) { build(:work) }
9
+
10
+ describe '.apply' do
11
+ it 'initializes with template' do
12
+ expect(described_class.apply(template))
13
+ .to have_attributes(template: template)
14
+ end
15
+ end
16
+
17
+ describe '#apply_to' do
18
+ let(:template) do
19
+ create(:permission_template,
20
+ manage_groups: manage_groups,
21
+ manage_users: manage_users,
22
+ view_groups: view_groups,
23
+ view_users: view_users)
24
+ end
25
+
26
+ it 'applies edit groups' do
27
+ edit_after_application = work.edit_groups + manage_groups
28
+
29
+ expect { applicator.apply_to(model: work) }
30
+ .to change { work.edit_groups }
31
+ .to contain_exactly(*edit_after_application)
32
+ end
33
+
34
+ it 'applies edit users' do
35
+ edit_after_application = work.edit_users + manage_users
36
+
37
+ expect { applicator.apply_to(model: work) }
38
+ .to change { work.edit_users }
39
+ .to contain_exactly(*edit_after_application)
40
+ end
41
+
42
+ it 'applies read groups' do
43
+ read_after_application = work.read_groups + view_groups
44
+
45
+ expect { applicator.apply_to(model: work) }
46
+ .to change { work.read_groups }
47
+ .to contain_exactly(*read_after_application)
48
+ end
49
+
50
+ it 'applies read users' do
51
+ read_after_application = work.read_users + view_users
52
+
53
+ expect { applicator.apply_to(model: work) }
54
+ .to change { work.read_users }
55
+ .to contain_exactly(*read_after_application)
56
+ end
57
+ end
58
+
59
+ describe '#template' do
60
+ let(:new_template) { :not_another_template }
61
+
62
+ it 'has a template attribute' do
63
+ expect { applicator.template = new_template }
64
+ .to change { applicator.template }
65
+ .from(template)
66
+ .to new_template
67
+ end
68
+ end
69
+ end
@@ -5,6 +5,10 @@ def coverage_needed?
5
5
  ENV['COVERAGE'] || ENV['TRAVIS']
6
6
  end
7
7
 
8
+ def ci_build?
9
+ ENV['TRAVIS'] || ENV['CIRCLE']
10
+ end
11
+
8
12
  if coverage_needed?
9
13
  require 'simplecov'
10
14
  require 'coveralls'
@@ -60,7 +64,7 @@ require 'webmock/rspec'
60
64
  WebMock.disable_net_connect!(allow_localhost: true)
61
65
 
62
66
  require 'i18n/debug' if ENV['I18N_DEBUG']
63
- require 'byebug' unless ENV['TRAVIS']
67
+ require 'byebug' unless ci_build?
64
68
 
65
69
  # @note In January 2018, TravisCI disabled Chrome sandboxing in its Linux
66
70
  # container build environments to mitigate Meltdown/Spectre
@@ -141,7 +145,7 @@ RSpec.configure do |config|
141
145
  config.include Shoulda::Matchers::ActiveRecord, type: :model
142
146
  config.include Shoulda::Matchers::ActiveModel, type: :form
143
147
  config.include Shoulda::Callback::Matchers::ActiveModel
144
- config.full_backtrace = true if ENV['TRAVIS']
148
+ config.full_backtrace = true if ci_build?
145
149
  config.expect_with :rspec do |c|
146
150
  c.syntax = :expect
147
151
  end
@@ -165,6 +169,13 @@ RSpec.configure do |config|
165
169
  DatabaseCleaner.start
166
170
  end
167
171
 
172
+ if example.metadata[:type] == :view
173
+ # View tests should not hit any services. This ensures the tests are unit
174
+ # testing only the views and run fast.
175
+ WebMock.disable_net_connect!(allow_localhost: false)
176
+ else
177
+ WebMock.disable_net_connect!(allow_localhost: true)
178
+ end
168
179
  # using :workflow is preferable to :clean_repo, use the former if possible
169
180
  # It's important that this comes after DatabaseCleaner.start
170
181
  ensure_deposit_available_for(user) if example.metadata[:workflow]
@@ -1,6 +1,9 @@
1
1
  RSpec.describe 'catalog/index.html.erb', type: :view do
2
- let(:collection) { build(:collection, id: "abc123") }
3
- let(:doc) { SolrDocument.new(collection.to_solr) }
2
+ let(:doc) do
3
+ SolrDocument.new(id: "abc123",
4
+ has_model_ssim: ['Collection'],
5
+ title_tesim: ['Collection Title 999'])
6
+ end
4
7
 
5
8
  before do
6
9
  view.extend Hyrax::CollectionsHelper
@@ -30,7 +33,7 @@ RSpec.describe 'catalog/index.html.erb', type: :view do
30
33
  before { allow(view).to receive(:can?).and_return(false) }
31
34
  it 'appears on page without error' do
32
35
  render
33
- expect(rendered).to include(collection.title.first)
36
+ expect(rendered).to include('Collection Title 999')
34
37
  page = Capybara::Node::Simple.new(rendered)
35
38
  expect(page).to have_selector("span.fa.fa-cubes.collection-icon-search")
36
39
  end
@@ -39,7 +42,7 @@ RSpec.describe 'catalog/index.html.erb', type: :view do
39
42
  before { allow(view).to receive(:can?).and_return(true) }
40
43
  it 'appears on page without error' do
41
44
  render
42
- expect(rendered).to include(collection.title.first)
45
+ expect(rendered).to include('Collection Title 999')
43
46
  page = Capybara::Node::Simple.new(rendered)
44
47
  expect(page).to have_selector("span.fa.fa-cubes.collection-icon-search")
45
48
  end
@@ -20,6 +20,7 @@ RSpec.describe 'hyrax/admin/admin_sets/_show_actions.html.erb', type: :view do
20
20
  context "when presenter has delete disabled" do
21
21
  before do
22
22
  allow(presenter).to receive(:disable_delete?).and_return(true)
23
+ allow(presenter).to receive(:disabled_message).and_return('')
23
24
  render
24
25
  end
25
26
  it "displays a disabled delete button" do
@@ -43,6 +44,7 @@ RSpec.describe 'hyrax/admin/admin_sets/_show_actions.html.erb', type: :view do
43
44
  context "with default admin set" do
44
45
  before do
45
46
  allow(presenter).to receive(:disable_delete?).and_return(true)
47
+ allow(presenter).to receive(:disabled_message).and_return('')
46
48
  render
47
49
  end
48
50
  it "displays a disabled delete button" do
@@ -3,13 +3,16 @@ RSpec.describe 'hyrax/admin/admin_sets/_show_document_list_row.html.erb', type:
3
3
  let(:ability) { Ability.new(user) }
4
4
 
5
5
  let(:work) do
6
- create(:work, user: user, creator: ["ggm"], title: ['One Hundred Years of Solitude'])
6
+ stub_model(GenericWork, title: ['One Hundred Years of Solitude'])
7
7
  end
8
8
 
9
9
  before do
10
10
  view.blacklight_config = Blacklight::Configuration.new
11
11
  allow(controller).to receive(:current_ability).and_return(ability)
12
12
  allow(view).to receive(:current_user).and_return(user)
13
+ allow(view).to receive(:render_collection_links).and_return('')
14
+ allow(view).to receive(:render_visibility_link).and_return('')
15
+
13
16
  allow(work).to receive(:title_or_label).and_return("One Hundred Years of Solitude")
14
17
  allow(work).to receive(:edit_groups).and_return([user])
15
18
  allow(work).to receive(:edit_people).and_return([user])