sufia 0.0.1.pre1 → 0.0.1.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. data/.gitignore +1 -2
  2. data/Gemfile +2 -1
  3. data/README.md +19 -15
  4. data/Rakefile +2 -0
  5. data/app/controllers/batch_controller.rb +2 -3
  6. data/app/controllers/contact_form_controller.rb +1 -0
  7. data/app/controllers/dashboard_controller.rb +2 -2
  8. data/app/controllers/generic_files_controller.rb +24 -12
  9. data/app/controllers/mailbox_controller.rb +2 -2
  10. data/app/controllers/single_use_link_controller.rb +5 -5
  11. data/app/controllers/users_controller.rb +10 -10
  12. data/app/helpers/{application_helper.rb → sufia_helper.rb} +5 -13
  13. data/app/models/audit_job.rb +3 -4
  14. data/app/models/batch.rb +2 -0
  15. data/app/models/batch_update_job.rb +4 -6
  16. data/app/models/checksum_audit_log.rb +2 -0
  17. data/app/models/contact_form.rb +2 -0
  18. data/app/models/content_delete_event_job.rb +1 -1
  19. data/app/models/content_deposit_event_job.rb +2 -2
  20. data/app/models/content_new_version_event_job.rb +2 -2
  21. data/app/models/content_restored_version_event_job.rb +2 -2
  22. data/app/models/content_update_event_job.rb +2 -2
  23. data/app/models/datastreams/properties_datastream.rb +1 -1
  24. data/app/models/domain_term.rb +1 -0
  25. data/app/models/event_job.rb +1 -1
  26. data/app/models/generic_file.rb +5 -4
  27. data/app/models/local_authority.rb +1 -0
  28. data/app/models/local_authority_entry.rb +1 -0
  29. data/app/models/single_use_link.rb +2 -2
  30. data/app/models/user_edit_profile_event_job.rb +1 -1
  31. data/app/models/user_follow_event_job.rb +2 -2
  32. data/app/models/user_unfollow_event_job.rb +2 -2
  33. data/app/models/version_committer.rb +1 -0
  34. data/app/views/_footer.html.erb +21 -0
  35. data/app/views/_logo.html.erb +3 -0
  36. data/app/views/_masthead.html.erb +38 -0
  37. data/app/views/_user_util_links.html.erb +14 -43
  38. data/app/views/catalog/_document_list.html.erb +0 -7
  39. data/app/views/catalog/_home_text.html.erb +4 -4
  40. data/app/views/catalog/_recent_document.html.erb +5 -5
  41. data/app/views/contact_form/_directions.html.erb +4 -0
  42. data/app/views/contact_form/new.html.erb +2 -4
  43. data/app/views/dashboard/_document_list.html.erb +1 -8
  44. data/app/views/dashboard/_facets.html.erb +1 -1
  45. data/app/views/dashboard/_index_partials/_list_files.html.erb +1 -1
  46. data/app/views/dashboard/_index_partials/_thumbnail_display.html.erb +6 -6
  47. data/app/views/dashboard/_search_form.html.erb +1 -1
  48. data/app/views/dashboard/index.html.erb +26 -25
  49. data/app/views/generic_files/_media_display.html.erb +5 -5
  50. data/app/views/generic_files/_permission.html.erb +11 -11
  51. data/app/views/generic_files/edit.html.erb +10 -8
  52. data/app/views/generic_files/show.html.erb +16 -12
  53. data/app/views/layouts/error.html.erb +2 -53
  54. data/app/views/layouts/hydra-head.html.erb +2 -21
  55. data/app/views/mailbox/index.html.erb +1 -1
  56. data/app/views/static/about.html.erb +2 -65
  57. data/app/views/static/help.html.erb +1 -721
  58. data/app/views/users/_search_form.html.erb +1 -1
  59. data/app/views/users/edit.html.erb +6 -3
  60. data/config/locales/sufia.en.yml +6 -0
  61. data/config/routes.rb +1 -3
  62. data/features/browse_dashboard_files.feature +1 -1
  63. data/features/display_dashboard.feature +1 -1
  64. data/features/step_definitions/fixture_steps.rb +2 -2
  65. data/features/step_definitions/user_steps.rb +12 -8
  66. data/features/support/env.rb +9 -0
  67. data/features/support/paths.rb +21 -21
  68. data/lib/generators/sufia/sufia_generator.rb +46 -4
  69. data/lib/generators/sufia/templates/catalog_controller.rb +2 -2
  70. data/lib/generators/sufia/templates/config/redis_config.rb +20 -0
  71. data/lib/generators/sufia/templates/config/sufia.rb +29 -0
  72. data/lib/generators/sufia/templates/migrations/add_groups_to_users.rb +0 -4
  73. data/lib/sufia.rb +22 -15
  74. data/lib/sufia/active_fedora/redis.rb +49 -0
  75. data/lib/{generators/sufia/templates/config/active_record_base_redis.rb → sufia/active_record/redis.rb} +1 -16
  76. data/lib/sufia/controller.rb +1 -2
  77. data/lib/sufia/http_header_auth.rb +9 -0
  78. data/lib/sufia/role_mapper.rb +1 -0
  79. data/lib/sufia/user.rb +24 -6
  80. data/lib/sufia/version.rb +1 -1
  81. data/lib/tasks/fixtures.rake +245 -0
  82. data/spec/.gitignore +1 -0
  83. data/spec/active_fedora/unsaved_digital_object_spec.rb +2 -2
  84. data/spec/config/host_to_vhost_spec.rb +8 -8
  85. data/spec/controllers/batch_controller_spec.rb +6 -6
  86. data/spec/controllers/catalog_controller_spec.rb +2 -0
  87. data/spec/controllers/dashboard_controller_spec.rb +13 -10
  88. data/spec/controllers/downloads_controller_spec.rb +8 -8
  89. data/spec/controllers/generic_files_controller_spec.rb +46 -44
  90. data/spec/controllers/mailbox_controller_spec.rb +6 -12
  91. data/spec/controllers/sessions_controller_spec.rb +8 -6
  92. data/spec/controllers/single_use_link_controller_spec.rb +9 -14
  93. data/spec/controllers/users_controller_spec.rb +49 -49
  94. data/spec/{factories.rb → factories/users.rb} +6 -3
  95. data/spec/fixtures/scholarsphere/scholarsphere_test2.foxml.erb +2 -2
  96. data/spec/fixtures/scholarsphere/scholarsphere_test3.foxml.erb +2 -2
  97. data/spec/fixtures/scholarsphere/scholarsphere_test4.foxml.erb +2 -2
  98. data/spec/fixtures/scholarsphere/scholarsphere_test6.foxml.erb +2 -2
  99. data/spec/fixtures/scholarsphere/sufia_scholarsphere1.descMeta.txt +12 -0
  100. data/spec/fixtures/scholarsphere/sufia_scholarsphere1.foxml.erb +79 -0
  101. data/spec/fixtures/scholarsphere/sufia_scholarsphere1.txt +1 -0
  102. data/spec/fixtures/scholarsphere/{scholarsphere_test1.foxml.erb → sufia_test1.foxml.erb} +6 -6
  103. data/spec/fixtures/scholarsphere/{scholarsphere_test5.foxml.erb → sufia_test5.foxml.erb} +5 -5
  104. data/spec/fixtures/scholarsphere_generic_stub.foxml.erb +5 -5
  105. data/spec/lib/{scholarsphere → sufia}/id_service_spec.rb +5 -5
  106. data/spec/lib/{scholarsphere → sufia}/role_mapper_spec.rb +5 -2
  107. data/spec/models/audit_job_spec.rb +1 -1
  108. data/spec/models/batch_spec.rb +2 -2
  109. data/spec/models/batch_update_job_spec.rb +5 -5
  110. data/spec/models/checksum_audit_log_spec.rb +1 -1
  111. data/spec/models/event_jobs_spec.rb +19 -19
  112. data/spec/models/file_content_datastream_spec.rb +6 -6
  113. data/spec/models/fits_datastream_spec.rb +1 -1
  114. data/spec/models/generic_file_spec.rb +8 -9
  115. data/spec/models/local_authority_spec.rb +3 -3
  116. data/spec/models/single_use_link_spec.rb +5 -5
  117. data/spec/models/unzip_job_spec.rb +1 -1
  118. data/spec/models/user_spec.rb +5 -26
  119. data/spec/rake/scholarsphere_fixtures_spec.rb +13 -12
  120. data/spec/routing/route_spec.rb +4 -41
  121. data/spec/spec_helper.rb +14 -4
  122. data/spec/support/Gemfile +21 -0
  123. data/spec/support/config/redis.yml +6 -0
  124. data/spec/support/lib/generators/test_app_generator.rb +40 -0
  125. data/sufia.gemspec +4 -2
  126. data/tasks/cucumber.rake +0 -6
  127. data/tasks/jetty.rake +40 -0
  128. data/tasks/scholarsphere-dev.rake +57 -17
  129. data/tasks/scholarsphere-fixtures.rake +16 -63
  130. metadata +74 -55
  131. data/.rvmrc +0 -59
  132. data/LICENSE +0 -22
  133. data/app/assets/images/site_images/logo_psuss_logotype.png +0 -0
  134. data/app/assets/images/site_images/logo_psuss_shield.png +0 -0
  135. data/lib/generators/sufia/templates/config/active_fedora_base_redis.rb +0 -54
  136. data/lib/sufia/ldap.rb +0 -123
  137. data/spec/fixtures/hydra_test_default_partials.foxml.xml +0 -80
  138. data/spec/fixtures/hydra_test_generic_content.foxml.xml +0 -138
  139. data/spec/fixtures/hydra_test_generic_image.foxml.xml +0 -395
  140. data/spec/fixtures/hydra_test_no_model.foxml.xml +0 -79
  141. data/spec/fixtures/hydrangea_fixture_archivist_only_mods_article.foxml.xml +0 -1212
  142. data/spec/fixtures/hydrangea_fixture_file_asset1.foxml.xml +0 -4946
  143. data/spec/fixtures/hydrangea_fixture_mods_article1.foxml.xml +0 -234
  144. data/spec/fixtures/hydrangea_fixture_mods_article2.foxml.xml +0 -177
  145. data/spec/fixtures/hydrangea_fixture_mods_article3.foxml.xml +0 -170
  146. data/spec/fixtures/hydrangea_fixture_mods_dataset1.foxml.xml +0 -187
  147. data/spec/fixtures/hydrangea_fixture_uploaded_svg1.foxml.xml +0 -676
  148. data/spec/fixtures/hydrus_admin_class1.foxml.xml +0 -176
  149. data/spec/fixtures/libra-oa_1.foxml.xml +0 -2324
  150. data/spec/fixtures/libra-oa_2.foxml.xml +0 -2422
  151. data/spec/fixtures/libra-oa_7.foxml.xml +0 -1735
