curate 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. data/LICENSE +14 -0
  2. data/app/controllers/application_controller.rb +69 -0
  3. data/app/controllers/catalog_controller.rb +336 -0
  4. data/app/controllers/classify_concerns_controller.rb +29 -0
  5. data/app/controllers/common_objects_controller.rb +27 -0
  6. data/app/controllers/curation_concern/base_controller.rb +26 -0
  7. data/app/controllers/curation_concern/generic_files_controller.rb +82 -0
  8. data/app/controllers/dashboard_controller.rb +85 -0
  9. data/app/controllers/downloads_controller.rb +22 -0
  10. data/app/controllers/errors_controller.rb +19 -0
  11. data/app/controllers/help_requests_controller.rb +38 -0
  12. data/app/controllers/terms_of_service_agreements_controller.rb +44 -0
  13. data/app/controllers/welcome_controller.rb +14 -0
  14. data/app/helpers/application_helper.rb +89 -0
  15. data/app/helpers/blacklight_helper.rb +19 -0
  16. data/app/helpers/common_objects_helper.rb +5 -0
  17. data/app/inputs/multi_value_input.rb +71 -0
  18. data/app/models/access_right.rb +53 -0
  19. data/app/models/classify_concern.rb +30 -0
  20. data/app/models/contributor_agreement.rb +58 -0
  21. data/app/models/digital_object_identifier.rb +83 -0
  22. data/app/models/doi_config.rb +26 -0
  23. data/app/models/help_request.rb +34 -0
  24. data/app/models/mint_doi.rb +51 -0
  25. data/app/models/mint_purl.rb +40 -0
  26. data/app/models/object_access.rb +17 -0
  27. data/app/models/purl.rb +18 -0
  28. data/app/models/purl_config.rb +10 -0
  29. data/app/models/repo_object.rb +24 -0
  30. data/app/models/solr_document.rb +35 -0
  31. data/app/repository_datastreams/file_content_datastream.rb +36 -0
  32. data/app/repository_models/curation_concern/embargoable.rb +43 -0
  33. data/app/repository_models/curation_concern/with_access_right.rb +31 -0
  34. data/app/repository_models/generic_file.rb +36 -0
  35. data/app/services/anti_virus_scanner.rb +28 -0
  36. data/app/services/curation_concern.rb +22 -0
  37. data/app/services/curation_concern/base_actor.rb +48 -0
  38. data/app/services/curation_concern/generic_file_actor.rb +38 -0
  39. data/app/validators/future_date_validator.rb +19 -0
  40. data/app/views/_footer.html.erb +19 -0
  41. data/app/views/_ga.html.erb +6 -0
  42. data/app/views/_logo.html.erb +34 -0
  43. data/app/views/_masthead.html.erb +34 -0
  44. data/app/views/catalog/_bookmark_control.html.erb +25 -0
  45. data/app/views/catalog/_bookmark_form.html.erb +8 -0
  46. data/app/views/catalog/_citation.html.erb +11 -0
  47. data/app/views/catalog/_constraints.html.erb +6 -0
  48. data/app/views/catalog/_constraints_element.html.erb +20 -0
  49. data/app/views/catalog/_delete_partials/_default.html.erb +29 -0
  50. data/app/views/catalog/_did_you_mean.html.erb +10 -0
  51. data/app/views/catalog/_document.html.erb +19 -0
  52. data/app/views/catalog/_document_list.html.erb +2 -0
  53. data/app/views/catalog/_edit_partials/_default.html.erb +58 -0
  54. data/app/views/catalog/_edit_partials/_default_details.html.erb +13 -0
  55. data/app/views/catalog/_email_form.html.erb +11 -0
  56. data/app/views/catalog/_facet_layout.html.erb +12 -0
  57. data/app/views/catalog/_facet_limit.html.erb +19 -0
  58. data/app/views/catalog/_facet_selected.html.erb +12 -0
  59. data/app/views/catalog/_facets.html.erb +5 -0
  60. data/app/views/catalog/_folder_control.html.erb +12 -0
  61. data/app/views/catalog/_home.html.erb +2 -0
  62. data/app/views/catalog/_home_text.html.erb +10 -0
  63. data/app/views/catalog/_index_default.html.erb +11 -0
  64. data/app/views/catalog/_index_partials/_default_group.html.erb +37 -0
  65. data/app/views/catalog/_marc_view.html.erb +33 -0
  66. data/app/views/catalog/_opensearch_response_metadata.html.erb +2 -0
  67. data/app/views/catalog/_previous_next_doc.html.erb +6 -0
  68. data/app/views/catalog/_refworks_form.html.erb +7 -0
  69. data/app/views/catalog/_results_pagination.html.erb +6 -0
  70. data/app/views/catalog/_search_form.html.erb +20 -0
  71. data/app/views/catalog/_show_default.html.erb +9 -0
  72. data/app/views/catalog/_show_partials/_default.html.erb +22 -0
  73. data/app/views/catalog/_show_partials/_default_details.html.erb +15 -0
  74. data/app/views/catalog/_show_partials/_facets.html.erb +52 -0
  75. data/app/views/catalog/_show_sidebar.html.erb +1 -0
  76. data/app/views/catalog/_show_tools.html.erb +46 -0
  77. data/app/views/catalog/_sms_form.html.erb +21 -0
  78. data/app/views/catalog/_sort_and_per_page.html.erb +38 -0
  79. data/app/views/catalog/_uva_tabs.html.erb +10 -0
  80. data/app/views/catalog/about.html.erb +0 -0
  81. data/app/views/catalog/citation.html.erb +1 -0
  82. data/app/views/catalog/email.erb +1 -0
  83. data/app/views/catalog/endnote.endnote.erb +1 -0
  84. data/app/views/catalog/index.atom.builder +109 -0
  85. data/app/views/catalog/index.html.erb +55 -0
  86. data/app/views/catalog/index.rss.builder +19 -0
  87. data/app/views/catalog/librarian_view.html.erb +3 -0
  88. data/app/views/catalog/opensearch.json.erb +0 -0
  89. data/app/views/catalog/opensearch.xml.builder +10 -0
  90. data/app/views/catalog/send_email_record.erb +0 -0
  91. data/app/views/catalog/show.endnote.erb +1 -0
  92. data/app/views/catalog/show.html.erb +40 -0
  93. data/app/views/catalog/show.refworks.erb +1 -0
  94. data/app/views/catalog/sms.erb +1 -0
  95. data/app/views/classify_concerns/new.html.erb +24 -0
  96. data/app/views/common_objects/_generic_file.html.erb +0 -0
  97. data/app/views/common_objects/_senior_thesis.html.erb +2 -0
  98. data/app/views/common_objects/show.html.erb +11 -0
  99. data/app/views/common_objects/show_stub_information.html.erb +13 -0
  100. data/app/views/curation_concern/_content_license.html.erb +16 -0
  101. data/app/views/curation_concern/_contributor_agreement.html.erb +27 -0
  102. data/app/views/curation_concern/_doi.html.erb +43 -0
  103. data/app/views/curation_concern/_media_display.html.erb +1 -0
  104. data/app/views/curation_concern/_permission.html.erb +39 -0
  105. data/app/views/curation_concern/_related_files.html.erb +46 -0
  106. data/app/views/curation_concern/generic_files/_attributes.html.erb +63 -0
  107. data/app/views/curation_concern/generic_files/_form.html.erb +57 -0
  108. data/app/views/curation_concern/generic_files/edit.html.erb +5 -0
  109. data/app/views/curation_concern/generic_files/new.html.erb +5 -0
  110. data/app/views/curation_concern/generic_files/show.html.erb +12 -0
  111. data/app/views/curation_concern/senior_theses/_attributes.html.erb +13 -0
  112. data/app/views/curation_concern/senior_theses/_form.html.erb +88 -0
  113. data/app/views/curation_concern/senior_theses/edit.html.erb +15 -0
  114. data/app/views/curation_concern/senior_theses/new.html.erb +14 -0
  115. data/app/views/curation_concern/senior_theses/show.html.erb +18 -0
  116. data/app/views/dashboard/_constraints.html.erb +22 -0
  117. data/app/views/dashboard/_did_you_mean.html.erb +26 -0
  118. data/app/views/dashboard/_document_list.html.erb +20 -0
  119. data/app/views/dashboard/_facet_layout.html.erb +27 -0
  120. data/app/views/dashboard/_facet_limit.html.erb +35 -0
  121. data/app/views/dashboard/_facet_pagination.html.erb +25 -0
  122. data/app/views/dashboard/_facet_selected.html.erb +28 -0
  123. data/app/views/dashboard/_facets.html.erb +22 -0
  124. data/app/views/dashboard/_index_partials/_default_group.html.erb +37 -0
  125. data/app/views/dashboard/_index_partials/_list_files.html.erb +66 -0
  126. data/app/views/dashboard/_index_partials/_thumbnail_display.html.erb +0 -0
  127. data/app/views/dashboard/_results_pagination.html.erb +22 -0
  128. data/app/views/dashboard/_search_form.html.erb +36 -0
  129. data/app/views/dashboard/_show_partials/_default.html.erb +38 -0
  130. data/app/views/dashboard/_show_partials/_default_details.html.erb +31 -0
  131. data/app/views/dashboard/_show_partials/_facets.html.erb +103 -0
  132. data/app/views/dashboard/_sort_and_per_page.html.erb +18 -0
  133. data/app/views/dashboard/facet.html.erb +38 -0
  134. data/app/views/dashboard/get_related_file.html.erb +4 -0
  135. data/app/views/dashboard/index.html.erb +60 -0
  136. data/app/views/errors/401.html.erb +5 -0
  137. data/app/views/errors/404.html.erb +16 -0
  138. data/app/views/errors/500.html.erb +10 -0
  139. data/app/views/help_requests/new.html.erb +60 -0
  140. data/app/views/layouts/application.html.erb +14 -0
  141. data/app/views/layouts/boilerplate.html.erb +28 -0
  142. data/app/views/layouts/common_objects.html.erb +45 -0
  143. data/app/views/layouts/curate_nd.html.erb +55 -0
  144. data/app/views/layouts/curate_nd/1_column.html.erb +22 -0
  145. data/app/views/layouts/curate_nd/2_column.html.erb +26 -0
  146. data/app/views/layouts/curate_nd/catalog.html.erb +22 -0
  147. data/app/views/layouts/curate_nd/dashboard.html.erb +22 -0
  148. data/app/views/layouts/hydra-head.html.erb +95 -0
  149. data/app/views/shared/_action_bar.html.erb +30 -0
  150. data/app/views/shared/_flash_message.html.erb +9 -0
  151. data/app/views/shared/_site_search.html.erb +18 -0
  152. data/app/views/terms_of_service_agreements/new.html.erb +136 -0
  153. data/app/views/welcome/index.html.erb +21 -0
  154. data/app/workers/characterize_job.rb +4 -0
  155. data/app/workers/doi_worker.rb +16 -0
  156. data/config/routes.rb +35 -0
  157. data/lib/curate.rb +6 -0
  158. data/lib/curate/engine.rb +46 -0
  159. data/lib/curate/version.rb +1 -1
  160. data/spec/abilities/generic_file_abilities_spec.rb +55 -0
  161. data/spec/controllers/application_controller_spec.rb +38 -0
  162. data/spec/controllers/classify_concerns_controller_spec.rb +36 -0
  163. data/spec/controllers/common_objects_controller_spec.rb +112 -0
  164. data/spec/controllers/curation_concern/base_controller_spec.rb +14 -0
  165. data/spec/controllers/curation_concern/generic_files_controller_spec.rb +156 -0
  166. data/spec/controllers/dashboard_controller_spec.rb +85 -0
  167. data/spec/controllers/downloads_controller_spec.rb +42 -0
  168. data/spec/controllers/help_requests_controller_spec.rb +42 -0
  169. data/spec/controllers/terms_of_service_agreements_controller_spec.rb +30 -0
  170. data/spec/controllers/welcome_controller_spec.rb +10 -0
  171. data/spec/dummy/app/models/solr_document.rb +4 -0
  172. data/spec/dummy/app/models/user.rb +13 -0
  173. data/spec/dummy/config/application.rb +8 -1
  174. data/spec/dummy/config/database.yml +21 -22
  175. data/spec/dummy/config/doi.yml +11 -0
  176. data/spec/dummy/config/fedora.yml +20 -0
  177. data/spec/dummy/config/initializers/devise.rb +232 -0
  178. data/spec/dummy/config/initializers/hydra_config.rb +41 -0
  179. data/spec/dummy/config/initializers/mailboxer.rb +17 -0
  180. data/spec/dummy/config/initializers/redis_config.rb +45 -0
  181. data/spec/dummy/config/initializers/sufia.rb +66 -0
  182. data/spec/dummy/config/purl.yml +15 -0
  183. data/spec/dummy/config/redis.yml +6 -0
  184. data/spec/dummy/config/role_map_ci.yml +15 -0
  185. data/spec/dummy/config/role_map_cucumber.yml +10 -0
  186. data/spec/dummy/config/role_map_development.yml +12 -0
  187. data/spec/dummy/config/role_map_pre_production.yml +2 -0
  188. data/spec/dummy/config/role_map_production.yml +2 -0
  189. data/spec/dummy/config/role_map_test.yml +15 -0
  190. data/spec/dummy/config/routes.rb +4 -55
  191. data/spec/dummy/config/solr.yml +17 -0
  192. data/spec/dummy/db/migrate/20130130142162_create_purl.rb +55 -0
  193. data/spec/dummy/db/migrate/20130312135359_create_help_requests.rb +22 -0
  194. data/spec/dummy/db/migrate/20130408165008_create_users.rb +11 -0
  195. data/spec/dummy/db/migrate/20130408165009_acts_as_follower_migration.rb +31 -0
  196. data/spec/dummy/db/migrate/20130408165010_add_social_to_users.rb +27 -0
  197. data/spec/dummy/db/migrate/20130408165011_create_single_use_links.rb +12 -0
  198. data/spec/dummy/db/migrate/20130408165012_add_ldap_attrs_to_user.rb +41 -0
  199. data/spec/dummy/db/migrate/20130408165013_add_avatars_to_users.rb +23 -0
  200. data/spec/dummy/db/migrate/20130408165014_create_checksum_audit_logs.rb +34 -0
  201. data/spec/dummy/db/migrate/20130408165015_create_version_committers.rb +29 -0
  202. data/spec/dummy/db/migrate/20130408165016_add_groups_to_users.rb +25 -0
  203. data/spec/dummy/db/migrate/20130408165017_create_local_authorities.rb +64 -0
  204. data/spec/dummy/db/migrate/20130408165018_create_trophies.rb +10 -0
  205. data/spec/dummy/db/migrate/20130408165022_create_mailboxer.mailboxer_engine.rb +62 -0
  206. data/spec/dummy/db/migrate/20130408165023_add_notified_object.mailboxer_engine.rb +18 -0
  207. data/spec/dummy/db/migrate/20130408165024_add_notification_code.mailboxer_engine.rb +14 -0
  208. data/spec/dummy/db/migrate/20130408165025_add_attachments.mailboxer_engine.rb +10 -0
  209. data/spec/dummy/db/migrate/20130408165026_rename_receipts_read.mailboxer_engine.rb +10 -0
  210. data/spec/dummy/db/schema.rb +197 -0
  211. data/spec/dummy/db/test.sqlite3 +0 -0
  212. data/spec/dummy/fedora_conf/conf/development/fedora.fcfg +953 -0
  213. data/spec/dummy/fedora_conf/conf/test/fedora.fcfg +953 -0
  214. data/spec/dummy/log/development.log +1791 -0
  215. data/spec/dummy/log/test.log +176333 -0
  216. data/spec/dummy/solr_conf/conf/schema.xml +692 -0
  217. data/spec/dummy/solr_conf/conf/solrconfig.xml +299 -0
  218. data/spec/dummy/solr_conf/solr.xml +35 -0
  219. data/spec/factories/create_curation_concern.rb +11 -0
  220. data/spec/factories/create_generic_file.rb +36 -0
  221. data/spec/factories/help_requests.rb +10 -0
  222. data/spec/factories/mock_curation_concerns.rb +4 -0
  223. data/spec/factories/users.rb +8 -0
  224. data/spec/helpers/application_helper_spec.rb +139 -0
  225. data/spec/helpers/common_objects_helper_spec.rb +9 -0
  226. data/spec/models/access_right_spec.rb +47 -0
  227. data/spec/models/classify_concern_spec.rb +30 -0
  228. data/spec/models/contributor_agreement_spec.rb +45 -0
  229. data/spec/models/digital_object_identifier_spec.rb +50 -0
  230. data/spec/models/help_request_spec.rb +5 -0
  231. data/spec/models/mint_doi_spec.rb +79 -0
  232. data/spec/models/mint_purl_spec.rb +38 -0
  233. data/spec/models/object_access_spec.rb +24 -0
  234. data/spec/models/purl_spec.rb +22 -0
  235. data/spec/models/repo_object_spec.rb +39 -0
  236. data/spec/repository_models/curation_concern/embargoable_spec.rb +69 -0
  237. data/spec/repository_models/generic_file_spec.rb +38 -0
  238. data/spec/services/anti_virus_scanner_spec.rb +26 -0
  239. data/spec/services/curation_concern/base_actor_spec.rb +28 -0
  240. data/spec/services/curation_concern/generic_file_actor_spec.rb +75 -0
  241. data/spec/services/curation_concern_spec.rb +34 -0
  242. data/spec/spec_helper.rb +54 -1
  243. data/spec/support/environment_override.rb +17 -0
  244. data/spec/support/matchers/raise_rescue_response_type_matcher.rb +42 -0
  245. data/spec/support/mock_curation_concern.rb +61 -0
  246. data/spec/support/shared/shared_examples_is_embargoable.rb +9 -0
  247. data/spec/support/shared/shared_examples_with_access_rights.rb +33 -0
  248. data/spec/workers/characterize_job_spec.rb +26 -0
  249. metadata +686 -10
  250. data/MIT-LICENSE +0 -20
