sufia 6.0.0.rc4 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/Gemfile +1 -1
  4. data/History.md +280 -0
  5. data/README.md +180 -98
  6. data/SUFIA_VERSION +1 -1
  7. data/app/assets/images/site_images/collection-icon.svg +168 -0
  8. data/app/assets/javascripts/sufia/uploader.js +7 -4
  9. data/app/assets/stylesheets/sufia.css.scss +1 -1
  10. data/app/assets/stylesheets/sufia/_collections.scss +33 -13
  11. data/app/assets/stylesheets/sufia/_file-show.scss +24 -0
  12. data/app/assets/stylesheets/sufia/_settings.scss +4 -0
  13. data/app/controllers/concerns/sufia/catalog.rb +1 -11
  14. data/app/controllers/concerns/sufia/collections_controller_behavior.rb +13 -15
  15. data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +3 -1
  16. data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +2 -1
  17. data/app/controllers/concerns/sufia/files_controller/local_ingest_behavior.rb +1 -0
  18. data/app/controllers/concerns/sufia/files_controller_behavior.rb +4 -1
  19. data/app/controllers/concerns/sufia/homepage_controller.rb +4 -11
  20. data/app/controllers/concerns/sufia/my_controller_behavior.rb +3 -21
  21. data/app/controllers/concerns/sufia/transfers_controller_behavior.rb +6 -6
  22. data/app/controllers/concerns/sufia/users_controller_behavior.rb +7 -7
  23. data/app/controllers/my/collections_controller.rb +1 -8
  24. data/app/controllers/my/files_controller.rb +1 -1
  25. data/app/controllers/my/highlights_controller.rb +1 -9
  26. data/app/controllers/my/shares_controller.rb +1 -8
  27. data/app/helpers/generic_file_helper.rb +4 -0
  28. data/app/helpers/sufia/sufia_helper_behavior.rb +3 -3
  29. data/app/helpers/sufia_url_helper.rb +9 -0
  30. data/app/jobs/content_depositor_change_event_job.rb +5 -5
  31. data/app/search_builders/sufia/search_builder.rb +50 -0
  32. data/app/views/_user_util_links.html.erb +6 -4
  33. data/app/views/batch_edits/_check_all.html.erb +1 -1
  34. data/app/views/catalog/index.html.erb +3 -30
  35. data/app/views/collections/_media_display.html.erb +1 -1
  36. data/app/views/collections/_show_descriptions.html.erb +1 -1
  37. data/app/views/collections/_show_document_list_row.html.erb +2 -2
  38. data/app/views/dashboard/_index_partials/_heading_actions.html.erb +16 -12
  39. data/app/views/generic_files/_browse_everything.html.erb +3 -1
  40. data/app/views/generic_files/_local_file_import.html.erb +0 -1
  41. data/app/views/generic_files/_multiple_upload.html.erb +0 -1
  42. data/app/views/generic_files/_show_descriptions.html.erb +6 -11
  43. data/app/views/generic_files/_show_details.html.erb +41 -65
  44. data/app/views/generic_files/new.html.erb +1 -0
  45. data/app/views/generic_files/show.html.erb +2 -1
  46. data/app/views/generic_files/upload/_alerts.html.erb +5 -13
  47. data/app/views/homepage/_home_header.html.erb +6 -7
  48. data/app/views/my/_index_partials/_list_collections.html.erb +1 -1
  49. data/app/views/my/index.html.erb +2 -2
  50. data/app/views/records/edit_fields/_resource_type.html.erb +1 -1
  51. data/config/initializers/sufia_events.rb +2 -3
  52. data/config/locales/sufia.en.yml +11 -2
  53. data/lib/generators/sufia/install_generator.rb +5 -1
  54. data/lib/generators/sufia/templates/catalog_controller.rb +3 -5
  55. data/lib/generators/sufia/upgrade600_generator.rb +26 -0
  56. data/lib/sufia/version.rb +1 -1
  57. data/spec/actors/generic_file/actor_spec.rb +14 -0
  58. data/spec/controllers/collections_controller_spec.rb +19 -2
  59. data/spec/controllers/dashboard_controller_spec.rb +43 -12
  60. data/spec/controllers/generic_files_controller_spec.rb +24 -1
  61. data/spec/controllers/transfers_controller_spec.rb +4 -4
  62. data/spec/controllers/users_controller_spec.rb +18 -4
  63. data/spec/fixtures/spoken-text.m4a +0 -0
  64. data/spec/helpers/dashboard_helper_spec.rb +1 -1
  65. data/spec/helpers/sufia_url_helper_spec.rb +15 -0
  66. data/spec/inputs/select_with_help_input_spec.rb +15 -0
  67. data/spec/jobs/{active_fedora_pid_based_job_spec.rb → active_fedora_id_based_job_spec.rb} +2 -2
  68. data/spec/jobs/audit_job_spec.rb +2 -2
  69. data/spec/lib/sufia/id_service_spec.rb +8 -8
  70. data/spec/lib/sufia/user_stat_importer_spec.rb +9 -1
  71. data/spec/models/ability_spec.rb +7 -4
  72. data/spec/models/checksum_audit_log_spec.rb +10 -10
  73. data/spec/models/collection_spec.rb +8 -13
  74. data/spec/models/fits_datastream_spec.rb +17 -0
  75. data/spec/models/generic_file_spec.rb +9 -1
  76. data/spec/models/proxy_deposit_request_spec.rb +15 -3
  77. data/spec/services/generic_file_audit_service_spec.rb +1 -1
  78. data/spec/support/features.rb +1 -0
  79. data/spec/support/rake_output.rb +20 -0
  80. data/spec/tasks/rake_spec.rb +58 -0
  81. data/spec/test_app_templates/Gemfile.extra +3 -1
  82. data/spec/views/batch/edit.html.erb_spec.rb +6 -2
  83. data/spec/views/catalog/index.html.erb_spec.rb +1 -1
  84. data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +6 -2
  85. data/spec/views/dashboard/index_spec.rb +49 -1
  86. data/spec/views/generic_file/_browse_everything.html.erb_spec.rb +9 -0
  87. data/spec/views/generic_file/show.html.erb_spec.rb +13 -8
  88. data/spec/views/homepage/_home_header.html.erb_spec.rb +26 -0
  89. data/spec/views/users/_user_util_links.html.erb_spec.rb +20 -0
  90. data/spec/views/users/show.html.erb_spec.rb +1 -1
  91. data/sufia-models/app/actors/sufia/generic_file/actor.rb +1 -1
  92. data/sufia-models/app/jobs/active_fedora_id_based_job.rb +22 -0
  93. data/sufia-models/app/jobs/active_fedora_pid_based_job.rb +5 -20
  94. data/sufia-models/app/jobs/audit_job.rb +5 -6
  95. data/sufia-models/app/jobs/characterize_job.rb +1 -1
  96. data/sufia-models/app/jobs/create_derivatives_job.rb +1 -1
  97. data/sufia-models/app/jobs/import_url_job.rb +2 -2
  98. data/sufia-models/app/models/batch.rb +18 -4
  99. data/sufia-models/app/models/checksum_audit_log.rb +2 -2
  100. data/sufia-models/app/models/concerns/sufia/ability.rb +7 -1
  101. data/sufia-models/app/models/concerns/sufia/collection_behavior.rb +1 -1
  102. data/sufia-models/app/models/concerns/sufia/generic_file/full_text_indexing.rb +23 -14
  103. data/sufia-models/app/models/concerns/sufia/generic_file/proxy_deposit.rb +1 -1
  104. data/sufia-models/app/models/datastreams/fits_datastream.rb +1 -36
  105. data/sufia-models/app/models/proxy_deposit_request.rb +6 -6
  106. data/sufia-models/app/services/sufia/generic_file_audit_service.rb +1 -1
  107. data/sufia-models/app/services/sufia/generic_file_indexing_service.rb +0 -1
  108. data/sufia-models/app/services/sufia/id_service.rb +2 -3
  109. data/sufia-models/app/services/sufia/noid.rb +1 -1
  110. data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +1 -1
  111. data/sufia-models/lib/generators/sufia/models/templates/migrations/change_audit_log_pid_to_generic_file_id.rb +5 -0
  112. data/sufia-models/lib/generators/sufia/models/templates/migrations/change_proxy_deposit_request_pid_to_generic_file_id.rb +5 -0
  113. data/sufia-models/lib/generators/sufia/models/upgrade600_generator.rb +21 -0
  114. data/sufia-models/lib/sufia/models/stats/user_stat_importer.rb +20 -1
  115. data/sufia-models/lib/sufia/models/version.rb +1 -1
  116. data/sufia-models/lib/tasks/batch_cleanup.rake +19 -0
  117. data/sufia-models/lib/tasks/migrate.rake +21 -0
  118. data/sufia-models/lib/tasks/sufia-models_tasks.rake +55 -38
  119. data/sufia-models/sufia-models.gemspec +1 -1
  120. data/sufia.gemspec +2 -2
  121. metadata +44 -38
  122. data/app/assets/images/site_images/bg_body.png +0 -0
  123. data/app/assets/images/site_images/bg_breadcrumbs.png +0 -0
  124. data/app/assets/images/site_images/bg_button1.png +0 -0
  125. data/app/assets/images/site_images/bg_button2.png +0 -0
  126. data/app/assets/images/site_images/bg_button3.png +0 -0
  127. data/app/assets/images/site_images/bg_content.png +0 -0
  128. data/app/assets/images/site_images/bg_content2.png +0 -0
  129. data/app/assets/images/site_images/bg_footer.png +0 -0
  130. data/app/assets/images/site_images/bg_masthead.png +0 -0
  131. data/app/assets/images/site_images/bg_search_field.png +0 -0
  132. data/app/assets/images/site_images/bg_search_header.png +0 -0
  133. data/app/assets/images/site_images/bg_signin.png +0 -0
  134. data/app/assets/images/site_images/carrot_blue.png +0 -0
  135. data/app/assets/images/site_images/carrot_yellow.png +0 -0
  136. data/app/assets/images/site_images/icon_arrow2_up.png +0 -0
  137. data/app/assets/images/site_images/icon_arrow3_down.png +0 -0
  138. data/app/assets/images/site_images/icon_arrow3_right.png +0 -0
  139. data/app/assets/images/site_images/icon_arrow_down.png +0 -0
  140. data/app/assets/images/site_images/icons_sprite.png +0 -0
  141. data/app/assets/images/site_images/logo_psuss_footer.png +0 -0
  142. data/app/views/catalog/_edit_partials/_default.html.erb +0 -55
  143. data/spec/support/fedora_conf/fedora.fcfg +0 -953
