sufia 4.0.0.rc2 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +443 -621
  3. data/LICENSE.md +11 -174
  4. data/README.md +21 -7
  5. data/SUFIA_VERSION +1 -1
  6. data/app/assets/javascripts/sufia/batch.js +7 -2
  7. data/app/assets/javascripts/sufia/dashboard_actions.js +21 -10
  8. data/app/assets/javascripts/terms_of_service.js +1 -1
  9. data/app/assets/stylesheets/batch-edit.css.scss +21 -0
  10. data/app/assets/stylesheets/collections.css.scss +4 -0
  11. data/app/assets/stylesheets/home-page.css.scss +8 -1
  12. data/app/assets/stylesheets/styles.css.scss +8 -5
  13. data/app/assets/stylesheets/sufia.css.scss +1 -0
  14. data/app/builders/sufia/bootstrap_breadcrumbs_builder.rb +28 -0
  15. data/app/controllers/collections_controller.rb +2 -0
  16. data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +3 -1
  17. data/app/controllers/concerns/sufia/breadcrumbs.rb +41 -0
  18. data/app/controllers/concerns/sufia/files_controller_behavior.rb +3 -1
  19. data/app/controllers/concerns/sufia/homepage_controller.rb +1 -1
  20. data/app/helpers/sufia/blacklight_override.rb +1 -1
  21. data/app/helpers/sufia/records_helper_behavior.rb +19 -5
  22. data/app/helpers/sufia/sufia_helper_behavior.rb +13 -6
  23. data/app/models/concerns/sufia/solr_document_behavior.rb +4 -0
  24. data/app/views/_user_util_links.html.erb +4 -2
  25. data/app/views/batch/_metadata.html.erb +25 -31
  26. data/app/views/batch/_more_metadata.html.erb +6 -5
  27. data/app/views/batch/edit.html.erb +3 -3
  28. data/app/views/batch_edits/edit.html.erb +1 -1
  29. data/app/views/catalog/_search_form.html.erb +1 -3
  30. data/app/views/collections/_form_for_select_collection.html.erb +6 -3
  31. data/app/views/collections/_show_actions.html.erb +2 -2
  32. data/app/views/collections/edit.html.erb +1 -3
  33. data/app/views/collections/show.html.erb +1 -2
  34. data/app/views/generic_files/_field_form.html.erb +3 -3
  35. data/app/views/generic_files/_permission_form.html.erb +20 -3
  36. data/app/views/generic_files/edit.html.erb +1 -1
  37. data/app/views/generic_files/new.html.erb +8 -7
  38. data/app/views/generic_files/show.html.erb +1 -1
  39. data/app/views/generic_files/stats.html.erb +1 -1
  40. data/app/views/generic_files/upload/_form_fields.html.erb +4 -4
  41. data/app/views/homepage/_featured_fields.html.erb +20 -18
  42. data/app/views/homepage/_home_content.html.erb +8 -7
  43. data/app/views/homepage/_recent_document.html.erb +3 -4
  44. data/app/views/homepage/_recents.html.erb +4 -1
  45. data/app/views/homepage/_tagcloud.html.erb +5 -4
  46. data/app/views/kaminari/blacklight_compact/_paginator.html.erb +23 -0
  47. data/app/views/my/_action_menu.html.erb +15 -12
  48. data/app/views/my/_collection_action_menu.html.erb +8 -6
  49. data/app/views/my/_facets.html.erb +1 -1
  50. data/app/views/my/_index_partials/_default_group.html.erb +1 -1
  51. data/app/views/my/_index_partials/_list_collections.html.erb +12 -6
  52. data/app/views/my/_index_partials/_list_files.html.erb +14 -6
  53. data/app/views/my/index.html.erb +7 -2
  54. data/app/views/records/edit_fields/_suffix.html.erb +0 -1
  55. data/app/views/shared/_attributes.html.erb +6 -6
  56. data/app/views/users/_notify_link.html.erb +1 -0
  57. data/app/views/users/_notify_number.html.erb +3 -2
  58. data/config/locales/sufia.en.yml +24 -4
  59. data/lib/sufia.rb +2 -0
  60. data/lib/sufia/version.rb +1 -1
  61. data/spec/actors/generic_file/actor_spec.rb +21 -2
  62. data/spec/controllers/batch_controller_spec.rb +3 -3
  63. data/spec/controllers/batch_edits_controller_spec.rb +4 -0
  64. data/spec/controllers/catalog_controller_spec.rb +3 -3
  65. data/spec/controllers/collections_controller_spec.rb +5 -1
  66. data/spec/controllers/generic_files_controller_spec.rb +21 -4
  67. data/spec/controllers/homepage_controller_spec.rb +8 -1
  68. data/spec/features/browse_dashboard_files_spec.rb +1 -1
  69. data/spec/features/collection_spec.rb +3 -3
  70. data/spec/helpers/records_helper_spec.rb +53 -25
  71. data/spec/jobs/import_url_job_spec.rb +2 -1
  72. data/spec/lib/sufia/breadcrumbs_spec.rb +80 -0
  73. data/spec/lib/sufia/messages_spec.rb +8 -1
  74. data/spec/models/characterization_spec.rb +23 -0
  75. data/spec/models/fits_datastream_spec.rb +20 -23
  76. data/spec/support/features/session_helpers.rb +1 -1
  77. data/spec/views/catalog/index.html.erb_spec.rb +2 -0
  78. data/spec/views/generic_file/stats.html.erb_spec.rb +0 -6
  79. data/spec/views/users/show.html.erb_spec.rb +19 -0
  80. data/sufia-models/app/actors/sufia/generic_file/actor.rb +2 -1
  81. data/sufia-models/app/models/concerns/sufia/generic_file/characterization.rb +3 -4
  82. data/sufia-models/app/models/concerns/sufia/generic_file/full_text_indexing.rb +21 -14
  83. data/sufia-models/app/models/concerns/sufia/generic_file/mime_types.rb +4 -0
  84. data/sufia-models/app/models/file_usage.rb +6 -2
  85. data/sufia-models/lib/sufia/models/version.rb +1 -1
  86. data/sufia.gemspec +1 -0
  87. metadata +28 -9
  88. data/app/views/generic_files/_breadcrumbs.html.erb +0 -31
  89. data/spec/views/generic_file/_breadcrumbs.html.erb_spec.rb +0 -32