@@ -17,22 +17,22 @@ require 'spec_helper'
17
17
  describe 'host_to_vhost' do
18
18
  it "should return the proper vhost on fedora1test" do
19
19
  Socket.stubs(:gethostname).returns('fedora1test')
20
- ScholarSphere::Application.get_vhost_by_host[0].should == 'scholarsphere-integration.dlt.psu.edu-8443'
21
- ScholarSphere::Application.get_vhost_by_host[1].should == 'https://scholarsphere-integration.dlt.psu.edu:8443/'
20
+ Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[0].should == 'scholarsphere-integration.dlt.psu.edu-8443'
21
+ Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[1].should == 'https://scholarsphere-integration.dlt.psu.edu:8443/'
22
22
  end
23
23
  it "should return the proper vhost on fedora2test" do
24
24
  Socket.stubs(:gethostname).returns('fedora2test')
25
- ScholarSphere::Application.get_vhost_by_host[0].should == 'scholarsphere-test.dlt.psu.edu'
26
- ScholarSphere::Application.get_vhost_by_host[1].should == 'https://scholarsphere-test.dlt.psu.edu/'
25
+ Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[0].should == 'scholarsphere-test.dlt.psu.edu'
26
+ Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[1].should == 'https://scholarsphere-test.dlt.psu.edu/'
27
27
  end
