zizia 5.5.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.github_changelog_generator +1 -1
  3. data/.rubocop.yml +0 -1
  4. data/CHANGELOG.md +12 -6
  5. data/README.md +2 -2
  6. data/app/assets/javascripts/zizia/zizia.js +1 -43
  7. data/app/helpers/zizia/application_helper.rb +6 -0
  8. data/app/models/zizia/csv_import_detail.rb +4 -0
  9. data/app/models/zizia/pre_ingest_work.rb +0 -15
  10. data/app/uploaders/zizia/csv_manifest_validator.rb +2 -2
  11. data/app/views/zizia/csv_import_details/_pre_ingest_files_table.html.erb +4 -0
  12. data/app/views/zizia/csv_import_details/index.html.erb +4 -0
  13. data/app/views/zizia/csv_import_details/show.html.erb +2 -8
  14. data/config/initializers/content_deposit_event_job_prepends.rb +10 -0
  15. data/config/initializers/file_set_attached_event_job_prepends.rb +12 -0
  16. data/config/initializers/prepends.rb +2 -0
  17. data/config/routes.rb +0 -1
  18. data/db/migrate/20191114021032_add_status_to_pre_ingest_file.rb +5 -0
  19. data/db/migrate/20191210223833_add_status_to_pre_ingest_work.rb +5 -0
  20. data/lib/zizia/hyrax/hyrax_basic_metadata_mapper.rb +10 -1
  21. data/lib/zizia/version.rb +1 -1
  22. data/spec/dummy/app/models/work.rb +1 -1
  23. data/spec/dummy/db/schema.rb +3 -0
  24. data/spec/dummy/spec/fixtures/csv_import/csv_files_with_problems/extra - headers.csv +4 -4
  25. data/spec/dummy/spec/fixtures/csv_import/good/all_fields.csv +2 -2
  26. data/spec/dummy/spec/fixtures/csv_import/good/all_fields_multi.csv +2 -0
  27. data/spec/dummy/spec/support/capybara.rb +1 -0
  28. data/spec/dummy/spec/system/csv_import_details_page_spec.rb +15 -24
  29. data/spec/dummy/spec/system/import_file_status_spec.rb +95 -0
  30. data/spec/dummy/spec/system/import_from_csv_spec.rb +2 -2
  31. data/spec/factories/pre_ingest_file.rb +1 -1
  32. data/spec/models/zizia/application_job_spec.rb +12 -0
  33. data/spec/models/zizia/pre_ingest_file_spec.rb +2 -8
  34. data/spec/rails_helper.rb +0 -3
  35. data/spec/support/hyrax/basic_metadata.rb +3 -0
  36. data/spec/zizia/hyrax/hyrax_basic_metadata_mapper_spec.rb +5 -1
  37. data/zizia.gemspec +1 -0
  38. metadata +24 -6
  39. data/app/controllers/zizia/pre_ingest_works_controller.rb +0 -32
  40. data/app/models/zizia/ability.rb +0 -15
  41. data/spec/controllers/pre_ingest_works_controller_spec.rb +0 -56
  42. data/spec/factories/file_sets.rb +0 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94370ebf6412c155e295ce307d1d60f7a650d12e60ad61172c869bf3054a76b3
4
- data.tar.gz: 137780153f7ccb0f0dd129ca47cdf1ba82bf867ac3c7942d9af0638320a2a306
3
+ metadata.gz: 4ea278f920c48f0ca7d4e52cc54a619fdcb1214cf115efaeff63f96ca36590ce
4
+ data.tar.gz: cf2d2a451e0e6d41d80ccf121793e1672cb2b1ce13a830013bfd031273a69f26
5
5
  SHA512:
6
- metadata.gz: 95c8b4a8bac7fc41862b6b5291122cafab5a6aae10e7e78231cfafd94e51a4dd07e84010a73fe8796e74a4f3c5e81f99df2e49b4637798242584e898682a3b36
7
- data.tar.gz: f0ff9cb82e4dda1a2dbe9f63761ffc0557c20932e2fea5d9e934f280f0094eb218fba7970778cff9437834d8aed3fcf0e014794364f0b49fb5825c95b9ae6a0c
6
+ metadata.gz: 30c878339f6b6076f203c008fed9b6ae448466947e55fbb8c80a53b56920e014be4e92d58afc322fffde6e04120a8cf8cee9be66ba5b90fda776a92ded3d5606
7
+ data.tar.gz: dfaf9874758df10a63ce96425105c986708858ed549f02217fac2977bb000e204294cb05dbe6e5b8a3ceb347604418e1a67396ddc2b97d0428389c23d8185e9d
@@ -1,2 +1,2 @@
1
1
  unreleased=true
2
- future-release=5.5.0
2
+ future-release=6.0.0
data/.rubocop.yml CHANGED
@@ -62,7 +62,6 @@ RSpec/DescribeClass:
62
62
 
63
63
  RSpec/ExampleLength:
64
64
  Exclude:
65
- - 'spec/controllers/pre_ingest_works_controller_spec.rb'
66
65
  - 'spec/zizia/hyrax/hyrax_basic_metadata_mapper_spec.rb'
67
66
  - 'spec/integration/import_hyrax_csv.rb'
68
67
  - 'spec/integration/csv_import_detail_spec.rb'
data/CHANGELOG.md CHANGED
@@ -1,8 +1,17 @@
1
1
  # Changelog
2
2
 
3
- ## [5.5.0](https://github.com/curationexperts/zizia/tree/5.5.0) (2019-11-21)
3
+ ## [6.0.0](https://github.com/curationexperts/zizia/tree/6.0.0) (2019-12-13)
4
4
 