@@ -1,4 +1,5 @@
1
1
  <%= link_to sufia.notifications_path, id: "notify_link", class: "btn btn-default", title: "User Notifications" do %>
2
+ <span class="sr-only">click for notifications.</span>
2
3
  <%= render partial: 'users/notify_number' %>
3
4
  <% end %>
4
5
  <div class='hide'>
@@ -1,4 +1,5 @@
1
1
  <i class="glyphicon glyphicon-bullhorn"></i>
2
2
  <% if @notify_number > 0 %>
3
- <span id="notify_number" class="overlay"> <%=@notify_number%></span>
4
- <% end %>
3
+ <span id="notify_number" class="overlay"> <%=@notify_number%></span>
4
+ <span class="sr-only">unread notifications</span>
5
+ <% end %>
@@ -34,8 +34,11 @@ en:
34
34
  text: "Search"
35
35
  upload:
36
36
  my_computer:
37
+ sr_tab_label: "Access Files from"
37
38
  tab_label: "My Computer"
39
+ sr_instructions: "Agree to the deposit agreement and then select files. Press the Start Upload Button once all files have been selected."
38
40
  browse_everything:
41
+ sr_tab_label: "Access Files from"
39
42
  tab_label: "Cloud Providers"
40
43
  browse_files_button: "Browse cloud files"
41
44
  files_selected: "files selected"
@@ -52,6 +55,10 @@ en:
52
55
  size: "Size"
53
56
  homepage:
54
57
  featured_works: 'Featured Works'
58
+ recently_uploaded: 'Recently Uploaded'
59
+ explore: 'Explore'
60
+ sr_explore: 'Popular Keywords'
61
+ no_public: 'No public work has been contributed.'
55
62
  dashboard:
56
63
  title: "My Dashboard"
57
64
  greeting: "Hello, "
@@ -75,6 +82,12 @@ en:
75
82
  collections: "My Collections"
76
83
  highlights: "My Highlights"
77
84
  shares: "Files Shared with Me"