@@ -1,28 +1,25 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe DashboardController, :type => :controller do
4
-
5
4
  context "with an unauthenticated user" do
6
-
7
5
  it "redirects to sign-in page" do
8
6
  get :index
9
7
  expect(response).to be_redirect
10
8
  expect(flash[:alert]).to eq("You need to sign in or sign up before continuing.")
11
9
  end
12
-
13
10
  end
14
11
 
15
12
  context "with an authenticated user" do
13
+ let(:user) { FactoryGirl.find_or_create(:user_with_mail) }
16
14
 
17
15
  before do
18
- @user = FactoryGirl.find_or_create(:user_with_mail)
19
- sign_in @user
16
+ sign_in user
20
17
  end
21
18
 
22
19
  it "renders the dashboard with the user's info" do
23
20
  get :index
24
21
  expect(response).to be_successful
25
- expect(assigns(:user)).to eq(@user)
22
+ expect(assigns(:user)).to eq(user)
26
23
  end
27
24
 
28
25
  it "gathers the user's recent activity" do
@@ -35,12 +32,49 @@ describe DashboardController, :type => :controller do
35
32
  expect(assigns(:notifications)).to be_truthy
36
33
  end
37
34
 
38
- context "with activities" do
35
+ context 'with transfers' do
36
+ let(:another_user) { FactoryGirl.find_or_create(:archivist) }
37
+ context 'when incoming' do
38
+ let!(:incoming_file) do
39
+ GenericFile.new.tap do |f|
40
+ f.apply_depositor_metadata(another_user.user_key)
41
+ f.save!
42
+ f.request_transfer_to(user)
43
+ end
44
+ end
45
+
46
+ it 'assigns an instance variable' do
47
+ get :index
48
+ expect(response).to be_success
49
+ expect(assigns[:incoming].first).to be_kind_of ProxyDepositRequest
50
+ expect(assigns[:incoming].first.generic_file_id).to eq(incoming_file.id)
51
+ end
52
+ end
53
+
54
+ context 'when outgoing' do
55
+ let!(:outgoing_file) do
56
+ GenericFile.new.tap do |f|
57
+ f.apply_depositor_metadata(user.user_key)
58
+ f.save!
59
+ f.request_transfer_to(another_user)
60
+ end
61
+ end
62
+
63
+ it 'assigns an instance variable' do
64
+ get :index
65
+ expect(response).to be_success
66
+ expect(assigns[:outgoing].first).to be_kind_of ProxyDepositRequest
67
+ expect(assigns[:outgoing].first.generic_file_id).to eq(outgoing_file.id)
68
+ end
69
+ end
70
+ end
39
71
 
