sufia 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +5 -2
  5. data/History.md +6 -0
  6. data/README.md +40 -0
  7. data/Rakefile +4 -0
  8. data/app/assets/javascripts/sufia.js +3 -115
  9. data/app/assets/javascripts/sufia/batch_select_all.js +179 -0
  10. data/app/assets/javascripts/sufia/edit_metadata.js +86 -0
  11. data/app/assets/javascripts/sufia/multiForm.js +57 -0
  12. data/app/assets/javascripts/terms_of_service.js +7 -0
  13. data/app/assets/stylesheets/audio-js.css +3 -0
  14. data/app/assets/stylesheets/dashboard.css.scss +51 -0
  15. data/app/assets/stylesheets/generic_files.css +36 -0
  16. data/app/assets/stylesheets/sufia.css.scss +2 -0
  17. data/app/controllers/batch_controller.rb +11 -0
  18. data/app/controllers/batch_edits_controller.rb +1 -77
  19. data/app/controllers/generic_files_controller.rb +1 -0
  20. data/app/controllers/mailbox_controller.rb +1 -1
  21. data/app/controllers/single_use_link_controller.rb +11 -7
  22. data/app/helpers/generic_file_helper.rb +11 -3
  23. data/app/helpers/sufia_helper.rb +13 -10
  24. data/app/models/batch.rb +1 -1
  25. data/app/models/datastreams/fits_datastream.rb +2 -2
  26. data/app/models/datastreams/generic_file_rdf_datastream.rb +22 -18
  27. data/app/models/datastreams/properties_datastream.rb +2 -2
  28. data/app/views/_user_util_links.html.erb +2 -2
  29. data/app/views/batch/_metadata.html.erb +82 -0
  30. data/app/views/batch/_more_metadata.html.erb +6 -0
  31. data/app/views/batch/edit.html.erb +1 -8
  32. data/app/views/batch_edits/_check_all.html.erb +0 -157
  33. data/app/views/batch_edits/edit.html.erb +0 -29
  34. data/app/views/catalog/_index_partials/_list_files.html.erb +8 -10
  35. data/app/views/catalog/_recent_document.html.erb +9 -18
  36. data/app/views/catalog/_results_pagination.html.erb +1 -1
  37. data/app/views/contact_form/new.html.erb +1 -1
  38. data/app/views/dashboard/_index_partials/_default_group.html.erb +1 -1
  39. data/app/views/dashboard/_index_partials/_list_files.html.erb +12 -14
  40. data/app/views/dashboard/_index_partials/_thumbnail_display.html.erb +9 -19
  41. data/app/views/dashboard/_results_pagination.html.erb +1 -1
  42. data/app/views/dashboard/index.html.erb +6 -82
  43. data/app/views/error/single_use_error.html.erb +35 -0
  44. data/app/views/generic_files/_descriptions.html.erb +2 -2
  45. data/app/views/generic_files/_extra_fields_modal.html.erb +1 -1
  46. data/app/views/generic_files/_field_form.html.erb +2 -5
  47. data/app/views/generic_files/_media_display.html.erb +8 -6
  48. data/app/views/generic_files/_permission.html.erb +2 -2
  49. data/app/views/generic_files/_rights_modal.html.erb +1 -1
  50. data/app/views/generic_files/_show_actions.html.erb +1 -1
  51. data/app/views/generic_files/_show_details.html.erb +11 -6
  52. data/app/views/generic_files/edit.html.erb +0 -8
  53. data/app/views/generic_files/edit_fields/_type.html.erb +1 -1
  54. data/app/views/generic_files/show.html.erb +5 -8
  55. data/app/views/generic_files/show_fields/_based_near.html.erb +4 -1
  56. data/app/views/generic_files/show_fields/_contributor.html.erb +4 -1
  57. data/app/views/generic_files/show_fields/_creator.html.erb +4 -1
  58. data/app/views/generic_files/show_fields/_date_created.html.erb +4 -1
  59. data/app/views/generic_files/show_fields/_description.html.erb +4 -1
  60. data/app/views/generic_files/show_fields/_language.html.erb +1 -1
  61. data/app/views/generic_files/show_fields/_publisher.html.erb +4 -1
  62. data/app/views/generic_files/show_fields/_related_url.html.erb +3 -1
  63. data/app/views/generic_files/show_fields/_resource_type.html.erb +1 -1
  64. data/app/views/generic_files/show_fields/_subject.html.erb +4 -1
  65. data/app/views/generic_files/show_fields/_tag.html.erb +1 -1
  66. data/app/views/generic_files/show_fields/_title.html.erb +4 -1
  67. data/app/views/layouts/error.html.erb +0 -4
  68. data/app/views/layouts/hydra-head.html.erb +2 -6
  69. data/app/views/single_use_link/show.html.erb +1 -1
  70. data/app/views/users/index.html.erb +1 -1
  71. data/app/views/users/show.html.erb +1 -1
  72. data/config/locales/sufia.en.yml +1 -0
  73. data/config/routes.rb +11 -4
  74. data/lib/generators/sufia/sufia_generator.rb +2 -1
  75. data/lib/generators/sufia/templates/catalog_controller.rb +143 -117
  76. data/lib/generators/sufia/templates/config/resque_admin.rb +10 -0
  77. data/lib/generators/sufia/templates/config/sufia.rb +8 -0
  78. data/lib/sufia.rb +4 -14
  79. data/lib/sufia/batch_edits_controller_behavior.rb +89 -0
  80. data/lib/sufia/controller.rb +7 -5
  81. data/lib/sufia/downloads_controller_behavior.rb +14 -19
  82. data/lib/sufia/file_content/extract_metadata.rb +11 -4
  83. data/lib/sufia/files_controller_behavior.rb +63 -44
  84. data/lib/sufia/generic_file.rb +29 -11
  85. data/lib/sufia/generic_file/audit.rb +1 -1
  86. data/lib/sufia/generic_file/thumbnail.rb +51 -26
  87. data/lib/sufia/id_service.rb +28 -11
  88. data/lib/sufia/jobs/batch_update_job.rb +2 -2
  89. data/lib/sufia/jobs/characterize_job.rb +11 -3
  90. data/lib/sufia/jobs/ffmpeg_transcode_job.rb +61 -0
  91. data/lib/sufia/jobs/resolrize_job.rb +1 -1
  92. data/lib/sufia/jobs/transcode_audio_job.rb +40 -0
  93. data/lib/sufia/jobs/transcode_video_job.rb +9 -49
  94. data/lib/sufia/queue/resque.rb +2 -2
  95. data/lib/sufia/single_use_error.rb +4 -0
  96. data/lib/sufia/solr_document_behavior.rb +108 -1
  97. data/lib/sufia/version.rb +1 -1
  98. data/solr_conf/conf/schema.xml +332 -652
  99. data/solr_conf/conf/solrconfig.xml +60 -196
  100. data/spec/controllers/batch_controller_spec.rb +4 -5
  101. data/spec/controllers/catalog_controller_spec.rb +13 -13
  102. data/spec/controllers/dashboard_controller_spec.rb +2 -2
  103. data/spec/controllers/downloads_controller_spec.rb +74 -62
  104. data/spec/controllers/generic_files_controller_spec.rb +10 -8
  105. data/spec/controllers/single_use_link_controller_spec.rb +12 -4
  106. data/spec/fixtures/Example.ogg +0 -0
  107. data/spec/fixtures/piano_note.wav +0 -0
  108. data/spec/fixtures/sufia_generic_stub.descMeta.txt +1 -1
  109. data/spec/helpers/sufia_helper_spec.rb +12 -0
  110. data/spec/models/characterize_job_spec.rb +89 -0
  111. data/spec/models/checksum_audit_log_spec.rb +1 -0
  112. data/spec/models/event_jobs_spec.rb +9 -9
  113. data/spec/models/file_content_datastream_spec.rb +16 -10
  114. data/spec/models/fits_datastream_spec.rb +2 -8
  115. data/spec/models/generic_file_spec.rb +131 -60
  116. data/spec/models/solr_document_spec.rb +21 -0
  117. data/spec/models/transcode_audio_job_spec.rb +81 -0
  118. data/spec/models/transcode_video_job_spec.rb +2 -2
  119. data/spec/models/unzip_job_spec.rb +3 -3
  120. data/spec/spec_helper.rb +21 -0
  121. data/spec/support/Gemfile +7 -3
  122. data/sufia.gemspec +8 -11
  123. data/tasks/cucumber.rake +1 -2
  124. data/tasks/sufia-dev.rake +13 -2
  125. data/tasks/sufia.rake +1 -1
  126. metadata +77 -118
  127. data/app/views/batch_edits/_metadata.html.erb +0 -180
  128. data/lib/generators/sufia/templates/config/hydra_config.rb +0 -32
  129. data/lib/kaminari/helpers/tag.rb +0 -11