28
28
  it "should return the proper vhost on ss1stage" do
29
29
  Socket.stubs(:gethostname).returns('ss1stage')
30
- ScholarSphere::Application.get_vhost_by_host[0].should == 'scholarsphere-staging.dlt.psu.edu'
31
- ScholarSphere::Application.get_vhost_by_host[1].should == 'https://scholarsphere-staging.dlt.psu.edu/'
30
+ Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[0].should == 'scholarsphere-staging.dlt.psu.edu'
31
+ Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[1].should == 'https://scholarsphere-staging.dlt.psu.edu/'
32
32
  end
33
33
  it "should return the proper vhost on dev" do
34
34
  Socket.stubs(:gethostname).returns('some1host')
35
- ScholarSphere::Application.get_vhost_by_host[0].should == 'some1host'
36
- ScholarSphere::Application.get_vhost_by_host[1].should == 'https://some1host/'
35
+ Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[0].should == 'some1host'
36
+ Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[1].should == 'https://some1host/'
37
37
  end
38
38
  end
@@ -31,7 +31,7 @@ describe BatchController do
31
31
  @batch = Batch.new
32
32
  @batch.save
33
33
  @file = GenericFile.new(:batch=>@batch)
34
- @file.apply_depositor_metadata(@user.login)
34
+ @file.apply_depositor_metadata(@user.user_key)
35
35
  @file.save
36
36
  @file2 = GenericFile.new(:batch=>@batch)
37
37
  @file2.apply_depositor_metadata('otherUser')
@@ -44,14 +44,14 @@ describe BatchController do
44
44
  end
45
45
  it "should equeue a batch update job" do
46
46
  params = {'generic_file' => {'terms_of_service' => '1', 'read_groups_string' => '', 'read_users_string' => 'archivist1, archivist2', 'tag' => ['']}, 'id' => @batch.pid, 'controller' => 'batch', 'action' => 'update'}
47
- Resque.expects(:enqueue).with(BatchUpdateJob, @user.login, params, params['generic_file']).once
47
+ Resque.expects(:enqueue).with(BatchUpdateJob, @user.user_key, params, params['generic_file']).once
48
48
  post :update, :id=>@batch.pid, "generic_file"=>{"terms_of_service"=>"1", "read_groups_string"=>"", "read_users_string"=>"archivist1, archivist2", "tag"=>[""]}
49
49
  end
50
50
  describe "when views are shown" do
51
51
  render_views
52
52
  it "should show flash messages" do
53
53
  post :update, :id=>@batch.pid, "generic_file"=>{"terms_of_service"=>"1", "read_groups_string"=>"","read_users_string"=>"archivist1, archivist2", "tag"=>[""]}
