sufia 6.0.0.beta1 → 6.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +12 -2
- data/Gemfile +10 -1
- data/History.md +21 -0
- data/SUFIA_VERSION +1 -1
- data/app/assets/images/orcid.png +0 -0
- data/app/assets/javascripts/sufia.js +1 -1
- data/app/assets/javascripts/sufia/batch_edit.js +36 -54
- data/app/assets/javascripts/sufia/edit_metadata.js +10 -11
- data/app/assets/javascripts/sufia/permissions.js +2 -26
- data/app/assets/stylesheets/sufia.css.scss +10 -2
- data/app/assets/stylesheets/sufia/_batch-edit.scss +8 -6
- data/app/assets/stylesheets/sufia/_dashboard.scss +10 -0
- data/app/assets/stylesheets/sufia/_settings.scss +1 -0
- data/app/assets/stylesheets/sufia/_styles.scss +5 -3
- data/app/controllers/batch_controller.rb +9 -6
- data/app/controllers/batch_edits_controller.rb +2 -2
- data/app/controllers/collections_controller.rb +19 -3
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +30 -29
- data/app/controllers/concerns/sufia/breadcrumbs.rb +8 -3
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +19 -7
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +14 -2
- data/app/controllers/single_use_links_viewer_controller.rb +5 -1
- data/app/forms/sufia/forms/batch_edit_form.rb +6 -0
- data/app/forms/sufia/forms/collection_edit_form.rb +17 -0
- data/app/forms/sufia/forms/generic_file_edit_form.rb +16 -0
- data/app/helpers/generic_file_helper.rb +3 -47
- data/app/helpers/sufia/permissions_helper.rb +29 -0
- data/app/helpers/sufia/sufia_helper_behavior.rb +11 -0
- data/app/inputs/multi_value_with_help_input.rb +8 -0
- data/app/inputs/select_with_help_input.rb +3 -0
- data/app/inputs/select_with_modal_help_input.rb +36 -0
- data/app/inputs/with_help_icon.rb +32 -0
- data/app/models/concerns/sufia/solr_document_behavior.rb +1 -1
- data/app/presenters/sufia/collection_presenter.rb +29 -0
- data/app/presenters/sufia/generic_file_presenter.rb +14 -0
- data/app/presenters/sufia/presenter_renderer.rb +53 -0
- data/app/views/batch/_metadata.html.erb +10 -44
- data/app/views/batch/_more_metadata.html.erb +3 -2
- data/app/views/batch/edit.html.erb +2 -2
- data/app/views/batch_edits/edit.html.erb +13 -17
- data/app/views/collections/_form.html.erb +5 -5
- data/app/views/collections/_show_descriptions.html.erb +8 -10
- data/app/views/collections/edit.html.erb +8 -9
- data/app/views/collections/edit_fields/_description.html.erb +1 -2
- data/app/views/dashboard/_index_partials/_stats.html.erb +3 -3
- data/app/views/generic_files/_descriptions.html.erb +5 -8
- data/app/views/generic_files/_permission_form.html.erb +8 -17
- data/app/views/generic_files/_show_descriptions.html.erb +3 -4
- data/app/views/generic_files/edit.html.erb +1 -2
- data/app/views/generic_files/jq_upload.json.jbuilder +8 -0
- data/app/views/records/edit_fields/_default.html.erb +5 -10
- data/app/views/records/edit_fields/_description.html.erb +5 -10
- data/app/views/records/edit_fields/_resource_type.html.erb +2 -5
- data/app/views/records/edit_fields/_rights.html.erb +3 -9
- data/app/views/single_use_links_viewer/show.html.erb +10 -16
- data/app/views/users/_profile.html.erb +1 -2
- data/app/views/users/_user_info.html.erb +20 -3
- data/app/views/users/edit.html.erb +11 -2
- data/app/views/users/show.html.erb +1 -1
- data/config/locales/sufia.en.yml +46 -26
- data/config/routes.rb +1 -1
- data/lib/generators/sufia/install_generator.rb +4 -0
- data/lib/sufia.rb +4 -0
- data/lib/sufia/form_builder.rb +16 -0
- data/lib/sufia/version.rb +1 -1
- data/spec/actors/generic_file/actor_spec.rb +1 -2
- data/spec/controllers/batch_controller_spec.rb +16 -48
- data/spec/controllers/batch_edits_controller_spec.rb +27 -16
- data/spec/controllers/collections_controller_spec.rb +81 -61
- data/spec/controllers/generic_files_controller_spec.rb +17 -2
- data/spec/controllers/users_controller_spec.rb +13 -3
- data/spec/features/collection_spec.rb +93 -88
- data/spec/features/users_spec.rb +1 -1
- data/spec/forms/collection_edit_form_spec.rb +20 -0
- data/spec/forms/generic_file_edit_form_spec.rb +26 -0
- data/spec/helpers/generic_file_helper_spec.rb +33 -7
- data/spec/helpers/permissions_helper_spec.rb +21 -0
- data/spec/inputs/multi_value_with_help_input_spec.rb +25 -0
- data/spec/inputs/select_with_modal_help_input_spec.rb +21 -0
- data/spec/jobs/batch_update_job_spec.rb +11 -14
- data/spec/lib/sufia/breadcrumbs_spec.rb +46 -8
- data/spec/models/generic_file_spec.rb +0 -13
- data/spec/models/user_spec.rb +23 -0
- data/spec/presenters/presenter_renderer_spec.rb +19 -0
- data/spec/presenters/sufia/generic_file_presenter_spec.rb +12 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/support/input_support.rb +12 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/spec/views/batch/edit.html.erb_spec.rb +13 -23
- data/spec/views/batch_edits/edit.html.erb_spec.rb +19 -0
- data/spec/views/collections/_form.html.erb_spec.rb +26 -28
- data/spec/views/collections/_show_descriptions.html.erb_spec.rb +15 -9
- data/spec/views/dashboard/index_spec.rb +2 -2
- data/spec/views/generic_file/_permission_form.html.erb_spec.rb +23 -0
- data/spec/views/generic_file/edit.html.erb_spec.rb +5 -0
- data/spec/views/generic_file/show.html.erb_spec.rb +5 -0
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +1 -1
- data/sufia-models/app/jobs/batch_update_job.rb +5 -5
- data/sufia-models/app/models/batch.rb +7 -3
- data/sufia-models/app/models/concerns/sufia/collection.rb +7 -25
- data/sufia-models/app/models/concerns/sufia/generic_file.rb +0 -1
- data/sufia-models/app/models/concerns/sufia/generic_file/export.rb +2 -2
- data/sufia-models/app/models/concerns/sufia/generic_file/indexing.rb +4 -13
- data/sufia-models/app/models/concerns/sufia/generic_file/metadata.rb +1 -1
- data/sufia-models/app/models/concerns/sufia/user.rb +24 -17
- data/sufia-models/app/models/sufia/orcid_validator.rb +8 -0
- data/sufia-models/app/services/sufia/generic_file_indexing_service.rb +13 -0
- data/sufia-models/app/services/sufia/indexing_service.rb +15 -0
- data/sufia-models/lib/generators/sufia/models/abstract_migration_generator.rb +30 -0
- data/sufia-models/lib/generators/sufia/models/cached_stats_generator.rb +3 -47
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +11 -31
- data/sufia-models/lib/generators/sufia/models/orcid_field_generator.rb +19 -0
- data/sufia-models/lib/generators/sufia/models/proxies_generator.rb +2 -31
- data/sufia-models/lib/generators/sufia/models/templates/config/redis.yml +3 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +3 -0
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_orcid_to_users.rb +5 -0
- data/sufia-models/lib/generators/sufia/models/upgrade400_generator.rb +2 -33
- data/sufia-models/lib/generators/sufia/models/user_stats_generator.rb +31 -0
- data/sufia-models/lib/sufia/models/engine.rb +1 -0
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia-models/sufia-models.gemspec +5 -5
- data/sufia.gemspec +2 -3
- metadata +49 -39
- data/app/assets/javascripts/sufia/multiForm.js +0 -67
- data/app/helpers/records_helper.rb +0 -4
- data/app/helpers/sufia/records_helper_behavior.rb +0 -68
- data/app/views/batch_edits/update_edit.js.erb +0 -5
- data/app/views/collections/_edit_descriptions.html.erb +0 -18
- data/app/views/collections/edit_fields/_title.html.erb +0 -3
- data/app/views/generic_files/_field_form.html.erb +0 -20
- data/app/views/records/_edit_field.html.erb +0 -22
- data/app/views/records/edit_fields/_suffix.html.erb +0 -10
- data/app/views/records/edit_fields/_type.html.erb +0 -8
- data/app/views/users/_social_media_info.html.erb +0 -20
- data/spec/helpers/records_helper_spec.rb +0 -102
- data/spec/models/generic_file/web_form_spec.rb +0 -35
- data/sufia-models/app/models/concerns/sufia/generic_file/accessible_attributes.rb +0 -87
- data/sufia-models/app/models/concerns/sufia/generic_file/web_form.rb +0 -62
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'MultiValueWithHelpInput', type: :input do
|
4
|
+
subject { input_for file, field, { as: :multi_value_with_help, required: true } }
|
5
|
+
let(:file) { GenericFile.new }
|
6
|
+
|
7
|
+
context "when the field has a translation" do
|
8
|
+
let(:field) { :language }
|
9
|
+
it 'renders help icon' do
|
10
|
+
expect(subject).to have_selector('a[rel=popover][data-original-title=Language]')
|
11
|
+
expect(subject).to have_selector('a[rel=popover][data-content="The language of the file content."]')
|
12
|
+
expect(subject).to have_selector('i.help-icon')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "when the field doesn't have a translation" do
|
17
|
+
let(:field) { :date_modified }
|
18
|
+
it 'renders help icon' do
|
19
|
+
expect(subject).to have_selector('a[rel=popover][data-original-title="Date modified"]')
|
20
|
+
expect(subject).to have_selector('a[rel=popover][data-content="Date modified"]')
|
21
|
+
expect(subject).to have_selector('i.help-icon')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'SelectWithModalHelpInput', type: :input do
|
4
|
+
subject { input_for file, :rights, options }
|
5
|
+
let(:file) { GenericFile.new }
|
6
|
+
let(:base_options) { { as: :select_with_modal_help, required: true, collection: Sufia.config.cc_licenses } }
|
7
|
+
let(:options) { base_options }
|
8
|
+
|
9
|
+
context "when a blank is requested" do
|
10
|
+
let(:options) { base_options.merge(include_blank: true) }
|
11
|
+
it 'renders a blank option' do
|
12
|
+
expect(subject).to have_selector 'select option[value=""]'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "when a blank is not requested" do
|
17
|
+
it 'has no blanks' do
|
18
|
+
expect(subject).to have_selector 'select option:first-child', text: 'Attribution 3.0 United States'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -20,24 +20,21 @@ describe BatchUpdateJob do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "#run" do
|
23
|
-
let(:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
tag: ['']
|
28
|
-
},
|
29
|
-
title: { file.id => ['File One'], file2.id => ['File Two'] },
|
30
|
-
id: batch.id,
|
31
|
-
controller: 'batch',
|
32
|
-
action: 'update'
|
33
|
-
}.with_indifferent_access
|
23
|
+
let(:title) { { file.id => ['File One'], file2.id => ['File Two'] }}
|
24
|
+
let(:metadata) do
|
25
|
+
{ read_groups_string: '', read_users_string: 'archivist1, archivist2',
|
26
|
+
tag: [''] }.with_indifferent_access
|
34
27
|
end
|
35
28
|
|
29
|
+
let(:visibility) { nil }
|
30
|
+
|
31
|
+
let(:job) { BatchUpdateJob.new(user.user_key, batch.id, title, metadata, visibility) }
|
32
|
+
|
36
33
|
context "with a failing update" do
|
37
34
|
it "should check permissions for each file before updating" do
|
38
35
|
expect_any_instance_of(User).to receive(:can?).with(:edit, file).and_return(false)
|
39
36
|
expect_any_instance_of(User).to receive(:can?).with(:edit, file2).and_return(false)
|
40
|
-
|
37
|
+
job.run
|
41
38
|
expect(user.mailbox.inbox[0].messages[0].subject).to eq("Batch upload permission denied")
|
42
39
|
expect(user.mailbox.inbox[0].messages[0].body).to include("data-content")
|
43
40
|
expect(user.mailbox.inbox[0].messages[0].body).to include("These files")
|
@@ -54,7 +51,7 @@ describe BatchUpdateJob do
|
|
54
51
|
expect(Sufia.queue).to receive(:push).with(s1).once
|
55
52
|
expect(ContentUpdateEventJob).to receive(:new).with(file2.id, user.user_key).and_return(s2)
|
56
53
|
expect(Sufia.queue).to receive(:push).with(s2).once
|
57
|
-
|
54
|
+
job.run
|
58
55
|
expect(user.mailbox.inbox[0].messages[0].subject).to eq("Batch upload complete")
|
59
56
|
expect(user.mailbox.inbox[0].messages[0].body).to include("data-content")
|
60
57
|
expect(user.mailbox.inbox[0].messages[0].body).to include("These files")
|
@@ -64,7 +61,7 @@ describe BatchUpdateJob do
|
|
64
61
|
describe "updates metadata" do
|
65
62
|
before do
|
66
63
|
allow(Sufia.queue).to receive(:push)
|
67
|
-
|
64
|
+
job.run
|
68
65
|
end
|
69
66
|
|
70
67
|
it "should update the titles" do
|
@@ -54,25 +54,63 @@ describe Sufia::Breadcrumbs do
|
|
54
54
|
expect(crumbs.trail_from_referer).to eql([[I18n.t('sufia.bread_crumb.search_results'), referer]])
|
55
55
|
end
|
56
56
|
end
|
57
|
-
context "when coming
|
57
|
+
context "when coming places other than the catalog" do
|
58
58
|
before do
|
59
|
-
allow(crumbs.request).to receive(:referer).and_return("http://...
|
59
|
+
allow(crumbs.request).to receive(:referer).and_return("http://...blargh/")
|
60
60
|
allow(crumbs).to receive(:user_signed_in?) { true }
|
61
|
+
allow(crumbs).to receive(:action_name).and_return("view")
|
61
62
|
end
|
62
63
|
specify "the trail goes back to the user's files" do
|
63
64
|
allow(crumbs).to receive(:controller_name).and_return("my/files")
|
64
|
-
|
65
|
-
expect(crumbs.
|
65
|
+
crumbs.trail_from_referer
|
66
|
+
expect(crumbs.trail.first).to eql([I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path])
|
67
|
+
expect(crumbs.trail.last).to eql([I18n.t('sufia.dashboard.my.files'), sufia.dashboard_files_path])
|
66
68
|
end
|
67
69
|
specify "the trail goes back to the user's collections" do
|
68
70
|
allow(crumbs).to receive(:controller_name).and_return("my/collections")
|
69
|
-
|
70
|
-
expect(crumbs.
|
71
|
+
crumbs.trail_from_referer
|
72
|
+
expect(crumbs.trail.first).to eql([I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path])
|
73
|
+
expect(crumbs.trail.last).to eql([I18n.t('sufia.dashboard.my.collections'), sufia.dashboard_collections_path])
|
71
74
|
end
|
72
75
|
specify "the trail goes back to the user's files when on the batch edit page" do
|
73
76
|
allow(crumbs).to receive(:controller_name).and_return("batch_edit")
|
74
|
-
|
75
|
-
expect(crumbs.
|
77
|
+
crumbs.trail_from_referer
|
78
|
+
expect(crumbs.trail.first).to eql([I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path])
|
79
|
+
expect(crumbs.trail.last).to eql([I18n.t('sufia.dashboard.my.files'), sufia.dashboard_files_path])
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "when editing a file" do
|
84
|
+
before do
|
85
|
+
allow(crumbs.request).to receive(:referer).and_return("http://...blargh/")
|
86
|
+
allow(crumbs).to receive(:user_signed_in?) { true }
|
87
|
+
allow(crumbs).to receive(:action_name).and_return("edit")
|
88
|
+
allow(crumbs).to receive(:params).and_return({"id" => "abc123"})
|
89
|
+
allow(crumbs).to receive(:controller_name).and_return("generic_files")
|
90
|
+
end
|
91
|
+
|
92
|
+
specify "the trail goes back to the user's files and the browse view" do
|
93
|
+
crumbs.trail_from_referer
|
94
|
+
expect(crumbs.trail.first).to eql([I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path])
|
95
|
+
expect(crumbs.trail[1]).to eql([I18n.t('sufia.dashboard.my.files'), sufia.dashboard_files_path])
|
96
|
+
expect(crumbs.trail.last).to eql([I18n.t('sufia.generic_file.browse_view'), sufia.generic_file_path("abc123")])
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "when viewing file statistics" do
|
101
|
+
before do
|
102
|
+
allow(crumbs.request).to receive(:referer).and_return("http://...blargh/")
|
103
|
+
allow(crumbs).to receive(:user_signed_in?) { true }
|
104
|
+
allow(crumbs).to receive(:action_name).and_return("stats")
|
105
|
+
allow(crumbs).to receive(:params).and_return({"id" => "abc123"})
|
106
|
+
allow(crumbs).to receive(:controller_name).and_return("generic_files")
|
107
|
+
end
|
108
|
+
|
109
|
+
specify "the trail goes back to the user's files and the browse view" do
|
110
|
+
crumbs.trail_from_referer
|
111
|
+
expect(crumbs.trail.first).to eql([I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path])
|
112
|
+
expect(crumbs.trail[1]).to eql([I18n.t('sufia.dashboard.my.files'), sufia.dashboard_files_path])
|
113
|
+
expect(crumbs.trail.last).to eql([I18n.t('sufia.generic_file.browse_view'), sufia.generic_file_path("abc123")])
|
76
114
|
end
|
77
115
|
end
|
78
116
|
end
|
@@ -528,19 +528,6 @@ describe GenericFile, :type => :model do
|
|
528
528
|
end
|
529
529
|
end
|
530
530
|
|
531
|
-
describe "#remove_blank_assertions" do
|
532
|
-
before do
|
533
|
-
subject.title = ["foo"]
|
534
|
-
subject.description = [""]
|
535
|
-
subject.remove_blank_assertions
|
536
|
-
end
|
537
|
-
|
538
|
-
it "should only change title" do
|
539
|
-
expect(subject.title).to eq(["foo"])
|
540
|
-
expect(subject.description).to be_empty
|
541
|
-
end
|
542
|
-
end
|
543
|
-
|
544
531
|
describe "to_solr record" do
|
545
532
|
let(:depositor) { 'jcoyne' }
|
546
533
|
subject do
|
data/spec/models/user_spec.rb
CHANGED
@@ -20,6 +20,29 @@ describe User, :type => :model do
|
|
20
20
|
expect(user).to respond_to(:facebook_handle)
|
21
21
|
expect(user).to respond_to(:googleplus_handle)
|
22
22
|
expect(user).to respond_to(:linkedin_handle)
|
23
|
+
expect(user).to respond_to(:orcid)
|
24
|
+
end
|
25
|
+
describe 'ORCID validation and normalization' do
|
26
|
+
it 'saves when a valid bare ORCID is supplied' do
|
27
|
+
user.orcid = '0000-0000-1111-2222'
|
28
|
+
expect(user).to be_valid
|
29
|
+
expect(user.save).to be true
|
30
|
+
end
|
31
|
+
it 'saves when a valid ORCID URI is supplied' do
|
32
|
+
user.orcid = 'http://orcid.org/0000-0000-1111-2222'
|
33
|
+
expect(user).to be_valid
|
34
|
+
expect(user.save).to be true
|
35
|
+
end
|
36
|
+
it 'normalizes bare ORCIDs to URIs' do
|
37
|
+
user.orcid = '0000-0000-1111-2222'
|
38
|
+
user.save
|
39
|
+
expect(user.orcid).to eq 'http://orcid.org/0000-0000-1111-2222'
|
40
|
+
end
|
41
|
+
it 'marks bad ORCIDs as invalid' do
|
42
|
+
user.orcid = '000-000-111-222'
|
43
|
+
expect(user).not_to be_valid
|
44
|
+
expect(user.save).to be false
|
45
|
+
end
|
23
46
|
end
|
24
47
|
|
25
48
|
describe "#to_param" do
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::PresenterRenderer, type: :view do
|
4
|
+
let(:generic_file) { GenericFile.new }
|
5
|
+
let(:presenter) { Sufia::GenericFilePresenter.new(generic_file) }
|
6
|
+
let(:renderer) { Sufia::PresenterRenderer.new(presenter, view) }
|
7
|
+
|
8
|
+
describe "#label" do
|
9
|
+
context "of a field with a translation" do
|
10
|
+
subject { renderer.label(:date_created) }
|
11
|
+
it { is_expected.to eq 'Date Created' }
|
12
|
+
end
|
13
|
+
|
14
|
+
context "of a field without a translation" do
|
15
|
+
subject { renderer.label(:date_uploaded) }
|
16
|
+
it { is_expected.to eq 'Date uploaded' }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::GenericFilePresenter do
|
4
|
+
describe "#terms" do
|
5
|
+
it "should return a list" do
|
6
|
+
expect(described_class.terms).to eq([:resource_type, :title,
|
7
|
+
:creator, :contributor, :description, :tag, :rights, :publisher,
|
8
|
+
:date_created, :subject, :language, :identifier, :based_near,
|
9
|
+
:related_url])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -20,6 +20,7 @@ require 'equivalent-xml'
|
|
20
20
|
require 'equivalent-xml/rspec_matchers'
|
21
21
|
require 'database_cleaner'
|
22
22
|
require 'support/features'
|
23
|
+
require 'support/input_support'
|
23
24
|
require 'byebug' unless ENV['TRAVIS']
|
24
25
|
|
25
26
|
if ENV['COVERAGE']
|
@@ -124,6 +125,10 @@ RSpec.configure do |config|
|
|
124
125
|
|
125
126
|
config.include Warden::Test::Helpers, type: :feature
|
126
127
|
config.after(:each, type: :feature) { Warden.test_reset! }
|
128
|
+
|
129
|
+
config.include InputSupport, type: :input
|
130
|
+
config.include Capybara::RSpecMatchers, type: :input
|
131
|
+
|
127
132
|
config.infer_spec_type_from_file_location!
|
128
133
|
end
|
129
134
|
|
@@ -1,48 +1,38 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'batch/edit.html.erb'
|
4
|
-
let(
|
5
|
-
|
6
|
-
}
|
7
|
-
|
8
|
-
let(:content) { double('content', versions: [], mimeType: 'application/pdf') }
|
9
|
-
let(:generic_file) {
|
10
|
-
stub_model(GenericFile, id: '321', noid: '321', depositor: 'bob', rights: [''])
|
11
|
-
}
|
12
|
-
|
3
|
+
describe 'batch/edit.html.erb' do
|
4
|
+
let(:batch) { stub_model(Batch, id: '123') }
|
5
|
+
let(:generic_file) { stub_model(GenericFile, id: nil, depositor: 'bob', rights: ['']) }
|
6
|
+
let(:form) { Sufia::Forms::BatchEditForm.new(generic_file) }
|
13
7
|
|
14
8
|
before do
|
15
|
-
allow(generic_file).to receive(:content).and_return(content)
|
16
9
|
allow(controller).to receive(:current_user).and_return(stub_model(User))
|
17
|
-
controller.request.path_parameters[:id] = "123"
|
18
10
|
assign :batch, batch
|
19
|
-
assign :
|
11
|
+
assign :form, form
|
20
12
|
render
|
21
|
-
@page = Capybara::Node::Simple.new(rendered)
|
22
13
|
end
|
23
14
|
|
24
15
|
it "should draw tooltip for visibility" do
|
25
|
-
expect(
|
26
|
-
expect(@page).to have_selector("a#generic_file_visibility_help", count: 1)
|
16
|
+
expect(rendered).to have_selector "span#visibility_tooltip a i.help-icon"
|
27
17
|
end
|
28
18
|
|
29
19
|
it "should draw tooltip for share_with" do
|
30
|
-
expect(
|
31
|
-
expect(@page).to have_selector("a#generic_file_share_with_help", count: 1)
|
20
|
+
expect(rendered).to have_selector "span#share_with_tooltip a i.help-icon"
|
32
21
|
end
|
33
22
|
|
34
23
|
context "rights" do
|
35
24
|
it "should have a modal" do
|
36
|
-
expect(
|
25
|
+
expect(rendered).to have_selector("div#rightsModal .modal-dialog .modal-content")
|
37
26
|
end
|
38
27
|
|
39
28
|
it "should allow setting many rights" do
|
40
|
-
expect(
|
29
|
+
expect(rendered).to have_selector('select#generic_file_rights[name="generic_file[rights][]"]')
|
41
30
|
end
|
42
|
-
|
31
|
+
|
43
32
|
it "should not have an empty rights element" do
|
44
|
-
|
45
|
-
|
33
|
+
page = Capybara::Node::Simple.new(rendered)
|
34
|
+
page.all('select#generic_file_rights option').each do |elem|
|
35
|
+
expect(elem.value).to_not be_empty
|
46
36
|
end
|
47
37
|
end
|
48
38
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'batch_edits/edit.html.erb' do
|
4
|
+
let(:generic_file) { stub_model(GenericFile, id: nil, depositor: 'bob', rights: ['']) }
|
5
|
+
|
6
|
+
before do
|
7
|
+
allow(controller).to receive(:current_user).and_return(stub_model(User))
|
8
|
+
assign :names, ['title 1', 'title 2']
|
9
|
+
assign :terms, [:description, :rights]
|
10
|
+
assign :generic_file, generic_file
|
11
|
+
render
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should draw tooltip for description" do
|
15
|
+
expect(rendered).to have_selector ".generic_file_description a i.help-icon"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
@@ -1,34 +1,32 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'collections/_form.html.erb'
|
4
|
-
|
5
|
-
|
6
|
-
creator: ['the creator'])}
|
3
|
+
describe 'collections/_form.html.erb' do
|
4
|
+
let(:collection) { Collection.new(title: 'the title', description: 'the description',
|
5
|
+
creator: ['the creator'])}
|
7
6
|
|
8
|
-
|
9
|
-
controller.request.path_parameters[:id] = 'j12345'
|
10
|
-
collection.initialize_fields
|
11
|
-
assign(:collection, collection)
|
12
|
-
end
|
7
|
+
let(:collection_form) { Sufia::Forms::CollectionEditForm.new(collection) }
|
13
8
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
9
|
+
before do
|
10
|
+
controller.request.path_parameters[:id] = 'j12345'
|
11
|
+
assign(:form, collection_form)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should draw the metadata fields for collection" do
|
15
|
+
render
|
16
|
+
expect(rendered).to have_selector("input#collection_title")
|
17
|
+
expect(rendered).to_not have_selector("div#additional_title.multi_value")
|
18
|
+
expect(rendered).to have_selector("input#collection_creator.multi_value")
|
19
|
+
expect(rendered).to have_selector("textarea#collection_description")
|
20
|
+
expect(rendered).to have_selector("input#collection_contributor")
|
21
|
+
expect(rendered).to have_selector("input#collection_tag")
|
22
|
+
expect(rendered).to have_selector("input#collection_subject")
|
23
|
+
expect(rendered).to have_selector("input#collection_publisher")
|
24
|
+
expect(rendered).to have_selector("input#collection_date_created")
|
25
|
+
expect(rendered).to have_selector("input#collection_language")
|
26
|
+
expect(rendered).to have_selector("input#collection_identifier")
|
27
|
+
expect(rendered).to have_selector("input#collection_based_near")
|
28
|
+
expect(rendered).to have_selector("input#collection_related_url")
|
29
|
+
expect(rendered).to have_selector("select#collection_rights")
|
30
|
+
expect(rendered).to have_selector("select#collection_resource_type")
|
33
31
|
end
|
34
32
|
end
|