sufia 4.0.0.beta3 → 4.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -0
  3. data/SUFIA_VERSION +1 -1
  4. data/app/assets/javascripts/sufia/search.js +4 -6
  5. data/app/assets/stylesheets/dashboard.css.scss +26 -0
  6. data/app/assets/stylesheets/header.css.scss +21 -12
  7. data/app/controllers/batch_controller.rb +0 -1
  8. data/app/controllers/collections_controller.rb +0 -1
  9. data/app/controllers/concerns/sufia/catalog.rb +0 -9
  10. data/app/controllers/concerns/sufia/controller.rb +4 -0
  11. data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +24 -74
  12. data/app/controllers/concerns/sufia/downloads_controller_behavior.rb +0 -3
  13. data/app/controllers/concerns/sufia/files_controller_behavior.rb +4 -13
  14. data/app/controllers/concerns/sufia/my_controller_behavior.rb +87 -0
  15. data/app/controllers/{dashboard → my}/collections_controller.rb +3 -2
  16. data/app/controllers/{dashboard → my}/files_controller.rb +3 -2
  17. data/app/controllers/{dashboard → my}/highlights_controller.rb +3 -2
  18. data/app/controllers/{dashboard → my}/shares_controller.rb +3 -2
  19. data/app/controllers/my_controller.rb +3 -0
  20. data/app/controllers/single_use_links_controller.rb +0 -2
  21. data/app/helpers/dashboard_helper.rb +3 -0
  22. data/app/helpers/generic_file_helper.rb +4 -4
  23. data/app/helpers/sufia/dashboard_helper_behavior.rb +25 -0
  24. data/app/helpers/sufia/sufia_helper_behavior.rb +44 -0
  25. data/app/jobs/content_delete_event_job.rb +2 -2
  26. data/app/models/concerns/sufia/solr_document_behavior.rb +5 -0
  27. data/app/views/_user_util_links.html.erb +5 -5
  28. data/app/views/catalog/_results_pagination.html.erb +1 -1
  29. data/app/views/catalog/_search_form.html.erb +56 -28
  30. data/app/views/collections/_dashboard_document_list.html.erb +1 -1
  31. data/app/views/collections/_document_list.html.erb +1 -1
  32. data/app/views/collections/edit.html.erb +8 -11
  33. data/app/views/collections/show.html.erb +2 -2
  34. data/app/views/collections/show_fields/_creator.html.erb +11 -0
  35. data/app/views/collections/show_fields/_description.html.erb +8 -0
  36. data/app/views/collections/show_fields/_title.html.erb +8 -0
  37. data/app/views/dashboard/_index_partials/_stats.html.erb +16 -0
  38. data/app/views/dashboard/_index_partials/_user_info.html.erb +18 -0
  39. data/app/views/dashboard/index.html.erb +51 -19
  40. data/app/views/generic_files/_show_descriptions.html.erb +11 -10
  41. data/app/views/generic_files/show.html.erb +1 -1
  42. data/app/views/generic_files/show_fields/_based_near.html.erb +7 -0
  43. data/app/views/generic_files/show_fields/_contributor.html.erb +7 -0
  44. data/app/views/generic_files/show_fields/_creator.html.erb +7 -0
  45. data/app/views/generic_files/show_fields/_date_created.html.erb +7 -0
  46. data/app/views/generic_files/show_fields/_default.html.erb +6 -12
  47. data/app/views/generic_files/show_fields/_description.html.erb +7 -0
  48. data/app/views/generic_files/show_fields/_identifier.html.erb +4 -0
  49. data/app/views/generic_files/show_fields/_language.html.erb +4 -0
  50. data/app/views/generic_files/show_fields/_publisher.html.erb +7 -0
  51. data/app/views/generic_files/show_fields/_related_url.html.erb +6 -0
  52. data/app/views/generic_files/show_fields/_resource_type.html.erb +4 -0
  53. data/app/views/generic_files/show_fields/_rights.html.erb +4 -0
  54. data/app/views/generic_files/show_fields/_subject.html.erb +7 -0
  55. data/app/views/generic_files/show_fields/_tag.html.erb +4 -0
  56. data/app/views/generic_files/show_fields/_title.html.erb +7 -0
  57. data/app/views/generic_files/upload/_form_fields.html.erb +4 -5
  58. data/app/views/generic_files/upload/_script_templates.html.erb +1 -2
  59. data/app/views/layouts/sufia-dashboard.html.erb +16 -30
  60. data/app/views/mailbox/_notifications.html.erb +21 -0
  61. data/app/views/mailbox/index.html.erb +2 -23
  62. data/app/views/{dashboard → my}/_action_menu.html.erb +0 -0
  63. data/app/views/{dashboard → my}/_batch_edits_actions.html.erb +0 -0
  64. data/app/views/{dashboard → my}/_collection_action_menu.html.erb +0 -0
  65. data/app/views/{dashboard → my}/_did_you_mean.html.erb +0 -0
  66. data/app/views/my/_document_list.html.erb +4 -0
  67. data/app/views/{dashboard → my}/_facet_layout.html.erb +0 -0
  68. data/app/views/{dashboard → my}/_facet_limit.html.erb +0 -0
  69. data/app/views/{dashboard → my}/_facet_pagination.html.erb +0 -0
  70. data/app/views/{dashboard → my}/_facet_selected.html.erb +0 -0
  71. data/app/views/{dashboard → my}/_facets.html.erb +0 -0
  72. data/app/views/{dashboard → my}/_index_partials/_default_group.html.erb +2 -2
  73. data/app/views/{dashboard → my}/_index_partials/_list_collections.html.erb +0 -0
  74. data/app/views/{dashboard → my}/_index_partials/_list_files.html.erb +0 -0
  75. data/app/views/{dashboard → my}/_results_pagination.html.erb +0 -0
  76. data/app/views/my/_scripts.js.erb +11 -0
  77. data/app/views/{dashboard → my}/_sort_and_per_page.html.erb +0 -0
  78. data/app/views/{dashboard → my}/facet.html.erb +0 -0
  79. data/app/views/{dashboard/lists → my}/index.html.erb +4 -20
  80. data/app/views/users/_user_info.html.erb +1 -1
  81. data/config/initializers/sufia_events.rb +19 -2
  82. data/config/locales/sufia.en.yml +27 -2
  83. data/config/routes.rb +7 -11
  84. data/lib/generators/sufia/sufia_generator.rb +15 -0
  85. data/lib/generators/sufia/templates/catalog_controller.rb +14 -14
  86. data/lib/sufia.rb +1 -0
  87. data/lib/sufia/version.rb +1 -1
  88. data/spec/controllers/catalog_controller_spec.rb +7 -16
  89. data/spec/controllers/dashboard_controller_spec.rb +63 -30
  90. data/spec/controllers/generic_files_controller_spec.rb +1 -1
  91. data/spec/controllers/{dashboard → my}/collections_controller_spec.rb +1 -15
  92. data/spec/controllers/my/files_controller_spec.rb +68 -0
  93. data/spec/controllers/{dashboard → my}/highlights_controller_spec.rb +1 -15
  94. data/spec/controllers/{dashboard → my}/shares_controller_spec.rb +1 -15
  95. data/spec/controllers/my_controller_spec.rb +9 -0
  96. data/spec/features/browse_dashboard_files_spec.rb +72 -26
  97. data/spec/features/collection_spec.rb +2 -4
  98. data/spec/features/display_dashboard_spec.rb +20 -26
  99. data/spec/features/search_spec.rb +25 -13
  100. data/spec/helpers/dashboard_helper_spec.rb +41 -0
  101. data/spec/helpers/sufia_helper_spec.rb +104 -3
  102. data/spec/jobs/event_jobs_spec.rb +1 -1
  103. data/spec/models/generic_file/web_form_spec.rb +3 -4
  104. data/spec/models/generic_file_spec.rb +47 -43
  105. data/spec/routing/route_spec.rb +10 -14
  106. data/spec/views/batch_edits/check_all_spec.rb +4 -4
  107. data/spec/views/catalog/sort_and_per_pange.html.erb_spec.rb +27 -0
  108. data/spec/views/dashboard/index_spec.rb +105 -0
  109. data/spec/views/{dashboard → my}/facet_limit.html.erb_spec.rb +2 -2
  110. data/sufia-models/app/actors/sufia/generic_file/actor.rb +23 -3
  111. data/sufia-models/app/models/concerns/sufia/generic_file.rb +0 -5
  112. data/sufia-models/app/models/concerns/sufia/generic_file/metadata.rb +9 -2
  113. data/sufia-models/app/models/concerns/sufia/generic_file/web_form.rb +2 -2
  114. data/sufia-models/app/models/datastreams/generic_file_rdf_datastream.rb +1 -1
  115. data/sufia-models/app/services/sufia/noid.rb +21 -16
  116. data/sufia-models/lib/generators/sufia/models/install_generator.rb +2 -16
  117. data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +23 -0
  118. data/sufia-models/lib/sufia/models/version.rb +1 -1
  119. data/sufia-models/sufia-models.gemspec +1 -1
  120. data/vendor/assets/javascripts/fileupload/jquery.fileupload-ui.js +18 -10
  121. metadata +68 -45
  122. data/app/assets/images/glyphicons-halflings-white.png +0 -0
  123. data/app/assets/images/glyphicons-halflings.png +0 -0
  124. data/app/controllers/dashboard/lists_controller.rb +0 -13
  125. data/app/views/dashboard/_constraints.html.erb +0 -6
  126. data/app/views/dashboard/_document_list.html.erb +0 -4
  127. data/app/views/dashboard/_heading.html.erb +0 -1
  128. data/app/views/dashboard/_search_form.html.erb +0 -14
  129. data/app/views/dashboard/_show_partials/_default.html.erb +0 -20
  130. data/app/views/dashboard/_show_partials/_default_details.html.erb +0 -15
  131. data/app/views/dashboard/_show_partials/_facets.html.erb +0 -87
  132. data/app/views/generic_files/_field_display.html.erb +0 -12
  133. data/spec/controllers/dashboard/files_controller_spec.rb +0 -71