@@ -1,57 +1,13 @@
1
1
  <?xml version="1.0" encoding="UTF-8" ?>
2
- <!--
3
- Licensed to the Apache Software Foundation (ASF) under one or more
4
- contributor license agreements. See the NOTICE file distributed with
5
- this work for additional information regarding copyright ownership.
6
- The ASF licenses this file to You under the Apache License, Version 2.0
7
- (the "License"); you may not use this file except in compliance with
8
- the License. You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing, software
13
- distributed under the License is distributed on an "AS IS" BASIS,
14
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific language governing permissions and
16
- limitations under the License.
17
- -->
18
-
19
- <!--
20
- For more details about configurations options that may appear in
21
- this file, see http://wiki.apache.org/solr/SolrConfigXml.
22
- -->
23
2
  <config>
24
- <!-- In all configuration below, a prefix of "solr." for class names
25
- is an alias that causes solr to search appropriate packages,
26
- including org.apache.solr.(search|update|request|core|analysis)
27
-
28
- You may also specify a fully qualified Java classname if you
29
- have your own custom plugins.
30
- -->
31
-
32
- <!-- Set this to 'false' if you want solr to continue working after
33
- it has encountered an severe configuration error. In a
34
- production environment, you may want solr to keep working even
35
- if one handler is mis-configured.
36
-
37
- You may also set this to false using by setting the system
38
- property:
39
-
40
- -Dsolr.abortOnConfigurationError=false
41
- -->
3
+ <!-- NOTE: various comments and unused configuration possibilities have been purged
4
+ from this file. Please refer to http://wiki.apache.org/solr/SolrConfigXml,
5
+ as well as the default solrconfig file included with Solr -->
6
+
42
7
  <abortOnConfigurationError>${solr.abortOnConfigurationError:true}</abortOnConfigurationError>
