hyrax 2.1.0.rc2 → 2.1.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/assets/stylesheets/hyrax/_work-show.scss +11 -2
- data/app/controllers/hyrax/admin/admin_sets_controller.rb +22 -1
- data/app/jobs/import_url_job.rb +50 -18
- data/app/models/concerns/hyrax/ability/admin_set_ability.rb +1 -1
- data/app/presenters/hyrax/file_set_presenter.rb +4 -0
- data/app/presenters/hyrax/work_show_presenter.rb +2 -2
- data/app/services/hyrax/collections/permissions_create_service.rb +23 -0
- data/app/services/hyrax/collections/permissions_service.rb +17 -11
- data/app/views/hyrax/base/_items.html.erb +3 -1
- data/app/views/hyrax/collections/_show_document_list_row.html.erb +0 -19
- data/app/views/hyrax/file_sets/_actions.html.erb +38 -36
- data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
- data/config/features.rb +2 -2
- data/config/locales/hyrax.de.yml +13 -1
- data/config/locales/hyrax.en.yml +12 -0
- data/config/locales/hyrax.es.yml +12 -0
- data/config/locales/hyrax.fr.yml +12 -0
- data/config/locales/hyrax.it.yml +12 -0
- data/config/locales/hyrax.pt-BR.yml +12 -0
- data/config/locales/hyrax.zh.yml +12 -0
- data/lib/hyrax/version.rb +1 -1
- data/spec/abilities/admin_set_ability_spec.rb +5 -0
- data/spec/controllers/hyrax/admin/admin_sets_controller_spec.rb +71 -2
- data/spec/jobs/import_url_job_spec.rb +53 -0
- data/spec/models/flipflop_spec.rb +2 -2
- data/spec/presenters/hyrax/file_set_presenter_spec.rb +24 -0
- data/spec/presenters/hyrax/work_show_presenter_spec.rb +10 -0
- data/spec/services/hyrax/collections/permissions_create_service_spec.rb +23 -0
- data/spec/services/hyrax/collections/permissions_service_spec.rb +92 -8
- data/spec/views/hyrax/base/_items.html.erb_spec.rb +23 -45
- data/spec/views/hyrax/base/_member.html.erb_spec.rb +1 -1
- data/spec/views/hyrax/collections/_show_document_list_row.html.erb_spec.rb +1 -0
- data/spec/views/hyrax/dashboard/collections/_show_document_list_row.html.erb_spec.rb +1 -0
- data/spec/views/hyrax/file_sets/_actions.html.erb_spec.rb +30 -9
- data/template.rb +1 -1
- metadata +2 -2
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if Hyrax.config.display_media_download_link? %>
|
1
|
+
<% if Hyrax.config.display_media_download_link? && can?(:download, file_set.id) %>
|
2
2
|
<div>
|
3
3
|
<h2 class="sr-only"><%= t('hyrax.file_set.show.downloadable_content.heading') %></h2>
|
4
4
|
<%= image_tag thumbnail_url(file_set),
|
data/config/features.rb
CHANGED
@@ -35,7 +35,7 @@ Flipflop.configure do
|
|
35
35
|
default: false,
|
36
36
|
description: "Display new reporting features. *Very Experimental*"
|
37
37
|
|
38
|
-
feature :
|
38
|
+
feature :hide_private_items,
|
39
39
|
default: false,
|
40
|
-
description: "Do not show the private
|
40
|
+
description: "Do not show the private items."
|
41
41
|
end
|
data/config/locales/hyrax.de.yml
CHANGED
@@ -414,6 +414,7 @@ de:
|
|
414
414
|
header: Artikel
|
415
415
|
thumbnail: Miniaturansicht
|
416
416
|
title: Titel
|
417
|
+
unauthorized: Es gibt keine öffentlich verfügbaren Elemente in diesem %{type}.
|
417
418
|
visibility: Sichtbarkeit
|
418
419
|
relationships:
|
419
420
|
empty: Diese %{type} ist derzeit noch keiner Sammlung zugeordnet.
|
@@ -698,7 +699,7 @@ de:
|
|
698
699
|
select_none: Nichts ausgewählt
|
699
700
|
transfer: Besitz der Arbeit übertragen
|
700
701
|
unhighlight: Hervorhebung der Arbeit entfernen
|
701
|
-
view_admin_set:
|
702
|
+
view_admin_set: Sammlung anzeigen
|
702
703
|
view_collection: Sammlung anzeigen
|
703
704
|
work_confirmation: Das Löschen einer Arbeit aus %{application_name} ist dauerhaft. Klicken Sie auf OK, um diese Arbeit aus %{application_name} zu löschen, oder auf Abbrechen, um diesen Vorgang abzubrechen
|
704
705
|
collection_list:
|
@@ -831,6 +832,17 @@ de:
|
|
831
832
|
pdf_link: PDF Herunterladen
|
832
833
|
video_link: Video herunterladen
|
833
834
|
file_sets:
|
835
|
+
actions:
|
836
|
+
delete: Löschen
|
837
|
+
delete_confirm: Das Löschen von %{file_set} aus %{application_name} ist permanent. Klicken Sie auf OK, um dies aus %{application_name} zu löschen, oder auf Abbrechen, um diesen Vorgang abzubrechen
|
838
|
+
delete_title: Löschen Sie %{file_set}
|
839
|
+
download: Herunterladen
|
840
|
+
download_title: Laden Sie %{file_set} herunter
|
841
|
+
edit: Bearbeiten
|
842
|
+
edit_title: Bearbeite %{file_set}
|
843
|
+
header: Wählen Sie eine Aktion
|
844
|
+
versions: Versionen
|
845
|
+
versions_title: Vorherige Versionen anzeigen
|
834
846
|
groups_description:
|
835
847
|
description_html: Die Liste der Gruppen in der Auswahlliste mit der Bezeichnung „ Wählen Sie eine Gruppe aus „ zeigt ihnen jene Benutzer administrierten Gruppen an, bei denen Sie Mitglied sind. Sie können eine bestimmte Gruppe auswählen und eine Zugriffsebene für eine Datei innerhalb von %{application_name} zuweisen, ähnlich wie das Hinzufügen von Benutzerzugriffsebenen.
|
836
848
|
help:
|
data/config/locales/hyrax.en.yml
CHANGED
@@ -413,6 +413,7 @@ en:
|
|
413
413
|
header: Items
|
414
414
|
thumbnail: Thumbnail
|
415
415
|
title: Title
|
416
|
+
unauthorized: There are no publicly available items in this %{type}.
|
416
417
|
visibility: Visibility
|
417
418
|
relationships:
|
418
419
|
empty: This %{type} is not currently in any collections.
|
@@ -830,6 +831,17 @@ en:
|
|
830
831
|
pdf_link: Download PDF
|
831
832
|
video_link: Download video
|
832
833
|
file_sets:
|
834
|
+
actions:
|
835
|
+
delete: Delete
|
836
|
+
delete_confirm: Deleting %{file_set} from %{application_name} is permanent. Click OK to delete this from %{application_name}, or Cancel to cancel this operation
|
837
|
+
delete_title: Delete %{file_set}
|
838
|
+
download: Download
|
839
|
+
download_title: Download %{file_set}
|
840
|
+
edit: Edit
|
841
|
+
edit_title: Edit %{file_set}
|
842
|
+
header: Select an action
|
843
|
+
versions: Versions
|
844
|
+
versions_title: Display previous versions
|
833
845
|
groups_description:
|
834
846
|
description_html: The list of groups in the drop-down marked "Select a group" is a list of User Managed Groups that you are a member of. You may select a specific group and assign an access level for a file within %{application_name}, similarly to adding user access levels.
|
835
847
|
help:
|
data/config/locales/hyrax.es.yml
CHANGED
@@ -412,6 +412,7 @@ es:
|
|
412
412
|
header: Elementos
|
413
413
|
thumbnail: Miniatura
|
414
414
|
title: Título
|
415
|
+
unauthorized: No hay elementos disponibles públicamente en este %{type}.
|
415
416
|
visibility: Visibilidad
|
416
417
|
relationships:
|
417
418
|
empty: Este %{type} no está actualmente disponible en ninguna colección.
|
@@ -829,6 +830,17 @@ es:
|
|
829
830
|
pdf_link: Descargar PDF
|
830
831
|
video_link: Descargar video
|
831
832
|
file_sets:
|
833
|
+
actions:
|
834
|
+
delete: Borrar
|
835
|
+
delete_confirm: Eliminar %{file_set} de %{application_name} es permanente. Haga clic en Aceptar para eliminar esto de %{application_name}, o en Cancelar para cancelar esta operación
|
836
|
+
delete_title: Eliminar %{file_set}
|
837
|
+
download: Descargar
|
838
|
+
download_title: Descargar %{file_set}
|
839
|
+
edit: Editar
|
840
|
+
edit_title: Editar %{file_set}
|
841
|
+
header: Selecciona una acción
|
842
|
+
versions: Versiones
|
843
|
+
versions_title: Mostrar versiones anteriores
|
832
844
|
groups_description:
|
833
845
|
description_html: 'La lista de grupos del listado "Seleccionar un grupo" es una lista de Grupos Administrados por el Usuario de la que que es miembro. Puede seleccionar un grupo específico y asignar un nivel de acceso por archivo dentro de %{application_name}, y del mismo modo puede agregar niveles de acceso de usuarios.
|
834
846
|
|
data/config/locales/hyrax.fr.yml
CHANGED
@@ -413,6 +413,7 @@ fr:
|
|
413
413
|
header: Articles
|
414
414
|
thumbnail: La vignette
|
415
415
|
title: Titre
|
416
|
+
unauthorized: Il n'y a pas d'objets disponibles publiquement dans ce %{type}.
|
416
417
|
visibility: Visibilité
|
417
418
|
relationships:
|
418
419
|
empty: Ce %{type} ne se trouve actuellement dans aucune collection.
|
@@ -830,6 +831,17 @@ fr:
|
|
830
831
|
pdf_link: Télécharger le fichier PDF
|
831
832
|
video_link: Télécharger la video
|
832
833
|
file_sets:
|
834
|
+
actions:
|
835
|
+
delete: Effacer
|
836
|
+
delete_confirm: La suppression de %{file_set} à partir de %{application_name} est permanente. Cliquez sur OK pour le supprimer de %{application_name}, ou sur Annuler pour annuler cette opération
|
837
|
+
delete_title: Supprimer %{file_set}
|
838
|
+
download: Télécharger
|
839
|
+
download_title: Télécharger %{file_set}
|
840
|
+
edit: modifier
|
841
|
+
edit_title: Modifier %{file_set}
|
842
|
+
header: Sélectionnez une action
|
843
|
+
versions: Versions
|
844
|
+
versions_title: Afficher les versions précédentes
|
833
845
|
groups_description:
|
834
846
|
description_html: La liste des groupes dans le menu déroulant intitulé «Sélectionner un groupe» est une liste des groupes gérés par l'utilisateur dont vous êtes membre. Vous pouvez sélectionner un groupe spécifique et attribuer un niveau d'accès pour un fichier dans %{application_name}, de même que l'ajout de niveaux d'accès utilisateur.
|
835
847
|
help:
|
data/config/locales/hyrax.it.yml
CHANGED
@@ -412,6 +412,7 @@ it:
|
|
412
412
|
header: Elementi
|
413
413
|
thumbnail: Thumbnail
|
414
414
|
title: Titolo
|
415
|
+
unauthorized: Non ci sono articoli disponibili pubblicamente in questo %{type}.
|
415
416
|
visibility: Visibilità
|
416
417
|
relationships:
|
417
418
|
empty: Questo %{type} non è in una raccolta.
|
@@ -829,6 +830,17 @@ it:
|
|
829
830
|
pdf_link: Scarica il pdf
|
830
831
|
video_link: Scarica video
|
831
832
|
file_sets:
|
833
|
+
actions:
|
834
|
+
delete: Elimina
|
835
|
+
delete_confirm: L'eliminazione di %{file_set} da %{application_name} è permanente. Fare clic su OK per eliminare questo da %{application_name}, o Annulla per annullare questa operazione
|
836
|
+
delete_title: Elimina %{file_set}
|
837
|
+
download: Scaricare
|
838
|
+
download_title: Scarica %{file_set}
|
839
|
+
edit: modificare
|
840
|
+
edit_title: Modifica %{file_set}
|
841
|
+
header: Seleziona un'azione
|
842
|
+
versions: versioni
|
843
|
+
versions_title: Mostra le versioni precedenti
|
832
844
|
groups_description:
|
833
845
|
description_html: L'elenco dei gruppi nel menu a discesa contrassegnato con "Seleziona un gruppo" è un elenco di Gruppi gestiti utente di cui sei membro. È possibile selezionare un gruppo specifico e assegnare un livello di accesso per un file all'interno di %{application_name}, analogamente ad aggiungere livelli di accesso utente.
|
834
846
|
help:
|
@@ -407,6 +407,7 @@ pt-BR:
|
|
407
407
|
header: Unid
|
408
408
|
thumbnail: Miniatura
|
409
409
|
title: Título
|
410
|
+
unauthorized: Não há itens publicamente disponíveis neste %{type}.
|
410
411
|
visibility: Visibilidade
|
411
412
|
relationships:
|
412
413
|
empty: Este %{type} atualmente não está em nenhuma coleção.
|
@@ -824,6 +825,17 @@ pt-BR:
|
|
824
825
|
pdf_link: baixar PDF
|
825
826
|
video_link: Baixar video
|
826
827
|
file_sets:
|
828
|
+
actions:
|
829
|
+
delete: Excluir
|
830
|
+
delete_confirm: A exclusão de %{file_set} de %{application_name} é permanente. Clique em OK para excluir isso do %{application_name} ou Cancelar para cancelar esta operação
|
831
|
+
delete_title: Excluir %{file_set}
|
832
|
+
download: Baixar
|
833
|
+
download_title: Baixar %{file_set}
|
834
|
+
edit: Editar
|
835
|
+
edit_title: Editar %{file_set}
|
836
|
+
header: Selecione uma ação
|
837
|
+
versions: Versões
|
838
|
+
versions_title: Exibir versões anteriores
|
827
839
|
groups_description:
|
828
840
|
description_html: A lista de grupos no menu suspenso marcado como "Selecionar um grupo" é uma lista de Grupos Gerenciados pelo Usuário de que você é membro. Você pode selecionar um grupo específico e atribuir um nível de acesso para um arquivo dentro do %{application_name}, de forma semelhante à adição de níveis de acesso ao usuário.
|
829
841
|
help:
|
data/config/locales/hyrax.zh.yml
CHANGED
@@ -410,6 +410,7 @@ zh:
|
|
410
410
|
header: 单件
|
411
411
|
thumbnail: 缩略图
|
412
412
|
title: 标题
|
413
|
+
unauthorized: 这个%{type}中没有公开可用的项目。
|
413
414
|
visibility: 公开度
|
414
415
|
relationships:
|
415
416
|
empty: 该 %{type} 目前未纳入任何收藏集内。
|
@@ -827,6 +828,17 @@ zh:
|
|
827
828
|
pdf_link: 下载PDF文件
|
828
829
|
video_link: 下载视频
|
829
830
|
file_sets:
|
831
|
+
actions:
|
832
|
+
delete: 删除
|
833
|
+
delete_confirm: 从%{application_name}删除%{file_set}是永久性的。单击确定从%{application_name}中删除此项,或单击取消取消此操作
|
834
|
+
delete_title: 删除%{file_set}
|
835
|
+
download: 下载
|
836
|
+
download_title: 下载%{file_set}
|
837
|
+
edit: 编辑
|
838
|
+
edit_title: 编辑%{file_set}
|
839
|
+
header: 选择一个动作
|
840
|
+
versions: 版本
|
841
|
+
versions_title: 显示以前的版本
|
830
842
|
groups_description:
|
831
843
|
description_html: 标有"选择一个群"的下拉框内是您所属的一组用户管理群的清单。您可以选择一个特定的群,指定对%{application_name}中文件的访问级别,类似于添加用户访问级别。
|
832
844
|
help:
|
data/lib/hyrax/version.rb
CHANGED
@@ -23,6 +23,7 @@ RSpec.describe 'AdminSetAbility' do
|
|
23
23
|
is_expected.to be_able_to(:manage, AdminSet)
|
24
24
|
is_expected.to be_able_to(:manage_any, AdminSet)
|
25
25
|
is_expected.to be_able_to(:create_any, AdminSet)
|
26
|
+
is_expected.to be_able_to(:create, AdminSet)
|
26
27
|
is_expected.to be_able_to(:view_admin_show_any, AdminSet)
|
27
28
|
is_expected.to be_able_to(:edit, admin_set)
|
28
29
|
is_expected.to be_able_to(:edit, solr_document) # defined in solr_document_ability.rb
|
@@ -72,6 +73,7 @@ RSpec.describe 'AdminSetAbility' do
|
|
72
73
|
it 'denies manage ability' do
|
73
74
|
is_expected.not_to be_able_to(:manage, AdminSet)
|
74
75
|
is_expected.not_to be_able_to(:create_any, AdminSet) # granted by collection type, not collection
|
76
|
+
is_expected.not_to be_able_to(:create, AdminSet)
|
75
77
|
end
|
76
78
|
end
|
77
79
|
|
@@ -100,6 +102,7 @@ RSpec.describe 'AdminSetAbility' do
|
|
100
102
|
is_expected.not_to be_able_to(:manage, AdminSet)
|
101
103
|
is_expected.not_to be_able_to(:manage_any, AdminSet)
|
102
104
|
is_expected.not_to be_able_to(:create_any, AdminSet) # granted by collection type, not collection
|
105
|
+
is_expected.not_to be_able_to(:create, AdminSet)
|
103
106
|
is_expected.not_to be_able_to(:edit, admin_set)
|
104
107
|
is_expected.not_to be_able_to(:edit, solr_document) # defined in solr_document_ability.rb
|
105
108
|
is_expected.not_to be_able_to(:update, admin_set)
|
@@ -133,6 +136,7 @@ RSpec.describe 'AdminSetAbility' do
|
|
133
136
|
is_expected.not_to be_able_to(:manage, AdminSet)
|
134
137
|
is_expected.not_to be_able_to(:manage_any, AdminSet)
|
135
138
|
is_expected.not_to be_able_to(:create_any, AdminSet) # granted by collection type, not collection
|
139
|
+
is_expected.not_to be_able_to(:create, AdminSet)
|
136
140
|
is_expected.not_to be_able_to(:edit, admin_set)
|
137
141
|
is_expected.not_to be_able_to(:edit, solr_document) # defined in solr_document_ability.rb
|
138
142
|
is_expected.not_to be_able_to(:update, admin_set)
|
@@ -154,6 +158,7 @@ RSpec.describe 'AdminSetAbility' do
|
|
154
158
|
is_expected.not_to be_able_to(:manage, AdminSet)
|
155
159
|
is_expected.not_to be_able_to(:manage_any, AdminSet)
|
156
160
|
is_expected.not_to be_able_to(:create_any, AdminSet) # granted by collection type, not collection
|
161
|
+
is_expected.not_to be_able_to(:create, AdminSet)
|
157
162
|
is_expected.not_to be_able_to(:view_admin_show_any, AdminSet)
|
158
163
|
is_expected.not_to be_able_to(:edit, admin_set)
|
159
164
|
is_expected.not_to be_able_to(:edit, solr_document) # defined in solr_document_ability.rb
|
@@ -18,16 +18,85 @@ RSpec.describe Hyrax::Admin::AdminSetsController do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
describe "#show" do
|
21
|
-
|
21
|
+
before do
|
22
|
+
sign_in user
|
23
|
+
controller.instance_variable_set(:@admin_set, admin_set)
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when user has access through public group" do
|
27
|
+
# Even though the user can view this admin set, they should not be able to view
|
28
|
+
# it on the admin page.
|
29
|
+
let(:admin_set) { create(:adminset_lw, with_solr_document: true, with_permission_template: { view_groups: ['public'] }) }
|
30
|
+
|
31
|
+
it 'is unauthorized' do
|
32
|
+
get :show, params: { id: admin_set }
|
33
|
+
expect(response).to be_redirect
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when user has access through registered group" do
|
22
38
|
# Even though the user can view this admin set, the should not be able to view
|
23
39
|
# it on the admin page.
|
24
|
-
let(:admin_set) { create(:
|
40
|
+
let(:admin_set) { create(:adminset_lw, with_solr_document: true, with_permission_template: { view_groups: ['registered'] }) }
|
25
41
|
|
26
42
|
it 'is unauthorized' do
|
27
43
|
get :show, params: { id: admin_set }
|
28
44
|
expect(response).to be_redirect
|
29
45
|
end
|
30
46
|
end
|
47
|
+
|
48
|
+
context "when user is directly granted view access" do
|
49
|
+
# Even though the user can view this admin set, the should not be able to view
|
50
|
+
# it on the admin page.
|
51
|
+
let(:admin_set) { create(:adminset_lw, with_solr_document: true, with_permission_template: { view_users: [user.user_key] }) }
|
52
|
+
|
53
|
+
before do
|
54
|
+
create(:work, :public, admin_set: admin_set)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'defines a presenter' do
|
58
|
+
get :show, params: { id: admin_set }
|
59
|
+
expect(response).to be_success
|
60
|
+
expect(assigns[:presenter]).to be_kind_of Hyrax::AdminSetPresenter
|
61
|
+
expect(assigns[:presenter].id).to eq admin_set.id
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#edit" do
|
67
|
+
before do
|
68
|
+
sign_in user
|
69
|
+
end
|
70
|
+
|
71
|
+
context "when user is directly granted manage access" do
|
72
|
+
# Even though the user can view this admin set, the should not be able to view
|
73
|
+
# it on the admin page.
|
74
|
+
let(:admin_set) { create(:adminset_lw, with_solr_document: true, with_permission_template: { manage_users: [user.user_key] }) }
|
75
|
+
let(:admin_set2) { create(:adminset_lw, with_solr_document: true, with_permission_template: true) }
|
76
|
+
|
77
|
+
context 'and user is accessing the managed set' do
|
78
|
+
before do
|
79
|
+
controller.instance_variable_set(:@admin_set, admin_set)
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'defines a form' do
|
83
|
+
get :edit, params: { id: admin_set }
|
84
|
+
expect(response).to be_success
|
85
|
+
expect(assigns[:form]).to be_kind_of Hyrax::Forms::AdminSetForm
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'and user attempts to access another admin set' do
|
90
|
+
before do
|
91
|
+
controller.instance_variable_set(:@admin_set, admin_set2)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'is unauthorized' do
|
95
|
+
get :edit, params: { id: admin_set2 }
|
96
|
+
expect(response).to be_redirect
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
31
100
|
end
|
32
101
|
|
33
102
|
describe "#files" do
|
@@ -14,6 +14,9 @@ RSpec.describe ImportUrlJob do
|
|
14
14
|
let(:operation) { create(:operation) }
|
15
15
|
let(:actor) { instance_double(Hyrax::Actors::FileSetActor, create_content: true) }
|
16
16
|
|
17
|
+
let(:mock_retriever) { double }
|
18
|
+
let(:inbox) { user.mailbox.inbox }
|
19
|
+
|
17
20
|
before do
|
18
21
|
allow(Hyrax::Actors::FileSetActor).to receive(:new).with(file_set, user).and_return(actor)
|
19
22
|
|
@@ -26,6 +29,22 @@ RSpec.describe ImportUrlJob do
|
|
26
29
|
stub_request(:get, "http://example.org#{file_hash}").to_return(
|
27
30
|
body: File.open(File.expand_path(file_path, __FILE__)).read, status: 200, headers: response_headers
|
28
31
|
)
|
32
|
+
|
33
|
+
allow(BrowseEverything::Retriever).to receive(:new).and_return(mock_retriever)
|
34
|
+
allow(mock_retriever).to receive(:retrieve)
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'before enqueueing the job' do
|
38
|
+
before do
|
39
|
+
file_set.id = 'fsid123'
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '.operation' do
|
43
|
+
it 'fetches the operation' do
|
44
|
+
described_class.perform_later(file_set, operation)
|
45
|
+
expect { subject.operation.to eq Hyrax::Operation }
|
46
|
+
end
|
47
|
+
end
|
29
48
|
end
|
30
49
|
|
31
50
|
context 'after running the job' do
|
@@ -75,4 +94,38 @@ RSpec.describe ImportUrlJob do
|
|
75
94
|
expect(file.title).to eq(['File One'])
|
76
95
|
end
|
77
96
|
end
|
97
|
+
|
98
|
+
context 'when the remote file is unavailable' do
|
99
|
+
before do
|
100
|
+
response_headers = { 'Content-Type' => 'image/png', 'Content-Length' => File.size(File.expand_path(file_path, __FILE__)) }
|
101
|
+
|
102
|
+
stub_request(:head, "http://example.org#{file_hash}").to_return(
|
103
|
+
body: "", status: 404, headers: response_headers
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'sends error message' do
|
108
|
+
expect(operation).to receive(:fail!)
|
109
|
+
expect(file_set.original_file).to be_nil
|
110
|
+
described_class.perform_now(file_set, operation)
|
111
|
+
expect(inbox.count).to eq(1)
|
112
|
+
last_message = inbox[0].last_message
|
113
|
+
expect(last_message.subject).to eq('File Import Error')
|
114
|
+
expect(last_message.body).to eq("Error: Expired URL")
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context 'when retrieval fails' do
|
119
|
+
before { allow(mock_retriever).to receive(:retrieve).and_raise(StandardError, 'Timeout') }
|
120
|
+
|
121
|
+
it 'sends error message' do
|
122
|
+
expect(operation).to receive(:fail!)
|
123
|
+
expect(file_set.original_file).to be_nil
|
124
|
+
described_class.perform_now(file_set, operation)
|
125
|
+
expect(inbox.count).to eq(1)
|
126
|
+
last_message = inbox[0].last_message
|
127
|
+
expect(last_message.subject).to eq('File Import Error')
|
128
|
+
expect(last_message.body).to eq("Error: Timeout")
|
129
|
+
end
|
130
|
+
end
|
78
131
|
end
|
@@ -31,8 +31,8 @@ RSpec.describe Flipflop do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe "
|
35
|
-
subject { described_class.
|
34
|
+
describe "hide_private_items?" do
|
35
|
+
subject { described_class.hide_private_items? }
|
36
36
|
|
37
37
|
it "defaults to false" do
|
38
38
|
is_expected.to be false
|
@@ -55,6 +55,30 @@ RSpec.describe Hyrax::FileSetPresenter do
|
|
55
55
|
it { is_expected.to be false }
|
56
56
|
end
|
57
57
|
|
58
|
+
describe "#user_can_perform_any_action?" do
|
59
|
+
subject { presenter.user_can_perform_any_action? }
|
60
|
+
let(:current_ability) { ability }
|
61
|
+
|
62
|
+
context 'when user can perform at least 1 action' do
|
63
|
+
before do
|
64
|
+
expect(current_ability).to receive(:can?).with(:edit, presenter.id).and_return false
|
65
|
+
expect(current_ability).to receive(:can?).with(:destroy, presenter.id).and_return false
|
66
|
+
expect(current_ability).to receive(:can?).with(:download, presenter.id).and_return true
|
67
|
+
end
|
68
|
+
|
69
|
+
it { is_expected.to be true }
|
70
|
+
end
|
71
|
+
context 'when user cannot perform any action' do
|
72
|
+
before do
|
73
|
+
expect(current_ability).to receive(:can?).with(:edit, presenter.id).and_return false
|
74
|
+
expect(current_ability).to receive(:can?).with(:destroy, presenter.id).and_return false
|
75
|
+
expect(current_ability).to receive(:can?).with(:download, presenter.id).and_return false
|
76
|
+
end
|
77
|
+
|
78
|
+
it { is_expected.to be false }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
58
82
|
describe "properties delegated to solr_document" do
|
59
83
|
let(:solr_properties) do
|
60
84
|
["date_uploaded", "title_or_label",
|