72
+ context "with activities" do
40
73
  let(:activity) { double }
74
+
41
75
  before do
42
76
  allow(activity).to receive(:map).and_return(activity)
43
- expect_any_instance_of(User).to receive(:get_all_user_activity).and_return(activity)
77
+ allow_any_instance_of(User).to receive(:get_all_user_activity).and_return(activity)
44
78
  end
45
79
 
46
80
  it "gathers the user's recent activity within the default amount of time" do
@@ -51,10 +85,7 @@ describe DashboardController, :type => :controller do
51
85
  it "returns results in JSON" do
52
86
  get :activity
53
87
  expect(response).to be_successful
54
- end
55
-
88
+ end
56
89
  end
57
-
58
90
  end
59
-
60
91
  end
@@ -44,7 +44,7 @@ describe GenericFilesController do
44
44
  it "spawns a content deposit event job" do
45
45
  expect_any_instance_of(Sufia::GenericFile::Actor).to receive(:create_content).with(file, 'world.png', 'content', 'image/png').and_return(true)
46
46
  xhr :post, :create, files: [file], 'Filename' => 'The world', batch_id: batch_id, permission: {group: { public: 'read' } }, terms_of_service: '1'
47
- expect(response.body).to eq '[{"name":null,"size":"","url":"/files/test123","thumbnail_url":"test123","delete_url":"deleteme","delete_type":"DELETE"}]'
47
+ expect(response.body).to eq '[{"name":null,"size":null,"url":"/files/test123","thumbnail_url":"test123","delete_url":"deleteme","delete_type":"DELETE"}]'
48
48
  expect(flash[:error]).to be_nil