43
8
 
44
- <!-- Controls what version of Lucene various components of Solr
45
- adhere to. Generally, you want to use the latest version to
46
- get all bug fixes and improvements. It is highly recommended
47
- that you fully re-index after changing this setting as it can
48
- affect both how text is indexed and queried.
49
- -->
50
9
  <luceneMatchVersion>LUCENE_40</luceneMatchVersion>
51
10
 
52
- <!-- The DirectoryFactory to use for indexes.
53
- solr.StandardDirectoryFactory, the default, is filesystem based.
54
- solr.RAMDirectoryFactory is memory based, not persistent, and doesn't work with replication. -->
55
11
  <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.StandardDirectoryFactory}"/>
56
12
 
57
13
  <!-- solr lib dirs -->
@@ -60,40 +16,18 @@
60
16
 
61
17
  <dataDir>${solr.data.dir:}</dataDir>
62
18
 
63
- <requestHandler name="/replication" class="solr.ReplicationHandler" startup="lazy" />
64
-
65
- <requestDispatcher handleSelect="true" >
66
- <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048" />
67
- </requestDispatcher>
68
-
69
- <requestHandler name="/analysis/field" startup="lazy" class="solr.FieldAnalysisRequestHandler" />
70
- <requestHandler name="/update" class="solr.UpdateRequestHandler" />
71
- <requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
72
-
73
- <requestHandler name="/admin/ping" class="solr.PingRequestHandler">
74
- <lst name="invariants">
75
- <str name="q">solrpingquery</str>
76
- </lst>
77
- <lst name="defaults">
78
- <str name="echoParams">all</str>
79
- </lst>
80
- </requestHandler>
81
-
82
- <!-- config for the admin interface -->
83
- <admin>
84
- <defaultQuery>search</defaultQuery>
85
- </admin>
86
-
87
-
88
19
  <requestHandler name="search" class="solr.SearchHandler" default="true">
89
20
  <!-- default values for query parameters can be specified, these
90
21
  will be overridden by parameters in the request
91
22
  -->
92
23
  <lst name="defaults">
93
- <str name="defType">dismax</str>
24
+ <str name="defType">edismax</str>
94
25
  <str name="echoParams">explicit</str>
95
26
  <str name="q.alt">*:*</str>
96
27
  <str name="mm">2&lt;-1 5&lt;-2 6&lt;90%</str>
28
+ <int name="qs">1</int>
29
+ <int name="ps">2</int>
30
+ <float name="tie">0.01</float>
97
31
  <!-- this qf and pf are used by default, if not otherwise specified by