@@ -157,7 +157,7 @@ describe 'event jobs' do
157
157
  @another_user.events.length.should == 0
158
158
  @third_user.events.length.should == 0
159
159
  Time.should_receive(:now).at_least(:once).and_return(1)
160
- event = {action: 'User <a href="/users/jilluser@example-dot-com">jilluser@example.com</a> has deleted file \'test:123\'', timestamp: '1' }
160
+ event = {action: 'User <a href="/users/jilluser@example-dot-com">jilluser@example.com</a> has deleted file \'123\'', timestamp: '1' }
161
161
  ContentDeleteEventJob.new('test:123', @user.user_key).run
162
162
  @user.profile_events.length.should == 1
163
163
  @user.profile_events.first.should == event
@@ -15,16 +15,15 @@ describe GenericFile do
15
15
  it "should return a list" do
16
16
  expect(subject.terms_for_display).to eq([:resource_type, :title,
17
17
  :creator, :contributor, :description, :tag, :rights, :publisher,
18
- :date_created, :date_uploaded, :date_modified, :subject, :language,
19
- :identifier, :based_near, :related_url])
18
+ :date_created, :subject, :language, :identifier, :based_near,
19
+ :related_url])
20
20
  end
21
21
  end
22
22
 
23
23
  describe "accessible_attributes" do
