Skip to content

Commit

Permalink
Merge branch 'main' into refactor_slowest_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkadel committed Sep 21, 2021
2 parents b8e3e98 + 0f04509 commit 46b9162
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 10 deletions.
5 changes: 1 addition & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ RSpec/DescribeClass:
- 'spec/*_spec.rb'

RSpec/ExampleLength:
Exclude:
- 'spec/zizia/hyrax/hyrax_basic_metadata_mapper_spec.rb'
- 'spec/integration/import_hyrax_csv.rb'
- 'spec/integration/csv_import_detail_spec.rb'
Enabled: false

RSpec/MessageSpies:
Exclude:
Expand Down
12 changes: 11 additions & 1 deletion app/models/zizia/pre_ingest_work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ def title
'This work\'s metadata has not been indexed yet.'
end

def collection
@collection ||= Collection.find(collection_id) if collection_id
end

def collection_title
Collection.find(collection_id).title.first if collection_id
collection.title.first if collection_id
rescue Ldp::Gone
"The associated collection has been deleted."
end

def collection_identifier
collection.identifier.first if collection_id
rescue Ldp::Gone
"deleted"
end
end
end
2 changes: 1 addition & 1 deletion app/uploaders/zizia/csv_manifest_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def valid_headers
end

def parse_csv
@rows = CSV.read(csv_file.path)
@rows = CSV.read(csv_file.path).reject { |x| x.empty? || x.all?(nil) }
@headers = @rows.first || []
@transformed_headers = @headers.map { |header| header.downcase.strip }
rescue
Expand Down
4 changes: 2 additions & 2 deletions app/views/zizia/csv_import_details/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<table id="works-table" class="table works-list">
<tr>
<th>Collection ID</th>
<th>Collection Identifier</th>
<th>Collection Title</th>
<th>Deduplication Key</th>
<th>Title</th>
Expand All @@ -21,7 +21,7 @@
<% @pre_ingest_works.each do |pre_ingest_work| %>
<tr>
<td>
<%= pre_ingest_work&.collection_id %>
<%= pre_ingest_work&.collection_identifier %>
</td>
<td>
<%= pre_ingest_work.collection_title %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
object type,Title,Resource Type,Creator,Contributor,Description,Keyword,License,Rights Statement,Publisher,Date Created,Subject,Language,Identifier,Based Near,Related Url,Bibliographic Citation,Source,Visibility,files,deduplication_key
w,"Canoeing on Lake Harriet, Minneapolis with color bars",Image,Minneapolis Selling Company,"Bussey, Mark H.","Postcard depicting Lake Harriet in Minneapolis, MN with color bars",postcard|~|Minneapolis|~|Lake Harriet,http://creativecommons.org/publicdomain/mark/1.0/,http://rightsstatements.org/vocab/NoC-OKLR/1.0/,Minneapolis Selling Company,1900-1945,Postcards,English,PC-001,,,,,open,MN-02.png,PC-001

,,,,,,,,,,,,,,,,,,,,
w,"Canoeing on Lake Harriet, Minneapolis",Image,Minneapolis Selling Company,"Bussey, Mark H.","Postcard depicting Lake Harriet in Minnneapolis, MN",postcard|~|Minneapolis|~|Lake Harriet,http://creativecommons.org/publicdomain/mark/1.0/,http://rightsstatements.org/vocab/NoC-OKLR/1.0/,Minneapolis Selling Company,1900-1945,Postcards,English,PC-002,,,,,open,MN-02 1.png|~|MN-02 2.png,PC-002
w,"Lake Harriet, Minneapolis, Minn",Image,Bloom Bros Co.,"Bussey, Mark H.",Postcard depicting Lake Harriet,postcard|~|Minneapolis|~|Lake Harriet,http://creativecommons.org/publicdomain/mark/1.0/,http://rightsstatements.org/vocab/NoC-OKLR/1.0/,Bloom Bros Co.,1900-1945,Postcards,English,PC-003,,,,,open,MN-02 3.png|~|MN-02 4.png,PC-003
w,"Art Museum, Minneapolis, Minn",Image,Bloom Bros Co.,"Bussey, Mark H.",Postcard depicting The Minneapolis Institute of Arts,postcard|~|Minneapolis|~|Art Museum,http://creativecommons.org/publicdomain/mark/1.0/,http://rightsstatements.org/vocab/NoC-OKLR/1.0/,Bloom Bros Co.,1900-1945,Postcards,English,PC-004,,,,,open,MN-02 5.png|~|MN-02 6.png,PC-004