49
49
  end
50
50
 
@@ -563,4 +563,27 @@ describe GenericFilesController do
563
563
  expect(user.mailbox.inbox[0].messages[0].subject).to eq "Test subject"
564
564
  end
565
565
  end
566
+
567
+ describe "batch creation" do
568
+ context "when uploading a file" do
569
+ let(:batch_id) { Sufia::IdService.mint }
570
+ let(:file1) { fixture_file_upload('/world.png','image/png') }
571
+ let(:file2) { fixture_file_upload('/image.jpg','image/png') }
572
+
573
+ it "should not create the batch on HTTP GET " do
574
+ expect(Batch).to_not receive(:create)
575
+ xhr :get, :new
576
+ expect(response).to be_success
577
+ end
578
+
579
+ it "should create the batch on HTTP POST with multiple files" do
580
+ expect(GenericFile).to receive(:new).twice
581
+ expect(Batch).to receive(:find_or_create).twice
582
+ xhr :post, :create, files: [file1], Filename: 'The world 1', batch_id: batch_id, on_behalf_of: 'carolyn', terms_of_service: '1'
583
+ expect(response).to be_success
584
+ xhr :post, :create, files: [file2], Filename: 'An image', batch_id: batch_id, on_behalf_of: 'carolyn', terms_of_service: '1'
585
+ expect(response).to be_success
586
+ end
587
+ end
588
+ end
566
589
  end
@@ -29,9 +29,9 @@ describe TransfersController, :type => :controller do
29
29
  get :index
30
30
  expect(response).to be_success
31
31
  expect(assigns[:incoming].first).to be_kind_of ProxyDepositRequest
32
- expect(assigns[:incoming].first.pid).to eq(incoming_file.id)
32
+ expect(assigns[:incoming].first.generic_file_id).to eq(incoming_file.id)
33
33
  expect(assigns[:outgoing].first).to be_kind_of ProxyDepositRequest
34
- expect(assigns[:outgoing].first.pid).to eq(outgoing_file.id)
34
+ expect(assigns[:outgoing].first.generic_file_id).to eq(outgoing_file.id)
35
35
  end
36
36
 
37
37
  describe "When the incoming request is for a deleted file" do
@@ -60,7 +60,7 @@ describe TransfersController, :type => :controller do
60
60
  expect(response).to be_success
61
61
  expect(assigns[:generic_file]).to eq(file)
62
62
  expect(assigns[:proxy_deposit_request]).to be_kind_of ProxyDepositRequest
