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
@@ -2,7 +2,6 @@ require 'spec_helper'
|
|
2
2
|
require_relative '../../../sufia-models/lib/sufia/models/stats/user_stat_importer'
|
3
3
|
|
4
4
|
describe Sufia::UserStatImporter do
|
5
|
-
|
6
5
|
before do
|
7
6
|
allow(Sufia.config).to receive(:analytic_start_date) { dates[0] }
|
8
7
|
stub_out_call_to_google_analytics
|
@@ -33,20 +32,20 @@ describe Sufia::UserStatImporter do
|
|
33
32
|
end
|
34
33
|
end
|
35
34
|
|
36
|
-
let(:dates)
|
35
|
+
let(:dates) do
|
37
36
|
ldates = []
|
38
|
-
4.downto(0) {|idx| ldates << (Date.today-idx.day) }
|
37
|
+
4.downto(0) { |idx| ldates << (Date.today - idx.day) }
|
39
38
|
ldates
|
40
|
-
|
39
|
+
end
|
41
40
|
|
42
|
-
let(:date_strs)
|
41
|
+
let(:date_strs) do
|
43
42
|
ldate_strs = []
|
44
|
-
dates.each {|date| ldate_strs << date.strftime("%Y%m%d") }
|
43
|
+
dates.each { |date| ldate_strs << date.strftime("%Y%m%d") }
|
45
44
|
ldate_strs
|
46
|
-
|
45
|
+
end
|
47
46
|
|
48
47
|
# This is what the data looks like that's returned from Google Analytics via the Legato gem.
|
49
|
-
let(:bilbo_file_1_pageview_stats)
|
48
|
+
let(:bilbo_file_1_pageview_stats) do
|
50
49
|
[
|
51
50
|
OpenStruct.new(date: date_strs[0], pageviews: 1),
|
52
51
|
OpenStruct.new(date: date_strs[1], pageviews: 2),
|
@@ -54,9 +53,9 @@ describe Sufia::UserStatImporter do
|
|
54
53
|
OpenStruct.new(date: date_strs[3], pageviews: 4),
|
55
54
|
OpenStruct.new(date: date_strs[4], pageviews: 5)
|
56
55
|
]
|
57
|
-
|
56
|
+
end
|
58
57
|
|
59
|
-
let(:bilbo_file_2_pageview_stats)
|
58
|
+
let(:bilbo_file_2_pageview_stats) do
|
60
59
|
[
|
61
60
|
OpenStruct.new(date: date_strs[0], pageviews: 11),
|
62
61
|
OpenStruct.new(date: date_strs[1], pageviews: 12),
|
@@ -64,9 +63,9 @@ describe Sufia::UserStatImporter do
|
|
64
63
|
OpenStruct.new(date: date_strs[3], pageviews: 14),
|
65
64
|
OpenStruct.new(date: date_strs[4], pageviews: 15)
|
66
65
|
]
|
67
|
-
|
66
|
+
end
|
68
67
|
|
69
|
-
let(:frodo_file_1_pageview_stats)
|
68
|
+
let(:frodo_file_1_pageview_stats) do
|
70
69
|
[
|
71
70
|
OpenStruct.new(date: date_strs[0], pageviews: 2),
|
72
71
|
OpenStruct.new(date: date_strs[1], pageviews: 4),
|
@@ -74,42 +73,41 @@ describe Sufia::UserStatImporter do
|
|
74
73
|
OpenStruct.new(date: date_strs[3], pageviews: 1),
|
75
74
|
OpenStruct.new(date: date_strs[4], pageviews: 9)
|
76
75
|
]
|
77
|
-
|
76
|
+
end
|
78
77
|
|
79
|
-
let(:bilbo_file_1_download_stats)
|
78
|
+
let(:bilbo_file_1_download_stats) do
|
80
79
|
[
|
81
80
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "bilbo1", date: date_strs[0], totalEvents: "2"),
|
82
81
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "bilbo1", date: date_strs[1], totalEvents: "3"),
|
83
82
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "bilbo1", date: date_strs[2], totalEvents: "5"),
|
84
83
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "bilbo1", date: date_strs[3], totalEvents: "3"),
|
85
|
-
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "bilbo1", date: date_strs[4], totalEvents: "7")
|
84
|
+
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "bilbo1", date: date_strs[4], totalEvents: "7")
|
86
85
|
]
|
87
|
-
|
86
|
+
end
|
88
87
|
|
89
|
-
let(:bilbo_file_2_download_stats)
|
88
|
+
let(:bilbo_file_2_download_stats) do
|
90
89
|
[
|
91
90
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "bilbo2", date: date_strs[0], totalEvents: "1"),
|
92
91
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "bilbo2", date: date_strs[1], totalEvents: "4"),
|
93
92
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "bilbo2", date: date_strs[2], totalEvents: "3"),
|
94
93
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "bilbo2", date: date_strs[3], totalEvents: "2"),
|
95
|
-
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "bilbo2", date: date_strs[4], totalEvents: "3")
|
94
|
+
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "bilbo2", date: date_strs[4], totalEvents: "3")
|
96
95
|
]
|
97
|
-
|
96
|
+
end
|
98
97
|
|
99
|
-
let(:frodo_file_1_download_stats)
|
98
|
+
let(:frodo_file_1_download_stats) do
|
100
99
|
[
|
101
100
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "frodo1", date: date_strs[0], totalEvents: "5"),
|
102
101
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "frodo1", date: date_strs[1], totalEvents: "4"),
|
103
102
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "frodo1", date: date_strs[2], totalEvents: "2"),
|
104
103
|
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "frodo1", date: date_strs[3], totalEvents: "1"),
|
105
|
-
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "frodo1", date: date_strs[4], totalEvents: "6")
|
104
|
+
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "frodo1", date: date_strs[4], totalEvents: "6")
|
106
105
|
]
|
107
|
-
|
108
|
-
|
106
|
+
end
|
109
107
|
|
110
108
|
describe 'with empty cache' do
|
111
109
|
it 'for each user it adds one entry per day to the cache' do
|
112
|
-
|
110
|
+
described_class.new.import
|
113
111
|
|
114
112
|
bilbos_stats = UserStat.where(user_id: bilbo.id).order(date: :asc)
|
115
113
|
expect(bilbos_stats.count).to eq 4
|
@@ -135,7 +133,7 @@ describe Sufia::UserStatImporter do
|
|
135
133
|
end
|
136
134
|
|
137
135
|
context "when Google analytics throws an error" do
|
138
|
-
let(:importer) {
|
136
|
+
let(:importer) { described_class.new(number_of_retries: 4) }
|
139
137
|
|
140
138
|
context "both error out completely" do
|
141
139
|
before do
|
@@ -191,7 +189,7 @@ describe Sufia::UserStatImporter do
|
|
191
189
|
expect(User.count).to eq 3
|
192
190
|
expect(UserStat.count).to eq 3
|
193
191
|
|
194
|
-
|
192
|
+
described_class.new.import
|
195
193
|
|
196
194
|
bilbos_stats = UserStat.where(user_id: bilbo.id).order(date: :asc)
|
197
195
|
expect(bilbos_stats.count).to eq 4
|
@@ -211,14 +209,14 @@ describe Sufia::UserStatImporter do
|
|
211
209
|
end
|
212
210
|
|
213
211
|
it "processes the oldest records first" do
|
214
|
-
# Since Gollum has no stats it will be the first one processed.
|
212
|
+
# Since Gollum has no stats it will be the first one processed.
|
215
213
|
# Followed by Frodo and Bilbo.
|
216
|
-
sorted_ids =
|
214
|
+
sorted_ids = described_class.new.sorted_users.map(&:id)
|
217
215
|
expect(sorted_ids).to eq([gollum.id, frodo.id, bilbo.id])
|
218
216
|
end
|
219
217
|
|
220
218
|
context "a user is already up to date" do
|
221
|
-
let(:importer) {
|
219
|
+
let(:importer) { described_class.new }
|
222
220
|
before do
|
223
221
|
allow(importer).to receive(:sorted_users).and_return([gollum, frodo, bilbo])
|
224
222
|
UserStat.create!(user_id: bilbo.id, date: dates[3], file_views: 999, file_downloads: 555)
|
@@ -227,7 +225,7 @@ describe Sufia::UserStatImporter do
|
|
227
225
|
it "skips if we already have uptodate information" do
|
228
226
|
expect(importer).to receive(:file_ids_for_user).with(gollum).and_call_original
|
229
227
|
expect(importer).to receive(:file_ids_for_user).with(frodo).and_call_original
|
230
|
-
#expect(importer).to receive(:file_ids_for_user).with(frodo.id).and_call_original
|
228
|
+
# expect(importer).to receive(:file_ids_for_user).with(frodo.id).and_call_original
|
231
229
|
expect(importer).not_to receive(:file_ids_for_user).with(bilbo)
|
232
230
|
importer.import
|
233
231
|
end
|
@@ -235,9 +233,8 @@ describe Sufia::UserStatImporter do
|
|
235
233
|
end
|
236
234
|
end
|
237
235
|
|
238
|
-
|
239
236
|
def stub_out_call_to_google_analytics
|
240
|
-
allow(FileViewStat).to receive(:ga_statistics) do |
|
237
|
+
allow(FileViewStat).to receive(:ga_statistics) do |_date, file_id|
|
241
238
|
case file_id
|
242
239
|
when bilbo_file_1.id
|
243
240
|
bilbo_file_1_pageview_stats
|
@@ -248,7 +245,7 @@ def stub_out_call_to_google_analytics
|
|
248
245
|
end
|
249
246
|
end
|
250
247
|
|
251
|
-
allow(FileDownloadStat).to receive(:ga_statistics) do |
|
248
|
+
allow(FileDownloadStat).to receive(:ga_statistics) do |_date, file_id|
|
252
249
|
case file_id
|
253
250
|
when bilbo_file_1.id
|
254
251
|
bilbo_file_1_download_stats
|
@@ -1,16 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Sufia::Permissions::Writable do
|
4
|
-
|
5
4
|
class SampleModel < ActiveFedora::Base
|
6
5
|
include Sufia::Permissions::Writable
|
7
6
|
end
|
8
7
|
let(:subject) { SampleModel.new }
|
9
8
|
|
10
9
|
describe "#permissions" do
|
11
|
-
it "
|
10
|
+
it "initializes with nothing specified" do
|
12
11
|
expect(subject.permissions).to be_empty
|
13
12
|
end
|
14
13
|
end
|
15
|
-
|
16
14
|
end
|
@@ -4,20 +4,18 @@ describe Sufia::Zotero do
|
|
4
4
|
it { is_expected.to respond_to(:config) }
|
5
5
|
|
6
6
|
describe 'configuration' do
|
7
|
-
subject {
|
7
|
+
subject { described_class.reload_config! }
|
8
8
|
|
9
9
|
let(:client_key) { 'abc123' }
|
10
10
|
let(:client_secret) { '789xyz' }
|
11
11
|
|
12
12
|
before do
|
13
|
-
stub_const('ENV',
|
14
|
-
|
15
|
-
'ZOTERO_CLIENT_SECRET' => client_secret
|
16
|
-
})
|
13
|
+
stub_const('ENV', 'ZOTERO_CLIENT_KEY' => client_key,
|
14
|
+
'ZOTERO_CLIENT_SECRET' => client_secret)
|
17
15
|
end
|
18
16
|
|
19
17
|
# Reload the config so other tests don't see the stub_const values
|
20
|
-
after(:context) {
|
18
|
+
after(:context) { described_class.reload_config! }
|
21
19
|
|
22
20
|
it 'has a client key' do
|
23
21
|
expect(subject['client_key']).to eq(client_key)
|
data/spec/models/ability_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'cancan/matchers'
|
3
3
|
|
4
|
-
describe Sufia::Ability, :
|
4
|
+
describe Sufia::Ability, type: :model do
|
5
5
|
describe "a user with no roles" do
|
6
6
|
let(:user) { nil }
|
7
7
|
subject { Ability.new(user) }
|
@@ -9,8 +9,11 @@ describe Sufia::Ability, :type => :model do
|
|
9
9
|
it { is_expected.not_to be_able_to(:create, TinymceAsset) }
|
10
10
|
it { is_expected.not_to be_able_to(:create, ContentBlock) }
|
11
11
|
it { is_expected.not_to be_able_to(:update, ContentBlock) }
|
12
|
-
it { is_expected.to
|
13
|
-
it { is_expected.to
|
12
|
+
it { is_expected.to be_able_to(:read, GenericFile) }
|
13
|
+
it { is_expected.to be_able_to(:stats, GenericFile) }
|
14
|
+
it { is_expected.to be_able_to(:citation, GenericFile) }
|
15
|
+
it { is_expected.to be_able_to(:read, ContentBlock) }
|
16
|
+
it { is_expected.to be_able_to(:view_share_work, GenericFile) }
|
14
17
|
end
|
15
18
|
|
16
19
|
describe "a registered user" do
|
@@ -20,8 +23,8 @@ describe Sufia::Ability, :type => :model do
|
|
20
23
|
it { is_expected.not_to be_able_to(:create, TinymceAsset) }
|
21
24
|
it { is_expected.not_to be_able_to(:create, ContentBlock) }
|
22
25
|
it { is_expected.not_to be_able_to(:update, ContentBlock) }
|
23
|
-
it { is_expected.to
|
24
|
-
it { is_expected.to
|
26
|
+
it { is_expected.to be_able_to(:read, ContentBlock) }
|
27
|
+
it { is_expected.to be_able_to(:view_share_work, GenericFile) }
|
25
28
|
end
|
26
29
|
|
27
30
|
describe "a user in the admin group" do
|
@@ -32,11 +35,10 @@ describe Sufia::Ability, :type => :model do
|
|
32
35
|
it { is_expected.to be_able_to(:create, TinymceAsset) }
|
33
36
|
it { is_expected.to be_able_to(:create, ContentBlock) }
|
34
37
|
it { is_expected.to be_able_to(:update, ContentBlock) }
|
35
|
-
it { is_expected.to be_able_to(:read,
|
36
|
-
it { is_expected.to
|
38
|
+
it { is_expected.to be_able_to(:read, ContentBlock) }
|
39
|
+
it { is_expected.to be_able_to(:view_share_work, GenericFile) }
|
37
40
|
end
|
38
41
|
|
39
|
-
|
40
42
|
describe "proxies and transfers" do
|
41
43
|
let(:sender) { FactoryGirl.find_or_create(:jill) }
|
42
44
|
let(:user) { FactoryGirl.find_or_create(:archivist) }
|
@@ -50,7 +52,7 @@ describe Sufia::Ability, :type => :model do
|
|
50
52
|
it { should_not be_able_to(:transfer, file.id) }
|
51
53
|
|
52
54
|
describe "depositor_for_document" do
|
53
|
-
it "
|
55
|
+
it "returns the depositor" do
|
54
56
|
expect(subject.send(:depositor_for_document, file.id)).to eq sender.user_key
|
55
57
|
end
|
56
58
|
end
|
data/spec/models/batch_spec.rb
CHANGED
@@ -2,36 +2,36 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Batch do
|
4
4
|
let(:user) { FactoryGirl.find_or_create(:jill) }
|
5
|
-
let(:batch) {
|
5
|
+
let(:batch) { described_class.create(title: ["test collection"], creator: [user.user_key]) }
|
6
6
|
|
7
|
-
it "
|
7
|
+
it "belongs to testuser" do
|
8
8
|
expect(batch.creator).to eq [user.user_key]
|
9
9
|
end
|
10
|
-
it "
|
10
|
+
it "is titled 'test collection'" do
|
11
11
|
expect(batch.title).to eq ["test collection"]
|
12
12
|
end
|
13
|
-
it "
|
13
|
+
it "has generic_files defined" do
|
14
14
|
expect(batch).to respond_to(:generic_files)
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
17
|
+
it "supports to_solr" do
|
18
18
|
expect(batch.to_solr).to_not be_nil
|
19
19
|
expect(batch.to_solr["batch__title_t"]).to be_nil
|
20
20
|
expect(batch.to_solr["batch__creator_t"]).to be_nil
|
21
21
|
end
|
22
22
|
describe "find_or_create" do
|
23
23
|
describe "when the object exists" do
|
24
|
-
let!
|
25
|
-
it "
|
26
|
-
expect(
|
27
|
-
|
24
|
+
let!(:batch) { described_class.create(title: ["test collection"], creator: [user.user_key]) }
|
25
|
+
it "finds batch instead of creating" do
|
26
|
+
expect(described_class).to_not receive(:create)
|
27
|
+
described_class.find_or_create(batch.id)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
describe "when the object does not exist" do
|
31
|
-
it "
|
32
|
-
expect {
|
33
|
-
expect(
|
34
|
-
expect(
|
31
|
+
it "creates" do
|
32
|
+
expect { described_class.find("batch-123") }.to raise_error(ActiveFedora::ObjectNotFoundError)
|
33
|
+
expect(described_class).to receive(:create).once.and_return("the batch")
|
34
|
+
expect(described_class.find_or_create("batch-123")).to eq "the batch"
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Sufia::GenericFile::Characterization, :
|
3
|
+
describe Sufia::GenericFile::Characterization, type: :model do
|
4
4
|
before do
|
5
5
|
class TestClass < ActiveFedora::Base
|
6
6
|
include Sufia::GenericFile::Characterization
|
@@ -16,8 +16,7 @@ describe Sufia::GenericFile::Characterization, :type => :model do
|
|
16
16
|
|
17
17
|
subject { TestClass.new }
|
18
18
|
|
19
|
-
it "
|
19
|
+
it "does not depend on anything except a file datastream and some property accessors" do
|
20
20
|
expect { subject.characterize }.to_not raise_error
|
21
21
|
end
|
22
|
-
|
23
22
|
end
|
@@ -14,52 +14,51 @@ describe ChecksumAuditLog do
|
|
14
14
|
|
15
15
|
let(:version_uri) { f.content.versions.first.uri }
|
16
16
|
let(:version_path) { 'content' }
|
17
|
-
let(:old) {
|
18
|
-
let(:new) {
|
17
|
+
let(:old) { described_class.create(generic_file_id: f.id, dsid: version_path, version: version_uri, pass: 1, created_at: 2.minutes.ago) }
|
18
|
+
let(:new) { described_class.create(generic_file_id: f.id, dsid: version_path, version: version_uri, pass: 0, created_at: 1.minute.ago) }
|
19
19
|
|
20
20
|
context "a file with multiple checksums audits" do
|
21
21
|
specify "should return a list of logs for this datastream sorted by date descending" do
|
22
|
-
logs =
|
22
|
+
logs = described_class.logs_for(f.id, version_path)
|
23
23
|
expect(logs).to eq([new, old])
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
context "after multiple checksum audits where the checksum does not change" do
|
28
28
|
specify "only one of them should be kept" do
|
29
|
-
success1 =
|
30
|
-
|
31
|
-
success2 =
|
32
|
-
|
33
|
-
success3 =
|
34
|
-
|
29
|
+
success1 = described_class.create(generic_file_id: f.id, dsid: version_path, version: version_uri, pass: 1)
|
30
|
+
described_class.prune_history(f.id, version_path)
|
31
|
+
success2 = described_class.create(generic_file_id: f.id, dsid: version_path, version: version_uri, pass: 1)
|
32
|
+
described_class.prune_history(f.id, version_path)
|
33
|
+
success3 = described_class.create(generic_file_id: f.id, dsid: version_path, version: version_uri, pass: 1)
|
34
|
+
described_class.prune_history(f.id, version_path)
|
35
35
|
|
36
|
-
expect {
|
37
|
-
expect {
|
38
|
-
expect(
|
39
|
-
logs =
|
36
|
+
expect { described_class.find(success2.id) }.to raise_exception ActiveRecord::RecordNotFound
|
37
|
+
expect { described_class.find(success3.id) }.to raise_exception ActiveRecord::RecordNotFound
|
38
|
+
expect(described_class.find(success1.id)).not_to be_nil
|
39
|
+
logs = described_class.logs_for(f.id, version_path)
|
40
40
|
expect(logs).to eq([success1, new, old])
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
context "should have an audit log history" do
|
45
45
|
before do
|
46
|
-
|
47
|
-
|
46
|
+
described_class.create(generic_file_id: f.id, dsid: 'content', version: 'v2', pass: 1)
|
47
|
+
described_class.create(generic_file_id: f.id, dsid: 'thumbnail', version: 'v1', pass: 1)
|
48
48
|
end
|
49
49
|
|
50
50
|
specify "should have an audit log history" do
|
51
|
-
audit =
|
51
|
+
audit = described_class.get_audit_log(f.id, 'content', version_uri)
|
52
52
|
expect(audit.generic_file_id).to eq(f.id)
|
53
53
|
expect(audit.version).to eq(version_uri)
|
54
54
|
|
55
|
-
audit =
|
55
|
+
audit = described_class.get_audit_log(f.id, 'content', 'v2')
|
56
56
|
expect(audit.generic_file_id).to eq(f.id)
|
57
57
|
expect(audit.version).to eq('v2')
|
58
58
|
|
59
|
-
audit =
|
59
|
+
audit = described_class.get_audit_log(f.id, 'thumbnail', 'v1')
|
60
60
|
expect(audit.generic_file_id).to eq(f.id)
|
61
61
|
expect(audit.version).to eq('v1')
|
62
|
-
|
63
62
|
end
|
64
63
|
end
|
65
64
|
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Collection, :
|
3
|
+
describe Collection, type: :model do
|
4
4
|
before do
|
5
5
|
@user = FactoryGirl.create(:user)
|
6
|
-
@collection =
|
6
|
+
@collection = described_class.new(id: 'mock-collection-with-members', title: "test collection") do |c|
|
7
7
|
c.apply_depositor_metadata(@user.user_key)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
11
|
+
it "has open visibility" do
|
12
12
|
@collection.save
|
13
13
|
expect(@collection.read_groups).to eq ['public']
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
17
|
-
|
18
|
-
|
16
|
+
it "does not allow a collection to be saved without a title" do
|
17
|
+
@collection.title = nil
|
18
|
+
expect { @collection.save! }.to raise_error(ActiveFedora::RecordInvalid)
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "::bytes" do
|
@@ -28,18 +28,18 @@ describe Collection, :type => :model do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
context "with three 33 byte files" do
|
31
|
-
let(:bitstream) { double("content", size: "33")}
|
31
|
+
let(:bitstream) { double("content", size: "33") }
|
32
32
|
let(:file) { mock_model GenericFile, content: bitstream }
|
33
33
|
let(:documents) do
|
34
|
-
[{ 'id' => 'file-1', 'file_size_is' => 33 },
|
35
|
-
{ 'id' => 'file-2', 'file_size_is' => 33 },
|
34
|
+
[{ 'id' => 'file-1', 'file_size_is' => 33 },
|
35
|
+
{ 'id' => 'file-2', 'file_size_is' => 33 },
|
36
36
|
{ 'id' => 'file-3', 'file_size_is' => 33 }]
|
37
37
|
end
|
38
38
|
let(:query) { ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: ::GenericFile.to_class_uri) }
|
39
39
|
let(:args) do
|
40
40
|
{ fq: "{!join from=hasCollectionMember_ssim to=id}id:#{@collection.id}",
|
41
|
-
|
42
|
-
|
41
|
+
fl: "id, file_size_is",
|
42
|
+
rows: 3 }
|
43
43
|
end
|
44
44
|
|
45
45
|
before do
|
@@ -60,6 +60,5 @@ describe Collection, :type => :model do
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
63
|
-
|
64
63
|
end
|
65
64
|
end
|