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,10 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe GeoNamesResource, :
|
4
|
-
|
5
|
-
|
6
|
-
hits = GeoNamesResource.find_location("State")
|
3
|
+
describe GeoNamesResource, type: :model do
|
4
|
+
it "finds locations" do
|
5
|
+
hits = described_class.find_location("State")
|
7
6
|
expect(hits).not_to be_nil
|
8
7
|
end
|
9
8
|
end
|
10
|
-
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe LocalAuthority, :
|
4
|
-
|
3
|
+
describe LocalAuthority, type: :model do
|
5
4
|
def harvest_nt
|
6
5
|
LocalAuthority.harvest_rdf("genres", [fixture_path + '/genreForms.nt'])
|
7
6
|
end
|
@@ -18,29 +17,28 @@ describe LocalAuthority, :type => :model do
|
|
18
17
|
Object.send(:remove_const, :MyTestRdfDatastream)
|
19
18
|
end
|
20
19
|
|
21
|
-
it "
|
20
|
+
it "harvests an ntriples RDF vocab" do
|
22
21
|
harvest_nt
|
23
|
-
expect(
|
22
|
+
expect(described_class.count).to eq(1)
|
24
23
|
expect(LocalAuthorityEntry.count).to eq(6)
|
25
24
|
end
|
26
|
-
it "
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
expect(
|
25
|
+
it "harvests an RDF/XML vocab (w/ an alt predicate)" do
|
26
|
+
described_class.harvest_rdf("langs", [fixture_path + '/lexvo.rdf'],
|
27
|
+
format: 'rdfxml',
|
28
|
+
predicate: ::RDF::URI("http://www.w3.org/2008/05/skos#prefLabel"))
|
29
|
+
expect(described_class.count).to eq(1)
|
31
30
|
expect(LocalAuthorityEntry.count).to eq(35)
|
32
31
|
end
|
33
|
-
it "
|
32
|
+
it "harvests TSV vocabs" do
|
34
33
|
harvest_tsv
|
35
|
-
expect(
|
36
|
-
auth =
|
34
|
+
expect(described_class.count).to eq(1)
|
35
|
+
auth = described_class.where(name: "geo").first
|
37
36
|
expect(LocalAuthorityEntry.where(local_authority_id: auth.id).first.uri).to start_with('http://sws.geonames.org/')
|
38
37
|
expect(LocalAuthorityEntry.count).to eq(149)
|
39
38
|
end
|
40
39
|
|
41
40
|
describe "when vocabs are harvested" do
|
42
|
-
|
43
|
-
let(:num_auths) { LocalAuthority.count }
|
41
|
+
let(:num_auths) { described_class.count }
|
44
42
|
let(:num_entries) { LocalAuthorityEntry.count }
|
45
43
|
|
46
44
|
before do
|
@@ -48,50 +46,49 @@ describe LocalAuthority, :type => :model do
|
|
48
46
|
harvest_tsv
|
49
47
|
end
|
50
48
|
|
51
|
-
it "
|
49
|
+
it "does not have any initial domain terms" do
|
52
50
|
expect(DomainTerm.count).to eq(0)
|
53
51
|
end
|
54
52
|
|
55
|
-
it "
|
53
|
+
it "does not harvest an RDF vocab twice" do
|
56
54
|
harvest_nt
|
57
|
-
expect(
|
55
|
+
expect(described_class.count).to eq(num_auths)
|
58
56
|
expect(LocalAuthorityEntry.count).to eq(num_entries)
|
59
57
|
end
|
60
|
-
it "
|
58
|
+
it "does not harvest a TSV vocab twice" do
|
61
59
|
harvest_tsv
|
62
|
-
expect(
|
60
|
+
expect(described_class.count).to eq(num_auths)
|
63
61
|
expect(LocalAuthorityEntry.count).to eq(num_entries)
|
64
62
|
end
|
65
|
-
it "
|
66
|
-
|
63
|
+
it "registers a vocab" do
|
64
|
+
described_class.register_vocabulary(MyTestRdfDatastream, "geographic", "geo")
|
67
65
|
expect(DomainTerm.count).to eq(1)
|
68
66
|
end
|
69
67
|
|
70
68
|
describe "when vocabs are registered" do
|
71
|
-
|
72
69
|
before do
|
73
|
-
|
74
|
-
|
70
|
+
described_class.register_vocabulary(MyTestRdfDatastream, "geographic", "geo")
|
71
|
+
described_class.register_vocabulary(MyTestRdfDatastream, "genre", "genres")
|
75
72
|
end
|
76
73
|
|
77
|
-
it "
|
74
|
+
it "has some doamin terms" do
|
78
75
|
expect(DomainTerm.count).to eq(2)
|
79
76
|
end
|
80
77
|
|
81
|
-
it "
|
82
|
-
expect(
|
78
|
+
it "returns nil for empty queries" do
|
79
|
+
expect(described_class.entries_by_term("my_test", "geographic", "")).to be_nil
|
83
80
|
end
|
84
|
-
it "
|
85
|
-
expect(
|
81
|
+
it "returns an empty array for unregistered models" do
|
82
|
+
expect(described_class.entries_by_term("my_foobar", "geographic", "E")).to eq([])
|
86
83
|
end
|
87
|
-
it "
|
88
|
-
expect(
|
84
|
+
it "returns an empty array for unregistered terms" do
|
85
|
+
expect(described_class.entries_by_term("my_test", "foobar", "E")).to eq([])
|
89
86
|
end
|
90
|
-
it "
|
87
|
+
it "returns entries by term" do
|
91
88
|
term = DomainTerm.where(model: "my_tests", term: "genre").first
|
92
89
|
authorities = term.local_authorities.collect(&:id).uniq
|
93
90
|
LocalAuthorityEntry.where("local_authority_id in (?)", authorities).where("label like ?", "A%").select("label, uri").limit(25)
|
94
|
-
expect(
|
91
|
+
expect(described_class.entries_by_term("my_tests", "genre", "A").count).to eq(6)
|
95
92
|
end
|
96
93
|
end
|
97
94
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Sufia::Pageview, :
|
3
|
+
describe Sufia::Pageview, type: :model do
|
4
4
|
before do
|
5
|
-
@pageview =
|
5
|
+
@pageview = described_class
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'has a pageviews metric' do
|
9
|
-
expect(@pageview.metrics).to be
|
9
|
+
expect(@pageview.metrics).to be == Legato::ListParameter.new(:metrics, [:pageviews])
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'has a date dimension' do
|
@@ -13,8 +13,8 @@ describe ProxyDepositRequest, type: :model do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
subject do
|
16
|
-
|
17
|
-
|
16
|
+
described_class.new(generic_file_id: file.id, sending_user: sender,
|
17
|
+
receiving_user: receiver, sender_comment: "please take this")
|
18
18
|
end
|
19
19
|
|
20
20
|
its(:status) { is_expected.to eq 'pending' }
|
@@ -92,7 +92,7 @@ describe ProxyDepositRequest, type: :model do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
context 'when the file is already being transferred' do
|
95
|
-
let(:subject2) {
|
95
|
+
let(:subject2) { described_class.new(generic_file_id: file.id, sending_user: sender, receiving_user: receiver2, sender_comment: 'please take this') }
|
96
96
|
|
97
97
|
it 'raises an error' do
|
98
98
|
subject.save!
|
@@ -10,56 +10,56 @@ describe SingleUseLink do
|
|
10
10
|
let(:file) { @file }
|
11
11
|
|
12
12
|
describe "create" do
|
13
|
-
|
13
|
+
before do
|
14
14
|
@now = DateTime.now
|
15
15
|
allow(DateTime).to receive(:now).and_return(@now)
|
16
|
-
@hash = "sha2hash#{@now.to_f
|
16
|
+
@hash = "sha2hash#{@now.to_f}"
|
17
17
|
expect(Digest::SHA2).to receive(:new).and_return(@hash)
|
18
|
-
|
19
|
-
|
20
|
-
su =
|
18
|
+
end
|
19
|
+
it "creates show link" do
|
20
|
+
su = described_class.create itemId: file.id, path: Sufia::Engine.routes.url_helpers.generic_file_path(file.id)
|
21
21
|
expect(su.downloadKey).to eq(@hash)
|
22
22
|
expect(su.itemId).to eq(file.id)
|
23
23
|
expect(su.path).to eq(Sufia::Engine.routes.url_helpers.generic_file_path(file.id))
|
24
24
|
su.delete
|
25
|
-
|
26
|
-
|
27
|
-
su =
|
25
|
+
end
|
26
|
+
it "creates show download link" do
|
27
|
+
su = described_class.create itemId: file.id, path: Sufia::Engine.routes.url_helpers.download_path(file.id)
|
28
28
|
expect(su.downloadKey).to eq(@hash)
|
29
29
|
expect(su.itemId).to eq(file.id)
|
30
30
|
expect(su.path).to eq(Sufia::Engine.routes.url_helpers.download_path(file.id))
|
31
31
|
su.delete
|
32
|
-
|
32
|
+
end
|
33
33
|
end
|
34
34
|
describe "find" do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
35
|
+
describe "not expired" do
|
36
|
+
before do
|
37
|
+
@su = described_class.create(downloadKey: 'sha2hashb', itemId: file.id, path: Sufia::Engine.routes.url_helpers.download_path(file), expires: DateTime.now.advance(hours: 1))
|
38
|
+
end
|
39
|
+
it "retrieves link" do
|
40
|
+
link = described_class.where(downloadKey: 'sha2hashb').first
|
41
|
+
expect(link.itemId).to eq(file.id)
|
42
|
+
end
|
43
|
+
it "retrieves link with find_by" do
|
44
|
+
link = described_class.find_by_downloadKey('sha2hashb')
|
45
|
+
expect(link.itemId).to eq(file.id)
|
46
|
+
end
|
47
|
+
it "expires link" do
|
48
|
+
link = described_class.where(downloadKey: 'sha2hashb').first
|
49
|
+
expect(link.expired?).to eq(false)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
describe "expired" do
|
53
|
+
before do
|
54
|
+
@su = described_class.create!(downloadKey: 'sha2hashb', itemId: file.id, path: Sufia::Engine.routes.url_helpers.download_path(file))
|
55
55
|
|
56
|
-
|
57
|
-
|
56
|
+
@su.update_attribute :expires, DateTime.now.advance(hours: -1)
|
57
|
+
end
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
it "expires link" do
|
60
|
+
link = described_class.where(downloadKey: 'sha2hashb').first
|
61
|
+
expect(link.expired?).to eq(true)
|
62
|
+
end
|
63
|
+
end
|
64
64
|
end
|
65
65
|
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SolrDocument, type: :model do
|
4
|
-
|
5
4
|
describe "date_uploaded" do
|
6
5
|
before do
|
7
6
|
subject['date_uploaded_dtsi'] = '2013-03-14T00:00:00Z'
|
8
7
|
end
|
9
|
-
it "
|
8
|
+
it "is a date" do
|
10
9
|
expect(subject.date_uploaded).to eq '03/14/2013'
|
11
10
|
end
|
12
11
|
end
|
@@ -29,7 +28,7 @@ describe SolrDocument, type: :model do
|
|
29
28
|
end
|
30
29
|
|
31
30
|
context "when mime-type is 'office'" do
|
32
|
-
it "
|
31
|
+
it "is office document" do
|
33
32
|
Mimes.office_document_mime_types.each do |type|
|
34
33
|
subject['mime_type_tesim'] = [type]
|
35
34
|
expect(subject).to be_office_document
|
@@ -38,14 +37,12 @@ describe SolrDocument, type: :model do
|
|
38
37
|
end
|
39
38
|
|
40
39
|
describe "when mime-type is 'video'" do
|
41
|
-
it "
|
40
|
+
it "is office" do
|
42
41
|
Mimes.video_mime_types.each do |type|
|
43
42
|
subject['mime_type_tesim'] = [type]
|
44
43
|
expect(subject).to be_video
|
45
44
|
end
|
46
45
|
end
|
47
46
|
end
|
48
|
-
|
49
47
|
end
|
50
|
-
|
51
48
|
end
|
data/spec/models/trophy_spec.rb
CHANGED
@@ -1,24 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Trophy, :
|
3
|
+
describe Trophy, type: :model do
|
4
4
|
before(:all) do
|
5
|
-
@trophy =
|
5
|
+
@trophy = described_class.create(user_id: 99, generic_file_id: "99")
|
6
6
|
end
|
7
7
|
|
8
|
-
it "
|
8
|
+
it "has a user" do
|
9
9
|
expect(@trophy).to respond_to(:user_id)
|
10
10
|
expect(@trophy.user_id).to eq(99)
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
13
|
+
it "has a file" do
|
14
14
|
expect(@trophy).to respond_to(:generic_file_id)
|
15
15
|
expect(@trophy.generic_file_id).to eq("99")
|
16
16
|
end
|
17
17
|
|
18
|
-
it "
|
19
|
-
(1..6).each { |n|
|
20
|
-
expect(
|
21
|
-
|
18
|
+
it "does not allow six trophies" do
|
19
|
+
(1..6).each { |n| described_class.create(user_id: 120, generic_file_id: n.to_s) }
|
20
|
+
expect(described_class.where(user_id: 120).count).to eq(5)
|
21
|
+
described_class.where(user_id: 120).map(&:delete)
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe UserMailbox do
|
4
|
+
let(:user) { FactoryGirl.find_or_create(:jill) }
|
5
|
+
let(:another_user) { FactoryGirl.find_or_create(:archivist) }
|
6
|
+
before do
|
7
|
+
another_user.send_message(user, "Test Message", "Test Subject")
|
8
|
+
user.send_message(another_user, "Test Message", "Test Subject")
|
9
|
+
end
|
10
|
+
|
11
|
+
subject { described_class.new(user) }
|
12
|
+
|
13
|
+
describe "#inbox" do
|
14
|
+
subject { described_class.new(user).inbox.first.last_message }
|
15
|
+
it "has mail" do
|
16
|
+
expect(subject.body).to eq('Test Message')
|
17
|
+
expect(subject.subject).to eq('Test Subject')
|
18
|
+
expect(user.mailbox.inbox(unread: true).count).to eq(0)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#delete_all" do
|
23
|
+
before do
|
24
|
+
another_user.send_message(user, 'message 2', 'subject 2')
|
25
|
+
another_user.send_message(user, 'message 3', 'subject 3')
|
26
|
+
end
|
27
|
+
it "deletes all messages" do
|
28
|
+
expect(user.mailbox.inbox.count).to eq(3)
|
29
|
+
subject.delete_all
|
30
|
+
expect(user.mailbox.inbox.count).to eq(0)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#delete" do
|
35
|
+
let(:rec) { another_user.send_message(user, 'message 2', 'subject 2') }
|
36
|
+
let!(:message_id) { rec.conversation.id }
|
37
|
+
|
38
|
+
it "deletes a message" do
|
39
|
+
subject.destroy message_id
|
40
|
+
expect { Mailboxer::Conversation.find(message_id) }.to raise_error(ActiveRecord::RecordNotFound)
|
41
|
+
end
|
42
|
+
|
43
|
+
context "non-existing conversation" do
|
44
|
+
let!(:message_id) { -99 }
|
45
|
+
it "raises an error" do
|
46
|
+
expect { subject.destroy message_id }.to raise_error(ActiveRecord::RecordNotFound)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "deleting a message from a third party" do
|
51
|
+
let(:curator) { FactoryGirl.find_or_create(:curator) }
|
52
|
+
let(:message) { another_user.send_message(curator, 'message 3', 'subject 3') }
|
53
|
+
let!(:message_id) { message.conversation.id }
|
54
|
+
|
55
|
+
it "does not delete the message" do
|
56
|
+
subject.destroy message_id
|
57
|
+
expect(subject.destroy(message_id)).to eq "You do not have privileges to delete the notification..."
|
58
|
+
expect(Mailboxer::Conversation.find(message_id).id).to eq message_id
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/spec/models/user_spec.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe User, :
|
3
|
+
describe User, type: :model do
|
4
4
|
let(:user) { FactoryGirl.build(:user) }
|
5
5
|
let(:another_user) { FactoryGirl.build(:user) }
|
6
6
|
|
7
|
-
it "
|
7
|
+
it "has an email" do
|
8
8
|
expect(user.user_key).to be_kind_of String
|
9
9
|
end
|
10
|
-
it "
|
10
|
+
it "has activity stream-related methods defined" do
|
11
11
|
expect(user).to respond_to(:stream)
|
12
12
|
expect(user).to respond_to(:events)
|
13
13
|
expect(user).to respond_to(:profile_events)
|
@@ -15,7 +15,7 @@ describe User, :type => :model do
|
|
15
15
|
expect(user).to respond_to(:log_event)
|
16
16
|
expect(user).to respond_to(:log_profile_event)
|
17
17
|
end
|
18
|
-
it "
|
18
|
+
it "has social attributes" do
|
19
19
|
expect(user).to respond_to(:twitter_handle)
|
20
20
|
expect(user).to respond_to(:facebook_handle)
|
21
21
|
expect(user).to respond_to(:googleplus_handle)
|
@@ -25,7 +25,7 @@ describe User, :type => :model do
|
|
25
25
|
|
26
26
|
describe 'Arkivo and Zotero integration' do
|
27
27
|
it 'sets an Arkivo token after_initialize if API is enabled' do
|
28
|
-
expect(
|
28
|
+
expect(described_class.new).to respond_to(:arkivo_token)
|
29
29
|
end
|
30
30
|
|
31
31
|
describe 'Arkivo token generation' do
|
@@ -37,9 +37,9 @@ describe User, :type => :model do
|
|
37
37
|
let(:token2) { 'token2' }
|
38
38
|
|
39
39
|
it 'generates a new token if a user is found with the existing token' do
|
40
|
-
user1 =
|
40
|
+
user1 = described_class.create(email: 'foo@example.org', password: 'foobarbaz')
|
41
41
|
expect(user1.arkivo_token).to eq token1
|
42
|
-
user2 =
|
42
|
+
user2 = described_class.create(email: 'bar@example.org', password: 'bazquuxquuux')
|
43
43
|
expect(user2.arkivo_token).to eq token2
|
44
44
|
end
|
45
45
|
end
|
@@ -49,7 +49,7 @@ describe User, :type => :model do
|
|
49
49
|
|
50
50
|
it 'has a custom getter/setter for Zotero request tokens' do
|
51
51
|
user.zotero_token = token
|
52
|
-
expect(user.read_attribute(:zotero_token)).to eq Marshal
|
52
|
+
expect(user.read_attribute(:zotero_token)).to eq Marshal.dump(token)
|
53
53
|
expect(user.zotero_token).to eq token
|
54
54
|
end
|
55
55
|
end
|
@@ -84,17 +84,17 @@ describe User, :type => :model do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
describe "#to_param" do
|
87
|
-
let(:user) {
|
87
|
+
let(:user) { described_class.new(email: 'jilluser@example.com') }
|
88
88
|
|
89
|
-
it "
|
89
|
+
it "overrides to_param to make keys more recognizable in redis (and useable within Rails URLs)" do
|
90
90
|
expect(user.to_param).to eq("jilluser@example-dot-com")
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
it "
|
94
|
+
it "has a cancan ability defined" do
|
95
95
|
expect(user).to respond_to(:can?)
|
96
96
|
end
|
97
|
-
it "
|
97
|
+
it "does not have any followers" do
|
98
98
|
expect(user.followers_count).to eq(0)
|
99
99
|
expect(another_user.follow_count).to eq(0)
|
100
100
|
end
|
@@ -105,13 +105,13 @@ describe User, :type => :model do
|
|
105
105
|
user.follow(another_user)
|
106
106
|
end
|
107
107
|
|
108
|
-
it "
|
108
|
+
it "is able to follow another user" do
|
109
109
|
expect(user).to be_following(another_user)
|
110
110
|
expect(another_user).to_not be_following(user)
|
111
111
|
expect(another_user).to be_followed_by(user)
|
112
112
|
expect(user).to_not be_followed_by(another_user)
|
113
113
|
end
|
114
|
-
it "
|
114
|
+
it "is able to unfollow another user" do
|
115
115
|
user.stop_following(another_user)
|
116
116
|
expect(user).to_not be_following(another_user)
|
117
117
|
expect(another_user).to_not be_followed_by(user)
|
@@ -127,21 +127,20 @@ describe User, :type => :model do
|
|
127
127
|
let!(:trophy2) { user.trophies.create!(generic_file_id: file2.id) }
|
128
128
|
let!(:trophy3) { user.trophies.create!(generic_file_id: file3.id) }
|
129
129
|
|
130
|
-
it "
|
130
|
+
it "returns a list of generic files" do
|
131
131
|
expect(user.trophy_files).to eq [file1, file2, file3]
|
132
132
|
end
|
133
|
-
|
134
133
|
end
|
135
134
|
|
136
135
|
describe "activity streams" do
|
137
136
|
let(:now) { DateTime.now.to_i }
|
138
|
-
let(:activities)
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
let(:file_activities)
|
137
|
+
let(:activities) do
|
138
|
+
[{ action: 'so and so edited their profile', timestamp: now },
|
139
|
+
{ action: 'so and so uploaded a file', timestamp: (now - 360) }]
|
140
|
+
end
|
141
|
+
let(:file_activities) do
|
143
142
|
[{ action: 'uploaded a file', timestamp: now + 1 }]
|
144
|
-
|
143
|
+
end
|
145
144
|
|
146
145
|
before do
|
147
146
|
allow(user).to receive(:events).and_return(activities)
|
@@ -149,11 +148,11 @@ describe User, :type => :model do
|
|
149
148
|
end
|
150
149
|
|
151
150
|
it "gathers the user's recent activity within the default amount of time" do
|
152
|
-
expect(user.
|
151
|
+
expect(user.all_user_activity).to eq(file_activities.concat(activities))
|
153
152
|
end
|
154
153
|
|
155
154
|
it "gathers the user's recent activity within a given timestamp" do
|
156
|
-
expect(user.
|
155
|
+
expect(user.all_user_activity(now - 60)).to eq(file_activities.concat([activities.first]))
|
157
156
|
end
|
158
157
|
end
|
159
158
|
describe "proxy_deposit_rights" do
|
@@ -174,23 +173,23 @@ describe User, :type => :model do
|
|
174
173
|
end
|
175
174
|
describe "class methods" do
|
176
175
|
describe "recent_users" do
|
177
|
-
let(:new_users) {
|
176
|
+
let(:new_users) { described_class.all.order(created_at: :desc) }
|
178
177
|
|
179
178
|
before do
|
180
|
-
(1..3).each {|i|
|
179
|
+
(1..3).each { |i| described_class.create(email: "abc#{i}@blah.frg", password: "blarg1234", created_at: DateTime.now - i.days) }
|
181
180
|
end
|
182
181
|
|
183
182
|
context "when has a start date" do
|
184
|
-
subject {
|
183
|
+
subject { described_class.recent_users(Date.today - 2.days) }
|
185
184
|
it "returns valid data" do
|
186
185
|
expect(subject.count).to eq 2
|
187
|
-
is_expected.to include(new_users[0],new_users[1])
|
186
|
+
is_expected.to include(new_users[0], new_users[1])
|
188
187
|
is_expected.not_to include(new_users[2])
|
189
188
|
end
|
190
189
|
end
|
191
190
|
|
192
191
|
context "when has start and end date" do
|
193
|
-
subject {
|
192
|
+
subject { described_class.recent_users(Date.today - 2.days, Date.today - 1.days) }
|
194
193
|
it "returns valid data" do
|
195
194
|
expect(subject.count).to eq 1
|
196
195
|
is_expected.to include(new_users[1])
|