24
24
  it "should have a list" do
25
25
  subject.accessible_attributes.should include(:part_of, :resource_type, :title, :creator, :contributor, :description,
26
- :tag, :rights, :publisher, :date_created, :date_uploaded, :date_modified, :subject, :language, :identifier,
27
- :based_near, :related_url, :permissions)
26
+ :tag, :rights, :publisher, :date_created, :subject, :language, :identifier, :based_near, :related_url, :permissions)
28
27
  end
29
28
 
30
29
  it "should sanitize them" do
@@ -264,49 +264,53 @@ describe GenericFile do
264
264
  end
265
265
  end
266
266
  end
267
- it "supports to_solr" do
268
- allow(subject).to receive(:pid).and_return('stubbed_pid')
269
- subject.part_of = "Arabiana"
270
- subject.contributor = "Mohammad"
271
- subject.creator = "Allah"
272
- subject.title = "The Work"
273
- subject.description = "The work by Allah"
274
- subject.publisher = "Vertigo Comics"
275
- subject.date_created = "1200-01-01"
276
- subject.date_uploaded = Date.parse("2011-01-01")
277
- subject.date_modified = Date.parse("2012-01-01")
278
- subject.subject = "Theology"
279
- subject.language = "Arabic"
280
- subject.rights = "Wide open, buddy."
281
- subject.resource_type = "Book"
282
- subject.identifier = "urn:isbn:1234567890"
283
- subject.based_near = "Medina, Saudi Arabia"
284
- subject.related_url = "http://example.org/TheWork/"
285
- subject.mime_type = "image/jpeg"
286
- subject.format_label = "JPEG Image"
287
- local = subject.to_solr
288
- local.should_not be_nil
289
- local[Solrizer.solr_name("desc_metadata__part_of")].should be_nil
290
- local[Solrizer.solr_name("desc_metadata__date_uploaded")].should be_nil
291
- local[Solrizer.solr_name("desc_metadata__date_modified")].should be_nil
292
- local[Solrizer.solr_name("desc_metadata__date_uploaded", :stored_sortable, type: :date)].should == '2011-01-01T00:00:00Z'
293
- local[Solrizer.solr_name("desc_metadata__date_modified", :stored_sortable, type: :date)].should == '2012-01-01T00:00:00Z'
294
- local[Solrizer.solr_name("desc_metadata__rights")].should == ["Wide open, buddy."]
295
- local[Solrizer.solr_name("desc_metadata__related_url")].should == ["http://example.org/TheWork/"]
296
- local[Solrizer.solr_name("desc_metadata__contributor")].should == ["Mohammad"]
297
- local[Solrizer.solr_name("desc_metadata__creator")].should == ["Allah"]
298
- local[Solrizer.solr_name("desc_metadata__title")].should == ["The Work"]
299
- local[Solrizer.solr_name("desc_metadata__description")].should == ["The work by Allah"]
300
- local[Solrizer.solr_name("desc_metadata__publisher")].should == ["Vertigo Comics"]
301
- local[Solrizer.solr_name("desc_metadata__subject")].should == ["Theology"]
302
- local[Solrizer.solr_name("desc_metadata__language")].should == ["Arabic"]
303
- local[Solrizer.solr_name("desc_metadata__date_created")].should == ["1200-01-01"]
304
- local[Solrizer.solr_name("desc_metadata__resource_type")].should == ["Book"]
305
- local[Solrizer.solr_name("file_format")].should == "jpeg (JPEG Image)"
306
- local[Solrizer.solr_name("desc_metadata__identifier")].should == ["urn:isbn:1234567890"]
307
- local[Solrizer.solr_name("desc_metadata__based_near")].should == ["Medina, Saudi Arabia"]
308
- local[Solrizer.solr_name("mime_type")].should == ["image/jpeg"]
309
- local["noid_tsi"].should eq('stubbed_pid')
267
+ describe "to_solr" do
268
+ before do
269
+ allow(subject).to receive(:pid).and_return('stubbed_pid')
270
+ subject.part_of = "Arabiana"
271
+ subject.contributor = "Mohammad"
272
+ subject.creator = "Allah"
273
+ subject.title = "The Work"
274
+ subject.description = "The work by Allah"
275
+ subject.publisher = "Vertigo Comics"
276
+ subject.date_created = "1200-01-01"
277
+ subject.date_uploaded = Date.parse("2011-01-01")
278
+ subject.date_modified = Date.parse("2012-01-01")
279
+ subject.subject = "Theology"
280
+ subject.language = "Arabic"
281
+ subject.rights = "Wide open, buddy."
282
+ subject.resource_type = "Book"
283
+ subject.identifier = "urn:isbn:1234567890"
284
+ subject.based_near = "Medina, Saudi Arabia"
285
+ subject.related_url = "http://example.org/TheWork/"
286
+ subject.mime_type = "image/jpeg"
287
+ subject.format_label = "JPEG Image"
288
+ end
289
+ it "supports to_solr" do
290
+ local = subject.to_solr
291
+ expect(local[Solrizer.solr_name("desc_metadata__part_of")]).to be_nil
292
+ expect(local[Solrizer.solr_name("desc_metadata__date_uploaded")]).to be_nil
293
+ expect(local[Solrizer.solr_name("desc_metadata__date_modified")]).to be_nil
294
+ expect(local[Solrizer.solr_name("desc_metadata__date_uploaded", :stored_sortable, type: :date)]).to eq '2011-01-01T00:00:00Z'
295
+ expect(local[Solrizer.solr_name("desc_metadata__date_modified", :stored_sortable, type: :date)]).to eq '2012-01-01T00:00:00Z'
296
+ expect(local[Solrizer.solr_name("desc_metadata__rights")]).to eq ["Wide open, buddy."]
297
+ expect(local[Solrizer.solr_name("desc_metadata__related_url")]).to eq ["http://example.org/TheWork/"]
298
+ expect(local[Solrizer.solr_name("desc_metadata__contributor")]).to eq ["Mohammad"]
299
+ expect(local[Solrizer.solr_name("desc_metadata__creator")]).to eq ["Allah"]
300
+ expect(local[Solrizer.solr_name("desc_metadata__title")]).to eq ["The Work"]
301
+ expect(local["desc_metadata__title_sim"]).to eq ["The Work"]
302
+ expect(local[Solrizer.solr_name("desc_metadata__description")]).to eq ["The work by Allah"]
303
+ expect(local[Solrizer.solr_name("desc_metadata__publisher")]).to eq ["Vertigo Comics"]
304
+ expect(local[Solrizer.solr_name("desc_metadata__subject")]).to eq ["Theology"]
305
+ expect(local[Solrizer.solr_name("desc_metadata__language")]).to eq ["Arabic"]
306
+ expect(local[Solrizer.solr_name("desc_metadata__date_created")]).to eq ["1200-01-01"]
307
+ expect(local[Solrizer.solr_name("desc_metadata__resource_type")]).to eq ["Book"]
308
+ expect(local[Solrizer.solr_name("file_format")]).to eq "jpeg (JPEG Image)"
309
+ expect(local[Solrizer.solr_name("desc_metadata__identifier")]).to eq ["urn:isbn:1234567890"]
310
+ expect(local[Solrizer.solr_name("desc_metadata__based_near")]).to eq ["Medina, Saudi Arabia"]
311
+ expect(local[Solrizer.solr_name("mime_type")]).to eq ["image/jpeg"]
312
+ expect(local["noid_tsi"]).to eq 'stubbed_pid'
313
+ end
310
314
  end
