hydra-file-access 5.0.0.pre1
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.
- data/.gitignore +2 -0
- data/Rakefile +5 -0
- data/app/assets/images/hydra/powered_by_hydra.png +0 -0
- data/app/assets/images/hydra/search-button.png +0 -0
- data/app/assets/javascripts/date-picker/booking/index.html +368 -0
- data/app/assets/javascripts/date-picker/calendarHTML.txt +84 -0
- data/app/assets/javascripts/date-picker/css/datepicker.css +511 -0
- data/app/assets/javascripts/date-picker/css/demo.css +229 -0
- data/app/assets/javascripts/date-picker/index.html +798 -0
- data/app/assets/javascripts/date-picker/js/datepicker.js +2898 -0
- data/app/assets/javascripts/date-picker/js/datepicker.packed.js +1 -0
- data/app/assets/javascripts/date-picker/js/lang/ar.js +9 -0
- data/app/assets/javascripts/date-picker/js/lang/cs.js +9 -0
- data/app/assets/javascripts/date-picker/js/lang/da.js +10 -0
- data/app/assets/javascripts/date-picker/js/lang/de.js +10 -0
- data/app/assets/javascripts/date-picker/js/lang/en.js +9 -0
- data/app/assets/javascripts/date-picker/js/lang/eo.js +13 -0
- data/app/assets/javascripts/date-picker/js/lang/es.js +9 -0
- data/app/assets/javascripts/date-picker/js/lang/et.js +23 -0
- data/app/assets/javascripts/date-picker/js/lang/fi.js +7 -0
- data/app/assets/javascripts/date-picker/js/lang/fr.js +69 -0
- data/app/assets/javascripts/date-picker/js/lang/he.js +9 -0
- data/app/assets/javascripts/date-picker/js/lang/hu.js +9 -0
- data/app/assets/javascripts/date-picker/js/lang/id.js +9 -0
- data/app/assets/javascripts/date-picker/js/lang/it.js +11 -0
- data/app/assets/javascripts/date-picker/js/lang/kr.js +9 -0
- data/app/assets/javascripts/date-picker/js/lang/lt.js +8 -0
- data/app/assets/javascripts/date-picker/js/lang/lv.js +9 -0
- data/app/assets/javascripts/date-picker/js/lang/nl.js +9 -0
- data/app/assets/javascripts/date-picker/js/lang/no.js +9 -0
- data/app/assets/javascripts/date-picker/js/lang/pl.js +10 -0
- data/app/assets/javascripts/date-picker/js/lang/pt-br.js +11 -0
- data/app/assets/javascripts/date-picker/js/lang/pt.js +9 -0
- data/app/assets/javascripts/date-picker/js/lang/ru.js +11 -0
- data/app/assets/javascripts/date-picker/js/lang/se.js +9 -0
- data/app/assets/javascripts/date-picker/js/lang/si.js +9 -0
- data/app/assets/javascripts/date-picker/js/lang/tr.js +9 -0
- data/app/assets/javascripts/date-picker/language/index.html +240 -0
- data/app/assets/javascripts/date-picker/media/Thumbs.db +0 -0
- data/app/assets/javascripts/date-picker/media/backstripes.gif +0 -0
- data/app/assets/javascripts/date-picker/media/bg_header.jpg +0 -0
- data/app/assets/javascripts/date-picker/media/bullet1.gif +0 -0
- data/app/assets/javascripts/date-picker/media/bullet2.gif +0 -0
- data/app/assets/javascripts/date-picker/media/cal-grey.gif +0 -0
- data/app/assets/javascripts/date-picker/media/cal.gif +0 -0
- data/app/assets/javascripts/date-picker/media/gradient-e5e5e5-ffffff.gif +0 -0
- data/app/assets/javascripts/hydra/hydra-head.js +195 -0
- data/app/assets/javascripts/hydra/mediashelf.datepicker.js +39 -0
- data/app/assets/javascripts/hydra/mediashelf.placeholder.js +67 -0
- data/app/assets/javascripts/jquery.form.js +1076 -0
- data/app/assets/javascripts/jquery.ui.datepicker.js +1793 -0
- data/app/assets/javascripts/spin.min.js +2 -0
- data/app/assets/stylesheets/hydra/html_refactor.css +79 -0
- data/app/assets/stylesheets/hydra/hydrangea-split-button.css +18 -0
- data/app/assets/stylesheets/hydra/hydrangea.css +288 -0
- data/app/assets/stylesheets/hydra/ie-styles.css +149 -0
- data/app/assets/stylesheets/hydra/styles.css +946 -0
- data/app/assets/stylesheets/redmond/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/app/assets/stylesheets/redmond/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
- data/app/assets/stylesheets/redmond/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
- data/app/assets/stylesheets/redmond/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
- data/app/assets/stylesheets/redmond/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/app/assets/stylesheets/redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
- data/app/assets/stylesheets/redmond/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
- data/app/assets/stylesheets/redmond/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
- data/app/assets/stylesheets/redmond/images/ui-icons_217bc0_256x240.png +0 -0
- data/app/assets/stylesheets/redmond/images/ui-icons_2e83ff_256x240.png +0 -0
- data/app/assets/stylesheets/redmond/images/ui-icons_469bdd_256x240.png +0 -0
- data/app/assets/stylesheets/redmond/images/ui-icons_6da8d5_256x240.png +0 -0
- data/app/assets/stylesheets/redmond/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/app/assets/stylesheets/redmond/images/ui-icons_d8e7f3_256x240.png +0 -0
- data/app/assets/stylesheets/redmond/images/ui-icons_f9bd01_256x240.png +0 -0
- data/app/assets/stylesheets/redmond/jquery-ui-1.8.5.custom.css +572 -0
- data/app/controllers/hydra/application_controller.rb +5 -0
- data/app/controllers/hydra/file_assets_controller.rb +3 -0
- data/app/helpers/application_helper.rb +3 -0
- data/app/helpers/hydra/application_helper_behavior.rb +8 -0
- data/app/helpers/hydra/hydra_helper_behavior.rb +70 -0
- data/app/helpers/hydra_helper.rb +4 -0
- data/app/models/file_asset.rb +5 -0
- data/app/models/uses_default_partials.rb +23 -0
- data/app/views/_add_assets_links.html.erb +14 -0
- data/app/views/_user_util_links.html.erb +24 -0
- data/app/views/generic_content_objects/_contributor_form.html.erb +11 -0
- data/app/views/generic_content_objects/_description_form.html.erb +7 -0
- data/app/views/generic_content_objects/_edit_description.html.erb +23 -0
- data/app/views/generic_content_objects/_new.html.erb +0 -0
- data/app/views/generic_content_objects/_show_description.html.erb +41 -0
- data/app/views/generic_contents/_edit.html.erb +10 -0
- data/app/views/generic_contents/_index.html.erb +21 -0
- data/app/views/generic_contents/_show.html.erb +6 -0
- data/app/views/generic_contents/_show_content.html.erb +7 -0
- data/app/views/generic_images/_edit.html.erb +36 -0
- data/app/views/generic_images/_index.html.erb +24 -0
- data/app/views/generic_images/_show.html.erb +13 -0
- data/app/views/generic_images/_show_all.html.erb +14 -0
- data/app/views/generic_images/_show_content.html.erb +7 -0
- data/app/views/hydra/file_assets/_asset_saved_flash.html.erb +2 -0
- data/app/views/hydra/file_assets/_deletable_result.html.erb +5 -0
- data/app/views/hydra/file_assets/_file_assets_form.html.erb +11 -0
- data/app/views/hydra/file_assets/_index.html.erb +29 -0
- data/app/views/hydra/file_assets/_new.html.erb +6 -0
- data/app/views/hydra/file_assets/_result.html.erb +11 -0
- data/app/views/hydra/file_assets/index.html.erb +5 -0
- data/app/views/hydra/permissions/_edit_person_permissions.html.erb +30 -0
- data/app/views/hydra/permissions/_index.html.erb +46 -0
- data/app/views/hydra/permissions/_new.html.erb +14 -0
- data/app/views/hydra/permissions/_permissions_form.html.erb +23 -0
- data/app/views/hydra/permissions/index.html.erb +1 -0
- data/app/views/hydra/permissions/new.html.erb +1 -0
- data/app/views/mods_assets/_additional_info_form.html.erb +44 -0
- data/app/views/mods_assets/_contributor_form.html.erb +14 -0
- data/app/views/mods_assets/_edit.html.erb +10 -0
- data/app/views/mods_assets/_edit_description.html.erb +73 -0
- data/app/views/mods_assets/_edit_journal.html.erb +57 -0
- data/app/views/mods_assets/_index.html.erb +1 -0
- data/app/views/mods_assets/_index_list.html.erb +37 -0
- data/app/views/mods_assets/_index_table.html.erb +7 -0
- data/app/views/mods_assets/_progress_box.html.erb +82 -0
- data/app/views/mods_assets/_publication_form.html.erb +13 -0
- data/app/views/mods_assets/_show.html.erb +39 -0
- data/app/views/mods_assets/_show_additional_info.html.erb +17 -0
- data/app/views/mods_assets/_show_contributors.html.erb +7 -0
- data/app/views/mods_assets/_show_description.html.erb +35 -0
- data/app/views/mods_assets/_show_file_assets.html.erb +22 -0
- data/app/views/mods_assets/_show_journal.html.erb +42 -0
- data/app/views/mods_assets/_show_permissions.html.erb +15 -0
- data/app/views/mods_assets/_show_publication.html.erb +8 -0
- data/app/views/shared/_delete_asset_confirmation.html.erb +17 -0
- data/config/jetty.yml +7 -0
- data/hydra-file-access.gemspec +39 -0
- data/lib/hydra-file-access.rb +15 -0
- data/lib/hydra/assets.rb +5 -0
- data/lib/hydra/assets_controller_helper.rb +122 -0
- data/lib/hydra/controller/assets_controller_behavior.rb +153 -0
- data/lib/hydra/controller/file_assets_behavior.rb +140 -0
- data/lib/hydra/file_access/engine.rb +12 -0
- data/lib/hydra/file_assets.rb +11 -0
- data/lib/hydra/submission_workflow.rb +139 -0
- data/lib/hydra/ui.rb +6 -0
- data/spec/.gitignore +1 -0
- data/spec/controllers/file_assets_controller_spec.rb +180 -0
- data/spec/fixtures/small_file.txt +1 -0
- data/spec/helpers/access_controls_evaluation_spec.rb +19 -0
- data/spec/helpers/assets_controller_helper_spec.rb +63 -0
- data/spec/helpers/file_assets_helper_spec.rb +116 -0
- data/spec/helpers/hydra_helper_spec.rb +21 -0
- data/spec/helpers/hydra_model_methods_spec.rb +88 -0
- data/spec/integration/file_asset_spec.rb +68 -0
- data/spec/lib/hydra_submission_workflow_spec.rb +141 -0
- data/spec/models/file_asset_spec.rb +25 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/support/Gemfile +12 -0
- data/spec/support/app/models/generic_content.rb +26 -0
- data/spec/support/app/models/sample.rb +33 -0
- data/spec/support/app/models/solr_document.rb +5 -0
- data/spec/support/db/migrate/20111101221803_create_searches.rb +16 -0
- data/spec/support/lib/generators/test_app_generator.rb +39 -0
- data/spec/support/matchers/helper_matcher.rb +14 -0
- data/spec/support/matchers/solr_matchers.rb +60 -0
- data/spec/support/spec/factories/users.rb +11 -0
- data/spec/support/spec/fixtures/hydra_test_generic_content.foxml.xml +138 -0
- data/spec/support/spec/fixtures/hydrangea_fixture_file_asset1.foxml.xml +4946 -0
- data/spec/support/spec/fixtures/hydrangea_fixture_mods_article1.foxml.xml +234 -0
- data/spec/support/spec/fixtures/hydrangea_fixture_mods_article2.foxml.xml +177 -0
- data/spec/support/spec/fixtures/hydrangea_fixture_mods_article3.foxml.xml +170 -0
- data/spec/support/spec/fixtures/hydrangea_fixture_uploaded_svg1.foxml.xml +676 -0
- data/tasks/rspec.rake +55 -0
- metadata +516 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
small
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Hydra::AccessControlsEvaluation do
|
|
4
|
+
|
|
5
|
+
describe "editor?" do
|
|
6
|
+
it "should return false if the session[:user] is not logged in" do
|
|
7
|
+
controller.stub(:current_user).and_return(nil)
|
|
8
|
+
helper.editor?.should be_false
|
|
9
|
+
end
|
|
10
|
+
it "should return false if the session[:user] does not have an editor role" do
|
|
11
|
+
mock_user = mock("User")
|
|
12
|
+
mock_user.stub(:email).and_return "nobody_special@example.com"
|
|
13
|
+
mock_user.stub(:new_record?).and_return(false)
|
|
14
|
+
controller.stub(:current_user).and_return(mock_user)
|
|
15
|
+
helper.editor?.should be_false
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Hydra::AssetsControllerHelper do
|
|
4
|
+
describe "sanitize_update_params" do
|
|
5
|
+
it "should create a hash appropriate for passing into ActiveFedora::Base.update_datastream_attributes" do
|
|
6
|
+
sample_params = {
|
|
7
|
+
"content_type"=>"mods_asset",
|
|
8
|
+
"action"=>"update",
|
|
9
|
+
"_method"=>"put",
|
|
10
|
+
"field_selectors"=>{
|
|
11
|
+
"descMetadata"=>{"person_0_computing_id"=>[{"person"=>"0"}, "computing_id"], "journal_0_issue_start_page"=>[{"journal"=>"0"}, "issue", "start_page"], "person_1_description"=>[{"person"=>"1"}, "description"], "person_1_institution"=>[{"person"=>"1"}, "institution"], "journal_0_origin_info_publisher"=>[{"journal"=>"0"}, "origin_info", "publisher"], "abstract"=>["abstract"], "person_0_last_name"=>[{"person"=>"0"}, "last_name"], "person_0_description"=>[{"person"=>"0"}, "description"], "journal_0_issue_volume"=>[{"journal"=>"0"}, "issue", "volume"], "title_info_main_title"=>["title_info", "main_title"], "location_url"=>["location", "url"], "note"=>["note"], "person_1_last_name"=>[{"person"=>"1"}, "last_name"], "subject_topic"=>["subject", "topic"], "person_0_institution"=>[{"person"=>"0"}, "institution"], "person_1_first_name"=>[{"person"=>"1"}, "first_name"], "person_1"=>[{"person"=>"1"}], "journal_0_title_info_main_title"=>[{"journal"=>"0"}, "title_info", "main_title"], "journal_0_issue_level"=>[{"journal"=>"0"}, "issue", "level"], "journal_0_issue_end_page"=>[{"journal"=>"0"}, "issue", "end_page"], "peer_reviewed"=>["peer_reviewed"], "person_0_first_name"=>[{"person"=>"0"}, "first_name"], "person_1_computing_id"=>[{"person"=>"1"}, "computing_id"], "journal_0_issn"=>[{"journal"=>"0"}, "issn"], "journal_0_issue_publication_date"=>[{"journal"=>"0"}, "issue", "publication_date"], "subject_topic" => ["subject", "topic", "subject", "topic"]},
|
|
12
|
+
"rightsMetadata"=>{"embargo_embargo_release_date"=>["embargo", "embargo_release_date"]},
|
|
13
|
+
"properties"=>{"release_to"=>["release_to"]}
|
|
14
|
+
},
|
|
15
|
+
"id"=>"hydrangea:fixture_mods_article3",
|
|
16
|
+
"controller"=>"assets",
|
|
17
|
+
"asset"=>{"descMetadata"=>{"person_0_computing_id"=>{"0"=>""}, "journal_0_issue_start_page"=>{"0"=>"195"}, "person_1_description"=>{"0"=>""}, "person_1_institution"=>{"0"=>"Baltimore"}, "journal_0_origin_info_publisher"=>{"0"=>"PUBLISHER"}, "abstract"=>{"0"=>"ABSTRACT"}, "person_0_last_name"=>{"0"=>"Smith"}, "person_0_description"=>{"0"=>""}, "journal_0_issue_volume"=>{"0"=>"2 "}, "title_info_main_title"=>{"0"=>"Test Article"}, "location_url"=>{"0"=>"http://example.com/foo"}, "note"=>{"0"=>""}, "person_1_last_name"=>{"0"=>"Lacks"}, "subject_topic"=>{"0"=>"TOPIC 1", "1"=>"TOPIC 2", "2"=>"CONTROLLED TERM"}, "person_0_institution"=>{"0"=>"FACULTY, UNIVERSITY"}, "person_1_first_name"=>{"0"=>"Henrietta"}, "journal_0_title_info_main_title"=>{"0"=>"The Journal of Mock Object"}, "journal_0_issue_level"=>{"0"=>""}, "journal_0_issue_end_page"=>{"0"=>"230"}, "person_0_first_name"=>{"0"=>"John"}, "person_1_computing_id"=>{"0"=>""}, "journal_0_issn"=>{"0"=>"1234-5678"}, "journal_0_issue_publication_date"=>{"0"=>"FEB. 2007"}, "subject_topic" => {"0"=>"Topic1", "1"=>"Topic2"}}, "rightsMetadata"=>{"embargo_embargo_release_date"=>{"0"=>""}}, "properties"=>{"released"=>{"0"=>"true"}, "release_to"=>{"0"=>"public"}}}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
expected_sane_params = {
|
|
21
|
+
"descMetadata"=>{[{:person=>0}, :institution]=>{"0"=>"FACULTY, UNIVERSITY"}, [{:journal=>0}, :title_info, :main_title]=>{"0"=>"The Journal of Mock Object"}, [{:journal=>0}, :issue, :volume]=>{"0"=>"2 "}, [{:journal=>0}, :issn]=>{"0"=>"1234-5678"}, [{:person=>1}, :first_name]=>{"0"=>"Henrietta"}, [{:person=>0}, :last_name]=>{"0"=>"Smith"}, [:location, :url]=>{"0"=>"http://example.com/foo"}, [:subject, :topic]=>{"0"=>"TOPIC 1", "1"=>"TOPIC 2", "2"=>"CONTROLLED TERM"}, [{:person=>0}, :first_name]=>{"0"=>"John"}, [{:person=>1}, :computing_id]=>{"0"=>""}, [{:journal=>0}, :issue, :end_page]=>{"0"=>"230"}, [:note]=>{"0"=>""}, [:title_info, :main_title]=>{"0"=>"Test Article"}, [{:journal=>0}, :issue, :publication_date]=>{"0"=>"FEB. 2007"}, [{:person=>1}, :description]=>{"0"=>""}, [:abstract]=>{"0"=>"ABSTRACT"}, [{:journal=>0}, :issue, :level]=>{"0"=>""}, [{:person=>1}, :institution]=>{"0"=>"Baltimore"}, [{:person=>0}, :computing_id]=>{"0"=>""}, [{:person=>1}, :last_name]=>{"0"=>"Lacks"}, [{:journal=>0}, :issue, :start_page]=>{"0"=>"195"}, [{:person=>0}, :description]=>{"0"=>""}, [{:journal=>0}, :origin_info, :publisher]=>{"0"=>"PUBLISHER"}, [:subject, :topic]=>{"0"=>"Topic1", "1"=>"Topic2"} }, "rightsMetadata"=>{[:embargo, :embargo_release_date]=>{"0"=>""}},
|
|
22
|
+
"properties"=>{[:release_to]=>{"0"=>"public"}, :released=>{"0"=>"true"}}
|
|
23
|
+
}
|
|
24
|
+
helper.stub(:params).and_return(sample_params)
|
|
25
|
+
sanitized_params = helper.sanitize_update_params
|
|
26
|
+
sanitized_params.should == expected_sane_params
|
|
27
|
+
sanitized_params["descMetadata"].should == expected_sane_params["descMetadata"]
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe "tidy_response_from_update" do
|
|
32
|
+
it "should put response values into an array with fieldname / index / value Hash for each field updated" do
|
|
33
|
+
sample_input = {"descMetadata"=>{"journal_0_issue_start_page"=>{"0"=>"195"}, "person_0_computing_id"=>{"-1"=>""}, "journal_0_origin_info_publisher"=>{"0"=>"PUBLISHER"}, "person_1_institution"=>{"0"=>"Baltimore"}, "person_1_description"=>{"-1"=>""}, "abstract"=>{"0"=>"ABSTRACT"}, "person_0_description"=>{"-1"=>""}, "person_0_last_name"=>{"0"=>"Smith"}, "journal_0_issue_volume"=>{"0"=>"2 "}, "title_info_main_title"=>{"0"=>"Matt's Test Article! Again!?"}, "note"=>{"-1"=>""}, "location_url"=>{"0"=>"http://example.com/foo"}, "person_1_last_name"=>{"0"=>"Lacks"}, "subject_topic"=>{"0"=>"TOPIC 1", "1"=>"TOPIC 2", "2"=>"CONTROLLED TERM"}, "journal_0_issue_level"=>{"0"=>"55 "}, "journal_0_issue_end_page"=>{"0"=>"230"}, "person_1_first_name"=>{"0"=>"Henrietta"}, "person_0_institution"=>{"0"=>"FACULTY, UNIVERSITY"}, "journal_0_title_info_main_title"=>{"0"=>"The Journal of Mock Object"}, "journal_0_issue_publication_date"=>{"0"=>"FEB. 2007"}, "person_1_computing_id"=>{"-1"=>""}, "person_0_first_name"=>{"0"=>"John"}, "journal_0_issn"=>{"0"=>"1234-5678"}}, "rightsMetadata"=>{"embargo_embargo_release_date"=>{"-1"=>""}}, "properties"=>{:released=>{"0"=>"true"}, :release_to=>{"0"=>"public"}, [:release_to]=>{}}}
|
|
34
|
+
expected_output = {"updated"=>[{"value"=>{"0"=>"195"}, "index"=>"journal_0_issue_start_page", "field_name"=>"descMetadata"}, {"value"=>{"-1"=>""}, "index"=>"person_0_computing_id", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"PUBLISHER"}, "index"=>"journal_0_origin_info_publisher", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"Baltimore"}, "index"=>"person_1_institution", "field_name"=>"descMetadata"}, {"value"=>{"-1"=>""}, "index"=>"person_1_description", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"ABSTRACT"}, "index"=>"abstract", "field_name"=>"descMetadata"}, {"value"=>{"-1"=>""}, "index"=>"person_0_description", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"Smith"}, "index"=>"person_0_last_name", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"2 "}, "index"=>"journal_0_issue_volume", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"Matt's Test Article! Again!?"}, "index"=>"title_info_main_title", "field_name"=>"descMetadata"}, {"value"=>{"-1"=>""}, "index"=>"note", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"http://example.com/foo"}, "index"=>"location_url", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"Lacks"}, "index"=>"person_1_last_name", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"TOPIC 1", "1"=>"TOPIC 2", "2"=>"CONTROLLED TERM"}, "index"=>"subject_topic", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"55 "}, "index"=>"journal_0_issue_level", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"230"}, "index"=>"journal_0_issue_end_page", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"Henrietta"}, "index"=>"person_1_first_name", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"FACULTY, UNIVERSITY"}, "index"=>"person_0_institution", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"The Journal of Mock Object"}, "index"=>"journal_0_title_info_main_title", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"FEB. 2007"}, "index"=>"journal_0_issue_publication_date", "field_name"=>"descMetadata"}, {"value"=>{"-1"=>""}, "index"=>"person_1_computing_id", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"John"}, "index"=>"person_0_first_name", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"1234-5678"}, "index"=>"journal_0_issn", "field_name"=>"descMetadata"}, {"value"=>{"-1"=>""}, "index"=>"embargo_embargo_release_date", "field_name"=>"rightsMetadata"}, {"value"=>{"0"=>"true"}, "index"=>:released, "field_name"=>"properties"}, {"value"=>{"0"=>"public"}, "index"=>:release_to, "field_name"=>"properties"}, {"value"=>{}, "index"=>[:release_to], "field_name"=>"properties"}]}
|
|
35
|
+
result = helper.tidy_response_from_update(sample_input)
|
|
36
|
+
(expected_output["updated"] - result["updated"]).should == []
|
|
37
|
+
end
|
|
38
|
+
it "if handling submission from jeditable (which will only submit one value at a time), return the value it submitted" do
|
|
39
|
+
sample_input = {"descMetadata"=>{"journal_0_issue_start_page"=>{"0"=>"195"}} }
|
|
40
|
+
expected_output = {"0"=>"195"}
|
|
41
|
+
helper.stub(:params).and_return({:field_id => "my field id"})
|
|
42
|
+
helper.tidy_response_from_update(sample_input).should == expected_output
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe "update_document" do
|
|
47
|
+
it "should update the document with the provided params" do
|
|
48
|
+
sample_params = "sample params"
|
|
49
|
+
mock_document = mock("document")
|
|
50
|
+
mock_document.should_receive(:update_datastream_attributes).with(sample_params)
|
|
51
|
+
helper.update_document(mock_document, sample_params)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe "send_datastream" do
|
|
56
|
+
it "should return the requested datastream with content disposition & mime type set from datastream attributes" do
|
|
57
|
+
test_ds = ModsAsset.find("hydrangea:fixture_file_asset1").datastreams["DS1"]
|
|
58
|
+
helper.should_receive(:send_data).with(test_ds.content, :filename=>"bali.jpg", :type=>"image/jpeg")
|
|
59
|
+
helper.send(:send_datastream, test_ds)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Hydra::Controller::UploadBehavior do
|
|
4
|
+
|
|
5
|
+
it "should respond to datastream_id" do
|
|
6
|
+
helper.should respond_to :datastream_id ### API method, test that it's there to be overridden
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe "create_and_save_file_asset_from_params" do
|
|
10
|
+
it "should create the file asset, add posted blob to it and save the file asset" do
|
|
11
|
+
mock_fa = mock("file asset")
|
|
12
|
+
helper.stub(:params).and_return( { :Filedata => [mock_fa] } )
|
|
13
|
+
mock_fa.should_receive(:save)
|
|
14
|
+
helper.should_receive(:create_asset_from_file).and_return(mock_fa)
|
|
15
|
+
helper.should_receive(:add_posted_blob_to_asset)
|
|
16
|
+
helper.create_and_save_file_assets_from_params
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe "add_posted_blob_to_asset" do
|
|
21
|
+
it "should set object title and label, relying on datastream_id to set dsId" do
|
|
22
|
+
mock_file = mock("File")
|
|
23
|
+
file_name = "Posted Filename.foo"
|
|
24
|
+
helper.stub(:params).and_return( :Filedata=>[mock_file], :Filename=>file_name, "container_id"=>"hydrangea:2973" )
|
|
25
|
+
mock_fa = mock("file asset")
|
|
26
|
+
mock_file.should_receive(:original_filename).and_return(file_name)
|
|
27
|
+
helper.stub(:datastream_id).and_return('bar')
|
|
28
|
+
mock_fa.should_receive(:add_file_datastream).with(mock_file, :label=>file_name, :mimeType=>"mymimetype", :dsid=>'bar')
|
|
29
|
+
mock_fa.should_receive(:set_title_and_label).with( file_name, :only_if_blank=>true )
|
|
30
|
+
helper.should_receive(:mime_type).with(file_name).and_return("mymimetype")
|
|
31
|
+
helper.add_posted_blob_to_asset(mock_fa,mock_file)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should support submissions from swfupload" do
|
|
35
|
+
mock_file = mock("File")
|
|
36
|
+
file_name = "Posted Filename.foo"
|
|
37
|
+
helper.stub(:params).and_return( :Filedata=>[mock_file], :Filename=>file_name, "container_id"=>"hydrangea:2973" )
|
|
38
|
+
mock_fa = mock("file asset")
|
|
39
|
+
mock_file.should_receive(:original_filename).and_return(file_name)
|
|
40
|
+
mock_fa.should_receive(:add_file_datastream).with(mock_file, :label=>file_name, :mimeType=>"mymimetype", :dsid => 'content')
|
|
41
|
+
mock_fa.stub(:set_title_and_label)
|
|
42
|
+
helper.should_receive(:mime_type).with(file_name).and_return("mymimetype")
|
|
43
|
+
helper.add_posted_blob_to_asset(mock_fa,mock_file)
|
|
44
|
+
end
|
|
45
|
+
it "should support submissions from single-file uploader, defaulting to dsId of content" do
|
|
46
|
+
mock_file = mock("File")
|
|
47
|
+
file_name = "Posted Filename.foo"
|
|
48
|
+
# helper.should_receive(:filename_from_params).and_return(file_name)
|
|
49
|
+
helper.stub(:params).and_return( :Filedata=>[mock_file], :container_id=>"hydrangea:2973" )
|
|
50
|
+
mock_file.should_receive(:original_filename).and_return(file_name)
|
|
51
|
+
mock_fa = mock("file asset")
|
|
52
|
+
helper.should_receive(:mime_type).with(file_name).and_return("mymimetype")
|
|
53
|
+
mock_fa.should_receive(:add_file_datastream).with(mock_file, :label=>file_name, :mimeType=>"mymimetype", :dsid => 'content')
|
|
54
|
+
mock_fa.stub(:set_title_and_label)
|
|
55
|
+
helper.add_posted_blob_to_asset(mock_fa,mock_file)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "create_asset_from_params" do
|
|
60
|
+
it "should create a new file asset and set the label from params[:Filename]" do
|
|
61
|
+
helper.stub(:params).and_return( { :Filename => "Test Filename" } )
|
|
62
|
+
result = helper.create_asset_from_params
|
|
63
|
+
result.should be_kind_of FileAsset
|
|
64
|
+
result.label.should == "Test Filename"
|
|
65
|
+
end
|
|
66
|
+
it "should choose model by filename" do
|
|
67
|
+
pending "this is currently disabled"
|
|
68
|
+
helper.should_receive(:choose_model_by_filename)
|
|
69
|
+
helper.create_asset_from_params
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe "posted_file" do
|
|
74
|
+
it "should return the posted file" do
|
|
75
|
+
helper.should_receive(:params).and_return(:Filedata=>"test posted file")
|
|
76
|
+
helper.posted_file.should == "test posted file"
|
|
77
|
+
end
|
|
78
|
+
it "should return nil if no file was posted" do
|
|
79
|
+
helper.posted_file.should == nil
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe "filename_from_params" do
|
|
84
|
+
it "should return the value of params[:Filename] if it was submitted" do
|
|
85
|
+
helper.stub(:params).and_return(:Filename => "Test Filename")
|
|
86
|
+
helper.filename_from_params.should == "Test Filename"
|
|
87
|
+
end
|
|
88
|
+
it "should default to using the original filename of the posted file" do
|
|
89
|
+
helper.stub(:params).and_return({})
|
|
90
|
+
helper.should_receive(:posted_file).and_return(mock("File", :original_filename=>"Test Original Filename"))
|
|
91
|
+
helper.filename_from_params.should == "Test Original Filename"
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
describe "choose_model_by_filename" do
|
|
96
|
+
it "should return model classes based on filename extensions" do
|
|
97
|
+
pending "This can only be enabled if/when we adopt replacements for ImageAsset, AudioAsset, etc. as default primitives."
|
|
98
|
+
|
|
99
|
+
["filename.wav","filename.mp3","filename.aiff"].each do |fn|
|
|
100
|
+
helper.choose_model_by_filename(fn).should == AudioAsset
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
["filename.mov","filename.flv","filename.mp4", "filename.m4v"].each do |fn|
|
|
104
|
+
helper.choose_model_by_filename(fn).should == VideoAsset
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
["filename.jpeg","filename.jpg","filename.gif", "filename.png"].each do |fn|
|
|
108
|
+
helper.choose_model_by_filename(fn).should == ImageAsset
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
["filename.doc","filename.pdf","filename.jp2", "filename.zip"].each do |fn|
|
|
112
|
+
helper.choose_model_by_filename(fn).should == FileAsset
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
describe HydraHelper do
|
|
5
|
+
|
|
6
|
+
describe "submit_name" do
|
|
7
|
+
it "should return 'Save' when the scripts session variable is set" do
|
|
8
|
+
helper.stub(:session => {:scripts=>true})
|
|
9
|
+
helper.submit_name.should == "Save"
|
|
10
|
+
end
|
|
11
|
+
it "should return 'Continue' when the new_asset param is set" do
|
|
12
|
+
helper.stub(:params => {:new_asset=>true})
|
|
13
|
+
helper.submit_name.should == "Continue"
|
|
14
|
+
end
|
|
15
|
+
it "should return 'Save and Continue' if all else fails" do
|
|
16
|
+
helper.stub(:params => {})
|
|
17
|
+
helper.submit_name.should == "Save and Continue"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Hydra::ModelMethods do
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
describe "set_title_and_label" do
|
|
7
|
+
before(:each) do
|
|
8
|
+
dm = mock("descMetadata")
|
|
9
|
+
helper.stub(:datastreams).and_return("descMetadata"=>dm)
|
|
10
|
+
end
|
|
11
|
+
it "should set the title and the label" do
|
|
12
|
+
helper.should_receive(:set_title)
|
|
13
|
+
helper.stub(:label).and_return(nil)
|
|
14
|
+
helper.should_receive(:label=).with("My title")
|
|
15
|
+
helper.set_title_and_label("My title")
|
|
16
|
+
end
|
|
17
|
+
it "should skip updating if the label is set already" do
|
|
18
|
+
helper.should_receive(:set_title).never
|
|
19
|
+
helper.should_receive(:label=).never
|
|
20
|
+
helper.stub(:label).and_return("pre existing label")
|
|
21
|
+
helper.set_title_and_label("My title", :only_if_blank=>true)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "set_title" do
|
|
26
|
+
it "should set the title if the descMetadata is a NokogiriDatastream that responds to :title term" do
|
|
27
|
+
obj = ActiveFedora::Base.new
|
|
28
|
+
dm = Hydra::Datastream::Properties.new(obj.inner_object, nil)
|
|
29
|
+
dm.stub(:content).and_return('')
|
|
30
|
+
helper.stub(:datastreams).and_return("descMetadata"=>dm)
|
|
31
|
+
helper.set_title("My title")
|
|
32
|
+
dm.term_values(:title).should == ["My title"]
|
|
33
|
+
end
|
|
34
|
+
it "should set the title if the descMetadata is a MetadataDatastream with a title field defined" do
|
|
35
|
+
obj = ActiveFedora::Base.new
|
|
36
|
+
dm = ActiveFedora::QualifiedDublinCoreDatastream.new(obj.inner_object, nil)
|
|
37
|
+
dm.stub(:content).and_return('')
|
|
38
|
+
#dm = ActiveFedora::QualifiedDublinCoreDatastream.new nil, nil
|
|
39
|
+
helper.stub(:datastreams).and_return("descMetadata"=>dm)
|
|
40
|
+
helper.set_title("My title")
|
|
41
|
+
dm.title.should == ["My title"]
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "set_collection_type" do
|
|
46
|
+
it "should set the collection metadata field" do
|
|
47
|
+
prop_ds = mock("properties ds")
|
|
48
|
+
prop_ds.should_receive(:respond_to?).with(:collection_values).and_return(true)
|
|
49
|
+
prop_ds.should_receive(:collection_values=).with("mods_asset")
|
|
50
|
+
|
|
51
|
+
helper.stub(:datastreams).and_return({"properties"=>prop_ds})
|
|
52
|
+
helper.set_collection_type("mods_asset")
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe "#destroyable_child_assets" do
|
|
57
|
+
it "should return an array of file assets available for deletion" do
|
|
58
|
+
ma = ModsAsset.load_instance_from_solr("hydrangea:fixture_mods_article1")
|
|
59
|
+
deletable_assets = ma.destroyable_child_assets
|
|
60
|
+
deletable_assets.should be_a_kind_of Array
|
|
61
|
+
deletable_assets.length.should >= 1
|
|
62
|
+
deletable_assets.select {|a| a.pid == "hydrangea:fixture_uploaded_svg1"}[0].pid.should == "hydrangea:fixture_uploaded_svg1"
|
|
63
|
+
end
|
|
64
|
+
it "should return an empty array if there are now file assets" do
|
|
65
|
+
ma = ModsAsset.load_instance_from_solr("hydrangea:fixture_mods_article2")
|
|
66
|
+
deletable_assets = ma.destroyable_child_assets
|
|
67
|
+
deletable_assets.should be_a_kind_of Array
|
|
68
|
+
deletable_assets.should be_empty
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe "#destroy_child_assets" do
|
|
73
|
+
it "should destroy any child assets and return an array listing the child assets" do
|
|
74
|
+
ma = ModsAsset.load_instance_from_solr("hydrangea:fixture_mods_article1")
|
|
75
|
+
file_asset = mock("file object")
|
|
76
|
+
file_asset.should_receive(:pid).and_return("hydrangea:fixture_uploaded_svg1")
|
|
77
|
+
file_asset.should_receive(:delete).and_return(true)
|
|
78
|
+
ma.stub(:destroyable_child_assets).and_return([file_asset])
|
|
79
|
+
ma.destroy_child_assets.should == ["hydrangea:fixture_uploaded_svg1"]
|
|
80
|
+
end
|
|
81
|
+
it "should do nothing and return an empty array for an object with no child assets" do
|
|
82
|
+
ma = ModsAsset.load_instance_from_solr("hydrangea:fixture_mods_article2")
|
|
83
|
+
ma.destroy_child_assets.should == []
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
class DummyFileAsset < ActiveFedora::Base
|
|
4
|
+
def initialize(attr={})
|
|
5
|
+
super(attr)
|
|
6
|
+
add_relationship(:has_model, "info:fedora/afmodel:FileAsset")
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe FileAsset do
|
|
11
|
+
before(:each) do
|
|
12
|
+
@file_asset = FileAsset.new
|
|
13
|
+
end
|
|
14
|
+
after(:each) do
|
|
15
|
+
begin
|
|
16
|
+
@file_asset.delete
|
|
17
|
+
rescue
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
describe "with parts" do
|
|
21
|
+
before(:each) do
|
|
22
|
+
@asset1 = ActiveFedora::Base.new
|
|
23
|
+
@asset1.save
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
after(:each) do
|
|
27
|
+
@asset1.delete
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe ".container_id" do
|
|
31
|
+
it "should return asset container objects via is_part_of relationships" do
|
|
32
|
+
#none
|
|
33
|
+
@file_asset.container_id.should be_nil
|
|
34
|
+
#is_part_of
|
|
35
|
+
@file_asset.container = @asset1
|
|
36
|
+
@file_asset.container_id.should == @asset1.pid
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe ".to_solr" do
|
|
42
|
+
it "should load base fields correctly if active_fedora_model is FileAsset" do
|
|
43
|
+
@file_asset.update_indexed_attributes({:title=>{0=>"testing"}})
|
|
44
|
+
solr_doc = @file_asset.to_solr
|
|
45
|
+
solr_doc["title_t"].should == ["testing"]
|
|
46
|
+
end
|
|
47
|
+
it "should load base fields for FileAsset for model_only if active_fedora_model is not FileAsset but is not child of FileAsset" do
|
|
48
|
+
pending "I'm unconvinced as to the usefullness of this test. Why create as one type then reload as another? - Justin"
|
|
49
|
+
@dummy_file_asset = DummyFileAsset.new
|
|
50
|
+
@dummy_file_asset.save
|
|
51
|
+
file_asset = FileAsset.find(@dummy_file_asset.pid)
|
|
52
|
+
ENABLE_SOLR_UPDATES = false
|
|
53
|
+
#it should save change to Fedora, but not solr
|
|
54
|
+
file_asset.update_indexed_attributes({:title=>{0=>"testing"}})
|
|
55
|
+
file_asset.save
|
|
56
|
+
ENABLE_SOLR_UPDATES = true
|
|
57
|
+
solr_doc = DummyFileAsset.find_by_solr(@dummy_file_asset.pid).hits.first
|
|
58
|
+
solr_doc["title_t"].should be_nil
|
|
59
|
+
@dummy_file_asset.update_index
|
|
60
|
+
solr_doc = DummyFileAsset.find_by_solr(@dummy_file_asset.pid).hits.first
|
|
61
|
+
solr_doc["title_t"].should == ["testing"]
|
|
62
|
+
begin
|
|
63
|
+
@dummy_file_asset.delete
|
|
64
|
+
rescue
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
require File.expand_path( File.join( File.dirname(__FILE__),'..','spec_helper') )
|
|
2
|
+
|
|
3
|
+
mods_asset_model = "info:fedora/afmodel:ModsAsset"
|
|
4
|
+
|
|
5
|
+
describe Hydra::SubmissionWorkflow do
|
|
6
|
+
before(:each) do
|
|
7
|
+
@document = SolrDocument.new({:has_model_s => [mods_asset_model]})
|
|
8
|
+
end
|
|
9
|
+
include Hydra::SubmissionWorkflow
|
|
10
|
+
|
|
11
|
+
describe "first step in workflow" do
|
|
12
|
+
it "should return the first step of a given workflow" do
|
|
13
|
+
first_step_in_workflow.should == "contributor"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "next in workflow" do
|
|
18
|
+
it "should provide the next step based on the provided step" do
|
|
19
|
+
next_step_in_workflow(:contributor).should == "publication"
|
|
20
|
+
end
|
|
21
|
+
it "should return nil if there is no step (denoting the last step)" do
|
|
22
|
+
next_step_in_workflow(:permissions).should be_nil
|
|
23
|
+
end
|
|
24
|
+
it "should return the step after the first if a blank current step is provided (e.g. started from the first step so no wf_step param)" do
|
|
25
|
+
next_step_in_workflow(nil).should == "publication"
|
|
26
|
+
next_step_in_workflow("").should == "publication"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "partial for step" do
|
|
31
|
+
it "should return the partial for the given step" do
|
|
32
|
+
workflow_partial_for_step(:contributor).should match(/contributor_form/)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe "previous show partials" do
|
|
37
|
+
it "should return all of the previous show partials for display in the HTML-only workflow" do
|
|
38
|
+
prev_partials = previous_show_partials(:permissions)
|
|
39
|
+
prev_partials.should be_kind_of(Array)
|
|
40
|
+
prev_partials.length.should == 4
|
|
41
|
+
prev_partials.first.should match(/mods.*contributors/)
|
|
42
|
+
prev_partials.last.should match(/mods.*file_assets/)
|
|
43
|
+
end
|
|
44
|
+
it "should return an empty array for the first step in the workflow" do
|
|
45
|
+
previous_show_partials(:contributor).should == []
|
|
46
|
+
previous_show_partials("").should == []
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe "model specific configurations" do
|
|
51
|
+
it "should return the appropriate configuration when an @document object is available" do
|
|
52
|
+
config = model_config
|
|
53
|
+
config.should be_kind_of(Array)
|
|
54
|
+
config.length.should == 5
|
|
55
|
+
partial_is_mods = []
|
|
56
|
+
config.each do |c|
|
|
57
|
+
c.is_a?(Hash).should be_true
|
|
58
|
+
c.has_key?(:name).should be_true
|
|
59
|
+
c.has_key?(:edit_partial).should be_true
|
|
60
|
+
partial_is_mods << c[:edit_partial].include?("mods_assets")
|
|
61
|
+
end
|
|
62
|
+
partial_is_mods.include?(true).should be_true
|
|
63
|
+
end
|
|
64
|
+
it "should return the appropriate config when a model is available in the params hash" do
|
|
65
|
+
@document = nil
|
|
66
|
+
to = SubmissionWorkflowObject.new
|
|
67
|
+
to.stub(:params).and_return({:content_type => "generic_content"})
|
|
68
|
+
config = to.model_config
|
|
69
|
+
config.should be_kind_of(Array)
|
|
70
|
+
config.length.should == 4
|
|
71
|
+
partial_is_generic = []
|
|
72
|
+
config.each do |c|
|
|
73
|
+
c.is_a?(Hash).should be_true
|
|
74
|
+
c.has_key?(:name).should be_true
|
|
75
|
+
c.has_key?(:edit_partial).should be_true
|
|
76
|
+
partial_is_generic << c[:edit_partial].include?("generic_content")
|
|
77
|
+
end
|
|
78
|
+
partial_is_generic.include?(true).should be_true
|
|
79
|
+
end
|
|
80
|
+
it "should return the appropriate config when the ID of an object is available in the params hash" do
|
|
81
|
+
@document = nil
|
|
82
|
+
to = SubmissionWorkflowObject.new
|
|
83
|
+
to.stub(:params).and_return({:id=>"hydrangea:fixture_mods_article1"})
|
|
84
|
+
config = to.model_config
|
|
85
|
+
config.should be_kind_of(Array)
|
|
86
|
+
config.length.should == 5
|
|
87
|
+
config.each do |c|
|
|
88
|
+
c.is_a?(Hash).should be_true
|
|
89
|
+
c.has_key?(:name).should be_true
|
|
90
|
+
c.has_key?(:edit_partial).should be_true
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
it "should return the configuration for non mods assets (generic_content)" do
|
|
94
|
+
@document = nil
|
|
95
|
+
to = SubmissionWorkflowObject.new
|
|
96
|
+
to.stub(:params).and_return(:id=>"hydra:test_generic_content")
|
|
97
|
+
config = to.model_config
|
|
98
|
+
config.should be_kind_of(Array)
|
|
99
|
+
config.length.should == 4
|
|
100
|
+
partial_is_generic = []
|
|
101
|
+
config.each do |c|
|
|
102
|
+
c.is_a?(Hash).should be_true
|
|
103
|
+
c.has_key?(:name).should be_true
|
|
104
|
+
c.has_key?(:edit_partial).should be_true
|
|
105
|
+
partial_is_generic << c[:edit_partial].include?("generic_content")
|
|
106
|
+
end
|
|
107
|
+
partial_is_generic.include?(true).should be_true
|
|
108
|
+
end
|
|
109
|
+
it "should return nil if an ID is the only context available and it is not a valid object" do
|
|
110
|
+
@document = nil
|
|
111
|
+
to = SubmissionWorkflowObject.new
|
|
112
|
+
to.stub(:params).and_return(:id=>"hydra:not_an_actual_record")
|
|
113
|
+
to.model_config.should be_nil
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
describe "before_filter validation" do
|
|
117
|
+
it "should redirect back when the validation method returns false." do
|
|
118
|
+
@document = nil
|
|
119
|
+
to = SubmissionWorkflowObject.new
|
|
120
|
+
to.stub(:params).and_return({:id=>"hydrangea:fixture_mods_article1",:action=>"create"})
|
|
121
|
+
to.should_receive(:redirect_to).with(:back)
|
|
122
|
+
to.validate_workflow_step
|
|
123
|
+
end
|
|
124
|
+
it "should not redirect when the validation method returns true." do
|
|
125
|
+
@document = nil
|
|
126
|
+
to = SubmissionWorkflowObject.new
|
|
127
|
+
to.stub(:params).and_return({:id=>"hydrangea:fixture_mods_article1",:action=>"update"})
|
|
128
|
+
to.should_receive(:redirect_to).never
|
|
129
|
+
to.validate_workflow_step
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
class SubmissionWorkflowObject
|
|
134
|
+
include Hydra::SubmissionWorkflow
|
|
135
|
+
def mods_assets_create_validation
|
|
136
|
+
return false
|
|
137
|
+
end
|
|
138
|
+
def mods_assets_update_validation
|
|
139
|
+
return true
|
|
140
|
+
end
|
|
141
|
+
end
|