@@ -0,0 +1,21 @@
1
+ <% content_for :page_title, construct_page_title('Welcome') %>
2
+ <% content_for :page_class, 'home' %>
3
+ <% content_for :page_header do %>
4
+
5
+ <h2>What is <%=t('sufia.product_name')%>?</h2>
6
+
7
+ <% end %>
8
+
9
+ <% content_for :left_column_class, 'span5' %>
10
+ <% content_for :left_column do %>
11
+
12
+ <%= render '/catalog/home_text' %>
13
+
14
+ <% end %>
15
+
16
+ <% content_for :right_column_class, 'span7 emphatic-action-area' %>
17
+ <% content_for :right_column do %>
18
+
19
+ <%= link_to 'Get Started', new_classify_concern_path, :class => "btn btn-large btn-primary" %>
20
+
21
+ <% end %>
@@ -0,0 +1,4 @@
1
+ require Sufia::Engine.root.join('lib/sufia/jobs/characterize_job')
2
+
3
+ # class CharacterizeJob
4
+ # end
@@ -0,0 +1,16 @@
1
+ class DoiWorker
2
+ def queue_name
3
+ :doi
4
+ end
5
+
6
+ attr_accessor :generic_file_id
7
+
8
+ def initialize(generic_file_id)
9
+ self.generic_file_id = generic_file_id
10
+ end
11
+
12
+ def run
13
+ mint_doi = MintDoi.new(generic_file_id)
14
+ mint_doi.create_or_retrieve_doi
15
+ end
16
+ end
@@ -1,2 +1,37 @@
1
1
  Rails.application.routes.draw do