63
- expect(assigns[:proxy_deposit_request].pid).to eq(file.id)
63
+ expect(assigns[:proxy_deposit_request].generic_file_id).to eq(file.id)
64
64
  end
65
65
  end
66
66
  end
@@ -80,7 +80,7 @@ describe TransfersController, :type => :controller do
80
80
  expect(response).to redirect_to @routes.url_helpers.transfers_path
81
81
  expect(flash[:notice]).to eq('Transfer request created')
82
82
  proxy_request = another_user.proxy_deposit_requests.first
83
- expect(proxy_request.pid).to eq(file.id)
83
+ expect(proxy_request.generic_file_id).to eq(file.id)
84
84
  expect(proxy_request.sending_user).to eq(user)
85
85
  # AND A NOTIFICATION SHOULD HAVE BEEN CREATED
86
86
  notification = another_user.reload.mailbox.inbox[0].messages[0]
@@ -103,10 +103,24 @@ describe UsersController, :type => :controller do
103
103
 
104
104
  context "when user attempts to edit another profile" do
105
105
  let(:another_user) { FactoryGirl.create(:user) }
106
- it "redirects to show profile" do
107
- get :edit, id: another_user.user_key
108
- expect(response).to redirect_to(@routes.url_helpers.profile_path(another_user.to_param))
109
- expect(flash[:alert]).to include("Permission denied: cannot access this page.")
106
+ context 'with default abilities' do
107
+ it "redirects to show profile" do
108
+ expect_any_instance_of(Ability).to receive(:can?).with(:edit, another_user).and_return(false)
109
+ get :edit, id: another_user.to_param
110
+ expect(response).to redirect_to(@routes.url_helpers.profile_path(another_user.to_param))
111
+ expect(flash[:alert]).to include("Permission denied: cannot access this page.")
112
+ end
113
+ end
114
+ context 'with a custom ability' do
115
+ before do
116
+ allow_any_instance_of(Ability).to receive(:can?).with(:edit, another_user).and_return(true)
117
+ end
118
+ it "allows user to edit another user's profile" do
119
+ get :edit, id: another_user.to_param
120
+ expect(response).to be_success
121
+ expect(response).not_to redirect_to(@routes.url_helpers.profile_path(another_user.to_param))
122
+ expect(flash[:alert]).to be_nil
123
+ end
110
124
  end
111
125
  end
112
126
 
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe DashboardHelper, :type => :helper do
4
-
4
+
5
5
  describe "#render_recent_activity" do
6
6
  context "when there is no activity" do
7
7
  it "should return a messages stating the user has no recent activity" do
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe SufiaUrlHelper do
4
+ let(:document) { SolrDocument.new(id: 'foo123') }
5
+
6
+ describe "#track_collection_path" do
7
+ subject { helper.track_collection_path(document) }
8
+ it { is_expected.to eq '/catalog/foo123/track' }
9
+ end
10
+
11
+ describe "#track_generic_file_path" do
12
+ subject { helper.track_generic_file_path(document) }
13
+ it { is_expected.to eq '/catalog/foo123/track' }
14
+ end
15
+ end
@@ -14,3 +14,18 @@ describe 'SelectWithHelpInput', type: :input do
14
14
  end
15
15
  end
16
16
 
17
+ describe 'SelectWithHelpInput File Edit', type: :input do
18
+ let(:user) { FactoryGirl.find_or_create(:jill) }
19
+ let(:file) { GenericFile.create(batch: Batch.create, label: 'f1') { |f| f.apply_depositor_metadata(user) } }
20
+ let(:form) { Sufia::Forms::GenericFileEditForm.new(file) }
21
+ let(:base_options) { { as: :select_with_help, collection: Sufia.config.resource_types,
22
+ input_html: { class: 'form-control', multiple: true } } }
23
+ let(:options) { base_options }
24
+
25
+ subject { input_for form, :resource_type, options }
26
+
27
+ it "should not be required by default" do
28
+ expect(subject).to have_selector 'select'
29
+ expect(subject).not_to match /required/
30
+ end
31
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ActiveFedoraPidBasedJob do
3
+ describe ActiveFedoraIdBasedJob do
4
4
  let (:user) {FactoryGirl.find_or_create(:jill)}
5
5
  let (:file) {GenericFile.new.tap do |gf|
6
6
  gf.apply_depositor_metadata(user)
@@ -8,7 +8,7 @@ describe ActiveFedoraPidBasedJob do
8
8
  end}