85
+ filter: "Filter your %{type}"
86
+ sr:
87
+ show_label: "Display all details of"
88
+ detail_label: "Display summary details of"
89
+ batch_checkbox: "Check to add to a collection or edit list"
90
+ check_all_label: "Select all files to be added to a collection or edited"
78
91
  file:
79
92
  collections_list:
80
93
  heading: "This file is in the following collections:"
@@ -106,14 +119,17 @@ en:
106
119
  date_created: "The date on which the file was generated. Dates are accepted in the form YYYY-MM-DD, e.g. 1776-07-04."
107
120
  description: "Free-text notes about the file itself. Examples include abstracts of a paper, citation information for a journal article, or a tag indicating a larger collection to which the file belongs."
108
121
  identifier: "A unique handle describing the file. An example would be a DOI for a journal article, or an ISBN or OCLC number for a book."
109
- language: " The language of the file content."
122
+ language: "The language of the file content."
110
123
  publisher: "The person or group making the file available. Generally this is the institution."
111
124
  rights: "Licensing and distribution information governing access to the file. Select from the provided drop-down list. <em>This is a required field</em>."
125
+ aria_label:
126
+ default: "Usage information for %{title}"
127
+ based_near: "Usage information for location"
128
+ description: "Usage information for abstract or summary"
129
+ tag: "Usage information for keyword"
130
+ rightsModal: "Usage information for rights"
112
131
  background_attribution: "Background image courtesy of Penn State University"
113
132
  bread_crumb:
114
- file_list: "Your File Listing"
115
- collections_list: "Your Collections"
116
- previous: "Back to Previous"
117
133
  search_results: "Back to search results"
118
134
  visibility:
119
135
  open: "Open Access"
@@ -121,3 +137,7 @@ en:
121
137
  user_profile:
122
138
  no_followers: "No one is following you."
123
139
  no_following: "You are not following anyone."
140
+ batch:
141
+ help:
142
+ title: "Filename will be the default title. Please provide a more meaningful title, and filenames will still be preserved by the system."
143
+ resource_type: "You may select multiple types to apply to all files"
@@ -18,6 +18,8 @@ module Sufia
18
18
 
19
19
  class Engine < ::Rails::Engine
20
20
  engine_name 'sufia'
21
+ # Breadcrumbs on rails must be required outside of an initializer or it doesn't get loaded.
22
+ require 'breadcrumbs_on_rails'
21
23
 
