sufia 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Gemfile +1 -1
  4. data/History.md +77 -0
  5. data/README.md +26 -11
  6. data/SUFIA_VERSION +1 -1
  7. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +4 -3
  8. data/app/helpers/sufia_helper.rb +7 -5
  9. data/app/jobs/ingest_local_file_job.rb +34 -0
  10. data/app/views/catalog/_facet_selected.html.erb +1 -1
  11. data/app/views/generic_files/_local_file_import.html.erb +3 -0
  12. data/app/views/generic_files/new.html.erb +10 -0
  13. data/app/views/generic_files/upload/_alerts.html.erb +2 -2
  14. data/app/views/generic_files/upload/_local_file_import_chooser.html.erb +27 -0
  15. data/app/views/generic_files/upload/_script_templates.html.erb +1 -1
  16. data/lib/generators/sufia/sufia_generator.rb +1 -0
  17. data/lib/generators/sufia/templates/config/resque_config.rb +3 -20
  18. data/lib/sufia/files_controller/local_ingest_behavior.rb +54 -0
  19. data/lib/sufia/files_controller/upload_complete_behavior.rb +7 -0
  20. data/lib/sufia/files_controller_behavior.rb +31 -11
  21. data/lib/sufia/version.rb +1 -1
  22. data/spec/active_fedora/unsaved_digital_object_spec.rb +1 -1
  23. data/spec/controllers/authorities_controller_spec.rb +1 -1
  24. data/spec/controllers/batch_controller_spec.rb +4 -4
  25. data/spec/controllers/batch_edits_controller_spec.rb +1 -1
  26. data/spec/controllers/catalog_controller_spec.rb +1 -1
  27. data/spec/controllers/dashboard_controller_spec.rb +2 -2
  28. data/spec/controllers/downloads_controller_spec.rb +2 -3
  29. data/spec/controllers/generic_files_controller_spec.rb +113 -31
  30. data/spec/controllers/mailbox_controller_spec.rb +1 -1
  31. data/spec/controllers/single_use_link_controller_spec.rb +4 -5
  32. data/spec/controllers/users_controller_spec.rb +3 -3
  33. data/spec/features/browse_dashboard_files.rb +1 -1
  34. data/spec/features/browse_files.rb +1 -1
  35. data/spec/features/contact_form.rb +1 -1
  36. data/spec/features/display_dashboard.rb +1 -1
  37. data/spec/features/ingest_upload_files.rb +1 -1
  38. data/spec/features/users_spec.rb +1 -1
  39. data/spec/helpers/generic_file_helper_spec.rb +1 -1
  40. data/spec/helpers/render_constraints_helper_behavior_spec.rb +42 -0
  41. data/spec/helpers/sufia_helper_spec.rb +40 -1
  42. data/spec/jobs/import_url_job_spec.rb +45 -0
  43. data/spec/jobs/ingest_local_file_job_spec.rb +35 -0
  44. data/spec/lib/sufia/id_service_spec.rb +1 -1
  45. data/spec/lib/sufia/upload_complete_behavior_spec.rb +26 -0
  46. data/spec/models/audit_job_spec.rb +2 -2
  47. data/spec/models/batch_spec.rb +1 -1
  48. data/spec/models/batch_update_job_spec.rb +2 -4
  49. data/spec/models/characterize_job_spec.rb +17 -14
  50. data/spec/models/checksum_audit_log_spec.rb +2 -2
  51. data/spec/models/event_jobs_spec.rb +2 -2
  52. data/spec/models/file_content_datastream_spec.rb +5 -5
  53. data/spec/models/fits_datastream_spec.rb +2 -2
  54. data/spec/models/generic_file/actions_spec.rb +25 -0
  55. data/spec/models/generic_file/web_form_spec.rb +1 -1
  56. data/spec/models/generic_file_spec.rb +16 -33
  57. data/spec/models/local_authority_spec.rb +1 -1
  58. data/spec/models/properties_datastream_spec.rb +1 -1
  59. data/spec/models/single_use_link_spec.rb +1 -1
  60. data/spec/models/solr_document_spec.rb +1 -1
  61. data/spec/models/transcode_audio_job_spec.rb +22 -18
  62. data/spec/models/transcode_video_job_spec.rb +4 -3
  63. data/spec/models/trophy_spec.rb +1 -1
  64. data/spec/models/unzip_job_spec.rb +2 -2
  65. data/spec/models/user_spec.rb +1 -1
  66. data/spec/rake/sufia_fixtures_spec.rb +1 -1
  67. data/spec/routing/route_spec.rb +1 -1
  68. data/spec/spec_helper.rb +2 -2
  69. data/spec/views/batch_edits/check_all_spec.rb +1 -1
  70. data/sufia-models/app/models/datastreams/file_content_datastream.rb +1 -15
  71. data/sufia-models/app/models/geo_names_resource.rb +0 -2
  72. data/sufia-models/lib/sufia/models.rb +1 -1
  73. data/sufia-models/lib/sufia/models/engine.rb +12 -1
  74. data/sufia-models/lib/sufia/models/file_content.rb +0 -3
  75. data/sufia-models/lib/sufia/models/generic_file.rb +6 -10
  76. data/sufia-models/lib/sufia/models/generic_file/actions.rb +1 -1
  77. data/sufia-models/lib/sufia/models/generic_file/characterization.rb +1 -1
  78. data/sufia-models/lib/sufia/models/generic_file/derivatives.rb +31 -0
  79. data/sufia-models/lib/sufia/models/generic_file/mime_types.rb +27 -0
  80. data/sufia-models/lib/sufia/models/generic_file/thumbnail.rb +6 -60
  81. data/sufia-models/lib/sufia/models/jobs/active_fedora_pid_based_job.rb +19 -0
  82. data/sufia-models/lib/sufia/models/jobs/audit_job.rb +12 -8
  83. data/sufia-models/lib/sufia/models/jobs/characterize_job.rb +3 -10
  84. data/sufia-models/lib/sufia/models/jobs/import_url_job.rb +2 -9
  85. data/sufia-models/lib/sufia/models/jobs/resolrize_job.rb +8 -1
  86. data/sufia-models/lib/sufia/models/jobs/transcode_audio_job.rb +4 -28
  87. data/sufia-models/lib/sufia/models/jobs/transcode_video_job.rb +4 -28
  88. data/sufia-models/lib/sufia/models/jobs/unzip_job.rb +5 -19
  89. data/sufia-models/lib/sufia/models/model_methods.rb +2 -16
  90. data/sufia-models/lib/sufia/models/user_local_directory_behavior.rb +29 -0
  91. data/sufia-models/lib/sufia/models/version.rb +1 -1
  92. data/sufia-models/sufia-models.gemspec +1 -1
  93. data/sufia.gemspec +2 -1
  94. data/tasks/sufia-dev.rake +1 -1
  95. metadata +26 -10
  96. data/app/assets/stylesheets/jquery-ui-1.8.1.custom.css +0 -486
  97. data/app/assets/stylesheets/jquery-ui-1.8.23.custom.css +0 -340
  98. data/sufia-models/lib/sufia/models/file_content/extract_metadata.rb +0 -60
  99. data/sufia-models/lib/sufia/models/jobs/ffmpeg_transcode_job.rb +0 -61