311
315
  it "should support multi-valued fields in solr" do
312
316
  subject.tag = ["tag1", "tag2"]
@@ -72,28 +72,24 @@ describe 'Routes' do
72
72
  { get: '/dashboard' }.should route_to(controller: 'dashboard', action: 'index')
73
73
  end
74
74
 
75
- it "should route to dashboard files tab" do
76
- { get: '/dashboard/files' }.should route_to(controller: 'dashboard/files', action: 'index')
77
- end
78
-
79
- it "should route to dashboard collections tab" do
80
- { get: '/dashboard/collections' }.should route_to(controller: 'dashboard/collections', action: 'index')
75
+ it "should route to dashboard activity" do
76
+ { get: '/dashboard/activity' }.should route_to(controller: 'dashboard', action: 'activity')
81
77
  end
82
78
 
83
- it "should route to dashboard highlighted tab" do
84
- { get: '/dashboard/highlights' }.should route_to(controller: 'dashboard/highlights', action: 'index')
79
+ it "should route to my files tab" do
80
+ { get: '/dashboard/files' }.should route_to(controller: 'my/files', action: 'index')
85
81
  end
86
82
 
87
- it "should route to dashboard shared tab" do
88
- { get: '/dashboard/shares' }.should route_to(controller: 'dashboard/shares', action: 'index')
83
+ it "should route to my collections tab" do
84
+ { get: '/dashboard/collections' }.should route_to(controller: 'my/collections', action: 'index')
89
85
  end