54
- response.should redirect_to dashboard_path
54
+ response.should redirect_to @routes.url_helpers.dashboard_path
55
55
  flash[:notice].should_not be_nil
56
56
  flash[:notice].should_not be_empty
57
57
  flash[:notice].should include("Your files are being processed")
@@ -63,7 +63,7 @@ describe BatchController do
63
63
  file = GenericFile.find(@file.pid)
64
64
  file.read_users.should == ['archivist1', 'archivist2']
65
65
 
66
- response.should redirect_to dashboard_path
66
+ response.should redirect_to @routes.url_helpers.dashboard_path
67
67
  end
68
68
  it "should set the groups with read access" do
69
69
  post :update, :id=>@batch.pid, "generic_file"=>{"terms_of_service"=>"1", "read_groups_string"=>"group1, group2", "read_users_string"=>"", "tag"=>[""]}
@@ -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.login)
121
+ @file.apply_depositor_metadata(@user.user_key)
122
122
  @file.save
123
123
  @file2 = GenericFile.new(:batch=>@b1, :label=>'f2')
124
- @file2.apply_depositor_metadata(@user.login)
124
+ @file2.apply_depositor_metadata(@user.user_key)
125
125
  @file2.save
126
126
  controller.stubs(:params).returns({id:@b1.id})
127
127
  end
@@ -47,6 +47,8 @@ describe CatalogController do
47
47
  it "should find pdf files" do
48
48
  response.should be_success
49
49
  response.should render_template('catalog/index')
50
+ assigns(:document_list).map(&:id) == [@gf1.id]
51
+
50
52
  assigns(:document_list).count.should eql(1)
51
53
  assigns(:document_list)[0].fetch(:generic_file__title_t)[0].should eql('Test Document PDF')
52
54
  end
@@ -22,16 +22,18 @@ describe DashboardController do
22
22
  end
23
23
  # This doesn't really belong here, but it works for now
24
24
  describe "authenticate!" do
25
- before(:each) do
26
- @user = FactoryGirl.find_or_create(:archivist)
27
- request.stubs(:headers).returns('REMOTE_USER' => @user.login).at_least_once
28
- @strategy = Devise::Strategies::HttpHeaderAuthenticatable.new(nil)
29
- @strategy.expects(:request).returns(request).at_least_once
30
- end
31
- after(:each) do
32
- @user.delete
33
- end
25
+ # move to scholarsphere
26
+ # before(:each) do
27
+ # @user = FactoryGirl.find_or_create(:archivist)
28
+ # request.stubs(:headers).returns('REMOTE_USER' => @user.login).at_least_once
29
+ # @strategy = Devise::Strategies::HttpHeaderAuthenticatable.new(nil)
30
+ # @strategy.expects(:request).returns(request).at_least_once
31
+ # end
32
+ # after(:each) do
33
+ # @user.delete
34
+ # end
34
35
  it "should populate LDAP attrs if user is new" do
36
+ pending "This should only be in scholarsphere"
35
37
  User.stubs(:find_by_login).with(@user.login).returns(nil)
36
38
  User.expects(:create).with(login: @user.login).returns(@user).once
37
39
  User.any_instance.expects(:populate_attributes).once
@@ -41,6 +43,7 @@ describe DashboardController do
41
43
  get :index
42
44
  end
43
45
  it "should not populate LDAP attrs if user is not new" do
46
+ pending "This should only be in scholarsphere"
44
47
  User.stubs(:find_by_login).with(@user.login).returns(@user)
45
48
  User.expects(:create).with(login: @user.login).never
46
49
  User.any_instance.expects(:populate_attributes).never
@@ -66,7 +69,7 @@ describe DashboardController do
66
69
  response.should render_template('dashboard/index')
67
70
  end
68
71
  it "should return an array of documents I can edit" do
69
- @user_results = Blacklight.solr.find Hash[:fq=>["edit_access_group_t:public OR edit_access_person_t:#{@user.login}"]]
72
+ @user_results = Blacklight.solr.find Hash[:fq=>["edit_access_group_t:public OR edit_access_person_t:#{@user.user_key}"]]
70
73
  assigns(:document_list).count.should eql(@user_results.docs.count)
71
74
  end
72
75
  end
@@ -18,16 +18,16 @@ describe DownloadsController do
18
18
 
19
19
  before(:all) do
20
20
  GenericFile.any_instance.stubs(:terms_of_service).returns('1')
21
- f = GenericFile.new(:pid => 'scholarsphere:test1')
22
- f.apply_depositor_metadata('archivist1')
21
+ f = GenericFile.new(:pid => 'sufia:test1')
22
+ f.apply_depositor_metadata('archivist1@example.com')
23
23
  f.set_title_and_label('world.png')
24
- f.add_file_datastream(File.new(Rails.root + 'spec/fixtures/world.png'), :dsid=>'content', :mimeType => 'image/png')
24
+ f.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content', :mimeType => 'image/png')
25
25
  f.expects(:characterize_if_changed).yields
