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
|
@@ -60,13 +60,14 @@ describe API::ZoteroController, type: :controller do
|
|
|
60
60
|
|
|
61
61
|
let(:token) { object_double(OAuth::RequestToken.new(client), authorize_url: 'https://www.zotero.org/oauth/authorize?identity=1&oauth_callback=http%3A%2F%2Ftest.host%2Fapi%2Fzotero%2Fcallback&oauth_token=bc2502f2750983c57224') }
|
|
62
62
|
let(:client) do
|
|
63
|
-
OAuth::Consumer.new(Sufia::Zotero.config['client_key'],
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
OAuth::Consumer.new(Sufia::Zotero.config['client_key'],
|
|
64
|
+
Sufia::Zotero.config['client_secret'],
|
|
65
|
+
site: 'https://www.zotero.org',
|
|
66
|
+
scheme: :query_string,
|
|
67
|
+
http_method: :get,
|
|
68
|
+
request_token_path: '/oauth/request',
|
|
69
|
+
access_token_path: '/oauth/access',
|
|
70
|
+
authorize_path: '/oauth/authorize')
|
|
70
71
|
end
|
|
71
72
|
|
|
72
73
|
subject { response }
|
|
@@ -151,8 +152,8 @@ describe API::ZoteroController, type: :controller do
|
|
|
151
152
|
let(:pin) { '12345' }
|
|
152
153
|
let(:user_token) do
|
|
153
154
|
double('token',
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
params: { oauth_token: token_string },
|
|
156
|
+
get_access_token: access_token)
|
|
156
157
|
end
|
|
157
158
|
let(:zuserid) { 'myzuser' }
|
|
158
159
|
let(:access_token) do
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe AuthoritiesController, :
|
|
3
|
+
describe AuthoritiesController, type: :controller do
|
|
4
4
|
describe "#query" do
|
|
5
|
-
it "
|
|
6
|
-
mock_hits = [{label: "English", uri: "http://example.org/eng"},
|
|
7
|
-
{label: "Environment", uri: "http://example.org/env"},
|
|
8
|
-
{label: "Edge", uri: "http://example.org/edge"},
|
|
9
|
-
{label: "Edgar", uri: "http://example.org/edga"},
|
|
10
|
-
{label: "Eddie", uri: "http://example.org/edd"},
|
|
11
|
-
{label: "Economics", uri: "http://example.org/eco"}]
|
|
5
|
+
it "returns an array of hashes" do
|
|
6
|
+
mock_hits = [{ label: "English", uri: "http://example.org/eng" },
|
|
7
|
+
{ label: "Environment", uri: "http://example.org/env" },
|
|
8
|
+
{ label: "Edge", uri: "http://example.org/edge" },
|
|
9
|
+
{ label: "Edgar", uri: "http://example.org/edga" },
|
|
10
|
+
{ label: "Eddie", uri: "http://example.org/edd" },
|
|
11
|
+
{ label: "Economics", uri: "http://example.org/eco" }]
|
|
12
12
|
expect(LocalAuthority).to receive(:entries_by_term).and_return(mock_hits)
|
|
13
13
|
xhr :get, :query, model: "generic_files", term: "subject", q: "E"
|
|
14
14
|
expect(response).to be_success
|
|
@@ -11,64 +11,63 @@ describe BatchController do
|
|
|
11
11
|
let(:batch) { Batch.create }
|
|
12
12
|
context "enquing a batch job" do
|
|
13
13
|
before do
|
|
14
|
-
allow(BatchUpdateJob).to receive(:new).with(user.user_key, batch.id, {'1' => 'foo'},
|
|
15
|
-
|
|
14
|
+
allow(BatchUpdateJob).to receive(:new).with(user.user_key, batch.id, { '1' => 'foo' },
|
|
15
|
+
{ tag: [] }, 'open').and_return(batch_update_message)
|
|
16
16
|
end
|
|
17
|
-
it "
|
|
17
|
+
it "is successful" do
|
|
18
18
|
expect(Sufia.queue).to receive(:push).with(batch_update_message).once
|
|
19
|
-
post :update, id: batch.id, title: {'1' => 'foo'}, visibility: 'open', generic_file: { tag: [""] }
|
|
19
|
+
post :update, id: batch.id, title: { '1' => 'foo' }, visibility: 'open', generic_file: { tag: [""] }
|
|
20
20
|
expect(response).to redirect_to routes.url_helpers.dashboard_files_path
|
|
21
21
|
expect(flash[:notice]).to include("Your files are being processed")
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
describe "when submiting files on behalf of another user" do
|
|
26
|
-
let(:somebody_else_file) do
|
|
26
|
+
let(:somebody_else_file) do
|
|
27
27
|
f = GenericFile.create(title: ['Original Title']) { |gf| gf.apply_depositor_metadata('current_user') }
|
|
28
28
|
f.on_behalf_of = 'somebody@else.org'
|
|
29
29
|
f.save!
|
|
30
30
|
f
|
|
31
|
-
end
|
|
31
|
+
end
|
|
32
32
|
let(:batch) { Batch.create { |b| b.generic_files.push(somebody_else_file) } }
|
|
33
|
-
it "
|
|
34
|
-
post :update, id: batch, "generic_file"=>{"permissions_attributes"=>[{"type" => "group", "name" => "public", "access" => "read"}]}
|
|
33
|
+
it "goes to my shares page" do
|
|
34
|
+
post :update, id: batch, "generic_file" => { "permissions_attributes" => [{ "type" => "group", "name" => "public", "access" => "read" }] }
|
|
35
35
|
expect(response).to redirect_to routes.url_helpers.dashboard_shares_path
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
|
|
40
39
|
describe "when user has edit permissions on a file" do
|
|
41
|
-
# TODO all these tests could move to batch_update_job_spec.rb
|
|
40
|
+
# TODO: all these tests could move to batch_update_job_spec.rb
|
|
42
41
|
let!(:file) { GenericFile.create(batch: batch) { |f| f.apply_depositor_metadata(user) } }
|
|
43
42
|
|
|
44
|
-
it "
|
|
45
|
-
post :update, id: batch, "generic_file"=>{"permissions_attributes"=>[{"type" => "group", "name" => "public", "access" => "read"}]}
|
|
43
|
+
it "sets the groups" do
|
|
44
|
+
post :update, id: batch, "generic_file" => { "permissions_attributes" => [{ "type" => "group", "name" => "public", "access" => "read" }] }
|
|
46
45
|
file.reload
|
|
47
46
|
expect(file.read_groups).to include "public"
|
|
48
47
|
expect(response).to redirect_to routes.url_helpers.dashboard_files_path
|
|
49
48
|
end
|
|
50
49
|
|
|
51
|
-
it "
|
|
50
|
+
it "sets public read access" do
|
|
52
51
|
post :update, id: batch, visibility: "open", generic_file: { tag: [""] }
|
|
53
52
|
expect(file.reload.read_groups).to eq ['public']
|
|
54
53
|
end
|
|
55
54
|
|
|
56
|
-
it "
|
|
55
|
+
it "sets metadata like title" do
|
|
57
56
|
post :update, id: batch, generic_file: { tag: ["footag", "bartag"] }, title: { file.id => ["New Title"] }
|
|
58
57
|
file.reload
|
|
59
58
|
expect(file.title).to eq ["New Title"]
|
|
60
|
-
# TODO is order important?
|
|
59
|
+
# TODO: is order important?
|
|
61
60
|
expect(file.tag).to include("footag", "bartag")
|
|
62
61
|
end
|
|
63
62
|
|
|
64
|
-
it "
|
|
63
|
+
it "does not set any tags" do
|
|
65
64
|
post :update, id: batch, generic_file: { tag: [""] }
|
|
66
65
|
expect(file.reload.tag).to be_empty
|
|
67
66
|
end
|
|
68
67
|
end
|
|
69
68
|
|
|
70
69
|
describe "when user does not have edit permissions on a file" do
|
|
71
|
-
# TODO all these tests could move to batch_update_job_spec.rb
|
|
70
|
+
# TODO: all these tests could move to batch_update_job_spec.rb
|
|
72
71
|
let(:file) do
|
|
73
72
|
GenericFile.new(batch: batch, title: ['Original Title']).tap do |f|
|
|
74
73
|
f.apply_depositor_metadata('someone_else')
|
|
@@ -76,8 +75,8 @@ describe BatchController do
|
|
|
76
75
|
end
|
|
77
76
|
end
|
|
78
77
|
|
|
79
|
-
it "
|
|
80
|
-
post :update, id: batch, "generic_file"=>{"read_groups_string"=>"group1, group2", "read_users_string"=>"", "tag"=>[""]}, "title"=>{file.id=>"Title Wont Change"}
|
|
78
|
+
it "does not modify the object" do
|
|
79
|
+
post :update, id: batch, "generic_file" => { "read_groups_string" => "group1, group2", "read_users_string" => "", "tag" => [""] }, "title" => { file.id => "Title Wont Change" }
|
|
81
80
|
file.reload
|
|
82
81
|
expect(file.title).to eq ["Original Title"]
|
|
83
82
|
expect(file.read_groups).to eq []
|
|
@@ -93,7 +92,7 @@ describe BatchController do
|
|
|
93
92
|
let!(:file) { GenericFile.create(batch: b1, label: 'f1') { |f| f.apply_depositor_metadata(user) } }
|
|
94
93
|
let!(:file2) { GenericFile.create(batch: b1, label: 'f2') { |f| f.apply_depositor_metadata(user) } }
|
|
95
94
|
|
|
96
|
-
it "
|
|
95
|
+
it "defaults creator" do
|
|
97
96
|
get :edit, id: b1
|
|
98
97
|
expect(assigns[:form]).not_to be_persisted
|
|
99
98
|
expect(assigns[:form].creator[0]).to eq user.display_name
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe BatchEditsController, :
|
|
3
|
+
describe BatchEditsController, type: :controller do
|
|
4
4
|
before do
|
|
5
5
|
sign_in FactoryGirl.find_or_create(:jill)
|
|
6
6
|
allow_any_instance_of(User).to receive(:groups).and_return([])
|
|
@@ -22,17 +22,17 @@ describe BatchEditsController, :type => :controller do
|
|
|
22
22
|
expect(controller).to receive(:can?).with(:edit, @two.id).and_return(true)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
it "
|
|
25
|
+
it "is successful" do
|
|
26
26
|
get :edit
|
|
27
27
|
expect(response).to be_successful
|
|
28
28
|
expect(assigns[:terms]).to eq [:creator, :contributor, :description, :tag, :rights, :publisher,
|
|
29
|
-
|
|
29
|
+
:date_created, :subject, :language, :identifier, :based_near, :related_url]
|
|
30
30
|
expect(assigns[:generic_file].creator).to eq ["Fred", "Wilma"]
|
|
31
31
|
expect(assigns[:generic_file].publisher).to eq ["Rand McNally"]
|
|
32
32
|
expect(assigns[:generic_file].language).to eq ["en"]
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
it "
|
|
35
|
+
it "sets the breadcrumb trail" do
|
|
36
36
|
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.title'), Sufia::Engine.routes.url_helpers.dashboard_index_path)
|
|
37
37
|
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.my.files'), Sufia::Engine.routes.url_helpers.dashboard_files_path)
|
|
38
38
|
get :edit
|
|
@@ -60,31 +60,30 @@ describe BatchEditsController, :type => :controller do
|
|
|
60
60
|
|
|
61
61
|
let(:mycontroller) { "my/files" }
|
|
62
62
|
|
|
63
|
-
it "
|
|
63
|
+
it "is successful" do
|
|
64
64
|
put :update, update_type: "delete_all"
|
|
65
65
|
expect(response).to redirect_to(Sufia::Engine.routes.url_for(controller: "dashboard", only_path: true))
|
|
66
66
|
expect { GenericFile.find(one.id) }.to raise_error(Ldp::Gone)
|
|
67
67
|
expect { GenericFile.find(two.id) }.to raise_error(Ldp::Gone)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
it "
|
|
70
|
+
it "redirects to the return controller" do
|
|
71
71
|
put :update, update_type: "delete_all", return_controller: mycontroller
|
|
72
72
|
expect(response).to redirect_to(Sufia::Engine.routes.url_for(controller: mycontroller, only_path: true))
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
it "
|
|
75
|
+
it "updates the records" do
|
|
76
76
|
put :update, update_type: "update", generic_file: { subject: ["zzz"] }
|
|
77
77
|
expect(response).to be_redirect
|
|
78
78
|
expect(GenericFile.find(one.id).subject).to eq ["zzz"]
|
|
79
79
|
expect(GenericFile.find(two.id).subject).to eq ["zzz"]
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
it "
|
|
82
|
+
it "updates permissions" do
|
|
83
83
|
put :update, update_type: "update", visibility: "authenticated"
|
|
84
84
|
expect(response).to be_redirect
|
|
85
85
|
expect(GenericFile.find(one.id).visibility).to eq "authenticated"
|
|
86
86
|
expect(GenericFile.find(two.id).visibility).to eq "authenticated"
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
|
-
|
|
90
89
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe CatalogController, :
|
|
3
|
+
describe CatalogController, type: :controller do
|
|
4
4
|
routes { Rails.application.class.routes }
|
|
5
5
|
|
|
6
6
|
let(:user) { FactoryGirl.find_or_create(:jill) }
|
|
@@ -40,7 +40,7 @@ describe CatalogController, :type => :controller do
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
describe "term search" do
|
|
43
|
-
it "
|
|
43
|
+
it "finds records" do
|
|
44
44
|
get :index, q: "pdf", owner: 'all'
|
|
45
45
|
expect(response).to be_success
|
|
46
46
|
expect(response).to render_template('catalog/index')
|
|
@@ -55,7 +55,7 @@ describe CatalogController, :type => :controller do
|
|
|
55
55
|
# TODO: this is not how a facet query is done.
|
|
56
56
|
get :index, q: "{f=contributor_tesim}Contrib1"
|
|
57
57
|
end
|
|
58
|
-
it "
|
|
58
|
+
it "finds facet files" do
|
|
59
59
|
expect(response).to be_success
|
|
60
60
|
expect(response).to render_template('catalog/index')
|
|
61
61
|
expect(assigns(:document_list).count).to eq 1
|
|
@@ -64,10 +64,10 @@ describe CatalogController, :type => :controller do
|
|
|
64
64
|
|
|
65
65
|
context "with collections" do
|
|
66
66
|
before do
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
@collection = Collection.new(title: "my collection", tag: ['rocks'], read_groups: ['public']).tap do |c|
|
|
68
|
+
c.apply_depositor_metadata('mjg36')
|
|
69
|
+
c.save!
|
|
70
|
+
end
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
it "finds collections and files" do
|
|
@@ -76,8 +76,6 @@ describe CatalogController, :type => :controller do
|
|
|
76
76
|
doc_list = assigns(:document_list)
|
|
77
77
|
expect(doc_list.map(&:id)).to match_array [@collection.id, @gf1.id]
|
|
78
78
|
end
|
|
79
|
-
|
|
80
79
|
end
|
|
81
|
-
|
|
82
80
|
end
|
|
83
81
|
end
|
|
@@ -13,7 +13,7 @@ describe CollectionsController do
|
|
|
13
13
|
sign_in user
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
it '
|
|
16
|
+
it 'assigns @collection' do
|
|
17
17
|
get :new
|
|
18
18
|
expect(assigns(:collection)).to be_kind_of(Collection)
|
|
19
19
|
end
|
|
@@ -24,54 +24,53 @@ describe CollectionsController do
|
|
|
24
24
|
sign_in user
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
it "
|
|
28
|
-
expect
|
|
29
|
-
post :create, collection: {title: "My First Collection ", description: "The Description\r\n\r\nand more"}
|
|
30
|
-
|
|
27
|
+
it "creates a Collection" do
|
|
28
|
+
expect do
|
|
29
|
+
post :create, collection: { title: "My First Collection ", description: "The Description\r\n\r\nand more" }
|
|
30
|
+
end.to change { Collection.count }.by(1)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
it "
|
|
34
|
-
expect
|
|
33
|
+
it "removes blank strings from params before creating Collection" do
|
|
34
|
+
expect do
|
|
35
35
|
post :create, collection: {
|
|
36
36
|
title: "My First Collection ", creator: [""] }
|
|
37
|
-
|
|
37
|
+
end.to change { Collection.count }.by(1)
|
|
38
38
|
expect(assigns[:collection].title).to eq("My First Collection ")
|
|
39
39
|
expect(assigns[:collection].creator).to eq([])
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
it "
|
|
42
|
+
it "creates a Collection with files I can access" do
|
|
43
43
|
@asset1 = GenericFile.new(title: ["First of the Assets"])
|
|
44
44
|
@asset1.apply_depositor_metadata(user.user_key)
|
|
45
45
|
@asset1.save
|
|
46
46
|
@asset2 = GenericFile.new(title: ["Second of the Assets"], depositor: user.user_key)
|
|
47
47
|
@asset2.apply_depositor_metadata(user.user_key)
|
|
48
48
|
@asset2.save
|
|
49
|
-
@asset3 = GenericFile.new(title: ["Third of the Assets"], depositor:'abc')
|
|
49
|
+
@asset3 = GenericFile.new(title: ["Third of the Assets"], depositor: 'abc')
|
|
50
50
|
@asset3.apply_depositor_metadata('abc')
|
|
51
51
|
@asset3.save
|
|
52
|
-
expect
|
|
52
|
+
expect do
|
|
53
53
|
post :create, collection: { title: "My own Collection", description: "The Description\r\n\r\nand more" },
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
batch_document_ids: [@asset1.id, @asset2.id, @asset3.id]
|
|
55
|
+
end.to change { Collection.count }.by(1)
|
|
56
56
|
collection = assigns(:collection)
|
|
57
57
|
expect(collection.members).to match_array [@asset1, @asset2]
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
it "
|
|
60
|
+
it "adds docs to the collection if a batch id is provided and add the collection id to the documents in the collection" do
|
|
61
61
|
@asset1 = GenericFile.new(title: ["First of the Assets"])
|
|
62
62
|
@asset1.apply_depositor_metadata(user.user_key)
|
|
63
63
|
@asset1.save
|
|
64
64
|
post :create, batch_document_ids: [@asset1.id],
|
|
65
|
-
|
|
65
|
+
collection: { title: "My Second Collection ", description: "The Description\r\n\r\nand more" }
|
|
66
66
|
expect(assigns[:collection].members).to eq [@asset1]
|
|
67
|
-
asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset1.id}\""],fl:['id',Solrizer.solr_name(:collection)]}
|
|
67
|
+
asset_results = ActiveFedora::SolrService.instance.conn.get "select", params: { fq: ["id:\"#{@asset1.id}\""], fl: ['id', Solrizer.solr_name(:collection)] }
|
|
68
68
|
expect(asset_results["response"]["numFound"]).to eq 1
|
|
69
69
|
doc = asset_results["response"]["docs"].first
|
|
70
70
|
expect(doc["id"]).to eq @asset1.id
|
|
71
71
|
afterupdate = GenericFile.find(@asset1.id)
|
|
72
72
|
expect(doc[Solrizer.solr_name(:collection)]).to eq afterupdate.to_solr[Solrizer.solr_name(:collection)]
|
|
73
73
|
end
|
|
74
|
-
|
|
75
74
|
end
|
|
76
75
|
|
|
77
76
|
describe "#update" do
|
|
@@ -91,23 +90,23 @@ describe CollectionsController do
|
|
|
91
90
|
@asset2 = GenericFile.new(title: ["Second of the Assets"], depositor: user.user_key)
|
|
92
91
|
@asset2.apply_depositor_metadata(user.user_key)
|
|
93
92
|
@asset2.save
|
|
94
|
-
@asset3 = GenericFile.new(title: ["Third of the Assets"], depositor:'abc')
|
|
93
|
+
@asset3 = GenericFile.new(title: ["Third of the Assets"], depositor: 'abc')
|
|
95
94
|
@asset3.apply_depositor_metadata(user.user_key)
|
|
96
95
|
@asset3.save
|
|
97
96
|
end
|
|
98
97
|
|
|
99
|
-
it "
|
|
100
|
-
put :update, id: collection, collection: {members:"add"}, batch_document_ids: [@asset3.id, @asset1.id, @asset2.id]
|
|
98
|
+
it "sets collection on members" do
|
|
99
|
+
put :update, id: collection, collection: { members: "add" }, batch_document_ids: [@asset3.id, @asset1.id, @asset2.id]
|
|
101
100
|
expect(response).to redirect_to routes.url_helpers.collection_path(collection)
|
|
102
101
|
expect(assigns[:collection].members).to match_array [@asset2, @asset3, @asset1]
|
|
103
|
-
asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset2.id}\""],fl:['id',Solrizer.solr_name(:collection)]}
|
|
102
|
+
asset_results = ActiveFedora::SolrService.instance.conn.get "select", params: { fq: ["id:\"#{@asset2.id}\""], fl: ['id', Solrizer.solr_name(:collection)] }
|
|
104
103
|
expect(asset_results["response"]["numFound"]).to eq 1
|
|
105
104
|
doc = asset_results["response"]["docs"].first
|
|
106
105
|
expect(doc["id"]).to eq @asset2.id
|
|
107
106
|
afterupdate = GenericFile.find(@asset2.id)
|
|
108
107
|
expect(doc[Solrizer.solr_name(:collection)]).to eq afterupdate.to_solr[Solrizer.solr_name(:collection)]
|
|
109
|
-
put :update, id: collection, collection: {members:"remove"}, batch_document_ids: [@asset2]
|
|
110
|
-
asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset2.id}\""],fl:['id',Solrizer.solr_name(:collection)]}
|
|
108
|
+
put :update, id: collection, collection: { members: "remove" }, batch_document_ids: [@asset2]
|
|
109
|
+
asset_results = ActiveFedora::SolrService.instance.conn.get "select", params: { fq: ["id:\"#{@asset2.id}\""], fl: ['id', Solrizer.solr_name(:collection)] }
|
|
111
110
|
expect(asset_results["response"]["numFound"]).to eq 1
|
|
112
111
|
doc = asset_results["response"]["docs"].first
|
|
113
112
|
expect(doc["id"]).to eq @asset2.id
|
|
@@ -117,19 +116,18 @@ describe CollectionsController do
|
|
|
117
116
|
end
|
|
118
117
|
|
|
119
118
|
context "updating a collections metadata" do
|
|
120
|
-
it "
|
|
119
|
+
it "saves the metadata" do
|
|
121
120
|
put :update, id: collection, collection: { creator: ['Emily'] }
|
|
122
121
|
collection.reload
|
|
123
122
|
expect(collection.creator).to eq ['Emily']
|
|
124
123
|
end
|
|
125
124
|
|
|
126
|
-
it "
|
|
125
|
+
it "removes blank strings from params before updating Collection metadata" do
|
|
127
126
|
put :update, id: collection, collection: {
|
|
128
127
|
title: "My Next Collection ", creator: [""] }
|
|
129
128
|
expect(assigns[:collection].title).to eq("My Next Collection ")
|
|
130
129
|
expect(assigns[:collection].creator).to eq([])
|
|
131
130
|
end
|
|
132
|
-
|
|
133
131
|
end
|
|
134
132
|
end
|
|
135
133
|
|
|
@@ -152,14 +150,14 @@ describe CollectionsController do
|
|
|
152
150
|
|
|
153
151
|
let(:collection) do
|
|
154
152
|
Collection.create(title: "My collection",
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
description: "My incredibly detailed description of the collection",
|
|
154
|
+
members: [asset1, asset2, asset3]) { |c| c.apply_depositor_metadata(user) }
|
|
157
155
|
end
|
|
158
156
|
|
|
159
157
|
context "when signed in" do
|
|
160
158
|
before { sign_in user }
|
|
161
159
|
|
|
162
|
-
it "
|
|
160
|
+
it "returns the collection and its members" do
|
|
163
161
|
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.title'), Sufia::Engine.routes.url_helpers.dashboard_index_path)
|
|
164
162
|
get :show, id: collection
|
|
165
163
|
expect(response).to be_successful
|
|
@@ -170,7 +168,7 @@ describe CollectionsController do
|
|
|
170
168
|
end
|
|
171
169
|
|
|
172
170
|
context "not signed in" do
|
|
173
|
-
it "
|
|
171
|
+
it "does not show me files in the collection" do
|
|
174
172
|
get :show, id: collection
|
|
175
173
|
expect(assigns[:member_docs].count).to eq 0
|
|
176
174
|
end
|
|
@@ -180,14 +178,14 @@ describe CollectionsController do
|
|
|
180
178
|
describe "#edit" do
|
|
181
179
|
let(:collection) do
|
|
182
180
|
Collection.create(title: "My collection",
|
|
183
|
-
|
|
181
|
+
description: "My incredibly detailed description of the collection") do |c|
|
|
184
182
|
c.apply_depositor_metadata(user)
|
|
185
183
|
end
|
|
186
184
|
end
|
|
187
185
|
|
|
188
186
|
before { sign_in user }
|
|
189
187
|
|
|
190
|
-
it "
|
|
188
|
+
it "does not show flash" do
|
|
191
189
|
get :edit, id: collection
|
|
192
190
|
expect(flash[:notice]).to be_nil
|
|
193
191
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe ContentBlocksController, :
|
|
3
|
+
describe ContentBlocksController, type: :controller do
|
|
4
4
|
describe "#update" do
|
|
5
5
|
let(:content_block) { FactoryGirl.create(:content_block) }
|
|
6
6
|
before { request.env["HTTP_REFERER"] = "whence_i_came" }
|
|
@@ -36,7 +36,7 @@ describe ContentBlocksController, :type => :controller do
|
|
|
36
36
|
before { allow(controller).to receive_messages(current_user: user) }
|
|
37
37
|
|
|
38
38
|
context "as a user in the admin group" do
|
|
39
|
-
before { expect(user).to receive(:groups).and_return(
|
|
39
|
+
before { expect(user).to receive(:groups).and_return(['admin', 'registered']) }
|
|
40
40
|
|
|
41
41
|
it "UPDATE should save" do
|
|
42
42
|
patch :update, id: content_block, content_block: { value: 'foo' }
|
|
@@ -45,9 +45,9 @@ describe ContentBlocksController, :type => :controller do
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "CREATE should save" do
|
|
48
|
-
expect
|
|
48
|
+
expect do
|
|
49
49
|
post :create, content_block: { name: 'NNN', value: 'VVV', external_key: 'key' }
|
|
50
|
-
|
|
50
|
+
end.to change { ContentBlock.count }.by(1)
|
|
51
51
|
expect(response).to redirect_to "whence_i_came"
|
|
52
52
|
expect(assigns[:content_block].name).to eq 'NNN'
|
|
53
53
|
expect(assigns[:content_block].value).to eq 'VVV'
|