22
24
  config.autoload_paths += %W(
23
25
  #{config.root}/app/controllers/concerns
@@ -1,3 +1,3 @@
1
1
  module Sufia
2
- VERSION = "4.0.0.rc2"
2
+ VERSION = "4.0.0"
3
3
  end
@@ -1,15 +1,17 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Sufia::GenericFile::Actor do
4
+
5
+ let(:user) { FactoryGirl.create(:user) }
6
+
4
7
  describe "#virus_check" do
5
8
  it "should return the results of running ClamAV scanfile method" do
6
- ClamAV.instance.should_receive(:scanfile).and_return(1)
9
+ expect(ClamAV.instance).to receive(:scanfile).and_return(1)
7
10
  expect { Sufia::GenericFile::Actor.virus_check(File.new(fixture_path + '/world.png')) }.to raise_error(Sufia::VirusFoundError)
8
11
  end
9
12
  end
10
13
 
11
14
  describe "#featured_work" do
12
- let(:user) { FactoryGirl.create(:user) }
13
15
  let(:gf) { FactoryGirl.create(:generic_file, visibility: 'open') }
14
16
  let(:actor) { Sufia::GenericFile::Actor.new(gf, user)}
15
17
 
@@ -24,4 +26,21 @@ describe Sufia::GenericFile::Actor do
24
26
  end
25
27
  end
26
28
 
29
+ context "when a label is already specified" do
30
+ let(:generic_file_with_label) do
31
+ GenericFile.new.tap do |f|
32
+ f.apply_depositor_metadata(user.user_key)
33
+ f.label = "test_file.name"
34
+ end
35
+ end
36
+
37
+ let(:actor) { Sufia::GenericFile::Actor.new(generic_file_with_label, user)}
38
+
39
+ it "uses the label instead of the path" do
40
+ allow(actor).to receive(:save_characterize_and_record_committer).and_return("true")
41
+ actor.create_content(Tempfile.new('foo'), 'tmp\foo', 'content')
42
+ expect(generic_file_with_label.content.dsLabel).to eq generic_file_with_label.label
43
+ end
44
+ end
45
+
27
46
  end
@@ -84,7 +84,7 @@ describe BatchController do
84
84
  file.discover_groups.should == []
85
85
  end
86
86
  it "should set metadata like title" do
87
- post :update, id: @batch.pid, "generic_file"=>{"tag"=>["footag", "bartag"]}, "title"=>{@file.pid=>"New Title"}
87
+ post :update, id: @batch.pid, "generic_file"=>{"tag"=>["footag", "bartag"]}, "title"=>{@file.pid=>["New Title"]}
88
88
  file = GenericFile.find(@file.pid)
89
89
  file.title.should == ["New Title"]
90
90
  file.tag.should == ["footag", "bartag"]
@@ -98,10 +98,10 @@ describe BatchController do
98
98
  describe "when user does not have edit permissions on a file" do
99
99
  it "should not modify the object" do
100
100
  file = GenericFile.find(@file2.pid)
101
- file.title = "Original Title"
101
+ file.title = ["Original Title"]
102
102
  file.read_groups.should == []
103
103
  file.save
104
- post :update, id: @batch.pid, "generic_file"=>{"read_groups_string"=>"group1, group2", "read_users_string"=>"", "tag"=>[""]}, "title"=>{@file2.pid=>"Title Wont Change"}
104
+ post :update, id: @batch.pid, "generic_file"=>{"read_groups_string"=>"group1, group2", "read_users_string"=>"", "tag"=>[""]}, "title"=>{@file2.pid=>["Title Wont Change"]}
105
105
  file = GenericFile.find(@file2.pid)
106
106
  file.title.should == ["Original Title"]
107
107
  file.read_groups.should == []
@@ -33,6 +33,10 @@ describe BatchEditsController do
33
33
  expect(assigns[:show_file].publisher).to eq ["Rand McNally"]
34
34
  expect(assigns[:show_file].language).to eq ["en"]
35
35
  end
36
+ it "should set the breadcrumb trail" do
37
+ expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.title'), Sufia::Engine.routes.url_helpers.dashboard_index_path)
38
+ get :edit
39
+ end
36
40
  end
37
41
 
38
42
  describe "update" do
@@ -12,12 +12,12 @@ describe CatalogController do
12
12
  describe "#index" do
13
13
  before (:all) do
14
14
  @user = FactoryGirl.find_or_create(:jill)
15
- @gf1 = GenericFile.new(title: 'Test Document PDF', filename: 'test.pdf', tag: 'rocks', read_groups: ['public']).tap do |f|
15
+ @gf1 = GenericFile.new(title: ['Test Document PDF'], filename: ['test.pdf'], tag: ['rocks'], read_groups: ['public']).tap do |f|
16
16
  f.apply_depositor_metadata('mjg36')
17
17
  f.save
18
18
  end
19
19
 
20
- @gf2 = GenericFile.new(title: 'Test 2 Document', filename: 'test2.doc', tag: 'clouds', contributor: 'Contrib1', read_groups: ['public']).tap do |f|
20
+ @gf2 = GenericFile.new(title: ['Test 2 Document'], filename: ['test2.doc'], tag: ['clouds'], contributor: ['Contrib1'], read_groups: ['public']).tap do |f|
21
21
  f.apply_depositor_metadata('mjg36')
22
22
  f.full_text.content = 'full_textfull_text'
23
23
  f.save
@@ -68,7 +68,7 @@ describe CatalogController do
68
68
 
69
69
  context "with collections" do
70
70
  before do
71
- @collection = Collection.new(title:"my collection", tag: 'rocks').tap do |c|
71
+ @collection = Collection.new(title: "my collection", tag: ['rocks']).tap do |c|
72
72
  c.apply_depositor_metadata('mjg36')
73
73
  c.save!
74
74
  end
@@ -80,7 +80,7 @@ describe CollectionsController do
80
80
 
81
81
  describe "#update" do
82
82
  before do
83
- @collection = Collection.new(title: ["Collection Title"])
83
+ @collection = Collection.new(title: "Collection Title")
84
84
  @collection.apply_depositor_metadata(user.user_key)
85
85
  @collection.save
86
86
  @asset1 = GenericFile.new(title: ["First of the Assets"])
@@ -157,6 +157,10 @@ describe CollectionsController do
157
157
  expect(ids).to include @asset1.pid, @asset2.pid, @asset3.pid
158
158
  expect(ids).to_not include @asset4.pid
159
159
  end
160
+ it "should set the breadcrumb trail" do
161
+ expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.title'), Sufia::Engine.routes.url_helpers.dashboard_index_path)
162
+ get :show, id: @collection.id
163
+ end
160
164
  end
161
165
  context "not signed in" do
162
166
  it "should not show me files in the collection" do
@@ -282,7 +282,6 @@ describe GenericFilesController do
282
282
 
283
283
  context 'when user has access to file' do
284
284
  before do
285
- sign_in @user
286
285
  mock_query = double('query')
287
286
  allow(mock_query).to receive(:for_path).and_return([
288
287
  OpenStruct.new(date: '2014-01-01', pageviews: 4),
@@ -292,7 +291,7 @@ describe GenericFilesController do
292
291
  OpenStruct.new(date: '2014-01-05', pageviews: 2)])
293
292
  allow(mock_query).to receive(:map).and_return(mock_query.for_path.map(&:marshal_dump))
294
293
  profile = double('profile')
295
- allow(profile).to receive(:pageview).and_return(mock_query)
294
+ allow(profile).to receive(:sufia__pageview).and_return(mock_query)
296
295
  allow(Sufia::Analytics).to receive(:profile).and_return(profile)
297
296
 
298
297
  download_query = double('query')
@@ -300,7 +299,7 @@ describe GenericFilesController do
300
299
  OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:123456789", totalEvents: "3")
301
300
  ])
