sufia 6.0.0.rc2 → 6.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -5
- data/History.md +14 -0
- data/LICENSE +15 -0
- data/SUFIA_VERSION +1 -1
- data/app/assets/javascripts/sufia/batch_edit.js +1 -1
- data/app/assets/javascripts/sufia/permissions.js +8 -12
- data/app/assets/stylesheets/sufia.css.scss +1 -1
- data/app/assets/stylesheets/sufia/_multi_value_fields.css.scss +67 -0
- data/app/assets/stylesheets/sufia/_settings.scss +1 -0
- data/app/assets/stylesheets/sufia/_styles.scss +4 -0
- data/app/assets/stylesheets/sufia/_tinymce.scss +14 -0
- data/app/controllers/batch_controller.rb +11 -2
- data/app/controllers/concerns/sufia/breadcrumbs.rb +2 -3
- data/app/controllers/concerns/sufia/collections_controller_behavior.rb +0 -1
- data/app/controllers/concerns/sufia/contact_form_controller_behavior.rb +1 -2
- data/app/controllers/concerns/sufia/controller.rb +1 -7
- data/app/controllers/concerns/sufia/downloads_controller_behavior.rb +3 -8
- data/app/controllers/concerns/sufia/files_controller/local_ingest_behavior.rb +2 -3
- data/app/controllers/concerns/sufia/files_controller/upload_complete_behavior.rb +1 -2
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +27 -14
- data/app/controllers/concerns/sufia/homepage_controller.rb +3 -2
- data/app/controllers/content_blocks_controller.rb +17 -1
- data/app/controllers/downloads_controller.rb +0 -1
- data/app/controllers/my/shares_controller.rb +1 -0
- data/app/controllers/single_use_links_controller.rb +0 -1
- data/app/controllers/single_use_links_viewer_controller.rb +3 -8
- data/app/forms/sufia/forms/generic_file_edit_form.rb +1 -8
- data/app/helpers/content_block_helper.rb +30 -10
- data/app/helpers/generic_file_helper.rb +4 -4
- data/app/helpers/sufia/dashboard_helper_behavior.rb +2 -2
- data/app/helpers/sufia/sufia_helper_behavior.rb +4 -4
- data/app/helpers/trophy_helper.rb +3 -3
- data/app/jobs/content_delete_event_job.rb +1 -2
- data/app/jobs/content_deposit_event_job.rb +1 -1
- data/app/jobs/content_depositor_change_event_job.rb +1 -1
- data/app/jobs/content_new_version_event_job.rb +1 -1
- data/app/jobs/content_restored_version_event_job.rb +1 -1
- data/app/jobs/content_update_event_job.rb +1 -1
- data/app/models/concerns/sufia/solr_document_behavior.rb +5 -9
- data/app/models/content_block.rb +20 -0
- data/app/models/featured_work_list.rb +4 -0
- data/app/presenters/sufia/collection_presenter.rb +14 -2
- data/app/presenters/sufia/generic_file_presenter.rb +16 -0
- data/app/presenters/sufia/version_list_presenter.rb +1 -1
- data/app/views/batch/_metadata.html.erb +4 -4
- data/app/views/batch_edits/edit.html.erb +1 -1
- data/app/views/collections/_action_menu.html.erb +4 -5
- data/app/views/collections/_show_descriptions.html.erb +1 -5
- data/app/views/collections/_show_document_list.html.erb +0 -2
- data/app/views/collections/_show_document_list_menu.html.erb +5 -6
- data/app/views/collections/_show_document_list_row.html.erb +9 -9
- data/app/views/collections/_sort_and_per_page.html.erb +1 -1
- data/app/views/collections/_view_type_group.html.erb +1 -1
- data/app/views/collections/show.html.erb +3 -3
- data/app/views/generic_files/_asset_permissions_denial_flash.html.erb +1 -1
- data/app/views/generic_files/_asset_saved_flash.html.erb +1 -1
- data/app/views/generic_files/_asset_updated_flash.html.erb +1 -1
- data/app/views/generic_files/_browse_everything.html.erb +4 -4
- data/app/views/generic_files/_media_display.html.erb +9 -9
- data/app/views/generic_files/_permission_form.html.erb +1 -1
- data/app/views/generic_files/_show_actions.html.erb +1 -1
- data/app/views/generic_files/_show_collections.html.erb +2 -2
- data/app/views/generic_files/_show_details.html.erb +1 -1
- data/app/views/generic_files/_versioning.html.erb +9 -5
- data/app/views/generic_files/jq_upload.json.jbuilder +1 -1
- data/app/views/generic_files/new.html.erb +2 -3
- data/app/views/generic_files/show.html.erb +13 -16
- data/app/views/generic_files/upload/_alerts.html.erb +2 -2
- data/app/views/generic_files/upload/_form_fields.html.erb +1 -1
- data/app/views/generic_files/upload/_local_file_import_chooser.html.erb +1 -1
- data/app/views/generic_files/upload/_script_templates.html.erb +2 -2
- data/app/views/homepage/_featured.html.erb +2 -4
- data/app/views/homepage/_featured_researcher.html.erb +1 -1
- data/app/views/homepage/_featured_works.html.erb +5 -3
- data/app/views/homepage/_home_content.html.erb +1 -1
- data/app/views/homepage/_recent_document.html.erb +2 -2
- data/app/views/homepage/_sortable_featured.html.erb +1 -2
- data/app/views/my/_action_menu.html.erb +8 -8
- data/app/views/my/_collection_action_menu.html.erb +4 -4
- data/app/views/my/_index_partials/_list_collections.html.erb +9 -12
- data/app/views/my/_index_partials/_list_files.html.erb +9 -9
- data/app/views/my/index.html.erb +0 -1
- data/app/views/records/_rights_modal.html.erb +1 -0
- data/app/views/users/_contributions.html.erb +2 -3
- data/app/views/users/_edit_primary.html.erb +68 -0
- data/app/views/users/_edit_secondary.html.erb +1 -0
- data/app/views/users/_trophy_edit.html.erb +1 -3
- data/app/views/users/edit.html.erb +4 -78
- data/config/initializers/simple_form.rb +167 -0
- data/config/initializers/simple_form_bootstrap.rb +137 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/config/locales/sufia.en.yml +7 -4
- data/config/routes.rb +1 -1
- data/lib/generators/sufia/templates/catalog_controller.rb +1 -1
- data/lib/sufia/single_use_error.rb +1 -1
- data/lib/sufia/version.rb +1 -1
- data/spec/actors/generic_file/actor_spec.rb +5 -5
- data/spec/controllers/batch_controller_spec.rb +15 -0
- data/spec/controllers/collections_controller_spec.rb +1 -1
- data/spec/controllers/content_blocks_controller_spec.rb +23 -3
- data/spec/controllers/downloads_controller_spec.rb +5 -5
- data/spec/controllers/generic_files_controller_spec.rb +12 -12
- data/spec/controllers/homepage_controller_spec.rb +19 -6
- data/spec/controllers/my/files_controller_spec.rb +8 -10
- data/spec/controllers/my/shares_controller_spec.rb +34 -23
- data/spec/controllers/single_use_links_controller_spec.rb +2 -3
- data/spec/controllers/single_use_links_viewer_controller_spec.rb +19 -20
- data/spec/controllers/users_controller_spec.rb +8 -8
- data/spec/factories/generic_files.rb +4 -4
- data/spec/factories/users.rb +2 -3
- data/spec/features/browse_dashboard_files_spec.rb +8 -8
- data/spec/features/collection_spec.rb +15 -8
- data/spec/features/edit_file_spec.rb +26 -0
- data/spec/features/single_use_links_spec.rb +3 -3
- data/spec/forms/generic_file_edit_form_spec.rb +8 -1
- data/spec/helpers/content_block_helper_spec.rb +10 -0
- data/spec/helpers/dashboard_helper_spec.rb +42 -0
- data/spec/helpers/sufia_helper_spec.rb +34 -7
- data/spec/helpers/trophy_helper_spec.rb +6 -6
- data/spec/inputs/select_with_help_input_spec.rb +16 -0
- data/spec/jobs/audit_job_spec.rb +1 -1
- data/spec/jobs/characterize_job_spec.rb +2 -7
- data/spec/jobs/create_derivatives_job_spec.rb +27 -38
- data/spec/jobs/import_url_job_spec.rb +2 -2
- data/spec/jobs/ingest_local_file_job_spec.rb +6 -8
- data/spec/lib/sufia/id_service_spec.rb +0 -7
- data/spec/lib/sufia/messages_spec.rb +16 -13
- data/spec/models/ability_spec.rb +3 -0
- data/spec/models/checksum_audit_log_spec.rb +1 -1
- data/spec/models/content_block_spec.rb +41 -0
- data/spec/models/featured_work_list_spec.rb +23 -9
- data/spec/models/file_content_datastream_spec.rb +4 -4
- data/spec/models/file_usage_spec.rb +1 -1
- data/spec/models/fits_datastream_spec.rb +4 -4
- data/spec/models/generic_file_spec.rb +31 -15
- data/spec/models/single_use_link_spec.rb +2 -2
- data/spec/models/solr_document_spec.rb +8 -5
- data/spec/models/user_spec.rb +3 -3
- data/spec/presenters/sufia/collection_presenter_spec.rb +34 -0
- data/spec/presenters/sufia/generic_file_presenter_spec.rb +41 -1
- data/spec/presenters/sufia/version_list_presenter_spec.rb +12 -2
- data/spec/services/generic_file_audit_service_spec.rb +3 -3
- data/spec/services/noid_spec.rb +4 -11
- data/spec/services/repository_audit_service_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/fixture_helpers.rb +2 -3
- data/spec/support/selectors.rb +7 -7
- data/spec/test_app_templates/Gemfile.extra +1 -0
- data/spec/views/batch/edit.html.erb_spec.rb +14 -17
- data/spec/views/collections/_show_descriptions.html.erb_spec.rb +1 -1
- data/spec/views/generic_file/_permission_form.html.erb_spec.rb +29 -7
- data/spec/views/generic_file/edit.html.erb_spec.rb +1 -1
- data/spec/views/generic_file/show.html.erb_spec.rb +69 -151
- data/spec/views/generic_file/stats.html.erb_spec.rb +1 -1
- data/spec/views/homepage/_featured_works.html.erb_spec.rb +29 -0
- data/spec/views/users/show.html.erb_spec.rb +1 -1
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +12 -8
- data/sufia-models/app/jobs/batch_update_job.rb +2 -2
- data/sufia-models/app/jobs/import_url_job.rb +5 -3
- data/sufia-models/app/jobs/ingest_local_file_job.rb +46 -0
- data/sufia-models/app/jobs/resolrize_job.rb +1 -8
- data/sufia-models/app/models/batch.rb +0 -7
- data/sufia-models/app/models/concerns/sufia/ability.rb +1 -1
- data/sufia-models/app/models/concerns/sufia/{collection.rb → collection_behavior.rb} +1 -13
- data/sufia-models/app/models/concerns/sufia/generic_file/batches.rb +3 -4
- data/sufia-models/app/models/concerns/sufia/generic_file/export.rb +1 -1
- data/sufia-models/app/models/concerns/sufia/generic_file/featured.rb +1 -4
- data/sufia-models/app/models/concerns/sufia/generic_file/metadata.rb +7 -7
- data/sufia-models/app/models/concerns/sufia/generic_file/trophies.rb +1 -2
- data/sufia-models/app/models/concerns/sufia/generic_file/virus_check.rb +16 -11
- data/sufia-models/app/models/concerns/sufia/model_methods.rb +1 -14
- data/sufia-models/app/models/concerns/sufia/user.rb +5 -0
- data/sufia-models/app/models/file_usage.rb +1 -1
- data/sufia-models/app/models/file_view_stat.rb +1 -1
- data/sufia-models/app/models/sufia/collection.rb +5 -0
- data/sufia-models/app/services/sufia/generic_file_indexing_service.rb +1 -1
- data/sufia-models/app/services/sufia/id_service.rb +1 -2
- data/sufia-models/app/services/sufia/noid.rb +4 -24
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +6 -1
- data/sufia-models/lib/generators/sufia/models/templates/app/models/collection.rb +2 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/resque_config.rb +1 -1
- data/sufia-models/lib/generators/sufia/models/templates/config/solrconfig.xml +46 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +9 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_external_key_to_content_blocks.rb +6 -0
- data/sufia-models/lib/generators/sufia/models/update_content_blocks_generator.rb +18 -0
- data/sufia-models/lib/sufia/messages.rb +11 -12
- data/sufia-models/lib/sufia/models/engine.rb +2 -1
- data/sufia-models/lib/sufia/models/stats/user_stat_importer.rb +9 -5
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia-models/sufia-models.gemspec +5 -5
- data/sufia.gemspec +15 -15
- data/tasks/sufia-dev.rake +0 -16
- metadata +86 -64
- data/LICENSE.md +0 -14
- data/app/jobs/ingest_local_file_job.rb +0 -39
- data/sufia-models/app/models/collection.rb +0 -3
- data/sufia-models/app/services/sufia/indexing_service.rb +0 -15
@@ -14,7 +14,7 @@ FactoryGirl.define do
|
|
14
14
|
factory :fixture do
|
15
15
|
factory :public_pdf do
|
16
16
|
transient do
|
17
|
-
id "
|
17
|
+
id "fixturepdf"
|
18
18
|
end
|
19
19
|
initialize_with { new(id: id) }
|
20
20
|
read_groups ["public"]
|
@@ -22,12 +22,12 @@ FactoryGirl.define do
|
|
22
22
|
subject %w"lorem ipsum dolor sit amet"
|
23
23
|
title ["fake_document.pdf"]
|
24
24
|
before(:create) do |gf|
|
25
|
-
gf.title = ["Fake
|
25
|
+
gf.title = ["Fake PDF Title"]
|
26
26
|
end
|
27
27
|
end
|
28
28
|
factory :public_mp3 do
|
29
29
|
transient do
|
30
|
-
id "
|
30
|
+
id "fixturemp3"
|
31
31
|
end
|
32
32
|
initialize_with { new(id: id) }
|
33
33
|
subject %w"consectetur adipisicing elit"
|
@@ -36,7 +36,7 @@ FactoryGirl.define do
|
|
36
36
|
end
|
37
37
|
factory :public_wav do
|
38
38
|
transient do
|
39
|
-
id "
|
39
|
+
id "fixturewav"
|
40
40
|
end
|
41
41
|
initialize_with { new(id: id) }
|
42
42
|
resource_type ["Audio", "Dataset"]
|
data/spec/factories/users.rb
CHANGED
@@ -14,7 +14,7 @@ FactoryGirl.define do
|
|
14
14
|
factory :user_with_mail do
|
15
15
|
after(:create) do |user|
|
16
16
|
# TODO: what is this class for?
|
17
|
-
# <span class="batchid ui-helper-hidden">
|
17
|
+
# <span class="batchid ui-helper-hidden">fake_batch_id</span>
|
18
18
|
message = BatchMessage.new
|
19
19
|
|
20
20
|
# Create examples of single file successes and failures
|
@@ -42,9 +42,8 @@ FactoryGirl.define do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
class MockFile
|
45
|
-
attr_accessor :
|
45
|
+
attr_accessor :to_s, :id
|
46
46
|
def initialize id, string
|
47
|
-
self.noid = id
|
48
47
|
self.id = id
|
49
48
|
self.to_s = string
|
50
49
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "Browse Dashboard", :
|
4
|
-
|
3
|
+
describe "Browse Dashboard", type: :feature do
|
5
4
|
let(:user) { FactoryGirl.create(:user) }
|
5
|
+
let!(:fixtures) { create_file_fixtures(user.user_key) }
|
6
|
+
|
6
7
|
before do
|
7
|
-
@fixtures = create_file_fixtures(user.user_key)
|
8
8
|
sign_in user
|
9
9
|
end
|
10
10
|
|
@@ -12,7 +12,7 @@ describe "Browse Dashboard", :type => :feature do
|
|
12
12
|
visit "/dashboard"
|
13
13
|
fill_in "q", with: "PDF"
|
14
14
|
click_button "search-submit-header"
|
15
|
-
expect(page).to have_content("Fake
|
15
|
+
expect(page).to have_content("Fake PDF Title")
|
16
16
|
end
|
17
17
|
|
18
18
|
context "within my files page" do
|
@@ -23,7 +23,7 @@ describe "Browse Dashboard", :type => :feature do
|
|
23
23
|
|
24
24
|
it "should display all the necessary information" do
|
25
25
|
# TODO this would make a good view test.
|
26
|
-
within("#document_#{
|
26
|
+
within("#document_#{fixtures.first.id}") do
|
27
27
|
click_button("Select an action")
|
28
28
|
end
|
29
29
|
expect(page).to have_content("Edit File")
|
@@ -39,7 +39,7 @@ describe "Browse Dashboard", :type => :feature do
|
|
39
39
|
it "should allow you to search your own files and remove constraints" do
|
40
40
|
fill_in "q", with: "PDF"
|
41
41
|
click_button "search-submit-header"
|
42
|
-
expect(page).to have_content("Fake
|
42
|
+
expect(page).to have_content("Fake PDF Title")
|
43
43
|
within(".constraints-container") do
|
44
44
|
expect(page).to have_content("You searched for:")
|
45
45
|
expect(page).to have_css("span.glyphicon-remove")
|
@@ -52,7 +52,7 @@ describe "Browse Dashboard", :type => :feature do
|
|
52
52
|
click_link "Subject"
|
53
53
|
click_link "more Subjects"
|
54
54
|
click_link "consectetur"
|
55
|
-
within("#document_#{
|
55
|
+
within("#document_#{fixtures[1].id}") do
|
56
56
|
click_link "Display all details of Test Document MP3.mp3"
|
57
57
|
end
|
58
58
|
expect(page).to have_content("File Details")
|
@@ -70,7 +70,7 @@ describe "Browse Dashboard", :type => :feature do
|
|
70
70
|
it "should refresh the page of files" do
|
71
71
|
# TODO this would make a good view test.
|
72
72
|
click_button "Refresh"
|
73
|
-
within("#document_#{
|
73
|
+
within("#document_#{fixtures.first.id}") do
|
74
74
|
click_button("Select an action")
|
75
75
|
expect(page).to have_content("Edit File")
|
76
76
|
expect(page).to have_content("Download File")
|
@@ -5,6 +5,13 @@ describe 'collection', :type => :feature do
|
|
5
5
|
visit '/dashboard'
|
6
6
|
first('#hydra-collection-add').click
|
7
7
|
expect(page).to have_content 'Create New Collection'
|
8
|
+
|
9
|
+
# Creator is a multi-value field, so it should have button to add more fields
|
10
|
+
expect(page).to have_selector "div.collection_creator .input-append button.add"
|
11
|
+
|
12
|
+
# Title is a single-value field, so it should not have the adder button
|
13
|
+
expect(page).to_not have_selector "div.collection_title .input-append button.add"
|
14
|
+
|
8
15
|
fill_in('Title', with: title)
|
9
16
|
fill_in('Abstract or Summary', with: description)
|
10
17
|
click_button("Create Collection")
|
@@ -67,7 +74,7 @@ describe 'collection', :type => :feature do
|
|
67
74
|
|
68
75
|
it "should delete a collection" do
|
69
76
|
expect(page).to have_content(collection.title)
|
70
|
-
within('#document_'+collection.
|
77
|
+
within('#document_'+collection.id) do
|
71
78
|
first('button.dropdown-toggle').click
|
72
79
|
first(".itemtrash").click
|
73
80
|
end
|
@@ -89,7 +96,7 @@ describe 'collection', :type => :feature do
|
|
89
96
|
|
90
97
|
it "should show a collection with a listing of Descriptive Metadata and catalog-style search results" do
|
91
98
|
expect(page).to have_content(collection.title)
|
92
|
-
within('#document_'+collection.
|
99
|
+
within('#document_'+collection.id) do
|
93
100
|
click_link("Display all details of collection title")
|
94
101
|
end
|
95
102
|
expect(page).to have_content(collection.title)
|
@@ -112,7 +119,7 @@ describe 'collection', :type => :feature do
|
|
112
119
|
it "should hide collection descriptive metadata when searching a collection" do
|
113
120
|
# URL: /dashboard/collections
|
114
121
|
expect(page).to have_content(collection.title)
|
115
|
-
within("#document_#{collection.
|
122
|
+
within("#document_#{collection.id}") do
|
116
123
|
click_link("Display all details of collection title")
|
117
124
|
end
|
118
125
|
# URL: /collections/collection-id
|
@@ -147,7 +154,7 @@ describe 'collection', :type => :feature do
|
|
147
154
|
it "should edit and update collection metadata" do
|
148
155
|
# URL: /dashboard/collections
|
149
156
|
expect(page).to have_content(collection.title)
|
150
|
-
within("#document_#{collection.
|
157
|
+
within("#document_#{collection.id}") do
|
151
158
|
find('button.dropdown-toggle').click
|
152
159
|
click_link('Edit Collection')
|
153
160
|
end
|
@@ -174,7 +181,7 @@ describe 'collection', :type => :feature do
|
|
174
181
|
|
175
182
|
it "should remove a file from a collection" do
|
176
183
|
expect(page).to have_content(collection.title)
|
177
|
-
within("#document_#{collection.
|
184
|
+
within("#document_#{collection.id}") do
|
178
185
|
first('button.dropdown-toggle').click
|
179
186
|
click_link('Edit Collection')
|
180
187
|
end
|
@@ -182,7 +189,7 @@ describe 'collection', :type => :feature do
|
|
182
189
|
expect(page).to have_field('collection_description', with: collection.description)
|
183
190
|
expect(page).to have_content(gf1.title.first)
|
184
191
|
expect(page).to have_content(gf2.title.first)
|
185
|
-
within("#document_#{gf1.
|
192
|
+
within("#document_#{gf1.id}") do
|
186
193
|
first('button.dropdown-toggle').click
|
187
194
|
click_button('Remove from Collection')
|
188
195
|
end
|
@@ -194,7 +201,7 @@ describe 'collection', :type => :feature do
|
|
194
201
|
|
195
202
|
it "should remove all files from a collection", js: true do
|
196
203
|
expect(page).to have_content(collection.title)
|
197
|
-
within('#document_'+collection.
|
204
|
+
within('#document_'+collection.id) do
|
198
205
|
first('button.dropdown-toggle').click
|
199
206
|
click_link('Edit Collection')
|
200
207
|
end
|
@@ -230,7 +237,7 @@ describe 'collection', :type => :feature do
|
|
230
237
|
it "should show a collection with a listing of Descriptive Metadata and catalog-style search results" do
|
231
238
|
visit '/dashboard/collections'
|
232
239
|
expect(page).to have_content(collection.title)
|
233
|
-
within('#document_'+collection.
|
240
|
+
within('#document_'+collection.id) do
|
234
241
|
click_link("Display all details of collection title")
|
235
242
|
end
|
236
243
|
expect(page).to have_css(".pager")
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Editing a file:", :type => :feature do
|
4
|
+
let(:user) { FactoryGirl.create(:user) }
|
5
|
+
let(:file_title) { 'Some kind of title' }
|
6
|
+
let(:file) { GenericFile.new.tap do |f|
|
7
|
+
f.title = [file_title]
|
8
|
+
f.apply_depositor_metadata(user.user_key)
|
9
|
+
f.save!
|
10
|
+
end
|
11
|
+
}
|
12
|
+
|
13
|
+
before { sign_in user }
|
14
|
+
|
15
|
+
context 'when the user tries to update file content, but forgets to select a file:' do
|
16
|
+
|
17
|
+
it 'displays an error' do
|
18
|
+
visit sufia.edit_generic_file_path(file)
|
19
|
+
click_link 'Versions'
|
20
|
+
click_button 'Upload New Version'
|
21
|
+
expect(page).to have_content "Edit #{file_title}"
|
22
|
+
expect(page).to have_content 'Please select a file'
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -7,10 +7,10 @@ describe "Create and use single-use links", :type => :feature do
|
|
7
7
|
|
8
8
|
let(:user) { FactoryGirl.find_or_create(:jill) }
|
9
9
|
let(:file) do
|
10
|
-
GenericFile.
|
11
|
-
f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
10
|
+
GenericFile.create do |f|
|
11
|
+
f.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png')
|
12
|
+
f.label = 'world.png'
|
12
13
|
f.apply_depositor_metadata(user)
|
13
|
-
f.save
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -8,6 +8,11 @@ describe Sufia::Forms::GenericFileEditForm do
|
|
8
8
|
expect(subject.terms).to eq([:resource_type, :title, :creator, :contributor, :description, :tag,
|
9
9
|
:rights, :publisher, :date_created, :subject, :language, :identifier, :based_near, :related_url])
|
10
10
|
end
|
11
|
+
|
12
|
+
it "doesn't contain fields that users shouldn't be allowed to edit" do
|
13
|
+
# date_uploaded is reserved for the original creation date of the record.
|
14
|
+
expect(subject.terms).not_to include(:date_uploaded)
|
15
|
+
end
|
11
16
|
end
|
12
17
|
|
13
18
|
it "should initialize multivalued fields" do
|
@@ -15,12 +20,14 @@ describe Sufia::Forms::GenericFileEditForm do
|
|
15
20
|
end
|
16
21
|
|
17
22
|
describe ".model_attributes" do
|
18
|
-
let(:params) { ActionController::Parameters.new(title: ['foo'], description: [''])}
|
23
|
+
let(:params) { ActionController::Parameters.new(title: ['foo'], description: [''], "permissions_attributes"=>{"2"=>{"access"=>"edit", "_destroy"=>"true", "id"=>"a987551e-b87f-427a-8721-3e5942273125"}})}
|
19
24
|
subject { described_class.model_attributes(params) }
|
20
25
|
|
21
26
|
it "should only change title" do
|
22
27
|
expect(subject['title']).to eq ["foo"]
|
23
28
|
expect(subject['description']).to be_empty
|
29
|
+
expect(subject['permissions_attributes']).to eq("2" => {"access"=>"edit", "id"=>"a987551e-b87f-427a-8721-3e5942273125", "_destroy"=>"true"})
|
24
30
|
end
|
25
31
|
end
|
32
|
+
|
26
33
|
end
|
@@ -11,11 +11,21 @@ describe ContentBlockHelper, :type => :helper do
|
|
11
11
|
expect(helper).to receive(:can?).with(:update, content_block).and_return(true)
|
12
12
|
end
|
13
13
|
let(:node) { Capybara::Node::Simple.new(subject) }
|
14
|
+
|
14
15
|
it "should show the preview and the form" do
|
15
16
|
expect(node).to have_selector "button[data-target='#edit_content_block_1'][data-behavior='reveal-editor']"
|
16
17
|
expect(node).to have_selector "form#edit_content_block_1[action='#{sufia.content_block_path(content_block)}']"
|
17
18
|
expect(subject).to be_html_safe
|
18
19
|
end
|
20
|
+
|
21
|
+
context "with option to create new:" do
|
22
|
+
subject { helper.editable_content_block(content_block, true) }
|
23
|
+
|
24
|
+
it "shows the button & form for a new content block" do
|
25
|
+
expect(node).to have_selector "button[data-target='#new_content_block'][data-behavior='reveal-editor']"
|
26
|
+
expect(node).to have_selector "form#new_content_block[action='#{sufia.content_blocks_path}']"
|
27
|
+
end
|
28
|
+
end
|
19
29
|
end
|
20
30
|
end
|
21
31
|
|
@@ -49,4 +49,46 @@ describe DashboardHelper, :type => :helper do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
|
53
|
+
describe "#number_of_files" do
|
54
|
+
let(:conn) { ActiveFedora::SolrService.instance.conn }
|
55
|
+
let(:user1) { User.new(email: "abc@test") }
|
56
|
+
let(:user2) { User.new(email: "abc@test.123") }
|
57
|
+
before do
|
58
|
+
create_models("GenericFile", user1, user2)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "finds only 3 files" do
|
62
|
+
expect(helper.number_of_files(user1)).to eq(3)
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#number_of_collections" do
|
68
|
+
let(:conn) { ActiveFedora::SolrService.instance.conn }
|
69
|
+
let(:user1) { User.new(email: "abc@test") }
|
70
|
+
let(:user2) { User.new(email: "abc@test.123") }
|
71
|
+
before do
|
72
|
+
create_models("Collection", user1, user2)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "finds only 3 files" do
|
76
|
+
expect(helper.number_of_collections(user1)).to eq(3)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
def create_models (model, user1, user2)
|
82
|
+
# deposited by the first user
|
83
|
+
3.times do |t|
|
84
|
+
conn.add id: "199#{t}", Solrizer.solr_name('depositor', :stored_searchable) => user1.user_key, "has_model_ssim"=>[model],
|
85
|
+
Solrizer.solr_name('depositor', :symbol) => user1.user_key
|
86
|
+
end
|
87
|
+
|
88
|
+
# deposited by the second user, but editable by the first
|
89
|
+
conn.add id: "1994", Solrizer.solr_name('depositor', :stored_searchable) => user2.user_key, "has_model_ssim"=>[model],
|
90
|
+
Solrizer.solr_name('depositor', :symbol) => user2.user_key, "edit_access_person_ssim" =>user1.user_key
|
91
|
+
conn.commit
|
92
|
+
end
|
93
|
+
|
52
94
|
end
|
@@ -42,25 +42,25 @@ describe SufiaHelper, :type => :helper do
|
|
42
42
|
|
43
43
|
describe "sufia_thumbnail_tag" do
|
44
44
|
context "for an image object" do
|
45
|
-
let(:document) { SolrDocument.new( mime_type_tesim: 'image/jpeg',
|
45
|
+
let(:document) { SolrDocument.new( mime_type_tesim: 'image/jpeg', id: '1234' ) }
|
46
46
|
it "should show the audio thumbnail" do
|
47
47
|
rendered = helper.sufia_thumbnail_tag(document, { width: 90 })
|
48
|
-
expect(rendered).to match /src="\/downloads\/1234\?
|
48
|
+
expect(rendered).to match /src="\/downloads\/1234\?file=thumbnail"/
|
49
49
|
expect(rendered).to match /width="90"/
|
50
50
|
end
|
51
51
|
end
|
52
52
|
context "for an audio object" do
|
53
|
-
let(:document) { SolrDocument.new( mime_type_tesim: 'audio/x-wave') }
|
53
|
+
let(:document) { SolrDocument.new( mime_type_tesim: 'audio/x-wave', id: '1234') }
|
54
54
|
it "should show the audio thumbnail" do
|
55
55
|
rendered = helper.sufia_thumbnail_tag(document, {})
|
56
56
|
expect(rendered).to match /src="\/assets\/audio.png"/
|
57
57
|
end
|
58
58
|
end
|
59
59
|
context "for an document object" do
|
60
|
-
let(:document) { SolrDocument.new( mime_type_tesim: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
60
|
+
let(:document) { SolrDocument.new( mime_type_tesim: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', id: '1234') }
|
61
61
|
it "should show the default thumbnail" do
|
62
62
|
rendered = helper.sufia_thumbnail_tag(document, { width: 90 })
|
63
|
-
expect(rendered).to match /src="\/downloads\/1234\?
|
63
|
+
expect(rendered).to match /src="\/downloads\/1234\?file=thumbnail"/
|
64
64
|
expect(rendered).to match /width="90"/
|
65
65
|
end
|
66
66
|
end
|
@@ -72,7 +72,7 @@ describe SufiaHelper, :type => :helper do
|
|
72
72
|
@user = mock_model(User)
|
73
73
|
allow(@user).to receive(:telephone).and_return('867-5309')
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
context "when @user is set" do
|
77
77
|
it "should return a link to the user's telephone" do
|
78
78
|
expect(helper.link_to_telephone).to eq("<a href=\"wtai://wp/mc;867-5309\">867-5309</a>")
|
@@ -84,7 +84,7 @@ describe SufiaHelper, :type => :helper do
|
|
84
84
|
expect(helper.link_to_telephone(@user)).to eq("<a href=\"wtai://wp/mc;867-5309\">867-5309</a>")
|
85
85
|
end
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
end
|
89
89
|
|
90
90
|
describe "#current_search_parameters" do
|
@@ -164,4 +164,31 @@ describe SufiaHelper, :type => :helper do
|
|
164
164
|
|
165
165
|
end
|
166
166
|
|
167
|
+
describe "#number_of_deposits" do
|
168
|
+
let(:conn) { ActiveFedora::SolrService.instance.conn }
|
169
|
+
let(:user1) { User.new(email: "abc@test") }
|
170
|
+
let(:user2) { User.new(email: "abc@test.123") }
|
171
|
+
before do
|
172
|
+
create_models("Collection", user1, user2)
|
173
|
+
end
|
174
|
+
|
175
|
+
it "finds only 3 files" do
|
176
|
+
expect(helper.number_of_deposits(user1)).to eq(3)
|
177
|
+
end
|
178
|
+
|
179
|
+
def create_models (model, user1, user2)
|
180
|
+
# deposited by the first user
|
181
|
+
3.times do |t|
|
182
|
+
conn.add id: "199#{t}", Solrizer.solr_name('depositor', :stored_searchable) => user1.user_key, "has_model_ssim"=>[model],
|
183
|
+
Solrizer.solr_name('depositor', :symbol) => user1.user_key
|
184
|
+
end
|
185
|
+
|
186
|
+
# deposited by the second user, but editable by the first
|
187
|
+
conn.add id: "1994", Solrizer.solr_name('depositor', :stored_searchable) => user2.user_key, "has_model_ssim"=>[model],
|
188
|
+
Solrizer.solr_name('depositor', :symbol) => user2.user_key, "edit_access_person_ssim" =>user1.user_key
|
189
|
+
conn.commit
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
|
167
194
|
end
|
@@ -3,14 +3,14 @@ require 'spec_helper'
|
|
3
3
|
describe TrophyHelper, :type => :helper do
|
4
4
|
describe "#display_trophy_link" do
|
5
5
|
let(:user) { FactoryGirl.create(:user) }
|
6
|
-
let(:
|
6
|
+
let(:id) { '9999' }
|
7
7
|
|
8
8
|
let(:text_attributes) { '[data-add-text="Highlight File on Profile"][data-remove-text="Unhighlight File"]' }
|
9
|
-
let(:url_attribute) { "[data-url=\"/users/#{user.to_param}/trophy?file_id
|
9
|
+
let(:url_attribute) { "[data-url=\"/users/#{user.to_param}/trophy?file_id=#{id}\"]" }
|
10
10
|
|
11
11
|
context "when there is no trophy" do
|
12
12
|
it "should have a link for highlighting" do
|
13
|
-
out = helper.display_trophy_link(user,
|
13
|
+
out = helper.display_trophy_link(user, id) { |text| "foo #{text} bar" }
|
14
14
|
node = Capybara::Node::Simple.new(out)
|
15
15
|
expect(node).to have_selector("a.trophy-class.trophy-off#{text_attributes}#{url_attribute}")
|
16
16
|
expect(node).to have_link 'foo Highlight File on Profile bar', href: '#'
|
@@ -19,18 +19,18 @@ describe TrophyHelper, :type => :helper do
|
|
19
19
|
|
20
20
|
context "when there is a trophy" do
|
21
21
|
before do
|
22
|
-
user.trophies.create(generic_file_id:
|
22
|
+
user.trophies.create(generic_file_id: id)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should have a link for highlighting" do
|
26
|
-
out = helper.display_trophy_link(user,
|
26
|
+
out = helper.display_trophy_link(user, id) { |text| "foo #{text} bar" }
|
27
27
|
node = Capybara::Node::Simple.new(out)
|
28
28
|
expect(node).to have_selector("a.trophy-class.trophy-on#{text_attributes}#{url_attribute}")
|
29
29
|
expect(node).to have_link 'foo Unhighlight File bar', href: '#'
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should allow removerow to be passed" do
|
33
|
-
out = helper.display_trophy_link(user,
|
33
|
+
out = helper.display_trophy_link(user, id, data: {removerow: true}) { |text| "foo #{text} bar" }
|
34
34
|
node = Capybara::Node::Simple.new(out)
|
35
35
|
expect(node).to have_selector("a.trophy-class.trophy-on[data-removerow=\"true\"]#{text_attributes}#{url_attribute}")
|
36
36
|
end
|