26
26
  f.save
27
27
  end
28
28
 
29
29
  after(:all) do
30
- GenericFile.find('scholarsphere:test1').delete
30
+ GenericFile.find('sufia:test1').delete
31
31
  end
32
32
 
33
33
  describe "routing" do
@@ -50,28 +50,28 @@ describe DownloadsController do
50
50
  it "should default to returning configured default download" do
51
51
  DownloadsController.default_content_dsid.should == "content"
52
52
  controller.stubs(:render)
53
- expected_content = ActiveFedora::Base.find("scholarsphere:test1").content.content
53
+ expected_content = ActiveFedora::Base.find("sufia:test1").content.content
54
54
  controller.expects(:send_data).with(expected_content, {:filename => 'world.png', :disposition => 'inline', :type => 'image/png' })
55
55
  get "show", :id => "test1"
56
56
  response.should be_success
57
57
  end
58
58
  it "should return requested datastreams" do
59
59
  controller.stubs(:render)
60
- expected_content = ActiveFedora::Base.find("scholarsphere:test1").descMetadata.content
60
+ expected_content = ActiveFedora::Base.find("sufia:test1").descMetadata.content
61
61
  controller.expects(:send_data).with(expected_content, {:filename => 'descMetadata', :disposition => 'inline', :type => "text/plain"})
62
62
  get "show", :id => "test1", :datastream_id => "descMetadata"
63
63
  response.should be_success
64
64
  end
65
65
  it "should support setting disposition to inline" do
66
66
  controller.stubs(:render)
67
- expected_content = ActiveFedora::Base.find("scholarsphere:test1").content.content
67
+ expected_content = ActiveFedora::Base.find("sufia:test1").content.content
68
68
  controller.expects(:send_data).with(expected_content, {:filename => 'world.png', :type => 'image/png', :disposition => "inline"})
69
69
  get "show", :id => "test1", :disposition => "inline"
70
70
  response.should be_success
71
71
  end
72
72
  it "should allow you to specify filename for download" do
73
73
  controller.stubs(:render)
74
- expected_content = ActiveFedora::Base.find("scholarsphere:test1").content.content
74
+ expected_content = ActiveFedora::Base.find("sufia:test1").content.content
75
75
  controller.expects(:send_data).with(expected_content, {:filename => "my%20dog.png", :disposition => 'inline', :type => 'image/png'})
76
76
  get "show", :id => "test1", "filename" => "my%20dog.png"
77
77
  end
@@ -16,8 +16,7 @@ require 'spec_helper'
16
16
 
17
17
  describe GenericFilesController do
18
18
  before do
19
- Hydra::LDAP.connection.stubs(:get_operation_result).returns(OpenStruct.new({code:0, message:"Success"}))
20
- Hydra::LDAP.stubs(:does_user_exist?).returns(true)
19
+ controller.stubs(:has_access?).returns(true)
21
20
 
22
21
  GenericFile.any_instance.stubs(:terms_of_service).returns('1')
23
22
  @user = FactoryGirl.find_or_create(:user)
@@ -41,19 +40,19 @@ describe GenericFilesController do
41
40
  end
42
41
 
43
42
  it "should spawn a content deposit event job" do
44
- GenericFile.any_instance.stubs(:to_solr).returns({})
43
+ #GenericFile.any_instance.stubs(:to_solr).returns({})
45
44
  file = fixture_file_upload('/world.png','image/png')
46
- Resque.expects(:enqueue).with(ContentDepositEventJob, 'test:123', 'jilluser')
45
+ Resque.expects(:enqueue).with(ContentDepositEventJob, 'test:123', 'jilluser@example.com')
47
46
  Resque.expects(:enqueue).with(CharacterizeJob, 'test:123')
48
47
  xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service=>"1"
49
48
  end
50
49
 
51
50
  it "should expand zip files" do
52
- GenericFile.any_instance.stubs(:to_solr).returns({})
51
+ #GenericFile.any_instance.stubs(:to_solr).returns({})
53
52
  file = fixture_file_upload('/world.png','application/zip')
54
53
  Resque.expects(:enqueue).with(CharacterizeJob, 'test:123')
55
54
  Resque.expects(:enqueue).with(UnzipJob, 'test:123')
56
- Resque.expects(:enqueue).with(ContentDepositEventJob, 'test:123', 'jilluser')
55
+ Resque.expects(:enqueue).with(ContentDepositEventJob, 'test:123', 'jilluser@example.com')
57
56
  xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service=>"1"
58
57
  end
59
58
 
@@ -76,22 +75,22 @@ describe GenericFilesController do
76
75
  end
77
76
 
78
77
  it "should record what user created the first version of content" do
79
- GenericFile.any_instance.stubs(:to_solr).returns({})
78
+ #GenericFile.any_instance.stubs(:to_solr).returns({})
80
79
  file = fixture_file_upload('/world.png','image/png')
81
80
  xhr :post, :create, :files=>[file], :Filename=>"The world", :terms_of_service=>"1"