9
9
 
10
10
  it "finds object" do
11
- job = ActiveFedoraPidBasedJob.new(file.id)
11
+ job = ActiveFedoraIdBasedJob.new(file.id)
12
12
  expect(job.generic_file).to_not be_nil
13
13
  end
14
14
  end
@@ -59,8 +59,8 @@ describe AuditJob do
59
59
 
60
60
  describe "run_audit" do
61
61
  let(:uri) { file.content.versions.first.uri }
62
- let!(:old) { ChecksumAuditLog.create(pid: file.id, dsid: 'content', version: uri, pass: 1, created_at: 2.minutes.ago) }
63
- let!(:new) { ChecksumAuditLog.create(pid: file.id, dsid: 'content', version: uri, pass: 0) }
62
+ let!(:old) { ChecksumAuditLog.create(generic_file_id: file.id, dsid: 'content', version: uri, pass: 1, created_at: 2.minutes.ago) }
63
+ let!(:new) { ChecksumAuditLog.create(generic_file_id: file.id, dsid: 'content', version: uri, pass: 0) }
64
64
  let(:mock_service) { double('mock fixity check service') }
65
65
 
66
66
  before do
@@ -14,18 +14,18 @@ describe Sufia::IdService do
14
14
  expect(Sufia::IdService.valid?(subject)).to be true
15
15
  end
16
16
 
17
- context "when the pid already exists in Fedora" do
18
- let(:mock_pid) { 'ef12ef12f' }
19
- let(:unique_pid) { 'bb22bb22b' }
17
+ context "when the id already exists in Fedora" do
18
+ let(:mock_id) { 'ef12ef12f' }
19
+ let(:unique_id) { 'bb22bb22b' }
20
20
 
21
21
  before do
22
- allow(Sufia::IdService).to receive(:next_id).and_return(mock_pid, unique_pid)
23
- expect(ActiveFedora::Base).to receive(:exists?).with(mock_pid).and_return(true)
24
- expect(ActiveFedora::Base).to receive(:exists?).with(unique_pid).and_return(false)
22
+ allow(Sufia::IdService).to receive(:next_id).and_return(mock_id, unique_id)
23
+ expect(ActiveFedora::Base).to receive(:exists?).with(mock_id).and_return(true)
24
+ expect(ActiveFedora::Base).to receive(:exists?).with(unique_id).and_return(false)
25
25
  end
26
26
 
27
- it "should not assign that pid again" do
28
- expect(subject).to eq unique_pid
27
+ it "should not assign that id again" do
28
+ expect(subject).to eq unique_id
29
29
  end
30
30
  end
31
31
  end
@@ -10,6 +10,7 @@ describe Sufia::UserStatImporter do
10
10
 
11
11
  let(:bilbo) { FactoryGirl.create(:user, email: 'bilbo@example.com') }
12
12
  let(:frodo) { FactoryGirl.create(:user, email: 'frodo@example.com') }
13
+ let!(:gollum) { FactoryGirl.create(:user, email: 'gollum@example.com') }
13
14
 
14
15
  let!(:bilbo_file_1) do
15
16
  GenericFile.new(id: 'bilbo1').tap do |f|
@@ -143,7 +144,7 @@ describe Sufia::UserStatImporter do
143
144
  end
144
145
 
145
146
  it "doesn't duplicate entries for existing dates" do
146
- expect(User.count).to eq 2
147
+ expect(User.count).to eq 3
147
148
  expect(UserStat.count).to eq 3
148
149
 
149
150
  Sufia::UserStatImporter.new.import
@@ -164,6 +165,13 @@ describe Sufia::UserStatImporter do
164
165
 
165
166
  expect(frodos_stats[0].file_downloads).to eq(frodo_file_1_download_stats[0].totalEvents.to_i)
166
167
  end
168
+
169
+ it "processes the oldest records first" do
170
+ # Since Gollum has no stats it will be the first one processed.
171
+ # Followed by Frodo and Bilbo.
172
+ sorted_ids = Sufia::UserStatImporter.new.sorted_users.map { |u| u.id }
173
+ expect(sorted_ids).to eq([gollum.id, frodo.id, bilbo.id])
174
+ end
167
175
  end
168
176
  end
169
177
 
@@ -10,6 +10,7 @@ describe Sufia::Ability, :type => :model do
10
10
  it { is_expected.not_to be_able_to(:create, ContentBlock) }