@@ -1,3 +1,3 @@
1
1
  module Sufia
2
- VERSION = "3.0.0"
2
+ VERSION = "3.1.0"
3
3
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::UnsavedDigitalObject do
4
4
  it "should have an ARK-style pid" do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe AuthoritiesController do
4
4
  describe "#query" do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe BatchController do
4
4
  before do
@@ -16,7 +16,7 @@ describe BatchController do
16
16
  @batch = Batch.new
17
17
  @batch.save
18
18
  @file = GenericFile.new(:batch=>@batch)
19
- @file.apply_depositor_metadata(@user.user_key)
19
+ @file.apply_depositor_metadata(@user)
20
20
  @file.save
21
21
  @file2 = GenericFile.new(:batch=>@batch)
22
22
  @file2.apply_depositor_metadata('otherUser')
@@ -118,10 +118,10 @@ describe BatchController do
118
118
  @b1 = Batch.new
119
119
  @b1.save
120
120
  @file = GenericFile.new(:batch=>@b1, :label=>'f1')
121
- @file.apply_depositor_metadata(@user.user_key)
121
+ @file.apply_depositor_metadata(@user)
122
122
  @file.save
123
123
  @file2 = GenericFile.new(:batch=>@b1, :label=>'f2')
124
- @file2.apply_depositor_metadata(@user.user_key)
124
+ @file2.apply_depositor_metadata(@user)
125
125
  @file2.save
126
126
  end
127
127
  after do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe BatchEditsController do