82
81
 
83
82
  saved_file = GenericFile.find('test:123')
84
83
  version = saved_file.content.latest_version
85
84
  version.versionID.should == "content.0"
86
- saved_file.content.version_committer(version).should == @user.login
85
+ saved_file.content.version_committer(version).should == @user.user_key
87
86
  end
88
87
 
89
88
  it "should create batch associations from batch_id" do
90
- Rails.application.config.stubs(:id_namespace).returns('sample')
89
+ Sufia::Engine.config.stubs(:id_namespace).returns('sample')
91
90
  file = fixture_file_upload('/world.png','image/png')
92
91
  controller.stubs(:add_posted_blob_to_asset)
93
92
  xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service=>"1"
94
- lambda {Batch.find("sample:batch_id")}.should raise_error(ActiveFedora::ObjectNotFoundError) # The controller shouldn't actually save the Batch
93
+ lambda {Batch.find("sample:batch_id")}.should raise_error(ActiveFedora::ObjectNotFoundError) # The controller shouldn't actually save the Batch, but it should write the batch id to the files.
95
94
  b = Batch.create(pid: "sample:batch_id")
96
95
  b.generic_files.first.pid.should == "test:123"
97
96
  end
@@ -102,18 +101,23 @@ describe GenericFilesController do
102
101
 
103
102
  saved_file = GenericFile.find('test:123')
104
103
  # This is confirming that apply_depositor_metadata recorded the depositor
105
- saved_file.properties.depositor.should == ['jilluser']
106
- saved_file.depositor.should == 'jilluser'
104
+ #TODO make sure this is moved to scholarsphere:
105
+ #saved_file.properties.depositor.should == ['jilluser']
106
+ saved_file.properties.depositor.should == ['jilluser@example.com']
107
+ #TODO make sure this is moved to scholarsphere:
108
+ #saved_file.depositor.should == 'jilluser'
109
+ saved_file.depositor.should == 'jilluser@example.com'
107
110
  saved_file.properties.to_solr.keys.should include('depositor_t')
108
- saved_file.properties.to_solr['depositor_t'].should == ['jilluser']
111
+ #TODO make sure this is moved to scholarsphere:
112
+ #saved_file.properties.to_solr['depositor_t'].should == ['jilluser']
113
+ saved_file.properties.to_solr['depositor_t'].should == ['jilluser@example.com']
109
114
  saved_file.to_solr.keys.should include('depositor_t')
110
- saved_file.to_solr['depositor_t'].should == ['jilluser']
115
+ saved_file.to_solr['depositor_t'].should == ['jilluser@example.com']
111
116
  end
112
117
  it "Should call virus check" do
113
- GenericFile.any_instance.stubs(:to_solr).returns({})
114
118
  controller.expects(:virus_check).returns(0)
115
119
  file = fixture_file_upload('/world.png','image/png')
116
- Resque.expects(:enqueue).with(ContentDepositEventJob, 'test:123', 'jilluser')
120
+ Resque.expects(:enqueue).with(ContentDepositEventJob, 'test:123', 'jilluser@example.com')
117
121
  Resque.expects(:enqueue).with(CharacterizeJob, 'test:123')
118
122
  xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service=>"1"
119
123
  end
@@ -146,9 +150,9 @@ describe GenericFilesController do
146
150
 
147
151
  describe "audit" do
148
152
  before do
149
- GenericFile.any_instance.stubs(:to_solr).returns({})
153
+ #GenericFile.any_instance.stubs(:to_solr).returns({})
150
154
  @generic_file = GenericFile.new
151
- @generic_file.add_file_datastream(File.new(Rails.root + 'spec/fixtures/world.png'), :dsid=>'content')
155
+ @generic_file.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content')
152
156
  @generic_file.apply_depositor_metadata('mjg36')
153
157
  @generic_file.save
154
158
  end
@@ -159,7 +163,7 @@ describe GenericFilesController do
159
163
  xhr :post, :audit, :id=>@generic_file.pid
160
164
  response.should be_success
161
165
  lambda { JSON.parse(response.body) }.should_not raise_error
162
- audit_results = JSON.parse(response.body).collect { |result| result["checksum_audit_log"]["pass"] }
166
+ audit_results = JSON.parse(response.body).collect { |result| result["pass"] }
163
167
  audit_results.reduce(true) { |sum, value| sum && value }.should be_true
164
168
  end
165
169
  end
@@ -167,9 +171,8 @@ describe GenericFilesController do
167
171
  describe "destroy" do
168
172
  before(:each) do
169
173
  GenericFile.any_instance.stubs(:terms_of_service).returns('1')
170
- GenericFile.any_instance.stubs(:to_solr).returns({})
171
174
  @generic_file = GenericFile.new
172
- @generic_file.apply_depositor_metadata(@user.login)
175
+ @generic_file.apply_depositor_metadata(@user.user_key)
173
176
  @generic_file.save
174
177
  @user = FactoryGirl.find_or_create(:user)
175
178
  sign_in @user