302
301
  allow(download_query).to receive(:map).and_return(download_query.for_file.map(&:marshal_dump))
303
- allow(profile).to receive(:download).and_return(download_query)
302
+ allow(profile).to receive(:sufia__download).and_return(download_query)
304
303
  end
305
304
 
306
305
  it 'renders the stats view' do
@@ -308,6 +307,20 @@ describe GenericFilesController do
308
307
  expect(response).to be_success
309
308
  expect(response).to render_template(:stats)
310
309
  end
310
+
311
+ context "user is not signed in but the file is public" do
312
+ before do
313
+ sign_out @user
314
+ @generic_file.read_groups = ['public']
315
+ @generic_file.save
316
+ end
317
+
318
+ it 'renders the stats view' do
319
+ get :stats, id: @generic_file.noid
320
+ expect(response).to be_success
321
+ expect(response).to render_template(:stats)
322
+ end
323
+ end
311
324
  end
312
325
 
313
326
  context 'when user lacks access to file' do
@@ -341,7 +354,7 @@ describe GenericFilesController do
341
354
  Sufia.queue.should_receive(:push).with(s1).once
342
355
  @user = FactoryGirl.find_or_create(:jill)
343
356
  sign_in @user
344
- post :update, id: generic_file, generic_file: {title: 'new_title', tag: [''], permissions: { new_user_name: {'archivist1'=>'edit'}}}
357
+ post :update, id: generic_file, generic_file: {title: ['new_title'], tag: [''], permissions: { new_user_name: {'archivist1'=>'edit'}}}
345
358
  @user.delete
346
359
  end
347
360
 
@@ -533,6 +546,10 @@ describe GenericFilesController do
533
546
  response.should_not redirect_to(action: 'show')
534
547
  flash[:alert].should be_nil
535
548
  end
549
+ it "should set the breadcrumbs" do
550
+ expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.title'), Sufia::Engine.routes.url_helpers.dashboard_index_path)
551
+ get :show, id: "test5"
552
+ end
536
553
  end
537
554
  describe "flash" do
538
555
  it "should not let the user submit if they logout" do
@@ -9,7 +9,7 @@ describe HomepageController do
9
9
  @gf1 = GenericFile.new(title:['Test Document PDF'], filename:['test.pdf'], tag:['rocks'], read_groups:['public'])
10
10
  @gf1.apply_depositor_metadata('mjg36')
11
11
  @gf1.save
