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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +1 -1
- data/History.md +280 -0
- data/README.md +180 -98
- data/SUFIA_VERSION +1 -1
- data/app/assets/images/site_images/collection-icon.svg +168 -0
- data/app/assets/javascripts/sufia/uploader.js +7 -4
- data/app/assets/stylesheets/sufia.css.scss +1 -1
- data/app/assets/stylesheets/sufia/_collections.scss +33 -13
- data/app/assets/stylesheets/sufia/_file-show.scss +24 -0
- data/app/assets/stylesheets/sufia/_settings.scss +4 -0
- data/app/controllers/concerns/sufia/catalog.rb +1 -11
- data/app/controllers/concerns/sufia/collections_controller_behavior.rb +13 -15
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +3 -1
- data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +2 -1
- data/app/controllers/concerns/sufia/files_controller/local_ingest_behavior.rb +1 -0
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +4 -1
- data/app/controllers/concerns/sufia/homepage_controller.rb +4 -11
- data/app/controllers/concerns/sufia/my_controller_behavior.rb +3 -21
- data/app/controllers/concerns/sufia/transfers_controller_behavior.rb +6 -6
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +7 -7
- data/app/controllers/my/collections_controller.rb +1 -8
- data/app/controllers/my/files_controller.rb +1 -1
- data/app/controllers/my/highlights_controller.rb +1 -9
- data/app/controllers/my/shares_controller.rb +1 -8
- data/app/helpers/generic_file_helper.rb +4 -0
- data/app/helpers/sufia/sufia_helper_behavior.rb +3 -3
- data/app/helpers/sufia_url_helper.rb +9 -0
- data/app/jobs/content_depositor_change_event_job.rb +5 -5
- data/app/search_builders/sufia/search_builder.rb +50 -0
- data/app/views/_user_util_links.html.erb +6 -4
- data/app/views/batch_edits/_check_all.html.erb +1 -1
- data/app/views/catalog/index.html.erb +3 -30
- data/app/views/collections/_media_display.html.erb +1 -1
- data/app/views/collections/_show_descriptions.html.erb +1 -1
- data/app/views/collections/_show_document_list_row.html.erb +2 -2
- data/app/views/dashboard/_index_partials/_heading_actions.html.erb +16 -12
- data/app/views/generic_files/_browse_everything.html.erb +3 -1
- data/app/views/generic_files/_local_file_import.html.erb +0 -1
- data/app/views/generic_files/_multiple_upload.html.erb +0 -1
- data/app/views/generic_files/_show_descriptions.html.erb +6 -11
- data/app/views/generic_files/_show_details.html.erb +41 -65
- data/app/views/generic_files/new.html.erb +1 -0
- data/app/views/generic_files/show.html.erb +2 -1
- data/app/views/generic_files/upload/_alerts.html.erb +5 -13
- data/app/views/homepage/_home_header.html.erb +6 -7
- data/app/views/my/_index_partials/_list_collections.html.erb +1 -1
- data/app/views/my/index.html.erb +2 -2
- data/app/views/records/edit_fields/_resource_type.html.erb +1 -1
- data/config/initializers/sufia_events.rb +2 -3
- data/config/locales/sufia.en.yml +11 -2
- data/lib/generators/sufia/install_generator.rb +5 -1
- data/lib/generators/sufia/templates/catalog_controller.rb +3 -5
- data/lib/generators/sufia/upgrade600_generator.rb +26 -0
- data/lib/sufia/version.rb +1 -1
- data/spec/actors/generic_file/actor_spec.rb +14 -0
- data/spec/controllers/collections_controller_spec.rb +19 -2
- data/spec/controllers/dashboard_controller_spec.rb +43 -12
- data/spec/controllers/generic_files_controller_spec.rb +24 -1
- data/spec/controllers/transfers_controller_spec.rb +4 -4
- data/spec/controllers/users_controller_spec.rb +18 -4
- data/spec/fixtures/spoken-text.m4a +0 -0
- data/spec/helpers/dashboard_helper_spec.rb +1 -1
- data/spec/helpers/sufia_url_helper_spec.rb +15 -0
- data/spec/inputs/select_with_help_input_spec.rb +15 -0
- data/spec/jobs/{active_fedora_pid_based_job_spec.rb → active_fedora_id_based_job_spec.rb} +2 -2
- data/spec/jobs/audit_job_spec.rb +2 -2
- data/spec/lib/sufia/id_service_spec.rb +8 -8
- data/spec/lib/sufia/user_stat_importer_spec.rb +9 -1
- data/spec/models/ability_spec.rb +7 -4
- data/spec/models/checksum_audit_log_spec.rb +10 -10
- data/spec/models/collection_spec.rb +8 -13
- data/spec/models/fits_datastream_spec.rb +17 -0
- data/spec/models/generic_file_spec.rb +9 -1
- data/spec/models/proxy_deposit_request_spec.rb +15 -3
- data/spec/services/generic_file_audit_service_spec.rb +1 -1
- data/spec/support/features.rb +1 -0
- data/spec/support/rake_output.rb +20 -0
- data/spec/tasks/rake_spec.rb +58 -0
- data/spec/test_app_templates/Gemfile.extra +3 -1
- data/spec/views/batch/edit.html.erb_spec.rb +6 -2
- data/spec/views/catalog/index.html.erb_spec.rb +1 -1
- data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +6 -2
- data/spec/views/dashboard/index_spec.rb +49 -1
- data/spec/views/generic_file/_browse_everything.html.erb_spec.rb +9 -0
- data/spec/views/generic_file/show.html.erb_spec.rb +13 -8
- data/spec/views/homepage/_home_header.html.erb_spec.rb +26 -0
- data/spec/views/users/_user_util_links.html.erb_spec.rb +20 -0
- data/spec/views/users/show.html.erb_spec.rb +1 -1
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +1 -1
- data/sufia-models/app/jobs/active_fedora_id_based_job.rb +22 -0
- data/sufia-models/app/jobs/active_fedora_pid_based_job.rb +5 -20
- data/sufia-models/app/jobs/audit_job.rb +5 -6
- data/sufia-models/app/jobs/characterize_job.rb +1 -1
- data/sufia-models/app/jobs/create_derivatives_job.rb +1 -1
- data/sufia-models/app/jobs/import_url_job.rb +2 -2
- data/sufia-models/app/models/batch.rb +18 -4
- data/sufia-models/app/models/checksum_audit_log.rb +2 -2
- data/sufia-models/app/models/concerns/sufia/ability.rb +7 -1
- data/sufia-models/app/models/concerns/sufia/collection_behavior.rb +1 -1
- data/sufia-models/app/models/concerns/sufia/generic_file/full_text_indexing.rb +23 -14
- data/sufia-models/app/models/concerns/sufia/generic_file/proxy_deposit.rb +1 -1
- data/sufia-models/app/models/datastreams/fits_datastream.rb +1 -36
- data/sufia-models/app/models/proxy_deposit_request.rb +6 -6
- data/sufia-models/app/services/sufia/generic_file_audit_service.rb +1 -1
- data/sufia-models/app/services/sufia/generic_file_indexing_service.rb +0 -1
- data/sufia-models/app/services/sufia/id_service.rb +2 -3
- data/sufia-models/app/services/sufia/noid.rb +1 -1
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +1 -1
- data/sufia-models/lib/generators/sufia/models/templates/migrations/change_audit_log_pid_to_generic_file_id.rb +5 -0
- data/sufia-models/lib/generators/sufia/models/templates/migrations/change_proxy_deposit_request_pid_to_generic_file_id.rb +5 -0
- data/sufia-models/lib/generators/sufia/models/upgrade600_generator.rb +21 -0
- data/sufia-models/lib/sufia/models/stats/user_stat_importer.rb +20 -1
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia-models/lib/tasks/batch_cleanup.rake +19 -0
- data/sufia-models/lib/tasks/migrate.rake +21 -0
- data/sufia-models/lib/tasks/sufia-models_tasks.rake +55 -38
- data/sufia-models/sufia-models.gemspec +1 -1
- data/sufia.gemspec +2 -2
- metadata +44 -38
- data/app/assets/images/site_images/bg_body.png +0 -0
- data/app/assets/images/site_images/bg_breadcrumbs.png +0 -0
- data/app/assets/images/site_images/bg_button1.png +0 -0
- data/app/assets/images/site_images/bg_button2.png +0 -0
- data/app/assets/images/site_images/bg_button3.png +0 -0
- data/app/assets/images/site_images/bg_content.png +0 -0
- data/app/assets/images/site_images/bg_content2.png +0 -0
- data/app/assets/images/site_images/bg_footer.png +0 -0
- data/app/assets/images/site_images/bg_masthead.png +0 -0
- data/app/assets/images/site_images/bg_search_field.png +0 -0
- data/app/assets/images/site_images/bg_search_header.png +0 -0
- data/app/assets/images/site_images/bg_signin.png +0 -0
- data/app/assets/images/site_images/carrot_blue.png +0 -0
- data/app/assets/images/site_images/carrot_yellow.png +0 -0
- data/app/assets/images/site_images/icon_arrow2_up.png +0 -0
- data/app/assets/images/site_images/icon_arrow3_down.png +0 -0
- data/app/assets/images/site_images/icon_arrow3_right.png +0 -0
- data/app/assets/images/site_images/icon_arrow_down.png +0 -0
- data/app/assets/images/site_images/icons_sprite.png +0 -0
- data/app/assets/images/site_images/logo_psuss_footer.png +0 -0
- data/app/views/catalog/_edit_partials/_default.html.erb +0 -55
- data/spec/support/fedora_conf/fedora.fcfg +0 -953
@@ -118,4 +118,21 @@ describe FitsDatastream, type: :model, unless: $in_travis do
|
|
118
118
|
expect(@myfile.full_text.content).to eq("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nMicrosoft Word - sample.pdf.docx\n\n\n \n \n\n \n\n \n\n \n\nThis PDF file was created using CutePDF. \n\nwww.cutepdf.com")
|
119
119
|
end
|
120
120
|
end
|
121
|
+
|
122
|
+
describe "m4a" do
|
123
|
+
before do
|
124
|
+
@myfile = GenericFile.new(id: 'foo123')
|
125
|
+
@myfile.add_file(File.open(fixture_path + '/spoken-text.m4a', 'rb').read, path: 'content', original_name: 'spoken-text.m4a', mime_type: 'audio/mp4a-latm')
|
126
|
+
@myfile.apply_depositor_metadata('agw13')
|
127
|
+
# characterize method saves
|
128
|
+
@myfile.characterize
|
129
|
+
@myfile.reload
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should return expected content for full text" do
|
133
|
+
expect(@myfile.full_text.content).to eq("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nLavf56.15.102")
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
|
121
138
|
end
|
@@ -8,6 +8,14 @@ describe GenericFile, :type => :model do
|
|
8
8
|
@file.apply_depositor_metadata(user.user_key)
|
9
9
|
end
|
10
10
|
|
11
|
+
context "when it is initialized" do
|
12
|
+
it "has empty arrays for all the properties" do
|
13
|
+
subject.attributes.each do |k,v|
|
14
|
+
expect(Array(v)).to eq([])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
11
19
|
describe "created for someone (proxy)" do
|
12
20
|
before do
|
13
21
|
@transfer_to = FactoryGirl.find_or_create(:jill)
|
@@ -265,7 +273,7 @@ describe GenericFile, :type => :model do
|
|
265
273
|
|
266
274
|
describe "to_solr" do
|
267
275
|
before do
|
268
|
-
allow(subject).to receive(:id).and_return('
|
276
|
+
allow(subject).to receive(:id).and_return('stubbed_id')
|
269
277
|
subject.part_of = ["Arabiana"]
|
270
278
|
subject.contributor = ["Mohammad"]
|
271
279
|
subject.creator = ["Allah"]
|
@@ -13,7 +13,7 @@ describe ProxyDepositRequest, type: :model do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
subject do
|
16
|
-
ProxyDepositRequest.new(
|
16
|
+
ProxyDepositRequest.new(generic_file_id: file.id, sending_user: sender,
|
17
17
|
receiving_user: receiver, sender_comment: "please take this")
|
18
18
|
end
|
19
19
|
|
@@ -78,7 +78,7 @@ describe ProxyDepositRequest, type: :model do
|
|
78
78
|
subject.transfer_to = receiver.user_key
|
79
79
|
subject.save!
|
80
80
|
proxy_request = receiver.proxy_deposit_requests.first
|
81
|
-
expect(proxy_request.
|
81
|
+
expect(proxy_request.generic_file_id).to eq(file.id)
|
82
82
|
expect(proxy_request.sending_user).to eq(sender)
|
83
83
|
end
|
84
84
|
end
|
@@ -92,12 +92,24 @@ describe ProxyDepositRequest, type: :model do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
context 'when the file is already being transferred' do
|
95
|
+
let(:subject2) {ProxyDepositRequest.new(generic_file_id: file.id, sending_user: sender, receiving_user: receiver2, sender_comment: 'please take this')}
|
96
|
+
|
95
97
|
it 'raises an error' do
|
96
98
|
subject.save!
|
97
|
-
subject2 = ProxyDepositRequest.new(pid: file.id, sending_user: sender, receiving_user: receiver2, sender_comment: 'please take this')
|
98
99
|
expect(subject2).not_to be_valid
|
99
100
|
expect(subject2.errors[:open_transfer]).to eq(['must close open transfer on the file before creating a new one'])
|
100
101
|
end
|
102
|
+
|
103
|
+
context 'when the first transfer is closed' do
|
104
|
+
before do
|
105
|
+
subject.status = 'accepted'
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'does not raise an error' do
|
109
|
+
subject.save!
|
110
|
+
expect(subject2).to be_valid
|
111
|
+
end
|
112
|
+
end
|
101
113
|
end
|
102
114
|
end
|
103
115
|
end
|
@@ -52,7 +52,7 @@ describe Sufia::GenericFileAuditService do
|
|
52
52
|
|
53
53
|
context "when no audit is pasing" do
|
54
54
|
before do
|
55
|
-
ChecksumAuditLog.create!(pass: 1,
|
55
|
+
ChecksumAuditLog.create!(pass: 1, generic_file_id: f.id, version: f.content.versions.first.label, dsid: 'content')
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should report that audits have not been run" do
|
data/spec/support/features.rb
CHANGED
@@ -7,6 +7,7 @@ require File.expand_path('../locations', __FILE__)
|
|
7
7
|
require File.expand_path('../poltergeist', __FILE__)
|
8
8
|
require File.expand_path('../cleaner', __FILE__)
|
9
9
|
require File.expand_path('../statistic_helper', __FILE__)
|
10
|
+
require File.expand_path('../rake_output', __FILE__)
|
10
11
|
|
11
12
|
RSpec.configure do |config|
|
12
13
|
config.include Features::SessionHelpers, type: :feature
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module RakeOutput
|
2
|
+
|
3
|
+
# saves original $stdout in variable
|
4
|
+
# set $stdout as local instance of StringIO
|
5
|
+
# yields to code execution
|
6
|
+
# returns the local instance of StringIO
|
7
|
+
# resets $stdout to original value
|
8
|
+
def capture_stdout
|
9
|
+
out = StringIO.new
|
10
|
+
$stdout = out
|
11
|
+
yield
|
12
|
+
return out.string
|
13
|
+
ensure
|
14
|
+
$stdout = STDOUT
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.include RakeOutput
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
describe "Rake tasks" do
|
5
|
+
|
6
|
+
describe "sufia:empty_batches" do
|
7
|
+
before do
|
8
|
+
load File.expand_path("../../../sufia-models/lib/tasks/batch_cleanup.rake", __FILE__)
|
9
|
+
Rake::Task.define_task(:environment)
|
10
|
+
end
|
11
|
+
after { Rake::Task["sufia:empty_batches"].reenable }
|
12
|
+
subject { capture_stdout { Rake::Task["sufia:empty_batches"].invoke } }
|
13
|
+
|
14
|
+
context "without an empty batch" do
|
15
|
+
it { is_expected.to be_empty }
|
16
|
+
end
|
17
|
+
|
18
|
+
context "with an empty batch" do
|
19
|
+
before { Batch.create("empty-batch") }
|
20
|
+
it { is_expected.to start_with("empty-batch contains no files - to delete, rerun with the remove option") }
|
21
|
+
|
22
|
+
describe "removing the empty batch" do
|
23
|
+
subject { capture_stdout { Rake::Task["sufia:empty_batches"].invoke("remove") } }
|
24
|
+
it { is_expected.to start_with("empty-batch contains no files - deleted") }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "sufia:migrate" do
|
30
|
+
let(:namespaced_id) { "sufia:123" }
|
31
|
+
let(:corrected_id) { "123" }
|
32
|
+
before do
|
33
|
+
load File.expand_path("../../../sufia-models/lib/tasks/migrate.rake", __FILE__)
|
34
|
+
Rake::Task.define_task(:environment)
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "deleting the namespace from ProxyDepositRequest#generic_file_id" do
|
38
|
+
let(:sender) { FactoryGirl.find_or_create(:jill) }
|
39
|
+
let(:receiver) { FactoryGirl.find_or_create(:archivist) }
|
40
|
+
before do
|
41
|
+
ProxyDepositRequest.create(generic_file_id: namespaced_id, sending_user: sender, receiving_user: receiver, sender_comment: "please take this")
|
42
|
+
Rake::Task["sufia:migrate:proxy_deposits"].invoke
|
43
|
+
end
|
44
|
+
subject { ProxyDepositRequest.first.generic_file_id }
|
45
|
+
it { is_expected.to eql corrected_id }
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "deleting the namespace from ChecksumAuditLog#generic_file_id" do
|
49
|
+
before do
|
50
|
+
ChecksumAuditLog.create(generic_file_id: namespaced_id)
|
51
|
+
Rake::Task["sufia:migrate:audit_logs"].invoke
|
52
|
+
end
|
53
|
+
subject { ChecksumAuditLog.first.generic_file_id }
|
54
|
+
it { is_expected.to eql corrected_id }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -1,8 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'batch/edit.html.erb' do
|
4
|
-
let(:batch) {
|
5
|
-
let(:generic_file)
|
4
|
+
let(:batch) { Batch.create }
|
5
|
+
let(:generic_file) do
|
6
|
+
GenericFile.new(title: ['some title']).tap do |f|
|
7
|
+
f.apply_depositor_metadata("bob")
|
8
|
+
end
|
9
|
+
end
|
6
10
|
let(:form) { Sufia::Forms::BatchEditForm.new(generic_file) }
|
7
11
|
|
8
12
|
before do
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe 'catalog/index.html.erb' do
|
4
4
|
|
5
|
-
let(:collection) { Collection
|
5
|
+
let(:collection) { stub_model(Collection, title: 'collection1', id: 'abc123') }
|
6
6
|
let(:doc) { SolrDocument.new(collection.to_solr) }
|
7
7
|
|
8
8
|
before do
|
@@ -15,13 +15,17 @@ describe 'catalog/_sort_and_per_page.html.erb', :type => :view do
|
|
15
15
|
allow(view).to receive(:blacklight_config).and_return(CatalogController.blacklight_config)
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
18
|
it 'appears on page without error' do
|
21
19
|
render
|
22
20
|
page = Capybara::Node::Simple.new(rendered)
|
23
21
|
expect(page).to have_selector('span.page_entries', count: 1)
|
24
22
|
expect(rendered).to include("<strong>4</strong> - <strong>6</strong> of <strong>20</strong>")
|
25
23
|
end
|
24
|
+
|
25
|
+
it 'displays the relevance option for sorting' do
|
26
|
+
render
|
27
|
+
page = Capybara::Node::Simple.new(rendered)
|
28
|
+
expect(rendered).to include("<li><a href=\"/catalog?sort=score+desc%2C+date_uploaded_dtsi+desc\">relevance</a></li>")
|
29
|
+
end
|
26
30
|
|
27
31
|
end
|
@@ -15,11 +15,17 @@ describe "dashboard/index.html.erb", :type => :view do
|
|
15
15
|
allow(@user).to receive(:total_file_views).and_return(1)
|
16
16
|
allow(@user).to receive(:total_file_downloads).and_return(3)
|
17
17
|
allow(controller).to receive(:current_user).and_return(@user)
|
18
|
+
@ability = instance_double("Ability")
|
19
|
+
allow(controller).to receive(:current_ability).and_return(@ability)
|
20
|
+
allow(@ability).to receive(:can?).with(:create, GenericFile).and_return(can_create_file)
|
21
|
+
allow(@ability).to receive(:can?).with(:create, Collection).and_return(can_create_collection)
|
18
22
|
allow(view).to receive(:number_of_files).and_return("15")
|
19
23
|
allow(view).to receive(:number_of_collections).and_return("3")
|
20
24
|
assign(:activity, [])
|
21
25
|
assign(:notifications, [])
|
22
26
|
end
|
27
|
+
let(:can_create_file) { true }
|
28
|
+
let(:can_create_collection) { true }
|
23
29
|
|
24
30
|
describe "heading" do
|
25
31
|
|
@@ -36,6 +42,19 @@ describe "dashboard/index.html.erb", :type => :view do
|
|
36
42
|
expect(@heading).to include "Hello, Charles Francis Xavier"
|
37
43
|
end
|
38
44
|
|
45
|
+
context "when the user can't create files" do
|
46
|
+
let(:can_create_file) { false }
|
47
|
+
it "should not display the upload button" do
|
48
|
+
expect(@heading).not_to have_link("Upload", sufia.new_generic_file_path)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
context "when the user can't create collections" do
|
52
|
+
let(:can_create_collection) { false }
|
53
|
+
it "should not display the create collection button" do
|
54
|
+
expect(@heading).not_to have_link("Create Collection", collections.new_collection_path)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
39
58
|
end
|
40
59
|
|
41
60
|
describe "sidebar" do
|
@@ -94,7 +113,6 @@ describe "dashboard/index.html.erb", :type => :view do
|
|
94
113
|
end
|
95
114
|
|
96
115
|
context "with notifications" do
|
97
|
-
|
98
116
|
before do
|
99
117
|
assign(:notifications, FactoryGirl.create(:user_with_mail).mailbox.inbox)
|
100
118
|
end
|
@@ -115,7 +133,37 @@ describe "dashboard/index.html.erb", :type => :view do
|
|
115
133
|
render
|
116
134
|
expect(rendered).to include "Single File 1"
|
117
135
|
end
|
136
|
+
end
|
118
137
|
|
138
|
+
context 'with transfers' do
|
139
|
+
let(:user) { FactoryGirl.find_or_create(:jill) }
|
140
|
+
let(:another_user) { FactoryGirl.find_or_create(:archivist) }
|
141
|
+
let(:title1) { 'foobar' }
|
142
|
+
let(:title2) { 'bazquux' }
|
143
|
+
|
144
|
+
before do
|
145
|
+
GenericFile.new(title: [title1]).tap do |f|
|
146
|
+
f.apply_depositor_metadata(another_user.user_key)
|
147
|
+
f.save!
|
148
|
+
f.request_transfer_to(user)
|
149
|
+
end
|
150
|
+
GenericFile.new(title: [title2]).tap do |f|
|
151
|
+
f.apply_depositor_metadata(user.user_key)
|
152
|
+
f.save!
|
153
|
+
f.request_transfer_to(another_user)
|
154
|
+
end
|
155
|
+
allow(controller).to receive(:current_user).and_return(user)
|
156
|
+
assign(:incoming, ProxyDepositRequest.where(receiving_user_id: user.id))
|
157
|
+
assign(:outgoing, ProxyDepositRequest.where(sending_user_id: user.id))
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'renders received and sent transfer requests' do
|
161
|
+
render
|
162
|
+
expect(rendered).not_to include "You haven't received any file transfers requests"
|
163
|
+
expect(rendered).not_to include "You haven't transferred any files"
|
164
|
+
expect(rendered).to include title1
|
165
|
+
expect(rendered).to include title2
|
166
|
+
end
|
119
167
|
end
|
120
168
|
|
121
169
|
context "without activities and notifications" do
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'generic_files/_browse_everything.html.erb', :type => :view do
|
4
|
+
it 'shows user timing warning' do
|
5
|
+
render
|
6
|
+
page = Capybara::Node::Simple.new(rendered)
|
7
|
+
expect(page).to have_selector('div.alert-success', text: /Please note that if you upload a large number of files/i , count: 1)
|
8
|
+
end
|
9
|
+
end
|
@@ -16,7 +16,7 @@ describe 'generic_files/show.html.erb', :type => :view do
|
|
16
16
|
depositor: depositor.user_key,
|
17
17
|
audit_stat: 1,
|
18
18
|
title: ['My Title'],
|
19
|
-
description: ['Lorem ipsum lorem ipsum.'],
|
19
|
+
description: ['Lorem ipsum lorem ipsum. http://my.link.com'],
|
20
20
|
tag: ['bacon', 'sausage', 'eggs'],
|
21
21
|
rights: ['http://example.org/rights/1'],
|
22
22
|
based_near: ['Seattle, WA, US'],
|
@@ -55,6 +55,16 @@ describe 'generic_files/show.html.erb', :type => :view do
|
|
55
55
|
h1 = doc.xpath("//h1[@class='visibility']").text
|
56
56
|
expect(h1).to start_with 'My Title'
|
57
57
|
end
|
58
|
+
|
59
|
+
it 'shows the description' do
|
60
|
+
d1 = doc.xpath("//p[@class='genericfile_description']").text
|
61
|
+
expect(d1).to start_with 'Lorem ipsum'
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'shows links in the description' do
|
65
|
+
a1 = doc.xpath("//p[@class='genericfile_description']/a").text
|
66
|
+
expect(a1).to start_with 'http://my.link.com'
|
67
|
+
end
|
58
68
|
end
|
59
69
|
|
60
70
|
describe 'schema.org' do
|
@@ -68,11 +78,6 @@ describe 'generic_files/show.html.erb', :type => :view do
|
|
68
78
|
# set itemtype to CreativeWork
|
69
79
|
expect(item.type).to eq('http://schema.org/CreativeWork')
|
70
80
|
|
71
|
-
# set title as name
|
72
|
-
expect(item.properties['name'].first).to eq('My Title')
|
73
|
-
|
74
|
-
expect(item.properties['description'].first).to eq('Lorem ipsum lorem ipsum.')
|
75
|
-
|
76
81
|
# tag as keywords
|
77
82
|
expect(item.properties['keywords']).to include('bacon', 'sausage', 'eggs')
|
78
83
|
|
@@ -168,7 +173,7 @@ describe 'generic_files/show.html.erb', :type => :view do
|
|
168
173
|
expect(tag.attribute('content').value).to eq('My Title')
|
169
174
|
|
170
175
|
tag = doc.xpath("//meta[@property='og:description']")
|
171
|
-
expect(tag.attribute('content').value).to eq('Lorem ipsum lorem ipsum.')
|
176
|
+
expect(tag.attribute('content').value).to eq('Lorem ipsum lorem ipsum. http://my.link.com')
|
172
177
|
|
173
178
|
tag = doc.xpath("//meta[@property='og:image']")
|
174
179
|
expect(tag.attribute('content').value).to eq('http://test.host/downloads/123?file=thumbnail')
|
@@ -265,7 +270,7 @@ describe 'generic_files/show.html.erb', :type => :view do
|
|
265
270
|
render
|
266
271
|
end
|
267
272
|
it "should display the visibility badge" do
|
268
|
-
expect(rendered).to include('<span class="label label-danger" title="'+t('sufia.visibility.
|
273
|
+
expect(rendered).to include('<span class="label label-danger" title="'+t('sufia.visibility.private_title_attr')+'">'+t('sufia.visibility.private')+'</span></a>')
|
269
274
|
end
|
270
275
|
end
|
271
276
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "homepage/_home_header.html.erb" do
|
4
|
+
let(:groups) { [] }
|
5
|
+
let(:ability) { instance_double("Ability") }
|
6
|
+
describe "share your work button" do
|
7
|
+
before do
|
8
|
+
allow(controller).to receive(:current_ability).and_return(ability)
|
9
|
+
allow(ability).to receive(:can?).with(:view_share_work, GenericFile).and_return(can_view_share_work)
|
10
|
+
stub_template "homepage/_marketing.html.erb" => "marketing"
|
11
|
+
render
|
12
|
+
end
|
13
|
+
context "when the user can view" do
|
14
|
+
let(:can_view_share_work) { true }
|
15
|
+
it "should display" do
|
16
|
+
expect(rendered).to have_content t("sufia.share_button")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
context "when the user can't view" do
|
20
|
+
let(:can_view_share_work) { false }
|
21
|
+
it "should not display" do
|
22
|
+
expect(rendered).not_to have_content t("sufia.share_button")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -6,9 +6,12 @@ describe '/_user_util_links.html.erb', :type => :view do
|
|
6
6
|
before do
|
7
7
|
allow(view).to receive(:user_signed_in?).and_return(true)
|
8
8
|
allow(view).to receive(:current_user).and_return(stub_model(User, user_key: 'userX'))
|
9
|
+
allow(view).to receive(:can?).with(:create, GenericFile).and_return(can_create_file)
|
9
10
|
assign :notify_number, 8
|
10
11
|
end
|
11
12
|
|
13
|
+
let(:can_create_file) { true }
|
14
|
+
|
12
15
|
it 'should have link to dashboard' do
|
13
16
|
render
|
14
17
|
page = Capybara::Node::Simple.new(rendered)
|
@@ -21,5 +24,22 @@ describe '/_user_util_links.html.erb', :type => :view do
|
|
21
24
|
expect(page).to have_link('my profile', href: '/users/userX')
|
22
25
|
end
|
23
26
|
|
27
|
+
describe "upload button" do
|
28
|
+
before do
|
29
|
+
render
|
30
|
+
end
|
31
|
+
context "when the user can create generic files" do
|
32
|
+
it "should have a link to upload" do
|
33
|
+
expect(rendered).to have_link('upload', href: '/files/new')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
context "when the user can't create generic files" do
|
37
|
+
let(:can_create_file) { false }
|
38
|
+
it "should not have a link to upload" do
|
39
|
+
expect(rendered).not_to have_link('upload')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
24
44
|
end
|
25
45
|
|