sufia 4.0.0.rc1 → 4.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +2 -2
- data/Gemfile +9 -17
- data/README.md +18 -9
- data/Rakefile +10 -5
- data/SUFIA_VERSION +1 -1
- data/app/assets/javascripts/jquery.blacklightTagCloud.js +1 -1
- data/app/assets/javascripts/sufia.js +5 -22
- data/app/assets/javascripts/sufia/batch.js +8 -0
- data/app/assets/javascripts/sufia/batch_edit.js +19 -3
- data/app/assets/javascripts/sufia/dashboard_actions.js +23 -10
- data/app/assets/javascripts/sufia/multiForm.js +2 -2
- data/app/assets/javascripts/sufia/permissions.js +10 -9
- data/app/assets/javascripts/sufia/tabs.js +20 -0
- data/app/assets/stylesheets/catalog.css.scss +5 -0
- data/app/assets/stylesheets/collections.css.scss +40 -0
- data/app/assets/stylesheets/file-listing.css.scss +37 -13
- data/app/assets/stylesheets/generic_files.css.erb +5 -0
- data/app/assets/stylesheets/header.css.scss +1 -4
- data/app/assets/stylesheets/settings.css.scss +6 -0
- data/app/assets/stylesheets/styles.css.scss +4 -3
- data/app/assets/stylesheets/sufia-audio-overrides.css +2 -2
- data/app/assets/stylesheets/sufia.css.scss +27 -5
- data/app/assets/stylesheets/tagcloud.css +5 -1
- data/app/controllers/batch_controller.rb +3 -3
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +14 -1
- data/app/controllers/concerns/sufia/catalog.rb +0 -1
- data/app/controllers/concerns/sufia/controller.rb +5 -0
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +2 -9
- data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +3 -3
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +5 -1
- data/app/controllers/concerns/sufia/homepage_controller.rb +1 -1
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +3 -2
- data/app/helpers/batch_edits_helper.rb +6 -0
- data/app/helpers/generic_file_helper.rb +15 -0
- data/app/helpers/sufia/blacklight_override.rb +19 -3
- data/app/helpers/sufia/dashboard_helper_behavior.rb +25 -3
- data/app/helpers/sufia/records_helper_behavior.rb +13 -5
- data/app/helpers/sufia/sufia_helper_behavior.rb +15 -12
- data/app/models/concerns/sufia/solr_document_behavior.rb +5 -36
- data/app/views/_masthead.html.erb +1 -1
- data/app/views/_user_util_links.html.erb +6 -4
- data/app/views/advanced/_advanced_search_fields.html.erb +4 -4
- data/app/views/advanced/_advanced_search_form.html.erb +14 -17
- data/app/views/advanced/index.html.erb +3 -3
- data/app/views/batch/_metadata.html.erb +22 -24
- data/app/views/batch/_more_metadata.html.erb +1 -1
- data/app/views/batch/edit.html.erb +2 -2
- data/app/views/batch_edits/_check_all.html.erb +7 -9
- data/app/views/batch_edits/_delete_selected.html.erb +1 -0
- data/app/views/batch_edits/edit.html.erb +25 -26
- data/app/views/batch_edits/update_edit.js.erb +1 -1
- data/app/views/catalog/_facet_limit.html.erb +4 -12
- data/app/views/catalog/_search_form.html.erb +8 -13
- data/app/views/collections/_action_menu.html.erb +2 -2
- data/app/views/collections/_collection.html.erb +10 -31
- data/app/views/collections/_document_list.html.erb +1 -1
- data/app/views/collections/_edit_actions.html.erb +2 -2
- data/app/views/collections/_edit_descriptions.html.erb +3 -5
- data/app/views/collections/_form.html.erb +8 -10
- data/app/views/collections/_media_display.html.erb +1 -1
- data/app/views/collections/_show_actions.html.erb +5 -5
- data/app/views/collections/_show_descriptions.html.erb +13 -8
- data/app/views/collections/_show_document_list.html.erb +17 -0
- data/app/views/collections/_show_document_list_menu.html.erb +24 -0
- data/app/views/collections/_show_document_list_row.html.erb +63 -0
- data/app/views/collections/edit.html.erb +2 -2
- data/app/views/collections/show.html.erb +28 -19
- data/app/views/contact_form/new.html.erb +21 -29
- data/app/views/dashboard/_index_partials/_contents.html.erb +14 -0
- data/app/views/dashboard/_index_partials/_heading_actions.html.erb +18 -0
- data/app/views/dashboard/_index_partials/_heading_greetings.html.erb +8 -0
- data/app/views/dashboard/_index_partials/_stats.html.erb +6 -2
- data/app/views/dashboard/index.html.erb +5 -37
- data/app/views/generic_files/_breadcrumbs.html.erb +2 -0
- data/app/views/generic_files/_browse_everything.html.erb +2 -2
- data/app/views/generic_files/_descriptions.html.erb +4 -6
- data/app/views/generic_files/_field_form.html.erb +2 -2
- data/app/views/generic_files/_generic_file.html.erb +8 -29
- data/app/views/generic_files/_groups_description.html.erb +5 -4
- data/app/views/generic_files/_permission.html.erb +2 -2
- data/app/views/generic_files/_permission_form.html.erb +62 -77
- data/app/views/generic_files/_rights_modal.html.erb +0 -2
- data/app/views/generic_files/_share_with.html.erb +14 -0
- data/app/views/generic_files/_show_actions.html.erb +1 -1
- data/app/views/generic_files/_show_collections.html.erb +17 -0
- data/app/views/generic_files/_show_descriptions.html.erb +2 -2
- data/app/views/generic_files/_versioning.html.erb +2 -2
- data/app/views/generic_files/_visibility.html.erb +17 -0
- data/app/views/generic_files/show.html.erb +39 -2
- data/app/views/generic_files/stats.html.erb +1 -1
- data/app/views/generic_files/upload/_form_fields.html.erb +2 -2
- data/app/views/generic_files/upload/_local_file_import_chooser.html.erb +1 -1
- data/app/views/generic_files/upload/_script_templates.html.erb +2 -2
- data/app/views/generic_files/upload/_tos_checkbox.html.erb +3 -3
- data/app/views/homepage/_home_content.html.erb +0 -9
- data/app/views/homepage/_home_header.html.erb +1 -1
- data/app/views/homepage/_recent_document.html.erb +2 -2
- data/app/views/layouts/_head_tag_content.html.erb +7 -1
- data/app/views/layouts/sufia-dashboard.html.erb +4 -2
- data/app/views/layouts/sufia-one-column.html.erb +1 -1
- data/app/views/my/_action_menu.html.erb +1 -1
- data/app/views/my/_collection_action_menu.html.erb +3 -3
- data/app/views/my/_constraints.html.erb +11 -0
- data/app/views/my/_document_list.html.erb +1 -1
- data/app/views/my/_facet_limit.html.erb +4 -12
- data/app/views/my/_facets.html.erb +1 -3
- data/app/views/my/_index_partials/_default_group.html.erb +2 -3
- data/app/views/my/_index_partials/_list_collections.html.erb +17 -11
- data/app/views/my/_index_partials/_list_files.html.erb +20 -24
- data/app/views/my/_search_header.html.erb +5 -0
- data/app/views/my/_sort_and_per_page.html.erb +11 -7
- data/app/views/my/index.html.erb +9 -15
- data/app/views/records/_edit_field.html.erb +14 -10
- data/app/views/records/edit_fields/_default.html.erb +6 -0
- data/app/views/records/edit_fields/_description.html.erb +3 -7
- data/app/views/records/edit_fields/_resource_type.html.erb +4 -6
- data/app/views/records/edit_fields/_rights.html.erb +4 -5
- data/app/views/records/edit_fields/_suffix.html.erb +6 -3
- data/app/views/records/edit_fields/_type.html.erb +7 -12
- data/app/views/{generic_files → records}/show_fields/_based_near.html.erb +1 -1
- data/app/views/{generic_files → records}/show_fields/_contributor.html.erb +2 -2
- data/app/views/records/show_fields/_creator.html.erb +6 -0
- data/app/views/{generic_files → records}/show_fields/_date_created.html.erb +1 -1
- data/app/views/records/show_fields/_default.html.erb +6 -0
- data/app/views/records/show_fields/_description.html.erb +6 -0
- data/app/views/records/show_fields/_identifier.html.erb +4 -0
- data/app/views/{generic_files → records}/show_fields/_language.html.erb +1 -1
- data/app/views/{generic_files → records}/show_fields/_publisher.html.erb +1 -1
- data/app/views/records/show_fields/_related_url.html.erb +6 -0
- data/app/views/{generic_files → records}/show_fields/_resource_type.html.erb +1 -1
- data/app/views/{generic_files → records}/show_fields/_rights.html.erb +1 -1
- data/app/views/{generic_files → records}/show_fields/_subject.html.erb +1 -1
- data/app/views/{generic_files → records}/show_fields/_tag.html.erb +1 -1
- data/app/views/records/show_fields/_title.html.erb +6 -0
- data/app/views/shared/_attributes.html.erb +27 -0
- data/app/views/static/agreement.html.erb +1 -1
- data/app/views/users/_activity_log.html.erb +0 -2
- data/app/views/users/_follower_modal.html.erb +27 -23
- data/app/views/users/_following_modal.html.erb +27 -23
- data/app/views/users/_social_media_info.html.erb +4 -4
- data/app/views/users/_trophy_edit.html.erb +5 -7
- data/app/views/users/_user_info.html.erb +3 -3
- data/app/views/users/_user_util_links_extra.html.erb +4 -0
- data/app/views/users/edit.html.erb +28 -33
- data/app/views/users/index.html.erb +1 -1
- data/app/views/users/show.html.erb +0 -4
- data/config/jetty.yml +1 -1
- data/config/locales/sufia.en.yml +53 -12
- data/lib/generators/sufia/install_generator.rb +89 -0
- data/lib/generators/sufia/templates/catalog_controller.rb +1 -1
- data/lib/generators/sufia/upgrade400_generator.rb +4 -0
- data/lib/sufia.rb +1 -10
- data/lib/sufia/version.rb +1 -1
- data/solr_conf/conf/solrconfig.xml +31 -17
- data/spec/actors/generic_file/actor_spec.rb +17 -0
- data/spec/controllers/batch_controller_spec.rb +2 -2
- data/spec/controllers/batch_edits_controller_spec.rb +24 -19
- data/spec/controllers/catalog_controller_spec.rb +23 -12
- data/spec/controllers/collections_controller_spec.rb +19 -17
- data/spec/controllers/dashboard_controller_spec.rb +5 -19
- data/spec/controllers/generic_files_controller_spec.rb +35 -20
- data/spec/controllers/homepage_controller_spec.rb +25 -2
- data/spec/controllers/users_controller_spec.rb +99 -102
- data/spec/factories/generic_files.rb +2 -2
- data/spec/factories/users.rb +32 -2
- data/spec/features/browse_dashboard_files_spec.rb +14 -2
- data/spec/features/browse_files_spec.rb +5 -1
- data/spec/features/catalog_search_spec.rb +7 -6
- data/spec/features/collection_spec.rb +43 -33
- data/spec/features/display_dashboard_spec.rb +25 -22
- data/spec/features/notifications_spec.rb +9 -4
- data/spec/features/users_spec.rb +34 -25
- data/spec/fixtures/1.5mb-avatar.jpg +0 -0
- data/spec/helpers/batch_edits_helper_spec.rb +38 -0
- data/spec/helpers/dashboard_helper_spec.rb +16 -5
- data/spec/helpers/generic_file_helper_spec.rb +41 -0
- data/spec/helpers/records_helper_spec.rb +12 -0
- data/spec/jobs/active_fedora_pid_based_job_spec.rb +1 -1
- data/spec/jobs/audit_job_spec.rb +2 -3
- data/spec/jobs/batch_update_job_spec.rb +39 -24
- data/spec/jobs/event_jobs_spec.rb +1 -1
- data/spec/lib/sufia/id_service_spec.rb +25 -7
- data/spec/lib/sufia/messages_spec.rb +60 -0
- data/spec/lib/sufia/readable_permissions_spec.rb +56 -0
- data/spec/lib/sufia/writable_permissions_spec.rb +20 -0
- data/spec/models/batch_spec.rb +1 -1
- data/spec/models/collection_spec.rb +24 -2
- data/spec/models/featured_work_spec.rb +2 -2
- data/spec/models/file_content_datastream_spec.rb +5 -5
- data/spec/models/generic_file_spec.rb +149 -133
- data/spec/models/local_authority_spec.rb +1 -1
- data/spec/models/user_spec.rb +33 -6
- data/spec/spec_helper.rb +7 -10
- data/spec/{support → test_app_templates}/lib/generators/test_app_generator.rb +11 -6
- data/spec/views/batch/edit.html.erb_spec.rb +8 -2
- data/spec/views/catalog/index.html.erb_spec.rb +34 -0
- data/spec/views/catalog/{sort_and_per_pange.html.erb_spec.rb → sort_and_per_page.html.erb_spec.rb} +0 -0
- data/spec/views/collections/_form.html.erb_spec.rb +32 -0
- data/spec/views/collections/_show_descriptions.html.erb_spec.rb +25 -0
- data/spec/views/dashboard/index_spec.rb +33 -4
- data/spec/views/generic_file/_breadcrumbs.html.erb_spec.rb +32 -0
- data/spec/views/generic_file/show.html.erb_spec.rb +273 -8
- data/spec/views/users/_user_util_links.html.erb_spec.rb +25 -0
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +14 -5
- data/sufia-models/{lib/sufia/models → app}/jobs/active_fedora_pid_based_job.rb +0 -0
- data/sufia-models/{lib/sufia/models → app}/jobs/audit_job.rb +4 -10
- data/sufia-models/{lib/sufia/models → app}/jobs/batch_update_job.rb +22 -18
- data/sufia-models/{lib/sufia/models → app}/jobs/characterize_job.rb +0 -0
- data/sufia-models/{lib/sufia/models → app}/jobs/create_derivatives_job.rb +0 -0
- data/sufia-models/{lib/sufia/models → app}/jobs/import_url_job.rb +0 -0
- data/sufia-models/{lib/sufia/models → app}/jobs/resolrize_job.rb +0 -0
- data/sufia-models/app/models/collection.rb +1 -39
- data/sufia-models/{lib → app/models/concerns}/sufia/ability.rb +0 -0
- data/sufia-models/app/models/concerns/sufia/collection.rb +55 -0
- data/sufia-models/app/models/concerns/sufia/generic_file.rb +5 -11
- data/sufia-models/app/models/concerns/sufia/generic_file/audit.rb +1 -2
- data/sufia-models/app/models/concerns/sufia/generic_file/characterization.rb +4 -2
- data/sufia-models/app/models/concerns/sufia/generic_file/full_text_indexing.rb +27 -0
- data/sufia-models/app/models/concerns/sufia/generic_file/mime_types.rb +1 -0
- data/sufia-models/app/models/concerns/sufia/generic_file/permissions.rb +2 -49
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/model_methods.rb +0 -0
- data/sufia-models/app/models/concerns/sufia/user.rb +8 -1
- data/sufia-models/app/models/sufia/avatar_uploader.rb +2 -3
- data/sufia-models/app/services/sufia/noid.rb +9 -0
- data/sufia-models/config/locales/sufia.en.yml +1 -0
- data/sufia-models/lib/generators/sufia/models/fulltext_generator.rb +27 -0
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +7 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/analytics.yml +5 -5
- data/sufia-models/lib/generators/sufia/models/templates/config/solrconfig.xml +177 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +3 -1
- data/sufia-models/lib/generators/sufia/models/upgrade400_generator.rb +7 -0
- data/sufia-models/lib/sufia/messages.rb +67 -0
- data/sufia-models/lib/sufia/models.rb +2 -0
- data/sufia-models/lib/sufia/models/active_fedora/redis.rb +0 -6
- data/sufia-models/lib/sufia/models/engine.rb +1 -3
- data/sufia-models/lib/sufia/models/resque.rb +1 -1
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia-models/lib/sufia/permissions.rb +9 -0
- data/sufia-models/lib/sufia/permissions/readable.rb +20 -0
- data/sufia-models/lib/sufia/permissions/writable.rb +56 -0
- data/sufia-models/lib/tasks/sufia-models_tasks.rake +58 -2
- data/sufia-models/sufia-models.gemspec +11 -11
- data/sufia.gemspec +19 -9
- data/tasks/jetty.rake +6 -5
- data/tasks/sufia-dev.rake +4 -77
- metadata +235 -72
- data/app/assets/images/folder.png +0 -0
- data/app/views/collections/show_fields/_creator.html.erb +0 -11
- data/app/views/collections/show_fields/_description.html.erb +0 -8
- data/app/views/collections/show_fields/_title.html.erb +0 -8
- data/app/views/generic_files/edit_fields/_default.html.erb +0 -6
- data/app/views/generic_files/edit_fields/_description.html.erb +0 -5
- data/app/views/generic_files/edit_fields/_resource_type.html.erb +0 -6
- data/app/views/generic_files/edit_fields/_rights.html.erb +0 -6
- data/app/views/generic_files/edit_fields/_suffix.html.erb +0 -9
- data/app/views/generic_files/show_fields/_creator.html.erb +0 -7
- data/app/views/generic_files/show_fields/_default.html.erb +0 -6
- data/app/views/generic_files/show_fields/_description.html.erb +0 -7
- data/app/views/generic_files/show_fields/_identifier.html.erb +0 -4
- data/app/views/generic_files/show_fields/_related_url.html.erb +0 -6
- data/app/views/generic_files/show_fields/_title.html.erb +0 -7
- data/lib/generators/sufia/sufia_generator.rb +0 -89
- data/spec/active_fedora/unsaved_digital_object_spec.rb +0 -35
@@ -23,6 +23,18 @@ describe RecordsHelper do
|
|
23
23
|
i.attr('class').should == 'glyphicon glyphicon-question-sign large-icon'
|
24
24
|
end
|
25
25
|
|
26
|
+
specify "draws help_icon_modal" do
|
27
|
+
str = String.new(helper.help_icon_modal('myModal'))
|
28
|
+
doc = Nokogiri::HTML(str)
|
29
|
+
a = doc.xpath('//a').first
|
30
|
+
|
31
|
+
expect(a.attr('href')).to eq('#myModal')
|
32
|
+
expect(a.attr('data-toggle')).to eq('modal')
|
33
|
+
expect(a.attr('id')).to eq('generic_file_myModal_help_modal')
|
34
|
+
i = a.children.first
|
35
|
+
expect(i.attr('class')).to eq('glyphicon glyphicon-question-sign large-icon')
|
36
|
+
end
|
37
|
+
|
26
38
|
describe "download links" do
|
27
39
|
|
28
40
|
before :all do
|
@@ -13,6 +13,6 @@ describe ActiveFedoraPidBasedJob do
|
|
13
13
|
it "finds object" do
|
14
14
|
job = ActiveFedoraPidBasedJob.new(file.id)
|
15
15
|
expect(job.generic_file).to_not be_nil
|
16
|
-
expect(job.generic_file
|
16
|
+
expect(job.generic_file).to be_reload_on_save
|
17
17
|
end
|
18
18
|
end
|
data/spec/jobs/audit_job_spec.rb
CHANGED
@@ -7,7 +7,6 @@ describe AuditJob do
|
|
7
7
|
@file = GenericFile.new
|
8
8
|
@file.apply_depositor_metadata(@user)
|
9
9
|
@file.save
|
10
|
-
@ds = @file.datastreams.first
|
11
10
|
end
|
12
11
|
after do
|
13
12
|
@file.delete
|
@@ -15,7 +14,7 @@ describe AuditJob do
|
|
15
14
|
describe "passing audit" do
|
16
15
|
it "should not send passing mail" do
|
17
16
|
ActiveFedora::RelsExtDatastream.any_instance.stub(:dsChecksumValid).and_return(true)
|
18
|
-
AuditJob.new(@file.pid,
|
17
|
+
AuditJob.new(@file.pid, "RELS-EXT", @file.rels_ext.versionID).run
|
19
18
|
@inbox = @user.mailbox.inbox
|
20
19
|
@inbox.count.should == 0
|
21
20
|
end
|
@@ -23,7 +22,7 @@ describe AuditJob do
|
|
23
22
|
describe "failing audit" do
|
24
23
|
it "should send failing mail" do
|
25
24
|
ActiveFedora::RelsExtDatastream.any_instance.stub(:dsChecksumValid).and_return(false)
|
26
|
-
AuditJob.new(@file.pid,
|
25
|
+
AuditJob.new(@file.pid, "RELS-EXT", @file.rels_ext.versionID).run
|
27
26
|
@inbox = @user.mailbox.inbox
|
28
27
|
@inbox.count.should == 1
|
29
28
|
@inbox.each { |msg| msg.last_message.subject.should == AuditJob::FAIL }
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BatchUpdateJob do
|
4
|
+
|
4
5
|
before do
|
5
6
|
@user = FactoryGirl.find_or_create(:jill)
|
6
7
|
@batch = Batch.new
|
@@ -12,36 +13,50 @@ describe BatchUpdateJob do
|
|
12
13
|
@file2.apply_depositor_metadata('otherUser')
|
13
14
|
@file2.save
|
14
15
|
end
|
16
|
+
|
15
17
|
after do
|
18
|
+
@user.mailbox.inbox[0].messages[0].move_to_trash @user
|
16
19
|
@batch.delete
|
17
20
|
@file.delete
|
18
21
|
@file2.delete
|
19
22
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
|
24
|
+
describe "#run" do
|
25
|
+
let(:params) do
|
26
|
+
{
|
27
|
+
generic_file: {
|
28
|
+
read_groups_string: '', read_users_string: 'archivist1, archivist2', tag: ['']
|
29
|
+
},
|
30
|
+
id: @batch.pid,
|
31
|
+
controller: 'batch',
|
32
|
+
action: 'update'
|
33
|
+
}.with_indifferent_access
|
29
34
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
35
|
+
context "with a failing update" do
|
36
|
+
it "should check permissions for each file before updating" do
|
37
|
+
User.any_instance.should_receive(:can?).with(:edit, @file).and_return(false)
|
38
|
+
User.any_instance.should_receive(:can?).with(:edit, @file2).and_return(false)
|
39
|
+
BatchUpdateJob.new(@user.user_key, params).run
|
40
|
+
@user.mailbox.inbox[0].messages[0].subject.should == "Batch upload permission denied"
|
41
|
+
@user.mailbox.inbox[0].messages[0].body.should include("data-content")
|
42
|
+
@user.mailbox.inbox[0].messages[0].body.should include("These files")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
context "with a passing update" do
|
46
|
+
let(:s1) { double('one') }
|
47
|
+
let(:s2) { double('two') }
|
48
|
+
it "should log a content update event" do
|
49
|
+
User.any_instance.should_receive(:can?).with(:edit, @file).and_return(true)
|
50
|
+
User.any_instance.should_receive(:can?).with(:edit, @file2).and_return(true)
|
51
|
+
ContentUpdateEventJob.should_receive(:new).with(@file.pid, @user.user_key).and_return(s1)
|
52
|
+
Sufia.queue.should_receive(:push).with(s1).once
|
53
|
+
ContentUpdateEventJob.should_receive(:new).with(@file2.pid, @user.user_key).and_return(s2)
|
54
|
+
Sufia.queue.should_receive(:push).with(s2).once
|
55
|
+
BatchUpdateJob.new(@user.user_key, params).run
|
56
|
+
@user.mailbox.inbox[0].messages[0].subject.should == "Batch upload complete"
|
57
|
+
@user.mailbox.inbox[0].messages[0].body.should include("data-content")
|
58
|
+
@user.mailbox.inbox[0].messages[0].body.should include("These files")
|
59
|
+
end
|
45
60
|
end
|
46
61
|
end
|
47
62
|
end
|
@@ -2,15 +2,33 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Sufia::IdService do
|
4
4
|
describe "mint" do
|
5
|
-
|
6
|
-
|
5
|
+
subject { Sufia::IdService.mint }
|
6
|
+
|
7
|
+
it { should_not be_empty }
|
8
|
+
|
9
|
+
it "should not mint the same id twice in a row" do
|
10
|
+
expect(Sufia::IdService.mint).to_not eq subject
|
7
11
|
end
|
8
|
-
|
9
|
-
|
12
|
+
|
13
|
+
it "should be valid" do
|
14
|
+
expect(Sufia::IdService.valid?(subject)).to be true
|
10
15
|
end
|
11
|
-
|
12
|
-
|
13
|
-
|
16
|
+
|
17
|
+
context "when the pid already exists in Fedora" do
|
18
|
+
let(:mock_pid) { 'scholarsphere:ef12ef12f' }
|
19
|
+
let(:unique_pid) { 'scholarsphere:bb22bb22b' }
|
20
|
+
|
21
|
+
before do
|
22
|
+
allow(Sufia::IdService).to receive(:next_id).and_return(mock_pid, unique_pid)
|
23
|
+
expect(ActiveFedora::Base).to receive(:exists?).with(mock_pid).and_return(true)
|
24
|
+
expect(ActiveFedora::Base).to receive(:exists?).with(unique_pid).and_return(false)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should not assign that pid again" do
|
28
|
+
expect(subject).to eq unique_pid
|
29
|
+
end
|
14
30
|
end
|
15
31
|
end
|
32
|
+
|
33
|
+
|
16
34
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::Messages do
|
4
|
+
|
5
|
+
let(:message) do
|
6
|
+
class TestClass
|
7
|
+
include Sufia::Messages
|
8
|
+
end
|
9
|
+
TestClass.new
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:batch_id) { "1" }
|
13
|
+
let(:single) { double(noid: "1", to_s: "File 1") }
|
14
|
+
let(:multiple) { [ double(noid: "1", to_s: "File 1"), double(noid: "2", to_s: "File 2"), double(noid: "3", to_s: "File 3") ] }
|
15
|
+
let(:file_list) { "<a href='/files/1'>File 1</a>, <a href='/files/2'>File 2</a>, <a href='/files/3'>File 3</a>" }
|
16
|
+
|
17
|
+
describe "message subjects" do
|
18
|
+
it "should provide a subject for a success message" do
|
19
|
+
expect(message.success_subject).to eq("Batch upload complete")
|
20
|
+
end
|
21
|
+
it "should provide a subject for a failure message" do
|
22
|
+
expect(message.failure_subject).to eq("Batch upload permission denied")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#single_success" do
|
27
|
+
let(:expected) { '<span id="ss-1"><a href="/files/1">File 1</a> has been saved.</span>' }
|
28
|
+
it "should render a success message for a single file" do
|
29
|
+
expect(message.single_success(batch_id, single)).to eq(expected)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#multiple_success" do
|
34
|
+
let(:expected) { '<span id="ss-1"><a data-content="'+file_list+'" data-title="Files uploaded successfully" href="#" rel="popover">These files</a> have been saved.</span>' }
|
35
|
+
it "should render a success message for multiple files" do
|
36
|
+
expect(message.multiple_success(batch_id, multiple)).to eq(expected)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#single_failure" do
|
41
|
+
let(:expected) { '<span id="ss-1"><a href="/files/1">File 1</a> could not be updated. You do not have sufficient privileges to edit it.</span>' }
|
42
|
+
it "should render a failure message for a single file" do
|
43
|
+
expect(message.single_failure(batch_id, single)).to eq(expected)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#multiple_failure" do
|
48
|
+
let(:expected) { '<span id="ss-1"><a data-content="'+file_list+'" data-title="Files failed" href="#" rel="popover">These files</a> could not be updated. You do not have sufficient privileges to edit them.</span>' }
|
49
|
+
it "should render a failure message for multiple files" do
|
50
|
+
expect(message.multiple_failure(batch_id, multiple)).to eq(expected)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#file_list" do
|
55
|
+
it "should replace double-quotes with single quotes" do
|
56
|
+
expect(message.file_list(multiple)).to eq(file_list)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::Permissions::Readable do
|
4
|
+
|
5
|
+
class SubjectClass
|
6
|
+
include Sufia::Permissions::Readable
|
7
|
+
attr_accessor :read_groups
|
8
|
+
end
|
9
|
+
let(:subject) { SubjectClass.new }
|
10
|
+
|
11
|
+
describe "#public?" do
|
12
|
+
it "should return true for public items" do
|
13
|
+
subject.read_groups = ["public","othergroup"]
|
14
|
+
expect(subject).to be_public
|
15
|
+
end
|
16
|
+
it "should return fale for non-public items" do
|
17
|
+
subject.read_groups = ["notpublic","othergroup"]
|
18
|
+
expect(subject).to_not be_public
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#registered?" do
|
23
|
+
it "should return true for registered items" do
|
24
|
+
subject.read_groups = ["registered","othergroup"]
|
25
|
+
expect(subject).to be_registered
|
26
|
+
end
|
27
|
+
it "should return fale for non-registered items" do
|
28
|
+
subject.read_groups = ["othergroup"]
|
29
|
+
expect(subject).to_not be_registered
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#private?" do
|
34
|
+
context "is true" do
|
35
|
+
specify "when there are no groups defined" do
|
36
|
+
subject.read_groups = []
|
37
|
+
expect(subject).to be_private
|
38
|
+
end
|
39
|
+
specify "when groups do not include 'public' or 'registered'" do
|
40
|
+
subject.read_groups = ["othergroup"]
|
41
|
+
expect(subject).to be_private
|
42
|
+
end
|
43
|
+
end
|
44
|
+
context "is false" do
|
45
|
+
specify "when 'registered' group is present" do
|
46
|
+
subject.read_groups = ["registered"]
|
47
|
+
expect(subject).to_not be_private
|
48
|
+
end
|
49
|
+
specify "when 'public' group is present" do
|
50
|
+
subject.read_groups = ["public"]
|
51
|
+
expect(subject).to_not be_private
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::Permissions::Writable do
|
4
|
+
|
5
|
+
class SampleModel < ActiveFedora::Base
|
6
|
+
include Sufia::Permissions::Writable
|
7
|
+
end
|
8
|
+
let(:subject) { SampleModel.new }
|
9
|
+
|
10
|
+
it "should initialized with a parnoid rightsMetadata datastream" do
|
11
|
+
expect(subject.rightsMetadata).to be_kind_of ParanoidRightsDatastream
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#permissions" do
|
15
|
+
it "should initialize with nothing specified" do
|
16
|
+
expect(subject.permissions).to be_empty
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/spec/models/batch_spec.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Collection do
|
4
|
-
before
|
4
|
+
before do
|
5
5
|
@user = FactoryGirl.create(:user)
|
6
6
|
@collection = Collection.new(title: "test collection").tap do |c|
|
7
7
|
c.apply_depositor_metadata(@user.user_key)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
after
|
11
|
+
after do
|
12
12
|
@collection.delete
|
13
|
+
@user.destroy
|
13
14
|
end
|
14
15
|
|
15
16
|
it "should have open visibility" do
|
@@ -21,4 +22,25 @@ describe Collection do
|
|
21
22
|
@collection.title = nil
|
22
23
|
expect{ @collection.save! }.to raise_error(ActiveFedora::RecordInvalid)
|
23
24
|
end
|
25
|
+
|
26
|
+
describe "::bytes" do
|
27
|
+
|
28
|
+
context "with no items" do
|
29
|
+
specify "is zero" do
|
30
|
+
@collection.save
|
31
|
+
expect(@collection.bytes).to eq 0
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "with characterized GenericFiles" do
|
36
|
+
let(:file) { mock_model GenericFile, file_size: ["50"] }
|
37
|
+
before do
|
38
|
+
allow(@collection).to receive(:members).and_return([file, file])
|
39
|
+
end
|
40
|
+
specify "is the sum of the files' sizes" do
|
41
|
+
expect(@collection.bytes).to eq 100
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
24
46
|
end
|
@@ -21,7 +21,7 @@ describe FeaturedWork do
|
|
21
21
|
describe "can_create_another?" do
|
22
22
|
subject { FeaturedWork }
|
23
23
|
context "when none exist" do
|
24
|
-
its(:can_create_another?) { should
|
24
|
+
its(:can_create_another?) { should be true }
|
25
25
|
end
|
26
26
|
context "when five exist" do
|
27
27
|
before do
|
@@ -29,7 +29,7 @@ describe FeaturedWork do
|
|
29
29
|
FeaturedWork.create(generic_file_id:n.to_s)
|
30
30
|
end
|
31
31
|
end
|
32
|
-
its(:can_create_another?) { should
|
32
|
+
its(:can_create_another?) { should be false }
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -78,17 +78,17 @@ describe FileContentDatastream do
|
|
78
78
|
end
|
79
79
|
it "should only return true when the datastream has actually changed" do
|
80
80
|
@generic_file.add_file(File.open(fixture_path + '/world.png', 'rb'), 'content', 'world.png')
|
81
|
-
@generic_file.content.
|
81
|
+
expect(@generic_file.content).to be_changed
|
82
82
|
@generic_file.save!
|
83
|
-
@generic_file.content.
|
83
|
+
expect(@generic_file.content).to_not be_changed
|
84
84
|
|
85
85
|
# Add a thumbnail ds
|
86
86
|
@generic_file.add_file(File.open(fixture_path + '/world.png'), 'thumbnail', 'world.png')
|
87
|
-
@generic_file.thumbnail.
|
88
|
-
@generic_file.content.
|
87
|
+
expect(@generic_file.thumbnail).to be_changed
|
88
|
+
expect(@generic_file.content).to_not be_changed
|
89
89
|
|
90
90
|
retrieved_file = @generic_file.reload
|
91
|
-
retrieved_file.content.
|
91
|
+
expect(retrieved_file.content).to_not be_changed
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
@@ -27,6 +27,13 @@ describe GenericFile do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
describe "assign_pid" do
|
31
|
+
it "should use the noid id service" do
|
32
|
+
expect_any_instance_of(Rubydora::Fc3Service).to_not receive(:next_pid)
|
33
|
+
GenericFile.assign_pid(nil)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
30
37
|
describe "mime type recognition" do
|
31
38
|
context "when image?" do
|
32
39
|
it "should be true for jpeg2000" do
|
@@ -243,9 +250,9 @@ describe GenericFile do
|
|
243
250
|
f.should respond_to(:log_event)
|
244
251
|
end
|
245
252
|
it "should be able to set values via delegated methods" do
|
246
|
-
subject.related_url = "http://example.org/"
|
247
|
-
subject.creator = "John Doe"
|
248
|
-
subject.title = "New work"
|
253
|
+
subject.related_url = ["http://example.org/"]
|
254
|
+
subject.creator = ["John Doe"]
|
255
|
+
subject.title = ["New work"]
|
249
256
|
subject.save
|
250
257
|
f = subject.reload
|
251
258
|
f.related_url.should == ["http://example.org/"]
|
@@ -253,13 +260,13 @@ describe GenericFile do
|
|
253
260
|
f.title.should == ["New work"]
|
254
261
|
end
|
255
262
|
it "should be able to be added to w/o unexpected graph behavior" do
|
256
|
-
subject.creator = "John Doe"
|
257
|
-
subject.title = "New work"
|
263
|
+
subject.creator = ["John Doe"]
|
264
|
+
subject.title = ["New work"]
|
258
265
|
subject.save
|
259
266
|
f = subject.reload
|
260
267
|
f.creator.should == ["John Doe"]
|
261
268
|
f.title.should == ["New work"]
|
262
|
-
f.creator = "Jane Doe"
|
269
|
+
f.creator = ["Jane Doe"]
|
263
270
|
f.title << "Newer work"
|
264
271
|
f.save
|
265
272
|
f = subject.reload
|
@@ -271,24 +278,25 @@ describe GenericFile do
|
|
271
278
|
describe "to_solr" do
|
272
279
|
before do
|
273
280
|
allow(subject).to receive(:pid).and_return('stubbed_pid')
|
274
|
-
subject.part_of = "Arabiana"
|
275
|
-
subject.contributor = "Mohammad"
|
276
|
-
subject.creator = "Allah"
|
277
|
-
subject.title = "The Work"
|
278
|
-
subject.description = "The work by Allah"
|
279
|
-
subject.publisher = "Vertigo Comics"
|
280
|
-
subject.date_created = "1200-01-01"
|
281
|
+
subject.part_of = ["Arabiana"]
|
282
|
+
subject.contributor = ["Mohammad"]
|
283
|
+
subject.creator = ["Allah"]
|
284
|
+
subject.title = ["The Work"]
|
285
|
+
subject.description = ["The work by Allah"]
|
286
|
+
subject.publisher = ["Vertigo Comics"]
|
287
|
+
subject.date_created = ["1200-01-01"]
|
281
288
|
subject.date_uploaded = Date.parse("2011-01-01")
|
282
289
|
subject.date_modified = Date.parse("2012-01-01")
|
283
|
-
subject.subject = "Theology"
|
284
|
-
subject.language = "Arabic"
|
285
|
-
subject.rights = "Wide open, buddy."
|
286
|
-
subject.resource_type = "Book"
|
287
|
-
subject.identifier = "urn:isbn:1234567890"
|
288
|
-
subject.based_near = "Medina, Saudi Arabia"
|
289
|
-
subject.related_url = "http://example.org/TheWork/"
|
290
|
+
subject.subject = ["Theology"]
|
291
|
+
subject.language = ["Arabic"]
|
292
|
+
subject.rights = ["Wide open, buddy."]
|
293
|
+
subject.resource_type = ["Book"]
|
294
|
+
subject.identifier = ["urn:isbn:1234567890"]
|
295
|
+
subject.based_near = ["Medina, Saudi Arabia"]
|
296
|
+
subject.related_url = ["http://example.org/TheWork/"]
|
290
297
|
subject.mime_type = "image/jpeg"
|
291
|
-
subject.format_label = "JPEG Image"
|
298
|
+
subject.format_label = ["JPEG Image"]
|
299
|
+
subject.full_text.content = 'abcxyz'
|
292
300
|
end
|
293
301
|
it "supports to_solr" do
|
294
302
|
local = subject.to_solr
|
@@ -314,6 +322,7 @@ describe GenericFile do
|
|
314
322
|
expect(local[Solrizer.solr_name("desc_metadata__based_near")]).to eq ["Medina, Saudi Arabia"]
|
315
323
|
expect(local[Solrizer.solr_name("mime_type")]).to eq ["image/jpeg"]
|
316
324
|
expect(local["noid_tsi"]).to eq 'stubbed_pid'
|
325
|
+
expect(local['all_text_timv']).to eq('abcxyz')
|
317
326
|
end
|
318
327
|
end
|
319
328
|
it "should support multi-valued fields in solr" do
|
@@ -348,26 +357,25 @@ describe GenericFile do
|
|
348
357
|
end
|
349
358
|
describe "trophies" do
|
350
359
|
before do
|
351
|
-
u = FactoryGirl.
|
360
|
+
u = FactoryGirl.find_or_create(:jill)
|
352
361
|
@f = GenericFile.new.tap do |gf|
|
353
362
|
gf.apply_depositor_metadata(u)
|
354
363
|
gf.save!
|
355
364
|
end
|
356
|
-
@t = Trophy.create(user_id: u.id, generic_file_id: @f.
|
365
|
+
@t = Trophy.create(user_id: u.id, generic_file_id: @f.noid)
|
357
366
|
end
|
358
367
|
it "should have a trophy" do
|
359
|
-
Trophy.where(generic_file_id: @f.
|
368
|
+
expect(Trophy.where(generic_file_id: @f.noid).count).to eq 1
|
360
369
|
end
|
361
370
|
it "should remove all trophies when file is deleted" do
|
362
|
-
@f.should_receive(:cleanup_trophies)
|
363
371
|
@f.destroy
|
364
|
-
Trophy.where(generic_file_id: @f.
|
372
|
+
expect(Trophy.where(generic_file_id: @f.noid).count).to eq 0
|
365
373
|
end
|
366
374
|
end
|
367
375
|
|
368
376
|
describe "audit" do
|
369
377
|
before do
|
370
|
-
u = FactoryGirl.
|
378
|
+
u = FactoryGirl.find_or_create(:jill)
|
371
379
|
f = GenericFile.new
|
372
380
|
f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
373
381
|
f.apply_depositor_metadata(u)
|
@@ -399,16 +407,16 @@ describe GenericFile do
|
|
399
407
|
@f.datastreams.each { |ds| ds.stub(:dsChecksumValid).and_return(false) }
|
400
408
|
GenericFile.stub(:run_audit).and_return(double(:respose, pass:1, created_at: '2005-12-20', pid: 'foo:123', dsid: 'foo', version: '1'))
|
401
409
|
@f.audit!
|
402
|
-
ChecksumAuditLog.all.
|
410
|
+
expect(ChecksumAuditLog.all).to be_all { |cal| cal.pass == 0 }
|
403
411
|
end
|
404
412
|
it "should log a passing audit" do
|
405
413
|
GenericFile.stub(:run_audit).and_return(double(:respose, pass:1, created_at: '2005-12-20', pid: 'foo:123', dsid: 'foo', version: '1'))
|
406
414
|
@f.audit!
|
407
|
-
ChecksumAuditLog.all.
|
415
|
+
expect(ChecksumAuditLog.all).to be_all { |cal| cal.pass == 1 }
|
408
416
|
end
|
409
417
|
|
410
418
|
it "should return true on audit_status" do
|
411
|
-
@f.audit_stat.
|
419
|
+
expect(@f.audit_stat).to be_truthy
|
412
420
|
end
|
413
421
|
end
|
414
422
|
|
@@ -443,39 +451,46 @@ describe GenericFile do
|
|
443
451
|
|
444
452
|
end
|
445
453
|
|
446
|
-
describe "related_files" do
|
447
|
-
let(:
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
@f2.apply_depositor_metadata('mjg36')
|
454
|
-
@f3.apply_depositor_metadata('mjg36')
|
454
|
+
describe "#related_files" do
|
455
|
+
let!(:f1) do
|
456
|
+
GenericFile.new.tap do |f|
|
457
|
+
f.apply_depositor_metadata('mjg36')
|
458
|
+
f.batch_id = batch_id
|
459
|
+
f.save
|
460
|
+
end
|
455
461
|
end
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
@f3.delete
|
462
|
+
let!(:f2) do
|
463
|
+
GenericFile.new.tap do |f|
|
464
|
+
f.apply_depositor_metadata('mjg36')
|
465
|
+
f.batch_id = batch_id
|
466
|
+
f.save
|
462
467
|
end
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
@f3.save!
|
468
|
+
end
|
469
|
+
let!(:f3) do
|
470
|
+
GenericFile.new.tap do |f|
|
471
|
+
f.apply_depositor_metadata('mjg36')
|
472
|
+
f.batch_id = batch_id
|
473
|
+
f.save
|
470
474
|
end
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
+
end
|
476
|
+
|
477
|
+
context "when the files belong to a batch" do
|
478
|
+
let(:batch) { Batch.create }
|
479
|
+
let(:batch_id) { batch.id }
|
480
|
+
|
481
|
+
it "shouldn't return itself from the related_files method" do
|
482
|
+
expect(f1.related_files).to match_array [f2, f3]
|
483
|
+
expect(f2.related_files).to match_array [f1, f3]
|
484
|
+
expect(f3.related_files).to match_array [f1, f2]
|
475
485
|
end
|
476
486
|
end
|
477
|
-
|
478
|
-
|
487
|
+
|
488
|
+
context "when there are no related files" do
|
489
|
+
let(:batch_id) { nil }
|
490
|
+
|
491
|
+
it "should return an empty array when there are no related files" do
|
492
|
+
expect(f1.related_files).to eq []
|
493
|
+
end
|
479
494
|
end
|
480
495
|
end
|
481
496
|
describe "noid integration" do
|
@@ -512,12 +527,12 @@ describe GenericFile do
|
|
512
527
|
myfile.add_file(File.open(fixture_path + '/sufia/sufia_test4.pdf', 'rb').read, 'content', 'sufia_test4.pdf')
|
513
528
|
myfile.label = 'label123'
|
514
529
|
myfile.apply_depositor_metadata('mjg36')
|
530
|
+
# characterize method saves
|
515
531
|
myfile.characterize
|
516
|
-
myfile.save
|
517
532
|
@myfile = myfile.reload
|
518
533
|
end
|
519
534
|
after(:all) do
|
520
|
-
@myfile.
|
535
|
+
@myfile.destroy
|
521
536
|
end
|
522
537
|
it "should return expected results after a save" do
|
523
538
|
@myfile.file_size.should == ['218882']
|
@@ -535,12 +550,14 @@ describe GenericFile do
|
|
535
550
|
@myfile.title.should include("Microsoft Word - sample.pdf.docx")
|
536
551
|
@myfile.filename[0].should == @myfile.label
|
537
552
|
end
|
538
|
-
|
539
553
|
it "should append each term only once" do
|
540
554
|
@myfile.append_metadata
|
541
555
|
@myfile.format_label.should == ["Portable Document Format"]
|
542
556
|
@myfile.title.should include("Microsoft Word - sample.pdf.docx")
|
543
557
|
end
|
558
|
+
it 'includes extracted full-text content' do
|
559
|
+
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\n\n\nMicrosoft Word - sample.pdf.docx\n\n\n \n \n\n \n\n \n\n \n\nThis PDF file was created using CutePDF. \n\nwww.cutepdf.com")
|
560
|
+
end
|
544
561
|
end
|
545
562
|
end
|
546
563
|
describe "label" do
|
@@ -618,66 +635,66 @@ describe GenericFile do
|
|
618
635
|
it "should work via permissions=()" do
|
619
636
|
@file.permissions = {user: {'mjg36' => 'read'}}
|
620
637
|
lambda { @file.save }.should_not raise_error
|
621
|
-
@file.
|
638
|
+
expect(@file).to be_new_record
|
622
639
|
@file.errors.should include(:edit_users)
|
623
640
|
@file.errors[:edit_users].should include('Depositor must have edit access')
|
624
|
-
@file.
|
641
|
+
expect(@file).to_not be_valid
|
625
642
|
end
|
626
643
|
it "should work via update_attributes" do
|
627
644
|
# automatically triggers save
|
628
645
|
lambda { @file.update_attributes(read_users_string: 'mjg36') }.should_not raise_error
|
629
|
-
@file.
|
646
|
+
expect(@file).to be_new_record
|
630
647
|
@file.errors.should include(:edit_users)
|
631
648
|
@file.errors[:edit_users].should include('Depositor must have edit access')
|
632
|
-
@file.
|
649
|
+
expect(@file).to_not be_valid
|
633
650
|
end
|
634
651
|
it "should work via update_indexed_attributes" do
|
635
652
|
@rightsmd.update_indexed_attributes([:edit_access, :person] => '')
|
636
653
|
lambda { @file.save }.should_not raise_error
|
637
|
-
@file.
|
654
|
+
expect(@file).to be_new_record
|
638
655
|
@file.errors.should include(:edit_users)
|
639
656
|
@file.errors[:edit_users].should include('Depositor must have edit access')
|
640
|
-
@file.
|
657
|
+
expect(@file).to_not be_valid
|
641
658
|
end
|
642
659
|
it "should work via permissions()" do
|
643
660
|
@rightsmd.permissions({person: "mjg36"}, "read")
|
644
661
|
lambda { @file.save }.should_not raise_error
|
645
|
-
@file.
|
662
|
+
expect(@file).to be_new_record
|
646
663
|
@file.errors.should include(:edit_users)
|
647
664
|
@file.errors[:edit_users].should include('Depositor must have edit access')
|
648
|
-
@file.
|
665
|
+
expect(@file).to_not be_valid
|
649
666
|
end
|
650
667
|
it "should work via update_permissions()" do
|
651
668
|
@rightsmd.update_permissions({"person" => {"mjg36" => "read"}})
|
652
669
|
lambda { @file.save }.should_not raise_error
|
653
|
-
@file.
|
670
|
+
expect(@file).to be_new_record
|
654
671
|
@file.errors.should include(:edit_users)
|
655
672
|
@file.errors[:edit_users].should include('Depositor must have edit access')
|
656
|
-
@file.
|
673
|
+
expect(@file).to_not be_valid
|
657
674
|
end
|
658
675
|
it "should work via content=()" do
|
659
676
|
@rightsmd.content=(@rights_xml)
|
660
677
|
lambda { @file.save }.should_not raise_error
|
661
|
-
@file.
|
678
|
+
expect(@file).to be_new_record
|
662
679
|
@file.errors.should include(:edit_users)
|
663
680
|
@file.errors[:edit_users].should include('Depositor must have edit access')
|
664
|
-
@file.
|
681
|
+
expect(@file).to_not be_valid
|
665
682
|
end
|
666
683
|
it "should work via ng_xml=()" do
|
667
684
|
@rightsmd.ng_xml=(Nokogiri::XML::Document.parse(@rights_xml))
|
668
685
|
lambda { @file.save }.should_not raise_error
|
669
|
-
@file.
|
686
|
+
expect(@file).to be_new_record
|
670
687
|
@file.errors.should include(:edit_users)
|
671
688
|
@file.errors[:edit_users].should include('Depositor must have edit access')
|
672
|
-
@file.
|
689
|
+
expect(@file).to_not be_valid
|
673
690
|
end
|
674
691
|
it "should work via update_values()" do
|
675
692
|
@rightsmd.update_values([:edit_access, :person] => '')
|
676
693
|
lambda { @file.save }.should_not raise_error
|
677
|
-
@file.
|
694
|
+
expect(@file).to be_new_record
|
678
695
|
@file.errors.should include(:edit_users)
|
679
696
|
@file.errors[:edit_users].should include('Depositor must have edit access')
|
680
|
-
@file.
|
697
|
+
expect(@file).to_not be_valid
|
681
698
|
end
|
682
699
|
end
|
683
700
|
context "public must not have edit access" do
|
@@ -718,66 +735,66 @@ describe GenericFile do
|
|
718
735
|
it "should work via permissions=()" do
|
719
736
|
@file.permissions = {group: {'public' => 'edit'}}
|
720
737
|
lambda { @file.save }.should_not raise_error
|
721
|
-
@file.
|
738
|
+
expect(@file).to be_new_record
|
722
739
|
@file.errors.should include(:edit_groups)
|
723
740
|
@file.errors[:edit_groups].should include('Public cannot have edit access')
|
724
|
-
@file.
|
741
|
+
expect(@file).to_not be_valid
|
725
742
|
end
|
726
743
|
it "should work via update_attributes" do
|
727
744
|
# automatically triggers save
|
728
745
|
lambda { @file.update_attributes(edit_groups_string: 'public') }.should_not raise_error
|
729
|
-
@file.
|
746
|
+
expect(@file).to be_new_record
|
730
747
|
@file.errors.should include(:edit_groups)
|
731
748
|
@file.errors[:edit_groups].should include('Public cannot have edit access')
|
732
|
-
@file.
|
749
|
+
expect(@file).to_not be_valid
|
733
750
|
end
|
734
751
|
it "should work via update_indexed_attributes" do
|
735
752
|
@rightsmd.update_indexed_attributes([:edit_access, :group] => 'public')
|
736
753
|
lambda { @file.save }.should_not raise_error
|
737
|
-
@file.
|
754
|
+
expect(@file).to be_new_record
|
738
755
|
@file.errors.should include(:edit_groups)
|
739
756
|
@file.errors[:edit_groups].should include('Public cannot have edit access')
|
740
|
-
@file.
|
757
|
+
expect(@file).to_not be_valid
|
741
758
|
end
|
742
759
|
it "should work via permissions()" do
|
743
760
|
@rightsmd.permissions({group: "public"}, "edit")
|
744
761
|
lambda { @file.save }.should_not raise_error
|
745
|
-
@file.
|
762
|
+
expect(@file).to be_new_record
|
746
763
|
@file.errors.should include(:edit_groups)
|
747
764
|
@file.errors[:edit_groups].should include('Public cannot have edit access')
|
748
|
-
@file.
|
765
|
+
expect(@file).to_not be_valid
|
749
766
|
end
|
750
767
|
it "should work via update_permissions()" do
|
751
768
|
@rightsmd.update_permissions({"group" => {"public" => "edit"}})
|
752
769
|
lambda { @file.save }.should_not raise_error
|
753
|
-
@file.
|
770
|
+
expect(@file).to be_new_record
|
754
771
|
@file.errors.should include(:edit_groups)
|
755
772
|
@file.errors[:edit_groups].should include('Public cannot have edit access')
|
756
|
-
@file.
|
773
|
+
expect(@file).to_not be_valid
|
757
774
|
end
|
758
775
|
it "should work via content=()" do
|
759
776
|
@rightsmd.content=(@rights_xml)
|
760
777
|
lambda { @file.save }.should_not raise_error
|
761
|
-
@file.
|
778
|
+
expect(@file).to be_new_record
|
762
779
|
@file.errors.should include(:edit_groups)
|
763
780
|
@file.errors[:edit_groups].should include('Public cannot have edit access')
|
764
|
-
@file.
|
781
|
+
expect(@file).to_not be_valid
|
765
782
|
end
|
766
783
|
it "should work via ng_xml=()" do
|
767
784
|
@rightsmd.ng_xml=(Nokogiri::XML::Document.parse(@rights_xml))
|
768
785
|
lambda { @file.save }.should_not raise_error
|
769
|
-
@file.
|
786
|
+
expect(@file).to be_new_record
|
770
787
|
@file.errors.should include(:edit_groups)
|
771
788
|
@file.errors[:edit_groups].should include('Public cannot have edit access')
|
772
|
-
@file.
|
789
|
+
expect(@file).to_not be_valid
|
773
790
|
end
|
774
791
|
it "should work via update_values()" do
|
775
792
|
@rightsmd.update_values([:edit_access, :group] => 'public')
|
776
793
|
lambda { @file.save }.should_not raise_error
|
777
|
-
@file.
|
794
|
+
expect(@file).to be_new_record
|
778
795
|
@file.errors.should include(:edit_groups)
|
779
796
|
@file.errors[:edit_groups].should include('Public cannot have edit access')
|
780
|
-
@file.
|
797
|
+
expect(@file).to_not be_valid
|
781
798
|
end
|
782
799
|
end
|
783
800
|
context "registered must not have edit access" do
|
@@ -818,66 +835,66 @@ describe GenericFile do
|
|
818
835
|
it "should work via permissions=()" do
|
819
836
|
@file.permissions = {group: {'registered' => 'edit'}}
|
820
837
|
lambda { @file.save }.should_not raise_error
|
821
|
-
@file.
|
838
|
+
expect(@file).to be_new_record
|
822
839
|
@file.errors.should include(:edit_groups)
|
823
840
|
@file.errors[:edit_groups].should include('Registered cannot have edit access')
|
824
|
-
@file.
|
841
|
+
expect(@file).to_not be_valid
|
825
842
|
end
|
826
843
|
it "should work via update_attributes" do
|
827
844
|
# automatically triggers save
|
828
845
|
lambda { @file.update_attributes(edit_groups_string: 'registered') }.should_not raise_error
|
829
|
-
@file.
|
846
|
+
expect(@file).to be_new_record
|
830
847
|
@file.errors.should include(:edit_groups)
|
831
848
|
@file.errors[:edit_groups].should include('Registered cannot have edit access')
|
832
|
-
@file.
|
849
|
+
expect(@file).to_not be_valid
|
833
850
|
end
|
834
851
|
it "should work via update_indexed_attributes" do
|
835
852
|
@rightsmd.update_indexed_attributes([:edit_access, :group] => 'registered')
|
836
853
|
lambda { @file.save }.should_not raise_error
|
837
|
-
@file.
|
854
|
+
expect(@file).to be_new_record
|
838
855
|
@file.errors.should include(:edit_groups)
|
839
856
|
@file.errors[:edit_groups].should include('Registered cannot have edit access')
|
840
|
-
@file.
|
857
|
+
expect(@file).to_not be_valid
|
841
858
|
end
|
842
859
|
it "should work via permissions()" do
|
843
860
|
@rightsmd.permissions({group: "registered"}, "edit")
|
844
861
|
lambda { @file.save }.should_not raise_error
|
845
|
-
@file.
|
862
|
+
expect(@file).to be_new_record
|
846
863
|
@file.errors.should include(:edit_groups)
|
847
864
|
@file.errors[:edit_groups].should include('Registered cannot have edit access')
|
848
|
-
@file.
|
865
|
+
expect(@file).to_not be_valid
|
849
866
|
end
|
850
867
|
it "should work via update_permissions()" do
|
851
868
|
@rightsmd.update_permissions({"group" => {"registered" => "edit"}})
|
852
869
|
lambda { @file.save }.should_not raise_error
|
853
|
-
@file.
|
870
|
+
expect(@file).to be_new_record
|
854
871
|
@file.errors.should include(:edit_groups)
|
855
872
|
@file.errors[:edit_groups].should include('Registered cannot have edit access')
|
856
|
-
@file.
|
873
|
+
expect(@file).to_not be_valid
|
857
874
|
end
|
858
875
|
it "should work via content=()" do
|
859
876
|
@rightsmd.content=(@rights_xml)
|
860
877
|
lambda { @file.save }.should_not raise_error
|
861
|
-
@file.
|
878
|
+
expect(@file).to be_new_record
|
862
879
|
@file.errors.should include(:edit_groups)
|
863
880
|
@file.errors[:edit_groups].should include('Registered cannot have edit access')
|
864
|
-
@file.
|
881
|
+
expect(@file).to_not be_valid
|
865
882
|
end
|
866
883
|
it "should work via ng_xml=()" do
|
867
884
|
@rightsmd.ng_xml=(Nokogiri::XML::Document.parse(@rights_xml))
|
868
885
|
lambda { @file.save }.should_not raise_error
|
869
|
-
@file.
|
886
|
+
expect(@file).to be_new_record
|
870
887
|
@file.errors.should include(:edit_groups)
|
871
888
|
@file.errors[:edit_groups].should include('Registered cannot have edit access')
|
872
|
-
@file.
|
889
|
+
expect(@file).to_not be_valid
|
873
890
|
end
|
874
891
|
it "should work via update_values()" do
|
875
892
|
@rightsmd.update_values([:edit_access, :group] => 'registered')
|
876
893
|
lambda { @file.save }.should_not raise_error
|
877
|
-
@file.
|
894
|
+
expect(@file).to be_new_record
|
878
895
|
@file.errors.should include(:edit_groups)
|
879
896
|
@file.errors[:edit_groups].should include('Registered cannot have edit access')
|
880
|
-
@file.
|
897
|
+
expect(@file).to_not be_valid
|
881
898
|
end
|
882
899
|
end
|
883
900
|
context "everything is copacetic" do
|
@@ -920,58 +937,58 @@ describe GenericFile do
|
|
920
937
|
it "should work via permissions=()" do
|
921
938
|
@file.permissions = {group: {'registered' => 'read'}}
|
922
939
|
lambda { @file.save }.should_not raise_error
|
923
|
-
@file.
|
940
|
+
expect(@file).to_not be_new_record
|
924
941
|
@file.errors.should be_empty
|
925
|
-
@file.
|
942
|
+
expect(@file).to be_valid
|
926
943
|
end
|
927
944
|
it "should work via update_attributes" do
|
928
945
|
# automatically triggers save
|
929
946
|
lambda { @file.update_attributes(read_groups_string: 'registered') }.should_not raise_error
|
930
|
-
@file.
|
947
|
+
expect(@file).to_not be_new_record
|
931
948
|
@file.errors.should be_empty
|
932
|
-
@file.
|
949
|
+
expect(@file).to be_valid
|
933
950
|
end
|
934
951
|
it "should work via update_indexed_attributes" do
|
935
952
|
@rightsmd.update_indexed_attributes([:read_access, :group] => 'registered')
|
936
953
|
lambda { @file.save }.should_not raise_error
|
937
|
-
@file.
|
954
|
+
expect(@file).to_not be_new_record
|
938
955
|
@file.errors.should be_empty
|
939
|
-
@file.
|
956
|
+
expect(@file).to be_valid
|
940
957
|
end
|
941
958
|
it "should work via permissions()" do
|
942
959
|
@rightsmd.permissions({group: "registered"}, "read")
|
943
960
|
lambda { @file.save }.should_not raise_error
|
944
|
-
@file.
|
961
|
+
expect(@file).to_not be_new_record
|
945
962
|
@file.errors.should be_empty
|
946
|
-
@file.
|
963
|
+
expect(@file).to be_valid
|
947
964
|
end
|
948
965
|
it "should work via update_permissions()" do
|
949
966
|
@rightsmd.update_permissions({"group" => {"registered" => "read"}})
|
950
967
|
lambda { @file.save }.should_not raise_error
|
951
|
-
@file.
|
968
|
+
expect(@file).to_not be_new_record
|
952
969
|
@file.errors.should be_empty
|
953
|
-
@file.
|
970
|
+
expect(@file).to be_valid
|
954
971
|
end
|
955
972
|
it "should work via content=()" do
|
956
973
|
@rightsmd.content=(@rights_xml)
|
957
974
|
lambda { @file.save }.should_not raise_error
|
958
|
-
@file.
|
975
|
+
expect(@file).to_not be_new_record
|
959
976
|
@file.errors.should be_empty
|
960
|
-
@file.
|
977
|
+
expect(@file).to be_valid
|
961
978
|
end
|
962
979
|
it "should work via ng_xml=()" do
|
963
980
|
@rightsmd.ng_xml=(Nokogiri::XML::Document.parse(@rights_xml))
|
964
981
|
lambda { @file.save }.should_not raise_error
|
965
|
-
@file.
|
982
|
+
expect(@file).to_not be_new_record
|
966
983
|
@file.errors.should be_empty
|
967
|
-
@file.
|
984
|
+
expect(@file).to be_valid
|
968
985
|
end
|
969
986
|
it "should work via update_values()" do
|
970
987
|
@rightsmd.update_values([:read_access, :group] => 'registered')
|
971
988
|
lambda { @file.save }.should_not raise_error
|
972
|
-
@file.
|
989
|
+
expect(@file).to_not be_new_record
|
973
990
|
@file.errors.should be_empty
|
974
|
-
@file.
|
991
|
+
expect(@file).to be_valid
|
975
992
|
end
|
976
993
|
end
|
977
994
|
end
|
@@ -1011,7 +1028,7 @@ describe GenericFile do
|
|
1011
1028
|
f2 = GenericFile.find(subject.id)
|
1012
1029
|
f2.reload_on_save = true
|
1013
1030
|
f1.mime_type = "video/abc123"
|
1014
|
-
f2.title = "abc123"
|
1031
|
+
f2.title = ["abc123"]
|
1015
1032
|
f1.save
|
1016
1033
|
mime_type_key = Solrizer.solr_name("mime_type")
|
1017
1034
|
title_key = Solrizer.solr_name("desc_metadata__title", :stored_searchable, type: :string)
|
@@ -1024,15 +1041,14 @@ describe GenericFile do
|
|
1024
1041
|
end
|
1025
1042
|
|
1026
1043
|
describe "public?" do
|
1027
|
-
|
1028
|
-
subject.read_groups = ['public']
|
1029
|
-
|
1044
|
+
context "when read group is set to public" do
|
1045
|
+
before { subject.read_groups = ['public'] }
|
1046
|
+
it { should be_public }
|
1030
1047
|
end
|
1031
1048
|
|
1032
|
-
|
1033
|
-
subject.read_groups = ['foo']
|
1034
|
-
|
1049
|
+
context "when read group is not set to public" do
|
1050
|
+
before { subject.read_groups = ['foo'] }
|
1051
|
+
it { should_not be_public }
|
1035
1052
|
end
|
1036
|
-
|
1037
1053
|
end
|
1038
1054
|
end
|