98
32
  client. The default blacklight_config will use these for the
99
33
  "keywords" search. See the author_qf/author_pf, title_qf, etc
@@ -103,93 +37,37 @@
103
37
  -->
104
38
  <str name="qf">
105
39
  id
106
- title_t^25000
107
- text
108
- active_fedora_model_s
109
- object_type_facet
40
+ all_text_timv
41
+ active_fedora_model_ssi
42
+ object_type_si
110
43
  </str>
111
44
  <str name="pf">
112
- id
113
- title_t^250000
114
- text^10
115
- active_fedora_model_s
116
- object_type_facet
45
+ all_text_timv^10
117
46
  </str>
118
47
 
119
48
  <str name="author_qf">
120
- author_unstem_search^200
121
- author_addl_unstem_search^50
122
- author_t^20
123
- author_addl_t
124
49
  </str>
125
50
  <str name="author_pf">
126
- author_unstem_search^2000
127
- author_addl_unstem_search^500
128
- author_t^200
129
- author_addl_t^10
130
51
  </str>
131
52
  <str name="title_qf">
132
- title_unstem_search^50000
133
- subtitle_unstem_search^25000
134
- title_addl_unstem_search^10000
135
- title_t^5000
136
- subtitle_t^2500
137
- title_addl_t^100
138
- title_added_entry_unstem_search^50
139
- title_added_entry_t^10
140
- title_series_unstem_search^5
141
- title_series_t
142
53
  </str>
143
54
  <str name="title_pf">
144
- title_unstem_search^500000
145
- subtitle_unstem_search^250000
146
- title_addl_unstem_search^100000
147
- title_t^50000
148
- subtitle_t^25000
149
- title_addl_t^1000
150
- title_added_entry_unstem_search^500
151
- title_added_entry_t^100
152
- title_series_t^50
153
- title_series_unstem_search^10
154
55
  </str>
155
56
  <str name="subject_qf">
156
- subject_topic_unstem_search^200
157
- subject_unstem_search^125
158
- subject_topic_facet^100
159
- subject_t^50
160
- subject_addl_unstem_search^10
161
- subject_addl_t
162
57
  </str>
163
58
  <str name="subject_pf">
164
- subject_topic_unstem_search^2000
165
- subject_unstem_search^1250
166
- subject_t^1000
167
- subject_topic_facet^500
168
- subject_addl_unstem_search^100
169
- subject_addl_t^10
170
59
  </str>
171
60
 
172
- <int name="ps">3</int>
173
- <float name="tie">0.01</float>
174
-
175
- <!-- NOT using marc_display because it is large and will slow things down for search results -->
176
61
  <str name="fl">
177
62
  *,
178
- score,
63
+ score
179
64
  </str>
180
65
 
181
66
  <str name="facet">true</str>
182
67
  <str name="facet.mincount">1</str>
183
68
  <str name="facet.limit">10</str>
184
- <str name="facet.field">format</str>
185
- <str name="facet.field">lc_1letter_facet</str>
186
- <str name="facet.field">lc_alpha_facet</str>
187
- <str name="facet.field">lc_b4cutter_facet</str>
188
- <str name="facet.field">language_facet</str>
189
- <str name="facet.field">pub_date</str>
190
- <str name="facet.field">subject_era_facet</str>
191
- <str name="facet.field">subject_geo_facet</str>
192
- <str name="facet.field">subject_topic_facet</str>
69
+ <str name="facet.field">active_fedora_model_ssi</str>
70
+ <str name="facet.field">object_type_si</str>
193
71
 
194
72
  <str name="spellcheck">true</str>
195
73
  <str name="spellcheck.dictionary">default</str>
@@ -202,16 +80,6 @@
202
80
  <arr name="last-components">
203
81
  <str>spellcheck</str>
204
82
  </arr>
205
-
206
- </requestHandler>
207
-
208
-
209
- <!-- Hydra Additions Start -->
210
-
211
- <requestHandler name="standard" class="solr.SearchHandler">
212
- <lst name="defaults">
213
- <str name="echoParams">explicit</str>
214
- </lst>
215
83
  </requestHandler>
216
84
 
217
85
  <requestHandler name="permissions" class="solr.SearchHandler" >
@@ -221,22 +89,28 @@
221
89
  <str name="rows">1</str>
