sufia 4.0.0.beta3 → 4.0.0.beta4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/SUFIA_VERSION +1 -1
- data/app/assets/javascripts/sufia/search.js +4 -6
- data/app/assets/stylesheets/dashboard.css.scss +26 -0
- data/app/assets/stylesheets/header.css.scss +21 -12
- data/app/controllers/batch_controller.rb +0 -1
- data/app/controllers/collections_controller.rb +0 -1
- data/app/controllers/concerns/sufia/catalog.rb +0 -9
- data/app/controllers/concerns/sufia/controller.rb +4 -0
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +24 -74
- data/app/controllers/concerns/sufia/downloads_controller_behavior.rb +0 -3
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +4 -13
- data/app/controllers/concerns/sufia/my_controller_behavior.rb +87 -0
- data/app/controllers/{dashboard → my}/collections_controller.rb +3 -2
- data/app/controllers/{dashboard → my}/files_controller.rb +3 -2
- data/app/controllers/{dashboard → my}/highlights_controller.rb +3 -2
- data/app/controllers/{dashboard → my}/shares_controller.rb +3 -2
- data/app/controllers/my_controller.rb +3 -0
- data/app/controllers/single_use_links_controller.rb +0 -2
- data/app/helpers/dashboard_helper.rb +3 -0
- data/app/helpers/generic_file_helper.rb +4 -4
- data/app/helpers/sufia/dashboard_helper_behavior.rb +25 -0
- data/app/helpers/sufia/sufia_helper_behavior.rb +44 -0
- data/app/jobs/content_delete_event_job.rb +2 -2
- data/app/models/concerns/sufia/solr_document_behavior.rb +5 -0
- data/app/views/_user_util_links.html.erb +5 -5
- data/app/views/catalog/_results_pagination.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +56 -28
- data/app/views/collections/_dashboard_document_list.html.erb +1 -1
- data/app/views/collections/_document_list.html.erb +1 -1
- data/app/views/collections/edit.html.erb +8 -11
- data/app/views/collections/show.html.erb +2 -2
- data/app/views/collections/show_fields/_creator.html.erb +11 -0
- data/app/views/collections/show_fields/_description.html.erb +8 -0
- data/app/views/collections/show_fields/_title.html.erb +8 -0
- data/app/views/dashboard/_index_partials/_stats.html.erb +16 -0
- data/app/views/dashboard/_index_partials/_user_info.html.erb +18 -0
- data/app/views/dashboard/index.html.erb +51 -19
- data/app/views/generic_files/_show_descriptions.html.erb +11 -10
- data/app/views/generic_files/show.html.erb +1 -1
- data/app/views/generic_files/show_fields/_based_near.html.erb +7 -0
- data/app/views/generic_files/show_fields/_contributor.html.erb +7 -0
- data/app/views/generic_files/show_fields/_creator.html.erb +7 -0
- data/app/views/generic_files/show_fields/_date_created.html.erb +7 -0
- data/app/views/generic_files/show_fields/_default.html.erb +6 -12
- data/app/views/generic_files/show_fields/_description.html.erb +7 -0
- data/app/views/generic_files/show_fields/_identifier.html.erb +4 -0
- data/app/views/generic_files/show_fields/_language.html.erb +4 -0
- data/app/views/generic_files/show_fields/_publisher.html.erb +7 -0
- data/app/views/generic_files/show_fields/_related_url.html.erb +6 -0
- data/app/views/generic_files/show_fields/_resource_type.html.erb +4 -0
- data/app/views/generic_files/show_fields/_rights.html.erb +4 -0
- data/app/views/generic_files/show_fields/_subject.html.erb +7 -0
- data/app/views/generic_files/show_fields/_tag.html.erb +4 -0
- data/app/views/generic_files/show_fields/_title.html.erb +7 -0
- data/app/views/generic_files/upload/_form_fields.html.erb +4 -5
- data/app/views/generic_files/upload/_script_templates.html.erb +1 -2
- data/app/views/layouts/sufia-dashboard.html.erb +16 -30
- data/app/views/mailbox/_notifications.html.erb +21 -0
- data/app/views/mailbox/index.html.erb +2 -23
- data/app/views/{dashboard → my}/_action_menu.html.erb +0 -0
- data/app/views/{dashboard → my}/_batch_edits_actions.html.erb +0 -0
- data/app/views/{dashboard → my}/_collection_action_menu.html.erb +0 -0
- data/app/views/{dashboard → my}/_did_you_mean.html.erb +0 -0
- data/app/views/my/_document_list.html.erb +4 -0
- data/app/views/{dashboard → my}/_facet_layout.html.erb +0 -0
- data/app/views/{dashboard → my}/_facet_limit.html.erb +0 -0
- data/app/views/{dashboard → my}/_facet_pagination.html.erb +0 -0
- data/app/views/{dashboard → my}/_facet_selected.html.erb +0 -0
- data/app/views/{dashboard → my}/_facets.html.erb +0 -0
- data/app/views/{dashboard → my}/_index_partials/_default_group.html.erb +2 -2
- data/app/views/{dashboard → my}/_index_partials/_list_collections.html.erb +0 -0
- data/app/views/{dashboard → my}/_index_partials/_list_files.html.erb +0 -0
- data/app/views/{dashboard → my}/_results_pagination.html.erb +0 -0
- data/app/views/my/_scripts.js.erb +11 -0
- data/app/views/{dashboard → my}/_sort_and_per_page.html.erb +0 -0
- data/app/views/{dashboard → my}/facet.html.erb +0 -0
- data/app/views/{dashboard/lists → my}/index.html.erb +4 -20
- data/app/views/users/_user_info.html.erb +1 -1
- data/config/initializers/sufia_events.rb +19 -2
- data/config/locales/sufia.en.yml +27 -2
- data/config/routes.rb +7 -11
- data/lib/generators/sufia/sufia_generator.rb +15 -0
- data/lib/generators/sufia/templates/catalog_controller.rb +14 -14
- data/lib/sufia.rb +1 -0
- data/lib/sufia/version.rb +1 -1
- data/spec/controllers/catalog_controller_spec.rb +7 -16
- data/spec/controllers/dashboard_controller_spec.rb +63 -30
- data/spec/controllers/generic_files_controller_spec.rb +1 -1
- data/spec/controllers/{dashboard → my}/collections_controller_spec.rb +1 -15
- data/spec/controllers/my/files_controller_spec.rb +68 -0
- data/spec/controllers/{dashboard → my}/highlights_controller_spec.rb +1 -15
- data/spec/controllers/{dashboard → my}/shares_controller_spec.rb +1 -15
- data/spec/controllers/my_controller_spec.rb +9 -0
- data/spec/features/browse_dashboard_files_spec.rb +72 -26
- data/spec/features/collection_spec.rb +2 -4
- data/spec/features/display_dashboard_spec.rb +20 -26
- data/spec/features/search_spec.rb +25 -13
- data/spec/helpers/dashboard_helper_spec.rb +41 -0
- data/spec/helpers/sufia_helper_spec.rb +104 -3
- data/spec/jobs/event_jobs_spec.rb +1 -1
- data/spec/models/generic_file/web_form_spec.rb +3 -4
- data/spec/models/generic_file_spec.rb +47 -43
- data/spec/routing/route_spec.rb +10 -14
- data/spec/views/batch_edits/check_all_spec.rb +4 -4
- data/spec/views/catalog/sort_and_per_pange.html.erb_spec.rb +27 -0
- data/spec/views/dashboard/index_spec.rb +105 -0
- data/spec/views/{dashboard → my}/facet_limit.html.erb_spec.rb +2 -2
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +23 -3
- data/sufia-models/app/models/concerns/sufia/generic_file.rb +0 -5
- data/sufia-models/app/models/concerns/sufia/generic_file/metadata.rb +9 -2
- data/sufia-models/app/models/concerns/sufia/generic_file/web_form.rb +2 -2
- data/sufia-models/app/models/datastreams/generic_file_rdf_datastream.rb +1 -1
- data/sufia-models/app/services/sufia/noid.rb +21 -16
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +2 -16
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +23 -0
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia-models/sufia-models.gemspec +1 -1
- data/vendor/assets/javascripts/fileupload/jquery.fileupload-ui.js +18 -10
- metadata +68 -45
- data/app/assets/images/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/glyphicons-halflings.png +0 -0
- data/app/controllers/dashboard/lists_controller.rb +0 -13
- data/app/views/dashboard/_constraints.html.erb +0 -6
- data/app/views/dashboard/_document_list.html.erb +0 -4
- data/app/views/dashboard/_heading.html.erb +0 -1
- data/app/views/dashboard/_search_form.html.erb +0 -14
- data/app/views/dashboard/_show_partials/_default.html.erb +0 -20
- data/app/views/dashboard/_show_partials/_default_details.html.erb +0 -15
- data/app/views/dashboard/_show_partials/_facets.html.erb +0 -87
- data/app/views/generic_files/_field_display.html.erb +0 -12
- data/spec/controllers/dashboard/files_controller_spec.rb +0 -71
data/config/locales/sufia.en.yml
CHANGED
|
@@ -4,6 +4,8 @@ en:
|
|
|
4
4
|
deposit_agreement: "Sufia's Deposit Agreement"
|
|
5
5
|
upload_tooltip: "Please accept Deposit Agreement before you can upload."
|
|
6
6
|
share_button: "Share Your Work"
|
|
7
|
+
view_profile: "View Profile"
|
|
8
|
+
edit_profile: "Edit Profile"
|
|
7
9
|
directory:
|
|
8
10
|
suffix: "@example.org"
|
|
9
11
|
search:
|
|
@@ -15,9 +17,18 @@ en:
|
|
|
15
17
|
all:
|
|
16
18
|
label_short: "All"
|
|
17
19
|
label_long: "All of Sufia"
|
|
18
|
-
|
|
20
|
+
my_files:
|
|
19
21
|
label_short: "My Files"
|
|
20
22
|
label_long: "My Files"
|
|
23
|
+
my_collections:
|
|
24
|
+
label_short: "My Collections"
|
|
25
|
+
label_long: "My Collections"
|
|
26
|
+
my_highlights:
|
|
27
|
+
label_short: "My Highlights"
|
|
28
|
+
label_long: "My Highlights"
|
|
29
|
+
my_shares:
|
|
30
|
+
label_short: "My Shares"
|
|
31
|
+
label_long: "My Shares"
|
|
21
32
|
upload:
|
|
22
33
|
my_computer:
|
|
23
34
|
tab_label: "My Computer"
|
|
@@ -34,6 +45,20 @@ en:
|
|
|
34
45
|
date_created: "Date Created"
|
|
35
46
|
related_url: "Related URL"
|
|
36
47
|
|
|
48
|
+
dashboard:
|
|
49
|
+
title: "My Dashboard"
|
|
50
|
+
greeting: "Hello, "
|
|
51
|
+
upload: "Upload"
|
|
52
|
+
create_collection: "Create Collection"
|
|
53
|
+
view_files: "View Files"
|
|
54
|
+
user_activity: "User Activity"
|
|
55
|
+
user_notiticiations: "User Notifications"
|
|
56
|
+
stats:
|
|
57
|
+
heading: "Your Statistics"
|
|
58
|
+
deposits: "Files you've deposited into Sufia"
|
|
59
|
+
following: "People you follow"
|
|
60
|
+
followers: "People who are following you"
|
|
61
|
+
|
|
37
62
|
metadata_help:
|
|
38
63
|
resource_type: "Pre-defined categories to describe the type of file content being uploaded, such as \"article\" or \"dataset.\" More than one type may be selected."
|
|
39
64
|
title: "A name for the file to aid in identifying it. Defaults to the file name, though a more descriptive title is encouraged. <em>This is a required field</em>."
|
|
@@ -53,4 +78,4 @@ en:
|
|
|
53
78
|
bread_crumb:
|
|
54
79
|
file_list: "Your File Listing"
|
|
55
80
|
previous: "Back to Previous"
|
|
56
|
-
search_results: "Back to search results"
|
|
81
|
+
search_results: "Back to search results"
|
data/config/routes.rb
CHANGED
|
@@ -47,40 +47,36 @@ Sufia::Engine.routes.draw do
|
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
# Dashboard
|
|
50
|
+
# Dashboard page
|
|
51
51
|
resources 'dashboard', only: :index do
|
|
52
52
|
collection do
|
|
53
|
-
get 'page/:page', action: :index
|
|
54
53
|
get 'activity', action: :activity, as: :dashboard_activity
|
|
55
|
-
get 'facet/:id', action: :facet, as: :dashboard_facet
|
|
56
54
|
end
|
|
57
55
|
end
|
|
56
|
+
|
|
57
|
+
# Routes for user's files, collections, highlights and shares
|
|
58
58
|
namespace :dashboard do
|
|
59
|
-
resources :files, only: :index do
|
|
59
|
+
resources :files, only: :index, controller: "/my/files" do
|
|
60
60
|
collection do
|
|
61
61
|
get 'page/:page', action: :index
|
|
62
|
-
get 'activity', action: :activity, as: :dashboard_activity
|
|
63
62
|
get 'facet/:id', action: :facet, as: :dashboard_facet
|
|
64
63
|
end
|
|
65
64
|
end
|
|
66
|
-
resources :collections, only: :index do
|
|
65
|
+
resources :collections, only: :index, controller: "/my/collections" do
|
|
67
66
|
collection do
|
|
68
67
|
get 'page/:page', action: :index
|
|
69
|
-
get 'activity', action: :activity, as: :dashboard_activity
|
|
70
68
|
get 'facet/:id', action: :facet, as: :dashboard_facet
|
|
71
69
|
end
|
|
72
70
|
end
|
|
73
|
-
resources :highlights, only: :index do
|
|
71
|
+
resources :highlights, only: :index, controller: "/my/highlights" do
|
|
74
72
|
collection do
|
|
75
73
|
get 'page/:page', action: :index
|
|
76
|
-
get 'activity', action: :activity, as: :dashboard_activity
|
|
77
74
|
get 'facet/:id', action: :facet, as: :dashboard_facet
|
|
78
75
|
end
|
|
79
76
|
end
|
|
80
|
-
resources :shares, only: :index do
|
|
77
|
+
resources :shares, only: :index, controller: "/my/shares" do
|
|
81
78
|
collection do
|
|
82
79
|
get 'page/:page', action: :index
|
|
83
|
-
get 'activity', action: :activity, as: :dashboard_activity
|
|
84
80
|
get 'facet/:id', action: :facet, as: :dashboard_facet
|
|
85
81
|
end
|
|
86
82
|
end
|
|
@@ -14,6 +14,7 @@ This generator makes the following changes to your application:
|
|
|
14
14
|
2. Adds Sufia's abilities into the Ability class
|
|
15
15
|
3. Adds controller behavior to the application controller
|
|
16
16
|
4. Copies the catalog controller into the local app
|
|
17
|
+
5. Adds Sufia::SolrDocumentBehavior to app/models/solr_document.rb
|
|
17
18
|
"""
|
|
18
19
|
|
|
19
20
|
def run_required_generators
|
|
@@ -71,4 +72,18 @@ This generator makes the following changes to your application:
|
|
|
71
72
|
sentinel = /devise_for :users/
|
|
72
73
|
inject_into_file 'config/routes.rb', routing_code, { after: sentinel, verbose: false }
|
|
73
74
|
end
|
|
75
|
+
|
|
76
|
+
# Add behaviors to the SolrDocument model
|
|
77
|
+
def inject_sufia_solr_document_behavior
|
|
78
|
+
file_path = "app/models/solr_document.rb"
|
|
79
|
+
if File.exists?(file_path)
|
|
80
|
+
inject_into_file file_path, after: /include Blacklight::Solr::Document.*$/ do
|
|
81
|
+
"\n # Adds Sufia behaviors to the SolrDocument.\n" +
|
|
82
|
+
" include Sufia::SolrDocumentBehavior\n"
|
|
83
|
+
end
|
|
84
|
+
else
|
|
85
|
+
puts " \e[31mFailure\e[0m Sufia requires a SolrDocument object. This generators assumes that the model is defined in the file #{file_path}, which does not exist."
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
74
89
|
end
|
|
@@ -35,8 +35,8 @@ class CatalogController < ApplicationController
|
|
|
35
35
|
qt: "search",
|
|
36
36
|
rows: 10
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
# Specify which field to use in the tag cloud on the homepage.
|
|
38
|
+
|
|
39
|
+
# Specify which field to use in the tag cloud on the homepage.
|
|
40
40
|
# To disable the tag cloud, comment out this line.
|
|
41
41
|
config.tag_cloud_field_name = Solrizer.solr_name("desc_metadata__tag", :facetable)
|
|
42
42
|
|
|
@@ -63,18 +63,18 @@ class CatalogController < ApplicationController
|
|
|
63
63
|
|
|
64
64
|
# solr fields to be displayed in the index (search results) view
|
|
65
65
|
# The ordering of the field names is the order of the display
|
|
66
|
-
config.add_index_field solr_name("desc_metadata__title", :stored_searchable), label: "Title"
|
|
67
|
-
config.add_index_field solr_name("desc_metadata__description", :stored_searchable), label: "Description"
|
|
68
|
-
config.add_index_field solr_name("desc_metadata__tag", :stored_searchable), label: "Keyword"
|
|
69
|
-
config.add_index_field solr_name("desc_metadata__subject", :stored_searchable), label: "Subject"
|
|
70
|
-
config.add_index_field solr_name("desc_metadata__creator", :stored_searchable), label: "Creator"
|
|
71
|
-
config.add_index_field solr_name("desc_metadata__contributor", :stored_searchable), label: "Contributor"
|
|
72
|
-
config.add_index_field solr_name("desc_metadata__publisher", :stored_searchable), label: "Publisher"
|
|
73
|
-
config.add_index_field solr_name("desc_metadata__based_near", :stored_searchable), label: "Location"
|
|
74
|
-
config.add_index_field solr_name("desc_metadata__language", :stored_searchable), label: "Language"
|
|
75
|
-
config.add_index_field solr_name("desc_metadata__date_uploaded", :stored_searchable), label: "Date Uploaded"
|
|
76
|
-
config.add_index_field solr_name("desc_metadata__date_modified", :stored_searchable), label: "Date Modified"
|
|
77
|
-
config.add_index_field solr_name("desc_metadata__date_created", :stored_searchable), label: "Date Created"
|
|
66
|
+
config.add_index_field solr_name("desc_metadata__title", :stored_searchable), label: "Title", itemprop: 'name'
|
|
67
|
+
config.add_index_field solr_name("desc_metadata__description", :stored_searchable), label: "Description", itemprop: 'description'
|
|
68
|
+
config.add_index_field solr_name("desc_metadata__tag", :stored_searchable), label: "Keyword", itemprop: 'keywords'
|
|
69
|
+
config.add_index_field solr_name("desc_metadata__subject", :stored_searchable), label: "Subject", itemprop: 'about'
|
|
70
|
+
config.add_index_field solr_name("desc_metadata__creator", :stored_searchable), label: "Creator", itemprop: 'creator'
|
|
71
|
+
config.add_index_field solr_name("desc_metadata__contributor", :stored_searchable), label: "Contributor", itemprop: 'contributor'
|
|
72
|
+
config.add_index_field solr_name("desc_metadata__publisher", :stored_searchable), label: "Publisher", itemprop: 'publisher'
|
|
73
|
+
config.add_index_field solr_name("desc_metadata__based_near", :stored_searchable), label: "Location", itemprop: 'contentLocation'
|
|
74
|
+
config.add_index_field solr_name("desc_metadata__language", :stored_searchable), label: "Language", itemprop: 'inLanguage'
|
|
75
|
+
config.add_index_field solr_name("desc_metadata__date_uploaded", :stored_searchable), label: "Date Uploaded", itemprop: 'datePublished'
|
|
76
|
+
config.add_index_field solr_name("desc_metadata__date_modified", :stored_searchable), label: "Date Modified", itemprop: 'dateModified'
|
|
77
|
+
config.add_index_field solr_name("desc_metadata__date_created", :stored_searchable), label: "Date Created", itemprop: 'dateCreated'
|
|
78
78
|
config.add_index_field solr_name("desc_metadata__rights", :stored_searchable), label: "Rights"
|
|
79
79
|
config.add_index_field solr_name("desc_metadata__resource_type", :stored_searchable), label: "Resource Type"
|
|
80
80
|
config.add_index_field solr_name("desc_metadata__format", :stored_searchable), label: "File Format"
|
data/lib/sufia.rb
CHANGED
data/lib/sufia/version.rb
CHANGED
|
@@ -33,22 +33,13 @@ describe CatalogController do
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
describe "term search" do
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
assigns(:document_list).first['desc_metadata__title_tesim'].should == ['Test Document PDF']
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
context "searching only documents editable to me" do
|
|
47
|
-
it "should only have records I can edit" do
|
|
48
|
-
get :index, q: "", owner: 'mine'
|
|
49
|
-
assigns(:document_list).map(&:id).should == [@editable_file.id]
|
|
50
|
-
expect(response).to be_success
|
|
51
|
-
end
|
|
36
|
+
it "should find records" do
|
|
37
|
+
get :index, q: "pdf", owner: 'all'
|
|
38
|
+
expect(response).to be_success
|
|
39
|
+
response.should render_template('catalog/index')
|
|
40
|
+
assigns(:document_list).map(&:id).should == [@gf1.id]
|
|
41
|
+
assigns(:document_list).count.should eql(1)
|
|
42
|
+
assigns(:document_list).first['desc_metadata__title_tesim'].should == ['Test Document PDF']
|
|
52
43
|
end
|
|
53
44
|
end
|
|
54
45
|
|
|
@@ -1,41 +1,74 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe DashboardController do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
|
|
5
|
+
context "with an unauthenticated user" do
|
|
6
|
+
|
|
7
|
+
it "redirects to sign-in page" do
|
|
8
|
+
get :index
|
|
9
|
+
expect(response).to be_redirect
|
|
10
|
+
expect(flash[:alert]).to eq("You need to sign in or sign up before continuing.")
|
|
11
|
+
end
|
|
12
|
+
|
|
7
13
|
end
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
# request.stub(:headers).and_return('REMOTE_USER' => @user.login).at_least(:once)
|
|
14
|
-
# @strategy = Devise::Strategies::HttpHeaderAuthenticatable.new(nil)
|
|
15
|
-
# @strategy.should_receive(:request).and_return(request).at_least(:once)
|
|
16
|
-
# end
|
|
17
|
-
# after(:each) do
|
|
18
|
-
# @user.delete
|
|
19
|
-
# end
|
|
20
|
-
it "should populate LDAP attrs if user is new" do
|
|
21
|
-
pending "This should only be in scholarsphere"
|
|
22
|
-
User.stub(:find_by_login).with(@user.login).and_return(nil)
|
|
23
|
-
User.should_receive(:create).with(login: @user.login).and_return(@user).once
|
|
24
|
-
User.any_instance.should_receive(:populate_attributes).once
|
|
25
|
-
@strategy.should be_valid
|
|
26
|
-
@strategy.authenticate!.should == :success
|
|
14
|
+
|
|
15
|
+
context "with an authenticated user" do
|
|
16
|
+
|
|
17
|
+
before do
|
|
18
|
+
@user = FactoryGirl.find_or_create(:user_with_mail)
|
|
27
19
|
sign_in @user
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "renders the dashboard with the user's info" do
|
|
28
23
|
get :index
|
|
24
|
+
expect(response).to be_successful
|
|
25
|
+
expect(assigns(:user)).to eq(@user)
|
|
29
26
|
end
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
sign_in @user
|
|
27
|
+
|
|
28
|
+
it "gathers the user's recent activity" do
|
|
29
|
+
get :index
|
|
30
|
+
expect(assigns(:activity)).to be_empty
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "gathers the user's notifications" do
|
|
38
34
|
get :index
|
|
35
|
+
expect(assigns(:notifications)).to be_true
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "with activities" do
|
|
39
|
+
|
|
40
|
+
before :all do
|
|
41
|
+
@now = DateTime.now.to_i
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
before do
|
|
45
|
+
allow_any_instance_of(User).to receive(:events).and_return(activities)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def activities
|
|
49
|
+
[
|
|
50
|
+
{ action: 'so and so edited their profile', timestamp: @now },
|
|
51
|
+
{ action: 'so and so uploaded a file', timestamp: (@now - 360 ) }
|
|
52
|
+
]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "gathers the user's recent activity within the default amount of time" do
|
|
56
|
+
get :index
|
|
57
|
+
expect(assigns(:activity)).to eq(activities.reverse)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "gathers the user's recent activity within a given timestamp" do
|
|
61
|
+
get :index, { since: (@now - 60 ) }
|
|
62
|
+
expect(assigns(:activity)).to eq([activities.first])
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "returns results in JSON" do
|
|
66
|
+
get :activity
|
|
67
|
+
expect(response).to be_successful
|
|
68
|
+
end
|
|
69
|
+
|
|
39
70
|
end
|
|
71
|
+
|
|
40
72
|
end
|
|
73
|
+
|
|
41
74
|
end
|
|
@@ -246,7 +246,7 @@ describe GenericFilesController do
|
|
|
246
246
|
end
|
|
247
247
|
it "should spawn a content delete event job" do
|
|
248
248
|
s1 = double('one')
|
|
249
|
-
ContentDeleteEventJob.should_receive(:new).with(@generic_file.
|
|
249
|
+
ContentDeleteEventJob.should_receive(:new).with(@generic_file.pid, @user.user_key).and_return(s1)
|
|
250
250
|
Sufia.queue.should_receive(:push).with(s1).once
|
|
251
251
|
delete :destroy, id: @generic_file.pid
|
|
252
252
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
3
|
+
describe My::CollectionsController do
|
|
4
4
|
describe "logged in user" do
|
|
5
5
|
before (:each) do
|
|
6
6
|
@user = FactoryGirl.find_or_create(:archivist)
|
|
@@ -24,11 +24,6 @@ describe Dashboard::CollectionsController do
|
|
|
24
24
|
it "should respond with success" do
|
|
25
25
|
get :index
|
|
26
26
|
expect(response).to be_successful
|
|
27
|
-
expect(response).to render_template('dashboard/lists/index')
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "sets the controller name" do
|
|
31
|
-
expect(controller.controller_name).to eq :dashboard
|
|
32
27
|
end
|
|
33
28
|
|
|
34
29
|
it "should paginate" do
|
|
@@ -59,13 +54,4 @@ describe Dashboard::CollectionsController do
|
|
|
59
54
|
end
|
|
60
55
|
end
|
|
61
56
|
|
|
62
|
-
describe "not logged in as a user" do
|
|
63
|
-
describe "#index" do
|
|
64
|
-
it "should return an error" do
|
|
65
|
-
get :index
|
|
66
|
-
expect(response).to be_redirect
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
57
|
end
|
|
71
|
-
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe My::FilesController do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
GenericFile.destroy_all
|
|
7
|
+
Collection.destroy_all
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
after :all do
|
|
11
|
+
GenericFile.destroy_all
|
|
12
|
+
Collection.destroy_all
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
let(:my_collection) do
|
|
16
|
+
Collection.new(title: 'test collection').tap do |c|
|
|
17
|
+
c.apply_depositor_metadata(@user.user_key)
|
|
18
|
+
c.save!
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
let(:shared_file) do
|
|
23
|
+
FactoryGirl.build(:generic_file).tap do |r|
|
|
24
|
+
r.apply_depositor_metadata FactoryGirl.create(:user)
|
|
25
|
+
r.edit_users += [@user.user_key]
|
|
26
|
+
r.save!
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
before do
|
|
31
|
+
@user = FactoryGirl.find_or_create(:archivist)
|
|
32
|
+
sign_in @user
|
|
33
|
+
@my_file = FactoryGirl.create(:generic_file, depositor: @user)
|
|
34
|
+
@my_collection = my_collection
|
|
35
|
+
@shared_file = shared_file
|
|
36
|
+
@unrelated_file = FactoryGirl.create(:generic_file, depositor: FactoryGirl.create(:user))
|
|
37
|
+
@wrong_type = Batch.create
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should respond with success" do
|
|
41
|
+
get :index
|
|
42
|
+
expect(response).to be_successful
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should paginate" do
|
|
46
|
+
FactoryGirl.create(:generic_file)
|
|
47
|
+
FactoryGirl.create(:generic_file)
|
|
48
|
+
get :index, per_page: 2
|
|
49
|
+
expect(assigns[:document_list].length).to eq 2
|
|
50
|
+
get :index, per_page: 2, page: 2
|
|
51
|
+
expect(assigns[:document_list].length).to be >= 1
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "shows the correct files" do
|
|
55
|
+
get :index
|
|
56
|
+
# shows documents I deposited
|
|
57
|
+
expect(assigns[:document_list].map(&:id)).to include(@my_file.id)
|
|
58
|
+
# doesn't show collections
|
|
59
|
+
expect(assigns[:document_list].map(&:id)).to_not include(@my_collection.id)
|
|
60
|
+
# doesn't show shared files
|
|
61
|
+
expect(assigns[:document_list].map(&:id)).to_not include(@shared_file.id)
|
|
62
|
+
# doesn't show other users' files
|
|
63
|
+
expect(assigns[:document_list].map(&:id)).to_not include(@unrelated_file.id)
|
|
64
|
+
# doesn't show non-generic files
|
|
65
|
+
expect(assigns[:document_list].map(&:id)).to_not include(@wrong_type.id)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
3
|
+
describe My::HighlightsController do
|
|
4
4
|
describe "logged in user" do
|
|
5
5
|
before (:each) do
|
|
6
6
|
@user = FactoryGirl.find_or_create(:archivist)
|
|
@@ -26,11 +26,6 @@ describe Dashboard::HighlightsController do
|
|
|
26
26
|
it "should respond with success" do
|
|
27
27
|
get :index
|
|
28
28
|
expect(response).to be_successful
|
|
29
|
-
expect(response).to render_template('dashboard/lists/index')
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "sets the controller name" do
|
|
33
|
-
expect(controller.controller_name).to eq :dashboard
|
|
34
29
|
end
|
|
35
30
|
|
|
36
31
|
it "should paginate" do
|
|
@@ -54,13 +49,4 @@ describe Dashboard::HighlightsController do
|
|
|
54
49
|
end
|
|
55
50
|
end
|
|
56
51
|
|
|
57
|
-
describe "not logged in as a user" do
|
|
58
|
-
describe "#index" do
|
|
59
|
-
it "should return an error" do
|
|
60
|
-
get :index
|
|
61
|
-
expect(response).to be_redirect
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
52
|
end
|
|
66
|
-
|