sufia 7.0.0.beta4 → 7.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/.rubocop.yml +0 -1
- data/.rubocop_todo.yml +1 -2
- data/.travis.yml +1 -0
- data/Gemfile +18 -9
- data/README.md +23 -3
- data/app/assets/javascripts/sufia.js +4 -1
- data/app/assets/javascripts/sufia/app.js +15 -3
- data/app/assets/javascripts/sufia/autocomplete.es6 +51 -0
- data/app/assets/javascripts/sufia/autocomplete/language.es6 +25 -0
- data/app/assets/javascripts/sufia/autocomplete/location.es6 +24 -0
- data/app/assets/javascripts/sufia/autocomplete/subject.es6 +26 -0
- data/app/assets/javascripts/sufia/batch_edit.js +8 -5
- data/app/assets/javascripts/sufia/permissions/control.es6 +7 -3
- data/app/assets/javascripts/sufia/save_work/required_fields.es6 +10 -4
- data/app/assets/javascripts/sufia/save_work/save_work_control.es6 +14 -4
- data/app/assets/stylesheets/sufia/_fixedsticky.scss +23 -21
- data/app/assets/stylesheets/sufia/_form-progress.scss +16 -7
- data/app/assets/stylesheets/sufia/_header.scss +2 -1
- data/app/assets/stylesheets/sufia/_settings.scss +4 -0
- data/app/controllers/api/items_controller.rb +2 -2
- data/app/controllers/api/zotero_controller.rb +1 -1
- data/app/controllers/citations_controller.rb +0 -2
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +7 -7
- data/app/controllers/concerns/sufia/batch_uploads_controller_behavior.rb +9 -3
- data/app/controllers/concerns/sufia/singular_subresource_controller.rb +6 -1
- data/app/controllers/concerns/sufia/transfers_controller_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +3 -3
- data/app/controllers/concerns/sufia/works_controller_behavior.rb +11 -4
- data/app/controllers/my/highlights_controller.rb +1 -1
- data/app/forms/sufia/forms/batch_edit_form.rb +10 -6
- data/app/forms/sufia/forms/batch_upload_form.rb +2 -2
- data/app/forms/sufia/forms/collection_form.rb +4 -0
- data/app/forms/sufia/forms/work_form.rb +4 -0
- data/app/helpers/sufia/blacklight_override.rb +0 -20
- data/app/helpers/sufia/collections_helper.rb +12 -0
- data/app/helpers/sufia/sufia_helper_behavior.rb +84 -56
- data/app/jobs/batch_create_job.rb +18 -2
- data/app/jobs/content_depositor_change_event_job.rb +13 -6
- data/app/jobs/create_work_job.rb +6 -2
- data/app/models/batch_upload_item.rb +15 -0
- data/app/models/concerns/sufia/ability.rb +7 -4
- data/app/models/concerns/sufia/user.rb +0 -11
- data/app/models/concerns/sufia/work_behavior.rb +1 -0
- data/app/models/concerns/sufia/works/featured.rb +23 -0
- data/app/models/file_download_stat.rb +9 -12
- data/app/models/file_view_stat.rb +5 -15
- data/app/models/proxy_deposit_request.rb +11 -7
- data/app/models/sufia/statistic.rb +65 -0
- data/app/models/work_view_stat.rb +5 -16
- data/app/presenters/file_usage.rb +3 -4
- data/app/presenters/sufia/file_set_presenter.rb +1 -3
- data/app/presenters/sufia/trophy_presenter.rb +28 -0
- data/app/presenters/sufia/user_profile_presenter.rb +1 -1
- data/app/presenters/work_usage.rb +5 -4
- data/app/search_builders/deposit_search_builder.rb +4 -3
- data/app/search_builders/parent_collection_search_builder.rb +1 -1
- data/app/services/sufia/collection_member_service.rb +1 -1
- data/app/services/sufia/user_stat_importer.rb +11 -6
- data/app/views/_controls.html.erb +11 -9
- data/app/views/batch_edits/edit.html.erb +8 -2
- data/app/views/catalog/_index_list_default.html.erb +2 -1
- data/app/views/curation_concerns/base/_form_metadata.html.erb +1 -1
- data/app/views/curation_concerns/base/_form_progress.html.erb +1 -1
- data/app/views/curation_concerns/base/_form_relationships.html.erb +1 -1
- data/app/views/curation_concerns/base/_guts4form.html.erb +6 -2
- data/app/views/curation_concerns/base/_items.html.erb +1 -1
- data/app/views/curation_concerns/base/edit.html.erb +1 -1
- data/app/views/curation_concerns/base/new.html.erb +1 -1
- data/app/views/curation_concerns/file_sets/_permission.html.erb +5 -1
- data/app/views/curation_concerns/file_sets/media_display/_default.html.erb +1 -1
- data/app/views/curation_concerns/file_sets/show.html.erb +1 -1
- data/app/views/dashboard/_index_partials/_heading_actions.html.erb +1 -1
- data/app/views/{error → errors}/404.html.erb +0 -0
- data/app/views/records/edit_fields/_based_near.html.erb +8 -0
- data/app/views/records/edit_fields/_language.html.erb +8 -0
- data/app/views/records/edit_fields/_subject.html.erb +8 -0
- data/app/views/stats/work.html.erb +1 -1
- data/app/views/sufia/batch_uploads/_form.html.erb +1 -1
- data/app/views/sufia/homepage/_home_header.html.erb +1 -1
- data/app/views/sufia/homepage/_sortable_featured.html.erb +1 -1
- data/app/views/transfers/new.html.erb +3 -1
- data/app/views/users/_contributions.html.erb +1 -1
- data/config/locales/sufia.en.yml +3 -2
- data/config/routes.rb +0 -7
- data/lib/generators/sufia/install_generator.rb +0 -24
- data/lib/generators/sufia/templates/catalog_controller.rb +4 -3
- data/lib/generators/sufia/templates/config/sufia.rb +4 -2
- data/lib/generators/sufia/upgrade700_generator.rb +7 -9
- data/lib/generators/sufia/work_generator.rb +56 -0
- data/lib/sufia.rb +4 -1
- data/lib/sufia/arkivo/actor.rb +1 -1
- data/lib/sufia/configuration.rb +15 -3
- data/lib/sufia/engine.rb +1 -10
- data/lib/sufia/version.rb +1 -1
- data/spec/controllers/api/items_controller_spec.rb +20 -7
- data/spec/controllers/sufia/batch_uploads_controller_spec.rb +4 -3
- data/spec/controllers/transfers_controller_spec.rb +3 -11
- data/spec/controllers/users_controller_spec.rb +2 -1
- data/spec/features/batch_edit_spec.rb +17 -2
- data/spec/forms/sufia/forms/batch_edit_form_spec.rb +2 -0
- data/spec/forms/sufia/forms/batch_upload_form_spec.rb +1 -1
- data/spec/helpers/blacklight_helper_spec.rb +36 -26
- data/spec/helpers/{generic_work_helper_spec.rb → sufia/collections_helper_spec.rb} +1 -1
- data/spec/helpers/sufia_helper_spec.rb +70 -32
- data/spec/javascripts/autocomplete_spec.js.coffee +7 -7
- data/spec/javascripts/save_work_spec.js +20 -20
- data/spec/lib/sufia/configuration_spec.rb +30 -0
- data/spec/lib/sufia/user_stat_importer_spec.rb +21 -36
- data/spec/models/file_download_stat_spec.rb +8 -8
- data/spec/models/file_view_stat_spec.rb +8 -8
- data/spec/models/generic_work_spec.rb +24 -0
- data/spec/models/proxy_deposit_request_spec.rb +2 -4
- data/spec/models/sufia/ability_spec.rb +7 -13
- data/spec/models/user_spec.rb +0 -14
- data/spec/models/work_view_stat_spec.rb +22 -8
- data/spec/presenters/sufia/file_usage_spec.rb +0 -4
- data/spec/presenters/sufia/trophy_presenter_spec.rb +46 -0
- data/spec/presenters/sufia/user_profile_presenter_spec.rb +4 -1
- data/spec/presenters/sufia/work_usage_spec.rb +8 -17
- data/spec/routing/route_spec.rb +0 -6
- data/spec/spec_helper.rb +8 -2
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +4 -0
- data/spec/views/batch_edits/edit.html.erb_spec.rb +8 -2
- data/spec/views/catalog/_index_list_default.html.erb_spec.rb +8 -6
- data/spec/views/curation_concerns/base/_form.html.erb_spec.rb +3 -0
- data/spec/views/curation_concerns/file_sets/_permission.html.erb_spec.rb +16 -0
- data/spec/views/curation_concerns/file_sets/show.html.erb_spec.rb +0 -2
- data/spec/views/records/edit_fields/_based_near.html.erb_spec.rb +20 -0
- data/spec/views/records/edit_fields/_language.html.erb_spec.rb +20 -0
- data/spec/views/records/edit_fields/_subject.html.erb_spec.rb +20 -0
- data/spec/views/{homepage → sufia/homepage}/_announcement.html.erb_spec.rb +0 -0
- data/spec/views/{homepage → sufia/homepage}/_featured_works.html.erb_spec.rb +0 -0
- data/spec/views/{homepage → sufia/homepage}/_home_header.html.erb_spec.rb +0 -0
- data/spec/views/sufia/homepage/_sortable_featured.html.erb_spec.rb +21 -0
- data/spec/views/users/edit.html.erb_spec.rb +5 -5
- data/spec/views/users/show.html.erb_spec.rb +5 -3
- data/sufia.gemspec +4 -3
- data/tasks/noid.rake +2 -2
- data/tasks/sufia-dev.rake +1 -1
- metadata +73 -68
- data/app/assets/javascripts/sufia/edit_metadata.js +0 -87
- data/app/controllers/authorities_controller.rb +0 -19
- data/app/helpers/generic_work_helper.rb +0 -10
- data/app/helpers/sufia_url_helper.rb +0 -14
- data/app/models/concerns/sufia/file_stat_utils.rb +0 -33
- data/app/models/concerns/sufia/work_stat_utils.rb +0 -33
- data/app/models/geo_names_resource.rb +0 -18
- data/app/models/local_authority.rb +0 -101
- data/app/models/local_authority_entry.rb +0 -3
- data/app/models/subject_local_authority_entry.rb +0 -2
- data/app/views/curation_concerns/generic_works/_generic_work.html.erb +0 -3
- data/app/views/error/401.html.erb +0 -18
- data/app/views/error/500.html.erb +0 -9
- data/app/views/error/single_use_error.html.erb +0 -19
- data/lib/generators/sufia/geonames_username_config_generator.rb +0 -20
- data/spec/controllers/authorities_controller_spec.rb +0 -18
- data/spec/fixtures/cities15000.tsv +0 -149
- data/spec/fixtures/genreForms.nt +0 -471
- data/spec/fixtures/lexvo.rdf +0 -3108
- data/spec/helpers/sufia_url_helper_spec.rb +0 -18
- data/spec/models/geo_names_resource_spec.rb +0 -30
- data/spec/models/local_authority_spec.rb +0 -108
- data/vendor/assets/javascripts/almond.js +0 -430
@@ -1,32 +1,45 @@
|
|
1
1
|
RSpec.describe BlacklightHelper, type: :helper do
|
2
2
|
let(:blacklight_config) { CatalogController.blacklight_config }
|
3
3
|
let(:attributes) do
|
4
|
-
{ 'creator_tesim'
|
5
|
-
'depositor_tesim'
|
4
|
+
{ 'creator_tesim' => ['Justin', 'Joe'],
|
5
|
+
'depositor_tesim' => ['jcoyne@justincoyne.com'],
|
6
6
|
'proxy_depositor_ssim' => ['atz@stanford.edu'],
|
7
|
-
'description_tesim'
|
8
|
-
'date_uploaded_dtsi'
|
7
|
+
'description_tesim' => ['This links to http://example.com/ What about that?'],
|
8
|
+
'date_uploaded_dtsi' => '2013-03-14T00:00:00Z',
|
9
9
|
'rights_tesim' => ["http://creativecommons.org/publicdomain/zero/1.0/",
|
10
10
|
"http://creativecommons.org/publicdomain/mark/1.0/",
|
11
11
|
"http://www.europeana.eu/portal/rights/rr-r.html"],
|
12
|
-
'identifier_tesim'
|
13
|
-
'keyword_tesim'
|
14
|
-
'subject_tesim'
|
15
|
-
'contributor_tesim'
|
16
|
-
'publisher_tesim'
|
17
|
-
'based_near_tesim'
|
18
|
-
'language_tesim'
|
19
|
-
'resource_type_tesim'
|
12
|
+
'identifier_tesim' => ['65434567654345654'],
|
13
|
+
'keyword_tesim' => ['taco', 'mustache'],
|
14
|
+
'subject_tesim' => ['Awesome'],
|
15
|
+
'contributor_tesim' => ['Bird, Big'],
|
16
|
+
'publisher_tesim' => ['Penguin Random House'],
|
17
|
+
'based_near_tesim' => ['Pennsylvania'],
|
18
|
+
'language_tesim' => ['English'],
|
19
|
+
'resource_type_tesim' => ['Capstone Project'] }
|
20
20
|
end
|
21
21
|
|
22
22
|
let(:document) { SolrDocument.new(attributes) }
|
23
23
|
before do
|
24
24
|
allow(helper).to receive(:blacklight_config).and_return(blacklight_config)
|
25
|
+
allow(controller).to receive(:action_name).and_return('index')
|
25
26
|
end
|
26
27
|
|
27
28
|
describe "render_index_field_value" do
|
28
|
-
include SufiaHelper
|
29
|
-
|
29
|
+
include SufiaHelper # FIXME: isolate testing BlacklightHelper, not SufiaHelper. Also, this method is odd.
|
30
|
+
def search_action_path(stuff)
|
31
|
+
search_catalog_path(stuff)
|
32
|
+
end
|
33
|
+
|
34
|
+
subject { index_presenter(document).field_value field_name }
|
35
|
+
|
36
|
+
context "description_tesim" do
|
37
|
+
let(:field_name) { 'description_tesim' }
|
38
|
+
it do
|
39
|
+
pending 'need a different way to test description'
|
40
|
+
is_expected.to eq '<span itemprop="description">This links to <a href="http://example.com/"><span class="glyphicon glyphicon-new-window"></span> http://example.com/</a> What about that?</span>'
|
41
|
+
end
|
42
|
+
end
|
30
43
|
|
31
44
|
context "rights_tesim" do
|
32
45
|
let(:field_name) { 'rights_tesim' }
|
@@ -37,54 +50,51 @@ RSpec.describe BlacklightHelper, type: :helper do
|
|
37
50
|
let(:search_state) { Blacklight::SearchState.new(params, CatalogController.blacklight_config) }
|
38
51
|
before do
|
39
52
|
allow(controller).to receive(:search_state).and_return(search_state)
|
40
|
-
def search_action_path(stuff)
|
41
|
-
search_catalog_path(stuff)
|
42
|
-
end
|
43
53
|
end
|
44
54
|
|
45
55
|
context "keyword_tesim" do
|
46
56
|
let(:field_name) { 'keyword_tesim' }
|
47
|
-
it { is_expected.to eq
|
57
|
+
it { is_expected.to eq '<span itemprop="keywords"><a href="/catalog?f%5Bkeyword_sim%5D%5B%5D=taco">taco</a></span> and <span itemprop="keywords"><a href="/catalog?f%5Bkeyword_sim%5D%5B%5D=mustache">mustache</a></span>' }
|
48
58
|
end
|
49
59
|
|
50
60
|
context "subject_tesim" do
|
51
61
|
let(:field_name) { 'subject_tesim' }
|
52
|
-
it { is_expected.to eq
|
62
|
+
it { is_expected.to eq '<span itemprop="about"><a href="/catalog?f%5Bsubject_sim%5D%5B%5D=Awesome">Awesome</a></span>' }
|
53
63
|
end
|
54
64
|
|
55
65
|
context "creator_tesim" do
|
56
66
|
let(:field_name) { 'creator_tesim' }
|
57
|
-
it { is_expected.to eq
|
67
|
+
it { is_expected.to eq '<span itemprop="creator"><a href="/catalog?f%5Bcreator_sim%5D%5B%5D=Justin">Justin</a></span> and <span itemprop="creator"><a href="/catalog?f%5Bcreator_sim%5D%5B%5D=Joe">Joe</a></span>' }
|
58
68
|
end
|
59
69
|
|
60
70
|
context "contributor_tesim" do
|
61
71
|
let(:field_name) { 'contributor_tesim' }
|
62
|
-
it { is_expected.to eq
|
72
|
+
it { is_expected.to eq '<span itemprop="contributor"><a href="/catalog?f%5Bcontributor_sim%5D%5B%5D=Bird%2C+Big">Bird, Big</a></span>' }
|
63
73
|
end
|
64
74
|
|
65
75
|
context "publisher_tesim" do
|
66
76
|
let(:field_name) { 'publisher_tesim' }
|
67
|
-
it { is_expected.to eq
|
77
|
+
it { is_expected.to eq '<span itemprop="publisher"><a href="/catalog?f%5Bpublisher_sim%5D%5B%5D=Penguin+Random+House">Penguin Random House</a></span>' }
|
68
78
|
end
|
69
79
|
|
70
80
|
context "location_tesim" do
|
71
81
|
let(:field_name) { 'based_near_tesim' }
|
72
|
-
it { is_expected.to eq
|
82
|
+
it { is_expected.to eq '<span itemprop="contentLocation"><a href="/catalog?f%5Bbased_near_sim%5D%5B%5D=Pennsylvania">Pennsylvania</a></span>' }
|
73
83
|
end
|
74
84
|
|
75
85
|
context "language_tesim" do
|
76
86
|
let(:field_name) { 'language_tesim' }
|
77
|
-
it { is_expected.to eq
|
87
|
+
it { is_expected.to eq '<span itemprop="inLanguage"><a href="/catalog?f%5Blanguage_sim%5D%5B%5D=English">English</a></span>' }
|
78
88
|
end
|
79
89
|
|
80
90
|
context "resource_type_tesim" do
|
81
91
|
let(:field_name) { 'resource_type_tesim' }
|
82
|
-
it { is_expected.to eq
|
92
|
+
it { is_expected.to eq '<a href="/catalog?f%5Bresource_type_sim%5D%5B%5D=Capstone+Project">Capstone Project</a>' }
|
83
93
|
end
|
84
94
|
|
85
95
|
context "identifier_tesim" do
|
86
96
|
let(:field_name) { 'identifier_tesim' }
|
87
|
-
it { is_expected.to eq
|
97
|
+
it { is_expected.to eq '<a href="/catalog?identifier=%2265434567654345654%22&search_field=advanced">65434567654345654</a>' }
|
88
98
|
end
|
89
99
|
end
|
90
100
|
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
def new_state
|
2
|
+
Blacklight::SearchState.new({}, CatalogController.blacklight_config)
|
3
|
+
end
|
4
|
+
|
1
5
|
describe SufiaHelper, type: :helper do
|
2
6
|
describe "show_transfer_request_title" do
|
3
7
|
let(:sender) { create(:user) }
|
@@ -15,36 +19,48 @@ describe SufiaHelper, type: :helper do
|
|
15
19
|
end
|
16
20
|
end
|
17
21
|
|
18
|
-
|
19
|
-
def search_state_double(value)
|
20
|
-
double('SearchState', add_facet_params_and_redirect: { f: { vehicle_type_sim: [value] } })
|
21
|
-
end
|
22
|
-
let(:search_state_for_car) { search_state_double("car") }
|
23
|
-
let(:search_state_for_truck) { search_state_double("truck") }
|
22
|
+
context 'link helpers' do
|
24
23
|
before do
|
25
|
-
allow(helper).to receive(:blacklight_config).and_return(CatalogController.blacklight_config)
|
26
|
-
allow(helper).to receive(:search_state).exactly(2).times.and_return(search_state_for_car, search_state_for_truck)
|
27
24
|
allow(helper).to receive(:search_action_path) do |*args|
|
28
25
|
search_catalog_path(*args)
|
29
26
|
end
|
27
|
+
allow(helper).to receive(:search_state).and_return(new_state)
|
30
28
|
end
|
31
29
|
|
32
|
-
|
33
|
-
|
30
|
+
describe "#link_to_facet_list" do
|
31
|
+
context "with values" do
|
32
|
+
subject { helper.link_to_facet_list(['car', 'truck'], 'vehicle_type') }
|
33
|
+
it "joins the values" do
|
34
|
+
expect(helper).to receive(:search_state).exactly(2).times
|
35
|
+
car_link = search_catalog_path(f: { 'vehicle_type_sim' => ['car'] })
|
36
|
+
truck_link = search_catalog_path(f: { 'vehicle_type_sim' => ['truck'] })
|
37
|
+
expect(subject).to eq "<a href=\"#{car_link}\">car</a>, <a href=\"#{truck_link}\">truck</a>"
|
38
|
+
expect(subject).to be_a ActiveSupport::SafeBuffer
|
39
|
+
expect(subject).to be_html_safe
|
40
|
+
end
|
41
|
+
end
|
34
42
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
43
|
+
context "without values" do
|
44
|
+
subject { helper.link_to_facet_list([], 'vehicle_type') }
|
45
|
+
it "shows the default text" do
|
46
|
+
expect(subject).to eq "No value entered"
|
47
|
+
expect(subject).to be_a ActiveSupport::SafeBuffer
|
48
|
+
expect(subject).to be_html_safe
|
49
|
+
end
|
40
50
|
end
|
41
51
|
end
|
42
52
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
expect(
|
53
|
+
describe '#index_field_link' do
|
54
|
+
let(:args) { { config: { field_name: 'contributor' }, value: ['Fritz Lang', 'Mel Brooks'] } }
|
55
|
+
it 'requires 1 arg' do
|
56
|
+
expect { helper.index_field_link }.to raise_error ArgumentError
|
57
|
+
expect { helper.index_field_link({}, 'junk') }.to raise_error ArgumentError
|
58
|
+
end
|
59
|
+
subject { helper.index_field_link(args) }
|
60
|
+
it 'returns link' do
|
61
|
+
expect(subject).to be_html_safe
|
62
|
+
expect(subject).to eq '<a href="/catalog?contributor=%22Fritz+Lang%22&search_field=advanced">Fritz Lang</a>, ' \
|
63
|
+
+ '<a href="/catalog?contributor=%22Mel+Brooks%22&search_field=advanced">Mel Brooks</a>'
|
48
64
|
end
|
49
65
|
end
|
50
66
|
end
|
@@ -55,7 +71,6 @@ describe SufiaHelper, type: :helper do
|
|
55
71
|
before { allow(helper).to receive(:params).and_return(cq: 'foo') }
|
56
72
|
it { is_expected.to have_collection_search_parameters }
|
57
73
|
end
|
58
|
-
|
59
74
|
context "when cq is not set" do
|
60
75
|
before { allow(helper).to receive(:params).and_return(cq: '') }
|
61
76
|
it { is_expected.not_to have_collection_search_parameters }
|
@@ -70,12 +85,10 @@ describe SufiaHelper, type: :helper do
|
|
70
85
|
|
71
86
|
describe "#link_to_telephone" do
|
72
87
|
subject { helper.link_to_telephone(user) }
|
73
|
-
|
74
88
|
context "when user is set" do
|
75
89
|
let(:user) { mock_model(User, telephone: '867-5309') }
|
76
90
|
it { is_expected.to eq "<a href=\"wtai://wp/mc;867-5309\">867-5309</a>" }
|
77
91
|
end
|
78
|
-
|
79
92
|
context "when user is not set" do
|
80
93
|
let(:user) { nil }
|
81
94
|
it { is_expected.to be_nil }
|
@@ -167,7 +180,6 @@ describe SufiaHelper, type: :helper do
|
|
167
180
|
|
168
181
|
describe '#zotero_label' do
|
169
182
|
subject { helper }
|
170
|
-
|
171
183
|
it { is_expected.to respond_to(:zotero_label) }
|
172
184
|
end
|
173
185
|
|
@@ -198,16 +210,42 @@ describe SufiaHelper, type: :helper do
|
|
198
210
|
end
|
199
211
|
|
200
212
|
describe "#iconify_auto_link" do
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
213
|
+
let(:text) { 'Foo < http://www.example.com. & More text' }
|
214
|
+
let(:linked_text) { 'Foo < <a href="http://www.example.com"><span class="glyphicon glyphicon-new-window"></span> http://www.example.com</a>. & More text' }
|
215
|
+
let(:document) { SolrDocument.new(has_model_ssim: ['GenericWork'], id: 512, title_tesim: text, description_tesim: text) }
|
216
|
+
let(:blacklight_config) { CatalogController.blacklight_config }
|
217
|
+
before do
|
218
|
+
allow(controller).to receive(:action_name).and_return('index')
|
219
|
+
allow(helper).to receive(:blacklight_config).and_return(blacklight_config)
|
220
|
+
end
|
221
|
+
it "boring String argument" do
|
222
|
+
expect(helper.iconify_auto_link('no escapes or links necessary')).to eq 'no escapes or links necessary'
|
223
|
+
expect(helper.iconify_auto_link('no escapes or links necessary', false)).to eq 'no escapes or links necessary'
|
205
224
|
end
|
206
|
-
|
207
|
-
|
225
|
+
context "interesting String argument" do
|
226
|
+
subject { helper.iconify_auto_link(text) }
|
227
|
+
it "escapes input" do
|
228
|
+
expect(subject).to start_with('Foo <').and end_with('. & More text')
|
229
|
+
end
|
230
|
+
it "adds links" do
|
231
|
+
expect(subject).to include('<a href="http://www.example.com">')
|
232
|
+
end
|
233
|
+
it "adds icons" do
|
234
|
+
expect(subject).to include('class="glyphicon glyphicon-new-window"')
|
235
|
+
end
|
208
236
|
end
|
209
|
-
|
210
|
-
|
237
|
+
|
238
|
+
context "when using a hash argument" do
|
239
|
+
subject { helper.iconify_auto_link(arg) }
|
240
|
+
describe "auto-linking in the title" do
|
241
|
+
let(:arg) { { document: document, value: [text], config: blacklight_config.index_fields['title_tesim'], field: 'title_tesim' } }
|
242
|
+
it { is_expected.to eq(linked_text) }
|
243
|
+
end
|
244
|
+
|
245
|
+
describe "auto-linking in the description" do
|
246
|
+
let(:arg) { { document: document, value: [text], config: blacklight_config.index_fields['description_tesim'], field: 'description_tesim' } }
|
247
|
+
it { is_expected.to eq(linked_text) }
|
248
|
+
end
|
211
249
|
end
|
212
250
|
end
|
213
251
|
|
@@ -5,7 +5,7 @@ describe "auto complete", ->
|
|
5
5
|
@spy_on_json = spyOn($, 'getJSON').and.returnValue resp
|
6
6
|
|
7
7
|
#set up a key down event to trigger the auto complete
|
8
|
-
@typeEvent = $.Event(
|
8
|
+
@typeEvent = $.Event('keydown')
|
9
9
|
@typeEvent.keyCode = 70 # lower case f
|
10
10
|
|
11
11
|
#define the jasmine clock so we can control time
|
@@ -18,8 +18,8 @@ describe "auto complete", ->
|
|
18
18
|
describe "language", ->
|
19
19
|
beforeEach ->
|
20
20
|
# setup two inputs for us to attach auto complete to
|
21
|
-
setFixtures '<input class="generic_work_language" value="" id="generic_work_language" type="text" >
|
22
|
-
<input class="generic_work_language" value="" type="text">'
|
21
|
+
setFixtures '<input class="generic_work_language" value="" id="generic_work_language" type="text" data-autocomplete="language" data-autocomplete-url="foo">
|
22
|
+
<input class="generic_work_language" value="" type="text" data-autocomplete="language" data-autocomplete-url="foo">'
|
23
23
|
|
24
24
|
# run all Blacklight.onload functions
|
25
25
|
Blacklight.activate()
|
@@ -58,8 +58,8 @@ describe "auto complete", ->
|
|
58
58
|
describe "subject", ->
|
59
59
|
beforeEach ->
|
60
60
|
# setup two inputs for us to attach auto complete to
|
61
|
-
setFixtures '<input class="generic_work_subject" value="" id="generic_work_subject" type="text" >
|
62
|
-
<input class="generic_work_subject" value="" type="text">'
|
61
|
+
setFixtures '<input class="generic_work_subject" value="" id="generic_work_subject" type="text" data-autocomplete="subject" data-autocomplete-url="foo">
|
62
|
+
<input class="generic_work_subject" value="" type="text" data-autocomplete="subject" data-autocomplete-url="foo">'
|
63
63
|
|
64
64
|
# run all Blacklight.onload functions
|
65
65
|
Blacklight.activate()
|
@@ -99,8 +99,8 @@ describe "auto complete", ->
|
|
99
99
|
describe "location", ->
|
100
100
|
beforeEach ->
|
101
101
|
# setup two inputs for us to attach auto complete to
|
102
|
-
setFixtures '<input class="generic_work_based_near" value="" id="generic_work_based_near" type="text" >
|
103
|
-
<input class="generic_work_based_near" value="" type="text">'
|
102
|
+
setFixtures '<input class="generic_work_based_near" value="" id="generic_work_based_near" type="text" data-autocomplete="based_near" data-autocomplete-url="foo">
|
103
|
+
<input class="generic_work_based_near" value="" type="text" data-autocomplete="based_near" data-autocomplete-url="foo">'
|
104
104
|
|
105
105
|
# run all Blacklight.onload functions
|
106
106
|
Blacklight.activate()
|
@@ -6,17 +6,13 @@ describe("SaveWorkControl", function() {
|
|
6
6
|
check: function() { },
|
7
7
|
uncheck: function() { },
|
8
8
|
};
|
9
|
-
var form = {
|
10
|
-
on: function () { }
|
11
|
-
};
|
12
|
-
var element = {
|
13
|
-
size: function() { return 1 },
|
14
|
-
closest: function() { return form },
|
15
|
-
data: function() { return }
|
16
|
-
};
|
17
9
|
|
18
10
|
beforeEach(function() {
|
19
|
-
|
11
|
+
var fixture = setFixtures('<form id="edit_generic_work">' +
|
12
|
+
'<aside id="form-progress"><ul><li id="required-metadata"><li id="required-files"></ul>' +
|
13
|
+
'<input type="checkbox" name="agreement" id="agreement" value="1" required="required" checked="checked" />' +
|
14
|
+
'<input type="submit"></aside></form>');
|
15
|
+
target = new control.SaveWorkControl(fixture.find('#form-progress'));
|
20
16
|
target.requiredMetadata = mockCheckbox;
|
21
17
|
spyOn(mockCheckbox, 'check').and.stub();
|
22
18
|
spyOn(mockCheckbox, 'uncheck').and.stub();
|
@@ -80,25 +76,27 @@ describe("SaveWorkControl", function() {
|
|
80
76
|
uncheck: function() { },
|
81
77
|
};
|
82
78
|
var form_id = 'new_generic_work';
|
83
|
-
var form = {
|
84
|
-
attr: function() { return form_id },
|
85
|
-
on: function() { },
|
86
|
-
};
|
87
|
-
var element = {
|
88
|
-
size: function() { return 1 },
|
89
|
-
closest: function() { return form },
|
90
|
-
data: function() { return }
|
91
|
-
};
|
92
79
|
|
93
|
-
|
94
|
-
|
80
|
+
var buildTarget = function(form_id) {
|
81
|
+
var buildFixture = function(id) {
|
82
|
+
return setFixtures('<form id="' + id + '">' +
|
83
|
+
'<aside id="form-progress"><ul><li id="required-metadata"><li id="required-files"></ul>' +
|
84
|
+
'<input type="checkbox" name="agreement" id="agreement" value="1" required="required" checked="checked" />' +
|
85
|
+
'<input type="submit"></aside></form>')
|
86
|
+
}
|
87
|
+
target = new control.SaveWorkControl(buildFixture(form_id).find('#form-progress'));
|
95
88
|
target.requiredFiles = mockCheckbox;
|
89
|
+
return target
|
90
|
+
}
|
91
|
+
|
92
|
+
beforeEach(function() {
|
96
93
|
spyOn(mockCheckbox, 'check').and.stub();
|
97
94
|
spyOn(mockCheckbox, 'uncheck').and.stub();
|
98
95
|
});
|
99
96
|
|
100
97
|
describe("when required files are present", function() {
|
101
98
|
beforeEach(function() {
|
99
|
+
target = buildTarget(form_id)
|
102
100
|
target.uploads = {
|
103
101
|
hasFiles: true
|
104
102
|
};
|
@@ -112,6 +110,7 @@ describe("SaveWorkControl", function() {
|
|
112
110
|
|
113
111
|
describe("when a required files are missing", function() {
|
114
112
|
beforeEach(function() {
|
113
|
+
target = buildTarget(form_id)
|
115
114
|
target.uploads = {
|
116
115
|
hasFiles: false
|
117
116
|
};
|
@@ -127,6 +126,7 @@ describe("SaveWorkControl", function() {
|
|
127
126
|
describe("when a required files are missing and it's an edit form", function() {
|
128
127
|
beforeEach(function() {
|
129
128
|
form_id = 'edit_generic_work'
|
129
|
+
target = buildTarget(form_id)
|
130
130
|
});
|
131
131
|
it("is complete", function() {
|
132
132
|
target.validateFiles();
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::Configuration do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
it { is_expected.to respond_to(:persistent_hostpath) }
|
7
|
+
it { is_expected.to respond_to(:redis_namespace) }
|
8
|
+
it { is_expected.to respond_to(:libreoffice_path) }
|
9
|
+
it { is_expected.to respond_to(:browse_everything) }
|
10
|
+
it { is_expected.to respond_to(:analytics) }
|
11
|
+
it { is_expected.to respond_to(:citations) }
|
12
|
+
it { is_expected.to respond_to(:max_notifications_for_dashboard) }
|
13
|
+
it { is_expected.to respond_to(:activity_to_show_default_seconds_since_now) }
|
14
|
+
it { is_expected.to respond_to(:arkivo_api) }
|
15
|
+
it { is_expected.to respond_to(:active_deposit_agreement_acceptance) }
|
16
|
+
it { is_expected.to respond_to(:batch_user_key) }
|
17
|
+
it { is_expected.to respond_to(:audit_user_key) }
|
18
|
+
it { is_expected.to respond_to(:upload_path) }
|
19
|
+
it { is_expected.to respond_to(:always_display_share_button) }
|
20
|
+
it { is_expected.to respond_to(:google_analytics_id) }
|
21
|
+
it { is_expected.to respond_to(:analytic_start_date) }
|
22
|
+
it { is_expected.to respond_to(:display_media_download_link) }
|
23
|
+
it { is_expected.to respond_to(:permission_levels) }
|
24
|
+
it { is_expected.to respond_to(:owner_permission_levels) }
|
25
|
+
it { is_expected.to respond_to(:translate_uri_to_id) }
|
26
|
+
it { is_expected.to respond_to(:translate_id_to_uri) }
|
27
|
+
it { is_expected.to respond_to(:contact_email) }
|
28
|
+
it { is_expected.to respond_to(:subject_prefix) }
|
29
|
+
it { is_expected.to respond_to(:model_to_create) }
|
30
|
+
end
|
@@ -2,33 +2,33 @@ describe Sufia::UserStatImporter do
|
|
2
2
|
before do
|
3
3
|
allow(Sufia.config).to receive(:analytic_start_date) { dates[0] }
|
4
4
|
|
5
|
-
allow(FileViewStat).to receive(:ga_statistics) do |_date,
|
6
|
-
case
|
7
|
-
when bilbo_file_1
|
5
|
+
allow(FileViewStat).to receive(:ga_statistics) do |_date, file|
|
6
|
+
case file
|
7
|
+
when bilbo_file_1
|
8
8
|
bilbo_file_1_pageview_stats
|
9
|
-
when bilbo_file_2
|
9
|
+
when bilbo_file_2
|
10
10
|
bilbo_file_2_pageview_stats
|
11
11
|
else
|
12
12
|
frodo_file_1_pageview_stats
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
allow(FileDownloadStat).to receive(:ga_statistics) do |_date,
|
17
|
-
case
|
18
|
-
when bilbo_file_1
|
16
|
+
allow(FileDownloadStat).to receive(:ga_statistics) do |_date, file|
|
17
|
+
case file
|
18
|
+
when bilbo_file_1
|
19
19
|
bilbo_file_1_download_stats
|
20
|
-
when bilbo_file_2
|
20
|
+
when bilbo_file_2
|
21
21
|
bilbo_file_2_download_stats
|
22
22
|
else
|
23
23
|
frodo_file_1_download_stats
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
allow(WorkViewStat).to receive(:ga_statistics) do |_date,
|
28
|
-
case
|
29
|
-
when bilbo_work_1
|
27
|
+
allow(WorkViewStat).to receive(:ga_statistics) do |_date, work|
|
28
|
+
case work
|
29
|
+
when bilbo_work_1
|
30
30
|
bilbo_work_1_pageview_stats
|
31
|
-
when bilbo_work_2
|
31
|
+
when bilbo_work_2
|
32
32
|
bilbo_work_2_pageview_stats
|
33
33
|
else
|
34
34
|
frodo_work_1_pageview_stats
|
@@ -36,48 +36,33 @@ describe Sufia::UserStatImporter do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
let(:bilbo) {
|
40
|
-
let(:frodo) {
|
41
|
-
let!(:gollum) {
|
39
|
+
let(:bilbo) { create(:user, email: 'bilbo@example.com') }
|
40
|
+
let(:frodo) { create(:user, email: 'frodo@example.com') }
|
41
|
+
let!(:gollum) { create(:user, email: 'gollum@example.com') }
|
42
42
|
|
43
43
|
let!(:bilbo_file_1) do
|
44
|
-
|
45
|
-
f.apply_depositor_metadata(bilbo.email)
|
46
|
-
f.save
|
47
|
-
end
|
44
|
+
create(:file_set, id: 'xyzbilbo1', user: bilbo)
|
48
45
|
end
|
49
46
|
|
50
47
|
let!(:bilbo_file_2) do
|
51
|
-
|
52
|
-
f.apply_depositor_metadata(bilbo.email)
|
53
|
-
f.save
|
54
|
-
end
|
48
|
+
create(:file_set, id: 'xyzbilbo2', user: bilbo)
|
55
49
|
end
|
56
50
|
|
57
51
|
let!(:frodo_file_1) do
|
58
|
-
|
59
|
-
f.apply_depositor_metadata(frodo.email)
|
60
|
-
f.save
|
61
|
-
end
|
52
|
+
create(:file_set, id: 'xyzfrodo1', user: frodo)
|
62
53
|
end
|
63
54
|
|
64
55
|
# work
|
65
56
|
let!(:bilbo_work_1) do
|
66
|
-
|
67
|
-
work.apply_depositor_metadata(bilbo.email)
|
68
|
-
end
|
57
|
+
create(:work, id: 'xyzbilbowork1', user: bilbo)
|
69
58
|
end
|
70
59
|
|
71
60
|
let!(:bilbo_work_2) do
|
72
|
-
|
73
|
-
work.apply_depositor_metadata(bilbo.email)
|
74
|
-
end
|
61
|
+
create(:work, id: 'xyzbilbowork2', user: bilbo)
|
75
62
|
end
|
76
63
|
|
77
64
|
let!(:frodo_work_1) do
|
78
|
-
|
79
|
-
work.apply_depositor_metadata(frodo.email)
|
80
|
-
end
|
65
|
+
create(:work, id: 'xyzfrodowork1', user: frodo)
|
81
66
|
end
|
82
67
|
|
83
68
|
let(:dates) {
|