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
@@ -18,27 +18,29 @@ describe 'collection', :type => :feature do
|
|
18
18
|
let(:title2) {"Test Collection 2"}
|
19
19
|
let(:description2) {"Description for collection 2 we are testing."}
|
20
20
|
|
21
|
-
let(:user) { FactoryGirl.
|
21
|
+
let(:user) { FactoryGirl.create(:user) }
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
@gfs[x] = GenericFile.new(title: ["title #{x}"]).tap do |f|
|
23
|
+
let(:gfs) do
|
24
|
+
(0..1).map do |x|
|
25
|
+
GenericFile.create(title: ["title #{x}"]) do |f|
|
27
26
|
f.apply_depositor_metadata(user.user_key)
|
28
|
-
f.save!
|
29
27
|
end
|
30
28
|
end
|
31
|
-
@gf1 = @gfs[0]
|
32
|
-
@gf2 = @gfs[1]
|
33
29
|
end
|
34
30
|
|
31
|
+
let(:gf1) { gfs[0] }
|
32
|
+
let(:gf2) { gfs[1] }
|
33
|
+
|
35
34
|
describe 'create collection' do
|
35
|
+
let!(:gf1) { gfs[0] }
|
36
|
+
let!(:gf2) { gfs[1] }
|
37
|
+
|
36
38
|
before do
|
37
39
|
sign_in user
|
40
|
+
create_collection(title2, description2)
|
38
41
|
end
|
39
42
|
|
40
43
|
it "should create collection from the dashboard and include files", js: true do
|
41
|
-
create_collection(title2, description2)
|
42
44
|
visit '/dashboard/files'
|
43
45
|
first('input#check_all').click
|
44
46
|
click_button "Add to Collection" # opens the modal
|
@@ -47,109 +49,111 @@ describe 'collection', :type => :feature do
|
|
47
49
|
expect(page).to have_content "Items in this Collection"
|
48
50
|
# There are two rows in the table per document (one for the general info, one for the details)
|
49
51
|
# Make sure we have at least 2 documents
|
50
|
-
expect(page).to have_selector "table.table-zebra-striped tr#document_#{
|
51
|
-
expect(page).to have_selector "table.table-zebra-striped tr#document_#{
|
52
|
+
expect(page).to have_selector "table.table-zebra-striped tr#document_#{gf1.id}"
|
53
|
+
expect(page).to have_selector "table.table-zebra-striped tr#document_#{gf2.id}"
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
57
|
describe 'delete collection' do
|
58
|
+
let!(:collection) do
|
59
|
+
Collection.create( title: 'collection title', description: 'collection description') do |c|
|
60
|
+
c.apply_depositor_metadata(user.user_key)
|
61
|
+
end
|
62
|
+
end
|
56
63
|
before do
|
57
|
-
@collection = Collection.new title:'collection title'
|
58
|
-
@collection.description = 'collection description'
|
59
|
-
@collection.apply_depositor_metadata(user.user_key)
|
60
|
-
@collection.save
|
61
64
|
sign_in user
|
62
65
|
visit '/dashboard/collections'
|
63
66
|
end
|
64
67
|
|
65
68
|
it "should delete a collection" do
|
66
|
-
expect(page).to have_content(
|
67
|
-
within('#document_'
|
69
|
+
expect(page).to have_content(collection.title)
|
70
|
+
within('#document_'+collection.noid) do
|
68
71
|
first('button.dropdown-toggle').click
|
69
72
|
first(".itemtrash").click
|
70
73
|
end
|
71
|
-
expect(page).not_to have_content(
|
74
|
+
expect(page).not_to have_content(collection.title)
|
72
75
|
end
|
73
76
|
end
|
74
77
|
|
75
78
|
describe 'show collection' do
|
79
|
+
let!(:collection) do
|
80
|
+
Collection.create( title: 'collection title', description: 'collection description',
|
81
|
+
members: [gf1, gf2]) do |c|
|
82
|
+
c.apply_depositor_metadata(user.user_key)
|
83
|
+
end
|
84
|
+
end
|
76
85
|
before do
|
77
|
-
@collection = Collection.new title: 'collection title'
|
78
|
-
@collection.description = 'collection description'
|
79
|
-
@collection.apply_depositor_metadata(user.user_key)
|
80
|
-
@collection.members = [@gf1,@gf2]
|
81
|
-
@collection.save
|
82
86
|
sign_in user
|
83
87
|
visit '/dashboard/collections'
|
84
88
|
end
|
85
89
|
|
86
90
|
it "should show a collection with a listing of Descriptive Metadata and catalog-style search results" do
|
87
|
-
expect(page).to have_content(
|
88
|
-
within('#document_'
|
91
|
+
expect(page).to have_content(collection.title)
|
92
|
+
within('#document_'+collection.noid) do
|
89
93
|
click_link("Display all details of collection title")
|
90
94
|
end
|
91
|
-
expect(page).to have_content(
|
92
|
-
expect(page).to have_content(
|
95
|
+
expect(page).to have_content(collection.title)
|
96
|
+
expect(page).to have_content(collection.description)
|
93
97
|
# Should not show title and description a second time
|
94
|
-
expect(page).to_not have_css('.metadata-collections', text:
|
95
|
-
expect(page).to_not have_css('.metadata-collections', text:
|
98
|
+
expect(page).to_not have_css('.metadata-collections', text: collection.title)
|
99
|
+
expect(page).to_not have_css('.metadata-collections', text: collection.description)
|
96
100
|
# Should not have Collection Descriptive metadata table
|
97
101
|
expect(page).to have_content("Descriptions")
|
98
102
|
# Should have search results / contents listing
|
99
|
-
expect(page).to have_content(
|
100
|
-
expect(page).to have_content(
|
103
|
+
expect(page).to have_content(gf1.title.first)
|
104
|
+
expect(page).to have_content(gf2.title.first)
|
101
105
|
expect(page).to_not have_css(".pager")
|
102
106
|
|
103
107
|
click_link "Gallery"
|
104
|
-
expect(page).to have_content(
|
105
|
-
expect(page).to have_content(
|
108
|
+
expect(page).to have_content(gf1.title.first)
|
109
|
+
expect(page).to have_content(gf2.title.first)
|
106
110
|
end
|
107
111
|
|
108
112
|
it "should hide collection descriptive metadata when searching a collection" do
|
109
113
|
# URL: /dashboard/collections
|
110
|
-
expect(page).to have_content(
|
111
|
-
within("#document_#{
|
114
|
+
expect(page).to have_content(collection.title)
|
115
|
+
within("#document_#{collection.noid}") do
|
112
116
|
click_link("Display all details of collection title")
|
113
117
|
end
|
114
118
|
# URL: /collections/collection-id
|
115
|
-
expect(page).to have_content(
|
116
|
-
expect(page).to have_content(
|
117
|
-
expect(page).to have_content(
|
118
|
-
expect(page).to have_content(
|
119
|
-
fill_in('collection_search', with:
|
119
|
+
expect(page).to have_content(collection.title)
|
120
|
+
expect(page).to have_content(collection.description)
|
121
|
+
expect(page).to have_content(gf1.title.first)
|
122
|
+
expect(page).to have_content(gf2.title.first)
|
123
|
+
fill_in('collection_search', with: gf1.title.first)
|
120
124
|
click_button('collection_submit')
|
121
125
|
# Should not have Collection metadata table (only title and description)
|
122
126
|
expect(page).to_not have_content("Total Items")
|
123
|
-
expect(page).to have_content(
|
124
|
-
expect(page).to have_content(
|
127
|
+
expect(page).to have_content(collection.title)
|
128
|
+
expect(page).to have_content(collection.description)
|
125
129
|
# Should have search results / contents listing
|
126
130
|
expect(page).to have_content("Search Results")
|
127
|
-
expect(page).to have_content(
|
128
|
-
expect(page).to_not have_content(
|
131
|
+
expect(page).to have_content(gf1.title.first)
|
132
|
+
expect(page).to_not have_content(gf2.title.first)
|
129
133
|
end
|
130
134
|
end
|
131
135
|
|
132
136
|
describe 'edit collection' do
|
137
|
+
let!(:collection) do
|
138
|
+
Collection.create(title: 'collection title', description: 'collection description',
|
139
|
+
members: [gf1, gf2]) { |c| c.apply_depositor_metadata(user.user_key) }
|
140
|
+
end
|
141
|
+
|
133
142
|
before do
|
134
|
-
@collection = Collection.new(title: 'collection title')
|
135
|
-
@collection.description = 'collection description'
|
136
|
-
@collection.apply_depositor_metadata(user.user_key)
|
137
|
-
@collection.members = [@gf1, @gf2]
|
138
|
-
@collection.save
|
139
143
|
sign_in user
|
140
144
|
visit '/dashboard/collections'
|
141
145
|
end
|
142
146
|
|
143
147
|
it "should edit and update collection metadata" do
|
144
148
|
# URL: /dashboard/collections
|
145
|
-
expect(page).to have_content(
|
146
|
-
within("#document_#{
|
149
|
+
expect(page).to have_content(collection.title)
|
150
|
+
within("#document_#{collection.noid}") do
|
147
151
|
find('button.dropdown-toggle').click
|
148
152
|
click_link('Edit Collection')
|
149
153
|
end
|
150
154
|
# URL: /collections/collection-id/edit
|
151
|
-
expect(page).to have_field('collection_title', with:
|
152
|
-
expect(page).to have_field('collection_description', with:
|
155
|
+
expect(page).to have_field('collection_title', with: collection.title)
|
156
|
+
expect(page).to have_field('collection_description', with: collection.description)
|
153
157
|
new_title = "Altered Title"
|
154
158
|
new_description = "Completely new Description text."
|
155
159
|
creators = ["Dorje Trollo", "Vajrayogini"]
|
@@ -161,71 +165,72 @@ describe 'collection', :type => :feature do
|
|
161
165
|
end
|
162
166
|
# URL: /collections/collection-id
|
163
167
|
header = find('header')
|
164
|
-
expect(header).to_not have_content(
|
165
|
-
expect(header).to_not have_content(
|
168
|
+
expect(header).to_not have_content(collection.title)
|
169
|
+
expect(header).to_not have_content(collection.description)
|
166
170
|
expect(header).to have_content(new_title)
|
167
171
|
expect(header).to have_content(new_description)
|
168
172
|
expect(page).to have_content(creators.first)
|
169
173
|
end
|
170
174
|
|
171
175
|
it "should remove a file from a collection" do
|
172
|
-
expect(page).to have_content(
|
173
|
-
within("#document_#{
|
176
|
+
expect(page).to have_content(collection.title)
|
177
|
+
within("#document_#{collection.noid}") do
|
174
178
|
first('button.dropdown-toggle').click
|
175
179
|
click_link('Edit Collection')
|
176
180
|
end
|
177
|
-
expect(page).to have_field('collection_title', with:
|
178
|
-
expect(page).to have_field('collection_description', with:
|
179
|
-
expect(page).to have_content(
|
180
|
-
expect(page).to have_content(
|
181
|
-
within("#document_#{
|
181
|
+
expect(page).to have_field('collection_title', with: collection.title)
|
182
|
+
expect(page).to have_field('collection_description', with: collection.description)
|
183
|
+
expect(page).to have_content(gf1.title.first)
|
184
|
+
expect(page).to have_content(gf2.title.first)
|
185
|
+
within("#document_#{gf1.noid}") do
|
182
186
|
first('button.dropdown-toggle').click
|
183
187
|
click_button('Remove from Collection')
|
184
188
|
end
|
185
|
-
expect(page).to have_content(
|
186
|
-
expect(page).to have_content(
|
187
|
-
expect(page).not_to have_content(
|
188
|
-
expect(page).to have_content(
|
189
|
+
expect(page).to have_content(collection.title)
|
190
|
+
expect(page).to have_content(collection.description)
|
191
|
+
expect(page).not_to have_content(gf1.title.first)
|
192
|
+
expect(page).to have_content(gf2.title.first)
|
189
193
|
end
|
190
194
|
|
191
195
|
it "should remove all files from a collection", js: true do
|
192
|
-
expect(page).to have_content(
|
193
|
-
within('#document_'
|
196
|
+
expect(page).to have_content(collection.title)
|
197
|
+
within('#document_'+collection.noid) do
|
194
198
|
first('button.dropdown-toggle').click
|
195
199
|
click_link('Edit Collection')
|
196
200
|
end
|
197
|
-
expect(page).to have_field('collection_title', with:
|
198
|
-
expect(page).to have_field('collection_description', with:
|
199
|
-
expect(page).to have_content(
|
200
|
-
expect(page).to have_content(
|
201
|
+
expect(page).to have_field('collection_title', with: collection.title)
|
202
|
+
expect(page).to have_field('collection_description', with: collection.description)
|
203
|
+
expect(page).to have_content(gf1.title.first)
|
204
|
+
expect(page).to have_content(gf2.title.first)
|
201
205
|
first('input#check_all').click
|
202
206
|
click_button('Remove From Collection')
|
203
|
-
expect(page).to have_content(
|
204
|
-
expect(page).to have_content(
|
205
|
-
expect(page).not_to have_content(
|
206
|
-
expect(page).not_to have_content(
|
207
|
+
expect(page).to have_content(collection.title)
|
208
|
+
expect(page).to have_content(collection.description)
|
209
|
+
expect(page).not_to have_content(gf1.title.first)
|
210
|
+
expect(page).not_to have_content(gf2.title.first)
|
207
211
|
end
|
208
212
|
end
|
209
213
|
|
210
214
|
describe 'show pages of a collection' do
|
211
|
-
|
212
|
-
(
|
213
|
-
|
215
|
+
let(:gfs) do
|
216
|
+
(0..12).map do |x|
|
217
|
+
GenericFile.create(title: ["title #{x}"]) do |f|
|
214
218
|
f.apply_depositor_metadata(user.user_key)
|
215
|
-
f.save!
|
216
219
|
end
|
217
220
|
end
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
221
|
+
end
|
222
|
+
|
223
|
+
before { sign_in user }
|
224
|
+
|
225
|
+
let!(:collection) do
|
226
|
+
Collection.create(title: 'collection title', description: 'collection description',
|
227
|
+
members: gfs) { |c| c.apply_depositor_metadata(user.user_key) }
|
224
228
|
end
|
225
229
|
|
226
230
|
it "should show a collection with a listing of Descriptive Metadata and catalog-style search results" do
|
227
|
-
|
228
|
-
|
231
|
+
visit '/dashboard/collections'
|
232
|
+
expect(page).to have_content(collection.title)
|
233
|
+
within('#document_'+collection.noid) do
|
229
234
|
click_link("Display all details of collection title")
|
230
235
|
end
|
231
236
|
expect(page).to have_css(".pager")
|
data/spec/features/users_spec.rb
CHANGED
@@ -30,7 +30,7 @@ describe "User Profile", :type => :feature do
|
|
30
30
|
click_button 'Save Profile'
|
31
31
|
expect(page).to have_content 'Your profile has been updated'
|
32
32
|
click_link 'Profile'
|
33
|
-
expect(page).to
|
33
|
+
expect(page).to have_link('curatorOfData', href: 'http://twitter.com/curatorOfData')
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::Forms::CollectionEditForm do
|
4
|
+
let(:collection) { Collection.new }
|
5
|
+
let(:form) { described_class.new(collection) }
|
6
|
+
|
7
|
+
describe "#terms" do
|
8
|
+
subject { form.terms}
|
9
|
+
it { is_expected.to eq [:resource_type, :title, :creator, :contributor, :description,
|
10
|
+
:tag, :rights, :publisher, :date_created, :subject, :language,
|
11
|
+
:identifier, :based_near, :related_url] }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "unique?" do
|
15
|
+
context "with :title" do
|
16
|
+
subject { Sufia::Forms::CollectionEditForm.unique?(:title) }
|
17
|
+
it { is_expected.to be true }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::Forms::GenericFileEditForm do
|
4
|
+
subject { described_class.new(GenericFile.new) }
|
5
|
+
|
6
|
+
describe "#terms" do
|
7
|
+
it "should return a list" do
|
8
|
+
expect(subject.terms).to eq([:resource_type, :title, :creator, :contributor, :description, :tag,
|
9
|
+
:rights, :publisher, :date_created, :subject, :language, :identifier, :based_near, :related_url])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should initialize multivalued fields" do
|
14
|
+
expect(subject.title).to eq ['']
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".model_attributes" do
|
18
|
+
let(:params) { ActionController::Parameters.new(title: ['foo'], description: [''])}
|
19
|
+
subject { described_class.model_attributes(params) }
|
20
|
+
|
21
|
+
it "should only change title" do
|
22
|
+
expect(subject['title']).to eq ["foo"]
|
23
|
+
expect(subject['description']).to be_empty
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,16 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe GenericFileHelper
|
3
|
+
describe GenericFileHelper do
|
4
4
|
|
5
5
|
describe "#render_collection_list" do
|
6
|
-
|
7
6
|
context "using a file that is part of a collection" do
|
8
7
|
|
9
8
|
let(:collection) do
|
10
9
|
mock_model(Collection, title: "Foo Collection")
|
11
10
|
end
|
12
11
|
|
13
|
-
let(:gf) do
|
12
|
+
let(:gf) do
|
14
13
|
mock_model(GenericFile, { collections: [collection, collection] })
|
15
14
|
end
|
16
15
|
|
@@ -21,21 +20,48 @@ describe GenericFileHelper, :type => :helper do
|
|
21
20
|
it "should display a comma-delimited list of collections" do
|
22
21
|
expect(helper.render_collection_list(gf)).to eq("Is part of: " + [link,link].join(", "))
|
23
22
|
end
|
24
|
-
|
25
23
|
end
|
26
24
|
|
27
25
|
context "using a file that is not part of a collection" do
|
28
|
-
|
29
|
-
let(:gf) do
|
26
|
+
let(:gf) do
|
30
27
|
mock_model(GenericFile, { collections: [] })
|
31
28
|
end
|
32
29
|
|
33
30
|
it "should render nothing" do
|
34
31
|
expect(helper.render_collection_list(gf)).to be_nil
|
35
32
|
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "download links" do
|
37
|
+
let(:file) { GenericFile.new(id: "fake-1") }
|
38
|
+
let(:link_text) { helper.render_download_link("Download Fake") }
|
39
|
+
let(:icon_text) { helper.render_download_icon("Download the full-sized Fake") }
|
40
|
+
|
41
|
+
before { assign :generic_file, file }
|
42
|
+
|
43
|
+
describe "#render_download_link" do
|
44
|
+
it "has default text" do
|
45
|
+
expect(helper.render_download_link).to have_selector("#file_download")
|
46
|
+
expect(helper.render_download_link).to have_content("Download")
|
47
|
+
end
|
36
48
|
|
49
|
+
it "includes user-supplied link text" do
|
50
|
+
expect(link_text).to have_selector("#file_download")
|
51
|
+
expect(link_text).to have_content("Download Fake")
|
52
|
+
end
|
37
53
|
end
|
38
54
|
|
39
|
-
|
55
|
+
describe "#render_download_icon" do
|
56
|
+
it "has default text" do
|
57
|
+
expect(helper.render_download_icon).to have_selector("#file_download")
|
58
|
+
expect(helper.render_download_icon).to match("Download the document")
|
59
|
+
end
|
40
60
|
|
61
|
+
it "includes user-supplied icon text" do
|
62
|
+
expect(icon_text).to have_selector("#file_download")
|
63
|
+
expect(icon_text).to match("Download the full-sized Fake")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
41
67
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::PermissionsHelper do
|
4
|
+
describe "#visibility_help" do
|
5
|
+
subject { helper.visibility_help }
|
6
|
+
|
7
|
+
it "draws help_icon" do
|
8
|
+
expect(subject).to match /data-content="<p>This setting will determine who can view your file/
|
9
|
+
expect(subject).to have_selector 'a i.help-icon'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#share_with_help" do
|
14
|
+
subject { helper.share_with_help }
|
15
|
+
|
16
|
+
it "draws help_icon" do
|
17
|
+
expect(subject).to match /data-content="<p>You may grant "View\/Download/
|
18
|
+
expect(subject).to have_selector 'a i.help-icon'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|