90
86
 
91
- it "should route to dashboard facet" do
92
- { get: '/dashboard/facet/1' }.should route_to(controller: 'dashboard', action: 'facet', id: '1')
87
+ it "should route to my highlighted tab" do
88
+ { get: '/dashboard/highlights' }.should route_to(controller: 'my/highlights', action: 'index')
93
89
  end
94
90
 
95
- it "should route to dashboard activity" do
96
- { get: '/dashboard/activity' }.should route_to(controller: 'dashboard', action: 'activity')
91
+ it "should route to my shared tab" do
92
+ { get: '/dashboard/shares' }.should route_to(controller: 'my/shares', action: 'index')
97
93
  end
98
94
  end
99
95
 
@@ -8,15 +8,15 @@ describe 'Check All' do
8
8
  end
9
9
 
10
10
  it 'should render batch edits actions' do
11
- controller.stub(:controller_name).and_return('batch_edits')
11
+ allow(controller).to receive(:controller_name).and_return('batch_edits')
12
12
  controller.prepend_view_path "app/views/batch_edits"
13
13
  html = render partial: 'batch_edits/check_all'
14
14
  html.should have_selector("li[data-behavior='batch-edit-select-abc']")
15
15
  end
16
16
 
17
- it 'should render dashboard actions' do
18
- controller.stub(:controller_name).and_return('dashboard')
19
- controller.prepend_view_path "app/views/dashboard"
17
+ it 'should render actions for my items' do
18
+ allow(controller).to receive(:controller_name).and_return('my')
19
+ controller.prepend_view_path "app/views/my"
20
20
  html = render partial: 'batch_edits/check_all'