5
- [Full Changelog](https://github.com/curationexperts/zizia/compare/v5.4.0...5.5.0)
5
+ [Full Changelog](https://github.com/curationexperts/zizia/compare/v5.5.0...6.0.0)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Revert "Basic file status" [\#68](https://github.com/curationexperts/zizia/pull/68) ([little9](https://github.com/little9))
10
+ - More detailed file status [\#66](https://github.com/curationexperts/zizia/pull/66) ([little9](https://github.com/little9))
11
+
12
+ ## [v5.5.0](https://github.com/curationexperts/zizia/tree/v5.5.0) (2019-11-21)
13
+
14
+ [Full Changelog](https://github.com/curationexperts/zizia/compare/v5.4.0...v5.5.0)
6
15
 
7
16
  **Merged pull requests:**
8
17
 
@@ -87,6 +96,7 @@
87
96
  - Add intro header for metadata field guide [\#36](https://github.com/curationexperts/zizia/pull/36) ([bess](https://github.com/bess))
88
97
  - Add field definitions for 'files' and 'visibility' to the field guide [\#35](https://github.com/curationexperts/zizia/pull/35) ([mark-dce](https://github.com/mark-dce))
89
98
  - Label and hide system fields [\#34](https://github.com/curationexperts/zizia/pull/34) ([bess](https://github.com/bess))
99
+ - Add files count to import details page [\#32](https://github.com/curationexperts/zizia/pull/32) ([little9](https://github.com/little9))
90
100
 
91
101
  ## [v4.5.4.alpha.01](https://github.com/curationexperts/zizia/tree/v4.5.4.alpha.01) (2019-10-04)
92
102
 
@@ -100,10 +110,6 @@
100
110
 
101
111
  [Full Changelog](https://github.com/curationexperts/zizia/compare/v4.5.2.alpha.01...v4.5.3.alpha.01)
102
112
 
103
- **Merged pull requests:**
104
-
105
- - Add files count to import details page [\#32](https://github.com/curationexperts/zizia/pull/32) ([little9](https://github.com/little9))
106
-
107
113
  ## [v4.5.2.alpha.01](https://github.com/curationexperts/zizia/tree/v4.5.2.alpha.01) (2019-10-03)
108
114
 
109
115
  [Full Changelog](https://github.com/curationexperts/zizia/compare/v4.5.1.alpha.01...v4.5.2.alpha.01)
data/README.md CHANGED
@@ -60,7 +60,7 @@ to create a new application with Zizia installed.
60
60
  8. Add a deduplication_key to your default work type's medata:
61
61
 
62
62
  ```
63
- property :deduplication_key, predicate: "http://curationexperts.com/vocab/predicates#deduplicationKey", multiple: false do |index|
63
+ property :deduplication_key, predicate: ::RDF::Vocab::BF2::identifiedBy, multiple: false do |index|
64
64
  index.as :stored_searchable
65
65
  end
66
66
  ```
@@ -104,7 +104,7 @@ environment variables called `IMPORT_PATH`. If `IMPORT_PATH` is not set, `HyraxR
104
104
 
105
105
  To run Solr and Fedora for testing purposes, open a new terminal session for each and run the following commads:
106
106
 
107
- `solr_wrapper --config spec/dummy/config/solr_wrapper_test.yml`
107
+ `solr_wrapper --config spec/dummy/config/solr_wrapper_test.yml`
108
108
  `fcrepo_wrapper --config spec/dummy/config/fcrepo_wrapper_test.yml`
109
109
 
110
110
  After this you can run the whole suite, or individual specs. System specs are located
@@ -1,48 +1,6 @@
1
1
  var Zizia = {
2
- displayUploadedFile: function () {
2
+ displayUploadedFile: function() {
3
3
  var DisplayUploadedFile = require('zizia/DisplayUploadedFile')
4
4
  new DisplayUploadedFile().display()
5
- },
6
- checkStatuses: function (options) {
7
- var results = []
8
- // Go through the list of thumbnails for the work based
9
- // on the deduplicationKey
10
- options.thumbnails.forEach(function (thumbnail) {
11
- $.ajax({
12
- type: 'HEAD',
13
- url: thumbnail,
14
- complete: function (xhr) {
15
- // Request only the headers from the thumbnail url
16
- // push the statuses into an array
17
- results.push(xhr.getResponseHeader('status'))
18
- // See how many urls are not returning 200
19
- var missingThumbnailCount = results.filter(
20
- function (status) {
21
- if (status !== '200 OK') { return true }
22
- }).length
23
- // If there are any not returning 200, the work is still being processed
24
- if (missingThumbnailCount > 0) {
25
-
26
- } else {
27
- Zizia.addSuccessClasses(options)
28
- }
29
- }
30
- })
31
- })
32
- },
33
- displayWorkStatus: function () {
34
- $('[id^=work-status]').each(function () {
35
- var deduplicationKey = $(this)[0].id.split('work-status-')[1]
36
- $.get('/pre_ingest_works/thumbnails/' + deduplicationKey, function (data) {
37
- data.deduplicationKey = deduplicationKey
38
- Zizia.checkStatuses(data)
39
- })
40
- })
41
- },
42
- addSuccessClasses: function (options) {
43
- $('#work-status-' + options.deduplicationKey + ' > span').removeClass('status-unknown')
44
- $('#work-status-' + options.deduplicationKey + ' > span').removeClass('glyphicon-question-sign')
45
- $('#work-status-' + options.deduplicationKey + ' > span').addClass('text-success')
46
- $('#work-status-' + options.deduplicationKey + ' > span').addClass('glyphicon-ok-sign')
47
5
  }
48
6
  }
@@ -30,5 +30,11 @@ module Zizia
30
30
  def collections?
31
31
  !ActiveFedora::SolrService.query('has_model_ssim:Collection').empty?
32
32
  end
33
+
34
+ def status_icon(status)
35
+ # rubocop:disable Rails/OutputSafety
36
+ return "<span class='glyphicon glyphicon-ok-sign text-success' aria-label='Status: Complete'></span>".html_safe if status == 'attached'
37
+ "<span class='glyphicon glyphicon-question-sign' aria-label='Status: Unknown'></span>".html_safe
38
+ end
33
39
  end
34
40
  end
@@ -9,6 +9,10 @@ module Zizia
9
9
  has_many :pre_ingest_works
10
10
  has_many :pre_ingest_files, through: :pre_ingest_works
11
11
 
12
+ def status
13
+ 'undetermined'
14
+ end
15
+
12
16
  def total_size
13
17
  return 0 if pre_ingest_files.empty?
14
18
  pre_ingest_files.map(&:size).sum
@@ -12,20 +12,5 @@ module Zizia
12
12
  return solr_title unless solr_title.nil?
13
13
  'This work\'s metadata has not been indexed yet.'
14
14
  end
15
-
16
- # Returns thumbnail urls based on the work's deduplication_key
17
- # @return [Array<String>] the work's thumbnail urls
18
- def thumbnails
19
- thumbnail_urls = []
20
- return thumbnail_urls if deduplication_key.nil?
21
- file_sets = ActiveFedora::SolrService.get("deduplication_key_tesim:#{deduplication_key}")
22
- .dig('response', 'docs', 0, 'file_set_ids_ssim')
23
- return thumbnail_urls unless file_sets
24
- file_sets.each do |file_set_id|
25
- thumbnail_urls.push(ActiveFedora::SolrService.get("id:#{file_set_id}")
26
- .dig('response', 'docs', 0, 'thumbnail_path_ss'))
27
- end
28
- thumbnail_urls
29
- end
30
15
  end
31
16
  end
@@ -63,7 +63,7 @@ module Zizia
63
63
  'publisher', 'date created', 'subject',
64
64
  'language', 'identifier', 'location',
65
65
  'related url', 'bibliographic_citation',
66
- 'source', 'visibility']
66
+ 'source', 'visibility', 'deduplication_key', 'type']
67
67
  end
68
68
 
69
69
  def parse_csv
@@ -82,7 +82,7 @@ module Zizia
82
82
  end
83
83
 
84
84
  def required_headers
85
- ['title', 'creator', 'keyword', 'rights statement', 'visibility', 'files']
85
+ ['title', 'creator', 'keyword', 'rights statement', 'visibility', 'files', 'deduplication_key']
86
86
  end
87
87
 
88
88
  def duplicate_headers
@@ -8,6 +8,7 @@
8
8
  <th>Size</th>
9
9
  <th>Row Number</th>
10
10
  <th>Date Created</th>
11
+ <th>Status</th>
11
12
  </tr>
12
13
  <% pre_ingest_work.pre_ingest_files.each do |pre_ingest_file| %>
13
14
  <tr>
@@ -23,6 +24,9 @@
23
24
  <td>
24
25
  <%= pre_ingest_file.created_at.strftime("%B %-d, %Y %H:%M") %>
25
26
  </td>
27
+ <td>
28
+ <%= status_icon(pre_ingest_file.status) %>
29
+ </td>
26
30
  </tr>
27
31
  <% end %>
28
32
  </table>
@@ -9,6 +9,7 @@
9
9
  <th>Number of Works</th>
10
10
  <th>Number of Files</th>
11
11
  <th>Total Size</th>
12
+ <th>Status</th>
12
13
  <th>Overwrite Behavior Type</th>
13
14
  </tr>
14
15
  <% @csv_import_details.each do |csv_import_detail| %>
@@ -34,6 +35,9 @@
34
35
  <td>
35
36
  <%= number_to_human_size(csv_import_detail.total_size) %>
36
37
  </td>
38
+ <td>
39
+ <%= csv_import_detail.status %>
40
+ </td>
37
41
  <td>
38
42
  <%= human_update_actor_stack(csv_import_detail.update_actor_stack) %>
39
43
  </td>
@@ -15,7 +15,6 @@
15
15
  <th>Title</th>
16
16
  <th>Files</th>
17
17
  <th>Date</th>
18
- <th>Status</th>
19
18
  </tr>
20
19
  <% @pre_ingest_works.each do |pre_ingest_work| %>
21
20
  <tr>
@@ -31,16 +30,11 @@
31
30
  <td>
32
31
  <%= pre_ingest_work.created_at.strftime("%B %-d, %Y %H:%M") %>
33
32
  </td>
34
- <td id="<%= "work-status-#{pre_ingest_work.deduplication_key}" %>">
35
- <span class="glyphicon glyphicon-question-sign status-unknown"></span>
33
+ <td>
34
+ <%= status_icon(pre_ingest_work.status) %>
36
35
  </td>
37
36
  </tr>
38
37
  <% end %>
39
38
  </table>
40
39
  <%= paginate @pre_ingest_works %>
41
40
  </div>
42
- <script>
43
- $(document).on('turbolinks:load', function() {
44
- Zizia.displayWorkStatus()
45
- })
46
- </script>
@@ -0,0 +1,10 @@
1
+ module ContentDepositEventJobPrepends
2
+ def action
3
+ super
4
+ if repo_object.deduplication_key
5
+ pre_ingest_work = Zizia::PreIngestWork.find_by(deduplication_key: repo_object.deduplication_key)
6
+ pre_ingest_work.status = 'attached'
7
+ pre_ingest_work.save
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ module FileSetAttachedEventJobPrepends
2
+ def action
3
+ if repo_object.kind_of?(FileSet)
4
+ pre_ingest_work_id = Zizia::PreIngestWork.find_by(deduplication_key: curation_concern.deduplication_key)
5
+ pre_ingest_file = Zizia::PreIngestFile.find_by(size: repo_object.files.first.size,
6
+ filename: repo_object.files.first.original_name,
7
+ pre_ingest_work_id: pre_ingest_work_id)
8
+ pre_ingest_file.status = 'attached'
9
+ pre_ingest_file.save
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ ContentDepositEventJob.prepend(ContentDepositEventJobPrepends)
2
+ FileSetAttachedEventJob.prepend(FileSetAttachedEventJobPrepends)
data/config/routes.rb CHANGED
@@ -10,5 +10,4 @@ Zizia::Engine.routes.draw do
10
10
 
11
11
  get 'csv_import_details/index'
12
12
  get 'csv_import_details/show/:id', to: 'csv_import_details#show', as: 'csv_import_detail'
13
- get 'pre_ingest_works/thumbnails/:deduplication_key', to: 'pre_ingest_works#thumbnails'
14
13
  end
@@ -0,0 +1,5 @@
1
+ class AddStatusToPreIngestFile < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :zizia_pre_ingest_files, :status, :string, default: 'preingest'
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddStatusToPreIngestWork < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :zizia_pre_ingest_works, :status, :string, default: 'preingest'
4
+ end
5
+ end
@@ -31,7 +31,7 @@ module Zizia
31
31
  ##
32
32
  # @return [Enumerable<Symbol>] The fields the mapper can process.
33
33
  def fields
34
- core_fields + basic_fields + [:visibility, :files]
34
+ core_fields + basic_fields + [:visibility, :files] + zizia_fields
35
35
  end
36
36
 
37
37
  # Properties defined with `multiple: false` in
@@ -57,6 +57,10 @@ module Zizia
57
57
  single_value('import_url')
58
58
  end
59
59
 
60
+ def deduplication_key
61
+ single_value('deduplication_key')
62
+ end
63
+
60
64
  # We should accept visibility values that match the UI and transform them into
61
65
  # the controlled vocabulary term expected by Hyrax
62
66
  def visibility
@@ -152,5 +156,10 @@ module Zizia
152
156
  :based_near, :related_url,
153
157
  :bibliographic_citation, :source]
154
158
  end
159
+
160
+ # Properties requires for zizia
161
+ def zizia_fields
162
+ [:deduplication_key]
163
+ end
155
164
  end
156
165
  end
data/lib/zizia/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zizia
4
- VERSION = '5.5.0'
4
+ VERSION = '6.0.0'
5
5
  end
@@ -9,7 +9,7 @@ class Work < ActiveFedora::Base
9
9
  validates :title, presence: { message: 'Your work must have a title.' }
10
10
 
11
11
 
12
- property :deduplication_key, predicate: 'http://metadata.example.com/vocab/predicates#deduplicationKey', multiple: false do |index|
12
+ property :deduplication_key, predicate: ::RDF::Vocab::BF2::identifiedBy, multiple: false do |index|
13
13
  index.as :stored_searchable
14
14
  end
15
15
  # This must be included at the end, because it finalizes the metadata
@@ -595,6 +595,8 @@ ActiveRecord::Schema.define(version: 201901241536542) do
595
595
  t.integer "pre_ingest_work_id"
596
596
  t.datetime "created_at", null: false
597
597
  t.datetime "updated_at", null: false
598
+ t.string "status", default: "preingest"
599
+ t.string "access_control_id"
598
600
  t.index ["pre_ingest_work_id"], name: "index_zizia_pre_ingest_files_on_pre_ingest_work_id"
599
601
  end
600
602
 
@@ -604,6 +606,7 @@ ActiveRecord::Schema.define(version: 201901241536542) do
604
606
  t.datetime "created_at", null: false
605
607
  t.datetime "updated_at", null: false
606
608
  t.string "deduplication_key"
609
+ t.string "status", default: "preingest"
607
610
  t.index ["csv_import_detail_id"], name: "index_zizia_pre_ingest_works_on_csv_import_detail_id"
608
611
  t.index ["deduplication_key"], name: "index_zizia_pre_ingest_works_on_deduplication_key"
609
612
  end
@@ -1,4 +1,4 @@
1
- rights_statement,another_header_2,rights statement,title,files,label,relative_path,import url,resource type,creator,contributor,abstract or summary,keyword,license,publisher,date created,subject,language,identifier,location,related url,bibliographic_citation,source,visibility
2
- http://rightsstatements.org/vocab/InC/1.0/,,http://rightsstatements.org/vocab/InC/1.0/,Work 1 Title,cat.jpg,,,,,creator,,,cat,,,,,,,,,,,open
3
- http://rightsstatements.org/vocab/InC/1.0/,,http://rightsstatements.org/vocab/InC/1.0/,Work 2 Title,cat.jpg,,,,,creator,,,cat,,,,,,,,,,,open
4
- http://rightsstatements.org/vocab/InC/1.0/,,http://rightsstatements.org/vocab/InC/1.0/,Work 3 Title,cat.jpg,,,,,creator,,,cat,,,,,,,,,,,open
1
+ deduplication_key,rights_statement,another_header_2,rights statement,title,files,label,relative_path,import url,resource type,creator,contributor,abstract or summary,keyword,license,publisher,date created,subject,language,identifier,location,related url,bibliographic_citation,source,visibility
2
+ 1,http://rightsstatements.org/vocab/InC/1.0/,,http://rightsstatements.org/vocab/InC/1.0/,Work 1 Title,cat.jpg,,,,,creator,,,cat,,,,,,,,,,,open
3
+ 2,http://rightsstatements.org/vocab/InC/1.0/,,http://rightsstatements.org/vocab/InC/1.0/,Work 2 Title,cat.jpg,,,,,creator,,,cat,,,,,,,,,,,open
4
+ 3,http://rightsstatements.org/vocab/InC/1.0/,,http://rightsstatements.org/vocab/InC/1.0/,Work 3 Title,cat.jpg,,,,,creator,,,cat,,,,,,,,,,,open
@@ -1,2 +1,2 @@
1
- identifier,license,deduplication_key,visibility,location,keyword,rights statement,creator,title,files
2
- abc/123,https://creativecommons.org/licenses/by/4.0/,abc/123,PUBlic,http://www.geonames.org/5667009/montana.html|~|http://www.geonames.org/6252001/united-states.html,Clothing stores $z California $z Los Angeles|~|Interior design $z California $z Los Angeles,http://rightsstatements.org/vocab/InC/1.0/,"Connell, Will, $d 1898-1961","Interior view of The Bachelors haberdashery designed by Julius Ralph Davidson, Los Angeles, circa 1929",dog.jpg
1
+ identifier,type,license,deduplication_key,visibility,location,keyword,rights statement,creator,title,files
2
+ abc/123,work,https://creativecommons.org/licenses/by/4.0/,abc/123,PUBlic,http://www.geonames.org/5667009/montana.html|~|http://www.geonames.org/6252001/united-states.html,Clothing stores $z California $z Los Angeles|~|Interior design $z California $z Los Angeles,http://rightsstatements.org/vocab/InC/1.0/,"Connell, Will, $d 1898-1961","Interior view of The Bachelors haberdashery designed by Julius Ralph Davidson, Los Angeles, circa 1929",dog.jpg
@@ -0,0 +1,2 @@
1
+ identifier,type,license,deduplication_key,visibility,location,keyword,rights statement,creator,title,files
2
+ abc/123,work,https://creativecommons.org/licenses/by/4.0/,abc/123,PUBlic,http://www.geonames.org/5667009/montana.html|~|http://www.geonames.org/6252001/united-states.html,Clothing stores $z California $z Los Angeles|~|Interior design $z California $z Los Angeles,http://rightsstatements.org/vocab/InC/1.0/,"Connell, Will, $d 1898-1961","Interior view of The Bachelors haberdashery designed by Julius Ralph Davidson, Los Angeles, circa 1929",dog.jpg|~|cat.jpg
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ Capybara.default_max_wait_time = 20
2
3
 
3
4
  # Setup chrome headless driver
4
5
  Capybara.server = :puma, { Silent: true }
@@ -1,7 +1,7 @@
1
1
  require 'rails_helper'
2
2
  include Warden::Test::Helpers
3
3
 
4
- RSpec.describe 'viewing the csv import detail page', :clean, js: true do
4
+ RSpec.describe 'viewing the csv import detail page', js: true do
5
5
  let(:user) { FactoryBot.create(:admin, email: 'systems@curationexperts.com')}
6
6
  let(:second_user) { FactoryBot.create(:user, email: 'user@curationexperts.com') }
7
7
  let(:csv_import) { FactoryBot.create(:csv_import) }
@@ -11,14 +11,6 @@ RSpec.describe 'viewing the csv import detail page', :clean, js: true do
11
11
  let(:csv_import_detail_third) { FactoryBot.create(:csv_import_detail, created_at: Time.parse('Wed, 30 Oct 2019 14:20:02 UTC +00:00').utc, depositor_id: second_user.id, csv_import_id: 2) }
12
12
  let(:csv_pre_ingest_works) { FactoryBot.create_list(:pre_ingest_work, 12, csv_import_detail_id: 4) }
13
13
  let(:csv_pre_ingest_work_second) { FactoryBot.create(:pre_ingest_work, csv_import_detail_id: 5, created_at: Time.parse('Thur, 31 Oct 2019 14:20:02 UTC +00:00').utc) }
14
- let(:pre_ingest_file) { FactoryBot.create(:pre_ingest_file, pre_ingest_work_id: csv_pre_ingest_work_second.id) }
15
- let(:file_set) do
16
- FactoryBot.create(:file_set,
17
- title: ['zizia.png'],
18
- content: File.open([Zizia::Engine.root, '/', 'spec/fixtures/zizia.png'].join))
19
- end
20
- let(:work) { Work.new(title: ['a title'], deduplication_key: csv_pre_ingest_work_second.deduplication_key) }
21
-
22
14
 
23
15
  before do
24
16
  user.save
@@ -35,10 +27,6 @@ RSpec.describe 'viewing the csv import detail page', :clean, js: true do
35
27
  csv_import_detail_third.save
36
28
  csv_pre_ingest_works.each(&:save)
37
29
  csv_pre_ingest_work_second.save
38
- pre_ingest_file.save
39
-
40
- work.ordered_members << file_set
41
- work.save
42
30
  login_as user
43
31
  end
44
32
 
@@ -46,6 +34,7 @@ RSpec.describe 'viewing the csv import detail page', :clean, js: true do
46
34
  visit ('/csv_import_details/index')
47
35
  expect(page).to have_content('ID')
48
36
  click_on '13'
37
+ expect(page).to have_content('Status')
49
38
  expect(page).to have_content('Total Size')
50
39
  expect(page).to have_content('Deduplication Key')
51
40
  end
@@ -65,6 +54,12 @@ RSpec.describe 'viewing the csv import detail page', :clean, js: true do
65
54
  expect(page).to have_link '13'
66
55
  end
67
56
 
57
+ it 'has a sortable status' do
58
+ pending 'status is always undetermined currently'
59
+ visit('/csv_import_details/index?direction=asc&locale=en&sort=status')
60
+ expect(page).to have_content 'zippy'
61
+ end
62
+
68
63
  it 'has a sortable date' do
69
64
  visit('/csv_import_details/index?direction=desc&locale=en&sort=created_at')
70
65
  expect(page).to have_content 'October 31'
@@ -83,6 +78,12 @@ RSpec.describe 'viewing the csv import detail page', :clean, js: true do
83
78
  expect(page).to have_content('October 29, 2019 14:20')
84
79
  end
85
80
 
81
+ it 'displays undetermined for the status' do
82
+ visit ('/csv_import_details/index')
83
+ expect(page).to have_content('Status')
84
+ expect(page).to have_content('undetermined')
85
+ end
86
+
86
87
  it 'displays the overwrite behavior type' do
87
88
  visit ('/csv_import_details/index')
88
89
  expect(page).to have_content('Overwrite Behavior Type')
@@ -98,6 +99,7 @@ RSpec.describe 'viewing the csv import detail page', :clean, js: true do
98
99
 
99
100
  visit('/csv_import_details/index')
100
101
  expect(page).to have_content('Next')
102
+
101
103
  end
102
104
 
103
105
  it 'has pagination at 10' do
@@ -132,15 +134,4 @@ RSpec.describe 'viewing the csv import detail page', :clean, js: true do
132
134
  click_on 'View Files'
133
135
  expect(page).to have_content 'Row Number'
134
136
  end
135
-
136
- it 'can show a status for a file' do
137
- file_set
138
- visit('/csv_import_details/index')
139
- click_on '5'
140
- expect(page).to have_content 'View Files'
141
- expect(page).to have_content 'Status'
142
- expect(page.html).to match(/glyphicon-question-sign/)
143
- click_on 'View Files'
144
- expect(page).to have_content('Filename')
145
- end
146
137
  end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+ require 'rails_helper'
3
+ include Warden::Test::Helpers
4
+
5
+ RSpec.describe 'Importing records from a CSV file', :perform_jobs, :clean, type: :system, js: true do
6
+ before do
7
+ allow(CharacterizeJob).to receive(:perform_later)
8
+ ENV['IMPORT_PATH'] = File.join(fixture_path, 'images')
9
+ end
10
+
11
+ let(:csv_file) { File.join(fixture_path, 'csv_import', 'good', 'all_fields_multi.csv') }
12
+
13
+ context 'logged in as an admin user' do
14
+ let(:collection) { FactoryBot.build(:collection, title: ['Testing Collection']) }
15
+ let(:admin_user) { FactoryBot.create(:admin) }
16
+
17
+ let(:admin_set_id) { AdminSet.find_or_create_default_admin_set_id }
18
+ let(:permission_template) { Hyrax::PermissionTemplate.find_or_create_by!(source_id: admin_set_id) }
19
+ let(:workflow) { Sipity::Workflow.create!(active: true, name: 'test-workflow', permission_template: permission_template) }
20
+
21
+ before do
22
+ # Create a single action that can be taken
23
+ Sipity::WorkflowAction.create!(name: 'submit', workflow: workflow)
24
+
25
+ # Grant the user access to deposit into the admin set.
26
+ Hyrax::PermissionTemplateAccess.create!(
27
+ permission_template_id: permission_template.id,
28
+ agent_type: 'user',
29
+ agent_id: admin_user.user_key,
30
+ access: 'deposit'
31
+ )
32
+
33
+ collection.save!
34
+ login_as admin_user
35
+ end
36
+
37
+ it 'starts the import' do
38
+ visit '/csv_imports/new'
39
+ expect(page).to have_content 'Testing Collection'
40
+ expect(page).not_to have_content '["Testing Collection"]'
41
+
42
+ # Fill in and submit the form
43
+ select 'Testing Collection', from: "csv_import[fedora_collection_id]"
44
+ select 'Update Existing Metadata, create new works', from: "csv_import[update_actor_stack]"
45
+ attach_file('csv_import[manifest]', csv_file, make_visible: true)
46
+
47
+ expect(page).to have_content('You sucessfully uploaded this CSV: all_fields_multi.csv')
48
+
49
+ click_on 'Preview Import'
50
+
51
+ # We expect to see the title of the collection on the page
52
+ expect(page).to have_content 'Testing Collection'
53
+
54
+ expect(page).to have_content 'This import will process 1 row(s).'
55
+
56
+ # There is a link so the user can cancel.
57
+ expect(page).to have_link 'Cancel', href: '/csv_imports/new?locale=en'
58
+
59
+ expect(page).not_to have_content 'deduplication_key'
60
+
61
+ # After reading the warnings, the user decides
62
+ # to continue with the import.
63
+ click_on 'Start Import'
64
+
65
+ # The show page for the CsvImport
66
+ expect(page).to have_content 'all_fields_multi.csv'
67
+ expect(page).to have_content 'Start time'
68
+
69
+ # We expect to see the title of the collection on the page
70
+ expect(page).to have_content 'Testing Collection'
71
+ expect(Work.count).to eq 1
72
+
73
+ # Ensure that all the fields got assigned as expected
74
+ work = Work.where(title: "*haberdashery*").first
75
+ expect(work.title.first).to match(/haberdashery/)
76
+ expect(Zizia::PreIngestFile.last.status).to eq('attached')
77
+
78
+ expect(Zizia::PreIngestWork.find_by(deduplication_key: work.deduplication_key).pre_ingest_files.count).to eq(2)
79
+
80
+ # Everything should have the attached status now
81
+ expect(Zizia::PreIngestWork.find_by(deduplication_key: work.deduplication_key)
82
+ .pre_ingest_files.first.status).to eq('attached')
83
+ expect(Zizia::PreIngestWork.find_by(deduplication_key: work.deduplication_key).pre_ingest_files.last.status).to eq('attached')
84
+ expect(Zizia::PreIngestWork.find_by(deduplication_key: work.deduplication_key).status).to eq('attached')
85
+ visit('/csv_import_details/index')
86
+ click_on '1'
87
+ expect(page).to have_content 'View Files'
88
+ click_on 'View Files'
89
+ expect(page.html).not_to match(/glyphicon-question-sign/)
90
+ expect(page.html).to match(/glyphicon-ok-sign/)
91
+ expect(page).to have_content('dog.jpg')
92
+ expect(page).to have_content('cat.jpg')
93
+ end
94
+ end
95
+ end
@@ -4,6 +4,7 @@ include Warden::Test::Helpers
4
4
 
5
5
  RSpec.describe 'Importing records from a CSV file', :perform_jobs, :clean, type: :system, js: true do
6
6
  before do
7
+ allow(CharacterizeJob).to receive(:perform_later)
7
8
  ENV['IMPORT_PATH'] = File.join(fixture_path, 'images')
8
9
  end
9
10
 
@@ -32,7 +33,6 @@ RSpec.describe 'Importing records from a CSV file', :perform_jobs, :clean, type:
32
33
  access: 'deposit'
33
34
  )
34
35
 
35
- allow(CharacterizeJob).to receive(:perform_later) # There is no fits installed on travis-ci
36
36
  collection.save!
37
37
  login_as admin_user
38
38
  end
@@ -251,7 +251,7 @@ RSpec.describe 'Importing records from a CSV file', :perform_jobs, :clean, type:
251
251
  expect(page).to have_content('cat.jpg')
252
252
  expect(page).to have_content('5.74 MB')
253
253
  expect(page).to have_content('abc/123')
254
- expect(page).to have_content('This work\'s metadata has not been indexed yet.')
254
+ expect(page).to have_content('haberdashery')
255
255
  expect(page).to have_content('Date Created')
256
256
  end
257
257
  end
@@ -7,7 +7,7 @@ FactoryBot.define do
7
7
  updated_at { Time.current }
8
8
  row_number { 1 }
9
9
  row { 'sample,row' }
10
- filename { [Zizia::Engine.root, '/', 'spec/fixtures/zizia.png'].join }
10
+ filename { '/a/path/to/my.csv' }
11
11
  size { 100_203_424 }
12
12
  end
13
13
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ require 'rails_helper'
3
+
4
+ RSpec.describe Zizia::ApplicationJob do
5
+ let(:application_job) { described_class.new }
6
+
7
+ context 'when including Zizia' do
8
+ it 'has its own ApplicationJob class' do
9
+ expect(application_job).to be_kind_of(ActiveJob::Base)
10
+ end
11
+ end
12
+ end
@@ -4,15 +4,9 @@ require 'rails_helper'
4
4
  RSpec.describe Zizia::PreIngestFile do
5
5
  let(:pre_ingest_work) { FactoryBot.create(:pre_ingest_work) }
6
6
  let(:pre_ingest_file) { FactoryBot.create(:pre_ingest_file, pre_ingest_work_id: pre_ingest_work.id) }
7
- let(:pre_ingest_file_without_file) { FactoryBot.create(:pre_ingest_file, pre_ingest_work_id: pre_ingest_work.id, filename: File.open([Zizia::Engine.root, '/', 'spec/fixtures/dog.jpg'].join)) }
8
- let(:file_set) do
9
- FactoryBot.create(:file_set,
10
- title: ['zizia.png'],
11
- content: File.open([Zizia::Engine.root, '/', 'spec/fixtures/zizia.png'].join))
12
- end
13
- let(:basename) { 'zizia.png' }
7
+ let(:basename) { 'my.csv' }
14
8
 
15
9
  it 'can get the basename for the file' do
16
- expect(pre_ingest_file.basename).to eq basename
10
+ expect(pre_ingest_file.basename).to eq(basename)
17
11
  end
18
12
  end
data/spec/rails_helper.rb CHANGED
@@ -12,7 +12,6 @@ require 'hydra-role-management'
12
12
  require 'byebug'
13
13
  require 'rails-controller-testing'
14
14
  require 'selenium-webdriver'
15
- require 'devise'
16
15
  # Add additional requires below this line. Rails is not loaded until this point!
17
16
 
18
17
  # Requires supporting ruby files with custom matchers and macros, etc, in
@@ -39,8 +38,6 @@ rescue ActiveRecord::PendingMigrationError => e
39
38
  exit 1
40
39
  end
41
40
  RSpec.configure do |config|
42
- config.include Devise::Test::ControllerHelpers, type: :controller
43
-
44
41
  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
45
42
  config.fixture_path = "#{::Rails.root}/spec/fixtures"
46
43
 
@@ -25,6 +25,9 @@ module Hyrax
25
25
  work.property :related_url, predicate: ::RDF::RDFS.seeAlso
26
26
  work.property :bibliographic_citation, predicate: ::RDF::Vocab::DC.bibliographicCitation
27
27
  work.property :source, predicate: ::RDF::Vocab::DC.source
28
+
29
+ # From Zizia
30
+ work.property :deduplication_key, predicate: ::RDF::Vocab::BF2.identifiedBy
28
31
  end
29
32
  end
30
33
  end
@@ -23,12 +23,16 @@ describe Zizia::HyraxBasicMetadataMapper do
23
23
  [:visibility, :files]
24
24
  end
25
25
 
26
+ let(:zizia_fields) do
27
+ [:deduplication_key]
28
+ end
29
+
26
30
  it_behaves_like 'a Zizia::Mapper' do
27
31
  let(:metadata) do
28
32
  { title: ['A Title for a Record'],
29
33
  my_custom_field: ['This gets ignored'] }
30
34
  end
31
- let(:expected_fields) { core_fields + basic_fields + tenejo_fields }
35
+ let(:expected_fields) { core_fields + basic_fields + tenejo_fields + zizia_fields }
32
36
  end
33
37
 
34
38
  context 'with metadata, but some missing fields' do
data/zizia.gemspec CHANGED
@@ -34,6 +34,7 @@ Gem::Specification.new do |gem|
34
34
  gem.add_development_dependency 'fcrepo_wrapper'
35
35
  gem.add_development_dependency 'ffaker'
36
36
  gem.add_development_dependency 'font-awesome-rails'
37
+ gem.add_development_dependency 'github_changelog_generator'
37
38
  gem.add_development_dependency 'hydra-role-management'
38
39
  gem.add_development_dependency 'hyrax', '~> 2.5.1'
39
40
  gem.add_development_dependency 'hyrax-spec'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zizia
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Data Curation Experts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-21 00:00:00.000000000 Z
11
+ date: 2019-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active-fedora
@@ -254,6 +254,20 @@ dependencies:
254
254
  - - ">="
255
255
  - !ruby/object:Gem::Version
256
256
  version: '0'
257
+ - !ruby/object:Gem::Dependency
258
+ name: github_changelog_generator
259
+ requirement: !ruby/object:Gem::Requirement
260
+ requirements:
261
+ - - ">="
262
+ - !ruby/object:Gem::Version
263
+ version: '0'
264
+ type: :development
265
+ prerelease: false
266
+ version_requirements: !ruby/object:Gem::Requirement
267
+ requirements:
268
+ - - ">="
269
+ - !ruby/object:Gem::Version
270
+ version: '0'
257
271
  - !ruby/object:Gem::Dependency
258
272
  name: hydra-role-management
259
273
  requirement: !ruby/object:Gem::Requirement
@@ -673,7 +687,6 @@ files:
673
687
  - app/controllers/zizia/csv_imports_controller.rb
674
688
  - app/controllers/zizia/importer_documentation_controller.rb
675
689
  - app/controllers/zizia/metadata_details_controller.rb
676
- - app/controllers/zizia/pre_ingest_works_controller.rb
677
690
  - app/helpers/zizia/application_helper.rb
678
691
  - app/helpers/zizia/metadata_details_helper.rb
679
692
  - app/importers/modular_importer.rb
@@ -682,7 +695,6 @@ files:
682
695
  - app/lib/zizia/metadata_details.rb
683
696
  - app/lib/zizia/metadata_usage.rb
684
697
  - app/lib/zizia/work_attributes.rb
685
- - app/models/zizia/ability.rb
686
698
  - app/models/zizia/csv_import.rb
687
699
  - app/models/zizia/csv_import_detail.rb
688
700
  - app/models/zizia/pre_ingest_file.rb
@@ -710,6 +722,9 @@ files:
710
722
  - app/views/zizia/importer_documentation/guide.html.erb
711
723
  - app/views/zizia/metadata_details/show.html.erb
712
724
  - bin/rails
725
+ - config/initializers/content_deposit_event_job_prepends.rb
726
+ - config/initializers/file_set_attached_event_job_prepends.rb
727
+ - config/initializers/prepends.rb
713
728
  - config/routes.rb
714
729
  - db/migrate/201901162141281_create_zizia_csv_imports.rb
715
730
  - db/migrate/201901162203121_add_manifest_to_zizia_csv_imports.rb
@@ -731,6 +746,8 @@ files:
731
746
  - db/migrate/20191031131041_add_deduplication_key_to_pre_ingest_work.rb
732
747
  - db/migrate/20191105165518_add_uniqueness_constraint_to_pre_ingest_work_deduplication_key.rb
733
748
  - db/migrate/20191105211127_remove_uniqueness_constraint_to_pre_ingest_work_deduplication_key.rb
749
+ - db/migrate/20191114021032_add_status_to_pre_ingest_file.rb
750
+ - db/migrate/20191210223833_add_status_to_pre_ingest_work.rb
734
751
  - docs/_config.yml
735
752
  - docs/customizing_metadata.md
736
753
  - docs/index.md
@@ -781,7 +798,6 @@ files:
781
798
  - solr/config/xslt/luke.xsl
782
799
  - spec/controllers/importer_documentation_controller_spec.rb
783
800
  - spec/controllers/metadata_details_spec.rb
784
- - spec/controllers/pre_ingest_works_controller_spec.rb
785
801
  - spec/dummy/.fcrepo_wrapper
786
802
  - spec/dummy/.gitignore
787
803
  - spec/dummy/.rspec
@@ -1474,6 +1490,7 @@ files:
1474
1490
  - spec/dummy/spec/fixtures/csv_import/good/all_fields.csv
1475
1491
  - spec/dummy/spec/fixtures/csv_import/good/all_fields_complete_update.csv
1476
1492
  - spec/dummy/spec/fixtures/csv_import/good/all_fields_metadata_update.csv
1493
+ - spec/dummy/spec/fixtures/csv_import/good/all_fields_multi.csv
1477
1494
  - spec/dummy/spec/fixtures/csv_import/good/all_fields_only_new.csv
1478
1495
  - spec/dummy/spec/fixtures/images/animals/cat.png
1479
1496
  - spec/dummy/spec/fixtures/images/birds.jpg
@@ -1490,6 +1507,7 @@ files:
1490
1507
  - spec/dummy/spec/support/capybara.rb
1491
1508
  - spec/dummy/spec/system/csv_import_details_page_spec.rb
1492
1509
  - spec/dummy/spec/system/import_csv_with_warnings_spec.rb
1510
+ - spec/dummy/spec/system/import_file_status_spec.rb
1493
1511
  - spec/dummy/spec/system/import_from_csv_spec.rb
1494
1512
  - spec/dummy/spec/system/import_from_csv_with_errors_spec.rb
1495
1513
  - spec/dummy/spec/system/import_with_no_collection_spec.rb
@@ -1512,7 +1530,6 @@ files:
1512
1530
  - spec/factories/collection.rb
1513
1531
  - spec/factories/csv_import.rb
1514
1532
  - spec/factories/csv_import_detail.rb
1515
- - spec/factories/file_sets.rb
1516
1533
  - spec/factories/pre_ingest_file.rb
1517
1534
  - spec/factories/pre_ingest_work.rb
1518
1535
  - spec/factories/user.rb
@@ -1532,6 +1549,7 @@ files:
1532
1549
  - spec/integration/csv_import_detail_spec.rb
1533
1550
  - spec/integration/import_hyrax_csv.rb
1534
1551
  - spec/models/csv_import_spec.rb
1552
+ - spec/models/zizia/application_job_spec.rb
1535
1553
  - spec/models/zizia/csv_import_detail_spec.rb
1536
1554
  - spec/models/zizia/pre_ingest_file_spec.rb
1537
1555
  - spec/models/zizia/pre_ingest_work_spec.rb
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Zizia
4
- class PreIngestWorksController < ::ApplicationController
5
- before_action :merge_abilities
6
- load_and_authorize_resource
7
-
8
- def thumbnails
9
- pre_ingest_work = Zizia::PreIngestWork.where(deduplication_key: pre_ingest_works_params[:deduplication_key]).first
10
-
11
- @thumbnails = if pre_ingest_work
12
- pre_ingest_work.thumbnails
13
- else
14
- []
15
- end
16
-
17
- respond_to do |format|
18
- format.json { render json: { thumbnails: @thumbnails } }
19
- end
20
- end
21
-
22
- private
23
-
24
- def pre_ingest_works_params
25
- params.permit(:deduplication_key, :format)
26
- end
27
-
28
- def merge_abilities
29
- current_ability.merge(Zizia::Ability.new(current_user))
30
- end
31
- end
32
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
- module Zizia
3
- class Ability
4
- include Hydra::Ability
5
- include Hyrax::Ability
6
- self.ability_logic += [:everyone_can_create_curation_concerns]
7
-
8
- # Define any customized permissions here.
9
- def custom_permissions
10
- can :manage, Zizia::CsvImport if current_user.admin?
11
- can :manage, Zizia::CsvImportDetail if current_user.admin?
12
- can :manage, Zizia::PreIngestWork if current_user.admin?
13
- end
14
- end
15
- end
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe Zizia::PreIngestWorksController, :clean, type: :controller do
6
- routes { Zizia::Engine.routes }
7
- let(:admin_user) { FactoryBot.create(:admin) }
8
- let(:pre_ingest_work) { FactoryBot.create(:pre_ingest_work) }
9
- let(:pre_ingest_file) { FactoryBot.create(:pre_ingest_file, pre_ingest_work_id: pre_ingest_work.id) }
10
- let(:pre_ingest_file_without_file) { FactoryBot.create(:pre_ingest_file, pre_ingest_work_id: pre_ingest_work.id, filename: File.open([Zizia::Engine.root, '/', 'spec/fixtures/dog.jpg'].join)) }
11
- let(:work) { Work.new(title: ['a title'], deduplication_key: pre_ingest_work.deduplication_key) }
12
- let(:file_set) do
13
- FactoryBot.create(:file_set,
14
- title: ['zizia.png'],
15
- content: File.open([Zizia::Engine.root, '/', 'spec/fixtures/zizia.png'].join))
16
- end
17
- let(:basename) { 'zizia.png' }
18
- before do
19
- work.ordered_members << file_set
20
- work.save
21
- end
22
-
23
- describe 'GET thumbnails' do
24
- context 'as a logged in user' do
25
- it 'returns 200' do
26
- allow(controller).to receive(:current_user).and_return(admin_user)
27
- get :thumbnails, params: { deduplication_key: pre_ingest_work.deduplication_key, format: :json }
28
- expect(response.status).to eq(200)
29
- end
30
-
31
- it 'returns an array of thumbail paths' do
32
- file_set.save
33
- allow(controller).to receive(:current_user).and_return(admin_user)
34
- get :thumbnails, params: { deduplication_key: pre_ingest_work.deduplication_key, format: :json }
35
- parsed_json = JSON.parse(response.body)
36
- expect(parsed_json['thumbnails']).to be_an(Array)
37
- expect(parsed_json['thumbnails'].empty?).to eq(false)
38
- end
39
-
40
- it 'returns an empty array if there aren\'t any thumbnails' do
41
- allow(controller).to receive(:current_user).and_return(admin_user)
42
- get :thumbnails, params: { deduplication_key: 'abc/1234', format: :json }
43
- parsed_json = JSON.parse(response.body)
44
- expect(parsed_json['thumbnails']).to be_an(Array)
45
- expect(parsed_json['thumbnails'].empty?).to eq(true)
46
- end
47
- end
48
-
49
- context 'as someone not logged in' do
50
- it 'returns 401' do
51
- get :thumbnails, params: { deduplication_key: pre_ingest_work.deduplication_key, format: :json }
52
- expect(response.status).to eq(401)
53
- end
54
- end
55
- end
56
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
- FactoryBot.define do
3
- factory :file_set do
4
- transient do
5
- user { build(:user) }
6
- title { nil }
7
- content { nil }
8
- end
9
- after(:build) do |fs, evaluator|
10
- fs.apply_depositor_metadata evaluator.user.user_key
11
- fs.title = evaluator.title
12
- end
13
-
14
- after(:create) do |file, evaluator|
15
- Hydra::Works::UploadFileToFileSet.call(file, evaluator.content) if evaluator.content
16
- end
17
-
18
- trait :public do
19
- read_groups { ["public"] }
20
- end
21
-
22
- trait :registered do
23
- read_groups { ["registered"] }
24
- end
25
-
26
- factory :file_with_work do
27
- after(:build) do |file, _evaluator|
28
- file.title = ['testfile']
29
- end
30
- after(:create) do |file, evaluator|
31
- Hydra::Works::UploadFileToFileSet.call(file, evaluator.content) if evaluator.content
32
- create(:work, user: evaluator.user).members << file
33
- end
34
- end
35
- end
36
- end