4
4
  before do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe CatalogController do
4
4
  before do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe DashboardController do
4
4
  before do
@@ -54,7 +54,7 @@ describe DashboardController do
54
54
  files_count = assigns(:document_list).count
55
55
  until files_count == 3
56
56
  gf = GenericFile.new()
57
- gf.apply_depositor_metadata(@user.user_key)
57
+ gf.apply_depositor_metadata(@user)
58
58
  gf.save
59
59
  files_count += 1
60
60
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe DownloadsController do
4
4
 
@@ -6,8 +6,7 @@ describe DownloadsController do
6
6
  before do
7
7
  @f = GenericFile.new(:pid => 'sufia:test1')
8
8
  @f.apply_depositor_metadata('archivist1@example.com')
9
- @f.set_title_and_label('world.png')
10
- @f.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content', :mimeType => 'image/png')
9
+ @f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
11
10
  @f.should_receive(:characterize_if_changed).and_yield
12
11
  @f.save!
13
12
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe GenericFilesController do
4
4
  before do
@@ -16,6 +16,7 @@ describe GenericFilesController do
16
16
  GenericFile.stub(:new).and_return(@mock)
17
17
  end
18
18
  after do
19
+ GenericFile.unstub(:new)
19
20
  begin
20
21
  Batch.find("sample:batch_id").delete
21
22
  rescue
@@ -30,6 +31,8 @@ describe GenericFilesController do
30
31
  JSON.parse(response.body).first['error'].should match(/no file for upload/i)
31
32
  end
32
33
 
34
+
35
+
33
36
  it "should spawn a content deposit event job" do
34
37
  file = fixture_file_upload('/world.png','image/png')
35
38
  s1 = double('one')
@@ -60,6 +63,7 @@ describe GenericFilesController do
60
63
  end
61
64
 
62
65
  it "should download and import a file from a given url" do
66
+ pending "This is just downloading a 401 error page"
63
67
  date_today = Date.today
64
68
  Date.stub(:today).and_return(date_today)
65
69
  generic_file = GenericFile.new #find(self.pid)
@@ -168,30 +172,7 @@ describe GenericFilesController do
168
172
  Sufia.queue.should_receive(:push).with(s2).once
169
173
  xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service=>"1"
170
174
  end
171
-
172
- describe "#virus_check" do
173
- before do
174
- unless defined? ClamAV
175
- class ClamAV
176
- def self.instance
177
- new
178
- end
179
- end
180
- @stubbed_clamav = true
181
- end
182
- end
183
- after do
184
- Object.send(:remove_const, :ClamAV) if @stubbed_clamav
185
- end
186
- it "failing virus check should create flash" do
187
- GenericFile.any_instance.stub(:to_solr).and_return({})
188
- ClamAV.any_instance.should_receive(:scanfile).and_return(1)
189
- file = fixture_file_upload('/world.png','image/png')
190
- controller.send :virus_check, file
191
- flash[:error].should_not be_empty
192
- end
193
- end
194
-
175
+
195
176
  it "should error out of create and save after on continuos rsolr error" do
196
177
  GenericFile.any_instance.stub(:save).and_raise(RSolr::Error::Http.new({},{}))
197
178
 
@@ -199,14 +180,116 @@ describe GenericFilesController do
199
180
  xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service=>"1"
200
181
  response.body.should include("Error occurred while creating generic file.")
201
182
  end