2
+ # devise_for :users
3
+
4
+ mount_roboto
5
+
6
+ Blacklight.add_routes(self)
7
+
8
+ resources 'dashboard', :only=>:index do
9
+ collection do
10
+ get 'page/:page', :action => :index
11
+ get 'facet/:id', :action => :facet, :as => :dashboard_facet
12
+ get 'related/:id',:action => :get_related_file, :as => :related_file
13
+ end
14
+ end
15
+ resources :downloads, only: [:show]
16
+
17
+ namespace :curation_concern, path: :concern do
18
+ resources(
19
+ :generic_files,
20
+ only: [:new, :create],
21
+ path: 'container/:parent_id/generic_files'
22
+ )
23
+ resources(
24
+ :generic_files,
25
+ only: [:show, :edit, :update, :destroy]
26
+ )
27
+ end
28
+
29
+ resources :terms_of_service_agreements, only: [:new, :create]
30
+ resources :help_requests, only: [:new, :create]
31
+ resources :classify_concerns, only: [:new, :create]
32
+
33
+ match "show/:id" => "common_objects#show", via: :get, as: "common_object"
34
+ match "show/stub/:id" => "common_objects#show_stub_information", via: :get, as: "common_object_stub_information"
35
+ root to: 'welcome#index'
36
+
2
37
  end