21
21
  html.should have_selector("li[data-behavior='batch-edit-select-none']")
22
22
  html.should have_selector("li[data-behavior='batch-edit-select-page']")
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'catalog/_sort_and_per_page.html.erb' do
4
+ before do
5
+ allow(controller).to receive(:current_user).and_return(stub_model(User))
6
+ allow_any_instance_of(Ability).to receive(:can?).and_return(true)
7
+ @resp = ["a","b","c"]
8
+ assign(:response, @resp )
9
+ allow(@resp).to receive(:total_count).and_return(20)
10
+ allow(@resp).to receive(:limit_value).and_return(3)
11
+ allow(@resp).to receive(:rows).and_return(3)
12
+ allow(@resp).to receive(:offset_value).and_return(3)
13
+ allow(@resp).to receive(:current_page).and_return(2)
14
+ allow(@resp).to receive(:total_pages).and_return(7)
15
+ allow(view).to receive(:blacklight_config).and_return(CatalogController.blacklight_config)
16
+ end
17
+
18
+
19
+
20
+ it 'appears on page without error' do
21
+ render
22
+ page = Capybara::Node::Simple.new(rendered)
23
+ expect(page).to have_selector('span.page_entries', count: 1)
24
+ expect(rendered).to include("<strong>4</strong> - <strong>6</strong> of <strong>20</strong>")
25
+ end
26
+
27
+ end
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+
3
+ describe "dashboard/index.html.erb" do
4
+
5
+ before do
6
+ @user = mock_model(User, name: "Charles Francis Xavier", user_key: "charles")
7
+ allow(@user).to receive(:title).and_return("Professor, Head")
8
+ allow(@user).to receive(:department).and_return("Xavier’s School for Gifted Youngsters")
9
+ allow(@user).to receive(:telephone).and_return("814.865.8399")
10
+ allow(@user).to receive(:email).and_return("chuck@xsgy.edu")
11
+ allow(@user).to receive(:all_following).and_return(["magneto"])
12
+ allow(@user).to receive(:followers).and_return(["wolverine","storm"])
13
+ allow(controller).to receive(:current_user).and_return(@user)
14
+ assign(:activity, [])
15
+ assign(:notifications, [])
16
+ end
17
+
18
+ describe "heading" do
19
+
20
+ before do
21
+ render
22
+ @heading = view.content_for(:heading)
23
+ end
24
+
25
+ it "should display welcome message and links" do
26
+ expect(@heading).to have_link("Upload", sufia.new_generic_file_path)
27
+ expect(@heading).to have_link("Create Collection", collections.new_collection_path)
28
+ expect(@heading).to have_link("View Files", sufia.dashboard_files_path)
29
+ expect(@heading).to include "My Dashboard"
30
+ expect(@heading).to include "Hello, Charles Francis Xavier"
31
+ end
32
+
33
+ end
34
+
35
+ describe "sidebar" do
36
+
37
+ before do
38
+ render
39
+ @sidebar = view.content_for(:sidebar)
40
+ end
41
+
42
+ it "should display information about the user" do
43
+ expect(@sidebar).to include "Charles Francis Xavier"
44
+ expect(@sidebar).to include "Professor, Head"
45
+ expect(@sidebar).to include "Xavier’s School for Gifted Youngsters"
46
+ expect(@sidebar).to include "814.865.8399"
47
+ expect(@sidebar).to include "chuck@xsgy.edu"
48
+ end
49
+
50
+ it "should have links to view and edit the user's profile" do
51
+ expect(@sidebar).to include '<a class="btn btn-info" href="' + sufia.profile_path(@user) + '">View Profile</a>'
52
+ expect(@sidebar).to include '<a class="btn btn-info" href="' + sufia.edit_profile_path(@user) + '">Edit Profile</a>'
53
+ end
54
+
55
+ it "should display user statistics" do
56
+ expect(@sidebar).to include "Your Statistics"
57
+ expect(@sidebar).to include '<span class="label label-default">1</span>'
58
+ expect(@sidebar).to include '<span class="label label-default">2</span>'
59
+ expect(@sidebar).to include '<span class="label label-default">0</span>'
60
+ end
61
+
62
+ end
63
+
64
+ describe "main" do
65
+
66
+ context "with activities and notifications" do
67
+
68
+ before do
69
+ @now = DateTime.now.to_i
70
+ assign(:activity, [
71
+ { action: 'so and so edited their profile', timestamp: @now },
72
+ { action: 'so and so uploaded a file', timestamp: (@now - 360 ) }
73
+ ])
74
+ assign(:notifications, FactoryGirl.create(:user_with_mail).mailbox.inbox)
75
+ end
76
+
77
+ it "should include recent activities and notifications" do
78
+ render
79
+ expect(rendered).to include "so and so edited their profile"
80
+ expect(rendered).to include "6 minutes ago"
81
+ expect(rendered).to include "You've got mail"
82
+ expect(rendered).to include "Sample notification"
83
+ end
84
+
85
+ end
86
+
87
+ context "without activities and notifications" do
88
+
89
+ it "should include headings for activities and notifications" do
90
+ render
91
+ expect(rendered).to include "User Activity"
92
+ expect(rendered).to include "User Notifications"
93
+ end
94
+
95
+ it "should show no activities or notifications" do
96
+ render
97
+ expect(rendered).to include "User has no notifications"
98
+ expect(rendered).to include "User has no recent activity"
99
+ end
100
+
101
+ end
102
+
103
+ end
104
+
105
+ end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'dashboard/_facet_limit.html.erb' do
3
+ describe 'my/_facet_limit.html.erb' do
4
4
 