@@ -183,7 +186,7 @@ describe GenericFilesController do
183
186
  lambda { GenericFile.find(@generic_file.pid) }.should raise_error(ActiveFedora::ObjectNotFoundError)
184
187
  end
185
188
  it "should spawn a content delete event job" do
186
- Resque.expects(:enqueue).with(ContentDeleteEventJob, @generic_file.noid, @user.login)
189
+ Resque.expects(:enqueue).with(ContentDeleteEventJob, @generic_file.noid, @user.user_key)
187
190
  delete :destroy, :id=>@generic_file.pid
188
191
  end
189
192
  end
@@ -193,7 +196,7 @@ describe GenericFilesController do
193
196
  GenericFile.any_instance.stubs(:terms_of_service).returns('1')
194
197
  #controller.expects(:virus_check).returns(0)
195
198
  @generic_file = GenericFile.new
196
- @generic_file.apply_depositor_metadata(@user.login)
199
+ @generic_file.apply_depositor_metadata(@user.user_key)
197
200
  @generic_file.save
198
201
  end
199
202
  after do
@@ -201,7 +204,7 @@ describe GenericFilesController do
201
204
  end
202
205
 
203
206
  it "should spawn a content update event job" do
204
- Resque.expects(:enqueue).with(ContentUpdateEventJob, @generic_file.pid, 'jilluser')
207
+ Resque.expects(:enqueue).with(ContentUpdateEventJob, @generic_file.pid, 'jilluser@example.com')
205
208
  @user = FactoryGirl.find_or_create(:user)
206
209
  sign_in @user
207
210
  post :update, :id=>@generic_file.pid, :generic_file=>{:terms_of_service=>"1", :title=>'new_title', :tag=>[''], :permissions=>{:new_user_name=>{'archivist1'=>'edit'}}}
@@ -209,7 +212,7 @@ describe GenericFilesController do
209
212
  end
210
213
 
211
214
  it "should spawn a content new version event job" do
212
- Resque.expects(:enqueue).with(ContentNewVersionEventJob, @generic_file.pid, 'jilluser')
215
+ Resque.expects(:enqueue).with(ContentNewVersionEventJob, @generic_file.pid, 'jilluser@example.com')
213
216
  Resque.expects(:enqueue).with(CharacterizeJob, @generic_file.pid)
214
217
  @user = FactoryGirl.find_or_create(:user)
215
218
  sign_in @user
@@ -220,25 +223,23 @@ describe GenericFilesController do
220
223
  end
221
224
 
222
225
  it "should record what user added a new version" do
223
- GenericFile.any_instance.stubs(:to_solr).returns({})
224
-
225
226
  @user = FactoryGirl.find_or_create(:user)
226
227
  sign_in @user
227
228
 
228
229
  file = fixture_file_upload('/world.png','image/png')
229
- post :update, :id=>@generic_file.pid, :filedata=>file, :Filename=>"The world", :generic_file=>{:terms_of_service=>"1", :tag=>[''], :permissions=>{:new_user_name=>{'archivist1'=>'edit'}}}
230
+ post :update, :id=>@generic_file.pid, :filedata=>file, :Filename=>"The world", :generic_file=>{:terms_of_service=>"1", :tag=>[''], :permissions=>{:new_user_name=>{'archivist1@example.com'=>'edit'}}}
230
231
 
231
232
  posted_file = GenericFile.find(@generic_file.pid)
232
233
  version1 = posted_file.content.latest_version
233
- posted_file.content.version_committer(version1).should == @user.login
234
+ posted_file.content.version_committer(version1).should == @user.user_key
234
235
 
235
- # other user uploads new version
236
+ # other user uploads new version
237
+ # TODO this should be a separate test
236
238
  archivist = FactoryGirl.find_or_create(:archivist)
237
239
  controller.stubs(:current_user).returns(archivist)
238
- sign_in archivist
239
240
 
240
- Resque.expects(:enqueue).with(ContentUpdateEventJob, @generic_file.pid, 'jilluser').never
241
- Resque.expects(:enqueue).with(ContentNewVersionEventJob, @generic_file.pid, archivist.login).once
241
+ Resque.expects(:enqueue).with(ContentUpdateEventJob, @generic_file.pid, 'jilluser@example.com').never
242
+ Resque.expects(:enqueue).with(ContentNewVersionEventJob, @generic_file.pid, archivist.user_key).once
242
243
  Resque.expects(:enqueue).with(CharacterizeJob, @generic_file.pid).once
243
244
  file = fixture_file_upload('/image.jp2','image/jp2')
244
245
  post :update, :id=>@generic_file.pid, :filedata=>file, :Filename=>"The world", :generic_file=>{:terms_of_service=>"1", :tag=>[''] }
@@ -246,13 +247,13 @@ describe GenericFilesController do
246
247
  edited_file = GenericFile.find(@generic_file.pid)
247
248
  version2 = edited_file.content.latest_version
248
249
  version2.versionID.should_not == version1.versionID
