sufia 6.2.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,10 +1,10 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
RSpec.describe FileViewStat, :
|
|
4
|
-
let(:file_id) {"99"}
|
|
5
|
-
let(:user_id) {123}
|
|
6
|
-
let(:date) {DateTime.new}
|
|
7
|
-
let(:file_stat) {
|
|
3
|
+
RSpec.describe FileViewStat, type: :model do
|
|
4
|
+
let(:file_id) { "99" }
|
|
5
|
+
let(:user_id) { 123 }
|
|
6
|
+
let(:date) { DateTime.new }
|
|
7
|
+
let(:file_stat) { described_class.create(views: "25", date: date, file_id: file_id, user_id: user_id) }
|
|
8
8
|
|
|
9
9
|
it "has attributes" do
|
|
10
10
|
expect(file_stat).to respond_to(:views)
|
|
@@ -17,72 +17,66 @@ RSpec.describe FileViewStat, :type => :model do
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
describe "#get_float_statistics" do
|
|
20
|
-
|
|
21
|
-
let(:dates) {
|
|
20
|
+
let(:dates) do
|
|
22
21
|
ldates = []
|
|
23
|
-
4.downto(0) {|idx| ldates << (Date.today-idx.day) }
|
|
22
|
+
4.downto(0) { |idx| ldates << (Date.today - idx.day) }
|
|
24
23
|
ldates
|
|
25
|
-
|
|
26
|
-
let(:date_strs)
|
|
27
|
-
dates.map {|date|
|
|
28
|
-
|
|
24
|
+
end
|
|
25
|
+
let(:date_strs) do
|
|
26
|
+
dates.map { |date| date.strftime("%Y%m%d") }
|
|
27
|
+
end
|
|
29
28
|
|
|
30
|
-
let(:view_output)
|
|
29
|
+
let(:view_output) do
|
|
31
30
|
[[statistic_date(dates[0]), 4], [statistic_date(dates[1]), 8], [statistic_date(dates[2]), 6], [statistic_date(dates[3]), 10]]
|
|
32
|
-
|
|
31
|
+
end
|
|
33
32
|
|
|
34
33
|
# This is what the data looks like that's returned from Google Analytics (GA) via the Legato gem
|
|
35
34
|
# Due to the nature of querying GA, testing this data in an automated fashion is problematc.
|
|
36
35
|
# Sample data structures were created by sending real events to GA from a test instance of
|
|
37
36
|
# Scholarsphere. The data below are essentially a "cut and paste" from the output of query
|
|
38
37
|
# results from the Legato gem.
|
|
39
|
-
let(:sample_pageview_statistics)
|
|
38
|
+
let(:sample_pageview_statistics) do
|
|
40
39
|
[
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
OpenStruct.new(date: date_strs[0], pageviews: 4),
|
|
41
|
+
OpenStruct.new(date: date_strs[1], pageviews: 8),
|
|
42
|
+
OpenStruct.new(date: date_strs[2], pageviews: 6),
|
|
43
|
+
OpenStruct.new(date: date_strs[3], pageviews: 10),
|
|
44
|
+
# OpenStruct.new(date: date_strs[4], pageviews: 2)
|
|
46
45
|
]
|
|
47
|
-
|
|
46
|
+
end
|
|
48
47
|
describe "cache empty" do
|
|
49
|
-
let(:stats)
|
|
50
|
-
expect(
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
let(:stats) do
|
|
49
|
+
expect(described_class).to receive(:ga_statistics).and_return(sample_pageview_statistics)
|
|
50
|
+
described_class.statistics(file_id, Date.today - 4.day, user_id)
|
|
51
|
+
end
|
|
53
52
|
|
|
54
53
|
it "includes cached ga data" do
|
|
55
|
-
expect(
|
|
54
|
+
expect(described_class.to_flots stats).to include(*view_output)
|
|
56
55
|
end
|
|
57
56
|
|
|
58
57
|
it "caches data" do
|
|
59
|
-
expect(
|
|
58
|
+
expect(described_class.to_flots stats).to include(*view_output)
|
|
60
59
|
expect(stats.first.user_id).to eq user_id
|
|
61
60
|
|
|
62
61
|
# at this point all data should be cached
|
|
63
|
-
allow(
|
|
62
|
+
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!")
|
|
64
63
|
|
|
65
|
-
stats2 =
|
|
66
|
-
expect(
|
|
64
|
+
stats2 = described_class.statistics(file_id, Date.today - 5.day)
|
|
65
|
+
expect(described_class.to_flots stats2).to include(*view_output)
|
|
67
66
|
end
|
|
68
|
-
|
|
69
67
|
end
|
|
70
68
|
|
|
71
69
|
describe "cache loaded" do
|
|
70
|
+
let!(:file_view_stat) { described_class.create(date: (Date.today - 5.day).to_datetime, file_id: file_id, views: "25") }
|
|
72
71
|
|
|
73
|
-
let
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
FileViewStat.statistics(file_id,Date.today-5.day)
|
|
78
|
-
}
|
|
72
|
+
let(:stats) do
|
|
73
|
+
expect(described_class).to receive(:ga_statistics).and_return(sample_pageview_statistics)
|
|
74
|
+
described_class.statistics(file_id, Date.today - 5.day)
|
|
75
|
+
end
|
|
79
76
|
|
|
80
77
|
it "includes cached data" do
|
|
81
|
-
expect(
|
|
78
|
+
expect(described_class.to_flots stats).to include([file_view_stat.date.to_i * 1000, file_view_stat.views], *view_output)
|
|
82
79
|
end
|
|
83
|
-
|
|
84
80
|
end
|
|
85
|
-
|
|
86
81
|
end
|
|
87
82
|
end
|
|
88
|
-
|
|
@@ -7,36 +7,36 @@ describe FitsDatastream, type: :model, unless: $in_travis do
|
|
|
7
7
|
@file.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png')
|
|
8
8
|
@file.characterize
|
|
9
9
|
end
|
|
10
|
-
it "
|
|
10
|
+
it "has a format label" do
|
|
11
11
|
expect(@file.format_label).to eq ["Portable Network Graphics"]
|
|
12
12
|
end
|
|
13
|
-
it "
|
|
13
|
+
it "has a mime type" do
|
|
14
14
|
expect(@file.mime_type).to eq "image/png"
|
|
15
15
|
end
|
|
16
|
-
it "
|
|
16
|
+
it "has a file size" do
|
|
17
17
|
expect(@file.file_size).to eq ["4218"]
|
|
18
18
|
end
|
|
19
|
-
it "
|
|
19
|
+
it "has a last modified timestamp" do
|
|
20
20
|
expect(@file.last_modified).to_not be_empty
|
|
21
21
|
end
|
|
22
|
-
it "
|
|
22
|
+
it "has a filename" do
|
|
23
23
|
expect(@file.filename).to_not be_empty
|
|
24
24
|
end
|
|
25
|
-
it "
|
|
25
|
+
it "has a checksum" do
|
|
26
26
|
expect(@file.original_checksum).to eq ["28da6259ae5707c68708192a40b3e85c"]
|
|
27
27
|
end
|
|
28
|
-
it "
|
|
28
|
+
it "has a height" do
|
|
29
29
|
expect(@file.height).to eq ["50"]
|
|
30
30
|
end
|
|
31
|
-
it "
|
|
31
|
+
it "has a width" do
|
|
32
32
|
expect(@file.width).to eq ["50"]
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
let(:datastream) { @file.characterization }
|
|
36
36
|
let(:xml) { datastream.ng_xml }
|
|
37
|
-
let(:namespace) { {'ns'=>'http://hul.harvard.edu/ois/xml/ns/fits/fits_output'} }
|
|
37
|
+
let(:namespace) { { 'ns' => 'http://hul.harvard.edu/ois/xml/ns/fits/fits_output' } }
|
|
38
38
|
|
|
39
|
-
it "
|
|
39
|
+
it "makes the fits XML" do
|
|
40
40
|
expect(xml.xpath('//ns:imageWidth/text()', namespace).inner_text).to eq '50'
|
|
41
41
|
end
|
|
42
42
|
end
|
|
@@ -47,37 +47,37 @@ describe FitsDatastream, type: :model, unless: $in_travis do
|
|
|
47
47
|
@file.add_file(File.open(fixture_path + '/sample_mpeg4.mp4'), path: 'content', original_name: 'sample_mpeg4.mp4')
|
|
48
48
|
@file.characterize
|
|
49
49
|
end
|
|
50
|
-
it "
|
|
50
|
+
it "has a format label" do
|
|
51
51
|
expect(@file.format_label).to eq ["ISO Media, MPEG v4 system, version 2"]
|
|
52
52
|
end
|
|
53
|
-
it "
|
|
53
|
+
it "has a mime type" do
|
|
54
54
|
expect(@file.mime_type).to eq "video/mp4"
|
|
55
55
|
end
|
|
56
|
-
it "
|
|
56
|
+
it "has a file size" do
|
|
57
57
|
expect(@file.file_size).to eq ["245779"]
|
|
58
58
|
end
|
|
59
|
-
it "
|
|
59
|
+
it "has a last modified timestamp" do
|
|
60
60
|
expect(@file.last_modified).to_not be_empty
|
|
61
61
|
end
|
|
62
|
-
it "
|
|
62
|
+
it "has a filename" do
|
|
63
63
|
expect(@file.filename).to_not be_empty
|
|
64
64
|
end
|
|
65
|
-
it "
|
|
65
|
+
it "has a checksum" do
|
|
66
66
|
expect(@file.original_checksum).to eq ["dc77a8de8c091c19d86df74280f6feb7"]
|
|
67
67
|
end
|
|
68
|
-
it "
|
|
68
|
+
it "has a width" do
|
|
69
69
|
expect(@file.width).to eq ["190"]
|
|
70
70
|
end
|
|
71
|
-
it "
|
|
71
|
+
it "has a height" do
|
|
72
72
|
expect(@file.height).to eq ["240"]
|
|
73
73
|
end
|
|
74
|
-
it "
|
|
74
|
+
it "has a sample_rate" do
|
|
75
75
|
expect(@file.sample_rate).to eq ["32000"]
|
|
76
76
|
end
|
|
77
|
-
it "
|
|
77
|
+
it "has a duration" do
|
|
78
78
|
expect(@file.duration).to eq ["4.97 s"]
|
|
79
79
|
end
|
|
80
|
-
it "
|
|
80
|
+
it "has a frame_rate" do
|
|
81
81
|
expect(@file.frame_rate.count).to eq 1
|
|
82
82
|
expect(@file.frame_rate[0].to_f).to eq 30.0
|
|
83
83
|
end
|
|
@@ -93,7 +93,7 @@ describe FitsDatastream, type: :model, unless: $in_travis do
|
|
|
93
93
|
@myfile.reload
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
-
it "
|
|
96
|
+
it "returns expected results after a save" do
|
|
97
97
|
expect(@myfile.file_size).to eq ['218882']
|
|
98
98
|
expect(@myfile.original_checksum).to eq ['5a2d761cab7c15b2b3bb3465ce64586d']
|
|
99
99
|
|
|
@@ -124,10 +124,8 @@ describe FitsDatastream, type: :model, unless: $in_travis do
|
|
|
124
124
|
@myfile.reload
|
|
125
125
|
end
|
|
126
126
|
|
|
127
|
-
it "
|
|
127
|
+
it "returns expected content for full text" do
|
|
128
128
|
expect(@myfile.full_text.content).to eq("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nLavf56.15.102")
|
|
129
129
|
end
|
|
130
130
|
end
|
|
131
|
-
|
|
132
|
-
|
|
133
131
|
end
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe Sufia::GenericFile, :
|
|
3
|
+
describe Sufia::GenericFile, type: :model do
|
|
4
4
|
module VisibilityOverride
|
|
5
5
|
extend ActiveSupport::Concern
|
|
6
6
|
include Sufia::GenericFile::Permissions
|
|
7
|
-
def visibility
|
|
8
|
-
|
|
7
|
+
def visibility
|
|
8
|
+
super
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def visibility=(value)
|
|
12
|
+
super(value)
|
|
13
|
+
end
|
|
9
14
|
end
|
|
10
15
|
class MockParent < ActiveFedora::Base
|
|
11
16
|
include VisibilityOverride
|
|
12
17
|
end
|
|
13
18
|
|
|
14
19
|
it 'allows for overrides of visibility' do
|
|
15
|
-
expect
|
|
20
|
+
expect do
|
|
16
21
|
MockParent.new(visibility: Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE)
|
|
17
|
-
|
|
22
|
+
end.to_not raise_error
|
|
18
23
|
end
|
|
19
24
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe GenericFile, :
|
|
3
|
+
describe GenericFile, type: :model do
|
|
4
4
|
let(:user) { FactoryGirl.find_or_create(:jill) }
|
|
5
5
|
|
|
6
6
|
before(:each) do
|
|
7
|
-
@file =
|
|
7
|
+
@file = described_class.new
|
|
8
8
|
@file.apply_depositor_metadata(user.user_key)
|
|
9
9
|
end
|
|
10
10
|
|
|
@@ -15,7 +15,7 @@ describe GenericFile, :type => :model do
|
|
|
15
15
|
|
|
16
16
|
context "when it is initialized" do
|
|
17
17
|
it "has empty arrays for all the properties" do
|
|
18
|
-
subject.attributes.each do |
|
|
18
|
+
subject.attributes.each do |_k, v|
|
|
19
19
|
expect(Array(v)).to eq([])
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -39,7 +39,7 @@ describe GenericFile, :type => :model do
|
|
|
39
39
|
before do
|
|
40
40
|
@file.proxy_depositor = "sally@example.com"
|
|
41
41
|
end
|
|
42
|
-
it "
|
|
42
|
+
it "includes proxies" do
|
|
43
43
|
expect(@file).to respond_to(:relative_path)
|
|
44
44
|
expect(@file).to respond_to(:depositor)
|
|
45
45
|
expect(@file.proxy_depositor).to eq 'sally@example.com'
|
|
@@ -162,55 +162,54 @@ describe GenericFile, :type => :model do
|
|
|
162
162
|
end
|
|
163
163
|
|
|
164
164
|
describe "visibility" do
|
|
165
|
-
it "
|
|
165
|
+
it "is not changed when it's new" do
|
|
166
166
|
expect(subject).not_to be_visibility_changed
|
|
167
167
|
end
|
|
168
|
-
it "
|
|
169
|
-
subject.visibility= 'open'
|
|
168
|
+
it "is changed when it has been changed" do
|
|
169
|
+
subject.visibility = 'open'
|
|
170
170
|
expect(subject).to be_visibility_changed
|
|
171
171
|
end
|
|
172
172
|
|
|
173
|
-
it "
|
|
174
|
-
subject.visibility= 'restricted'
|
|
173
|
+
it "is not changed when it's set to its previous value" do
|
|
174
|
+
subject.visibility = 'restricted'
|
|
175
175
|
expect(subject).not_to be_visibility_changed
|
|
176
176
|
end
|
|
177
|
-
|
|
178
177
|
end
|
|
179
178
|
|
|
180
179
|
describe "#apply_depositor_metadata" do
|
|
181
180
|
before { subject.apply_depositor_metadata('jcoyne') }
|
|
182
181
|
|
|
183
|
-
it "
|
|
182
|
+
it "grants edit access and record the depositor" do
|
|
184
183
|
expect(subject.edit_users).to eq ['jcoyne']
|
|
185
184
|
expect(subject.depositor).to eq 'jcoyne'
|
|
186
185
|
end
|
|
187
186
|
end
|
|
188
187
|
|
|
189
188
|
describe "attributes" do
|
|
190
|
-
it "
|
|
191
|
-
subject.read_groups=['group1', 'group2']
|
|
192
|
-
subject.edit_users=['user1']
|
|
193
|
-
subject.read_users=['user2', 'user3']
|
|
189
|
+
it "has a set of permissions" do
|
|
190
|
+
subject.read_groups = ['group1', 'group2']
|
|
191
|
+
subject.edit_users = ['user1']
|
|
192
|
+
subject.read_users = ['user2', 'user3']
|
|
194
193
|
expect(subject.permissions.map(&:to_hash)).to match_array [
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
194
|
+
{ type: "group", access: "read", name: "group1" },
|
|
195
|
+
{ type: "group", access: "read", name: "group2" },
|
|
196
|
+
{ type: "person", access: "read", name: "user2" },
|
|
197
|
+
{ type: "person", access: "read", name: "user3" },
|
|
198
|
+
{ type: "person", access: "edit", name: "user1" }]
|
|
200
199
|
end
|
|
201
200
|
|
|
202
|
-
it "
|
|
201
|
+
it "has a characterization datastream" do
|
|
203
202
|
expect(subject.characterization).to be_kind_of FitsDatastream
|
|
204
203
|
end
|
|
205
204
|
|
|
206
|
-
it "
|
|
205
|
+
it "has content datastream" do
|
|
207
206
|
subject.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png')
|
|
208
207
|
expect(subject.content).to be_kind_of FileContentDatastream
|
|
209
208
|
end
|
|
210
209
|
end
|
|
211
210
|
|
|
212
211
|
describe "metadata" do
|
|
213
|
-
it "
|
|
212
|
+
it "has descriptive metadata" do
|
|
214
213
|
expect(subject).to respond_to(:relative_path)
|
|
215
214
|
expect(subject).to respond_to(:depositor)
|
|
216
215
|
expect(subject).to respond_to(:related_url)
|
|
@@ -230,7 +229,7 @@ describe GenericFile, :type => :model do
|
|
|
230
229
|
expect(subject).to respond_to(:resource_type)
|
|
231
230
|
expect(subject).to respond_to(:identifier)
|
|
232
231
|
end
|
|
233
|
-
it "
|
|
232
|
+
it "delegates methods to characterization metadata" do
|
|
234
233
|
expect(subject).to respond_to(:format_label)
|
|
235
234
|
expect(subject).to respond_to(:mime_type)
|
|
236
235
|
expect(subject).to respond_to(:file_size)
|
|
@@ -242,14 +241,14 @@ describe GenericFile, :type => :model do
|
|
|
242
241
|
expect(subject).to respond_to(:file_author)
|
|
243
242
|
expect(subject).to respond_to(:page_count)
|
|
244
243
|
end
|
|
245
|
-
it "
|
|
244
|
+
it "redefines to_param to make redis keys more recognizable" do
|
|
246
245
|
expect(subject.to_param).to eq subject.id
|
|
247
246
|
end
|
|
248
247
|
|
|
249
248
|
describe "that have been saved" do
|
|
250
249
|
before { subject.apply_depositor_metadata('jcoyne') }
|
|
251
250
|
|
|
252
|
-
it "
|
|
251
|
+
it "has activity stream-related methods defined" do
|
|
253
252
|
subject.save!
|
|
254
253
|
f = subject.reload
|
|
255
254
|
expect(f).to respond_to(:stream)
|
|
@@ -258,7 +257,7 @@ describe GenericFile, :type => :model do
|
|
|
258
257
|
expect(f).to respond_to(:log_event)
|
|
259
258
|
end
|
|
260
259
|
|
|
261
|
-
it "
|
|
260
|
+
it "is able to set values via delegated methods" do
|
|
262
261
|
subject.related_url = ["http://example.org/"]
|
|
263
262
|
subject.creator = ["John Doe"]
|
|
264
263
|
subject.title = ["New work"]
|
|
@@ -269,7 +268,7 @@ describe GenericFile, :type => :model do
|
|
|
269
268
|
expect(f.title).to eq ["New work"]
|
|
270
269
|
end
|
|
271
270
|
|
|
272
|
-
it "
|
|
271
|
+
it "is able to be added to w/o unexpected graph behavior" do
|
|
273
272
|
subject.creator = ["John Doe"]
|
|
274
273
|
subject.title = ["New work"]
|
|
275
274
|
subject.save!
|
|
@@ -338,27 +337,27 @@ describe GenericFile, :type => :model do
|
|
|
338
337
|
expect(local['all_text_timv']).to eq('abcxyz')
|
|
339
338
|
end
|
|
340
339
|
end
|
|
341
|
-
it "
|
|
340
|
+
it "supports multi-valued fields in solr" do
|
|
342
341
|
subject.tag = ["tag1", "tag2"]
|
|
343
342
|
expect { subject.save }.not_to raise_error
|
|
344
343
|
subject.delete
|
|
345
344
|
end
|
|
346
|
-
it "
|
|
345
|
+
it "supports setting and getting the relative_path value" do
|
|
347
346
|
subject.relative_path = "documents/research/NSF/2010"
|
|
348
347
|
expect(subject.relative_path).to eq "documents/research/NSF/2010"
|
|
349
348
|
end
|
|
350
349
|
describe "create_thumbnail" do
|
|
351
350
|
before do
|
|
352
|
-
@f =
|
|
351
|
+
@f = described_class.new
|
|
353
352
|
@f.apply_depositor_metadata('mjg36')
|
|
354
353
|
end
|
|
355
354
|
describe "with a video", if: Sufia.config.enable_ffmpeg do
|
|
356
355
|
before do
|
|
357
|
-
allow(@f).to receive(mime_type: 'video/quicktime')
|
|
356
|
+
allow(@f).to receive(mime_type: 'video/quicktime') # Would get set by the characterization job
|
|
358
357
|
@f.add_file(File.open("#{fixture_path}/countdown.avi", 'rb'), path: 'content', original_name: 'countdown.avi')
|
|
359
358
|
@f.save
|
|
360
359
|
end
|
|
361
|
-
it "
|
|
360
|
+
it "makes a png thumbnail" do
|
|
362
361
|
@f.create_thumbnail
|
|
363
362
|
expect(@f.thumbnail.content.size).to eq 4768 # this is a bad test. I just want to show that it did something.
|
|
364
363
|
expect(@f.thumbnail.mime_type).to eq 'image/png'
|
|
@@ -368,16 +367,16 @@ describe GenericFile, :type => :model do
|
|
|
368
367
|
describe "trophies" do
|
|
369
368
|
before do
|
|
370
369
|
u = FactoryGirl.find_or_create(:jill)
|
|
371
|
-
@f =
|
|
370
|
+
@f = described_class.new.tap do |gf|
|
|
372
371
|
gf.apply_depositor_metadata(u)
|
|
373
372
|
gf.save!
|
|
374
373
|
end
|
|
375
374
|
@t = Trophy.create(user_id: u.id, generic_file_id: @f.id)
|
|
376
375
|
end
|
|
377
|
-
it "
|
|
376
|
+
it "has a trophy" do
|
|
378
377
|
expect(Trophy.where(generic_file_id: @f.id).count).to eq 1
|
|
379
378
|
end
|
|
380
|
-
it "
|
|
379
|
+
it "removes all trophies when file is deleted" do
|
|
381
380
|
@f.destroy
|
|
382
381
|
expect(Trophy.where(generic_file_id: @f.id).count).to eq 0
|
|
383
382
|
end
|
|
@@ -385,21 +384,21 @@ describe GenericFile, :type => :model do
|
|
|
385
384
|
|
|
386
385
|
describe "#related_files" do
|
|
387
386
|
let!(:f1) do
|
|
388
|
-
|
|
387
|
+
described_class.new.tap do |f|
|
|
389
388
|
f.apply_depositor_metadata('mjg36')
|
|
390
389
|
f.batch_id = batch_id
|
|
391
390
|
f.save
|
|
392
391
|
end
|
|
393
392
|
end
|
|
394
393
|
let!(:f2) do
|
|
395
|
-
|
|
394
|
+
described_class.new.tap do |f|
|
|
396
395
|
f.apply_depositor_metadata('mjg36')
|
|
397
396
|
f.batch_id = batch_id
|
|
398
397
|
f.save
|
|
399
398
|
end
|
|
400
399
|
end
|
|
401
400
|
let!(:f3) do
|
|
402
|
-
|
|
401
|
+
described_class.new.tap do |f|
|
|
403
402
|
f.apply_depositor_metadata('mjg36')
|
|
404
403
|
f.batch_id = batch_id
|
|
405
404
|
f.save
|
|
@@ -410,7 +409,7 @@ describe GenericFile, :type => :model do
|
|
|
410
409
|
let(:batch) { Batch.create }
|
|
411
410
|
let(:batch_id) { batch.id }
|
|
412
411
|
|
|
413
|
-
it "
|
|
412
|
+
it "does not return itself from the related_files method" do
|
|
414
413
|
expect(f1.related_files).to match_array [f2, f3]
|
|
415
414
|
expect(f2.related_files).to match_array [f1, f3]
|
|
416
415
|
expect(f3.related_files).to match_array [f1, f2]
|
|
@@ -420,7 +419,7 @@ describe GenericFile, :type => :model do
|
|
|
420
419
|
context "when there are no related files" do
|
|
421
420
|
let(:batch_id) { nil }
|
|
422
421
|
|
|
423
|
-
it "
|
|
422
|
+
it "returns an empty array when there are no related files" do
|
|
424
423
|
expect(f1.related_files).to eq []
|
|
425
424
|
end
|
|
426
425
|
end
|
|
@@ -434,12 +433,12 @@ describe GenericFile, :type => :model do
|
|
|
434
433
|
let(:noid) { 'wd3763094' }
|
|
435
434
|
|
|
436
435
|
subject do
|
|
437
|
-
|
|
436
|
+
described_class.create { |f| f.apply_depositor_metadata('mjg36') }
|
|
438
437
|
end
|
|
439
438
|
|
|
440
439
|
it "runs the overridden #assign_id method" do
|
|
441
440
|
expect_any_instance_of(ActiveFedora::Noid::Service).to receive(:mint).once
|
|
442
|
-
|
|
441
|
+
described_class.create { |f| f.apply_depositor_metadata('mjg36') }
|
|
443
442
|
end
|
|
444
443
|
|
|
445
444
|
it "returns the expected identifier" do
|
|
@@ -454,37 +453,37 @@ describe GenericFile, :type => :model do
|
|
|
454
453
|
let(:url) { 'http://localhost:8983/fedora/rest/test/wd/37/63/09/wd3763094' }
|
|
455
454
|
|
|
456
455
|
it "transforms the url into an id" do
|
|
457
|
-
expect(
|
|
456
|
+
expect(described_class.uri_to_id(url)).to eq 'wd3763094'
|
|
458
457
|
end
|
|
459
458
|
end
|
|
460
459
|
end
|
|
461
460
|
|
|
462
461
|
context "with access control metadata" do
|
|
463
462
|
subject do
|
|
464
|
-
|
|
463
|
+
described_class.new do |m|
|
|
465
464
|
m.apply_depositor_metadata('jcoyne')
|
|
466
|
-
m.permissions_attributes = [{type: 'person', access: 'read', name: "person1"},
|
|
467
|
-
{type: 'person', access: 'read', name: "person2"},
|
|
468
|
-
{type: 'group', access: 'read', name: "group-6"},
|
|
469
|
-
{type: 'group', access: 'read', name: "group-7"},
|
|
470
|
-
{type: 'group', access: 'edit', name: "group-8"}]
|
|
465
|
+
m.permissions_attributes = [{ type: 'person', access: 'read', name: "person1" },
|
|
466
|
+
{ type: 'person', access: 'read', name: "person2" },
|
|
467
|
+
{ type: 'group', access: 'read', name: "group-6" },
|
|
468
|
+
{ type: 'group', access: 'read', name: "group-7" },
|
|
469
|
+
{ type: 'group', access: 'edit', name: "group-8" }]
|
|
471
470
|
end
|
|
472
471
|
end
|
|
473
472
|
|
|
474
|
-
it "
|
|
473
|
+
it "has read groups accessor" do
|
|
475
474
|
expect(subject.read_groups).to eq ['group-6', 'group-7']
|
|
476
475
|
end
|
|
477
476
|
|
|
478
|
-
it "
|
|
477
|
+
it "has read groups string accessor" do
|
|
479
478
|
expect(subject.read_groups_string).to eq 'group-6, group-7'
|
|
480
479
|
end
|
|
481
480
|
|
|
482
|
-
it "
|
|
481
|
+
it "has read groups writer" do
|
|
483
482
|
subject.read_groups = ['group-2', 'group-3']
|
|
484
483
|
expect(subject.read_groups).to eq ['group-2', 'group-3']
|
|
485
484
|
end
|
|
486
485
|
|
|
487
|
-
it "
|
|
486
|
+
it "has read groups string writer" do
|
|
488
487
|
subject.read_groups_string = 'umg/up.dlt.staff, group-3'
|
|
489
488
|
expect(subject.read_groups).to eq ['umg/up.dlt.staff', 'group-3']
|
|
490
489
|
expect(subject.edit_groups).to eq ['group-8']
|
|
@@ -492,7 +491,7 @@ describe GenericFile, :type => :model do
|
|
|
492
491
|
expect(subject.edit_users).to eq ['jcoyne']
|
|
493
492
|
end
|
|
494
493
|
|
|
495
|
-
it "
|
|
494
|
+
it "onlies revoke eligible groups" do
|
|
496
495
|
subject.set_read_groups(['group-2', 'group-3'], ['group-6'])
|
|
497
496
|
# 'group-7' is not eligible to be revoked
|
|
498
497
|
expect(subject.read_groups).to match_array ['group-2', 'group-3', 'group-7']
|
|
@@ -520,7 +519,7 @@ describe GenericFile, :type => :model do
|
|
|
520
519
|
end
|
|
521
520
|
context "when public has edit access" do
|
|
522
521
|
before { asset.edit_groups = ['public'] }
|
|
523
|
-
it "
|
|
522
|
+
it "is valid" do
|
|
524
523
|
expect(asset).to be_valid
|
|
525
524
|
end
|
|
526
525
|
end
|
|
@@ -528,9 +527,9 @@ describe GenericFile, :type => :model do
|
|
|
528
527
|
|
|
529
528
|
context "when the depositor does not have edit access" do
|
|
530
529
|
before do
|
|
531
|
-
subject.permissions = [
|
|
530
|
+
subject.permissions = [Hydra::AccessControls::Permission.new(type: 'person', name: 'mjg36', access: 'read')]
|
|
532
531
|
end
|
|
533
|
-
it "
|
|
532
|
+
it "is invalid" do
|
|
534
533
|
expect(subject).to_not be_valid
|
|
535
534
|
expect(subject.errors[:edit_users]).to include('Depositor must have edit access')
|
|
536
535
|
end
|
|
@@ -539,7 +538,7 @@ describe GenericFile, :type => :model do
|
|
|
539
538
|
context "when the public has edit access" do
|
|
540
539
|
before { subject.edit_groups = ['public'] }
|
|
541
540
|
|
|
542
|
-
it "
|
|
541
|
+
it "is invalid" do
|
|
543
542
|
expect(subject).to_not be_valid
|
|
544
543
|
expect(subject.errors[:edit_groups]).to include('Public cannot have edit access')
|
|
545
544
|
end
|
|
@@ -548,14 +547,14 @@ describe GenericFile, :type => :model do
|
|
|
548
547
|
context "when registered has edit access" do
|
|
549
548
|
before { subject.edit_groups = ['registered'] }
|
|
550
549
|
|
|
551
|
-
it "
|
|
550
|
+
it "is invalid" do
|
|
552
551
|
expect(subject).to_not be_valid
|
|
553
552
|
expect(subject.errors[:edit_groups]).to include('Registered cannot have edit access')
|
|
554
553
|
end
|
|
555
554
|
end
|
|
556
555
|
|
|
557
556
|
context "everything is copacetic" do
|
|
558
|
-
it "
|
|
557
|
+
it "is valid" do
|
|
559
558
|
expect(subject).to be_valid
|
|
560
559
|
end
|
|
561
560
|
end
|
|
@@ -580,7 +579,7 @@ describe GenericFile, :type => :model do
|
|
|
580
579
|
it "does not save a new version of a GenericFile" do
|
|
581
580
|
subject.save!
|
|
582
581
|
allow(Sufia::GenericFile::Actor).to receive(:virus_check).and_raise(Sufia::VirusFoundError)
|
|
583
|
-
subject.add_file(File.new(fixture_path + '/sufia_generic_stub.txt')
|
|
582
|
+
subject.add_file(File.new(fixture_path + '/sufia_generic_stub.txt'), path: 'content', original_name: 'sufia_generic_stub.txt')
|
|
584
583
|
subject.save
|
|
585
584
|
expect(subject.reload.content.content).to eq "small\n"
|
|
586
585
|
end
|
|
@@ -590,7 +589,7 @@ describe GenericFile, :type => :model do
|
|
|
590
589
|
describe "to_solr record" do
|
|
591
590
|
let(:depositor) { 'jcoyne' }
|
|
592
591
|
subject do
|
|
593
|
-
|
|
592
|
+
described_class.new.tap do |f|
|
|
594
593
|
f.apply_depositor_metadata(depositor)
|
|
595
594
|
f.save
|
|
596
595
|
end
|
|
@@ -598,13 +597,13 @@ describe GenericFile, :type => :model do
|
|
|
598
597
|
let(:depositor_key) { Solrizer.solr_name("depositor") }
|
|
599
598
|
let(:title_key) { Solrizer.solr_name("title", :stored_searchable, type: :string) }
|
|
600
599
|
let(:title) { ["abc123"] }
|
|
601
|
-
let(:no_terms) {
|
|
602
|
-
let(:terms)
|
|
603
|
-
file =
|
|
600
|
+
let(:no_terms) { described_class.find(subject.id).to_solr }
|
|
601
|
+
let(:terms) do
|
|
602
|
+
file = described_class.find(subject.id)
|
|
604
603
|
file.title = title
|
|
605
604
|
file.save
|
|
606
605
|
file.to_solr
|
|
607
|
-
|
|
606
|
+
end
|
|
608
607
|
|
|
609
608
|
context "without terms" do
|
|
610
609
|
specify "title is nil" do
|
|
@@ -620,7 +619,6 @@ describe GenericFile, :type => :model do
|
|
|
620
619
|
expect(terms[title_key]).to eql(title)
|
|
621
620
|
end
|
|
622
621
|
end
|
|
623
|
-
|
|
624
622
|
end
|
|
625
623
|
|
|
626
624
|
describe "public?" do
|
|
@@ -636,7 +634,7 @@ describe GenericFile, :type => :model do
|
|
|
636
634
|
end
|
|
637
635
|
|
|
638
636
|
describe "find_by_date_created" do
|
|
639
|
-
subject {
|
|
637
|
+
subject { described_class.find_by_date_created(start_date, end_date) }
|
|
640
638
|
|
|
641
639
|
context "with no start date" do
|
|
642
640
|
let(:start_date) { nil }
|
|
@@ -645,8 +643,8 @@ describe GenericFile, :type => :model do
|
|
|
645
643
|
end
|
|
646
644
|
|
|
647
645
|
context "with no end date" do
|
|
648
|
-
let(:start_date) {1.days.ago}
|
|
649
|
-
let(:end_date) {nil}
|
|
646
|
+
let(:start_date) { 1.days.ago }
|
|
647
|
+
let(:end_date) { nil }
|
|
650
648
|
before do
|
|
651
649
|
@file.save
|
|
652
650
|
end
|
|
@@ -664,7 +662,7 @@ describe GenericFile, :type => :model do
|
|
|
664
662
|
end
|
|
665
663
|
|
|
666
664
|
describe "where_access_is" do
|
|
667
|
-
subject {
|
|
665
|
+
subject { described_class.where_access_is access_level }
|
|
668
666
|
before do
|
|
669
667
|
@file.read_groups = read_groups
|
|
670
668
|
@file.save
|
|
@@ -674,64 +672,64 @@ describe GenericFile, :type => :model do
|
|
|
674
672
|
let(:read_groups) { ["private"] }
|
|
675
673
|
context "when access level is private" do
|
|
676
674
|
let(:access_level) { 'private' }
|
|
677
|
-
it { is_expected.to eq [@file]}
|
|
675
|
+
it { is_expected.to eq [@file] }
|
|
678
676
|
end
|
|
679
677
|
context "when access level is public" do
|
|
680
678
|
let(:access_level) { 'public' }
|
|
681
|
-
it { is_expected.to eq []}
|
|
679
|
+
it { is_expected.to eq [] }
|
|
682
680
|
end
|
|
683
681
|
context "when access level is registered" do
|
|
684
682
|
let(:access_level) { 'registered' }
|
|
685
|
-
it { is_expected.to eq []}
|
|
683
|
+
it { is_expected.to eq [] }
|
|
686
684
|
end
|
|
687
685
|
end
|
|
688
686
|
context "when file is public" do
|
|
689
687
|
let(:read_groups) { ["public"] }
|
|
690
688
|
context "when access level is private" do
|
|
691
689
|
let(:access_level) { 'private' }
|
|
692
|
-
it { is_expected.to eq []}
|
|
690
|
+
it { is_expected.to eq [] }
|
|
693
691
|
end
|
|
694
692
|
context "when access level is public" do
|
|
695
693
|
let(:access_level) { 'public' }
|
|
696
|
-
it { is_expected.to eq [@file]}
|
|
694
|
+
it { is_expected.to eq [@file] }
|
|
697
695
|
end
|
|
698
696
|
context "when access level is registered" do
|
|
699
697
|
let(:access_level) { 'registered' }
|
|
700
|
-
it { is_expected.to eq []}
|
|
698
|
+
it { is_expected.to eq [] }
|
|
701
699
|
end
|
|
702
700
|
end
|
|
703
701
|
context "when file is registered" do
|
|
704
702
|
let(:read_groups) { ["registered"] }
|
|
705
703
|
context "when access level is private" do
|
|
706
704
|
let(:access_level) { 'private' }
|
|
707
|
-
it { is_expected.to eq []}
|
|
705
|
+
it { is_expected.to eq [] }
|
|
708
706
|
end
|
|
709
707
|
context "when access level is public" do
|
|
710
|
-
let(:access_level) {'public'}
|
|
711
|
-
it { is_expected.to eq []}
|
|
708
|
+
let(:access_level) { 'public' }
|
|
709
|
+
it { is_expected.to eq [] }
|
|
712
710
|
end
|
|
713
711
|
context "when access level is registered" do
|
|
714
712
|
let(:access_level) { 'registered' }
|
|
715
|
-
it { is_expected.to eq [@file]}
|
|
713
|
+
it { is_expected.to eq [@file] }
|
|
716
714
|
end
|
|
717
715
|
end
|
|
718
716
|
end
|
|
719
717
|
describe "where_private" do
|
|
720
718
|
it "calls where_access_is with private" do
|
|
721
|
-
expect(
|
|
722
|
-
|
|
719
|
+
expect(described_class).to receive(:where_access_is).with('private')
|
|
720
|
+
described_class.where_private
|
|
723
721
|
end
|
|
724
722
|
end
|
|
725
723
|
describe "where_registered" do
|
|
726
724
|
it "calls where_access_is with registered" do
|
|
727
|
-
expect(
|
|
728
|
-
|
|
725
|
+
expect(described_class).to receive(:where_access_is).with('registered')
|
|
726
|
+
described_class.where_registered
|
|
729
727
|
end
|
|
730
728
|
end
|
|
731
729
|
describe "where_public" do
|
|
732
730
|
it "calls where_access_is with public" do
|
|
733
|
-
expect(
|
|
734
|
-
|
|
731
|
+
expect(described_class).to receive(:where_access_is).with('public')
|
|
732
|
+
described_class.where_public
|
|
735
733
|
end
|
|
736
734
|
end
|
|
737
735
|
end
|