5
5
  it "should draw facet links" do
6
6
  allow(view).to receive(:display_facet).and_return(double(items: [double(value: 'Audio', hits: 3), double(value: 'Video', hits:2)]))
7
7
  allow(view).to receive(:solr_field).and_return('desc_metadata__resource_type_sim')
8
8
  allow(view).to receive(:facet_limit_for).and_return(5)
9
- allow(view).to receive(:blacklight_config).and_return(DashboardController.blacklight_config)
9
+ allow(view).to receive(:blacklight_config).and_return(MyController.blacklight_config)
10
10
  allow(view).to receive(:search_action_path).and_return('/search')
11
11
  allow(view).to receive(:params).and_return({controller: 'dashboard'})
12
12
  render
@@ -39,19 +39,39 @@ module Sufia::GenericFile
39
39
  def revert_content(revision_id, datastream_id)
40
40
  revision = generic_file.content.get_version(revision_id)
41
41
  generic_file.add_file(revision.content, datastream_id, revision.label)
42
- save_characterize_and_record_committer
42
+ save_characterize_and_record_committer do
43
+ if Sufia.config.respond_to?(:after_revert_content)
44
+ Sufia.config.after_revert_content.call(generic_file, user, revision_id)
45
+ end
46
+ end
43
47
  end
44
48
 
45
49
  def update_content(file, datastream_id)
46
50
  generic_file.add_file(file, datastream_id, file.original_filename)
47
- save_characterize_and_record_committer
51
+ save_characterize_and_record_committer do
52
+ if Sufia.config.respond_to?(:after_update_content)
53
+ Sufia.config.after_update_content.call(generic_file, user)
54
+ end
55
+ end
48
56
  end
49
57
 
50
58
  def update_metadata(attributes, visibility)
51
59
  generic_file.attributes = generic_file.sanitize_attributes(attributes)
52
60
  generic_file.visibility = visibility
53
61
  generic_file.date_modified = DateTime.now
54
- save_and_record_committer
62
+ save_and_record_committer do
63
+ if Sufia.config.respond_to?(:after_update_metadata)
64
+ Sufia.config.after_update_metadata.call(generic_file, user)
65
+ end
66
+ end
67
+ end
68
+
69
+ def destroy
70
+ pid = generic_file.pid #Work around for https://github.com/projecthydra/active_fedora/issues/422
71
+ generic_file.destroy
72
+ if Sufia.config.respond_to?(:after_destroy)
73
+ Sufia.config.after_destroy.call(pid, user)
74
+ end
55
75
  end
