sufia 3.7.2 → 4.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +3 -0
- data/README.md +88 -11
- data/SUFIA_VERSION +1 -1
- data/app/assets/images/old_main_tulips.jpg +0 -0
- data/app/assets/javascripts/contact_form.js +0 -16
- data/app/assets/javascripts/jquery.blacklightTagCloud.js +44 -0
- data/app/assets/javascripts/jquery.tagcloud.js +116 -0
- data/app/assets/javascripts/jquery.tinysort.min.js +7 -0
- data/app/assets/javascripts/sufia.js +41 -44
- data/app/assets/javascripts/sufia/edit_metadata.js +1 -1
- data/app/assets/javascripts/sufia/editor.js +12 -0
- data/app/assets/javascripts/sufia/featured_works.js +64 -0
- data/app/assets/javascripts/sufia/fileupload.js +1 -1
- data/app/assets/javascripts/sufia/multiForm.js +1 -1
- data/app/assets/javascripts/sufia/permissions.js +4 -8
- data/app/assets/javascripts/sufia/single_use_link.js +1 -2
- data/app/assets/javascripts/sufia/trophy.js +42 -27
- data/app/assets/javascripts/terms_of_service.js +1 -1
- data/app/assets/stylesheets/dashboard.css.scss +81 -40
- data/app/assets/stylesheets/featured.css.scss +16 -0
- data/app/assets/stylesheets/fileupload/{jquery.fileupload-ui.css → jquery.fileupload-ui.css.erb} +2 -2
- data/app/assets/stylesheets/{generic_files.css → generic_files.css.erb} +6 -7
- data/app/assets/stylesheets/header.css.scss +93 -0
- data/app/assets/stylesheets/home-page.css.scss +50 -0
- data/app/assets/stylesheets/nestable.css.scss +111 -0
- data/app/assets/stylesheets/styles.css.scss +106 -0
- data/app/assets/stylesheets/sufia.css.scss +13 -8
- data/app/assets/stylesheets/tagcloud.css +83 -0
- data/app/assets/stylesheets/usage-stats.css +30 -0
- data/app/controllers/batch_controller.rb +0 -1
- data/app/controllers/concerns/sufia/catalog.rb +64 -0
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +16 -13
- data/app/controllers/content_blocks_controller.rb +8 -0
- data/app/controllers/featured_work_lists_controller.rb +16 -0
- data/app/controllers/featured_works_controller.rb +26 -0
- data/app/controllers/mailbox_controller.rb +1 -1
- data/app/controllers/pages_controller.rb +7 -0
- data/app/controllers/single_use_links_viewer_controller.rb +2 -5
- data/app/controllers/tinymce_assets_controller.rb +12 -0
- data/app/helpers/content_block_helper.rb +21 -0
- data/app/helpers/generic_file_helper.rb +2 -2
- data/app/helpers/sufia_helper.rb +8 -4
- data/app/helpers/trophy_helper.rb +15 -7
- data/app/models/content_block.rb +2 -0
- data/app/models/featured_work_list.rb +42 -0
- data/app/models/tinymce_asset.rb +3 -0
- data/app/uploaders/tinymce_asset_uploader.rb +51 -0
- data/app/views/_add_assets_links.html.erb +0 -16
- data/app/views/_controls.html.erb +17 -0
- data/app/views/_flash_msg.html.erb +2 -18
- data/app/views/_footer.html.erb +10 -15
- data/app/views/_ga.html.erb +0 -16
- data/app/views/_logo.html.erb +2 -2
- data/app/views/_masthead.html.erb +9 -36
- data/app/views/_user_util_links.html.erb +16 -11
- data/app/views/advanced/_advanced_search_facets.html.erb +0 -16
- data/app/views/advanced/_advanced_search_fields.html.erb +0 -16
- data/app/views/advanced/_advanced_search_help.html.erb +0 -16
- data/app/views/advanced/_facet_layout.html.erb +0 -16
- data/app/views/advanced/_facet_limit.html.erb +0 -16
- data/app/views/advanced/index.html.erb +2 -18
- data/app/views/batch/_metadata.html.erb +3 -3
- data/app/views/batch/edit.html.erb +4 -21
- data/app/views/catalog/_facet_limit.html.erb +11 -12
- data/app/views/catalog/_featured_researcher.html.erb +2 -0
- data/app/views/catalog/_home.html.erb +6 -2
- data/app/views/catalog/_home_content.html.erb +36 -0
- data/app/views/catalog/_home_header.html.erb +15 -0
- data/app/views/catalog/_recent_document.html.erb +1 -1
- data/app/views/catalog/_recents.html.erb +3 -4
- data/app/views/catalog/_search_form.html.erb +13 -9
- data/app/views/catalog/_tagcloud.html.erb +7 -0
- data/app/views/catalog/index.html.erb +4 -10
- data/app/views/contact_form/create.html.erb +0 -16
- data/app/views/contact_form/new.html.erb +0 -16
- data/app/views/dashboard/_constraints.html.erb +3 -19
- data/app/views/dashboard/_did_you_mean.html.erb +0 -16
- data/app/views/dashboard/_document_list.html.erb +0 -16
- data/app/views/dashboard/_facet_layout.html.erb +1 -17
- data/app/views/dashboard/_facet_limit.html.erb +5 -5
- data/app/views/dashboard/_facet_selected.html.erb +1 -17
- data/app/views/dashboard/_facets.html.erb +0 -18
- data/app/views/dashboard/_heading.html.erb +1 -1
- data/app/views/dashboard/_index_partials/_default_group.html.erb +7 -23
- data/app/views/dashboard/_index_partials/_list_files.html.erb +62 -57
- data/app/views/dashboard/_search_form.html.erb +10 -7
- data/app/views/dashboard/_show_partials/_default.html.erb +0 -18
- data/app/views/dashboard/_show_partials/_default_details.html.erb +0 -16
- data/app/views/dashboard/_show_partials/_facets.html.erb +0 -16
- data/app/views/dashboard/_sort_and_per_page.html.erb +10 -9
- data/app/views/dashboard/facet.html.erb +4 -19
- data/app/views/dashboard/index.html.erb +27 -49
- data/app/views/error/401.html.erb +1 -17
- data/app/views/error/404.html.erb +0 -16
- data/app/views/error/500.html.erb +0 -16
- data/app/views/error/single_use_error.html.erb +1 -17
- data/app/views/generic_files/_asset_deleted_flash.html.erb +0 -16
- data/app/views/generic_files/_asset_permissions_denial_flash.html.erb +0 -16
- data/app/views/generic_files/_asset_saved_flash.html.erb +0 -16
- data/app/views/generic_files/_asset_updated_flash.html.erb +0 -16
- data/app/views/generic_files/_breadcrumbs.html.erb +0 -16
- data/app/views/generic_files/_browse_everything.html.erb +24 -0
- data/app/views/generic_files/_descriptions.html.erb +1 -1
- data/app/views/generic_files/_field_form.html.erb +5 -5
- data/app/views/generic_files/_media_display.html.erb +3 -3
- data/app/views/generic_files/_permission_form.html.erb +5 -5
- data/app/views/generic_files/_rights_modal.html.erb +13 -29
- data/app/views/generic_files/_show_actions.html.erb +13 -1
- data/app/views/generic_files/_versioning.html.erb +14 -10
- data/app/views/generic_files/citation.html.erb +0 -16
- data/app/views/generic_files/edit.html.erb +10 -12
- data/app/views/generic_files/edit_fields/_default.html.erb +1 -1
- data/app/views/generic_files/edit_fields/_description.html.erb +1 -1
- data/app/views/generic_files/edit_fields/_resource_type.html.erb +2 -3
- data/app/views/generic_files/edit_fields/_rights.html.erb +1 -1
- data/app/views/generic_files/new.html.erb +11 -26
- data/app/views/generic_files/show.html.erb +7 -25
- data/app/views/generic_files/stats.html.erb +141 -0
- data/app/views/homepage/_featured.html.erb +11 -0
- data/app/views/homepage/_featured_fields.html.erb +18 -0
- data/app/views/homepage/_featured_works.html.erb +17 -0
- data/app/views/homepage/_sortable_featured.html.erb +26 -0
- data/app/views/layouts/_head_tag_content.html.erb +1 -1
- data/app/views/layouts/_homepage_sidebar2.html.erb +14 -0
- data/app/views/layouts/error.html.erb +3 -21
- data/app/views/layouts/homepage.html.erb +8 -37
- data/app/views/layouts/sufia-dashboard.html.erb +46 -0
- data/app/views/layouts/sufia-one-column.html.erb +8 -24
- data/app/views/layouts/sufia-two-column.html.erb +9 -8
- data/app/views/pages/show.html.erb +4 -0
- data/app/views/single_use_links_viewer/show.html.erb +2 -2
- data/app/views/static/agreement.html.erb +0 -17
- data/app/views/static/help.html.erb +0 -17
- data/app/views/static/mendeley.html.erb +0 -16
- data/app/views/static/subject_libraries.html.erb +0 -17
- data/app/views/static/terms.html.erb +0 -16
- data/app/views/static/zotero.html.erb +0 -16
- data/app/views/users/_activity_log.html.erb +2 -2
- data/app/views/users/_contributions.html.erb +6 -2
- data/app/views/users/_follower_modal.html.erb +2 -2
- data/app/views/users/_following_modal.html.erb +2 -2
- data/app/views/users/_left_sidebar.html.erb +1 -1
- data/app/views/users/_notify_link.html.erb +1 -1
- data/app/views/users/_notify_number.html.erb +1 -1
- data/app/views/users/_profile_actions.html.erb +3 -3
- data/app/views/users/_profile_tabs.html.erb +1 -1
- data/app/views/users/_search_form.html.erb +3 -2
- data/app/views/users/_social_media_info.html.erb +3 -3
- data/app/views/users/_trophy_edit.html.erb +2 -2
- data/app/views/users/_user_info.html.erb +27 -27
- data/app/views/users/_vitals.html.erb +2 -2
- data/app/views/users/edit.html.erb +39 -39
- data/app/views/users/index.html.erb +3 -3
- data/app/views/users/show.html.erb +7 -9
- data/config/locales/sufia.en.yml +15 -7
- data/config/routes.rb +12 -9
- data/lib/generators/sufia/sufia_generator.rb +18 -15
- data/lib/generators/sufia/templates/catalog_controller.rb +11 -73
- data/lib/generators/sufia/templates/config/tinymce.yml +7 -0
- data/lib/sufia.rb +7 -0
- data/lib/sufia/downloads_controller_behavior.rb +3 -4
- data/lib/sufia/files_controller_behavior.rb +38 -27
- data/lib/sufia/version.rb +1 -1
- data/spec/controllers/batch_controller_spec.rb +1 -1
- data/spec/controllers/batch_edits_controller_spec.rb +5 -5
- data/spec/controllers/catalog_controller_spec.rb +37 -58
- data/spec/controllers/content_blocks_controller_spec.rb +37 -0
- data/spec/controllers/downloads_controller_spec.rb +3 -11
- data/spec/controllers/featured_work_lists_controller_spec.rb +20 -0
- data/spec/controllers/featured_works_controller_spec.rb +50 -0
- data/spec/controllers/generic_files_controller_spec.rb +74 -9
- data/spec/controllers/mailbox_controller_spec.rb +1 -1
- data/spec/controllers/pages_controller_spec.rb +25 -0
- data/spec/controllers/single_use_links_controller_spec.rb +1 -1
- data/spec/controllers/single_use_links_viewer_controller_spec.rb +1 -1
- data/spec/controllers/tinymce_assets_controller_spec.rb +39 -0
- data/spec/controllers/users_controller_spec.rb +3 -8
- data/spec/factories/content_blocks.rb +4 -0
- data/spec/factories/featured_works.rb +4 -0
- data/spec/factories/generic_files.rb +46 -39
- data/spec/factories/users.rb +18 -18
- data/spec/features/browse_dashboard_files_spec.rb +6 -7
- data/spec/features/browse_files_spec.rb +9 -6
- data/spec/features/cloud_upload_spec.rb +18 -0
- data/spec/features/single_use_links_spec.rb +2 -3
- data/spec/helpers/content_block_helper_spec.rb +31 -0
- data/spec/helpers/generic_file_helper_spec.rb +3 -3
- data/spec/helpers/sufia_helper_spec.rb +13 -81
- data/spec/helpers/trophy_helper_spec.rb +39 -0
- data/spec/jobs/import_url_job_spec.rb +1 -1
- data/spec/jobs/ingest_local_file_job_spec.rb +1 -1
- data/spec/lib/sufia/usage_statistics_spec.rb +75 -0
- data/spec/models/ability_spec.rb +31 -0
- data/spec/models/active_fedora_pid_based_job_spec.rb +1 -1
- data/spec/models/audit_job_spec.rb +1 -1
- data/spec/models/batch_spec.rb +1 -1
- data/spec/models/batch_update_job_spec.rb +1 -1
- data/spec/models/event_jobs_spec.rb +1 -1
- data/spec/models/featured_work_list_spec.rb +23 -0
- data/spec/models/featured_work_spec.rb +42 -0
- data/spec/models/fits_datastream_spec.rb +2 -2
- data/spec/models/generic_file/reload_on_save_spec.rb +1 -1
- data/spec/models/generic_file/web_form_spec.rb +4 -4
- data/spec/models/generic_file_spec.rb +41 -40
- data/spec/models/pageview.rb +19 -0
- data/spec/models/properties_datastream_spec.rb +2 -2
- data/spec/models/solr_document_spec.rb +9 -0
- data/spec/models/user_spec.rb +2 -2
- data/spec/routing/featured_works_route_spec.rb +16 -0
- data/spec/routing/route_spec.rb +10 -15
- data/spec/spec_helper.rb +3 -0
- data/spec/support/lib/generators/test_app_generator.rb +19 -8
- data/spec/views/dashboard/facet_limit.html.erb_spec.rb +2 -2
- data/spec/views/generic_file/show.html.erb_spec.rb +44 -0
- data/spec/views/generic_file/stats.html.erb_spec.rb +47 -0
- data/spec/views/users/_follower_modal.html.erb_spec.rb +18 -0
- data/spec/views/users/_following_modal.html.erb_spec.rb +18 -0
- data/spec/views/users/index.html.erb_spec.rb +1 -1
- data/sufia-models/app/models/batch.rb +1 -1
- data/sufia-models/app/models/concerns/sufia/properties_datastream_behavior.rb +30 -0
- data/sufia-models/app/models/concerns/sufia/user.rb +1 -1
- data/sufia-models/app/models/datastreams/batch_rdf_datastream.rb +4 -7
- data/sufia-models/app/models/datastreams/fits_datastream.rb +3 -0
- data/sufia-models/app/models/datastreams/generic_file_rdf_datastream.rb +53 -51
- data/sufia-models/app/models/datastreams/properties_datastream.rb +1 -15
- data/sufia-models/app/models/featured_work.rb +22 -0
- data/sufia-models/app/models/sufia/pageview.rb +9 -0
- data/sufia-models/{lib/sufia/models → app/services/sufia}/id_service.rb +0 -0
- data/sufia-models/{lib/sufia/models → app/services/sufia}/noid.rb +0 -0
- data/sufia-models/app/services/sufia/usage_statistics.rb +73 -0
- data/sufia-models/config/locales/sufia.en.yml +3 -4
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +23 -8
- data/sufia-models/lib/generators/sufia/models/templates/config/analytics.yml +9 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/mime_types.rb +6 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +11 -2
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_content_blocks.rb +10 -0
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_featured_works.rb +12 -0
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_tinymce_assets.rb +8 -0
- data/sufia-models/lib/generators/sufia/models/usagestats_generator.rb +19 -0
- data/sufia-models/lib/sufia/ability.rb +34 -0
- data/sufia-models/lib/sufia/models/engine.rb +5 -3
- data/sufia-models/lib/sufia/models/generic_file.rb +4 -2
- data/sufia-models/lib/sufia/models/generic_file/export.rb +3 -3
- data/sufia-models/lib/sufia/models/generic_file/featured.rb +14 -0
- data/sufia-models/lib/sufia/models/solr_document_behavior.rb +11 -4
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia-models/sufia-models.gemspec +6 -5
- data/sufia.gemspec +6 -4
- data/tasks/release.rake +1 -0
- data/tasks/sufia-dev.rake +5 -1
- data/vendor/assets/javascripts/flot/excanvas.js +1428 -0
- data/vendor/assets/javascripts/flot/jquery.flot.js +3137 -0
- data/vendor/assets/javascripts/flot/jquery.flot.selection.js +360 -0
- data/vendor/assets/javascripts/flot/jquery.flot.time.js +431 -0
- data/vendor/assets/javascripts/nestable.js +647 -0
- data/vendor/assets/javascripts/video.js +135 -126
- data/{app → vendor}/assets/stylesheets/video-js.css.erb +7 -6
- metadata +155 -33
- data/app/assets/stylesheets/application-bootstrap.css.erb +0 -295
- data/app/assets/stylesheets/audio-js.css +0 -3
- data/app/assets/stylesheets/blacklight_more_facets.css +0 -427
- data/app/assets/stylesheets/bootstrap.min.css.erb +0 -1433
- data/app/assets/stylesheets/contact_form.css +0 -4
- data/app/assets/stylesheets/reset_body.css +0 -4
- data/app/assets/stylesheets/trophy.css +0 -7
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -84
- data/app/helpers/facets_helper.rb +0 -3
- data/app/helpers/sufia/facets_helper_behavior.rb +0 -23
- data/app/views/catalog/_home_text.html.erb +0 -10
- data/app/views/generic_files/_dropbox_import.html.erb +0 -3
- data/app/views/generic_files/upload/_dropbox_chooser.html.erb +0 -39
- data/app/views/static/about.html.erb +0 -21
- data/spec/helpers/render_constraints_helper_behavior_spec.rb +0 -42
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe "Browse Dashboard files" do
|
4
4
|
|
5
5
|
before do
|
6
|
-
find_or_create_file_fixtures
|
6
|
+
@fixtures = find_or_create_file_fixtures
|
7
7
|
sign_in :user_with_fixtures
|
8
8
|
end
|
9
9
|
|
@@ -18,14 +18,13 @@ describe "Browse Dashboard files" do
|
|
18
18
|
|
19
19
|
it "should allow you to browse facets" do
|
20
20
|
# TODO: fix more facets link!
|
21
|
-
|
22
|
-
visit '/'
|
21
|
+
click_link "dashboard"
|
23
22
|
click_link "more Subjects"
|
24
23
|
click_link "consectetur"
|
25
|
-
#
|
26
|
-
|
27
|
-
|
28
|
-
page.
|
24
|
+
within("#document_#{@fixtures[1].noid}") do
|
25
|
+
click_link "Test Document MP3.mp3"
|
26
|
+
end
|
27
|
+
page.should have_content "File Details"
|
29
28
|
end
|
30
29
|
|
31
30
|
it "should allow me to edit files (from the fixtures)" do
|
@@ -4,26 +4,29 @@ describe "Browse files" do
|
|
4
4
|
|
5
5
|
before(:all) do
|
6
6
|
@fixtures = find_or_create_file_fixtures
|
7
|
+
@fixtures[0].tag = "key"
|
7
8
|
(1..25).each do |i|
|
8
9
|
@fixtures[0].tag << i
|
9
10
|
end
|
10
11
|
@fixtures[0].save
|
11
12
|
end
|
12
13
|
|
14
|
+
before do
|
15
|
+
visit '/'
|
16
|
+
fill_in "search-field-header", with: "key"
|
17
|
+
click_button "search-submit-header"
|
18
|
+
click_link "more Keywords"
|
19
|
+
end
|
20
|
+
|
13
21
|
describe "when not logged in" do
|
14
22
|
it "should let us browse some of the fixtures" do
|
15
|
-
visit '/'
|
16
|
-
click_link "more Keywords"
|
17
23
|
click_link "18"
|
18
|
-
page.should have_content "
|
24
|
+
page.should have_content "Search Results"
|
19
25
|
click_link @fixtures[0].title[0]
|
20
26
|
page.should have_content "Download"
|
21
27
|
page.should_not have_content "Edit"
|
22
28
|
end
|
23
29
|
it "should allow you to click next" do
|
24
|
-
# TODO: fix more facets link!
|
25
|
-
visit '/'
|
26
|
-
click_link "more Keywords"
|
27
30
|
first(:link, 'Next').click
|
28
31
|
page.should have_content "5"
|
29
32
|
page.should_not have_content "11"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Selecting files to import from cloud providers" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
sign_in :user
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should have a Cloud file picker using browse-everything" do
|
10
|
+
click_link "upload"
|
11
|
+
click_link "Cloud Providers"
|
12
|
+
page.should have_content "Browse cloud files"
|
13
|
+
page.should have_content "Submit selected files"
|
14
|
+
page.should have_content "0 items selected"
|
15
|
+
click_button 'Browse cloud files'
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -6,10 +6,9 @@ describe "Create and use single-use links" do
|
|
6
6
|
include Sufia::Engine.routes.url_helpers
|
7
7
|
|
8
8
|
before do
|
9
|
-
user =
|
9
|
+
user = FactoryGirl.find_or_create(:jill)
|
10
10
|
|
11
|
-
login_as(user
|
12
|
-
|
11
|
+
login_as(user)
|
13
12
|
|
14
13
|
@file = GenericFile.new
|
15
14
|
@file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ContentBlockHelper do
|
4
|
+
let(:content_block) { FactoryGirl.create(:content_block, value: "<p>foo bar</p>") }
|
5
|
+
|
6
|
+
subject { helper.editable_content_block(content_block) }
|
7
|
+
|
8
|
+
context "for someone" do
|
9
|
+
context "with access" do
|
10
|
+
before do
|
11
|
+
expect(helper).to receive(:can?).with(:update, content_block).and_return(true)
|
12
|
+
end
|
13
|
+
let(:node) { Capybara::Node::Simple.new(subject) }
|
14
|
+
it "should show the preview and the form" do
|
15
|
+
expect(node).to have_selector "button[data-target='#edit_content_block_1'][data-behavior='reveal-editor']"
|
16
|
+
expect(node).to have_selector "form#edit_content_block_1[action='#{sufia.content_block_path(content_block)}']"
|
17
|
+
expect(subject).to be_html_safe
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "anonymous" do
|
23
|
+
before do
|
24
|
+
expect(helper).to receive(:can?).with(:update, content_block).and_return(false)
|
25
|
+
end
|
26
|
+
it "should show the content" do
|
27
|
+
expect(subject).to eq '<p>foo bar</p>'
|
28
|
+
expect(subject).to be_html_safe
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -3,12 +3,12 @@ require 'spec_helper'
|
|
3
3
|
describe GenericFileHelper do
|
4
4
|
it "draws add button" do
|
5
5
|
helper.add_field(:test).should ==
|
6
|
-
"<button class=\"adder btn\" id=\"additional_test_submit\" name=\"additional_test\">+<span class=\"
|
6
|
+
"<button class=\"adder btn\" id=\"additional_test_submit\" name=\"additional_test\">+<span class=\"sr-only\">add another test</span></button>"
|
7
7
|
end
|
8
8
|
|
9
9
|
it "draws subtract button" do
|
10
10
|
helper.subtract_field(:test).should ==
|
11
|
-
"<button class=\"remover btn\" id=\"additional_test_submit\" name=\"additional_test\">-<span class=\"
|
11
|
+
"<button class=\"remover btn\" id=\"additional_test_submit\" name=\"additional_test\">-<span class=\"sr-only\">add another test</span></button>"
|
12
12
|
end
|
13
13
|
|
14
14
|
it "draws help_icon" do
|
@@ -20,7 +20,7 @@ describe GenericFileHelper do
|
|
20
20
|
a.attr('data-original-title').should == "Keyword"
|
21
21
|
a.attr('id').should == "generic_file_tag_help"
|
22
22
|
i = a.children.first
|
23
|
-
i.attr('class').should == '
|
23
|
+
i.attr('class').should == 'glyphicon glyphicon-question-sign icon-large'
|
24
24
|
end
|
25
25
|
|
26
26
|
end
|
@@ -1,95 +1,27 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SufiaHelper do
|
4
|
-
describe "link_to_profile" do
|
5
|
-
it "should use User#to_params" do
|
6
|
-
u = User.new
|
7
|
-
u.stub(:user_key).and_return('justin@example.com')
|
8
|
-
User.should_receive(:find_by_user_key).with('justin@example.com').and_return(u)
|
9
|
-
helper.link_to_profile('justin@example.com').should == "<a href=\"/users/justin@example-dot-com\">justin@example.com</a>"
|
10
|
-
end
|
11
|
-
end
|
12
4
|
|
13
|
-
describe "
|
14
|
-
|
15
|
-
let(:dashboard_query_params) {{ :page => "2", :controller=>'dashboard'}}
|
5
|
+
describe "#link_to_facet_list" do
|
6
|
+
before { helper.stub(blacklight_config: CatalogController.blacklight_config) }
|
16
7
|
|
17
|
-
|
18
|
-
helper.
|
19
|
-
tag = helper.link_back_to_catalog
|
20
|
-
tag.should =~ /q=query/
|
21
|
-
tag.should =~ /f=facets/
|
22
|
-
tag.should =~ /per_page=10/
|
23
|
-
tag.should =~ /page=2/
|
24
|
-
end
|
8
|
+
context "with values" do
|
9
|
+
subject { helper.link_to_facet_list(['car', 'truck'], 'vehicle_type') }
|
25
10
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "number_of_deposits" do
|
35
|
-
let(:conn) { ActiveFedora::SolrService.instance.conn }
|
36
|
-
before do
|
37
|
-
# More than 10 times, because the pagination threshold is 10
|
38
|
-
12.times do |t|
|
39
|
-
conn.add :id => "199#{t}", Solrizer.solr_name('depositor', :stored_searchable) => user.user_key
|
40
|
-
end
|
41
|
-
conn.commit
|
42
|
-
end
|
43
|
-
after do
|
44
|
-
12.times do |t|
|
45
|
-
conn.delete_by_id "199#{t}"
|
11
|
+
it "should join the values" do
|
12
|
+
car_link = root_path(f: {'vehicle_type_sim' => ['car']})
|
13
|
+
truck_link = root_path(f: {'vehicle_type_sim' => ['truck']})
|
14
|
+
expect(subject).to eq "<a href=\"#{car_link}\">car</a>, <a href=\"#{truck_link}\">truck</a>"
|
15
|
+
expect(subject).to be_html_safe
|
46
16
|
end
|
47
|
-
conn.commit
|
48
|
-
end
|
49
|
-
|
50
|
-
let(:user) { double(user_key: 'justin') }
|
51
|
-
|
52
|
-
it "should return the correct number" do
|
53
|
-
expect(number_of_deposits(user)).to eq 12
|
54
17
|
end
|
55
|
-
end
|
56
18
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
before(:each) do
|
61
|
-
helper.stub(:blacklight_config).and_return blacklight_config
|
62
|
-
helper.stub(:url_for).and_return('http://example.com')
|
63
|
-
end
|
19
|
+
context "without values" do
|
20
|
+
subject { helper.link_to_facet_list([], 'vehicle_type') }
|
64
21
|
|
65
|
-
|
66
|
-
|
67
|
-
it "be html_safe and not have the remove link" do
|
68
|
-
item = double("item", :value=>'two', :hits=>9)
|
69
|
-
ret_val = helper.render_facet_value("one", item)
|
70
|
-
doc = Nokogiri::HTML(ret_val)
|
71
|
-
filter = doc.xpath("//a[@class='facet_select']")
|
72
|
-
filter.text.should == item.value
|
73
|
-
ret_val.should be_html_safe
|
74
|
-
end
|
75
|
-
it "use facet_display_value" do
|
76
|
-
item = double("item", :value=>'two', :hits=>9)
|
77
|
-
helper.stub(:facet_display_value).and_return('four')
|
78
|
-
ret_val = helper.render_facet_value("one", item)
|
79
|
-
doc = Nokogiri::HTML(ret_val)
|
80
|
-
filter = doc.xpath("//a[@class='facet_select']")
|
81
|
-
filter.text.should == 'four'
|
22
|
+
it "should show the default text" do
|
23
|
+
expect(subject).to eq "No value entered"
|
82
24
|
end
|
83
|
-
it "use facet_display_value for dashboard" do
|
84
|
-
params[:controller] = "dashboard"
|
85
|
-
item = double("item", :value=>'two', :hits=>9)
|
86
|
-
helper.stub(:facet_display_value).and_return('four')
|
87
|
-
ret_val = helper.render_facet_value("one", item)
|
88
|
-
doc = Nokogiri::HTML(ret_val)
|
89
|
-
filter = doc.xpath("//a[@class='facet_select']")
|
90
|
-
filter.text.should == 'four'
|
91
|
-
end
|
92
|
-
|
93
25
|
end
|
94
26
|
end
|
95
27
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TrophyHelper do
|
4
|
+
describe "#display_trophy_link" do
|
5
|
+
let(:user) { FactoryGirl.create(:user) }
|
6
|
+
let(:noid) { '9999' }
|
7
|
+
|
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=9999\"]" }
|
10
|
+
|
11
|
+
context "when there is no trophy" do
|
12
|
+
it "should have a link for highlighting" do
|
13
|
+
out = helper.display_trophy_link(user, noid) { |text| "foo #{text} bar" }
|
14
|
+
node = Capybara::Node::Simple.new(out)
|
15
|
+
expect(node).to have_selector("a.trophy-class.trophy-off#{text_attributes}#{url_attribute}")
|
16
|
+
expect(node).to have_link 'foo Highlight File on Profile bar', href: '#'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "when there is a trophy" do
|
21
|
+
before do
|
22
|
+
user.trophies.create(generic_file_id: noid)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should have a link for highlighting" do
|
26
|
+
out = helper.display_trophy_link(user, noid) { |text| "foo #{text} bar" }
|
27
|
+
node = Capybara::Node::Simple.new(out)
|
28
|
+
expect(node).to have_selector("a.trophy-class.trophy-on#{text_attributes}#{url_attribute}")
|
29
|
+
expect(node).to have_link 'foo Unhighlight File bar', href: '#'
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should allow removerow to be passed" do
|
33
|
+
out = helper.display_trophy_link(user, noid, data: {removerow: true}) { |text| "foo #{text} bar" }
|
34
|
+
node = Capybara::Node::Simple.new(out)
|
35
|
+
expect(node).to have_selector("a.trophy-class.trophy-on[data-removerow=\"true\"]#{text_attributes}#{url_attribute}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::UsageStatistics do
|
4
|
+
before do
|
5
|
+
token = OAuth2::AccessToken.new(nil, nil)
|
6
|
+
allow(subject).to receive(:token).and_return(token)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'responds to :config' do
|
10
|
+
expect(subject).to respond_to(:config)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'reads its config from a yaml file' do
|
14
|
+
expect(subject.config.keys.sort).to eql ['app_name', 'app_version', 'client_email', 'privkey_path', 'privkey_secret']
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'responds to :user' do
|
18
|
+
expect(subject).to respond_to(:user)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'instantiates a user' do
|
22
|
+
expect(subject.user).to be_a(Legato::User)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'responds to :profile' do
|
26
|
+
expect(subject).to respond_to(:profile)
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'querying' do
|
30
|
+
before do
|
31
|
+
profile = Legato::Management::Profile.new({"id" => 12345, "name" => "Profile 1", "accountId" => "12345", "webPropertyId" => "UA-12345-2", "timezone" => "America/Chicago"}, subject.user)
|
32
|
+
allow(subject).to receive(:profile).and_return(profile)
|
33
|
+
end
|
34
|
+
|
35
|
+
let(:query) { Sufia::UsageStatistics.profile.pageview }
|
36
|
+
|
37
|
+
it 'returns a query object' do
|
38
|
+
expect(query).to be_a(Legato::Query)
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'results' do
|
42
|
+
before(:all) do
|
43
|
+
@system_timezone = ENV['TZ']
|
44
|
+
ENV['TZ'] = 'UTC'
|
45
|
+
end
|
46
|
+
|
47
|
+
after(:all) do
|
48
|
+
ENV['TZ'] = @system_timezone
|
49
|
+
end
|
50
|
+
|
51
|
+
# Mock and stub Google Analytics results
|
52
|
+
before do
|
53
|
+
@mock_query = double('query')
|
54
|
+
allow(@mock_query).to receive(:collection).and_return([
|
55
|
+
OpenStruct.new(date: '2014-01-01', pageviews: 4),
|
56
|
+
OpenStruct.new(date: '2014-01-02', pageviews: 8),
|
57
|
+
OpenStruct.new(date: '2014-01-03', pageviews: 6),
|
58
|
+
OpenStruct.new(date: '2014-01-04', pageviews: 10),
|
59
|
+
OpenStruct.new(date: '2014-01-05', pageviews: 2)])
|
60
|
+
allow(@mock_query).to receive(:map).and_return(@mock_query.collection.map(&:marshal_dump))
|
61
|
+
allow(Sufia::UsageStatistics.profile).to receive(:pageview).and_return(@mock_query)
|
62
|
+
end
|
63
|
+
|
64
|
+
let(:results) { @mock_query }
|
65
|
+
|
66
|
+
it 'converts results to json' do
|
67
|
+
expect(subject.as_flot_json(results)).to eql('[[1388534400000,4],[1388620800000,8],[1388707200000,6],[1388793600000,10],[1388880000000,2]]')
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'calculates total page views' do
|
71
|
+
expect(subject.total_pageviews(results)).to eql(30)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'cancan/matchers'
|
3
|
+
|
4
|
+
describe Sufia::Ability do
|
5
|
+
|
6
|
+
|
7
|
+
describe "a user with no roles" do
|
8
|
+
let(:user) { nil }
|
9
|
+
subject { Ability.new(user) }
|
10
|
+
it { should_not be_able_to(:create, GenericFile) }
|
11
|
+
it { should_not be_able_to(:create, TinymceAsset) }
|
12
|
+
it { should_not be_able_to(:update, ContentBlock) }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "a registered user" do
|
16
|
+
let(:user) { FactoryGirl.create(:user) }
|
17
|
+
subject { Ability.new(user) }
|
18
|
+
it { should be_able_to(:create, GenericFile) }
|
19
|
+
it { should_not be_able_to(:create, TinymceAsset) }
|
20
|
+
it { should_not be_able_to(:update, ContentBlock) }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "a user in the admin group" do
|
24
|
+
let(:user) { FactoryGirl.create(:user) }
|
25
|
+
before { user.stub(groups: ['admin', 'registered']) }
|
26
|
+
subject { Ability.new(user) }
|
27
|
+
it { should be_able_to(:create, GenericFile) }
|
28
|
+
it { should be_able_to(:create, TinymceAsset) }
|
29
|
+
it { should be_able_to(:update, ContentBlock) }
|
30
|
+
end
|
31
|
+
end
|