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
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FeaturedWorksController do
|
4
|
+
describe "#create" do
|
5
|
+
before do
|
6
|
+
sign_in FactoryGirl.create(:user)
|
7
|
+
expect(controller).to receive(:authorize!).with(:create, FeaturedWork).and_return(true)
|
8
|
+
end
|
9
|
+
|
10
|
+
context "when there are no featured works" do
|
11
|
+
it "should create one" do
|
12
|
+
expect {
|
13
|
+
post :create, id: '1234abcd', format: :json
|
14
|
+
}.to change { FeaturedWork.count}.by(1)
|
15
|
+
expect(response).to be_successful
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when there are 5 featured works" do
|
20
|
+
before do
|
21
|
+
5.times do |n|
|
22
|
+
FeaturedWork.create(generic_file_id:n.to_s)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
it "should not create another" do
|
26
|
+
expect {
|
27
|
+
post :create, id: '1234abcd', format: :json
|
28
|
+
}.to_not change { FeaturedWork.count}
|
29
|
+
expect(response.status).to eq 422
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#destroy" do
|
35
|
+
|
36
|
+
let!(:featured_work) { FactoryGirl.create(:featured_work, generic_file_id: '1234abcd') }
|
37
|
+
|
38
|
+
before do
|
39
|
+
sign_in FactoryGirl.create(:user)
|
40
|
+
expect(controller).to receive(:authorize!).with(:destroy, FeaturedWork).and_return(true)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should remove it" do
|
44
|
+
expect {
|
45
|
+
delete :destroy, id: '1234abcd', format: :json
|
46
|
+
}.to change { FeaturedWork.count}.by(-1)
|
47
|
+
expect(response.status).to eq 204
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -3,17 +3,19 @@ require 'spec_helper'
|
|
3
3
|
describe GenericFilesController do
|
4
4
|
before do
|
5
5
|
controller.stub(:has_access?).and_return(true)
|
6
|
-
@user = FactoryGirl.find_or_create(:
|
6
|
+
@user = FactoryGirl.find_or_create(:jill)
|
7
7
|
sign_in @user
|
8
8
|
User.any_instance.stub(:groups).and_return([])
|
9
9
|
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
10
10
|
end
|
11
|
+
|
11
12
|
describe "#create" do
|
12
13
|
before do
|
13
14
|
@file_count = GenericFile.count
|
14
15
|
@mock = GenericFile.new({:pid => 'test:123'})
|
15
16
|
GenericFile.stub(:new).and_return(@mock)
|
16
17
|
end
|
18
|
+
|
17
19
|
after do
|
18
20
|
GenericFile.unstub(:new)
|
19
21
|
Batch.find("sample:batch_id").delete rescue
|
@@ -117,7 +119,23 @@ describe GenericFilesController do
|
|
117
119
|
response.body.should include("Error occurred while creating generic file.")
|
118
120
|
end
|
119
121
|
end
|
120
|
-
|
122
|
+
|
123
|
+
describe "#create with browse-everything" do
|
124
|
+
before do
|
125
|
+
GenericFile.delete_all
|
126
|
+
@json_from_browse_everything = {"0"=>{"url"=>"https://dl.dropbox.com/fake/filepicker-demo.txt.txt", "expires"=>"2014-03-31T20:37:36.214Z", "file_name"=>"filepicker-demo.txt.txt"}, "1"=>{"url"=>"https://dl.dropbox.com/fake/Getting%20Started.pdf", "expires"=>"2014-03-31T20:37:36.731Z", "file_name"=>"Getting+Started.pdf"}}
|
127
|
+
end
|
128
|
+
it "should ingest files from provide URLs" do
|
129
|
+
ImportUrlJob.should_receive(:new).twice {"ImportJob"}
|
130
|
+
Sufia.queue.should_receive(:push).with("ImportJob").twice
|
131
|
+
lambda { post :create, selected_files: @json_from_browse_everything, :batch_id => "sample:batch_id"}.should change(GenericFile, :count).by(2)
|
132
|
+
created_files = GenericFile.all
|
133
|
+
["https://dl.dropbox.com/fake/Getting%20Started.pdf", "https://dl.dropbox.com/fake/filepicker-demo.txt.txt"].each do |url|
|
134
|
+
created_files.map {|f| f.import_url}.should include(url)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
121
139
|
describe "#create with local_file" do
|
122
140
|
let (:mock_url) {"http://example.com"}
|
123
141
|
before do
|
@@ -170,7 +188,6 @@ describe GenericFilesController do
|
|
170
188
|
lambda { post :create, local_file: ["world.png", "import"], batch_id: "xw42n7934"}.should change(GenericFile, :count).by(4)
|
171
189
|
response.should redirect_to Sufia::Engine.routes.url_helpers.batch_edit_path('xw42n7934')
|
172
190
|
# These files should have been moved out of the upload directory
|
173
|
-
File.exist?("#{@mock_upload_directory}/import/files/Example.ogg").should be_false
|
174
191
|
File.exist?("#{@mock_upload_directory}/import/files/icons.zip").should be_false
|
175
192
|
File.exist?("#{@mock_upload_directory}/import/metadata/dublin_core_rdf_descMetadata.nt").should be_false
|
176
193
|
File.exist?("#{@mock_upload_directory}/world.png").should be_false
|
@@ -216,7 +233,7 @@ describe GenericFilesController do
|
|
216
233
|
@generic_file = GenericFile.new
|
217
234
|
@generic_file.apply_depositor_metadata(@user)
|
218
235
|
@generic_file.save
|
219
|
-
@user = FactoryGirl.find_or_create(:
|
236
|
+
@user = FactoryGirl.find_or_create(:jill)
|
220
237
|
sign_in @user
|
221
238
|
end
|
222
239
|
after do
|
@@ -235,6 +252,54 @@ describe GenericFilesController do
|
|
235
252
|
end
|
236
253
|
end
|
237
254
|
|
255
|
+
describe 'stats' do
|
256
|
+
before do
|
257
|
+
@generic_file = GenericFile.new.tap do |gf|
|
258
|
+
gf.apply_depositor_metadata(@user)
|
259
|
+
gf.save
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
after do
|
264
|
+
@generic_file.destroy
|
265
|
+
end
|
266
|
+
|
267
|
+
context 'when user has access to file' do
|
268
|
+
before do
|
269
|
+
sign_in @user
|
270
|
+
mock_query = double('query')
|
271
|
+
allow(mock_query).to receive(:for_path).and_return([
|
272
|
+
OpenStruct.new(date: '2014-01-01', pageviews: 4),
|
273
|
+
OpenStruct.new(date: '2014-01-02', pageviews: 8),
|
274
|
+
OpenStruct.new(date: '2014-01-03', pageviews: 6),
|
275
|
+
OpenStruct.new(date: '2014-01-04', pageviews: 10),
|
276
|
+
OpenStruct.new(date: '2014-01-05', pageviews: 2)])
|
277
|
+
allow(mock_query).to receive(:map).and_return(mock_query.for_path.map(&:marshal_dump))
|
278
|
+
profile = double('profile')
|
279
|
+
allow(profile).to receive(:pageview).and_return(mock_query)
|
280
|
+
allow(Sufia::UsageStatistics).to receive(:profile).and_return(profile)
|
281
|
+
end
|
282
|
+
|
283
|
+
it 'renders the stats view' do
|
284
|
+
get :stats, id: @generic_file.noid
|
285
|
+
expect(response).to be_success
|
286
|
+
expect(response).to render_template(:stats)
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
context 'when user lacks access to file' do
|
291
|
+
before do
|
292
|
+
@archivist = FactoryGirl.find_or_create(:archivist)
|
293
|
+
sign_in @archivist
|
294
|
+
end
|
295
|
+
|
296
|
+
it 'redirects to root_url' do
|
297
|
+
get :stats, id: @generic_file.pid
|
298
|
+
expect(response).to redirect_to(Sufia::Engine.routes.url_helpers.root_path)
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
238
303
|
describe "update" do
|
239
304
|
before do
|
240
305
|
@generic_file = GenericFile.new
|
@@ -249,7 +314,7 @@ describe GenericFilesController do
|
|
249
314
|
s1 = double('one')
|
250
315
|
ContentUpdateEventJob.should_receive(:new).with(@generic_file.pid, 'jilluser@example.com').and_return(s1)
|
251
316
|
Sufia.queue.should_receive(:push).with(s1).once
|
252
|
-
@user = FactoryGirl.find_or_create(:
|
317
|
+
@user = FactoryGirl.find_or_create(:jill)
|
253
318
|
sign_in @user
|
254
319
|
post :update, :id=>@generic_file.pid, :generic_file=>{:title=>'new_title', :tag=>[''], :permissions=>{:new_user_name=>{'archivist1'=>'edit'}}}
|
255
320
|
@user.delete
|
@@ -262,7 +327,7 @@ describe GenericFilesController do
|
|
262
327
|
s2 = double('one')
|
263
328
|
CharacterizeJob.should_receive(:new).with(@generic_file.pid).and_return(s2)
|
264
329
|
Sufia.queue.should_receive(:push).with(s2).once
|
265
|
-
@user = FactoryGirl.find_or_create(:
|
330
|
+
@user = FactoryGirl.find_or_create(:jill)
|
266
331
|
sign_in @user
|
267
332
|
|
268
333
|
file = fixture_file_upload('/world.png','image/png')
|
@@ -271,7 +336,7 @@ describe GenericFilesController do
|
|
271
336
|
end
|
272
337
|
|
273
338
|
it "should change mime type when restoring a revision with a different mime type" do
|
274
|
-
@user = FactoryGirl.find_or_create(:
|
339
|
+
@user = FactoryGirl.find_or_create(:jill)
|
275
340
|
sign_in @user
|
276
341
|
|
277
342
|
file = fixture_file_upload('/world.png','image/png')
|
@@ -301,7 +366,7 @@ describe GenericFilesController do
|
|
301
366
|
end
|
302
367
|
|
303
368
|
it "should record what user added a new version" do
|
304
|
-
@user = FactoryGirl.find_or_create(:
|
369
|
+
@user = FactoryGirl.find_or_create(:jill)
|
305
370
|
sign_in @user
|
306
371
|
|
307
372
|
file = fixture_file_upload('/world.png','image/png')
|
@@ -378,7 +443,7 @@ describe GenericFilesController do
|
|
378
443
|
CharacterizeJob.should_receive(:new).with(@generic_file.pid).and_return(s2)
|
379
444
|
Sufia.queue.should_receive(:push).with(s2).once
|
380
445
|
GenericFile.stub(:save).and_return({})
|
381
|
-
@user = FactoryGirl.find_or_create(:
|
446
|
+
@user = FactoryGirl.find_or_create(:jill)
|
382
447
|
sign_in @user
|
383
448
|
file = fixture_file_upload('/world.png','image/png')
|
384
449
|
post :update, :id=>@generic_file.pid, :filedata=>file, :Filename=>"The world", :generic_file=>{:tag=>[''], :permissions=>{:new_user_name=>{'archivist1'=>'edit'}}}
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe MailboxController do
|
4
4
|
before(:each) do
|
5
|
-
@user = FactoryGirl.find_or_create(:
|
5
|
+
@user = FactoryGirl.find_or_create(:jill)
|
6
6
|
@another_user = FactoryGirl.find_or_create(:archivist)
|
7
7
|
@message = "Test Message"
|
8
8
|
@subject = "Test Subject"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PagesController do
|
4
|
+
let (:page_name) {"about_page"}
|
5
|
+
context "content exists" do
|
6
|
+
describe "GET #show" do
|
7
|
+
let(:page) { ContentBlock.create!(name: page_name, value: "foo bar") }
|
8
|
+
|
9
|
+
it "should update the node" do
|
10
|
+
get :show, id: page.name
|
11
|
+
expect(response).to be_successful
|
12
|
+
expect(assigns[:page]).to eq page
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
context "content does not exist" do
|
17
|
+
describe "GET #show" do
|
18
|
+
it "should create the node" do
|
19
|
+
get :show, id: "about_page"
|
20
|
+
expect(response).to be_successful
|
21
|
+
expect(assigns[:page]).not_to be_nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SingleUseLinksController do
|
4
4
|
before(:all) do
|
5
|
-
@user = FactoryGirl.find_or_create(:
|
5
|
+
@user = FactoryGirl.find_or_create(:jill)
|
6
6
|
@file = GenericFile.new
|
7
7
|
@file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
8
8
|
@file.apply_depositor_metadata(@user)
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SingleUseLinksViewerController do
|
4
4
|
before(:all) do
|
5
|
-
@user = FactoryGirl.find_or_create(:
|
5
|
+
@user = FactoryGirl.find_or_create(:jill)
|
6
6
|
@file = GenericFile.new
|
7
7
|
@file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
8
8
|
@file.apply_depositor_metadata(@user)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TinymceAssetsController do
|
4
|
+
let(:file) { fixture_file_upload('/world.png','image/png') }
|
5
|
+
|
6
|
+
context "when logged in" do
|
7
|
+
let(:user) { FactoryGirl.create(:user) }
|
8
|
+
before { sign_in user }
|
9
|
+
|
10
|
+
context "as a user who can upload" do
|
11
|
+
before { expect(controller).to receive(:authorize!).with(:create, TinymceAsset).and_return(true) }
|
12
|
+
|
13
|
+
it "should upload the file" do
|
14
|
+
expect {
|
15
|
+
post :create, file: file
|
16
|
+
expect(response).to be_successful
|
17
|
+
}.to change{ TinymceAsset.count }.by(1)
|
18
|
+
|
19
|
+
json = JSON.parse(response.body)
|
20
|
+
expect(json).to eq({"image"=>{"url"=>"/uploads/tinymce_asset/file/1/world.png"}})
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "as a user who can't upload" do
|
25
|
+
it "should redirect to root path" do
|
26
|
+
post :create, file: file
|
27
|
+
expect(response).to redirect_to root_path
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "when not logged in" do
|
33
|
+
it "should redirect to root path" do
|
34
|
+
post :create, file: file
|
35
|
+
expect(response).to redirect_to main_app.new_user_session_path
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -2,18 +2,13 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe UsersController do
|
4
4
|
before(:each) do
|
5
|
-
@user = FactoryGirl.find_or_create(:
|
5
|
+
@user = FactoryGirl.find_or_create(:jill)
|
6
6
|
@another_user = FactoryGirl.find_or_create(:archivist)
|
7
7
|
sign_in @user
|
8
8
|
User.any_instance.stub(:groups).and_return([])
|
9
9
|
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
10
10
|
end
|
11
|
-
|
12
|
-
@user = FactoryGirl.find(:user) rescue
|
13
|
-
@user.delete if @user
|
14
|
-
@another_user = FactoryGirl.find(:archivist) rescue
|
15
|
-
@another_user.delete if @user
|
16
|
-
end
|
11
|
+
|
17
12
|
describe "#show" do
|
18
13
|
it "show the user profile if user exists" do
|
19
14
|
get :show, id: @user.user_key
|
@@ -88,7 +83,7 @@ describe UsersController do
|
|
88
83
|
@u2.save
|
89
84
|
end
|
90
85
|
it "uses the base query" do
|
91
|
-
u3 = FactoryGirl.find_or_create(:
|
86
|
+
u3 = FactoryGirl.find_or_create(:jill)
|
92
87
|
controller.stub(:base_query).and_return(['email == "jilluser@example.com"'])
|
93
88
|
get :index
|
94
89
|
assigns[:users].should include(u3)
|
@@ -1,46 +1,53 @@
|
|
1
1
|
FactoryGirl.define do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
ignore do
|
6
|
-
pid "sufia:fixture-pdf"
|
7
|
-
end
|
8
|
-
initialize_with { new(pid: pid) }
|
9
|
-
read_groups ["public"]
|
10
|
-
resource_type "Dissertation"
|
11
|
-
subject %w"lorem ipsum dolor sit amet"
|
12
|
-
before(:create) do |gf|
|
13
|
-
gf.apply_depositor_metadata "archivist1@example.com"
|
14
|
-
gf.title = "Fake Document Title"
|
15
|
-
gf.label = "fake_document.pdf"
|
16
|
-
end
|
2
|
+
factory :generic_file do
|
3
|
+
ignore do
|
4
|
+
depositor "archivist1@example.com"
|
17
5
|
end
|
18
|
-
|
19
|
-
|
20
|
-
pid "sufia:fixture-mp3"
|
21
|
-
end
|
22
|
-
initialize_with { new(pid: pid) }
|
23
|
-
subject %w"consectetur adipisicing elit"
|
24
|
-
before(:create) do |gf|
|
25
|
-
gf.apply_depositor_metadata "archivist1@example.com"
|
26
|
-
gf.inner_object.pid = "sufia:fixture-mp3"
|
27
|
-
gf.label = "Test Document MP3.mp3"
|
28
|
-
end
|
29
|
-
read_groups ["public"]
|
6
|
+
before(:create) do |gf, evaluator|
|
7
|
+
gf.apply_depositor_metadata evaluator.depositor
|
30
8
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
9
|
+
|
10
|
+
factory :fixture do
|
11
|
+
factory :public_pdf do
|
12
|
+
ignore do
|
13
|
+
pid "sufia:fixture-pdf"
|
14
|
+
end
|
15
|
+
initialize_with { new(pid: pid) }
|
16
|
+
read_groups ["public"]
|
17
|
+
resource_type "Dissertation"
|
18
|
+
subject %w"lorem ipsum dolor sit amet"
|
19
|
+
before(:create) do |gf|
|
20
|
+
gf.apply_depositor_metadata "archivist1@example.com"
|
21
|
+
gf.title = "Fake Document Title"
|
22
|
+
gf.label = "fake_document.pdf"
|
23
|
+
end
|
34
24
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
25
|
+
factory :public_mp3 do
|
26
|
+
ignore do
|
27
|
+
pid "sufia:fixture-mp3"
|
28
|
+
end
|
29
|
+
initialize_with { new(pid: pid) }
|
30
|
+
subject %w"consectetur adipisicing elit"
|
31
|
+
before(:create) do |gf|
|
32
|
+
gf.apply_depositor_metadata "archivist1@example.com"
|
33
|
+
gf.inner_object.pid = "sufia:fixture-mp3"
|
34
|
+
gf.label = "Test Document MP3.mp3"
|
35
|
+
end
|
36
|
+
read_groups ["public"]
|
37
|
+
end
|
38
|
+
factory :public_wav do
|
39
|
+
ignore do
|
40
|
+
pid "sufia:fixture-wav"
|
41
|
+
end
|
42
|
+
initialize_with { new(pid: pid) }
|
43
|
+
resource_type ["Audio", "Dataset"]
|
44
|
+
read_groups ["public"]
|
45
|
+
subject %w"sed do eiusmod tempor incididunt ut labore"
|
46
|
+
before(:create) do |gf|
|
47
|
+
gf.apply_depositor_metadata "archivist1@example.com"
|
48
|
+
gf.label = "Fake Wav File.wav"
|
49
|
+
end
|
42
50
|
end
|
43
51
|
end
|
44
52
|
end
|
45
|
-
|
46
|
-
end
|
53
|
+
end
|
data/spec/factories/users.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
FactoryGirl.define do
|
2
|
-
factory :user
|
3
|
-
email
|
2
|
+
factory :user do
|
3
|
+
sequence(:email) { |n| "user#{n}@example.com" }
|
4
4
|
password 'password'
|
5
|
-
end
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
6
|
+
factory :jill do
|
7
|
+
email 'jilluser@example.com'
|
8
|
+
end
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
password 'password'
|
15
|
-
after(:create) do |user|
|
16
|
-
message = '<span class="batchid ui-helper-hidden">fake_batch_noid</span>You\'ve got mail.'
|
17
|
-
User.batchuser().send_message(user, message, "Sample notification.")
|
10
|
+
factory :archivist, aliases: [:user_with_fixtures] do
|
11
|
+
email 'archivist1@example.com'
|
18
12
|
end
|
19
|
-
end
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
|
14
|
+
factory :user_with_mail do
|
15
|
+
email 'archivist2@example.com'
|
16
|
+
after(:create) do |user|
|
17
|
+
message = '<span class="batchid ui-helper-hidden">fake_batch_noid</span>You\'ve got mail.'
|
18
|
+
User.batchuser().send_message(user, message, "Sample notification.")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
factory :curator do
|
23
|
+
email 'curator1@example.com'
|
24
|
+
end
|
24
25
|
end
|
25
26
|
end
|
26
|
-
|