11
11
  it { is_expected.not_to be_able_to(:update, ContentBlock) }
12
12
  it { is_expected.to be_able_to(:read, ContentBlock) }
13
+ it { is_expected.to be_able_to(:view_share_work, GenericFile) }
13
14
  end
14
15
 
15
16
  describe "a registered user" do
@@ -20,6 +21,7 @@ describe Sufia::Ability, :type => :model do
20
21
  it { is_expected.not_to be_able_to(:create, ContentBlock) }
21
22
  it { is_expected.not_to be_able_to(:update, ContentBlock) }
22
23
  it { is_expected.to be_able_to(:read, ContentBlock) }
24
+ it { is_expected.to be_able_to(:view_share_work, GenericFile) }
23
25
  end
24
26
 
25
27
  describe "a user in the admin group" do
@@ -31,6 +33,7 @@ describe Sufia::Ability, :type => :model do
31
33
  it { is_expected.to be_able_to(:create, ContentBlock) }
32
34
  it { is_expected.to be_able_to(:update, ContentBlock) }
33
35
  it { is_expected.to be_able_to(:read, ContentBlock) }
36
+ it { is_expected.to be_able_to(:view_share_work, GenericFile) }
34
37
  end
35
38
 
36
39
 
@@ -58,13 +61,13 @@ describe Sufia::Ability, :type => :model do
58
61
  end
59
62
 
60
63
  context "with a ProxyDepositRequest that they receive" do
61
- let(:request) { ProxyDepositRequest.create!(pid: file.id, receiving_user: user, sending_user: sender) }
64
+ let(:request) { ProxyDepositRequest.create!(generic_file_id: file.id, receiving_user: user, sending_user: sender) }
62
65
  it { should be_able_to(:accept, request) }
63
66
  it { should be_able_to(:reject, request) }
64
67
  it { should_not be_able_to(:destroy, request) }
65
68
 
66
69
  context "and the request has already been accepted" do
67
- let(:request) { ProxyDepositRequest.create!(pid: file.id, receiving_user: user, sending_user: sender, status: 'accepted') }
70
+ let(:request) { ProxyDepositRequest.create!(generic_file_id: file.id, receiving_user: user, sending_user: sender, status: 'accepted') }
68
71
  it { should_not be_able_to(:accept, request) }
69
72
  it { should_not be_able_to(:reject, request) }
70
73
  it { should_not be_able_to(:destroy, request) }
@@ -72,13 +75,13 @@ describe Sufia::Ability, :type => :model do
72
75
  end
73
76
 
74
77
  context "with a ProxyDepositRequest they are the sender of" do
75
- let(:request) { ProxyDepositRequest.create!(pid: file.id, receiving_user: sender, sending_user: user) }
78
+ let(:request) { ProxyDepositRequest.create!(generic_file_id: file.id, receiving_user: sender, sending_user: user) }
76
79
  it { should_not be_able_to(:accept, request) }
77
80
  it { should_not be_able_to(:reject, request) }
78
81
  it { should be_able_to(:destroy, request) }
79
82
 
80
83
  context "and the request has already been accepted" do
81
- let(:request) { ProxyDepositRequest.create!(pid: file.id, receiving_user: sender, sending_user: user, status: 'accepted') }
84
+ let(:request) { ProxyDepositRequest.create!(generic_file_id: file.id, receiving_user: sender, sending_user: user, status: 'accepted') }
82
85
  it { should_not be_able_to(:accept, request) }
83
86
  it { should_not be_able_to(:reject, request) }
84
87
  it { should_not be_able_to(:destroy, request) }
@@ -14,8 +14,8 @@ describe ChecksumAuditLog do
14
14
 
15
15
  let(:version_uri) { f.content.versions.first.uri }
16
16
  let(:version_path) { 'content' }
17
- let(:old) { ChecksumAuditLog.create(pid: f.id, dsid: version_path, version: version_uri, pass: 1, created_at: 2.minutes.ago) }
18
- let(:new) { ChecksumAuditLog.create(pid: f.id, dsid: version_path, version: version_uri, pass: 0, created_at: 1.minute.ago) }
17
+ let(:old) { ChecksumAuditLog.create(generic_file_id: f.id, dsid: version_path, version: version_uri, pass: 1, created_at: 2.minutes.ago) }
18
+ let(:new) { ChecksumAuditLog.create(generic_file_id: f.id, dsid: version_path, version: version_uri, pass: 0, created_at: 1.minute.ago) }
19
19
 