222
90
  <str name="q">{!raw f=id v=$id}</str> <!-- use id=666 instead of q=id:666 -->
223
91
  <str name="fl">
224
- id,access_t,
225
- discover_access_group_t,discover_access_person_t,
226
- read_access_group_t,read_access_person_t,
227
- edit_access_group_t,edit_access_person_t,
228
- depositor_t,
229
- embargo_release_date_dt,
230
- inheritable_access_t,
231
- inheritable_discover_access_group_t,inheritable_discover_access_person_t,
232
- inheritable_read_access_group_t,inheritable_read_access_person_t,
233
- inheritable_edit_access_group_t,inheritable_edit_access_person_t,
234
- inheritable_embargo_release_date_dt
92
+ id,
93
+ access_ssim,
94
+ discover_access_group_ssim,discover_access_person_ssim,
95
+ read_access_group_ssim,read_access_person_ssim,
96
+ edit_access_group_ssim,edit_access_person_ssim,
97
+ depositor_ti,
98
+ embargo_release_date_dtsi
99
+ inheritable_access_ssim,
100
+ inheritable_discover_access_group_ssim,inheritable_discover_access_person_ssim,
101
+ inheritable_read_access_group_ssim,inheritable_read_access_person_ssim,
102
+ inheritable_edit_access_group_ssim,inheritable_edit_access_person_ssim,
103
+ inheritable_embargo_release_date_dtsi
235
104
  </str>
236
105
  </lst>
237
106
  </requestHandler>
238
-
239
- <!-- Hydra Additions End -->
107
+
108
+ <requestHandler name="standard" class="solr.SearchHandler">
109
+ <lst name="defaults">
110
+ <str name="echoParams">explicit</str>
111
+ <str name="defType">lucene</str>
112
+ </lst>
113
+ </requestHandler>
240
114
 
241
115
  <!-- for requests to get a single document; use id=666 instead of q=id:666 -->
242
116
  <requestHandler name="document" class="solr.SearchHandler" >
@@ -249,24 +123,10 @@
249
123
  </requestHandler>
250
124
 
251
125
 
252
-
253
- <!-- Spell Check
254
-
255
- The spell check component can return a list of alternative spelling
256
- suggestions.
257
-
258
- http://wiki.apache.org/solr/SpellCheckComponent
259
- -->
260
126
  <searchComponent name="spellcheck" class="solr.SpellCheckComponent">
261
-
262
127
  <str name="queryAnalyzerFieldType">textSpell</str>
263
-
264
- <!-- Multiple "Spell Checkers" can be declared and used by this
265
- component
266
- -->
267
-
268
- <!-- a spellchecker built from a field of the main index, and
269
- written to disk
128
+ <!-- Multiple "Spell Checkers" can be declared and used by this component
129
+ (e.g. for title_spell field)
270
130
  -->
271
131
  <lst name="spellchecker">
272
132
  <str name="name">default</str>
@@ -274,26 +134,30 @@
274
134
  <str name="spellcheckIndexDir">./spell</str>
275
135
  <str name="buildOnOptimize">true</str>
276
136
  </lst>
277
- <lst name="spellchecker">
278
- <str name="name">author</str>
279
- <str name="field">author_spell</str>
280
- <str name="spellcheckIndexDir">./spell_author</str>
281
- <str name="accuracy">0.7</str>
282
- <str name="buildOnOptimize">true</str>
283
- </lst>
284
- <lst name="spellchecker">
285
- <str name="name">subject</str>
286
- <str name="field">subject_spell</str>
287
- <str name="spellcheckIndexDir">./spell_subject</str>
288
- <str name="accuracy">0.7</str>
289
- <str name="buildOnOptimize">true</str>
137
+ </searchComponent>
138
+
139
+ <requestHandler name="/replication" class="solr.ReplicationHandler" startup="lazy" />
140
+
141
+ <requestDispatcher handleSelect="true" >
142
+ <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048" />
143
+ </requestDispatcher>
144
+
145
+ <requestHandler name="/analysis/field" startup="lazy" class="solr.FieldAnalysisRequestHandler" />
146
+ <requestHandler name="/update" class="solr.UpdateRequestHandler" />
147
+ <requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
148
+
149
+ <requestHandler name="/admin/ping" class="solr.PingRequestHandler">
150
+ <lst name="invariants">
151
+ <str name="q">solrpingquery</str>
290
152
  </lst>