202
-
183
+ end
184
+
185
+ describe "#create with local_file" do
186
+ let (:mock_url) {"http://example.com"}
187
+ before do
188
+ Sufia.config.enable_local_ingest = true
189
+ GenericFile.delete_all
190
+ @mock_upload_directory = 'spec/mock_upload_directory'
191
+ # Dir.mkdir @mock_upload_directory unless File.exists? @mock_upload_directory
192
+ FileUtils.mkdir_p([File.join(@mock_upload_directory, "import/files"),File.join(@mock_upload_directory, "import/metadata")])
193
+ FileUtils.copy(File.expand_path('../../fixtures/world.png', __FILE__), @mock_upload_directory)
194
+ FileUtils.copy(File.expand_path('../../fixtures/image.jp2', __FILE__), @mock_upload_directory)
195
+ FileUtils.copy(File.expand_path('../../fixtures/dublin_core_rdf_descMetadata.nt', __FILE__), File.join(@mock_upload_directory, "import/metadata"))
196
+ FileUtils.copy(File.expand_path('../../fixtures/icons.zip', __FILE__), File.join(@mock_upload_directory, "import/files"))
197
+ FileUtils.copy(File.expand_path('../../fixtures/Example.ogg', __FILE__), File.join(@mock_upload_directory, "import/files"))
198
+ end
199
+ after do
200
+ Sufia.config.enable_local_ingest = false
201
+ FileContentDatastream.any_instance.stub(:live?).and_return(true)
202
+ GenericFile.destroy_all
203
+ end
204
+ context "when User model defines a directory path" do
205
+ before do
206
+ User.any_instance.stub(:directory).and_return(@mock_upload_directory)
207
+ end
208
+ it "should ingest files from the filesystem" do
209
+ if $in_travis
210
+ # This is in place because we stub fits for travis, and the stub sets the mime to application/pdf.
211
+ # In order to avoid an invalid derivative creation, just stub out the derivatives.
212
+ GenericFile.any_instance.stub(:create_derivatives)
213
+ end
214
+ lambda { post :create, local_file: ["world.png", "image.jp2"], batch_id: "xw42n7934"}.should change(GenericFile, :count).by(2)
215
+ response.should redirect_to Sufia::Engine.routes.url_helpers.batch_edit_path('xw42n7934')
216
+ # These files should have been moved out of the upload directory
217
+ File.exist?("#{@mock_upload_directory}/image.jp2").should be_false
218
+ File.exist?("#{@mock_upload_directory}/world.png").should be_false
219
+ # And into the storage directory
220
+ files = GenericFile.find(Solrizer.solr_name("is_part_of",:symbol) => 'info:fedora/sufia:xw42n7934')
221
+ files.first.label.should == 'world.png'
222
+ files.last.label.should == 'image.jp2'
223
+ end
224
+ it "should ingest redirect to another location" do
225
+ if $in_travis
226
+ # This is in place because we stub fits for travis, and the stub sets the mime to application/pdf.
227
+ # In order to avoid an invalid derivative creation, just stub out the derivatives.
228
+ GenericFile.any_instance.stub(:create_derivatives)
229
+ end
230
+ GenericFilesController.should_receive(:upload_complete_path).and_return(mock_url)
231
+ lambda { post :create, local_file: ["world.png"], batch_id: "xw42n7934"}.should change(GenericFile, :count).by(1)
232
+ response.should redirect_to mock_url
233
+ # These files should have been moved out of the upload directory
234
+ File.exist?("#{@mock_upload_directory}/world.png").should be_false
235
+ # And into the storage directory
236
+ files = GenericFile.find(Solrizer.solr_name("is_part_of",:symbol) => 'info:fedora/sufia:xw42n7934')
237
+ files.first.label.should == 'world.png'
238
+ end
239
+ it "should ingest directories from the filesystem" do
240
+ #TODO this test is very slow because it kicks off CharacterizeJob.
241
+ if $in_travis
242
+ # This is in place because we stub fits for travis, and the stub sets the mime to application/pdf.
243
+ # In order to avoid an invalid derivative creation, just stub out the derivatives.
244
+ GenericFile.any_instance.stub(:create_derivatives)
245
+ end
246
+ lambda { post :create, local_file: ["world.png", "import"], batch_id: "xw42n7934"}.should change(GenericFile, :count).by(4)
247
+ response.should redirect_to Sufia::Engine.routes.url_helpers.batch_edit_path('xw42n7934')
248
+ # These files should have been moved out of the upload directory
249
+ File.exist?("#{@mock_upload_directory}/import/files/Example.ogg").should be_false
250
+ File.exist?("#{@mock_upload_directory}/import/files/icons.zip").should be_false
251
+ File.exist?("#{@mock_upload_directory}/import/metadata/dublin_core_rdf_descMetadata.nt").should be_false
252
+ File.exist?("#{@mock_upload_directory}/world.png").should be_false
253
+ # And into the storage directory
254
+ files = GenericFile.find(Solrizer.solr_name("is_part_of",:symbol) => 'info:fedora/sufia:xw42n7934')
255
+ files.first.label.should == 'world.png'
256
+ ['icons.zip', 'Example.ogg'].each do |filename|
257
+ files.select{|f| f.label == filename}.first.relative_path.should == "import/files/#{filename}"
258
+ end
259
+ files.select{|f| f.label == 'dublin_core_rdf_descMetadata.nt'}.first.relative_path.should == 'import/metadata/dublin_core_rdf_descMetadata.nt'
260
+ end
261
+ end
262
+ context "when User model does not define directory path" do
263
+ it "should return an error message and redirect to file upload page" do
264
+ lambda { post :create, local_file: ["world.png", "image.jp2"], batch_id: "xw42n7934"}.should_not change(GenericFile, :count)
265
+ response.should render_template :new
266
+ flash[:alert].should == 'Your account is not configured for importing files from a user-directory on the server.'
267
+ end
268
+ end
269
+ end
270
+
271
+ describe "#virus_check" do
272
+ it "passing virus check should not create flash error" do
273
+ GenericFile.any_instance.stub(:to_solr).and_return({})
274
+ file = fixture_file_upload('/world.png','image/png')
275
+ Sufia::GenericFile::Actions.should_receive(:virus_check).with(file).and_return(0)
276
+ controller.send :virus_check, file
277
+ flash[:error].should be_nil
278
+ end
279
+ it "failing virus check should create flash" do
280
+ GenericFile.any_instance.stub(:to_solr).and_return({})
281
+ file = fixture_file_upload('/world.png','image/png')
282
+ Sufia::GenericFile::Actions.should_receive(:virus_check).with(file).and_return(1)
283
+ controller.send :virus_check, file
284
+ flash[:error].should_not be_empty
285
+ end
203
286
  end
