worthwhile 0.0.1.alpha → 0.0.1
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/.gitignore +3 -1
- data/.rspec +1 -0
- data/.travis.yml +19 -0
- data/Gemfile +7 -11
- data/README.md +8 -12
- data/Rakefile +17 -2
- data/app/actors/concerns/worthwhile/manages_embargoes_actor.rb +79 -0
- data/app/actors/curation_concern/base_actor.rb +68 -0
- data/app/actors/curation_concern/generic_file_actor.rb +40 -0
- data/app/actors/curation_concern/generic_work_actor.rb +92 -0
- data/app/actors/curation_concern/linked_resource_actor.rb +4 -0
- data/app/assets/images/default.png +0 -0
- data/app/assets/images/nope.png +0 -0
- data/app/assets/javascripts/.gitkeep +0 -0
- data/app/assets/javascripts/modernizr.js +3 -0
- data/app/assets/javascripts/worthwhile/.gitkeep +0 -0
- data/app/assets/javascripts/worthwhile/accept_contributor_agreement.js +15 -0
- data/app/assets/javascripts/worthwhile/application.js +18 -0
- data/app/assets/javascripts/worthwhile/browse_everything_implement.js +7 -0
- data/app/assets/javascripts/worthwhile/embargoes.js +17 -0
- data/app/assets/javascripts/worthwhile/facet_mine.js +22 -0
- data/app/assets/javascripts/worthwhile/help_modal.js +36 -0
- data/app/assets/javascripts/worthwhile/link_groups.js.coffee +123 -0
- data/app/assets/javascripts/worthwhile/link_users.js.coffee +126 -0
- data/app/assets/javascripts/worthwhile/manage_repeating_fields.js +74 -0
- data/app/assets/javascripts/worthwhile/proxy_rights.js.coffee +95 -0
- data/app/assets/javascripts/worthwhile/proxy_submission.js +23 -0
- data/app/assets/javascripts/worthwhile/select_works.js.coffee +20 -0
- data/app/assets/javascripts/worthwhile/worthwhile.js +45 -0
- data/app/assets/stylesheets/worthwhile.css.scss +23 -0
- data/app/assets/stylesheets/worthwhile/_global-variables.css.scss +5 -0
- data/app/assets/stylesheets/worthwhile/_modules.css.scss +14 -0
- data/app/assets/stylesheets/worthwhile/_positioning.css.scss +138 -0
- data/app/assets/stylesheets/worthwhile/_theme.css.scss +46 -0
- data/app/assets/stylesheets/worthwhile/_typography.css.scss +142 -0
- data/app/assets/stylesheets/worthwhile/_variables_bootstrap.css.scss +7 -0
- data/app/assets/stylesheets/worthwhile/_worthwhile.css.scss +7 -0
- data/app/assets/stylesheets/worthwhile/downloads.css.scss +3 -0
- data/app/assets/stylesheets/worthwhile/help_requests.css.scss +3 -0
- data/app/assets/stylesheets/worthwhile/modules/accessibility.css.scss +50 -0
- data/app/assets/stylesheets/worthwhile/modules/accordion.css.scss +33 -0
- data/app/assets/stylesheets/worthwhile/modules/attributes.css.scss +26 -0
- data/app/assets/stylesheets/worthwhile/modules/classify_work.css.scss +100 -0
- data/app/assets/stylesheets/worthwhile/modules/collections.css.scss +42 -0
- data/app/assets/stylesheets/worthwhile/modules/embargoes.css.scss +15 -0
- data/app/assets/stylesheets/worthwhile/modules/emphatic_action_area.css.scss +14 -0
- data/app/assets/stylesheets/worthwhile/modules/forms.css.scss +116 -0
- data/app/assets/stylesheets/worthwhile/modules/multi_value_fields.css.scss +52 -0
- data/app/assets/stylesheets/worthwhile/modules/pagination.css.scss +4 -0
- data/app/assets/stylesheets/worthwhile/modules/search_results.css.scss +55 -0
- data/app/assets/stylesheets/worthwhile/modules/site_actions.css.scss +53 -0
- data/app/assets/stylesheets/worthwhile/modules/site_search.css.scss +46 -0
- data/app/controllers/catalog_controller.rb +3 -0
- data/app/controllers/collections_controller.rb +59 -0
- data/app/controllers/concerns/worthwhile/application_controller_behavior.rb +23 -0
- data/app/controllers/concerns/worthwhile/catalog_controller.rb +347 -0
- data/app/controllers/concerns/worthwhile/curation_concern_controller.rb +131 -0
- data/app/controllers/concerns/worthwhile/files_controller.rb +149 -0
- data/app/controllers/concerns/worthwhile/manages_embargoes.rb +22 -0
- data/app/controllers/concerns/worthwhile/parent_container.rb +31 -0
- data/app/controllers/concerns/worthwhile/themed_layout_controller.rb +31 -0
- data/app/controllers/concerns/worthwhile/without_namespace.rb +15 -0
- data/app/controllers/curation_concern/generic_files_controller.rb +6 -0
- data/app/controllers/curation_concern/generic_works_controller.rb +6 -0
- data/app/controllers/curation_concern/linked_resources_controller.rb +68 -0
- data/app/controllers/curation_concern/permissions_controller.rb +19 -0
- data/app/controllers/downloads_controller.rb +4 -0
- data/app/controllers/embargoes_controller.rb +44 -0
- data/app/controllers/leases_controller.rb +34 -0
- data/app/controllers/registrations_controller.rb +20 -0
- data/app/controllers/sessions_controller.rb +4 -0
- data/app/controllers/worthwhile/application_controller.rb +7 -0
- data/app/controllers/worthwhile/classify_concerns_controller.rb +35 -0
- data/app/datastreams/generic_work_metadata.rb +3 -0
- data/app/datastreams/worthwhile/generic_work_rdf_properties.rb +57 -0
- data/app/datastreams/worthwhile/properties_datastream.rb +28 -0
- data/app/helpers/curate/collections_helper.rb +133 -0
- data/app/helpers/worthwhile/ability_helper.rb +46 -0
- data/app/helpers/worthwhile/attribute_helper.rb +67 -0
- data/app/helpers/worthwhile/catalog_helper.rb +38 -0
- data/app/helpers/worthwhile/collections_helper.rb +19 -0
- data/app/helpers/worthwhile/embargo_helper.rb +17 -0
- data/app/helpers/worthwhile/generic_file_helper.rb +19 -0
- data/app/helpers/worthwhile/lease_helper.rb +18 -0
- data/app/helpers/worthwhile/main_app_helpers.rb +14 -0
- data/app/helpers/worthwhile/render_constraints_helper.rb +42 -0
- data/app/helpers/worthwhile/search_paths_helper.rb +13 -0
- data/app/helpers/worthwhile/thumbnail_helper.rb +11 -0
- data/app/helpers/worthwhile/title_helper.rb +23 -0
- data/app/helpers/worthwhile/url_helper.rb +16 -0
- data/app/inputs/multi_value_input.rb +72 -0
- data/app/models/collection.rb +15 -0
- data/app/models/concerns/curation_concern/collection_model.rb +62 -0
- data/app/models/concerns/curation_concern/curatable.rb +77 -0
- data/app/models/concerns/curation_concern/has_representative.rb +14 -0
- data/app/models/concerns/curation_concern/human_readable_type.rb +23 -0
- data/app/models/concerns/curation_concern/with_basic_metadata.rb +49 -0
- data/app/models/concerns/curation_concern/with_editors.rb +44 -0
- data/app/models/concerns/curation_concern/with_generic_files.rb +23 -0
- data/app/models/concerns/curation_concern/with_linked_resources.rb +21 -0
- data/app/models/concerns/curation_concern/work.rb +24 -0
- data/app/models/concerns/worthwhile/ability.rb +34 -0
- data/app/models/concerns/worthwhile/generic_file/versioned_content.rb +18 -0
- data/app/models/concerns/worthwhile/generic_file_base.rb +64 -0
- data/app/models/concerns/worthwhile/solr_document_behavior.rb +140 -0
- data/app/models/generic_work.rb +5 -0
- data/app/models/worthwhile/classify_concern.rb +47 -0
- data/app/models/worthwhile/content_version.rb +23 -0
- data/app/models/worthwhile/contributor_agreement.rb +23 -0
- data/app/models/worthwhile/generic_file.rb +5 -0
- data/app/models/worthwhile/linked_resource.rb +41 -0
- data/app/models/worthwhile/quick_classification_query.rb +31 -0
- data/app/services/worthwhile/curation_concern.rb +21 -0
- data/app/services/worthwhile/embargo_service.rb +26 -0
- data/app/services/worthwhile/lease_service.rb +23 -0
- data/app/views/catalog/_action_menu_partials/_collection.html.erb +27 -0
- data/app/views/catalog/_action_menu_partials/_default.html.erb +27 -0
- data/app/views/catalog/_document.html.erb +3 -0
- data/app/views/catalog/_document_list.html.erb +5 -0
- data/app/views/catalog/_home_text.html.erb +8 -0
- data/app/views/catalog/_index_default.html.erb +17 -0
- data/app/views/catalog/_index_header_list_default.html.erb +17 -0
- data/app/views/catalog/_navbar.html.erb +12 -0
- data/app/views/catalog/_show_partials/_default.html.erb +22 -0
- data/app/views/catalog/_show_partials/_default_details.html.erb +15 -0
- data/app/views/catalog/_show_partials/_facets.html.erb +52 -0
- data/app/views/catalog/index.html.erb +48 -0
- data/app/views/collections/_batch_edits_actions.html.erb +3 -0
- data/app/views/collections/_button_for_creating_empty_collection.html.erb +3 -0
- data/app/views/collections/_collection.html.erb +1 -0
- data/app/views/collections/_dashboard_document_list.html.erb +6 -0
- data/app/views/collections/_document_list.html.erb +7 -0
- data/app/views/collections/_edit_actions.html.erb +5 -0
- data/app/views/collections/_edit_descriptions.html.erb +20 -0
- data/app/views/collections/_form.html.erb +26 -0
- data/app/views/collections/_form_for_select_collection.html.erb +34 -0
- data/app/views/collections/_form_permission.html.erb +36 -0
- data/app/views/collections/_form_required_information.html.erb +11 -0
- data/app/views/collections/_identifier_and_action.html.erb +15 -0
- data/app/views/collections/_media_display.html.erb +1 -0
- data/app/views/collections/_paginate.html.erb +6 -0
- data/app/views/collections/_search_collection_dashboard_form.html.erb +10 -0
- data/app/views/collections/_show_actions.html.erb +8 -0
- data/app/views/collections/_show_descriptions.html.erb +10 -0
- data/app/views/collections/_show_fields.html.erb +0 -0
- data/app/views/collections/_single_item_action_fields.html.erb +6 -0
- data/app/views/collections/_sort_and_per_page.html.erb +29 -0
- data/app/views/collections/_view_type_group.html.erb +13 -0
- data/app/views/collections/edit.html.erb +22 -0
- data/app/views/collections/new.html.erb +15 -0
- data/app/views/collections/show.html.erb +24 -0
- data/app/views/curate/collections/_add_to_collection_modal.html.erb +15 -0
- data/app/views/curate/collections/_button_remove_from_collection.html.erb +6 -0
- data/app/views/curate/collections/_form_to_add_member.html.erb +27 -0
- data/app/views/curate/collections/add_member_form.html.erb +6 -0
- data/app/views/curation_concern/base/_attributes.html.erb +25 -0
- data/app/views/curation_concern/base/_collections.html.erb +26 -0
- data/app/views/curation_concern/base/_form.html.erb +27 -0
- data/app/views/curation_concern/base/_form_additional_information.html.erb +9 -0
- data/app/views/curation_concern/base/_form_content_license.html.erb +16 -0
- data/app/views/curation_concern/base/_form_contributor_agreement.html.erb +29 -0
- data/app/views/curation_concern/base/_form_descriptive_fields.erb +23 -0
- data/app/views/curation_concern/base/_form_files_and_links.html.erb +29 -0
- data/app/views/curation_concern/base/_form_permission.html.erb +52 -0
- data/app/views/curation_concern/base/_form_permission_embargo.html.erb +6 -0
- data/app/views/curation_concern/base/_form_permission_lease.html.erb +6 -0
- data/app/views/curation_concern/base/_form_permission_under_embargo.html.erb +16 -0
- data/app/views/curation_concern/base/_form_permission_under_lease.html.erb +18 -0
- data/app/views/curation_concern/base/_form_representative_image.html.erb +13 -0
- data/app/views/curation_concern/base/_form_required_information.html.erb +11 -0
- data/app/views/curation_concern/base/_form_supplementary_fields.html.erb +15 -0
- data/app/views/curation_concern/base/_legally_binding_text.html.erb +33 -0
- data/app/views/curation_concern/base/_related_files.html.erb +24 -0
- data/app/views/curation_concern/base/_related_resources.html.erb +40 -0
- data/app/views/curation_concern/base/_representative_media.html.erb +8 -0
- data/app/views/curation_concern/base/edit.html.erb +15 -0
- data/app/views/curation_concern/base/new.html.erb +14 -0
- data/app/views/curation_concern/base/show.html.erb +32 -0
- data/app/views/curation_concern/base/unauthorized.html.erb +3 -0
- data/app/views/curation_concern/generic_files/_form.html.erb +35 -0
- data/app/views/curation_concern/generic_files/_media_display.html.erb +20 -0
- data/app/views/curation_concern/generic_files/edit.html.erb +5 -0
- data/app/views/curation_concern/generic_files/show.html.erb +15 -0
- data/app/views/curation_concern/generic_works/_generic_work.html.erb +3 -0
- data/app/views/curation_concern/linked_resources/_form.html.erb +11 -0
- data/app/views/curation_concern/linked_resources/edit.html.erb +5 -0
- data/app/views/curation_concern/linked_resources/new.html.erb +5 -0
- data/app/views/curation_concern/permissions/confirm.html.erb +13 -0
- data/app/views/curation_concern/worthwhile/generic_files/_actions.html.erb +16 -0
- data/app/views/curation_concern/worthwhile/generic_files/_generic_file.html.erb +12 -0
- data/app/views/embargoes/_embargo_history.html.erb +7 -0
- data/app/views/embargoes/_list_active_embargoes.html.erb +16 -0
- data/app/views/embargoes/_list_deactivated_embargoes.html.erb +10 -0
- data/app/views/embargoes/_list_expired_active_embargoes.html.erb +44 -0
- data/app/views/embargoes/edit.html.erb +43 -0
- data/app/views/embargoes/index.html.erb +18 -0
- data/app/views/layouts/boilerplate.html.erb +22 -0
- data/app/views/layouts/common_objects.html.erb +36 -0
- data/app/views/layouts/curate_nd.html.erb +33 -0
- data/app/views/layouts/curate_nd/1_column.html.erb +22 -0
- data/app/views/layouts/curate_nd/2_column.html.erb +26 -0
- data/app/views/layouts/curate_nd/catalog.html.erb +38 -0
- data/app/views/layouts/curate_nd/dashboard.html.erb +22 -0
- data/app/views/leases/_lease_history.html.erb +7 -0
- data/app/views/leases/_list_active_leases.html.erb +16 -0
- data/app/views/leases/_list_deactivated_leases.html.erb +4 -0
- data/app/views/leases/_list_expired_active_leases.html.erb +38 -0
- data/app/views/leases/edit.html.erb +43 -0
- data/app/views/leases/index.html.erb +18 -0
- data/app/views/shared/_add_content.html.erb +32 -0
- data/app/views/shared/_brand_bar.html.erb +10 -0
- data/app/views/shared/_flash_message.html.erb +17 -0
- data/app/views/shared/_footer.html.erb +10 -0
- data/app/views/shared/_ga.html.erb +6 -0
- data/app/views/shared/_header.html.erb +12 -0
- data/app/views/shared/_my_actions.html.erb +21 -0
- data/app/views/shared/_site_actions.html.erb +7 -0
- data/app/views/shared/_site_search.html.erb +12 -0
- data/app/views/shared/_title_bar.html.erb +16 -0
- data/app/views/worthwhile/classify_concerns/new.html.erb +27 -0
- data/app/workers/visibility_copy_worker.rb +29 -0
- data/config/initializers/simple_form.rb +31 -0
- data/config/locales/sufia.en.yml +26 -0
- data/config/locales/worthwhile.en.yml +68 -0
- data/config/routes.rb +4 -0
- data/lib/generators/worthwhile/install_generator.rb +74 -0
- data/lib/generators/worthwhile/templates/worthwhile.css.scss +3 -0
- data/lib/generators/worthwhile/templates/worthwhile.js +1 -0
- data/lib/generators/worthwhile/templates/worthwhile_config.rb +3 -0
- data/lib/generators/worthwhile/templates/worthwhile_helper.rb +4 -0
- data/lib/worthwhile.rb +3 -1
- data/lib/worthwhile/configuration.rb +74 -0
- data/lib/worthwhile/controller_resource.rb +10 -0
- data/lib/worthwhile/engine.rb +20 -0
- data/lib/worthwhile/rails/routes.rb +78 -0
- data/lib/worthwhile/spec_support.rb +10 -0
- data/lib/worthwhile/version.rb +1 -1
- data/spec/abilities/generic_file_abilities_spec.rb +62 -0
- data/spec/abilities/generic_work_abilities_spec.rb +58 -0
- data/spec/actors/curation_concern/generic_work_actor_spec.rb +215 -0
- data/spec/actors/curation_concern/linked_resource_actor_spec.rb +36 -0
- data/spec/actors/worthwile/manages_embargoes_actor_spec.rb +95 -0
- data/spec/controllers/catalog_controller_spec.rb +114 -0
- data/spec/controllers/collections_controller_spec.rb +216 -0
- data/spec/controllers/curation_concern/generic_files_controller_spec.rb +258 -0
- data/spec/controllers/curation_concern/generic_works_controller_spec.rb +171 -0
- data/spec/controllers/curation_concern/linked_resources_controller_spec.rb +123 -0
- data/spec/controllers/curation_concern/permissions_controller_spec.rb +29 -0
- data/spec/controllers/downloads_controller_spec.rb +53 -0
- data/spec/controllers/embargoes_controller_spec.rb +107 -0
- data/spec/controllers/leases_controller_spec.rb +95 -0
- data/spec/controllers/worthwhile/classify_concerns_controller_spec.rb +35 -0
- data/spec/factories/collections_factory.rb +21 -0
- data/spec/factories/create_curation_concern.rb +3 -0
- data/spec/factories/generic_files.rb +18 -0
- data/spec/factories/generic_works.rb +37 -0
- data/spec/factories/linked_resources_factory.rb +18 -0
- data/spec/factories/users.rb +15 -0
- data/spec/features/add_external_link_spec.rb +25 -0
- data/spec/features/add_file_spec.rb +28 -0
- data/spec/features/collection_spec.rb +238 -0
- data/spec/features/embargo_spec.rb +45 -0
- data/spec/features/lease_spec.rb +43 -0
- data/spec/features/update_file_spec.rb +28 -0
- data/spec/fixtures/files/image.png +0 -0
- data/spec/helpers/catalog_helper_spec.rb +58 -0
- data/spec/helpers/configuration_helper_spec.rb +13 -0
- data/spec/helpers/render_constraints_helper_spec.rb +19 -0
- data/spec/helpers/thumbnail_helper_spec.rb +21 -0
- data/spec/helpers/url_helper_spec.rb +19 -0
- data/spec/matchers.rb +24 -0
- data/spec/matchers/metadata_field_matchers.rb +28 -0
- data/spec/models/collection_spec.rb +136 -0
- data/spec/models/curation_concern/collection_model_spec.rb +50 -0
- data/spec/models/curation_concern/work_spec.rb +30 -0
- data/spec/models/generic_work_spec.rb +24 -0
- data/spec/models/worthwhile/content_version_spec.rb +27 -0
- data/spec/models/worthwhile/generic_file_spec.rb +77 -0
- data/spec/models/worthwhile/linked_resource_spec.rb +76 -0
- data/spec/routing/worthwhile/routes_spec.rb +23 -0
- data/spec/services/embargo_service_spec.rb +38 -0
- data/spec/services/lease_service_spec.rb +37 -0
- data/spec/spec_helper.rb +30 -5
- data/spec/support/controllers/engine_helpers.rb +7 -0
- data/spec/support/curation_concern/factory_helpers.rb +14 -0
- data/spec/support/features.rb +19 -0
- data/spec/support/features/fixture_file_upload.rb +14 -0
- data/spec/support/features/session_helpers.rb +41 -0
- data/spec/support/shared/shared_examples_has_dc_metadata.rb +17 -0
- data/spec/support/shared/shared_examples_is_a_curation_concern_model.rb +40 -0
- data/spec/support/shared/shared_examples_is_embargoable.rb +8 -0
- data/spec/support/shared/shared_examples_with_access_rights.rb +63 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +8 -29
- data/spec/views/curation_concern/base/_attributes.html.erb_spec.rb +25 -0
- data/spec/views/curation_concern/base/show.html.erb_spec.rb +25 -0
- data/spec/views/shared/_add_content.html.erb_spec.rb +42 -0
- data/spec/views/shared/_my_actions.html.erb_spec.rb +23 -0
- data/spec/workers/visibility_copy_worker_spec.rb +68 -0
- data/vendor/assets/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/vendor/assets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/vendor/assets/javascripts/handlebars.js +2278 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.autocomplete.js +602 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.core.js +356 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.effect-highlight.js +50 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.effect.js +1276 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.menu.js +610 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.position.js +498 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.widget.js +528 -0
- data/vendor/assets/javascripts/jquery.tokeninput.js +1061 -0
- data/vendor/assets/stylesheets/jquery-ui-lightness.css +474 -0
- data/vendor/assets/stylesheets/token-input-facebook.css +122 -0
- data/vendor/assets/stylesheets/token-input-mac.css +204 -0
- data/vendor/assets/stylesheets/token-input.css +127 -0
- data/worthwhile.gemspec +9 -3
- metadata +469 -9
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe CurationConcern::CollectionModel do
|
|
4
|
+
before do
|
|
5
|
+
class EssentialCollection < ActiveFedora::Base
|
|
6
|
+
include CurationConcern::CollectionModel
|
|
7
|
+
def members; @members ||= []; end
|
|
8
|
+
def save; true; end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
after do
|
|
12
|
+
Object.send(:remove_const, :EssentialCollection)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context '.add_member' do
|
|
16
|
+
let(:collectible?) { nil }
|
|
17
|
+
let(:proposed_collectible) { double(collections: []) }
|
|
18
|
+
subject { EssentialCollection.new }
|
|
19
|
+
before(:each) {
|
|
20
|
+
proposed_collectible.stub(:can_be_member_of_collection?).with(subject).and_return(collectible?)
|
|
21
|
+
proposed_collectible.stub(:save).and_return(true)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
context 'with itself' do
|
|
25
|
+
it 'does not add it to the collection\'s members' do
|
|
26
|
+
expect {
|
|
27
|
+
subject.add_member(subject)
|
|
28
|
+
}.to_not change{ subject.members.size }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context 'with a non-collectible object' do
|
|
33
|
+
let(:collectible?) { false }
|
|
34
|
+
it 'does not add it to the collection\'s members' do
|
|
35
|
+
expect {
|
|
36
|
+
subject.add_member(proposed_collectible)
|
|
37
|
+
}.to_not change{ subject.members.size }
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
context 'with a collectible object' do
|
|
42
|
+
let(:collectible?) { true }
|
|
43
|
+
it 'adds it to the collection\'s members' do
|
|
44
|
+
expect {
|
|
45
|
+
subject.add_member(proposed_collectible)
|
|
46
|
+
}.to change{ subject.members.size }.by(1)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe CurationConcern::Work do
|
|
4
|
+
before do
|
|
5
|
+
class EssentialWork < ActiveFedora::Base
|
|
6
|
+
include CurationConcern::Work
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
after do
|
|
10
|
+
Object.send(:remove_const, :EssentialWork)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
subject { EssentialWork.new }
|
|
14
|
+
|
|
15
|
+
it "should mix together all the goodness" do
|
|
16
|
+
[::CurationConcern::WithGenericFiles, ::CurationConcern::HumanReadableType, Hydra::AccessControls::Embargoable, ::CurationConcern::WithEditors, Sufia::Noid, Sufia::ModelMethods, Hydra::Collections::Collectible, Solrizer::Common].each do |mixin|
|
|
17
|
+
expect(subject.class.ancestors).to include(mixin)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe "human_readable_type" do
|
|
22
|
+
it "has a default" do
|
|
23
|
+
expect(subject.human_readable_type).to eq 'Essential Work'
|
|
24
|
+
end
|
|
25
|
+
it "should be settable" do
|
|
26
|
+
EssentialWork.human_readable_type = 'Custom Type'
|
|
27
|
+
expect(subject.human_readable_type).to eq 'Custom Type'
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe GenericWork do
|
|
4
|
+
it "should have a title" do
|
|
5
|
+
subject.title = ['foo']
|
|
6
|
+
expect(subject.title).to eq ['foo']
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
context "with attached files" do
|
|
10
|
+
subject { FactoryGirl.build(:work_with_files) }
|
|
11
|
+
|
|
12
|
+
it "should have two files" do
|
|
13
|
+
expect(subject.generic_files.size).to eq 2
|
|
14
|
+
expect(subject.generic_files.first).to be_kind_of Worthwhile::GenericFile
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe "to_solr" do
|
|
19
|
+
subject { FactoryGirl.build(:work, date_uploaded: Date.today).to_solr }
|
|
20
|
+
it "indexes some fields" do
|
|
21
|
+
expect(subject.keys).to include 'desc_metadata__date_uploaded_dtsi'
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Worthwhile
|
|
4
|
+
describe ContentVersion do
|
|
5
|
+
let(:content) { double }
|
|
6
|
+
let(:created_on) { Time.now }
|
|
7
|
+
let(:version_id) { 'content.1'}
|
|
8
|
+
let(:committer_name) { 'darryl' }
|
|
9
|
+
let(:raw_version) { double(dsCreateDate: created_on, versionID: version_id) }
|
|
10
|
+
subject { described_class.new(content, raw_version) }
|
|
11
|
+
|
|
12
|
+
before(:each) do
|
|
13
|
+
content.stub(:version_committer).with(raw_version).and_return(committer_name)
|
|
14
|
+
end
|
|
15
|
+
its(:created_on) { should eq(created_on) }
|
|
16
|
+
its(:committer_name) { should eq(committer_name) }
|
|
17
|
+
its(:version_id) { should eq version_id }
|
|
18
|
+
its(:formatted_created_on) { should eq created_on.localtime.to_formatted_s(:long_ordinal)}
|
|
19
|
+
end
|
|
20
|
+
describe ContentVersion::Null do
|
|
21
|
+
subject { described_class.new(double)}
|
|
22
|
+
its(:created_on) { should eq 'unknown'}
|
|
23
|
+
its(:committer_name) { should eq 'unknown'}
|
|
24
|
+
its(:version_id) { should eq 'unknown'}
|
|
25
|
+
its(:formatted_created_on) { should eq 'unknown'}
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -4,4 +4,81 @@ describe Worthwhile::GenericFile do
|
|
|
4
4
|
it "should have depositor" do
|
|
5
5
|
subject.depositor = 'tess@example.com'
|
|
6
6
|
end
|
|
7
|
+
|
|
8
|
+
describe "to_solr" do
|
|
9
|
+
before do
|
|
10
|
+
subject.title = ['One Flew Over the Cuckoo\'s Nest']
|
|
11
|
+
subject.characterization.metadata.image.height = '500'
|
|
12
|
+
subject.characterization.metadata.image.width = '600'
|
|
13
|
+
end
|
|
14
|
+
let(:solr_doc) { subject.to_solr }
|
|
15
|
+
|
|
16
|
+
it "has a solr_doc" do
|
|
17
|
+
expect(solr_doc['desc_metadata__title_tesim']).to eq ['One Flew Over the Cuckoo\'s Nest']
|
|
18
|
+
expect(solr_doc['desc_metadata__title_sim']).to eq ['One Flew Over the Cuckoo\'s Nest']
|
|
19
|
+
expect(solr_doc['height_isi']).to eq 500
|
|
20
|
+
expect(solr_doc['width_isi']).to eq 600
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
describe 'with a parent work' do
|
|
26
|
+
let(:parent_pid) { 'pid:123' }
|
|
27
|
+
let!(:parent) {
|
|
28
|
+
if ActiveFedora::Base.exists?(parent_pid)
|
|
29
|
+
ActiveFedora::Base.find(parent_pid).destroy
|
|
30
|
+
end
|
|
31
|
+
GenericWork.new pid: parent_pid, title: ['asdf']
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
subject { Worthwhile::GenericFile.create(batch: parent) }
|
|
35
|
+
|
|
36
|
+
describe '#remove_representative_relationship' do
|
|
37
|
+
let(:some_other_pid) { 'something:456' }
|
|
38
|
+
before do
|
|
39
|
+
parent.representative = some_other_pid
|
|
40
|
+
parent.save!
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
context "the parent object doesn't exist" do
|
|
44
|
+
before do
|
|
45
|
+
parent.representative = subject.pid
|
|
46
|
+
parent.save!
|
|
47
|
+
@parent_pid = parent.pid
|
|
48
|
+
parent.destroy
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "doesn't raise an error" do
|
|
52
|
+
expect(ActiveFedora::Base.exists?(@parent_pid)).to eq false
|
|
53
|
+
expect {
|
|
54
|
+
subject.remove_representative_relationship
|
|
55
|
+
}.to_not raise_error
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context 'it is not the representative' do
|
|
60
|
+
it "doesn't update parent work when file is deleted" do
|
|
61
|
+
expect(subject.batch).to eq parent
|
|
62
|
+
expect(parent.representative).to eq some_other_pid
|
|
63
|
+
subject.destroy
|
|
64
|
+
expect(parent.representative).to eq some_other_pid
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context 'it is the representative' do
|
|
69
|
+
before do
|
|
70
|
+
parent.representative = subject.pid
|
|
71
|
+
parent.save!
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'updates the parent work when the file is deleted' do
|
|
75
|
+
expect(subject.batch).to eq parent
|
|
76
|
+
expect(parent.representative).to eq subject.pid
|
|
77
|
+
subject.destroy
|
|
78
|
+
expect(parent.representative).to be_nil
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
7
84
|
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Worthwhile::LinkedResource do
|
|
4
|
+
subject { Worthwhile::LinkedResource.new }
|
|
5
|
+
|
|
6
|
+
it { should respond_to(:human_readable_type) }
|
|
7
|
+
|
|
8
|
+
it 'has a #human_readable_short_description' do
|
|
9
|
+
subject.human_readable_short_description.length.should_not == 0
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'has a .human_readable_short_description' do
|
|
13
|
+
subject.class.human_readable_short_description.length.should_not == 0
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'uses #noid for #to_param' do
|
|
17
|
+
subject.stub(:persisted?).and_return(true)
|
|
18
|
+
subject.to_param.should == subject.noid
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'has no url to display' do
|
|
22
|
+
subject.to_s.should == nil
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "validating" do
|
|
26
|
+
subject {Worthwhile::LinkedResource.new}
|
|
27
|
+
it "should not validate and have an error" do
|
|
28
|
+
subject.should_not be_valid
|
|
29
|
+
subject.errors[:url].should == ["can't be blank"]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "sanitizing" do
|
|
34
|
+
context "javascript uri" do
|
|
35
|
+
subject { FactoryGirl.build(:linked_resource, url: "javascript:void(alert('Hello'));") }
|
|
36
|
+
it "should be cleared" do
|
|
37
|
+
subject.url.should be_nil
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
context "http uri" do
|
|
41
|
+
subject { FactoryGirl.build(:linked_resource, url: "http://www.youtube.com/watch?v=oHg5SJYRHA0") }
|
|
42
|
+
it "should be stored" do
|
|
43
|
+
expect(subject.to_s).to eq 'http://www.youtube.com/watch?v=oHg5SJYRHA0'
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
context "https uri" do
|
|
47
|
+
subject { FactoryGirl.build(:linked_resource, url: "https://www.youtube.com/watch?v=oHg5SJYRHA0") }
|
|
48
|
+
it "should be stored" do
|
|
49
|
+
expect(subject.to_s).to eq 'https://www.youtube.com/watch?v=oHg5SJYRHA0'
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
context "ftp uri" do
|
|
53
|
+
subject { FactoryGirl.build(:linked_resource, url: "ftp://ftp.ed.ac.uk") }
|
|
54
|
+
it "should be stored" do
|
|
55
|
+
expect(subject.to_s).to eq 'ftp://ftp.ed.ac.uk/'
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
context '#to_solr' do
|
|
61
|
+
subject { Worthwhile::LinkedResource.new(url: 'http://www.youtube.com/watch?v=oHg5SJYRHA0') }
|
|
62
|
+
it 'should solrize its url' do
|
|
63
|
+
expect(subject.to_solr.fetch('url_tesim')).to eq(['http://www.youtube.com/watch?v=oHg5SJYRHA0'])
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe "with a persisted resource" do
|
|
68
|
+
let!(:resource) { FactoryGirl.create(:linked_resource, url: 'http://www.youtube.com/watch?v=oHg5SJYRHA0') }
|
|
69
|
+
|
|
70
|
+
it 'has url as its title to display' do
|
|
71
|
+
expect(resource.to_s).to eq 'http://www.youtube.com/watch?v=oHg5SJYRHA0'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module Worthwhile
|
|
4
|
+
describe "routing" do
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
describe "Classify concerns" do
|
|
8
|
+
routes { Worthwhile::Engine.routes }
|
|
9
|
+
it "routes to #new" do
|
|
10
|
+
expect(new_classify_concern_path).to eq '/classify_concerns/new'
|
|
11
|
+
get("/classify_concerns/new").should route_to("worthwhile/classify_concerns#new")
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "generic work" do
|
|
16
|
+
routes { Rails.application.routes }
|
|
17
|
+
it 'routes to #new' do
|
|
18
|
+
expect(new_curation_concern_generic_work_path).to eq '/concern/generic_works/new'
|
|
19
|
+
get("/concern/generic_works/new").should route_to("curation_concern/generic_works#new")
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Worthwhile::EmbargoService do
|
|
4
|
+
let(:future_date) { 2.days.from_now }
|
|
5
|
+
let(:past_date) { 2.days.ago }
|
|
6
|
+
|
|
7
|
+
let!(:work_with_expired_embargo1) do
|
|
8
|
+
FactoryGirl.build(:generic_work, embargo_release_date: past_date.to_s).tap do |work|
|
|
9
|
+
work.save(validate:false)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
let!(:work_with_expired_embargo2) do
|
|
14
|
+
FactoryGirl.build(:generic_work, embargo_release_date: past_date.to_s).tap do |work|
|
|
15
|
+
work.save(validate:false)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
let!(:work_with_embargo_in_effect) { FactoryGirl.create(:generic_work, embargo_release_date: future_date.to_s)}
|
|
20
|
+
let!(:work_without_embargo) { FactoryGirl.create(:generic_work)}
|
|
21
|
+
|
|
22
|
+
describe "#assets_with_expired_embargoes" do
|
|
23
|
+
it "returns an array of assets with expired embargoes" do
|
|
24
|
+
returned_pids = subject.assets_with_expired_embargoes.map {|a| a.pid}
|
|
25
|
+
expect(returned_pids).to include work_with_expired_embargo1.pid,work_with_expired_embargo2.pid
|
|
26
|
+
expect(returned_pids).to_not include work_with_embargo_in_effect.pid,work_without_embargo.pid
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "#assets_under_embargo" do
|
|
31
|
+
it "returns all assets with embargo release date set" do
|
|
32
|
+
result = subject.assets_under_embargo
|
|
33
|
+
returned_pids = subject.assets_under_embargo.map {|a| a.pid}
|
|
34
|
+
expect(returned_pids).to include work_with_expired_embargo1.pid,work_with_expired_embargo2.pid,work_with_embargo_in_effect.pid
|
|
35
|
+
expect(returned_pids).to_not include work_without_embargo.pid
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Worthwhile::LeaseService do
|
|
4
|
+
let(:future_date) { 2.days.from_now }
|
|
5
|
+
let(:past_date) { 2.days.ago }
|
|
6
|
+
|
|
7
|
+
let!(:work_with_expired_lease1) do
|
|
8
|
+
FactoryGirl.build(:generic_work, lease_expiration_date: past_date.to_s).tap do |work|
|
|
9
|
+
work.save(validate: false)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
let!(:work_with_expired_lease2) do
|
|
14
|
+
FactoryGirl.build(:generic_work, lease_expiration_date: past_date.to_s).tap do |work|
|
|
15
|
+
work.save(validate: false)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
let!(:work_with_lease_in_effect) { FactoryGirl.create(:generic_work, lease_expiration_date: future_date.to_s)}
|
|
20
|
+
let!(:work_without_lease) { FactoryGirl.create(:generic_work)}
|
|
21
|
+
|
|
22
|
+
describe "#assets_with_expired_leases" do
|
|
23
|
+
it "returns an array of assets with expired embargoes" do
|
|
24
|
+
returned_pids = subject.assets_with_expired_leases.map {|a| a.pid}
|
|
25
|
+
expect(returned_pids).to include work_with_expired_lease1.pid,work_with_expired_lease2.pid
|
|
26
|
+
expect(returned_pids).to_not include work_with_lease_in_effect.pid,work_without_lease.pid
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "#assets_under_lease" do
|
|
31
|
+
it "returns an array of assets with expired embargoes" do
|
|
32
|
+
returned_pids = subject.assets_under_lease.map {|a| a.pid}
|
|
33
|
+
expect(returned_pids).to include work_with_expired_lease1.pid,work_with_expired_lease2.pid,work_with_lease_in_effect.pid
|
|
34
|
+
expect(returned_pids).to_not include work_without_lease.pid
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -6,16 +6,37 @@ require 'devise'
|
|
|
6
6
|
require 'engine_cart'
|
|
7
7
|
EngineCart.load_application!
|
|
8
8
|
|
|
9
|
+
require 'rspec/its'
|
|
9
10
|
require 'rspec/rails'
|
|
10
|
-
require '
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
require 'capybara/poltergeist'
|
|
12
|
+
Capybara.javascript_driver = :poltergeist
|
|
13
|
+
Capybara.default_wait_time = ENV['TRAVIS'] ? 30 : 15
|
|
14
|
+
require 'capybara/rspec'
|
|
15
|
+
require 'capybara/rails'
|
|
14
16
|
|
|
15
|
-
require 'worthwhile'
|
|
16
17
|
|
|
18
|
+
if ENV['COVERAGE']
|
|
19
|
+
require 'simplecov'
|
|
20
|
+
|
|
21
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
|
22
|
+
|
|
23
|
+
# Out of the box, SimpleCov was looking at file in ENGINE_ROOT/spec/internal;
|
|
24
|
+
# After all that was where Rails was pointed at.
|
|
25
|
+
SimpleCov.root(ENGINE_ROOT)
|
|
26
|
+
SimpleCov.start 'rails' do
|
|
27
|
+
filters.clear
|
|
28
|
+
add_filter do |src|
|
|
29
|
+
src.filename !~ /^#{ENGINE_ROOT}/
|
|
30
|
+
end
|
|
31
|
+
add_filter '/spec/'
|
|
32
|
+
end
|
|
33
|
+
SimpleCov.command_name "spec"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
require 'worthwhile'
|
|
17
37
|
|
|
18
38
|
Dir["./spec/support/**/*.rb"].sort.each {|f| require f}
|
|
39
|
+
require File.expand_path('../matchers', __FILE__)
|
|
19
40
|
|
|
20
41
|
FactoryGirl.definition_file_paths = [File.expand_path("../factories", __FILE__)]
|
|
21
42
|
FactoryGirl.find_definitions
|
|
@@ -23,6 +44,7 @@ FactoryGirl.find_definitions
|
|
|
23
44
|
|
|
24
45
|
RSpec.configure do |config|
|
|
25
46
|
config.use_transactional_fixtures = false
|
|
47
|
+
config.fixture_path = File.expand_path("../fixtures", __FILE__)
|
|
26
48
|
|
|
27
49
|
config.before :each do
|
|
28
50
|
if Capybara.current_driver == :rack_test
|
|
@@ -41,5 +63,8 @@ RSpec.configure do |config|
|
|
|
41
63
|
config.include Devise::TestHelpers, type: :view
|
|
42
64
|
config.include Warden::Test::Helpers, type: :feature
|
|
43
65
|
config.after(:each, type: :feature) { Warden.test_reset! }
|
|
66
|
+
config.include Controllers::EngineHelpers, type: :controller
|
|
44
67
|
config.include Capybara::DSL
|
|
68
|
+
config.infer_spec_type_from_file_location!
|
|
69
|
+
config.deprecation_stream
|
|
45
70
|
end
|