291
- <lst name="spellchecker">
292
- <str name="name">title</str>
293
- <str name="field">title_spell</str>
294
- <str name="spellcheckIndexDir">./spell_title</str>
295
- <str name="accuracy">0.7</str>
296
- <str name="buildOnOptimize">true</str>
153
+ <lst name="defaults">
154
+ <str name="echoParams">all</str>
297
155
  </lst>
298
- </searchComponent>
156
+ </requestHandler>
157
+
158
+ <!-- config for the admin interface -->
159
+ <admin>
160
+ <defaultQuery>search</defaultQuery>
161
+ </admin>
162
+
299
163
  </config>
@@ -46,7 +46,7 @@ describe BatchController do
46
46
  ability.can?(:edit, @file).should be_true
47
47
  ability.can?(:edit, @file2).should be_false
48
48
  end
49
- it "should equeue a batch update job" do
49
+ it "should enqueue a batch update job" do
50
50
  params = {'generic_file' => {'read_groups_string' => '', 'read_users_string' => 'archivist1, archivist2', 'tag' => ['']}, 'id' => @batch.pid, 'controller' => 'batch', 'action' => 'update'}
51
51
  s1 = stub('one')
52
52
  BatchUpdateJob.should_receive(:new).with(@user.user_key, params).and_return(s1)
@@ -129,7 +129,6 @@ describe BatchController do
129
129
  @file2 = GenericFile.new(:batch=>@b1, :label=>'f2')
130
130
  @file2.apply_depositor_metadata(@user.user_key)
131
131
  @file2.save
132
- controller.stub(:params).and_return({id:@b1.id})
133
132
  end
134
133
  after do
135
134
  @b1.delete
@@ -137,9 +136,9 @@ describe BatchController do
137
136
  @file2.delete
138
137
  end
139
138
  it "should default creator" do
140
- controller.edit
141
- controller.instance_variable_get(:@generic_file).creator[0].should == @user.display_name
142
- controller.instance_variable_get(:@generic_file).title[0].should == 'f1'
139
+ get :edit, id: @b1.id
140
+ assigns[:generic_file].creator[0].should == @user.display_name
141
+ assigns[:generic_file].title[0].should == 'f1'
143
142
  end
144
143
  end
145
144
  end
@@ -46,15 +46,16 @@ describe CatalogController do
46
46
  it "should find pdf files" do
47
47
  response.should be_success
48
48
  response.should render_template('catalog/index')
49
- assigns(:document_list).map(&:id) == [@gf1.id]
49
+ assigns(:document_list).map(&:id).should == [@gf1.id]
50
50
 
51
51
  assigns(:document_list).count.should eql(1)
52
- assigns(:document_list)[0].fetch(:desc_metadata__title_t)[0].should eql('Test Document PDF')
52
+ assigns(:document_list).first['desc_metadata__title_tesim'].should == ['Test Document PDF']
53
53
  end
54
54
  end
55
55
  describe "facet search" do
56
56
  before do
57
- xhr :get, :index, :q=>"{f=desc_metadata__contributor_facet}Contrib1"
57
+ # TODO: this is not how a facet query is done.
58
+ xhr :get, :index, :q=>"{f=desc_metadata__contributor_tesim}Contrib1"
58
59
  end
59
60
  it "should find facet files" do
60
61
  response.should be_success
@@ -97,16 +98,15 @@ describe CatalogController do
97
98
  assigns(:recent_documents).count.should eql(4)
98
99
  # the order is reversed since the first in should be the last out in descending time order
99
100
  #assigns(:recent_documents).each {|doc| logger.info doc.fetch(:desc_metadata__title_t)[0]}
100
- lgf4 = assigns(:recent_documents)[0]
101
- lgf3 = assigns(:recent_documents)[1]
102
- lgf2 = assigns(:recent_documents)[2]
103
- lgf1 = assigns(:recent_documents)[3]
104
- lgf4.fetch(:desc_metadata__title_t)[0].should eql(@gf4.title[0])
105
- lgf4.fetch(:desc_metadata__contributor_t)[0].should eql(@gf4.contributor[0])
106
- lgf4.fetch(:desc_metadata__resource_type_t)[0].should eql(@gf4.resource_type[0])
107
- lgf1.fetch(:desc_metadata__title_t)[0].should eql(@gf1.title[0])
108
- lgf1.fetch(:desc_metadata__contributor_t)[0].should eql(@gf1.contributor[0])
109
- lgf1.fetch(:desc_metadata__resource_type_t)[0].should eql(@gf1.resource_type[0])
101
+ lgf1 = assigns(:recent_documents)[0]
102
+ lgf4 = assigns(:recent_documents)[3]
103
+ lgf4['desc_metadata__title_tesim'].should == ['Generic File 4']
104
+ lgf4['desc_metadata__contributor_tesim'].should == ['contributor 4']
105
+ lgf4['desc_metadata__resource_type_tesim'].should == ['type 4']
106
+
107
+ lgf1['desc_metadata__title_tesim'].should == ['Generic File 1']
108
+ lgf1['desc_metadata__contributor_tesim'].should == ['contributor 1']
109
+ lgf1['desc_metadata__resource_type_tesim'].should == ['type 1']
110
110
  end