12
- @gf2 = GenericFile.new(title:['Test 2 Document'], filename:['test2.doc'], tag:['clouds'], contributor:['Contrib1'], read_groups:['public'])
12
+ @gf2 = GenericFile.new(title:['Test Private Document'], filename:['test2.doc'], tag:['clouds'], contributor:['Contrib1'], read_groups:['private'])
13
13
  @gf2.apply_depositor_metadata('mjg36')
14
14
  @gf2.save
15
15
  end
@@ -42,6 +42,13 @@ describe HomepageController do
42
42
  end
43
43
  end
44
44
 
45
+ it "should not include other user's private documents in recent documents" do
46
+ get :index
47
+ expect(response).to be_success
48
+ titles = assigns(:recent_documents).map {|d| d['desc_metadata__title_tesim'][0]}
49
+ expect(titles).to_not include('Test Private Document')
50
+ end
51
+
45
52
  context "with a document not created this second" do
46
53
  before do
47
54
  gf3 = GenericFile.new(title:['Test 3 Document'], read_groups:['public'])
@@ -47,7 +47,7 @@ describe "Browse Dashboard" do
47
47
  click_link "more Subjects"
48
48
  click_link "consectetur"
49
49
  within("#document_#{@fixtures[1].noid}") do
50
- click_link "Test Document MP3.mp3"
50
+ click_link "Display all details of Test Document MP3.mp3"
51
51
  end
52
52
  expect(page).to have_content("File Details")
53
53
  end
@@ -97,7 +97,7 @@ describe 'collection' do
97
97
  it "should show a collection with a listing of Descriptive Metadata and catalog-style search results" do
98
98
  expect(page).to have_content(@collection.title)
99
99
  within('#document_'+@collection.noid) do
100
- click_link("collection title")
100
+ click_link("Display all details of collection title")
101
101
  end
102
102
  expect(page).to have_content(@collection.title)
103
103
  expect(page).to have_content(@collection.description)
@@ -120,7 +120,7 @@ describe 'collection' do
120
120
  # URL: /dashboard/collections
121
121
  expect(page).to have_content(@collection.title)
122
122
  within("#document_#{@collection.noid}") do
123
- click_link("collection title")
123
+ click_link("Display all details of collection title")
124
124
  end
125
125
  # URL: /collections/collection-id
126
126
  expect(page).to have_content(@collection.title)
@@ -232,7 +232,7 @@ describe 'collection' do
232
232
  it "should show a collection with a listing of Descriptive Metadata and catalog-style search results" do
233
233
  page.should have_content(@collection.title)
234
234
  within('#document_'+@collection.noid) do
235
- click_link("collection title")
235
+ click_link("Display all details of collection title")
236
236
  end
237
237
  page.should have_css(".pager")
238
238
  end
@@ -1,38 +1,38 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe RecordsHelper do
4
+ let(:adder) {
5
+ "<button class=\"adder btn\" id=\"additional_test_submit\" name=\"additional_test\"><span aria-hidden=\"true\">+</span><span class=\"sr-only\">add another test</span></button>"
6
+ }
7
+ let(:remover) {
8
+ "<button class=\"remover btn\" id=\"additional_test_submit\" name=\"additional_test\"><span aria-hidden=\"true\">-</span><span class=\"sr-only\">add another test</span></button>"
9
+ }
4
10
  it "draws add button" do
5
- helper.add_field(:test).should ==
6
- "<button class=\"adder btn\" id=\"additional_test_submit\" name=\"additional_test\">+<span class=\"sr-only\">add another test</span></button>"
11
+ expect(helper.add_field(:test)).to eql(adder)
7
12
  end
8
13
 
9
14
  it "draws subtract button" do
10
- helper.subtract_field(:test).should ==
11
- "<button class=\"remover btn\" id=\"additional_test_submit\" name=\"additional_test\">-<span class=\"sr-only\">add another test</span></button>"
15
+ expect(helper.subtract_field(:test)).to eql(remover)
12
16
  end
13
17
 
14
18
  it "draws help_icon" do
15
19
  str = String.new(helper.help_icon(:tag))
16
20
  doc = Nokogiri::HTML(str)
17
21
  a = doc.xpath('//a').first