@@ -1,4 +1,10 @@
1
+ require 'devise'
2
+ require 'warden'
3
+ require 'sufia'
1
4
  require "curate/engine"
5
+ require 'rails'
6
+ require 'simple_form'
7
+ require 'roboto'
2
8
 
3
9
  module Curate
4
10
  end
@@ -1,4 +1,50 @@
1
1
  module Curate
2
2
  class Engine < ::Rails::Engine
3
+ def paths
4
+ @curate_paths ||= begin
5
+ super_paths = super
6
+ super_paths.add "app/repository_datastreams", eager_load: true
7
+ super_paths.add "app/repository_models", eager_load: true
8
+ super_paths.add "app/repository_models/curation_concern", eager_load: true
9
+ super_paths.add "app/services", eager_load: true
10
+ super_paths.add "app/validators", eager_load: true
11
+ super_paths.add "app/workers", eager_load: true
12
+ super_paths.add "app/inputs", eager_load: true
13
+ super_paths.add "app/mailers", eager_load: true
14
+ super_paths
15
+ end
16
+ end
17
+
18
+ config.action_dispatch.rescue_responses["ActionController::RoutingError"] = :not_found
19
+ config.action_dispatch.rescue_responses["ActiveFedora::ObjectNotFoundError"] = :not_found
20
+ config.action_dispatch.rescue_responses["ActiveFedora::ActiveObjectNotFoundError"] = :not_found
21
+ config.action_dispatch.rescue_responses["Hydra::AccessDenied"] = :unauthorized
22
+ config.action_dispatch.rescue_responses["CanCan::AccessDenied"] = :unauthorized
23
+ config.action_dispatch.rescue_responses["Rubydora::RecordNotFound"] = :not_found
24
+
25
+ initializer "curate" do |app|
26
+ require File.expand_path('../../../app/repository_models/generic_file', __FILE__)
27
+ require File.expand_path('../../../app/models/solr_document', __FILE__)
28
+ # require File.expand_path('../../../app/workers/characterize_job', __FILE__)
29
+
30
+ module WithAntiVirusHandler
31
+ def run
32
+ super
33
+ rescue AntiVirusScanner::VirusDetected => e
34
+ GenericFile.find(generic_file_id).destroy
35
+ raise e
36
+ end
37
+ end
38
+ CharacterizeJob.send(:include, WithAntiVirusHandler)
39
+
40
+ require File.expand_path('../../../app/controllers/application_controller', __FILE__)
41
+ require File.expand_path('../../../app/controllers/downloads_controller', __FILE__)
42
+ require File.expand_path('../../../app/controllers/errors_controller', __FILE__)
43
+ require File.expand_path('../../../app/controllers/catalog_controller', __FILE__)
44
+ require File.expand_path('../../../app/controllers/dashboard_controller', __FILE__)
45
+
46
+ require File.expand_path('../../../app/helpers/blacklight_helper', __FILE__)
47
+
48
+ end
3
49
  end