249
- edited_file.content.version_committer(version2).should == archivist.login
250
+ edited_file.content.version_committer(version2).should == archivist.user_key
250
251
 
251
252
  # original user restores his or her version
252
253
  controller.stubs(:current_user).returns(@user)
253
254
  sign_in @user
254
- Resque.expects(:enqueue).with(ContentUpdateEventJob, @generic_file.pid, 'jilluser').never
255
- Resque.expects(:enqueue).with(ContentRestoredVersionEventJob, @generic_file.pid, @user.login, 'content.0').once
255
+ Resque.expects(:enqueue).with(ContentUpdateEventJob, @generic_file.pid, 'jilluser@example.com').never
256
+ Resque.expects(:enqueue).with(ContentRestoredVersionEventJob, @generic_file.pid, @user.user_key, 'content.0').once
256
257
  Resque.expects(:enqueue).with(CharacterizeJob, @generic_file.pid).once
257
258
  post :update, :id=>@generic_file.pid, :revision=>'content.0', :generic_file=>{:terms_of_service=>"1", :tag=>['']}
258
259
 
@@ -260,7 +261,7 @@ describe GenericFilesController do
260
261
  version3 = restored_file.content.latest_version
261
262
  version3.versionID.should_not == version2.versionID
262
263
  version3.versionID.should_not == version1.versionID
263
- restored_file.content.version_committer(version3).should == @user.login
264
+ restored_file.content.version_committer(version3).should == @user.user_key
264
265
  @user.delete
265
266
  end
266
267
 
@@ -268,7 +269,7 @@ describe GenericFilesController do
268
269
  post :update, :id=>@generic_file.pid, :generic_file=>{:terms_of_service=>"1", :tag=>[''], :permissions=>{:new_group_name=>{'group1'=>'read'}, :new_user_name=>{'user1'=>'edit'}}}
269
270
 
270
271
  assigns[:generic_file].read_groups.should == ["group1"]
271
- assigns[:generic_file].edit_users.should include("user1", @user.login)
272
+ assigns[:generic_file].edit_users.should include("user1", @user.user_key)
272
273
  end
273
274
  it "should update existing groups and users" do
274
275
  @generic_file.read_groups = ['group3']
@@ -280,7 +281,7 @@ describe GenericFilesController do
280
281
  it "should spawn a virus check" do
281
282
  # The expectation is in the begin block
282
283
  controller.expects(:virus_check).returns(0)
283
- Resque.stubs(:enqueue).with(ContentNewVersionEventJob, @generic_file.pid, 'jilluser')
284
+ Resque.stubs(:enqueue).with(ContentNewVersionEventJob, @generic_file.pid, 'jilluser@example.com')
284
285
  Resque.stubs(:enqueue).with(CharacterizeJob, @generic_file.pid)
285
286
  GenericFile.stubs(:save).returns({})
286
287
  @user = FactoryGirl.find_or_create(:user)
@@ -294,10 +295,10 @@ describe GenericFilesController do
294
295
  describe "someone elses files" do
295
296
  before(:all) do
296
297
  GenericFile.any_instance.stubs(:terms_of_service).returns('1')
297
- f = GenericFile.new(:pid => 'scholarsphere:test5')
298
- f.apply_depositor_metadata('archivist1')
298
+ f = GenericFile.new(:pid => 'sufia:test5')
299
+ f.apply_depositor_metadata('archivist1@example.com')
299
300
  f.set_title_and_label('world.png')
300
- f.add_file_datastream(File.new(Rails.root + 'spec/fixtures/world.png'))
301
+ f.add_file_datastream(File.new(fixture_path + '/world.png'))
301
302
  # grant public read access explicitly
302
303
  f.read_groups = ['public']
303
304
  f.expects(:characterize_if_changed).yields
@@ -305,12 +306,12 @@ describe GenericFilesController do
305
306
  @file = f
306
307
  end
307
308
  after(:all) do
308
- GenericFile.find('scholarsphere:test5').delete
309
+ GenericFile.find('sufia:test5').delete
309
310
  end
310
311
  describe "edit" do
311
312
  it "should give me a flash error" do
312
313
  get :edit, id:"test5"
313
- response.should redirect_to(:action => 'show')
314
+ response.should redirect_to @routes.url_helpers.generic_file_path('test5')
314
315
  flash[:alert].should_not be_nil
315
316
  flash[:alert].should_not be_empty
316
317
  flash[:alert].should include("You do not have sufficient privileges to edit this document")
@@ -354,6 +355,7 @@ describe GenericFilesController do
354
355
  @ds = @file.datastreams.first
355
356
  AuditJob.perform(@file.pid, @ds[0], @ds[1].versionID)
356
357
  get :show, id:"test5"
358
+ assigns[:notify_number].should == 1
357
359
  response.body.should include('<span id="notify_number" class="overlay"> 1</span>') # notify should be 1 for failing job
358
360
  @archivist.mailbox.inbox[0].messages[0].subject.should == "Failing Audit Run"
359
361
  end