sufia 4.0.0.rc1 → 4.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +2 -2
- data/Gemfile +9 -17
- data/README.md +18 -9
- data/Rakefile +10 -5
- data/SUFIA_VERSION +1 -1
- data/app/assets/javascripts/jquery.blacklightTagCloud.js +1 -1
- data/app/assets/javascripts/sufia.js +5 -22
- data/app/assets/javascripts/sufia/batch.js +8 -0
- data/app/assets/javascripts/sufia/batch_edit.js +19 -3
- data/app/assets/javascripts/sufia/dashboard_actions.js +23 -10
- data/app/assets/javascripts/sufia/multiForm.js +2 -2
- data/app/assets/javascripts/sufia/permissions.js +10 -9
- data/app/assets/javascripts/sufia/tabs.js +20 -0
- data/app/assets/stylesheets/catalog.css.scss +5 -0
- data/app/assets/stylesheets/collections.css.scss +40 -0
- data/app/assets/stylesheets/file-listing.css.scss +37 -13
- data/app/assets/stylesheets/generic_files.css.erb +5 -0
- data/app/assets/stylesheets/header.css.scss +1 -4
- data/app/assets/stylesheets/settings.css.scss +6 -0
- data/app/assets/stylesheets/styles.css.scss +4 -3
- data/app/assets/stylesheets/sufia-audio-overrides.css +2 -2
- data/app/assets/stylesheets/sufia.css.scss +27 -5
- data/app/assets/stylesheets/tagcloud.css +5 -1
- data/app/controllers/batch_controller.rb +3 -3
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +14 -1
- data/app/controllers/concerns/sufia/catalog.rb +0 -1
- data/app/controllers/concerns/sufia/controller.rb +5 -0
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +2 -9
- data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +3 -3
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +5 -1
- data/app/controllers/concerns/sufia/homepage_controller.rb +1 -1
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +3 -2
- data/app/helpers/batch_edits_helper.rb +6 -0
- data/app/helpers/generic_file_helper.rb +15 -0
- data/app/helpers/sufia/blacklight_override.rb +19 -3
- data/app/helpers/sufia/dashboard_helper_behavior.rb +25 -3
- data/app/helpers/sufia/records_helper_behavior.rb +13 -5
- data/app/helpers/sufia/sufia_helper_behavior.rb +15 -12
- data/app/models/concerns/sufia/solr_document_behavior.rb +5 -36
- data/app/views/_masthead.html.erb +1 -1
- data/app/views/_user_util_links.html.erb +6 -4
- data/app/views/advanced/_advanced_search_fields.html.erb +4 -4
- data/app/views/advanced/_advanced_search_form.html.erb +14 -17
- data/app/views/advanced/index.html.erb +3 -3
- data/app/views/batch/_metadata.html.erb +22 -24
- data/app/views/batch/_more_metadata.html.erb +1 -1
- data/app/views/batch/edit.html.erb +2 -2
- data/app/views/batch_edits/_check_all.html.erb +7 -9
- data/app/views/batch_edits/_delete_selected.html.erb +1 -0
- data/app/views/batch_edits/edit.html.erb +25 -26
- data/app/views/batch_edits/update_edit.js.erb +1 -1
- data/app/views/catalog/_facet_limit.html.erb +4 -12
- data/app/views/catalog/_search_form.html.erb +8 -13
- data/app/views/collections/_action_menu.html.erb +2 -2
- data/app/views/collections/_collection.html.erb +10 -31
- data/app/views/collections/_document_list.html.erb +1 -1
- data/app/views/collections/_edit_actions.html.erb +2 -2
- data/app/views/collections/_edit_descriptions.html.erb +3 -5
- data/app/views/collections/_form.html.erb +8 -10
- data/app/views/collections/_media_display.html.erb +1 -1
- data/app/views/collections/_show_actions.html.erb +5 -5
- data/app/views/collections/_show_descriptions.html.erb +13 -8
- data/app/views/collections/_show_document_list.html.erb +17 -0
- data/app/views/collections/_show_document_list_menu.html.erb +24 -0
- data/app/views/collections/_show_document_list_row.html.erb +63 -0
- data/app/views/collections/edit.html.erb +2 -2
- data/app/views/collections/show.html.erb +28 -19
- data/app/views/contact_form/new.html.erb +21 -29
- data/app/views/dashboard/_index_partials/_contents.html.erb +14 -0
- data/app/views/dashboard/_index_partials/_heading_actions.html.erb +18 -0
- data/app/views/dashboard/_index_partials/_heading_greetings.html.erb +8 -0
- data/app/views/dashboard/_index_partials/_stats.html.erb +6 -2
- data/app/views/dashboard/index.html.erb +5 -37
- data/app/views/generic_files/_breadcrumbs.html.erb +2 -0
- data/app/views/generic_files/_browse_everything.html.erb +2 -2
- data/app/views/generic_files/_descriptions.html.erb +4 -6
- data/app/views/generic_files/_field_form.html.erb +2 -2
- data/app/views/generic_files/_generic_file.html.erb +8 -29
- data/app/views/generic_files/_groups_description.html.erb +5 -4
- data/app/views/generic_files/_permission.html.erb +2 -2
- data/app/views/generic_files/_permission_form.html.erb +62 -77
- data/app/views/generic_files/_rights_modal.html.erb +0 -2
- data/app/views/generic_files/_share_with.html.erb +14 -0
- data/app/views/generic_files/_show_actions.html.erb +1 -1
- data/app/views/generic_files/_show_collections.html.erb +17 -0
- data/app/views/generic_files/_show_descriptions.html.erb +2 -2
- data/app/views/generic_files/_versioning.html.erb +2 -2
- data/app/views/generic_files/_visibility.html.erb +17 -0
- data/app/views/generic_files/show.html.erb +39 -2
- data/app/views/generic_files/stats.html.erb +1 -1
- data/app/views/generic_files/upload/_form_fields.html.erb +2 -2
- 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/generic_files/upload/_tos_checkbox.html.erb +3 -3
- data/app/views/homepage/_home_content.html.erb +0 -9
- data/app/views/homepage/_home_header.html.erb +1 -1
- data/app/views/homepage/_recent_document.html.erb +2 -2
- data/app/views/layouts/_head_tag_content.html.erb +7 -1
- data/app/views/layouts/sufia-dashboard.html.erb +4 -2
- data/app/views/layouts/sufia-one-column.html.erb +1 -1
- data/app/views/my/_action_menu.html.erb +1 -1
- data/app/views/my/_collection_action_menu.html.erb +3 -3
- data/app/views/my/_constraints.html.erb +11 -0
- data/app/views/my/_document_list.html.erb +1 -1
- data/app/views/my/_facet_limit.html.erb +4 -12
- data/app/views/my/_facets.html.erb +1 -3
- data/app/views/my/_index_partials/_default_group.html.erb +2 -3
- data/app/views/my/_index_partials/_list_collections.html.erb +17 -11
- data/app/views/my/_index_partials/_list_files.html.erb +20 -24
- data/app/views/my/_search_header.html.erb +5 -0
- data/app/views/my/_sort_and_per_page.html.erb +11 -7
- data/app/views/my/index.html.erb +9 -15
- data/app/views/records/_edit_field.html.erb +14 -10
- data/app/views/records/edit_fields/_default.html.erb +6 -0
- data/app/views/records/edit_fields/_description.html.erb +3 -7
- data/app/views/records/edit_fields/_resource_type.html.erb +4 -6
- data/app/views/records/edit_fields/_rights.html.erb +4 -5
- data/app/views/records/edit_fields/_suffix.html.erb +6 -3
- data/app/views/records/edit_fields/_type.html.erb +7 -12
- data/app/views/{generic_files → records}/show_fields/_based_near.html.erb +1 -1
- data/app/views/{generic_files → records}/show_fields/_contributor.html.erb +2 -2
- data/app/views/records/show_fields/_creator.html.erb +6 -0
- data/app/views/{generic_files → records}/show_fields/_date_created.html.erb +1 -1
- data/app/views/records/show_fields/_default.html.erb +6 -0
- data/app/views/records/show_fields/_description.html.erb +6 -0
- data/app/views/records/show_fields/_identifier.html.erb +4 -0
- data/app/views/{generic_files → records}/show_fields/_language.html.erb +1 -1
- data/app/views/{generic_files → records}/show_fields/_publisher.html.erb +1 -1
- data/app/views/records/show_fields/_related_url.html.erb +6 -0
- data/app/views/{generic_files → records}/show_fields/_resource_type.html.erb +1 -1
- data/app/views/{generic_files → records}/show_fields/_rights.html.erb +1 -1
- data/app/views/{generic_files → records}/show_fields/_subject.html.erb +1 -1
- data/app/views/{generic_files → records}/show_fields/_tag.html.erb +1 -1
- data/app/views/records/show_fields/_title.html.erb +6 -0
- data/app/views/shared/_attributes.html.erb +27 -0
- data/app/views/static/agreement.html.erb +1 -1
- data/app/views/users/_activity_log.html.erb +0 -2
- data/app/views/users/_follower_modal.html.erb +27 -23
- data/app/views/users/_following_modal.html.erb +27 -23
- data/app/views/users/_social_media_info.html.erb +4 -4
- data/app/views/users/_trophy_edit.html.erb +5 -7
- data/app/views/users/_user_info.html.erb +3 -3
- data/app/views/users/_user_util_links_extra.html.erb +4 -0
- data/app/views/users/edit.html.erb +28 -33
- data/app/views/users/index.html.erb +1 -1
- data/app/views/users/show.html.erb +0 -4
- data/config/jetty.yml +1 -1
- data/config/locales/sufia.en.yml +53 -12
- data/lib/generators/sufia/install_generator.rb +89 -0
- data/lib/generators/sufia/templates/catalog_controller.rb +1 -1
- data/lib/generators/sufia/upgrade400_generator.rb +4 -0
- data/lib/sufia.rb +1 -10
- data/lib/sufia/version.rb +1 -1
- data/solr_conf/conf/solrconfig.xml +31 -17
- data/spec/actors/generic_file/actor_spec.rb +17 -0
- data/spec/controllers/batch_controller_spec.rb +2 -2
- data/spec/controllers/batch_edits_controller_spec.rb +24 -19
- data/spec/controllers/catalog_controller_spec.rb +23 -12
- data/spec/controllers/collections_controller_spec.rb +19 -17
- data/spec/controllers/dashboard_controller_spec.rb +5 -19
- data/spec/controllers/generic_files_controller_spec.rb +35 -20
- data/spec/controllers/homepage_controller_spec.rb +25 -2
- data/spec/controllers/users_controller_spec.rb +99 -102
- data/spec/factories/generic_files.rb +2 -2
- data/spec/factories/users.rb +32 -2
- data/spec/features/browse_dashboard_files_spec.rb +14 -2
- data/spec/features/browse_files_spec.rb +5 -1
- data/spec/features/catalog_search_spec.rb +7 -6
- data/spec/features/collection_spec.rb +43 -33
- data/spec/features/display_dashboard_spec.rb +25 -22
- data/spec/features/notifications_spec.rb +9 -4
- data/spec/features/users_spec.rb +34 -25
- data/spec/fixtures/1.5mb-avatar.jpg +0 -0
- data/spec/helpers/batch_edits_helper_spec.rb +38 -0
- data/spec/helpers/dashboard_helper_spec.rb +16 -5
- data/spec/helpers/generic_file_helper_spec.rb +41 -0
- data/spec/helpers/records_helper_spec.rb +12 -0
- data/spec/jobs/active_fedora_pid_based_job_spec.rb +1 -1
- data/spec/jobs/audit_job_spec.rb +2 -3
- data/spec/jobs/batch_update_job_spec.rb +39 -24
- data/spec/jobs/event_jobs_spec.rb +1 -1
- data/spec/lib/sufia/id_service_spec.rb +25 -7
- data/spec/lib/sufia/messages_spec.rb +60 -0
- data/spec/lib/sufia/readable_permissions_spec.rb +56 -0
- data/spec/lib/sufia/writable_permissions_spec.rb +20 -0
- data/spec/models/batch_spec.rb +1 -1
- data/spec/models/collection_spec.rb +24 -2
- data/spec/models/featured_work_spec.rb +2 -2
- data/spec/models/file_content_datastream_spec.rb +5 -5
- data/spec/models/generic_file_spec.rb +149 -133
- data/spec/models/local_authority_spec.rb +1 -1
- data/spec/models/user_spec.rb +33 -6
- data/spec/spec_helper.rb +7 -10
- data/spec/{support → test_app_templates}/lib/generators/test_app_generator.rb +11 -6
- data/spec/views/batch/edit.html.erb_spec.rb +8 -2
- data/spec/views/catalog/index.html.erb_spec.rb +34 -0
- data/spec/views/catalog/{sort_and_per_pange.html.erb_spec.rb → sort_and_per_page.html.erb_spec.rb} +0 -0
- data/spec/views/collections/_form.html.erb_spec.rb +32 -0
- data/spec/views/collections/_show_descriptions.html.erb_spec.rb +25 -0
- data/spec/views/dashboard/index_spec.rb +33 -4
- data/spec/views/generic_file/_breadcrumbs.html.erb_spec.rb +32 -0
- data/spec/views/generic_file/show.html.erb_spec.rb +273 -8
- data/spec/views/users/_user_util_links.html.erb_spec.rb +25 -0
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +14 -5
- data/sufia-models/{lib/sufia/models → app}/jobs/active_fedora_pid_based_job.rb +0 -0
- data/sufia-models/{lib/sufia/models → app}/jobs/audit_job.rb +4 -10
- data/sufia-models/{lib/sufia/models → app}/jobs/batch_update_job.rb +22 -18
- data/sufia-models/{lib/sufia/models → app}/jobs/characterize_job.rb +0 -0
- data/sufia-models/{lib/sufia/models → app}/jobs/create_derivatives_job.rb +0 -0
- data/sufia-models/{lib/sufia/models → app}/jobs/import_url_job.rb +0 -0
- data/sufia-models/{lib/sufia/models → app}/jobs/resolrize_job.rb +0 -0
- data/sufia-models/app/models/collection.rb +1 -39
- data/sufia-models/{lib → app/models/concerns}/sufia/ability.rb +0 -0
- data/sufia-models/app/models/concerns/sufia/collection.rb +55 -0
- data/sufia-models/app/models/concerns/sufia/generic_file.rb +5 -11
- data/sufia-models/app/models/concerns/sufia/generic_file/audit.rb +1 -2
- data/sufia-models/app/models/concerns/sufia/generic_file/characterization.rb +4 -2
- data/sufia-models/app/models/concerns/sufia/generic_file/full_text_indexing.rb +27 -0
- data/sufia-models/app/models/concerns/sufia/generic_file/mime_types.rb +1 -0
- data/sufia-models/app/models/concerns/sufia/generic_file/permissions.rb +2 -49
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/model_methods.rb +0 -0
- data/sufia-models/app/models/concerns/sufia/user.rb +8 -1
- data/sufia-models/app/models/sufia/avatar_uploader.rb +2 -3
- data/sufia-models/app/services/sufia/noid.rb +9 -0
- data/sufia-models/config/locales/sufia.en.yml +1 -0
- data/sufia-models/lib/generators/sufia/models/fulltext_generator.rb +27 -0
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +7 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/analytics.yml +5 -5
- data/sufia-models/lib/generators/sufia/models/templates/config/solrconfig.xml +177 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +3 -1
- data/sufia-models/lib/generators/sufia/models/upgrade400_generator.rb +7 -0
- data/sufia-models/lib/sufia/messages.rb +67 -0
- data/sufia-models/lib/sufia/models.rb +2 -0
- data/sufia-models/lib/sufia/models/active_fedora/redis.rb +0 -6
- data/sufia-models/lib/sufia/models/engine.rb +1 -3
- data/sufia-models/lib/sufia/models/resque.rb +1 -1
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia-models/lib/sufia/permissions.rb +9 -0
- data/sufia-models/lib/sufia/permissions/readable.rb +20 -0
- data/sufia-models/lib/sufia/permissions/writable.rb +56 -0
- data/sufia-models/lib/tasks/sufia-models_tasks.rake +58 -2
- data/sufia-models/sufia-models.gemspec +11 -11
- data/sufia.gemspec +19 -9
- data/tasks/jetty.rake +6 -5
- data/tasks/sufia-dev.rake +4 -77
- metadata +235 -72
- data/app/assets/images/folder.png +0 -0
- data/app/views/collections/show_fields/_creator.html.erb +0 -11
- data/app/views/collections/show_fields/_description.html.erb +0 -8
- data/app/views/collections/show_fields/_title.html.erb +0 -8
- data/app/views/generic_files/edit_fields/_default.html.erb +0 -6
- data/app/views/generic_files/edit_fields/_description.html.erb +0 -5
- data/app/views/generic_files/edit_fields/_resource_type.html.erb +0 -6
- data/app/views/generic_files/edit_fields/_rights.html.erb +0 -6
- data/app/views/generic_files/edit_fields/_suffix.html.erb +0 -9
- data/app/views/generic_files/show_fields/_creator.html.erb +0 -7
- data/app/views/generic_files/show_fields/_default.html.erb +0 -6
- data/app/views/generic_files/show_fields/_description.html.erb +0 -7
- data/app/views/generic_files/show_fields/_identifier.html.erb +0 -4
- data/app/views/generic_files/show_fields/_related_url.html.erb +0 -6
- data/app/views/generic_files/show_fields/_title.html.erb +0 -7
- data/lib/generators/sufia/sufia_generator.rb +0 -89
- data/spec/active_fedora/unsaved_digital_object_spec.rb +0 -35
@@ -35,7 +35,7 @@ describe LocalAuthority do
|
|
35
35
|
LocalAuthority.harvest_tsv("geo", @tsv, prefix: 'http://sws.geonames.org/')
|
36
36
|
LocalAuthority.count.should == 1
|
37
37
|
auth = LocalAuthority.where(name: "geo").first
|
38
|
-
LocalAuthorityEntry.where(local_authority_id: auth.id).first.uri.start_with
|
38
|
+
expect(LocalAuthorityEntry.where(local_authority_id: auth.id).first.uri).to start_with('http://sws.geonames.org/')
|
39
39
|
LocalAuthorityEntry.count.should == 149
|
40
40
|
end
|
41
41
|
describe "when vocabs are harvested" do
|
data/spec/models/user_spec.rb
CHANGED
@@ -47,15 +47,15 @@ describe User do
|
|
47
47
|
@another_user.delete
|
48
48
|
end
|
49
49
|
it "should be able to follow another user" do
|
50
|
-
@user.
|
51
|
-
@another_user.
|
52
|
-
@another_user.
|
53
|
-
@user.
|
50
|
+
expect(@user).to be_following(@another_user)
|
51
|
+
expect(@another_user).to_not be_following(@user)
|
52
|
+
expect(@another_user).to be_followed_by(@user)
|
53
|
+
expect(@user).to_not be_followed_by(@another_user)
|
54
54
|
end
|
55
55
|
it "should be able to unfollow another user" do
|
56
56
|
@user.stop_following(@another_user)
|
57
|
-
@user.
|
58
|
-
@another_user.
|
57
|
+
expect(@user).to_not be_following(@another_user)
|
58
|
+
expect(@another_user).to_not be_followed_by(@user)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -73,4 +73,31 @@ describe User do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
end
|
76
|
+
|
77
|
+
describe "activity streams" do
|
78
|
+
let(:now){DateTime.now.to_i}
|
79
|
+
let(:user) { @user }
|
80
|
+
let(:activities) {
|
81
|
+
[{ action: 'so and so edited their profile', timestamp: now },
|
82
|
+
{ action: 'so and so uploaded a file', timestamp: (now - 360 ) }]
|
83
|
+
}
|
84
|
+
let(:file_activities) {
|
85
|
+
[{ action: 'uploaded a file', timestamp: now + 1 }]
|
86
|
+
}
|
87
|
+
|
88
|
+
before do
|
89
|
+
allow(user).to receive(:events).and_return(activities)
|
90
|
+
allow(user).to receive(:profile_events).and_return(file_activities)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "gathers the user's recent activity within the default amount of time" do
|
94
|
+
expect(user.get_all_user_activity).to eq(file_activities.concat(activities))
|
95
|
+
end
|
96
|
+
|
97
|
+
it "gathers the user's recent activity within a given timestamp" do
|
98
|
+
expect(user.get_all_user_activity(now-60)).to eq(file_activities.concat([activities.first]))
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
76
103
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,22 +1,23 @@
|
|
1
|
-
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
1
|
ENV["RAILS_ENV"] ||= 'test'
|
3
2
|
|
4
|
-
require
|
5
|
-
|
6
|
-
require 'database_cleaner'
|
3
|
+
require 'engine_cart'
|
4
|
+
EngineCart.load_application!
|
7
5
|
|
6
|
+
require 'mida'
|
8
7
|
require 'rspec/rails'
|
9
|
-
require 'rspec/
|
8
|
+
require 'rspec/its'
|
9
|
+
require 'rspec/active_model/mocks'
|
10
|
+
require 'factory_girl_rails'
|
10
11
|
require 'capybara/poltergeist'
|
11
12
|
Capybara.javascript_driver = :poltergeist
|
12
13
|
Capybara.default_wait_time = ENV['TRAVIS'] ? 30 : 15
|
13
14
|
require 'capybara/rspec'
|
14
15
|
require 'capybara/rails'
|
15
16
|
require 'equivalent-xml/rspec_matchers'
|
17
|
+
require 'database_cleaner'
|
16
18
|
|
17
19
|
require File.expand_path('../support/features', __FILE__)
|
18
20
|
|
19
|
-
|
20
21
|
if ENV['COVERAGE']
|
21
22
|
require 'simplecov'
|
22
23
|
SimpleCov.start 'rails'
|
@@ -60,9 +61,6 @@ end
|
|
60
61
|
|
61
62
|
Resque.inline = Rails.env.test?
|
62
63
|
|
63
|
-
FactoryGirl.definition_file_paths = [File.expand_path("../factories", __FILE__)]
|
64
|
-
FactoryGirl.find_definitions
|
65
|
-
|
66
64
|
module EngineRoutes
|
67
65
|
def self.included(base)
|
68
66
|
base.routes { Sufia::Engine.routes }
|
@@ -91,7 +89,6 @@ RSpec.configure do |config|
|
|
91
89
|
DatabaseCleaner.clean
|
92
90
|
end
|
93
91
|
|
94
|
-
|
95
92
|
# If true, the base class of anonymous controllers will be inferred
|
96
93
|
# automatically. This will be the default behavior in future versions of
|
97
94
|
# rspec-rails.
|
@@ -1,13 +1,18 @@
|
|
1
1
|
require 'rails/generators'
|
2
2
|
|
3
3
|
class TestAppGenerator < Rails::Generators::Base
|
4
|
-
source_root
|
4
|
+
source_root "./spec/test_app_templates"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
# if you need to generate any additional configuration
|
7
|
+
# into the test app, this generator will be run immediately
|
8
|
+
# after setting up the application
|
9
|
+
|
10
|
+
def install_engine
|
11
|
+
generate 'sufia:install', '-f'
|
12
|
+
end
|
13
|
+
|
14
|
+
def browse_everything_config
|
9
15
|
generate "browse_everything:config"
|
10
|
-
remove_file 'spec/factories/users.rb'
|
11
16
|
end
|
12
17
|
|
13
18
|
def add_analytics_config
|
@@ -35,5 +40,5 @@ class TestAppGenerator < Rails::Generators::Base
|
|
35
40
|
gsub_file 'app/assets/javascripts/application.js',
|
36
41
|
'//= require_tree .', '//= require sufia'
|
37
42
|
end
|
38
|
-
|
43
|
+
|
39
44
|
end
|
@@ -22,8 +22,14 @@ describe 'batch/edit.html.erb' do
|
|
22
22
|
@page = Capybara::Node::Simple.new(rendered)
|
23
23
|
end
|
24
24
|
|
25
|
-
it "should draw
|
26
|
-
expect(@page).to have_selector("
|
25
|
+
it "should draw tooltip for visibility" do
|
26
|
+
expect(@page).to have_selector("span#visibility_tooltip", count: 1)
|
27
|
+
expect(@page).to have_selector("a#generic_file_visibility_help", count: 1)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should draw tooltip for share_with" do
|
31
|
+
expect(@page).to have_selector("span#share_with_tooltip", count: 1)
|
32
|
+
expect(@page).to have_selector("a#generic_file_share_with_help", count: 1)
|
27
33
|
end
|
28
34
|
|
29
35
|
it "should draw modal for rights" do
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'catalog/index.html.erb' do
|
4
|
+
before do
|
5
|
+
allow(view).to receive(:blacklight_config).and_return(CatalogController.blacklight_config)
|
6
|
+
stub_template 'catalog/_search_sidebar.html.erb' => ''
|
7
|
+
stub_template 'catalog/_search_header.html.erb' => ''
|
8
|
+
allow(view).to receive(:render_opensearch_response_metadata).and_return('')
|
9
|
+
allow(view).to receive(:render_grouped_response?).and_return(false)
|
10
|
+
allow(view).to receive(:search_session).and_return({})
|
11
|
+
allow(view).to receive(:current_search_session).and_return(nil)
|
12
|
+
allow(view).to receive(:document_counter_with_offset).and_return(5)
|
13
|
+
params[:view] = 'gallery'
|
14
|
+
|
15
|
+
resp = []
|
16
|
+
assign(:response, resp )
|
17
|
+
allow(resp).to receive(:total_pages).and_return(1)
|
18
|
+
allow(resp).to receive(:current_page).and_return(1)
|
19
|
+
allow(resp).to receive(:limit_value).and_return(10)
|
20
|
+
allow(resp).to receive(:empty?).and_return(false)
|
21
|
+
|
22
|
+
@collection = Collection.new(pid: 'sufia:foo', title: 'collection1')
|
23
|
+
doc = SolrDocument.new(@collection.to_solr.merge('has_model_ssim' => [Collection.to_class_uri]))
|
24
|
+
assign(:document_list, [doc])
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
it 'appears on page without error' do
|
30
|
+
render
|
31
|
+
expect(rendered).to include(@collection.title)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/spec/views/catalog/{sort_and_per_pange.html.erb_spec.rb → sort_and_per_page.html.erb_spec.rb}
RENAMED
File without changes
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'collections/_form.html.erb' do
|
4
|
+
describe 'when the collection edit form is rendered' do
|
5
|
+
let(:collection) { Collection.new({title: 'the title', description: 'the description',
|
6
|
+
creator: 'the creator'})}
|
7
|
+
|
8
|
+
before do
|
9
|
+
controller.request.path_parameters[:id] = 'j12345'
|
10
|
+
collection.initialize_fields
|
11
|
+
assign(:collection, collection)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should draw the metadata fields for collection" do
|
15
|
+
render
|
16
|
+
expect(rendered).to have_selector("input#collection_title", count: 1)
|
17
|
+
expect(rendered).to have_selector("input#collection_creator", count: 1)
|
18
|
+
expect(rendered).to have_selector("textarea#collection_description", count: 1)
|
19
|
+
expect(rendered).to have_selector("input#collection_contributor", count: 1)
|
20
|
+
expect(rendered).to have_selector("input#collection_tag", count: 1)
|
21
|
+
expect(rendered).to have_selector("input#collection_subject", count: 1)
|
22
|
+
expect(rendered).to have_selector("input#collection_publisher", count: 1)
|
23
|
+
expect(rendered).to have_selector("input#collection_date_created", count: 1)
|
24
|
+
expect(rendered).to have_selector("input#collection_language", count: 1)
|
25
|
+
expect(rendered).to have_selector("input#collection_identifier", count: 1)
|
26
|
+
expect(rendered).to have_selector("input#collection_based_near", count: 1)
|
27
|
+
expect(rendered).to have_selector("input#collection_related_url", count: 1)
|
28
|
+
expect(rendered).to have_selector("select#collection_rights", count: 1)
|
29
|
+
expect(rendered).to have_selector("select#collection_resource_type", count: 1)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'collections/_show_descriptions.html.erb' do
|
4
|
+
context 'displaying a custom collection' do
|
5
|
+
before do
|
6
|
+
@collection = mock_model(Collection)
|
7
|
+
allow(view).to receive(:blacklight_config).and_return(Blacklight::Configuration.new)
|
8
|
+
allow(@collection).to receive(:date_modified).and_return(["today"])
|
9
|
+
allow(@collection).to receive(:terms_for_display).and_return([:date_modified])
|
10
|
+
allow(@collection).to receive(:members).and_return(["foo","bar"])
|
11
|
+
allow(@collection).to receive(:bytes).and_return(123456678)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should draw the metadata fields for collection" do
|
15
|
+
render
|
16
|
+
expect(rendered).to have_content 'Date modified'
|
17
|
+
expect(rendered).to include('itemprop="date_modified"')
|
18
|
+
expect(rendered).to have_content 'Total Items'
|
19
|
+
expect(rendered).to have_content '2'
|
20
|
+
expect(rendered).to have_content 'Size'
|
21
|
+
expect(rendered).to have_content '118 MB'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -11,6 +11,8 @@ describe "dashboard/index.html.erb" do
|
|
11
11
|
allow(@user).to receive(:all_following).and_return(["magneto"])
|
12
12
|
allow(@user).to receive(:followers).and_return(["wolverine","storm"])
|
13
13
|
allow(controller).to receive(:current_user).and_return(@user)
|
14
|
+
allow(view).to receive(:number_of_files).and_return("15")
|
15
|
+
allow(view).to receive(:number_of_collections).and_return("3")
|
14
16
|
assign(:activity, [])
|
15
17
|
assign(:notifications, [])
|
16
18
|
end
|
@@ -56,9 +58,13 @@ describe "dashboard/index.html.erb" do
|
|
56
58
|
expect(@sidebar).to include "Your Statistics"
|
57
59
|
expect(@sidebar).to include '<span class="label label-default">1</span>'
|
58
60
|
expect(@sidebar).to include '<span class="label label-default">2</span>'
|
59
|
-
expect(@sidebar).to include '<span class="label label-default">
|
61
|
+
expect(@sidebar).to include '<span class="label label-default">15</span>'
|
62
|
+
expect(@sidebar).to include '<span class="label label-default">3</span>'
|
60
63
|
end
|
61
64
|
|
65
|
+
it "should show the statistics before the profile" do
|
66
|
+
expect(@sidebar).to match /Your Statistics.*Charles Francis Xavier/m
|
67
|
+
end
|
62
68
|
end
|
63
69
|
|
64
70
|
describe "main" do
|
@@ -71,19 +77,42 @@ describe "dashboard/index.html.erb" do
|
|
71
77
|
{ action: 'so and so edited their profile', timestamp: @now },
|
72
78
|
{ action: 'so and so uploaded a file', timestamp: (@now - 360 ) }
|
73
79
|
])
|
74
|
-
assign(:notifications, FactoryGirl.create(:user_with_mail).mailbox.inbox)
|
75
80
|
end
|
76
81
|
|
77
82
|
it "should include recent activities and notifications" do
|
78
83
|
render
|
79
84
|
expect(rendered).to include "so and so edited their profile"
|
80
85
|
expect(rendered).to include "6 minutes ago"
|
81
|
-
expect(rendered).to include "You've got mail"
|
82
|
-
expect(rendered).to include "Sample notification"
|
83
86
|
end
|
84
87
|
|
85
88
|
end
|
86
89
|
|
90
|
+
context "with notifications" do
|
91
|
+
|
92
|
+
before do
|
93
|
+
assign(:notifications, FactoryGirl.create(:user_with_mail).mailbox.inbox)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "shows a link to all notifications" do
|
97
|
+
render
|
98
|
+
expect(rendered).to include "See all notifications"
|
99
|
+
end
|
100
|
+
|
101
|
+
it "defaults to a limited number of notifications" do
|
102
|
+
render
|
103
|
+
expect(rendered).to include "Single File 9"
|
104
|
+
expect(rendered).to_not include "Single File 2"
|
105
|
+
end
|
106
|
+
|
107
|
+
it "allows showing more notifications" do
|
108
|
+
Sufia.config.max_notifications_for_dashboard = 6
|
109
|
+
render
|
110
|
+
expect(rendered).to include "Single File 1"
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
end
|
115
|
+
|
87
116
|
context "without activities and notifications" do
|
88
117
|
|
89
118
|
it "should include headings for activities and notifications" do
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'generic_files/_breadcrumbs.html.erb' do
|
4
|
+
|
5
|
+
let(:request) { double("request", referer: referer) }
|
6
|
+
let(:generic_file) { GenericFile.new(title: ["Fake object"]) }
|
7
|
+
|
8
|
+
describe 'when coming from dashboard' do
|
9
|
+
let! (:referer) { "http://...dashboard" }
|
10
|
+
it "should link back to dashboard" do
|
11
|
+
allow(view).to receive(:request).and_return(request)
|
12
|
+
render partial: 'generic_files/breadcrumbs', locals: {include_file: false, generic_file: generic_file }
|
13
|
+
expect(rendered).to have_link(t('sufia.bread_crumb.file_list'), sufia.dashboard_files_path)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
describe 'when coming from files list' do
|
17
|
+
let! (:referer) { "http://...dashboard/files" }
|
18
|
+
it "should link back to files list" do
|
19
|
+
allow(view).to receive(:request).and_return(request)
|
20
|
+
render partial: 'generic_files/breadcrumbs', locals: {include_file: false, generic_file: generic_file }
|
21
|
+
expect(rendered).to have_link(t('sufia.bread_crumb.file_list'), sufia.dashboard_files_path)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
describe 'when coming from collections list' do
|
25
|
+
let! (:referer) { "http://...dashboard/collections" }
|
26
|
+
it "should link back to collections" do
|
27
|
+
allow(view).to receive(:request).and_return(request)
|
28
|
+
render partial: 'generic_files/breadcrumbs', locals: {include_file: false, generic_file: generic_file }
|
29
|
+
expect(rendered).to have_link(t('sufia.bread_crumb.collections_list'), sufia.dashboard_collections_path)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,23 +1,250 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'generic_files/show.html.erb' do
|
4
|
-
let(:
|
4
|
+
let(:depositor) {
|
5
|
+
stub_model(User,
|
6
|
+
user_key: 'bob',
|
7
|
+
twitter_handle: 'bot4lib')
|
8
|
+
}
|
9
|
+
|
10
|
+
let(:content) do
|
5
11
|
content = double('content', versions: [], mimeType: 'application/pdf')
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:generic_file) do
|
6
15
|
stub_model(GenericFile, noid: '123',
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
16
|
+
depositor: depositor.user_key,
|
17
|
+
audit_stat: 1,
|
18
|
+
title: ['My Title'],
|
19
|
+
description: ['Lorem ipsum lorem ipsum.'],
|
20
|
+
tag: ['bacon', 'sausage', 'eggs'],
|
21
|
+
rights: ['http://example.org/rights/1'],
|
22
|
+
based_near: ['Seattle, WA, US'],
|
23
|
+
contributor: ['Tweedledee', 'Tweedledum'],
|
24
|
+
creator: ['Doe, John', 'Doe, Jane'],
|
25
|
+
date_created: ['1984-01-02'],
|
26
|
+
language: ['Quechua'],
|
27
|
+
publisher: ['Random Publishing, Inc.'],
|
28
|
+
subject: ['Biology', 'Physiology', 'Ethnography'],
|
29
|
+
content: content)
|
30
|
+
end
|
11
31
|
|
12
32
|
before do
|
13
|
-
allow(controller).to receive(:current_user).and_return(
|
33
|
+
allow(controller).to receive(:current_user).and_return(depositor)
|
14
34
|
allow_any_instance_of(Ability).to receive(:can?).and_return(true)
|
35
|
+
allow(User).to receive(:find_by_user_key).with(generic_file.depositor).and_return(depositor)
|
36
|
+
allow(view).to receive(:blacklight_config).and_return(Blacklight::Configuration.new)
|
37
|
+
allow(view).to receive(:on_the_dashboard?).and_return(false)
|
15
38
|
assign(:generic_file, generic_file)
|
16
39
|
assign(:events, [])
|
40
|
+
assign(:notify_number, 0)
|
17
41
|
end
|
18
42
|
|
19
|
-
describe '
|
43
|
+
describe 'schema.org' do
|
44
|
+
describe 'descriptive metadata' do
|
45
|
+
before do
|
46
|
+
render template: 'generic_files/show.html.erb', layout: 'layouts/sufia-one-column'
|
47
|
+
@item = Mida::Document.new(rendered).items.first
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'sets itemtype to CreativeWork' do
|
51
|
+
expect(@item.type).to eq('http://schema.org/CreativeWork')
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'sets title as name' do
|
55
|
+
expect(@item.properties['name'].first).to eq('My Title')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'sets description' do
|
59
|
+
expect(@item.properties['description'].first).to eq('Lorem ipsum lorem ipsum.')
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'sets tag as keywords' do
|
63
|
+
expect(@item.properties['keywords']).to include('bacon', 'sausage', 'eggs')
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'sets based_near as contentLocation' do
|
67
|
+
based_near = @item.properties['contentLocation'].first
|
68
|
+
expect(based_near.type).to eq('http://schema.org/Place')
|
69
|
+
expect(based_near.properties['name'].first).to eq('Seattle, WA, US')
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'sets contributor' do
|
73
|
+
contributors = @item.properties['contributor']
|
74
|
+
expect(contributors.count).to eq(2)
|
75
|
+
contributor = contributors.first
|
76
|
+
expect(contributor.type).to eq('http://schema.org/Agent')
|
77
|
+
expect(contributor.properties['name'].first).to eq('Tweedledee')
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'sets creator' do
|
81
|
+
creators = @item.properties['creator']
|
82
|
+
expect(creators.count).to eq(2)
|
83
|
+
creator = creators.first
|
84
|
+
expect(creator.type).to eq('http://schema.org/Agent')
|
85
|
+
expect(creator.properties['name'].first).to eq('Doe, John')
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'sets date_created as dateCreated' do
|
89
|
+
expect(@item.properties['dateCreated'].first).to eq('1984-01-02')
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'sets language as inLanguage' do
|
93
|
+
expect(@item.properties['inLanguage'].first).to eq('Quechua')
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'sets publisher' do
|
97
|
+
publisher = @item.properties['publisher'].first
|
98
|
+
expect(publisher.type).to eq('http://schema.org/Organization')
|
99
|
+
expect(publisher.properties['name'].first).to eq('Random Publishing, Inc.')
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'sets subjects' do
|
103
|
+
subjects = @item.properties['about']
|
104
|
+
expect(subjects.count).to eq(3)
|
105
|
+
subject = subjects.first
|
106
|
+
expect(subject.type).to eq('http://schema.org/Thing')
|
107
|
+
expect(subject.properties['name'].first).to eq('Biology')
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'sets depositor as accountablePerson' do
|
111
|
+
depositor = @item.properties['accountablePerson'].first
|
112
|
+
expect(depositor.type).to eq('http://schema.org/Person')
|
113
|
+
expect(depositor.properties['name'].first).to eq('bob')
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe 'resource type-specific itemtypes' do
|
118
|
+
context 'when resource_type is Audio' do
|
119
|
+
it 'sets itemtype to AudioObject' do
|
120
|
+
generic_file.resource_type = ['Audio']
|
121
|
+
render template: 'generic_files/show.html.erb', layout: 'layouts/sufia-one-column'
|
122
|
+
@item = Mida::Document.new(rendered).items.first
|
123
|
+
expect(@item.type).to eq('http://schema.org/AudioObject')
|
124
|
+
end
|
125
|
+
end
|
126
|
+
context 'when resource_type is Conference Proceeding' do
|
127
|
+
it 'sets itemtype to ScholarlyArticle' do
|
128
|
+
generic_file.resource_type = ['Conference Proceeding']
|
129
|
+
render template: 'generic_files/show.html.erb', layout: 'layouts/sufia-one-column'
|
130
|
+
@item = Mida::Document.new(rendered).items.first
|
131
|
+
expect(@item.type).to eq('http://schema.org/ScholarlyArticle')
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe 'google scholar' do
|
138
|
+
# NOTE: before(:all) will not work in this context
|
139
|
+
before(:each) do
|
140
|
+
render template: 'generic_files/show.html.erb', layout: 'layouts/sufia-one-column'
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'appears in meta tags' do
|
144
|
+
gscholar_meta_tags = Nokogiri::HTML(rendered).xpath("//meta[contains(@name, 'citation_')]")
|
145
|
+
expect(gscholar_meta_tags.count).to eq(5)
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'displays title' do
|
149
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@name='citation_title']")
|
150
|
+
expect(tag.attribute('content').value).to eq('My Title')
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'displays authors' do
|
154
|
+
tags = Nokogiri::HTML(rendered).xpath("//meta[@name='citation_author']")
|
155
|
+
expect(tags.first.attribute('content').value).to eq('Doe, John')
|
156
|
+
expect(tags.last.attribute('content').value).to eq('Doe, Jane')
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'displays publication date' do
|
160
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@name='citation_publication_date']")
|
161
|
+
expect(tag.attribute('content').value).to eq('1984-01-02')
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'displays download URL' do
|
165
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@name='citation_pdf_url']")
|
166
|
+
expect(tag.attribute('content').value).to eq('http://test.host/downloads/123')
|
167
|
+
end
|
168
|
+
end
|
20
169
|
|
170
|
+
describe 'twitter cards' do
|
171
|
+
# NOTE: before(:all) will not work in this context
|
172
|
+
before(:each) do
|
173
|
+
render template: 'generic_files/show.html.erb', layout: 'layouts/sufia-one-column'
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'appears in meta tags' do
|
177
|
+
twitter_meta_tags = Nokogiri::HTML(rendered).xpath("//meta[contains(@name, 'twitter:') or contains(@property, 'og:')]")
|
178
|
+
expect(twitter_meta_tags.count).to eq(13)
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'displays twitter:card' do
|
182
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@name='twitter:card']")
|
183
|
+
expect(tag.attribute('content').value).to eq('product')
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'displays twitter:site' do
|
187
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@name='twitter:site']")
|
188
|
+
expect(tag.attribute('content').value).to eq('@HydraSphere')
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'displays twitter:creator' do
|
192
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@name='twitter:creator']")
|
193
|
+
expect(tag.attribute('content').value).to eq('@bot4lib')
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'displays og:site_name' do
|
197
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@property='og:site_name']")
|
198
|
+
expect(tag.attribute('content').value).to eq('Sufia')
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'displays og:type' do
|
202
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@property='og:type']")
|
203
|
+
expect(tag.attribute('content').value).to eq('object')
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'displays og:title' do
|
207
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@property='og:title']")
|
208
|
+
expect(tag.attribute('content').value).to eq('My Title')
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'displays og:description' do
|
212
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@property='og:description']")
|
213
|
+
expect(tag.attribute('content').value).to eq('Lorem ipsum lorem ipsum.')
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'displays og:image' do
|
217
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@property='og:image']")
|
218
|
+
expect(tag.attribute('content').value).to eq('http://test.host/downloads/123?datastream_id=thumbnail')
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'displays og:url' do
|
222
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@property='og:url']")
|
223
|
+
expect(tag.attribute('content').value).to eq('http://test.host/files/123')
|
224
|
+
end
|
225
|
+
|
226
|
+
it 'displays twitter:data1' do
|
227
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@name='twitter:data1']")
|
228
|
+
expect(tag.attribute('content').value).to eq('bacon, sausage, eggs')
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'displays twitter:label1' do
|
232
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@name='twitter:label1']")
|
233
|
+
expect(tag.attribute('content').value).to eq('Keywords')
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'displays twitter:data2' do
|
237
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@name='twitter:data2']")
|
238
|
+
expect(tag.attribute('content').value).to eq('http://example.org/rights/1')
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'displays twitter:label2' do
|
242
|
+
tag = Nokogiri::HTML(rendered).xpath("//meta[@name='twitter:label2']")
|
243
|
+
expect(tag.attribute('content').value).to eq('Rights')
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
describe 'analytics' do
|
21
248
|
context 'when enabled' do
|
22
249
|
before do
|
23
250
|
Sufia.config.analytics = true
|
@@ -44,7 +271,6 @@ describe 'generic_files/show.html.erb' do
|
|
44
271
|
end
|
45
272
|
|
46
273
|
describe 'featured' do
|
47
|
-
|
48
274
|
context "public file" do
|
49
275
|
before do
|
50
276
|
allow(generic_file).to receive(:public?).and_return(true)
|
@@ -69,4 +295,43 @@ describe 'generic_files/show.html.erb' do
|
|
69
295
|
end
|
70
296
|
end
|
71
297
|
end
|
298
|
+
|
299
|
+
describe 'collections list' do
|
300
|
+
context "when the file is not featured in any collections" do
|
301
|
+
|
302
|
+
it "should display the empty message" do
|
303
|
+
render
|
304
|
+
expect(rendered).to have_text(t('sufia.file.collections_list.empty'))
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
context "when the file is featured in collections" do
|
309
|
+
let(:collection1) {
|
310
|
+
stub_model(Collection,
|
311
|
+
title: 'collection1',
|
312
|
+
noid: '456')
|
313
|
+
}
|
314
|
+
|
315
|
+
before do
|
316
|
+
allow(generic_file).to receive(:collections).and_return([collection1])
|
317
|
+
end
|
318
|
+
|
319
|
+
it "should display the header and titles of collections it belongs to" do
|
320
|
+
render
|
321
|
+
expect(rendered).to have_text(t('sufia.file.collections_list.heading'))
|
322
|
+
expect(rendered).to have_text('collection1')
|
323
|
+
end
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
describe 'visibility' do
|
328
|
+
let(:expected) do
|
329
|
+
'<span class="label label-danger" title="'+t('sufia.visibility.private')+'">'+t('sufia.visibility.private')+'</span></a>'
|
330
|
+
end
|
331
|
+
it "should display the visibility badge" do
|
332
|
+
render
|
333
|
+
expect(rendered).to include(expected)
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
72
337
|
end
|