4
50
  end
@@ -1,3 +1,3 @@
1
1
  module Curate
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+ require "cancan/matchers"
3
+
4
+ describe "User" do
5
+ describe "Abilities" do
6
+ subject { ability }
7
+ let(:ability) { Ability.new(current_user) }
8
+ let(:visibility) { AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE }
9
+ let(:mock_curation_concern) {
10
+ FactoryGirl.create_curation_concern(:mock_curation_concern, creating_user, { visibility: visibility })
11
+ }
12
+ let(:generic_file) {
13
+ FactoryGirl.create_generic_file(mock_curation_concern, creating_user) { |gf|
14
+ gf.visibility = visibility
15
+ }
16
+ }
17
+ let(:creating_user) { nil }
18
+ let(:current_user) { nil }
19
+ let(:user) { FactoryGirl.create(:user) }
20
+ describe 'without embargo' do
21
+ describe 'creator of object' do
22
+ let(:creating_user) { user }
23
+ let(:current_user) { user }
24
+ it {
25
+ should be_able_to(:create, GenericFile.new)
26
+ should be_able_to(:read, generic_file)
27
+ should be_able_to(:update, generic_file)
28
+ should_not be_able_to(:delete, generic_file)
29
+ }
30
+ end
31
+
32
+ describe 'another authenticated user' do
33
+ let(:creating_user) { FactoryGirl.create(:user) }
34
+ let(:current_user) { user }
35
+ it {
36
+ should be_able_to(:create, GenericFile.new)
37
+ should_not be_able_to(:read, generic_file)
38
+ should_not be_able_to(:update, generic_file)
39
+ should_not be_able_to(:delete, generic_file)
40
+ }
41
+ end
42
+
43
+ describe 'a nil user' do
44
+ let(:creating_user) { FactoryGirl.create(:user) }
45
+ let(:current_user) { nil }
46
+ it {
47
+ should_not be_able_to(:create, GenericFile.new)
48
+ should_not be_able_to(:read, generic_file)
49
+ should_not be_able_to(:update, generic_file)
50
+ should_not be_able_to(:delete, generic_file)
51
+ }
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe CommonObjectsController do
4
+
5
+ let(:user) { FactoryGirl.create(:user) }
6
+
7
+ describe 'devise sign_in helper' do
8
+ it 'should set :current_user on signin' do
9
+ expect {
10
+ sign_in(user)
11
+ }.to change(controller, :current_user).from(nil).to(user)
12
+ end
13
+
14
+ it 'should indicate :user_signed_in?' do
15
+ expect {
16
+ sign_in(user)
17
+ }.to change(controller, :user_signed_in?).from(false).to(true)
18
+ end
19
+ end
20
+
21
+ describe 'devise sign_out helper' do
22
+ before(:each) do
23
+ sign_in(user)
24
+ end
25
+ it 'should unset :current_user' do
26
+ expect {
27
+ sign_out(user)
28
+ }.to change(controller, :current_user).from(user).to(nil)
29
+ end
30
+
31
+ it 'should indicate :user_signed_in?' do
32
+ expect {
33
+ sign_out(user)
34
+ }.to change(controller, :user_signed_in?).from(true).to(false)
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe ClassifyConcernsController do
4
+ render_views
5
+ let(:user) { FactoryGirl.create(:user) }
6
+
7
+ describe '#new' do
8
+ it 'requires authentication' do
9
+ get :new
10
+ response.status.should == 302
11
+ expect(response).to redirect_to(user_session_path)
12
+ end
13
+ it 'renders when signed in' do
14
+ sign_in(user)
15
+ get :new
16
+ response.status.should == 200
17
+ end
18
+ end
19
+
20
+ describe '#create' do
21
+ let(:user) { FactoryGirl.create(:user) }
22
+ it 'redirect to login page if user is not logged in' do
23
+ post :create, classify: { curation_concern_type: 'MockCurationConcern' }
24
+ response.status.should == 302
25
+ expect(response).to redirect_to(user_session_path)
26
+ end
27
+
28
+ it 'requires authentication' do
29
+ sign_in(user)
30
+ post :create, classify_concern: { curation_concern_type: 'MockCurationConcern' }
31
+ response.status.should == 302
32
+ expect(response).to redirect_to(new_curation_concern_mock_curation_concern_path)
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,112 @@
1
+ require 'spec_helper'
2
+
3
+ describe CommonObjectsController do
4
+ render_views
5
+
6
+ let(:user) { FactoryGirl.create(:user) }
7
+ let(:another_user) { FactoryGirl.create(:user) }
8
+ let(:visibility) { nil }
9
+ let(:curation_concern) {
10
+ FactoryGirl.create_generic_file(:mock_curation_concern, user) { |gf|
11
+ gf.visibility = visibility
12
+ }
13
+ }
14
+ describe '#show' do
15
+ let(:template_for_success) { 'show' }
16
+ describe '"Open Access" object' do
17
+ let(:visibility) { AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC }
18
+ it 'renders for unauthenticated person' do
19
+ get :show, id: curation_concern.to_param
20
+ response.status.should == 200
21
+ expect(response).to render_template(template_for_success)
22
+ end
23
+
24
+ it 'renders for the creator' do
25
+ sign_in(user)
26
+ get :show, id: curation_concern.to_param
27
+ response.status.should == 200
28
+ expect(response).to render_template(template_for_success)
29
+ end
30
+
31
+ it 'renders for the another user' do
32
+ sign_in(another_user)
33
+ get :show, id: curation_concern.to_param
34
+ response.status.should == 200
35
+ expect(response).to render_template(template_for_success)
36
+ end
37
+ end
38
+
39
+ describe '"Restricted" object' do
40
+ let(:visibility) { AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE }
41
+ it 'redirect to DOI information for unauthenticated person' do
42
+ get :show, id: curation_concern.to_param
43
+ response.status.should == 302
44
+ expect(response).to redirect_to(common_object_stub_information_path(curation_concern))
45
+ end
46
+
47
+ it 'renders for the creator' do
48
+ sign_in(user)
49
+ get :show, id: curation_concern.to_param
50
+ response.status.should == 200
51
+ expect(response).to render_template(template_for_success)
52
+ end
53
+
54
+ it 'renders for the creator' do
55
+ sign_in(another_user)
56
+ get :show, id: curation_concern.to_param
57
+ response.status.should == 302
58
+ expect(response).to redirect_to(common_object_stub_information_path(curation_concern))
59
+ end
60
+ end
61
+ describe '"Institution Only" object' do
62
+ let(:visibility) { AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED }
63
+ it 'does not display for unauthenticated person' do
64
+ get :show, id: curation_concern.to_param
65
+ response.status.should == 302
66
+ expect(response).to redirect_to(common_object_stub_information_path(curation_concern))
67
+ end
68
+
69
+ it 'renders for the creator' do
70
+ sign_in(user)
71
+ get :show, id: curation_concern.to_param
72
+ response.status.should == 200
73
+ expect(response).to render_template(template_for_success)
74
+ end
75
+
76
+ it 'renders for the creator' do
77
+ sign_in(another_user)
78
+ get :show, id: curation_concern.to_param
79
+ response.status.should == 200
80
+ expect(response).to render_template(template_for_success)
81
+ end
82
+ end
83
+ end
84
+
85
+ describe '#show_stub_information' do
86
+ let(:template_for_success) { 'show_stub_information' }
87
+ describe '"Open Access" object' do
88
+ let(:visibility) { AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC }
89
+ it 'renders rudimentary DOI information' do
90
+ get :show_stub_information, id: curation_concern.to_param
91
+ response.status.should == 200
92
+ expect(response).to render_template(template_for_success)
93
+ end
94
+ end
95
+ describe '"Restricted" object' do
96
+ let(:visibility) { AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE }
97
+ it 'renders rudimentary DOI information' do
98
+ get :show_stub_information, id: curation_concern.to_param
99
+ response.status.should == 200
100
+ expect(response).to render_template(template_for_success)
101
+ end
102
+ end
103
+ describe '"Institution Only" object' do
104
+ let(:visibility) { AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED }
105
+ it 'renders rudimentary DOI information' do
106
+ get :show_stub_information, id: curation_concern.to_param
107
+ response.status.should == 200
108
+ expect(response).to render_template(template_for_success)
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe CurationConcern::BaseController do
4
+ it 'should have #save_and_add_related_files_submit_value' do
5
+ subject._helper_methods.should include(:save_and_add_related_files_submit_value)
6
+ end
7
+ it 'should have #curation_concern exposed' do
8
+ subject._helper_methods.should include(:curation_concern)
9
+ end
10
+
11
+ it 'has #contributor_agreement' do
12
+ subject._helper_methods.should include(:contributor_agreement)
13
+ end
14
+ end
@@ -0,0 +1,156 @@
1
+ require 'spec_helper'
2
+
3
+ describe CurationConcern::GenericFilesController do
4
+ render_views
5
+ let(:user) { FactoryGirl.create(:user) }
6
+ let(:another_user) { FactoryGirl.create(:user) }
7
+ let(:visibility) { AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE }
8
+ let(:parent) {
9
+ FactoryGirl.create_curation_concern(:mock_curation_concern, user, {visibility: visibility})
10
+ }
11
+ let(:file) { Rack::Test::UploadedFile.new(__FILE__, 'text/plain', false) }
12
+ let(:generic_file) { FactoryGirl.create_generic_file(parent, user) {|gf|
13
+ gf.visibility = visibility
14
+ }
15
+ }
16
+ let(:another_user) { FactoryGirl.create(:user) }
17
+
18
+ describe '#new' do
19
+ it 'renders a form if you can edit the parent' do
20
+ parent
21
+ sign_in user
22
+ get(:new, parent_id: parent.to_param)
23
+ response.should be_successful
24
+ expect(response).to render_template('new')
25
+ end
26
+
27
+ it 'redirects if you cannot edit the parent' do
28
+ sign_in(another_user)
29
+ parent
30
+ expect {
31
+ get :new, parent_id: parent.to_param
32
+ }.to raise_rescue_response_type(:unauthorized)
33
+ end
34
+ end
35
+
36
+ describe '#create' do
37
+ let(:actor) { double('actor') }
38
+ let(:actors_action) { :create! }
39
+ let(:invalid_exception) {
40
+ ActiveFedora::RecordInvalid.new(ActiveFedora::Base.new)
41
+ }
42
+ let(:failing_actor) {
43
+ actor.should_receive(actors_action).and_raise(invalid_exception)
44
+ actor
45
+ }
46
+ let(:successful_actor) {
47
+ actor.should_receive(actors_action).and_return(true)
48
+ actor
49
+ }
50
+
51
+ it 'redirects to parent when successful' do
52
+ sign_in(user)
53
+ parent
54
+ controller.actor = successful_actor
55
+
56
+ post(
57
+ :create,
58
+ parent_id: parent.to_param,
59
+ generic_file: { title: "Title", file: file }
60
+ )
61
+
62
+ expect(response).to(
63
+ redirect_to(controller.polymorphic_path([:curation_concern, parent]))
64
+ )
65
+ end
66
+
67
+ it 'renders form when unsuccessful' do
68
+ sign_in(user)
69
+ parent
70
+ controller.actor = failing_actor
71
+
72
+ post(
73
+ :create,
74
+ parent_id: parent.to_param,
75
+ generic_file: { title: "Title", file: file }
76
+ )
77
+
78
+ expect(response).to render_template('new')
79
+ response.status.should == 422
80
+ end
81
+
82
+ end
83
+
84
+ describe '#edit' do
85
+ it 'should be successful' do
86
+ generic_file
87
+ sign_in user
88
+ get :edit, id: generic_file.to_param
89
+ controller.curation_concern.should be_kind_of(GenericFile)
90
+ response.should be_successful
91
+ end
92
+ end
93
+
94
+ describe '#update' do
95
+ let(:updated_title) { Time.now.to_s }
96
+ let(:failing_actor) {
97
+ actor.
98
+ should_receive(:update!).
99
+ and_raise(ActiveFedora::RecordInvalid.new(ActiveFedora::Base.new))
100
+ actor
101
+ }
102
+ let(:successful_actor) {
103
+ actor.should_receive(:update!).and_return(true)
104
+ actor
105
+ }
106
+ let(:actor) { double('actor') }
107
+ it 'renders form when unsuccessful' do
108
+ generic_file
109
+ controller.actor = failing_actor
110
+ sign_in(user)
111
+ put :update, id: generic_file.to_param, generic_file: {title: updated_title}
112
+ expect(response).to render_template('edit')
113
+ response.status.should == 422
114
+ end
115
+
116
+ it 'redirects to parent when successful' do
117
+ generic_file
118
+ sign_in(user)
119
+ put :update, id: generic_file.to_param, generic_file: {title: updated_title}
120
+ response.status.should == 302
121
+ expect(response).to(
122
+ redirect_to(
123
+ controller.polymorphic_path([:curation_concern, generic_file])
124
+ )
125
+ )
126
+ end
127
+ end
128
+
129
+ describe '#show' do
130
+ it 'should be successful if logged in' do
131
+ generic_file
132
+ sign_in user
133
+ get :show, id: generic_file.to_param
134
+ controller.curation_concern.should be_kind_of(GenericFile)
135
+ response.should be_successful
136
+ end
137
+
138
+ it 'does not allow another user to view it' do
139
+ generic_file
140
+ sign_in another_user
141
+ expect {
142
+ get :show, id: generic_file.to_param
143
+ }.to raise_rescue_response_type(:unauthorized)
144
+ end
145
+ end
146
+
147
+ describe '#destroy' do
148
+ it 'should be successful if file exists' do
149
+ parent = generic_file.batch
150
+ sign_in(user)
151
+ delete :destroy, id: generic_file.to_param
152
+ expect(response.status).to eq(302)
153
+ expect(response).to redirect_to(controller.polymorphic_path([:curation_concern, parent]))
154
+ end
155
+ end
156
+ end