204
287
 
205
288
  describe "audit" do
206
289
  before do
207
290
  #GenericFile.any_instance.stub(:to_solr).and_return({})
208
291
  @generic_file = GenericFile.new
209
- @generic_file.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content')
292
+ @generic_file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
210
293
  @generic_file.apply_depositor_metadata('mjg36')
211
294
  @generic_file.save
212
295
  end
@@ -225,7 +308,7 @@ describe GenericFilesController do
225
308
  describe "destroy" do
226
309
  before(:each) do
227
310
  @generic_file = GenericFile.new
228
- @generic_file.apply_depositor_metadata(@user.user_key)
311
+ @generic_file.apply_depositor_metadata(@user)
229
312
  @generic_file.save
230
313
  @user = FactoryGirl.find_or_create(:user)
231
314
  sign_in @user
@@ -250,7 +333,7 @@ describe GenericFilesController do
250
333
  before do
251
334
  #controller.should_receive(:virus_check).and_return(0)
252
335
  @generic_file = GenericFile.new
253
- @generic_file.apply_depositor_metadata(@user.user_key)
336
+ @generic_file.apply_depositor_metadata(@user)
254
337
  @generic_file.save
255
338
  end
256
339
  after do
@@ -412,8 +495,7 @@ describe GenericFilesController do
412
495
  before do
413
496
  f = GenericFile.new(:pid => 'sufia:test5')
414
497
  f.apply_depositor_metadata('archivist1@example.com')
415
- f.set_title_and_label('world.png')
416
- f.add_file_datastream(File.new(fixture_path + '/world.png'))
498
+ f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
417
499
  # grant public read access explicitly
418
500
  f.read_groups = ['public']
419
501
  f.should_receive(:characterize_if_changed).and_yield
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe MailboxController do
4
4
  before(:each) do
@@ -1,15 +1,14 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe SingleUseLinkController do
4
4
  before(:all) do
5
5
  @user = FactoryGirl.find_or_create(:user)
6
6
  @file = GenericFile.new
7
- @file.set_title_and_label('world.png')
8
- @file.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content', :mimeType => 'image/png')
9
- @file.apply_depositor_metadata(@user.user_key)
7
+ @file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
8
+ @file.apply_depositor_metadata(@user)
10
9
  @file.save
11
10
  @file2 = GenericFile.new
12
- @file2.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content', :mimeType => 'image/png')
11
+ @file2.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
13
12
  @file2.apply_depositor_metadata('mjg36')
14
13
  @file2.save
15
14
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe UsersController do
4
4
  before(:each) do
@@ -127,7 +127,7 @@ describe UsersController do
127
127
  end
128
128
  it "should remove a trophy" do
129
129
  f = GenericFile.create(title:"myFile")
130
- f.apply_depositor_metadata(@user.user_key)
130
+ f.apply_depositor_metadata(@user)
131
131
  f.save
132
132
  file_id = f.pid.split(":").last
133
133
  Trophy.create(:generic_file_id => file_id, :user_id => @user.id)
