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
@@ -5,21 +5,21 @@ describe UsersController do
|
|
5
5
|
@user = FactoryGirl.find_or_create(:jill)
|
6
6
|
@another_user = FactoryGirl.find_or_create(:archivist)
|
7
7
|
sign_in @user
|
8
|
-
User.
|
9
|
-
controller.
|
8
|
+
allow_any_instance_of(User).to receive(:groups).and_return([])
|
9
|
+
allow(controller).to receive(:clear_session_user) ## Don't clear out the authenticated session
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "#show" do
|
13
13
|
it "show the user profile if user exists" do
|
14
14
|
get :show, id: @user.user_key
|
15
|
-
response.
|
16
|
-
response.
|
17
|
-
flash[:alert].
|
15
|
+
expect(response).to be_success
|
16
|
+
expect(response).to_not redirect_to(root_path)
|
17
|
+
expect(flash[:alert]).to be_nil
|
18
18
|
end
|
19
19
|
it "redirects to root if user does not exist" do
|
20
20
|
get :show, id: 'johndoe666'
|
21
|
-
response.
|
22
|
-
flash[:alert].
|
21
|
+
expect(response).to redirect_to(root_path)
|
22
|
+
expect(flash[:alert]).to include ("User 'johndoe666' does not exist")
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "when the user has trophies" do
|
@@ -33,8 +33,8 @@ describe UsersController do
|
|
33
33
|
|
34
34
|
it "show the user profile if user exists" do
|
35
35
|
get :show, id: user.user_key
|
36
|
-
response.
|
37
|
-
assigns[:trophies].
|
36
|
+
expect(response).to be_success
|
37
|
+
expect(assigns[:trophies]).to match_array([file1, file2, file3])
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
@@ -47,36 +47,36 @@ describe UsersController do
|
|
47
47
|
describe "requesting html" do
|
48
48
|
it "should test users" do
|
49
49
|
get :index
|
50
|
-
assigns[:users].
|
51
|
-
response.
|
50
|
+
expect(assigns[:users]).to include(@u1, @u2)
|
51
|
+
expect(response).to be_successful
|
52
52
|
end
|
53
53
|
end
|
54
54
|
describe "requesting json" do
|
55
55
|
it "should display users" do
|
56
56
|
get :index, format: :json
|
57
|
-
response.
|
57
|
+
expect(response).to be_successful
|
58
58
|
json = JSON.parse(response.body)
|
59
|
-
json.map{|u| u['id']}.
|
60
|
-
json.map{|u| u['text']}.
|
59
|
+
expect(json.map{|u| u['id']}).to include(@u1.email, @u2.email)
|
60
|
+
expect(json.map{|u| u['text']}).to include(@u1.email, @u2.email)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
describe "query users" do
|
64
64
|
it "finds the expected user via email" do
|
65
65
|
get :index, uq: @u1.email
|
66
|
-
assigns[:users].
|
67
|
-
assigns[:users].
|
68
|
-
response.
|
66
|
+
expect(assigns[:users]).to include(@u1)
|
67
|
+
expect(assigns[:users]).to_not include(@u2)
|
68
|
+
expect(response).to be_successful
|
69
69
|
end
|
70
70
|
it "finds the expected user via display name" do
|
71
71
|
@u1.display_name = "Dr. Curator"
|
72
72
|
@u1.save
|
73
73
|
@u2.display_name = "Jr. Architect"
|
74
74
|
@u2.save
|
75
|
-
User.
|
75
|
+
allow_any_instance_of(User).to receive(:display_name).and_return("Dr. Curator", "Jr.Archivist")
|
76
76
|
get :index, uq: @u1.display_name
|
77
|
-
assigns[:users].
|
78
|
-
assigns[:users].
|
79
|
-
response.
|
77
|
+
expect(assigns[:users]).to include(@u1)
|
78
|
+
expect(assigns[:users]).to_not include(@u2)
|
79
|
+
expect(response).to be_successful
|
80
80
|
@u1.display_name = nil
|
81
81
|
@u1.save
|
82
82
|
@u2.display_name = nil
|
@@ -84,10 +84,10 @@ describe UsersController do
|
|
84
84
|
end
|
85
85
|
it "uses the base query" do
|
86
86
|
u3 = FactoryGirl.find_or_create(:jill)
|
87
|
-
controller.
|
87
|
+
allow(controller).to receive(:base_query).and_return(['email == "jilluser@example.com"'])
|
88
88
|
get :index
|
89
|
-
assigns[:users].
|
90
|
-
assigns[:users].
|
89
|
+
expect(assigns[:users]).to include(u3)
|
90
|
+
expect(assigns[:users]).to_not include(@u1, @u2)
|
91
91
|
u3.destroy
|
92
92
|
end
|
93
93
|
end
|
@@ -95,14 +95,14 @@ describe UsersController do
|
|
95
95
|
describe "#edit" do
|
96
96
|
it "show edit form when user edits own profile" do
|
97
97
|
get :edit, id: @user.user_key
|
98
|
-
response.
|
99
|
-
response.
|
100
|
-
flash[:alert].
|
98
|
+
expect(response).to be_success
|
99
|
+
expect(response).to render_template('users/edit')
|
100
|
+
expect(flash[:alert]).to be_nil
|
101
101
|
end
|
102
102
|
it "redirects to show profile when user attempts to edit another profile" do
|
103
103
|
get :edit, id: @another_user.user_key
|
104
|
-
response.
|
105
|
-
flash[:alert].
|
104
|
+
expect(response).to redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
|
105
|
+
expect(flash[:alert]).to include("Permission denied: cannot access this page.")
|
106
106
|
end
|
107
107
|
describe "when the user has trophies" do
|
108
108
|
let(:user) { @user }
|
@@ -115,8 +115,8 @@ describe UsersController do
|
|
115
115
|
|
116
116
|
it "show the user profile if user exists" do
|
117
117
|
get :edit, id: @user.user_key
|
118
|
-
response.
|
119
|
-
assigns[:trophies].
|
118
|
+
expect(response).to be_success
|
119
|
+
expect(assigns[:trophies]).to match_array([file1, file2, file3])
|
120
120
|
end
|
121
121
|
|
122
122
|
end
|
@@ -124,33 +124,33 @@ describe UsersController do
|
|
124
124
|
describe "#update" do
|
125
125
|
it "should not allow other users to update" do
|
126
126
|
post :update, id: @another_user.user_key, user: { avatar: nil }
|
127
|
-
response.
|
128
|
-
flash[:alert].
|
127
|
+
expect(response).to redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
|
128
|
+
expect(flash[:alert]).to include("Permission denied: cannot access this page.")
|
129
129
|
end
|
130
130
|
it "should set an avatar and redirect to profile" do
|
131
|
-
@user.avatar
|
131
|
+
expect(@user.avatar?).to be false
|
132
132
|
s1 = double('one')
|
133
|
-
UserEditProfileEventJob.
|
134
|
-
Sufia.queue.
|
135
|
-
f = fixture_file_upload('/
|
133
|
+
expect(UserEditProfileEventJob).to receive(:new).with(@user.user_key).and_return(s1)
|
134
|
+
expect(Sufia.queue).to receive(:push).with(s1).once
|
135
|
+
f = fixture_file_upload('/1.5mb-avatar.jpg', 'image/jpg')
|
136
136
|
post :update, id: @user.user_key, user: { avatar: f }
|
137
|
-
response.
|
138
|
-
flash[:notice].
|
139
|
-
User.find_by_user_key(@user.user_key).avatar
|
137
|
+
expect(response).to redirect_to(@routes.url_helpers.profile_path(@user.to_param))
|
138
|
+
expect(flash[:notice]).to include("Your profile has been updated")
|
139
|
+
expect(User.find_by_user_key(@user.user_key).avatar?).to be true
|
140
140
|
end
|
141
141
|
it "should validate the content type of an avatar" do
|
142
|
-
Sufia.queue.
|
142
|
+
expect(Sufia.queue).to receive(:push).never
|
143
143
|
f = fixture_file_upload('/image.jp2', 'image/jp2')
|
144
144
|
post :update, id: @user.user_key, user: { avatar: f }
|
145
|
-
response.
|
146
|
-
flash[:alert].
|
145
|
+
expect(response).to redirect_to(@routes.url_helpers.edit_profile_path(@user.to_param))
|
146
|
+
expect(flash[:alert]).to include("Avatar You are not allowed to upload \"jp2\" files, allowed types: jpg, jpeg, png, gif, bmp, tif, tiff")
|
147
147
|
end
|
148
148
|
it "should validate the size of an avatar" do
|
149
149
|
f = fixture_file_upload('/4-20.png', 'image/png')
|
150
|
-
Sufia.queue.
|
150
|
+
expect(Sufia.queue).to receive(:push).never
|
151
151
|
post :update, id: @user.user_key, user: { avatar: f }
|
152
|
-
response.
|
153
|
-
flash[:alert].
|
152
|
+
expect(response).to redirect_to(@routes.url_helpers.edit_profile_path(@user.to_param))
|
153
|
+
expect(flash[:alert]).to include("Avatar file size must be less than 2MB")
|
154
154
|
end
|
155
155
|
context "user with existing avatar" do
|
156
156
|
before do
|
@@ -160,36 +160,36 @@ describe UsersController do
|
|
160
160
|
end
|
161
161
|
it "should delete an avatar" do
|
162
162
|
s1 = double('one')
|
163
|
-
UserEditProfileEventJob.
|
164
|
-
Sufia.queue.
|
165
|
-
post :update, id: @user.user_key,
|
166
|
-
response.
|
167
|
-
flash[:notice].
|
168
|
-
User.find_by_user_key(@user.user_key).avatar
|
163
|
+
expect(UserEditProfileEventJob).to receive(:new).with(@user.user_key).and_return(s1)
|
164
|
+
expect(Sufia.queue).to receive(:push).with(s1).once
|
165
|
+
post :update, id: @user.user_key, user: { remove_avatar: true }
|
166
|
+
expect(response).to redirect_to(@routes.url_helpers.profile_path(@user.to_param))
|
167
|
+
expect(flash[:notice]).to include("Your profile has been updated")
|
168
|
+
expect(User.find_by_user_key(@user.user_key).avatar?).to be false
|
169
169
|
end
|
170
170
|
end
|
171
171
|
it "should refresh directory attributes" do
|
172
172
|
s1 = double('one')
|
173
|
-
UserEditProfileEventJob.
|
174
|
-
Sufia.queue.
|
175
|
-
User.
|
176
|
-
post :update, id: @user.user_key, update_directory: true
|
177
|
-
response.
|
178
|
-
flash[:notice].
|
173
|
+
expect(UserEditProfileEventJob).to receive(:new).with(@user.user_key).and_return(s1)
|
174
|
+
expect(Sufia.queue).to receive(:push).with(s1).once
|
175
|
+
expect_any_instance_of(User).to receive(:populate_attributes).once
|
176
|
+
post :update, id: @user.user_key, user: { update_directory: true }
|
177
|
+
expect(response).to redirect_to(@routes.url_helpers.profile_path(@user.to_param))
|
178
|
+
expect(flash[:notice]).to include("Your profile has been updated")
|
179
179
|
end
|
180
180
|
it "should set an social handles" do
|
181
|
-
@user.twitter_handle.
|
182
|
-
@user.facebook_handle.
|
183
|
-
@user.googleplus_handle.
|
184
|
-
@user.linkedin_handle.
|
181
|
+
expect(@user.twitter_handle).to be_blank
|
182
|
+
expect(@user.facebook_handle).to be_blank
|
183
|
+
expect(@user.googleplus_handle).to be_blank
|
184
|
+
expect(@user.linkedin_handle).to be_blank
|
185
185
|
post :update, id: @user.user_key, user: { twitter_handle: 'twit', facebook_handle: 'face', googleplus_handle: 'goo', linkedin_handle:"link" }
|
186
|
-
response.
|
187
|
-
flash[:notice].
|
186
|
+
expect(response).to redirect_to(@routes.url_helpers.profile_path(@user.to_param))
|
187
|
+
expect(flash[:notice]).to include("Your profile has been updated")
|
188
188
|
u = User.find_by_user_key(@user.user_key)
|
189
|
-
u.twitter_handle.
|
190
|
-
u.facebook_handle.
|
191
|
-
u.googleplus_handle.
|
192
|
-
u.linkedin_handle.
|
189
|
+
expect(u.twitter_handle).to eq 'twit'
|
190
|
+
expect(u.facebook_handle).to eq 'face'
|
191
|
+
expect(u.googleplus_handle).to eq 'goo'
|
192
|
+
expect(u.linkedin_handle).to eq 'link'
|
193
193
|
end
|
194
194
|
|
195
195
|
context "when removing a trophy" do
|
@@ -202,8 +202,8 @@ describe UsersController do
|
|
202
202
|
expect {
|
203
203
|
post :update, id: user.user_key, 'remove_trophy_'+file.noid => 'yes'
|
204
204
|
}.to change { user.trophies.count }.by(-1)
|
205
|
-
response.
|
206
|
-
flash[:notice].
|
205
|
+
expect(response).to redirect_to(@routes.url_helpers.profile_path(user.to_param))
|
206
|
+
expect(flash[:notice]).to include("Your profile has been updated")
|
207
207
|
end
|
208
208
|
end
|
209
209
|
end
|
@@ -213,54 +213,50 @@ describe UsersController do
|
|
213
213
|
@user.unfollow(@another_user) rescue nil
|
214
214
|
end
|
215
215
|
it "should follow another user if not already following, and log an event" do
|
216
|
-
@user.following?(@another_user).
|
216
|
+
expect(@user.following?(@another_user)).to be false
|
217
217
|
s1 = double('one')
|
218
|
-
UserFollowEventJob.
|
219
|
-
Sufia.queue.
|
218
|
+
expect(UserFollowEventJob).to receive(:new).with(@user.user_key, @another_user.user_key).and_return(s1)
|
219
|
+
expect(Sufia.queue).to receive(:push).with(s1).once
|
220
220
|
post :follow, id: @another_user.user_key
|
221
|
-
response.
|
222
|
-
flash[:notice].
|
221
|
+
expect(response).to redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
|
222
|
+
expect(flash[:notice]).to include("You are following #{@another_user.user_key}")
|
223
223
|
end
|
224
224
|
it "should redirect to profile if already following and not log an event" do
|
225
|
-
User.
|
226
|
-
|
227
|
-
Sufia.queue.should_receive(:push).never
|
225
|
+
allow_any_instance_of(User).to receive(:following?).with(@another_user).and_return(true)
|
226
|
+
expect(Sufia.queue).to receive(:push).never
|
228
227
|
post :follow, id: @another_user.user_key
|
229
|
-
response.
|
230
|
-
flash[:notice].
|
228
|
+
expect(response).to redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
|
229
|
+
expect(flash[:notice]).to include("You are following #{@another_user.user_key}")
|
231
230
|
end
|
232
231
|
it "should redirect to profile if user attempts to self-follow and not log an event" do
|
233
|
-
|
234
|
-
Sufia.queue.should_receive(:push).never
|
232
|
+
expect(Sufia.queue).to receive(:push).never
|
235
233
|
post :follow, id: @user.user_key
|
236
|
-
response.
|
237
|
-
flash[:alert].
|
234
|
+
expect(response).to redirect_to(@routes.url_helpers.profile_path(@user.to_param))
|
235
|
+
expect(flash[:alert]).to include("You cannot follow or unfollow yourself")
|
238
236
|
end
|
239
237
|
end
|
240
238
|
describe "#unfollow" do
|
241
239
|
it "should unfollow another user if already following, and log an event" do
|
242
|
-
User.
|
240
|
+
allow_any_instance_of(User).to receive(:following?).with(@another_user).and_return(true)
|
243
241
|
s1 = double('one')
|
244
|
-
UserUnfollowEventJob.
|
245
|
-
Sufia.queue.
|
242
|
+
expect(UserUnfollowEventJob).to receive(:new).with(@user.user_key, @another_user.user_key).and_return(s1)
|
243
|
+
expect(Sufia.queue).to receive(:push).with(s1).once
|
246
244
|
post :unfollow, id: @another_user.user_key
|
247
|
-
response.
|
248
|
-
flash[:notice].
|
245
|
+
expect(response).to redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
|
246
|
+
expect(flash[:notice]).to include("You are no longer following #{@another_user.user_key}")
|
249
247
|
end
|
250
248
|
it "should redirect to profile if not following and not log an event" do
|
251
|
-
@user.
|
252
|
-
|
253
|
-
Sufia.queue.should_receive(:push).never
|
249
|
+
allow(@user).to receive(:following?).with(@another_user).and_return(false)
|
250
|
+
expect(Sufia.queue).to receive(:push).never
|
254
251
|
post :unfollow, id: @another_user.user_key
|
255
|
-
response.
|
256
|
-
flash[:notice].
|
252
|
+
expect(response).to redirect_to(@routes.url_helpers.profile_path(@another_user.to_param))
|
253
|
+
expect(flash[:notice]).to include("You are no longer following #{@another_user.user_key}")
|
257
254
|
end
|
258
255
|
it "should redirect to profile if user attempts to self-follow and not log an event" do
|
259
|
-
|
260
|
-
Sufia.queue.should_receive(:push).never
|
256
|
+
expect(Sufia.queue).to receive(:push).never
|
261
257
|
post :unfollow, id: @user.user_key
|
262
|
-
response.
|
263
|
-
flash[:alert].
|
258
|
+
expect(response).to redirect_to(@routes.url_helpers.profile_path(@user.to_param))
|
259
|
+
expect(flash[:alert]).to include("You cannot follow or unfollow yourself")
|
264
260
|
end
|
265
261
|
end
|
266
262
|
describe "#toggle_trophy" do
|
@@ -275,18 +271,19 @@ describe UsersController do
|
|
275
271
|
end
|
276
272
|
it "should trophy a file" do
|
277
273
|
post :toggle_trophy, {id: @user.user_key, file_id: @file_id}
|
278
|
-
JSON.parse(response.body)
|
279
|
-
|
274
|
+
json = JSON.parse(response.body)
|
275
|
+
expect(json['user_id']).to eq @user.id
|
276
|
+
expect(json['generic_file_id']).to eq @file_id
|
280
277
|
end
|
281
278
|
it "should not trophy a file for a different user" do
|
282
279
|
post :toggle_trophy, {id: @another_user.user_key, file_id: @file_id}
|
283
|
-
response.
|
280
|
+
expect(response).to_not be_success
|
284
281
|
end
|
285
282
|
it "should not trophy a file with no edit privs" do
|
286
283
|
sign_out @user
|
287
284
|
sign_in @another_user
|
288
285
|
post :toggle_trophy, {id: @another_user.user_key, file_id: @file_id}
|
289
|
-
response.
|
286
|
+
expect(response).to_not be_success
|
290
287
|
end
|
291
288
|
end
|
292
289
|
end
|
@@ -18,11 +18,11 @@ FactoryGirl.define do
|
|
18
18
|
end
|
19
19
|
initialize_with { new(pid: pid) }
|
20
20
|
read_groups ["public"]
|
21
|
-
resource_type "Dissertation"
|
21
|
+
resource_type ["Dissertation"]
|
22
22
|
subject %w"lorem ipsum dolor sit amet"
|
23
23
|
before(:create) do |gf|
|
24
24
|
gf.apply_depositor_metadata "archivist1@example.com"
|
25
|
-
gf.title = "Fake Document Title"
|
25
|
+
gf.title = ["Fake Document Title"]
|
26
26
|
gf.label = "fake_document.pdf"
|
27
27
|
end
|
28
28
|
end
|
data/spec/factories/users.rb
CHANGED
@@ -13,13 +13,43 @@ FactoryGirl.define do
|
|
13
13
|
|
14
14
|
factory :user_with_mail do
|
15
15
|
after(:create) do |user|
|
16
|
-
|
17
|
-
|
16
|
+
# TODO: what is this class for?
|
17
|
+
# <span class="batchid ui-helper-hidden">fake_batch_noid</span>
|
18
|
+
message = BatchMessage.new
|
19
|
+
|
20
|
+
# Create examples of single file successes and failures
|
21
|
+
(1..10).each do |number|
|
22
|
+
file = MockFile.new(number.to_s, "Single File #{number.to_s}")
|
23
|
+
User.batchuser().send_message(user, message.single_success("single-batch-success", file), message.success_subject, sanitize_text = false)
|
24
|
+
User.batchuser().send_message(user, message.single_failure("single-batch-failure", file), message.failure_subject, sanitize_text = false)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Create examples of mulitple file successes and failures
|
28
|
+
files = []
|
29
|
+
(1..50).each do |number|
|
30
|
+
files << MockFile.new(number.to_s, "File #{number.to_s}")
|
31
|
+
end
|
32
|
+
User.batchuser().send_message(user, message.multiple_success("multiple-batch-success", files), message.success_subject, sanitize_text = false)
|
33
|
+
User.batchuser().send_message(user, message.multiple_failure("multiple-batch-failure", files), message.failure_subject, sanitize_text = false)
|
18
34
|
end
|
19
35
|
end
|
20
36
|
|
21
37
|
factory :curator do
|
22
38
|
email 'curator1@example.com'
|
23
39
|
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class MockFile
|
45
|
+
attr_accessor :noid, :to_s, :id
|
46
|
+
def initialize id, string
|
47
|
+
self.noid = id
|
48
|
+
self.id = id
|
49
|
+
self.to_s = string
|
24
50
|
end
|
25
51
|
end
|
52
|
+
|
53
|
+
class BatchMessage
|
54
|
+
include Sufia::Messages
|
55
|
+
end
|
@@ -20,15 +20,27 @@ describe "Browse Dashboard" do
|
|
20
20
|
visit "dashboard/files"
|
21
21
|
end
|
22
22
|
|
23
|
-
it "should
|
23
|
+
it "should display all the necessary information" do
|
24
24
|
expect(page).to have_content("Edit File")
|
25
25
|
expect(page).to have_content("Download File")
|
26
|
+
expect(page).to_not have_content("Is part of:")
|
27
|
+
first(".label-success") do
|
28
|
+
expect(page).to have_content("Open Access")
|
29
|
+
end
|
30
|
+
expect(page).to have_link("Create Collection")
|
31
|
+
expect(page).to have_link("Upload")
|
26
32
|
end
|
27
33
|
|
28
|
-
it "should allow you to search your own files" do
|
34
|
+
it "should allow you to search your own files and remove constraints" do
|
29
35
|
fill_in "q", with: "PDF"
|
30
36
|
click_button "search-submit-header"
|
31
37
|
expect(page).to have_content("Fake Document Title")
|
38
|
+
within(".constraints-container") do
|
39
|
+
expect(page).to have_content("You searched for:")
|
40
|
+
expect(page).to have_css("span.glyphicon-remove")
|
41
|
+
find(".dropdown-toggle").click
|
42
|
+
end
|
43
|
+
expect(page).to have_content("Fake Wav File")
|
32
44
|
end
|
33
45
|
|
34
46
|
it "should allow you to browse facets" do
|
@@ -2,9 +2,13 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "Browse files" do
|
4
4
|
|
5
|
+
before do
|
6
|
+
allow(User).to receive(:find_by_user_key).and_return(stub_model(User, twitter_handle: 'bob'))
|
7
|
+
end
|
8
|
+
|
5
9
|
before(:all) do
|
6
10
|
@fixtures = find_or_create_file_fixtures
|
7
|
-
@fixtures[0].tag = "key"
|
11
|
+
@fixtures[0].tag = ["key"]
|
8
12
|
(1..25).each do |i|
|
9
13
|
@fixtures[0].tag << i
|
10
14
|
end
|