sufia 6.2.0 → 6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +146 -0
- data/.travis.yml +4 -7
- data/Gemfile +2 -0
- data/History.md +29 -1
- data/README.md +25 -9
- data/SUFIA_VERSION +1 -1
- data/app/assets/stylesheets/sufia/_collections.scss +15 -0
- data/app/assets/stylesheets/sufia/_file-listing.scss +7 -0
- data/app/assets/stylesheets/sufia/_home-page.scss +10 -0
- data/app/builders/sufia/bootstrap_breadcrumbs_builder.rb +3 -5
- data/app/controllers/admin/stats_controller.rb +1 -76
- data/app/controllers/api/items_controller.rb +4 -6
- data/app/controllers/api/zotero_controller.rb +5 -5
- data/app/controllers/authorities_controller.rb +5 -1
- data/app/controllers/batch_edits_controller.rb +3 -3
- data/app/controllers/concerns/sufia/admin/depositor_stats.rb +41 -0
- data/app/controllers/concerns/sufia/admin/stats_behavior.rb +94 -0
- data/app/controllers/concerns/sufia/batch_controller_behavior.rb +16 -18
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +54 -56
- data/app/controllers/concerns/sufia/breadcrumbs.rb +3 -6
- data/app/controllers/concerns/sufia/collections_controller_behavior.rb +39 -39
- data/app/controllers/concerns/sufia/controller.rb +10 -10
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +17 -18
- data/app/controllers/concerns/sufia/depositors_controller_behavior.rb +9 -12
- data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +6 -7
- data/app/controllers/concerns/sufia/files_controller/local_ingest_behavior.rb +39 -40
- data/app/controllers/concerns/sufia/files_controller/upload_complete_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +109 -110
- data/app/controllers/concerns/sufia/homepage_controller.rb +8 -8
- data/app/controllers/concerns/sufia/my_controller_behavior.rb +13 -10
- data/app/controllers/concerns/sufia/single_use_links_controller_behavior.rb +11 -14
- data/app/controllers/concerns/sufia/single_use_links_viewer_controller_behavior.rb +27 -21
- data/app/controllers/concerns/sufia/transfers_controller_behavior.rb +17 -17
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +54 -54
- data/app/controllers/contact_form_controller.rb +1 -1
- data/app/controllers/content_blocks_controller.rb +11 -12
- data/app/controllers/directory_controller.rb +2 -3
- data/app/controllers/featured_work_lists_controller.rb +1 -1
- data/app/controllers/featured_works_controller.rb +2 -4
- data/app/controllers/homepage_controller.rb +1 -2
- data/app/controllers/mailbox_controller.rb +12 -32
- data/app/controllers/my/collections_controller.rb +3 -4
- data/app/controllers/my/files_controller.rb +4 -6
- data/app/controllers/my/highlights_controller.rb +4 -6
- data/app/controllers/my/shares_controller.rb +3 -5
- data/app/controllers/pages_controller.rb +1 -3
- data/app/controllers/single_use_links_controller.rb +0 -1
- data/app/controllers/single_use_links_viewer_controller.rb +0 -1
- data/app/controllers/static_controller.rb +1 -0
- data/app/forms/sufia/forms/collection_edit_form.rb +2 -2
- data/app/helpers/batch_edits_helper.rb +1 -3
- data/app/helpers/content_block_helper.rb +7 -8
- data/app/helpers/generic_file_helper.rb +23 -24
- data/app/helpers/sufia/blacklight_override.rb +6 -7
- data/app/helpers/sufia/dashboard_helper_behavior.rb +4 -7
- data/app/helpers/sufia/permissions_helper.rb +3 -4
- data/app/helpers/sufia/sufia_helper_behavior.rb +30 -29
- data/app/helpers/trophy_helper.rb +15 -15
- data/app/inputs/select_with_modal_help_input.rb +3 -3
- data/app/inputs/with_help_icon.rb +4 -4
- data/app/jobs/content_delete_event_job.rb +0 -1
- data/app/jobs/content_depositor_change_event_job.rb +1 -2
- data/app/jobs/event_job.rb +0 -1
- data/app/jobs/user_unfollow_event_job.rb +1 -0
- data/app/models/concerns/sufia/solr_document_behavior.rb +1 -2
- data/app/models/contact_form.rb +6 -6
- data/app/models/content_block.rb +1 -2
- data/app/models/featured_work_list.rb +3 -5
- data/app/models/user_mailbox.rb +44 -0
- data/app/presenters/sufia/collection_presenter.rb +6 -8
- data/app/presenters/sufia/generic_file_presenter.rb +2 -2
- data/app/presenters/sufia/presenter_renderer.rb +2 -2
- data/app/presenters/sufia/version_list_presenter.rb +1 -1
- data/app/presenters/sufia/version_presenter.rb +3 -6
- data/app/search_builders/deposit_search_builder.rb +19 -0
- data/app/search_builders/sufia/my_search_builder_behavior.rb +1 -2
- data/app/search_builders/sufia/search_builder.rb +1 -3
- data/app/uploaders/tinymce_asset_uploader.rb +0 -2
- data/app/views/_controls.html.erb +5 -5
- data/app/views/admin/stats/_deposits.html.erb +19 -0
- data/app/views/admin/stats/index.html.erb +2 -0
- data/app/views/batch_edits/edit.html.erb +2 -2
- data/app/views/collections/_edit_actions.html.erb +3 -3
- data/app/views/collections/_form_for_select_collection.html.erb +2 -2
- data/app/views/collections/_sort_and_per_page.html.erb +12 -9
- data/app/views/collections/_view_type_group.html.erb +1 -1
- data/app/views/collections/edit.html.erb +5 -5
- data/app/views/collections/show.html.erb +7 -6
- data/app/views/homepage/_announcement.html.erb +5 -0
- data/app/views/homepage/_home.html.erb +1 -0
- data/app/views/my/_sort_and_per_page.html.erb +14 -10
- data/app/views/my/index.html.erb +1 -1
- data/app/views/pages/show.html.erb +0 -2
- data/app/views/single_use_links/new_download.html.erb +1 -1
- data/app/views/single_use_links_viewer/show.html.erb +1 -1
- data/app/views/users/_notify_link.html.erb +1 -1
- data/app/views/users/_notify_number.html.erb +2 -2
- data/config/initializers/simple_form.rb +1 -1
- data/config/initializers/simple_form_bootstrap.rb +1 -1
- data/config/locales/sufia.en.yml +4 -0
- data/config/routes.rb +2 -3
- data/lib/generators/sufia/admin_stat_generator.rb +0 -3
- data/lib/generators/sufia/install_generator.rb +8 -9
- data/lib/generators/sufia/templates/catalog_controller.rb +2 -3
- data/lib/generators/sufia/templates/config/action_dispatch_http_upload_monkey_patch.rb +1 -0
- data/lib/generators/sufia/upgrade400_generator.rb +9 -9
- data/lib/generators/sufia/upgrade600_generator.rb +1 -4
- data/lib/sufia.rb +2 -2
- data/lib/sufia/arkivo/actor.rb +1 -1
- data/lib/sufia/arkivo/create_subscription_job.rb +30 -30
- data/lib/sufia/arkivo/metadata_munger.rb +7 -7
- data/lib/sufia/arkivo/schema_validator.rb +1 -1
- data/lib/sufia/single_use_error.rb +0 -1
- data/lib/sufia/version.rb +1 -1
- data/lib/sufia/zotero/config.rb +13 -13
- data/spec/actors/generic_file/actor_spec.rb +17 -18
- data/spec/controllers/admin_stats_controller_spec.rb +56 -5
- data/spec/controllers/api/zotero_controller_spec.rb +10 -9
- data/spec/controllers/authorities_controller_spec.rb +8 -8
- data/spec/controllers/batch_controller_spec.rb +19 -20
- data/spec/controllers/batch_edits_controller_spec.rb +8 -9
- data/spec/controllers/catalog_controller_spec.rb +7 -9
- data/spec/controllers/collections_controller_spec.rb +30 -32
- data/spec/controllers/content_blocks_controller_spec.rb +4 -4
- data/spec/controllers/dashboard_controller_spec.rb +12 -12
- data/spec/controllers/depositors_controller_spec.rb +8 -8
- data/spec/controllers/downloads_controller_spec.rb +10 -11
- data/spec/controllers/featured_work_lists_controller_spec.rb +4 -4
- data/spec/controllers/featured_works_controller_spec.rb +11 -12
- data/spec/controllers/generic_files_controller_spec.rb +154 -125
- data/spec/controllers/homepage_controller_spec.rb +22 -15
- data/spec/controllers/mailbox_controller_spec.rb +20 -36
- data/spec/controllers/my/collections_controller_spec.rb +4 -5
- data/spec/controllers/my/files_controller_spec.rb +10 -11
- data/spec/controllers/my/highlights_controller_spec.rb +4 -5
- data/spec/controllers/my/shares_controller_spec.rb +12 -14
- data/spec/controllers/my_controller_spec.rb +1 -3
- data/spec/controllers/pages_controller_spec.rb +4 -4
- data/spec/controllers/single_use_links_controller_spec.rb +1 -3
- data/spec/controllers/single_use_links_viewer_controller_spec.rb +1 -2
- data/spec/controllers/static_controller_spec.rb +1 -1
- data/spec/controllers/tinymce_assets_controller_spec.rb +8 -9
- data/spec/controllers/transfers_controller_spec.rb +19 -19
- data/spec/controllers/users_controller_spec.rb +33 -35
- data/spec/factories/api_items.rb +2 -2
- data/spec/factories/content_blocks.rb +1 -1
- data/spec/factories/featured_works.rb +1 -1
- data/spec/factories/generic_files.rb +3 -3
- data/spec/factories/users.rb +7 -8
- data/spec/features/browse_dashboard_files_spec.rb +14 -18
- data/spec/features/browse_files_spec.rb +3 -4
- data/spec/features/catalog_search_spec.rb +3 -5
- data/spec/features/cloud_upload_spec.rb +2 -2
- data/spec/features/collection_spec.rb +21 -21
- data/spec/features/contact_form_spec.rb +10 -11
- data/spec/features/display_dashboard_spec.rb +5 -9
- data/spec/features/edit_file_spec.rb +8 -9
- data/spec/features/featured_item_spec.rb +1 -1
- data/spec/features/ingest_upload_files_spec.rb +5 -5
- data/spec/features/notifications_spec.rb +2 -6
- data/spec/features/ownership_transfer_spec.rb +2 -2
- data/spec/features/proxy_spec.rb +2 -2
- data/spec/features/search_spec.rb +3 -4
- data/spec/features/single_use_links_spec.rb +1 -1
- data/spec/features/users_spec.rb +4 -5
- data/spec/forms/collection_edit_form_spec.rb +2 -2
- data/spec/forms/generic_file_edit_form_spec.rb +6 -7
- data/spec/helpers/batch_edits_helper_spec.rb +9 -13
- data/spec/helpers/content_block_helper_spec.rb +3 -3
- data/spec/helpers/dashboard_helper_spec.rb +19 -24
- data/spec/helpers/generic_file_helper_spec.rb +5 -7
- data/spec/helpers/sufia_helper_spec.rb +43 -54
- data/spec/helpers/trophy_helper_spec.rb +5 -5
- data/spec/inputs/multi_value_with_help_input_spec.rb +1 -2
- data/spec/inputs/select_with_help_input_spec.rb +19 -15
- data/spec/javascripts/jasmine_spec.rb +4 -5
- data/spec/javascripts/support/jasmine_helper.rb +9 -9
- data/spec/jobs/active_fedora_id_based_job_spec.rb +7 -5
- data/spec/jobs/audit_job_spec.rb +7 -7
- data/spec/jobs/batch_update_job_spec.rb +5 -6
- data/spec/jobs/characterize_job_spec.rb +1 -1
- data/spec/jobs/content_depositor_change_event_job_spec.rb +1 -1
- data/spec/jobs/create_derivatives_job_spec.rb +5 -5
- data/spec/jobs/event_jobs_spec.rb +16 -16
- data/spec/jobs/import_url_job_spec.rb +36 -5
- data/spec/jobs/ingest_local_file_job_spec.rb +31 -20
- data/spec/jobs/sufia_resque_queue_spec.rb +1 -1
- data/spec/lib/sufia/analytics_spec.rb +0 -1
- data/spec/lib/sufia/arkivo/actor_spec.rb +6 -6
- data/spec/lib/sufia/arkivo/schema_validator_spec.rb +18 -18
- data/spec/lib/sufia/breadcrumbs_spec.rb +5 -6
- data/spec/lib/sufia/messages_spec.rb +11 -12
- data/spec/lib/sufia/readable_permissions_spec.rb +8 -10
- data/spec/lib/sufia/upload_complete_behavior_spec.rb +6 -7
- data/spec/lib/sufia/user_stat_importer_spec.rb +30 -33
- data/spec/lib/sufia/writable_permissions_spec.rb +1 -3
- data/spec/lib/sufia/zotero/config_spec.rb +4 -6
- data/spec/models/ability_spec.rb +11 -9
- data/spec/models/batch_spec.rb +13 -13
- data/spec/models/characterization_spec.rb +2 -3
- data/spec/models/checksum_audit_log_spec.rb +18 -19
- data/spec/models/collection_spec.rb +11 -12
- data/spec/models/content_block_spec.rb +33 -22
- data/spec/models/download_spec.rb +3 -5
- data/spec/models/featured_work_list_spec.rb +3 -3
- data/spec/models/featured_work_spec.rb +12 -14
- data/spec/models/file_content_datastream_spec.rb +9 -7
- data/spec/models/file_download_stat_spec.rb +34 -40
- data/spec/models/file_usage_spec.rb +46 -52
- data/spec/models/file_view_stat_spec.rb +35 -41
- data/spec/models/fits_datastream_spec.rb +23 -25
- data/spec/models/generic_file/visibility_spec.rb +10 -5
- data/spec/models/generic_file_spec.rb +86 -88
- data/spec/models/geo_names_resource_spec.rb +3 -5
- data/spec/models/local_authority_spec.rb +30 -33
- data/spec/models/pageview_spec.rb +3 -3
- data/spec/models/proxy_deposit_request_spec.rb +3 -3
- data/spec/models/single_use_link_spec.rb +36 -36
- data/spec/models/solr_document_spec.rb +3 -6
- data/spec/models/trophy_spec.rb +8 -9
- data/spec/models/user_mailbox_spec.rb +62 -0
- data/spec/models/user_spec.rb +28 -29
- data/spec/presenters/presenter_renderer_spec.rb +1 -1
- data/spec/presenters/sufia/generic_file_presenter_spec.rb +5 -5
- data/spec/presenters/sufia/version_list_presenter_spec.rb +2 -2
- data/spec/presenters/sufia/version_presenter_spec.rb +1 -1
- data/spec/routing/featured_works_route_spec.rb +4 -4
- data/spec/routing/ownership_transfers_route_spec.rb +1 -1
- data/spec/routing/route_spec.rb +89 -89
- data/spec/services/generic_file_audit_service_spec.rb +8 -8
- data/spec/services/repository_audit_service_spec.rb +7 -3
- data/spec/spec_helper.rb +5 -4
- data/spec/support/features/session_helpers.rb +1 -1
- data/spec/support/input_support.rb +1 -2
- data/spec/support/rake.rb +1 -1
- data/spec/support/selectors.rb +1 -6
- data/spec/support/statistic_helper.rb +1 -1
- data/spec/support/uploaded_file_monkeypatch.rb +1 -1
- data/spec/tasks/rake_spec.rb +3 -5
- data/spec/views/admin/stats/index.html.erb_spec.rb +16 -16
- data/spec/views/batch/edit.html.erb_spec.rb +1 -3
- data/spec/views/batch_edits/check_all_spec.rb +5 -5
- data/spec/views/batch_edits/edit.html.erb_spec.rb +1 -3
- data/spec/views/catalog/index.html.erb_spec.rb +1 -3
- data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +4 -5
- data/spec/views/collections/_form.html.erb_spec.rb +5 -3
- data/spec/views/collections/_show_descriptions.html.erb_spec.rb +7 -8
- data/spec/views/collections/_show_document_list.erb_spec.rb +4 -6
- data/spec/views/dashboard/index_spec.rb +14 -21
- data/spec/views/generic_file/_browse_everything.html.erb_spec.rb +2 -2
- data/spec/views/generic_file/_permission_form.html.erb_spec.rb +8 -9
- data/spec/views/generic_file/edit.html.erb_spec.rb +7 -7
- data/spec/views/generic_file/show.html.erb_spec.rb +24 -25
- data/spec/views/generic_file/stats.html.erb_spec.rb +19 -19
- data/spec/views/homepage/_announcement.html.erb_spec.rb +51 -0
- data/spec/views/homepage/_featured_works.html.erb_spec.rb +5 -9
- data/spec/views/homepage/_home_header.html.erb_spec.rb +2 -2
- data/spec/views/my/facet.html.erb_spec.rb +4 -4
- data/spec/views/single_use_links/new_download.html.erb_spec.rb +28 -0
- data/spec/views/single_use_links_viewer/show.html.erb_spec.rb +29 -0
- data/spec/views/users/_follower_modal.html.erb_spec.rb +7 -8
- data/spec/views/users/_following_modal.html.erb_spec.rb +4 -5
- data/spec/views/users/_notify_number.html.erb_spec.rb +2 -5
- data/spec/views/users/_user_util_links.html.erb_spec.rb +5 -8
- data/spec/views/users/index.html.erb_spec.rb +4 -6
- data/spec/views/users/show.html.erb_spec.rb +4 -7
- data/tasks/sufia-dev.rake +19 -3
- metadata +20 -5
@@ -1,41 +1,52 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe ContentBlock, :
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
describe ContentBlock, type: :model do
|
4
|
+
let(:bilbo) do
|
5
|
+
described_class.create!(
|
6
|
+
name: ContentBlock::RESEARCHER,
|
7
|
+
value: '<h1>Bilbo Baggins</h1>',
|
8
|
+
created_at: Time.now)
|
9
|
+
end
|
10
10
|
|
11
|
-
let(:frodo)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
let(:frodo) do
|
12
|
+
described_class.create!(
|
13
|
+
name: ContentBlock::RESEARCHER,
|
14
|
+
value: '<h1>Frodo Baggins</h1>',
|
15
|
+
created_at: 2.hours.ago)
|
16
|
+
end
|
16
17
|
|
17
|
-
let(:marketing)
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
let(:marketing) do
|
19
|
+
described_class.create!(
|
20
|
+
name: ContentBlock::MARKETING,
|
21
|
+
value: '<h1>Marketing Text</h1>')
|
22
|
+
end
|
21
23
|
|
22
24
|
describe '.recent_researchers' do
|
23
|
-
before
|
24
|
-
|
25
|
+
before do
|
26
|
+
frodo
|
27
|
+
bilbo
|
28
|
+
marketing
|
29
|
+
end
|
30
|
+
|
31
|
+
subject { described_class.recent_researchers }
|
25
32
|
|
26
33
|
it 'returns featured_researcher entries in chronological order' do
|
27
|
-
expect(
|
34
|
+
expect(described_class.count).to eq 3
|
28
35
|
expect(subject).to eq [bilbo, frodo]
|
29
36
|
end
|
30
37
|
end
|
31
38
|
|
32
39
|
describe '.featured_researcher' do
|
33
|
-
before
|
34
|
-
|
40
|
+
before do
|
41
|
+
frodo
|
42
|
+
bilbo
|
43
|
+
marketing
|
44
|
+
end
|
45
|
+
|
46
|
+
subject { described_class.featured_researcher }
|
35
47
|
|
36
48
|
it 'finds the most recent entry for featured_researcher' do
|
37
49
|
expect(subject).to eq bilbo
|
38
50
|
end
|
39
51
|
end
|
40
|
-
|
41
52
|
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Sufia::Download, :
|
4
|
-
|
3
|
+
describe Sufia::Download, type: :model do
|
5
4
|
before do
|
6
|
-
@download =
|
5
|
+
@download = described_class
|
7
6
|
end
|
8
7
|
|
9
8
|
it 'has an events metric' do
|
10
|
-
expect(@download.metrics).to be
|
9
|
+
expect(@download.metrics).to be == Legato::ListParameter.new(:metrics, [:totalEvents])
|
11
10
|
end
|
12
11
|
|
13
12
|
it 'has dimensions' do
|
@@ -17,5 +16,4 @@ describe Sufia::Download, :type => :model do
|
|
17
16
|
it 'responds to :for_file' do
|
18
17
|
expect(@download).to respond_to(:for_file)
|
19
18
|
end
|
20
|
-
|
21
19
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe FeaturedWorkList, :
|
3
|
+
describe FeaturedWorkList, type: :model do
|
4
4
|
let(:file1) { create(:generic_file) }
|
5
5
|
let(:file2) { create(:generic_file) }
|
6
6
|
|
@@ -10,7 +10,7 @@ describe FeaturedWorkList, :type => :model do
|
|
10
10
|
create(:featured_work, generic_file_id: file2.id)
|
11
11
|
end
|
12
12
|
|
13
|
-
it '
|
13
|
+
it 'is a list of the featured work objects, each with the generic_file\'s solr_doc' do
|
14
14
|
expect(subject.featured_works.size).to eq 2
|
15
15
|
solr_doc = subject.featured_works.first.generic_file_solr_document
|
16
16
|
expect(solr_doc).to be_kind_of SolrDocument
|
@@ -25,7 +25,7 @@ describe FeaturedWorkList, :type => :model do
|
|
25
25
|
file1.destroy
|
26
26
|
end
|
27
27
|
|
28
|
-
it '
|
28
|
+
it 'is a list of the remaining featured work objects, each with the generic_file\'s solr_doc' do
|
29
29
|
expect(subject.featured_works.size).to eq 1
|
30
30
|
solr_doc = subject.featured_works.first.generic_file_solr_document
|
31
31
|
expect(solr_doc).to be_kind_of SolrDocument
|
@@ -1,25 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe FeaturedWork, :
|
4
|
-
let(:feature) {
|
3
|
+
describe FeaturedWork, type: :model do
|
4
|
+
let(:feature) { described_class.create(generic_file_id: "99") }
|
5
5
|
|
6
|
-
it "
|
6
|
+
it "has a file" do
|
7
7
|
expect(feature.generic_file_id).to eq "99"
|
8
8
|
end
|
9
9
|
|
10
|
-
it "
|
10
|
+
it "does not allow six features" do
|
11
11
|
5.times do |n|
|
12
|
-
expect(
|
12
|
+
expect(described_class.create(generic_file_id: n.to_s)).to_not be_new_record
|
13
13
|
end
|
14
|
-
|
15
|
-
expect(sixth).to be_new_record
|
14
|
+
described_class.create(generic_file_id: "6").tap do |sixth|
|
15
|
+
expect(sixth).to be_new_record
|
16
16
|
expect(sixth.errors.full_messages).to eq ["Limited to 5 featured works."]
|
17
17
|
end
|
18
|
-
expect(
|
18
|
+
expect(described_class.count).to eq 5
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "can_create_another?" do
|
22
|
-
subject {
|
22
|
+
subject { described_class }
|
23
23
|
context "when none exist" do
|
24
24
|
describe '#can_create_another?' do
|
25
25
|
subject { super().can_create_another? }
|
@@ -29,7 +29,7 @@ describe FeaturedWork, :type => :model do
|
|
29
29
|
context "when five exist" do
|
30
30
|
before do
|
31
31
|
5.times do |n|
|
32
|
-
|
32
|
+
described_class.create(generic_file_id: n.to_s)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -41,13 +41,11 @@ describe FeaturedWork, :type => :model do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
describe "#order" do
|
44
|
-
subject {
|
44
|
+
subject { described_class.new(order: 5) }
|
45
45
|
|
46
46
|
describe '#order' do
|
47
47
|
subject { super().order }
|
48
|
-
it {is_expected.to eq 5 }
|
48
|
+
it { is_expected.to eq 5 }
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
52
|
-
|
53
|
-
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe FileContentDatastream, :
|
3
|
+
describe FileContentDatastream, type: :model do
|
4
4
|
describe "#latest_version" do
|
5
5
|
let(:file) do
|
6
6
|
GenericFile.create do |f|
|
@@ -25,14 +25,16 @@ describe FileContentDatastream, :type => :model do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
describe "extract_metadata" do
|
28
|
-
let(:datastream) {
|
29
|
-
let(:file)
|
30
|
-
|
28
|
+
let(:datastream) { described_class.new('foo/content') }
|
29
|
+
let(:file) do
|
30
|
+
ActionDispatch::Http::UploadedFile.new(tempfile: File.new(fixture_path + '/world.png'),
|
31
|
+
filename: 'world.png')
|
32
|
+
end
|
31
33
|
before { datastream.content = file }
|
32
34
|
let(:document) { Nokogiri::XML.parse(datastream.extract_metadata).root }
|
33
|
-
let(:namespace) { { 'ns'=>'http://hul.harvard.edu/ois/xml/ns/fits/fits_output' } }
|
35
|
+
let(:namespace) { { 'ns' => 'http://hul.harvard.edu/ois/xml/ns/fits/fits_output' } }
|
34
36
|
|
35
|
-
it "
|
37
|
+
it "returns an xml document", unless: $in_travis do
|
36
38
|
expect(document.xpath('//ns:identity/@mimetype', namespace).first.value).to eq 'image/png'
|
37
39
|
end
|
38
40
|
end
|
@@ -43,7 +45,7 @@ describe FileContentDatastream, :type => :model do
|
|
43
45
|
@generic_file.apply_depositor_metadata('mjg36')
|
44
46
|
end
|
45
47
|
|
46
|
-
it "
|
48
|
+
it "onlies return true when the datastream has actually changed" do
|
47
49
|
@generic_file.add_file(File.open(fixture_path + '/world.png', 'rb'), path: 'content', original_name: 'world.png')
|
48
50
|
expect(@generic_file.content).to be_changed
|
49
51
|
@generic_file.save!
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
RSpec.describe FileDownloadStat, :
|
4
|
-
let(:file_id) {"99"}
|
5
|
-
let(:date) {DateTime.new}
|
6
|
-
let(:file_stat) {
|
3
|
+
RSpec.describe FileDownloadStat, type: :model do
|
4
|
+
let(:file_id) { "99" }
|
5
|
+
let(:date) { DateTime.new }
|
6
|
+
let(:file_stat) { described_class.create(downloads: "2", date: date, file_id: file_id) }
|
7
7
|
|
8
8
|
it "has attributes" do
|
9
9
|
expect(file_stat).to respond_to(:downloads)
|
@@ -14,73 +14,67 @@ RSpec.describe FileDownloadStat, :type => :model do
|
|
14
14
|
expect(file_stat.downloads).to eq(2)
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
17
|
describe "#get_float_statistics" do
|
19
|
-
|
20
|
-
let(:dates) {
|
18
|
+
let(:dates) do
|
21
19
|
ldates = []
|
22
|
-
4.downto(0) {|idx| ldates << (Date.today-idx.day) }
|
20
|
+
4.downto(0) { |idx| ldates << (Date.today - idx.day) }
|
23
21
|
ldates
|
24
|
-
|
25
|
-
let(:date_strs)
|
26
|
-
dates.map {|date|
|
27
|
-
|
22
|
+
end
|
23
|
+
let(:date_strs) do
|
24
|
+
dates.map { |date| date.strftime("%Y%m%d") }
|
25
|
+
end
|
28
26
|
|
29
|
-
let(:download_output)
|
27
|
+
let(:download_output) do
|
30
28
|
[[statistic_date(dates[0]), 1], [statistic_date(dates[1]), 1], [statistic_date(dates[2]), 2], [statistic_date(dates[3]), 3]]
|
31
|
-
|
29
|
+
end
|
32
30
|
|
33
31
|
# This is what the data looks like that's returned from Google Analytics (GA) via the Legato gem
|
34
32
|
# Due to the nature of querying GA, testing this data in an automated fashion is problematc.
|
35
33
|
# Sample data structures were created by sending real events to GA from a test instance of
|
36
34
|
# Scholarsphere. The data below are essentially a "cut and paste" from the output of query
|
37
35
|
# results from the Legato gem.
|
38
|
-
let(:sample_download_statistics)
|
36
|
+
let(:sample_download_statistics) do
|
39
37
|
[
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
38
|
+
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: date_strs[0], totalEvents: "1"),
|
39
|
+
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: date_strs[1], totalEvents: "1"),
|
40
|
+
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: date_strs[2], totalEvents: "2"),
|
41
|
+
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: date_strs[3], totalEvents: "3"),
|
42
|
+
# OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: date_strs[4], totalEvents: "5"),
|
45
43
|
]
|
46
|
-
|
44
|
+
end
|
47
45
|
|
48
46
|
describe "cache empty" do
|
49
|
-
let(:stats)
|
50
|
-
expect(
|
51
|
-
|
52
|
-
|
47
|
+
let(:stats) do
|
48
|
+
expect(described_class).to receive(:ga_statistics).and_return(sample_download_statistics)
|
49
|
+
described_class.statistics(file_id, Date.today - 4.day)
|
50
|
+
end
|
53
51
|
|
54
52
|
it "includes cached ga data" do
|
55
|
-
expect(
|
53
|
+
expect(described_class.to_flots stats).to include(*download_output)
|
56
54
|
end
|
57
55
|
|
58
56
|
it "caches data" do
|
59
|
-
expect(
|
57
|
+
expect(described_class.to_flots stats).to include(*download_output)
|
60
58
|
|
61
59
|
# at this point all data should be cached
|
62
|
-
allow(
|
60
|
+
allow(described_class).to receive(:ga_statistics).with(Date.today, file_id).and_raise("We should not call Google Analytics All data should be cached!")
|
63
61
|
|
64
|
-
stats2 =
|
65
|
-
expect(
|
62
|
+
stats2 = described_class.statistics(file_id, Date.today - 4.day)
|
63
|
+
expect(described_class.to_flots stats2).to include(*download_output)
|
66
64
|
end
|
67
|
-
|
68
65
|
end
|
69
66
|
|
70
67
|
describe "cache loaded" do
|
68
|
+
let!(:file_download_stat) { described_class.create(date: (Date.today - 5.day).to_datetime, file_id: file_id, downloads: "25") }
|
71
69
|
|
72
|
-
let
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
FileDownloadStat.statistics(file_id,Date.today-5.day)
|
77
|
-
}
|
70
|
+
let(:stats) do
|
71
|
+
expect(described_class).to receive(:ga_statistics).and_return(sample_download_statistics)
|
72
|
+
described_class.statistics(file_id, Date.today - 5.day)
|
73
|
+
end
|
78
74
|
|
79
75
|
it "includes cached data" do
|
80
|
-
expect(
|
76
|
+
expect(described_class.to_flots stats).to include([file_download_stat.date.to_i * 1000, file_download_stat.downloads], *download_output)
|
81
77
|
end
|
82
|
-
|
83
78
|
end
|
84
79
|
end
|
85
|
-
|
86
80
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe FileUsage, :
|
4
|
-
|
3
|
+
describe FileUsage, type: :model do
|
5
4
|
let(:file) do
|
6
5
|
GenericFile.new.tap do |file|
|
7
6
|
file.apply_depositor_metadata("awead")
|
@@ -9,24 +8,25 @@ describe FileUsage, :type => :model do
|
|
9
8
|
end
|
10
9
|
end
|
11
10
|
|
12
|
-
let(:dates)
|
11
|
+
let(:dates) do
|
13
12
|
ldates = []
|
14
|
-
4.downto(0) {|idx| ldates << (Date.today-idx.day) }
|
13
|
+
4.downto(0) { |idx| ldates << (Date.today - idx.day) }
|
15
14
|
ldates
|
16
|
-
|
17
|
-
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:date_strs) do
|
18
18
|
ldate_strs = []
|
19
|
-
dates.each {|date| ldate_strs << date.strftime("%Y%m%d") }
|
19
|
+
dates.each { |date| ldate_strs << date.strftime("%Y%m%d") }
|
20
20
|
ldate_strs
|
21
|
-
|
21
|
+
end
|
22
22
|
|
23
|
-
let(:view_output)
|
23
|
+
let(:view_output) do
|
24
24
|
[[statistic_date(dates[0]), 4], [statistic_date(dates[1]), 8], [statistic_date(dates[2]), 6], [statistic_date(dates[3]), 10], [statistic_date(dates[4]), 2]]
|
25
|
-
|
25
|
+
end
|
26
26
|
|
27
|
-
let(:download_output)
|
28
|
-
[[statistic_date(dates[0]), 1], [statistic_date(dates[1]), 1], [statistic_date(dates[2]), 2], [statistic_date(dates[3]), 3],
|
29
|
-
|
27
|
+
let(:download_output) do
|
28
|
+
[[statistic_date(dates[0]), 1], [statistic_date(dates[1]), 1], [statistic_date(dates[2]), 2], [statistic_date(dates[3]), 3], [statistic_date(dates[4]), 5]]
|
29
|
+
end
|
30
30
|
|
31
31
|
# This is what the data looks like that's returned from Google Analytics (GA) via the Legato gem
|
32
32
|
# Due to the nature of querying GA, testing this data in an automated fashion is problematc.
|
@@ -34,17 +34,17 @@ describe FileUsage, :type => :model do
|
|
34
34
|
# Scholarsphere. The data below are essentially a "cut and paste" from the output of query
|
35
35
|
# results from the Legato gem.
|
36
36
|
|
37
|
-
let(:sample_download_statistics)
|
37
|
+
let(:sample_download_statistics) do
|
38
38
|
[
|
39
39
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: date_strs[0], totalEvents: "1"),
|
40
40
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: date_strs[1], totalEvents: "1"),
|
41
41
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: date_strs[2], totalEvents: "2"),
|
42
42
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: date_strs[3], totalEvents: "3"),
|
43
|
-
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: date_strs[4], totalEvents: "5")
|
43
|
+
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: date_strs[4], totalEvents: "5")
|
44
44
|
]
|
45
|
-
|
45
|
+
end
|
46
46
|
|
47
|
-
let(:sample_pageview_statistics)
|
47
|
+
let(:sample_pageview_statistics) do
|
48
48
|
[
|
49
49
|
OpenStruct.new(date: date_strs[0], pageviews: 4),
|
50
50
|
OpenStruct.new(date: date_strs[1], pageviews: 8),
|
@@ -52,33 +52,30 @@ describe FileUsage, :type => :model do
|
|
52
52
|
OpenStruct.new(date: date_strs[3], pageviews: 10),
|
53
53
|
OpenStruct.new(date: date_strs[4], pageviews: 2)
|
54
54
|
]
|
55
|
-
|
55
|
+
end
|
56
56
|
|
57
|
-
let(:usage)
|
58
|
-
allow_any_instance_of(GenericFile).to receive(:create_date).and_return((Date.today-4.day).to_s)
|
57
|
+
let(:usage) do
|
58
|
+
allow_any_instance_of(GenericFile).to receive(:create_date).and_return((Date.today - 4.day).to_s)
|
59
59
|
expect(FileDownloadStat).to receive(:ga_statistics).and_return(sample_download_statistics)
|
60
60
|
expect(FileViewStat).to receive(:ga_statistics).and_return(sample_pageview_statistics)
|
61
|
-
|
62
|
-
|
61
|
+
described_class.new(file.id)
|
62
|
+
end
|
63
63
|
|
64
64
|
describe "#initialize" do
|
65
|
-
|
66
|
-
it "should set the id" do
|
65
|
+
it "sets the id" do
|
67
66
|
expect(usage.id).to eq(file.id)
|
68
67
|
end
|
69
68
|
|
70
|
-
it "
|
69
|
+
it "sets the path" do
|
71
70
|
expect(usage.path).to eq("/files/#{URI.encode(file.id, '/')}")
|
72
71
|
end
|
73
72
|
|
74
|
-
it "
|
73
|
+
it "sets the created date" do
|
75
74
|
expect(usage.created).to eq(file.create_date)
|
76
75
|
end
|
77
|
-
|
78
76
|
end
|
79
77
|
|
80
78
|
describe "statistics" do
|
81
|
-
|
82
79
|
before(:all) do
|
83
80
|
@system_timezone = ENV['TZ']
|
84
81
|
ENV['TZ'] = 'UTC'
|
@@ -88,15 +85,15 @@ describe FileUsage, :type => :model do
|
|
88
85
|
ENV['TZ'] = @system_timezone
|
89
86
|
end
|
90
87
|
|
91
|
-
it "
|
88
|
+
it "counts the total numver of downloads" do
|
92
89
|
expect(usage.total_downloads).to eq(12)
|
93
90
|
end
|
94
91
|
|
95
|
-
it "
|
92
|
+
it "counts the total numver of pageviews" do
|
96
93
|
expect(usage.total_pageviews).to eq(30)
|
97
94
|
end
|
98
95
|
|
99
|
-
it "
|
96
|
+
it "returns an array of hashes for use with JQuery Flot" do
|
100
97
|
expect(usage.to_flot[0][:label]).to eq("Pageviews")
|
101
98
|
expect(usage.to_flot[1][:label]).to eq("Downloads")
|
102
99
|
expect(usage.to_flot[0][:data]).to include(*view_output)
|
@@ -113,27 +110,26 @@ describe FileUsage, :type => :model do
|
|
113
110
|
end
|
114
111
|
|
115
112
|
describe "create date before earliest date set" do
|
116
|
-
let(:usage)
|
113
|
+
let(:usage) do
|
117
114
|
allow_any_instance_of(GenericFile).to receive(:create_date).and_return(create_date.to_s)
|
118
115
|
expect(FileDownloadStat).to receive(:ga_statistics).and_return(sample_download_statistics)
|
119
116
|
expect(FileViewStat).to receive(:ga_statistics).and_return(sample_pageview_statistics)
|
120
|
-
|
121
|
-
|
122
|
-
it "
|
117
|
+
described_class.new(file.id)
|
118
|
+
end
|
119
|
+
it "sets the created date to the earliest date not the created date" do
|
123
120
|
expect(usage.created).to eq(earliest)
|
124
121
|
end
|
125
|
-
|
126
122
|
end
|
127
123
|
|
128
124
|
describe "create date after earliest" do
|
129
|
-
let(:usage)
|
130
|
-
allow_any_instance_of(GenericFile).to receive(:create_date).and_return((Date.today-4.day).to_s)
|
125
|
+
let(:usage) do
|
126
|
+
allow_any_instance_of(GenericFile).to receive(:create_date).and_return((Date.today - 4.day).to_s)
|
131
127
|
expect(FileDownloadStat).to receive(:ga_statistics).and_return(sample_download_statistics)
|
132
128
|
expect(FileViewStat).to receive(:ga_statistics).and_return(sample_pageview_statistics)
|
133
129
|
Sufia.config.analytic_start_date = earliest
|
134
|
-
|
135
|
-
|
136
|
-
it "
|
130
|
+
described_class.new(file.id)
|
131
|
+
end
|
132
|
+
it "sets the created date to the earliest date not the created date" do
|
137
133
|
expect(usage.created).to eq(file.create_date)
|
138
134
|
end
|
139
135
|
end
|
@@ -143,20 +139,19 @@ describe FileUsage, :type => :model do
|
|
143
139
|
Sufia.config.analytic_start_date = nil
|
144
140
|
end
|
145
141
|
|
146
|
-
let(:usage)
|
142
|
+
let(:usage) do
|
147
143
|
allow_any_instance_of(GenericFile).to receive(:create_date).and_return(create_date.to_s)
|
148
144
|
expect(FileDownloadStat).to receive(:ga_statistics).and_return(sample_download_statistics)
|
149
145
|
expect(FileViewStat).to receive(:ga_statistics).and_return(sample_pageview_statistics)
|
150
|
-
|
151
|
-
|
152
|
-
it "
|
146
|
+
described_class.new(file.id)
|
147
|
+
end
|
148
|
+
it "sets the created date to the earliest date not the created date" do
|
153
149
|
expect(usage.created).to eq(create_date)
|
154
150
|
end
|
155
|
-
|
156
151
|
end
|
157
152
|
end
|
158
153
|
|
159
|
-
describe "on a migrated file" do
|
154
|
+
describe "on a migrated file" do
|
160
155
|
let(:date_uploaded) { "2014-12-31" }
|
161
156
|
|
162
157
|
let(:file_migrated) do
|
@@ -167,15 +162,14 @@ describe FileUsage, :type => :model do
|
|
167
162
|
end
|
168
163
|
end
|
169
164
|
|
170
|
-
let(:usage)
|
165
|
+
let(:usage) do
|
171
166
|
expect(FileDownloadStat).to receive(:ga_statistics).and_return(sample_download_statistics)
|
172
167
|
expect(FileViewStat).to receive(:ga_statistics).and_return(sample_pageview_statistics)
|
173
|
-
|
174
|
-
|
168
|
+
described_class.new(file_migrated.id)
|
169
|
+
end
|
175
170
|
|
176
|
-
it "
|
171
|
+
it "uses the date_uploaded for analytics" do
|
177
172
|
expect(usage.created).to eq(date_uploaded)
|
178
173
|
end
|
179
174
|
end
|
180
|
-
|
181
175
|
end
|