@@ -197,7 +197,7 @@ describe UsersController do
197
197
  describe "#toggle_trophy" do
198
198
  before do
199
199
  @file = GenericFile.new()
200
- @file.apply_depositor_metadata(@user.user_key)
200
+ @file.apply_depositor_metadata(@user)
201
201
  @file.save
202
202
  @file_id = @file.pid.split(":").last
203
203
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe "Browse Dashboard files" do
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe "Browse files" do
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe "Sending an email via the contact form" do
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe "Display Dashboard files" do
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe "Uploading files via web form" do
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe "User Profile" do
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe GenericFileHelper do
4
4
  it "draws add button" do
@@ -0,0 +1,42 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Blacklight::RenderConstraintsHelperBehavior do
4
+
5
+ describe "render_filter_element" do
6
+ let(:blacklight_config) { Blacklight::Configuration.new }
7
+
8
+ before(:each) do
9
+ helper.stub(:blacklight_config).and_return blacklight_config
10
+ end
11
+
12
+
13
+ describe "render_selected_facet_value" do
14
+ it "be html_safe and not have the remove link" do
15
+ item = double("item", :value=>'two', :hits=>9)
16
+ ret_val = helper.render_filter_element("one", [item],{})
17
+ doc = Nokogiri::HTML(ret_val.first)
18
+ filter = doc.xpath("//span[@class='filterValue']")
19
+ filter.text.should == item.value
20
+ end
21
+ it "use facet_display_value" do
22
+ helper.stub(:facet_display_value).and_return('four')
23
+ item = double("item", :value=>'two', :hits=>9)
24
+ ret_val = helper.render_filter_element("one", [item],{})
25
+ doc = Nokogiri::HTML(ret_val.first)
26
+ filter = doc.xpath("//span[@class='filterValue']")
27
+ filter.text.should == 'four'
28
+ end
29
+ it "use facet_display_value for dashboard" do
30
+ params[:controller] = "dashboard"
31
+ helper.stub(:facet_display_value).and_return('four')
32
+ helper.stub(:dashboard_index_path).and_return("abc")
33
+ item = double("item", :value=>'two', :hits=>9)
34
+ ret_val = helper.render_filter_element("one", [item],{})
35
+ doc = Nokogiri::HTML(ret_val.first)
36
+ filter = doc.xpath("//span[@class='filterValue']")
37
+ filter.text.should == 'four'
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe SufiaHelper do
4
4
  describe "link_to_profile" do
@@ -9,4 +9,43 @@ describe SufiaHelper do
9
9
  helper.link_to_profile('justin@example.com').should == "<a href=\"/users/justin@example-dot-com\">justin@example.com</a>"
10
10
  end
11
11
  end
12
+
13
+ describe "selected facet" do
14
+ let(:blacklight_config) { Blacklight::Configuration.new }
15
+
16
+ before(:each) do
17
+ helper.stub(:blacklight_config).and_return blacklight_config
18
+ helper.stub(:url_for).and_return('http://example.com')
19
+ end
20
+
21
+
22
+ describe "render_selected_facet_value" do
23
+ it "be html_safe and not have the remove link" do
24
+ item = double("item", :value=>'two', :hits=>9)
25
+ ret_val = helper.render_facet_value("one", item)
26
+ doc = Nokogiri::HTML(ret_val)
27
+ filter = doc.xpath("//a[@class='facet_select']")
28
+ filter.text.should == item.value
29
+ ret_val.should be_html_safe
30
+ end
31
+ it "use facet_display_value" do
32
+ item = double("item", :value=>'two', :hits=>9)
33
+ helper.stub(:facet_display_value).and_return('four')
34
+ ret_val = helper.render_facet_value("one", item)
35
+ doc = Nokogiri::HTML(ret_val)
36
+ filter = doc.xpath("//a[@class='facet_select']")
37
+ filter.text.should == 'four'
38
+ end
39
+ it "use facet_display_value for dashboard" do
40
+ params[:controller] = "dashboard"
41
+ item = double("item", :value=>'two', :hits=>9)
42
+ helper.stub(:facet_display_value).and_return('four')
43
+ ret_val = helper.render_facet_value("one", item)
44
+ doc = Nokogiri::HTML(ret_val)
45
+ filter = doc.xpath("//a[@class='facet_select']")
46
+ filter.text.should == 'four'
47
+ end
48
+
49
+ end
50
+ end
12
51
  end