20
20
  context "a file with multiple checksums audits" do
21
21
  specify "should return a list of logs for this datastream sorted by date descending" do
@@ -26,11 +26,11 @@ describe ChecksumAuditLog do
26
26
 
27
27
  context "after multiple checksum audits where the checksum does not change" do
28
28
  specify "only one of them should be kept" do
29
- success1 = ChecksumAuditLog.create(pid: f.id, dsid: version_path, version: version_uri, pass: 1)
29
+ success1 = ChecksumAuditLog.create(generic_file_id: f.id, dsid: version_path, version: version_uri, pass: 1)
30
30
  ChecksumAuditLog.prune_history(f.id, version_path)
31
- success2 = ChecksumAuditLog.create(pid: f.id, dsid: version_path, version: version_uri, pass: 1)
31
+ success2 = ChecksumAuditLog.create(generic_file_id: f.id, dsid: version_path, version: version_uri, pass: 1)
32
32
  ChecksumAuditLog.prune_history(f.id, version_path)
33
- success3 = ChecksumAuditLog.create(pid: f.id, dsid: version_path, version: version_uri, pass: 1)
33
+ success3 = ChecksumAuditLog.create(generic_file_id: f.id, dsid: version_path, version: version_uri, pass: 1)
34
34
  ChecksumAuditLog.prune_history(f.id, version_path)
35
35
 
36
36
  expect { ChecksumAuditLog.find(success2.id) }.to raise_exception ActiveRecord::RecordNotFound
@@ -43,21 +43,21 @@ describe ChecksumAuditLog do
43
43
 
44
44
  context "should have an audit log history" do
45
45
  before do
46
- ChecksumAuditLog.create(pid: f.id, dsid: 'content', version: 'v2', pass: 1)
47
- ChecksumAuditLog.create(pid: f.id, dsid: 'thumbnail', version: 'v1', pass: 1)
46
+ ChecksumAuditLog.create(generic_file_id: f.id, dsid: 'content', version: 'v2', pass: 1)
47
+ ChecksumAuditLog.create(generic_file_id: f.id, dsid: 'thumbnail', version: 'v1', pass: 1)
48
48
  end
49
49
 
50
50
  specify "should have an audit log history" do
51
51
  audit = ChecksumAuditLog.get_audit_log(f.id, 'content', version_uri)
52
- expect(audit.pid).to eq(f.id)
52
+ expect(audit.generic_file_id).to eq(f.id)
53
53
  expect(audit.version).to eq(version_uri)
54
54
 
55
55
  audit = ChecksumAuditLog.get_audit_log(f.id, 'content', 'v2')
56
- expect(audit.pid).to eq(f.id)
56
+ expect(audit.generic_file_id).to eq(f.id)
57
57
  expect(audit.version).to eq('v2')
58
58
 
59
59
  audit = ChecksumAuditLog.get_audit_log(f.id, 'thumbnail', 'v1')
60
- expect(audit.pid).to eq(f.id)
60
+ expect(audit.generic_file_id).to eq(f.id)
61
61
  expect(audit.version).to eq('v1')
62
62
 
63
63
  end
@@ -19,22 +19,17 @@ describe Collection, :type => :model do
19
19
  end
20
20
 
21
21
  describe "::bytes" do
22
-
22
+ subject { @collection.bytes }
23
23
  context "with no items" do
24
- specify "is zero" do
25
- @collection.save
26
- expect(@collection.bytes).to eq 0
27
- end
24
+ before { @collection.save }
25
+ it { is_expected.to eq 0 }
28
26
  end
29
27
 
30
- context "with characterized GenericFiles" do
31
- let(:file) { mock_model GenericFile, file_size: ["50"] }
32
- before do
33
- allow(@collection).to receive(:members).and_return([file, file])
34
- end
35
- specify "is the sum of the files' sizes" do
36
- expect(@collection.bytes).to eq 100
37
- end
28
+ context "with two 50 byte files" do
29
+ let(:bitstream) { double("content", size: "50")}
30
+ let(:file) { mock_model GenericFile, content: bitstream }
31
+ before { allow(@collection).to receive(:members).and_return([file, file]) }
32
+ it { is_expected.to eq 100 }
38
33
  end
39
34
 
40
35
  end