111
111
  end
112
112
  end
@@ -69,8 +69,8 @@ describe DashboardController do
69
69
  response.should render_template('dashboard/index')
70
70
  end
71
71
  it "should return an array of documents I can edit" do
72
- @user_results = Blacklight.solr.get "select", :params=>{:fq=>["edit_access_group_t:public OR edit_access_person_t:#{@user.user_key}"]}
73
- assigns(:document_list).count.should eql(@user_results["response"]["numFound"])
72
+ user_results = Blacklight.solr.get "select", :params=>{:fq=>["edit_access_group_ssim:public OR edit_access_person_ssim:#{@user.user_key}"]}
73
+ assigns(:document_list).count.should eql(user_results["response"]["numFound"])
74
74
  end
75
75
  end
76
76
  end
@@ -16,83 +16,95 @@ require 'spec_helper'
16
16
 
17
17
  describe DownloadsController do
18
18
 
19
- before(:all) do
20
- GenericFile.any_instance.stub(:terms_of_service).and_return('1')
21
- f = GenericFile.new(:pid => 'sufia:test1')
22
- f.apply_depositor_metadata('archivist1@example.com')
23
- f.set_title_and_label('world.png')
24
- f.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content', :mimeType => 'image/png')
25
- f.should_receive(:characterize_if_changed).and_yield
26
- f.save
27
- end
28
-
29
- after(:all) do
30
- GenericFile.find('sufia:test1').delete
31
- end
32
-
33
19
  describe "routing" do
34
20
  it "should route" do
35
21
  assert_recognizes( {:controller=>"downloads", :action=>"show", "id"=>"test1"}, "/downloads/test1?filename=my%20dog.jpg" )
36
22
  end
37
23
  end
38
24
 
39
- describe "when logged in as reader" do
25
+ describe "default_datastream?" do
26
+ it "should be true when no datastram_id is passed" do
27
+ controller.should be_default_datastream
28
+ end
29
+ it "should be false when a datastream_id is passed" do
30
+ controller.params[:datastream_id] = 'descMetadata'
31
+ controller.should_not be_default_datastream
32
+ end
33
+ end
34
+
35
+
36
+ describe "with a file" do
40
37
  before do
41
- sign_in FactoryGirl.find_or_create(:archivist)
42
- User.any_instance.stub(:groups).and_return([])
43
- controller.stub(:clear_session_user) ## Don't clear out the authenticated session
38
+ @f = GenericFile.new(:pid => 'sufia:test1')
39
+ @f.apply_depositor_metadata('archivist1@example.com')
40
+ @f.set_title_and_label('world.png')
41
+ @f.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content', :mimeType => 'image/png')
42
+ @f.should_receive(:characterize_if_changed).and_yield
43
+ @f.save!
44
44
  end
45
+
45
46
  after do
46
- arch = FactoryGirl.find(:archivist) rescue
47
- arch.delete if arch
47
+ @f.delete
48
48
  end
49
- describe "show" do
50
- it "should default to returning configured default download" do
51
- DownloadsController.default_content_dsid.should == "content"
52
- controller.stub(:render)
53
- expected_content = ActiveFedora::Base.find("sufia:test1").content.content
54
- controller.should_receive(:send_data).with(expected_content, {:filename => 'world.png', :disposition => 'inline', :type => 'image/png' })
55
- get "show", :id => "test1"
56
- response.should be_success
57
- end
58
- it "should return requested datastreams" do
59
- controller.stub(:render)
60
- expected_content = ActiveFedora::Base.find("sufia:test1").descMetadata.content
61
- controller.should_receive(:send_data).with(expected_content, {:filename => 'descMetadata', :disposition => 'inline', :type => "text/plain"})
62
- get "show", :id => "test1", :datastream_id => "descMetadata"
63
- response.should be_success
49
+
50
+ describe "when logged in as reader" do
51
+ before do
52
+ sign_in FactoryGirl.find_or_create(:archivist)
53
+ User.any_instance.stub(:groups).and_return([])
54
+ controller.stub(:clear_session_user) ## Don't clear out the authenticated session
64
55
  end