w,"The Milling District by Moonlight over the Ice-bound Mississippi, Minneapolis, Minn",Image,VO Mammon Publishing,"Bussey, Mark H.",Postcard depicting the Milling District of Minneapolis at night,postcard|~|Minneapolis|~|Milling District,http://creativecommons.org/publicdomain/mark/1.0/,http://rightsstatements.org/vocab/NoC-OKLR/1.0/,VO Mamon Publishing,1900-1945,Postcards,English,PC-005,,,,,open,MN-02 7.png|~|MN-02 8.png,PC-005
w,"Business District, Minneapolis, MN",Image,The Rotograph Co. N.Y City,"Bussey, Mark H.",Postcard depicting the Business District of Minneapolis,postcard|~|Minneapolis|~|Business District,http://creativecommons.org/publicdomain/mark/1.0/,http://rightsstatements.org/vocab/NoC-OKLR/1.0/,The Rotograph Co. N.Y City,1900-1945,Postcards,English,PC-006,,,,,open,MN-02 9.png|~|MN-02 10.png,PC-006
w,Minnehaha Falls,Image,Unknown,"Bussey, Mark H.",Postcard depicting Minnehaha Falls in Minneapolis,postcard|~|Minneapolis|~|Minnehaha Falls,http://creativecommons.org/publicdomain/mark/1.0/,http://rightsstatements.org/vocab/NoC-OKLR/1.0/,,1900-1945,Postcards,English,PC-007,,,,,open,MN-02 11.png|~|MN-02 12.png,PC-007
Expand All @@ -11,4 +14,4 @@ w,"Twin City R. T Co. Power House and Dam, Mississippi River",Image,Curt Teich &
w,"Hennepin Ave from 8th St., Minneapolis",Image,"Grogan Photo System, Inc","Bussey, Mark H.",Postcard depicting Hennepin Ave. in Minneapolis,postcard|~|Minneapolis|~|Hennepin Ave,http://creativecommons.org/publicdomain/mark/1.0/,http://rightsstatements.org/vocab/NoC-OKLR/1.0/,"Grogan Photo System, Inc",1900-1945,Postcards,English,PC-010,,,,,open,MN-02 17.png|~|MN-02 18.png,PC-010
w,"Bird's Eye View of Minneapolis, Minn., By Night",Image,Bloom Bros Co.,"Bussey, Mark H.",Postcard depicting Minneapolis from a bird's eye view,postcard|~|Minneapolis|~|downtown,http://creativecommons.org/publicdomain/mark/1.0/,http://rightsstatements.org/vocab/NoC-OKLR/1.0/,Bloom Bros Co.,1900-1945,Postcards,English,PC-011,,,,,open,MN-02 19.png|~|MN-02 20.png,PC-011
w,"Third Ave. Bridge, Minneapolis",Image,"Grogan Photo System, Inc","Bussey, Mark H.",Postcard depicting Third Ave. Bridge in Minneapolis,postcard|~|Minneapolis|~|Third Avenue|~|bridge,http://creativecommons.org/publicdomain/mark/1.0/,http://rightsstatements.org/vocab/NoC-OKLR/1.0/,"Grogan Photo System, Inc",1900-1945,Postcards,English,PC-012,,,,,open,MN-02 21.png|~|MN-02 22.png,PC-012
c,Minneapolis postcards,,,,,,,,,,,,,,,,,,,
c,Minneapolis postcards,,,,,,,,,,,,,,,,,,,
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
identifier,license,deduplication_key,visibility,location,keyword,rights statement,creator,title,files

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

,,,,,,,,,
abc/456,https://creativecommons.org/licenses/by/4.0/,abc/456,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 patisserie designed by Julius Ralph Davidson, Los Angeles, circa 1929",cat.jpg
3 changes: 2 additions & 1 deletion spec/dummy/spec/system/import_from_csv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@
visit "csv_import_details/show/#{Zizia::CsvImportDetail.last.id}"
within('#works-table') do
expect(page).to have_content('Files')
expect(page).to have_content('Collection Title')
expect(page).to have_content('Collection of Zuccini')
expect(page).to have_content('Collection Identifier')
expect(page).to have_content('def/123')
end
end
end
Expand Down
13 changes: 13 additions & 0 deletions spec/models/zizia/pre_ingest_work_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,21 @@
it 'has collection_ids' do
expect(work.member_of_collection_ids).to eq [collection.id]
expect(pre_ingest_work.collection_id).to eq collection.id
expect(pre_ingest_work.collection_identifier).to eq collection.identifier.first
expect(pre_ingest_work.collection_title).to eq 'Testing Collection'
end

it 'only looks up the collection once to return both title and identifier' do
notifier = class_double("Collection")
.as_stubbed_const(transfer_nested_constants: true)
# rubocop: disable RSpec/MessageSpies
expect(notifier).to receive(:find).with(collection.id).and_return(collection)
pre_ingest_work.collection_id
pre_ingest_work.collection_identifier
pre_ingest_work.collection_title
# rubocop: enable RSpec/MessageSpies
end

it 'can return that metadata has not been indexed yet' do
expect(pre_ingest_work.title).to eq('This work\'s metadata has not been indexed yet.')
end
Expand All @@ -38,6 +50,7 @@
it 'returns that the collection has been deleted' do
expect(Collection.count).to eq 0
expect(pre_ingest_work.collection_title).to eq("The associated collection has been deleted.")
expect(pre_ingest_work.collection_identifier).to eq('deleted')
end
end
end
1 change: 1 addition & 0 deletions spec/zizia/csv_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
title,description,date created
The Moomins and the Great Flood,"The Moomins and the Great Flood (Swedish: Småtrollen och den stora översvämningen, literally The Little Trolls and the Great Flood) is a book written by Finnish author Tove Jansson in 1945, during the end of World War II. It was the first book to star the Moomins, but is often seen as a prelude to the main Moomin books, as most of the main characters are introduced in the next book.",1945
,,
Comet in Moominland,"Comet in Moominland is the second in Tove Jansson's series of Moomin books. Published in 1946, it marks the first appearance of several main characters, like Snufkin and the Snork Maiden.",1946
EOS
end
Expand Down

0 comments on commit 46b9162

Please sign in to comment.