18
-
19
- a.attr('data-content').should == "Words or phrases you select to describe what the file is about. These are used to search for content. <em>This is a required field</em>."
20
- a.attr('data-original-title').should == "Keyword"
21
- a.attr('id').should == "generic_file_tag_help"
22
- i = a.children.first
23
- i.attr('class').should == 'glyphicon glyphicon-question-sign large-icon'
22
+ expect(a.attr('data-content')).to eql("Words or phrases you select to describe what the file is about. These are used to search for content. <em>This is a required field</em>.")
23
+ expect(a.attr('data-original-title')).to eql("Keyword")
24
+ expect(a.attr('id')).to eql("generic_file_tag_help")
25
+ expect(a.children.first.attr('class')).to eql('help-icon')
24
26
  end
25
27
 
26
28
  specify "draws help_icon_modal" do
27
29
  str = String.new(helper.help_icon_modal('myModal'))
28
30
  doc = Nokogiri::HTML(str)
29
31
  a = doc.xpath('//a').first
30
-
31
32
  expect(a.attr('href')).to eq('#myModal')
32
33
  expect(a.attr('data-toggle')).to eq('modal')
33
34
  expect(a.attr('id')).to eq('generic_file_myModal_help_modal')
34
- i = a.children.first
35
- expect(i.attr('class')).to eq('glyphicon glyphicon-question-sign large-icon')
35
+ expect(a.children.first.attr('class')).to eq('help-icon')
36
36
  end
37
37
 
38
38
  describe "download links" do
@@ -42,32 +42,60 @@ describe RecordsHelper do
42
42
  assign :generic_file, @file
43
43
  end
44
44
 
45
+ let(:link_text) { helper.render_download_link("Download Fake") }
46
+ let(:icon_text) { helper.render_download_icon("Download the full-sized Fake") }
47
+
45
48
  describe "#render_download_link" do
46
49
  it "has default text" do
47
- helper.render_download_link.should have_selector("#file_download")
48
- helper.render_download_link.should have_content("Download")
50
+ expect(helper.render_download_link).to have_selector("#file_download")
51
+ expect(helper.render_download_link).to have_content("Download")
49
52
  end
50
53
 
51
- it "includes user-supplied text" do
52
- content = helper.render_download_link("Download Fake")
53
- content.should have_selector("#file_download")
54
- content.should have_content("Download Fake")
54
+ it "includes user-supplied link text" do
55
+ expect(link_text).to have_selector("#file_download")
56
+ expect(link_text).to have_content("Download Fake")
55
57
  end
56
58
  end
57
59
 
58
60
  describe "#render_download_icon" do
59
61
  it "has default text" do
60
- helper.render_download_icon.should have_selector("#file_download")
61
- helper.render_download_icon.should match("Download the document")
62
+ expect(helper.render_download_icon).to have_selector("#file_download")
63
+ expect(helper.render_download_icon).to match("Download the document")
62
64
  end
63
65
 
64
- it "includes user-supplied text" do
65
- content = helper.render_download_icon("Download the full-sized Fake")
66
- content.should have_selector("#file_download")
67
- content.should match("Download the full-sized Fake")
66
+ it "includes user-supplied icon text" do
67
+ expect(icon_text).to have_selector("#file_download")
68
+ expect(icon_text).to match("Download the full-sized Fake")
68
69
  end
69
70
  end
70
71
 
71
72
  end
72
73
 
74
+ describe "#metadata_help" do
75
+ specify "default" do
76
+ expect(helper.metadata_help("foo")).to eql("Foo")
77
+ end
78
+ specify "using a key" do
79
+ expect(helper.metadata_help("language")).to eql("The language of the file content.")
80
+ end
81
+ end
82
+
83
+ describe "#get_label" do
84
+ specify "default" do
85
+ expect(helper.get_label("foo")).to eql("Foo")
86
+ end
87
+ specify "using a key" do
88
+ expect(helper.get_label("tag")).to eql("Keyword")
89
+ end
90
+ end
91
+
92
+ describe "#get_aria_label" do
93
+ specify "default" do
94
+ expect(helper.get_aria_label("foo")).to eql("Usage information for Foo")
95
+ end
96
+ specify "using a key" do
97
+ expect(helper.get_aria_label("tag")).to eql("Usage information for keyword")
98
+ end
99
+ end
100
+
73
101
  end