56
76
 
57
77
  # Takes an optional block and executes the block if the save was successful.
@@ -97,11 +97,6 @@ module Sufia
97
97
  end
98
98
  end
99
99
 
100
- # Redefine this for more intuitive keys in Redis
101
- def to_param
102
- noid
103
- end
104
-
105
100
  def label=(new_label)
106
101
  @inner_object.label = new_label
107
102
  if self.title.empty?
@@ -9,14 +9,21 @@ module Sufia
9
9
  has_file_datastream "content", type: FileContentDatastream
10
10
  has_file_datastream "thumbnail"
11
11
 
12
-
13
12
  has_attributes :relative_path, :depositor, :import_url, datastream: :properties, multiple: false
14
- has_attributes :date_uploaded, :date_modified, datastream: :descMetadata, multiple: false
13
+ has_attributes :date_uploaded, :date_modified, datastream: :descMetadata, multiple: false
15
14
  has_attributes :related_url, :based_near, :part_of, :creator,
16
15
  :contributor, :title, :tag, :description, :rights,
17
16
  :publisher, :date_created, :subject,
18
17
  :resource_type, :identifier, :language, datastream: :descMetadata, multiple: true
19
18
  end
19
+
20
+ # Add a schema.org itemtype
21
+ def itemtype
22
+ # Look up the first non-empty resource type value in a hash from the config
23
+ Sufia.config.resource_types_to_schema[resource_type.to_a.reject { |type| type.empty? }.first] || 'http://schema.org/CreativeWork'
24
+ rescue
25
+ 'http://schema.org/CreativeWork'
26
+ end
20
27
  end
21
28
  end
22
29
  end
@@ -16,7 +16,7 @@ module Sufia
16
16
  # override this method if you need to initialize more complex RDF assertions (b-nodes)
17
17
  def initialize_fields
18
18
  terms_for_editing.each do |key|
19
- # if value is empty, we create an one element array to loop over for output
19
+ # if value is empty, we create an one element array to loop over for output
20
20
  self[key] = [''] if self[key].empty?
21
21
  end
22
22
  end
@@ -34,7 +34,7 @@ module Sufia
34
34
  module ClassMethods
35
35
  def terms_for_display
36
36
  [:resource_type, :title, :creator, :contributor, :description, :tag, :rights, :publisher, :date_created,
37
- :date_uploaded, :date_modified, :subject, :language, :identifier, :based_near, :related_url]
37
+ :subject, :language, :identifier, :based_near, :related_url]
38
38
  end
39
39
  end
40
40
 
@@ -4,7 +4,7 @@ class GenericFileRdfDatastream < ActiveFedora::NtriplesRDFDatastream
4
4
  index.as :stored_searchable, :facetable
5
5
  end
6
6
  property :title, predicate: RDF::DC.title do |index|
7
- index.as :stored_searchable
7
+ index.as :stored_searchable, :facetable
8
8
  end
9
9
  property :creator, predicate: RDF::DC.creator do |index|
10
10
  index.as :stored_searchable, :facetable
@@ -1,28 +1,33 @@
1
1
  module Sufia
2
2
  module Noid
3
- def Noid.noidify(identifier)
4
- String(identifier).split(":").last
5
- end
6
-
7
- def Noid.namespaceize(identifier)
8
- if identifier.start_with?(Noid.namespace)
9
- identifier
10
- else
11
- "#{Noid.namespace}:#{identifier}"
12
- end
13
- end
14
3
 
15
4
  def noid
16
5
  Noid.noidify(self.pid)
17
6
  end
18
7
 
19
- def normalize_identifier
20
- params[:id] = Noid.namespaceize(params[:id])
8
+ # Redefine this for more intuitive keys in Redis
9
+ def to_param
10
+ noid
21
11
  end
22
12
 
23
- protected
24
- def Noid.namespace
25
- Sufia.config.id_namespace
13
+ class << self
14
+ def noidify(identifier)
15
+ String(identifier).split(":").last
16
+ end
17
+
18
+ def namespaceize(identifier)
19
+ if identifier.start_with?(namespace)
20
+ identifier
21
+ else
22
+ "#{namespace}:#{identifier}"
23
+ end
24
+ end
25
+
26
+ protected
27
+
28
+ def namespace
29
+ Sufia.config.id_namespace
30
+ end
26
31
  end
27
32
  end
28
33
  end