65
- it "should support setting disposition to inline" do
66
- controller.stub(:render)
67
- expected_content = ActiveFedora::Base.find("sufia:test1").content.content
68
- controller.should_receive(:send_data).with(expected_content, {:filename => 'world.png', :type => 'image/png', :disposition => "inline"})
69
- get "show", :id => "test1", :disposition => "inline"
70
- response.should be_success
56
+ after do
57
+ arch = FactoryGirl.find(:archivist) rescue
58
+ arch.delete if arch
71
59
  end
72
- it "should allow you to specify filename for download" do
73
- controller.stub(:render)
74
- expected_content = ActiveFedora::Base.find("sufia:test1").content.content
75
- controller.should_receive(:send_data).with(expected_content, {:filename => "my%20dog.png", :disposition => 'inline', :type => 'image/png'})
76
- get "show", :id => "test1", "filename" => "my%20dog.png"
60
+ describe "show" do
61
+ it "should default to returning configured default download" do
62
+ DownloadsController.default_content_dsid.should == "content"
63
+ controller.stub(:render) # send_data calls render internally
64
+ expected_content = ActiveFedora::Base.find("sufia:test1").content.content
65
+ controller.should_receive(:send_data).with(expected_content, {:filename => 'world.png', :disposition => 'inline', :type => 'image/png' })
66
+ get "show", :id => "test1"
67
+ response.should be_success
68
+ end
69
+ it "should return requested datastreams" do
70
+ controller.stub(:render) # send_data calls render internally
71
+ expected_content = ActiveFedora::Base.find("sufia:test1").descMetadata.content
72
+ controller.should_receive(:send_data).with(expected_content, {:filename=>"descMetadata", :disposition=>"inline", :type=>"text/plain"})
73
+ get "show", :id => "test1", :datastream_id => "descMetadata"
74
+ response.should be_success
75
+ end
76
+ it "should support setting disposition to inline" do
77
+ controller.stub(:render) # send_data calls render internally
78
+ expected_content = ActiveFedora::Base.find("sufia:test1").content.content
79
+ controller.should_receive(:send_data).with(expected_content, {:filename => 'world.png', :type => 'image/png', :disposition => "inline"})
80
+ get "show", :id => "test1", :disposition => "inline"
81
+ response.should be_success
82
+ end
83
+ it "should allow you to specify filename for download" do
84
+ controller.stub(:render) # send_data calls render internally
85
+ expected_content = ActiveFedora::Base.find("sufia:test1").content.content
86
+ controller.should_receive(:send_data).with(expected_content, {:filename => "my%20dog.png", :disposition => 'inline', :type => 'image/png'})
87
+ get "show", :id => "test1", "filename" => "my%20dog.png"
88
+ end
77
89
  end
78
90
  end
79
- end
80
91
 
81
- describe "when not logged in as reader" do
82
- before do
83
- sign_in FactoryGirl.find_or_create(:user)
84
- User.any_instance.stub(:groups).and_return([])
85
- controller.stub(:clear_session_user) ## Don't clear out the authenticated session
86
- end
87
- after do
88
- user = FactoryGirl.find(:user) rescue
89
- user.delete if user
90
- end
91
-
92
- describe "show" do
93
- it "should deny access" do
94
- get "show", :id => "test1"
95
- response.should redirect_to("/assets/NoAccess.png")
92
+ describe "when not logged in as reader" do
93
+ before do
94
+ sign_in FactoryGirl.find_or_create(:user)
95
+ User.any_instance.stub(:groups).and_return([])
96
+ controller.stub(:clear_session_user) ## Don't clear out the authenticated session
97
+ end
98
+ after do
99
+ user = FactoryGirl.find(:user) rescue
100
+ user.delete if user
101
+ end
102
+
103
+ describe "show" do
104
+ it "should deny access" do
105
+ get "show", :id => "test1"
106
+ response.should redirect_to("/assets/NoAccess.png")
107
+ end
96
108
  end
97
109
  end
98
110
  end