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
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Dashboard::SharesController do
3
+ describe My::SharesController do
4
4
  describe "logged in user" do
5
5
  before (:each) do
6
6
  @user = FactoryGirl.find_or_create(:archivist)
@@ -29,11 +29,6 @@ describe Dashboard::SharesController do
29
29
  it "should respond with success" do
30
30
  get :index
31
31
  expect(response).to be_successful
32
- expect(response).to render_template('dashboard/lists/index')
33
- end
34
-
35
- it "sets the controller name" do
36
- expect(controller.controller_name).to eq :dashboard
37
32
  end
38
33
 
39
34
  it "should paginate" do
@@ -66,13 +61,4 @@ describe Dashboard::SharesController do
66
61
  end
67
62
  end
68
63
 
69
- describe "not logged in as a user" do
70
- describe "#index" do
71
- it "should return an error" do
72
- get :index
73
- expect(response).to be_redirect
74
- end
75
- end
76
- end
77
64
  end
78
-
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe MyController do
4
+
5
+ it "sets the controller name" do
6
+ expect(controller.controller_name).to eq :my
7
+ end
8
+
9
+ end
@@ -1,42 +1,88 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Browse Dashboard files" do
3
+ describe "Browse Dashboard" do
4
4
 
5
5
  before do
6
6
  @fixtures = find_or_create_file_fixtures
7
7
  sign_in FactoryGirl.create :user_with_fixtures
8
8
  end
9
9
 
10
- it "should show me some files (from the fixtures)" do
11
- click_link "dashboard"
12
- click_link "Files"
13
- page.should have_content "Edit File"
14
- page.should have_content "Download File"
15
- fill_in "dashboard_search", with: "PDF"
16
- click_button "dashboard_submit"
10
+ it "should search your files by deafult" do
11
+ visit "/dashboard"
12
+ fill_in "q", with: "PDF"
13
+ click_button "search-submit-header"
17
14
  page.should have_content "Fake Document Title"
18
15
  end
19
16
 
20
- it "should allow you to browse facets" do
21
- pending "need to fix the 'more' link on facets with more than 5 items"
22
- # TODO: fix more facets link!
23
- click_link "dashboard"
24
- click_link "Files"
25
- click_link "more Subjects"
26
- click_link "consectetur"
27
- within("#document_#{@fixtures[1].noid}") do
28
- click_link "Test Document MP3.mp3"
29
- end
30
- page.should have_content "File Details"
17
+ context "within my files page" do
18
+
19
+ before do
20
+ visit "dashboard/files"
21
+ end
22
+
23
+ it "should show me some files" do
24
+ page.should have_content "Edit File"
25
+ page.should have_content "Download File"
26
+ end
27
+
28
+ it "should allow you to search your own files" do
29
+ fill_in "q", with: "PDF"
30
+ click_button "search-submit-header"
31
+ page.should have_content "Fake Document Title"
32
+ end
33
+
34
+ it "should allow you to browse facets" do
35
+ pending "Issue #428 is causing this"
36
+ click_link "more Subjects"
37
+ click_link "consectetur"
38
+ save_and_open_page
39
+ within("#document_#{@fixtures[1].noid}") do
40
+ click_link "Test Document MP3.mp3"
41
+ end
42
+ page.should have_content "File Details"
43
+ end
44
+
45
+ it "should allow me to edit files (from the fixtures)" do
46
+ fill_in "q", with: "Wav"
47
+ click_button "search-submit-header"
48
+ click_button "Select an action"
49
+ click_link "Edit File"
50
+ page.should have_content "Edit Fake Wav File.wav"
51
+ end
52
+
31
53
  end
32
54
 
33
- it "should allow me to edit files (from the fixtures)" do
34
- click_link "dashboard"
35
- click_link "Files"
36
- fill_in "dashboard_search", with: "Wav"
37
- click_button "dashboard_submit"
38
- click_link "Edit File"
39
- page.should have_content "Edit Fake Wav File.wav"
55
+ context "within my collections page" do
56
+ before do
57
+ visit "dashboard/collections"
58
+ end
59
+ it "should search within my collections" do
60
+ within(".input-group-btn") do
61
+ page.should have_content("My Collections")
62
+ end
63
+ end
64
+ end
65
+
66
+ context "within my highlights page" do
67
+ before do
68
+ visit "dashboard/highlights"
69
+ end
70
+ it "should search within my highlights" do
71
+ within(".input-group-btn") do
72
+ page.should have_content("My Highlights")
73
+ end
74
+ end
75
+ end
76
+
77
+ context "within my shares page" do
78
+ before do
79
+ visit "dashboard/shares"
80
+ end
81
+ it "should search within my shares" do
82
+ within(".input-group-btn") do
83
+ page.should have_content("My Shares")
84
+ end
85
+ end
40
86
  end
41
87
 
42
88
  end
@@ -17,7 +17,7 @@ describe 'collection' do
17
17
  let(:title2) {"Test Collection 2"}
18
18
  let(:description2) {"Description for collection 2 we are testing."}
19
19
 
20
- let(:user) { FactoryGirl.create(:user, email: 'user1@example.com') }
20
+ let(:user) { FactoryGirl.find_or_create(:archivist) }
21
21
  let(:user_key) { user.user_key }
22
22
 
23
23
  before(:all) do
@@ -28,7 +28,7 @@ describe 'collection' do
28
28
  (0..12).each do |x|
29
29
  @gfs[x] = GenericFile.new.tap do |f|
30
30
  f.title = "title #{x}"
31
- f.apply_depositor_metadata('user1@example.com')
31
+ f.apply_depositor_metadata('archivist1@example.com')
32
32
  f.save!
33
33
  end
34
34
  end
@@ -43,7 +43,6 @@ describe 'collection' do
43
43
  Collection.destroy_all
44
44
  end
45
45
 
46
-
47
46
  describe 'create collection' do
48
47
  before do
49
48
  sign_in user
@@ -79,7 +78,6 @@ describe 'collection' do
79
78
  first(".itemtrash").click
80
79
  end
81
80
  page.should_not have_content(@collection.title)
82
- page.should have_content("Dashboard")
83
81
  end
84
82
  end
85
83
 
@@ -1,41 +1,35 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Display Dashboard files" do
3
+ describe "Display User Dashboard" do
4
4
 
5
5
  before do
6
6
  sign_in :user_with_fixtures
7
+ visit "/dashboard"
7
8
  end
8
9
 
9
- it "should display the dashboard and have search" do
10
- click_link 'dashboard'
11
- click_link 'Files'
12
- fill_in "dashboard_search", with: "dash search"
13
- click_button "dashboard_submit"
14
- page.should have_content "Dashboard"
15
- page.should have_content "You searched for: dash search"
16
- find_field("search-field-header").value.should be_nil
10
+ it "should show the user's information" do
11
+ page.should have_content "My Dashboard"
12
+ page.should have_content "User Activity"
13
+ page.should have_content "User Notifications"
14
+ page.should have_content "Your Statistics"
17
15
  end
18
16
 
19
- it "should display the dashboard and want to upload files" do
20
- click_link 'dashboard'
21
- click_link 'Upload File(s)'
17
+ it "should let the user upload files" do
18
+ click_link "Upload"
22
19
  page.should have_content "Upload"
23
20
  end
24
21
 
25
- it "should display the dashboard and want to search the whole system" do
26
- fill_in "search-field-header", with: "system search"
27
- click_button "search-submit-header"
28
- page.should have_content "You searched for: system search"
29
- page.should_not have_content "Dashboard"
30
- find_field("search-field-header").value.should match(/system search/)
22
+ it "should let the user create collections" do
23
+ click_link "Create Collection"
24
+ page.should have_content "Create New Collection"
25
+ end
26
+
27
+ it "should let the user view files" do
28
+ click_link "View Files"
29
+ page.should have_content "Files"
30
+ page.should have_content "Collections"
31
+ page.should have_content "Highlighted"
32
+ page.should have_content "Shared with Me"
31
33
  end
32
34
 
33
- # @culerity
34
- # Scenario: I have files on my dashboard I should see icons
35
- # #Given I load sufia fixtures
36
- # And I am logged in as "archivist1@example.com"
37
- # And I follow "dashboard"
38
- # Then I should see "Test Document Text"
39
- # When I follow the link within "a[href='/files/test3'].itemtrash"
40
- # Then I should see "The file has been deleted"
41
35
  end
@@ -3,20 +3,32 @@ require 'spec_helper'
3
3
  describe 'searching' do
4
4
  before { GenericFile.destroy_all }
5
5
  let!(:file) { FactoryGirl.create(:public_file, title: "Toothbrush") }
6
- it "should find the file and have a gallery" do
7
- visit '/'
8
- fill_in "search-field-header", with: "Toothbrush"
9
- click_button "search-submit-header"
10
- expect(page).to have_content "1 entry found"
11
- within "#search-results" do
12
- expect(page).to have_content "Toothbrush"
6
+
7
+ context "as a public user" do
8
+ it "should find the file and have a gallery" do
9
+ visit '/'
10
+ fill_in "search-field-header", with: "Toothbrush"
11
+ click_button "search-submit-header"
12
+ expect(page).to have_content "1 entry found"
13
+ within "#search-results" do
14
+ expect(page).to have_content "Toothbrush"
15
+ end
16
+
17
+ click_link "Gallery"
18
+ expect(page).to have_content "You searched for: Toothbrush"
19
+ within "#documents" do
20
+ expect(page).to have_content "Toothbrush"
21
+ end
13
22
  end
14
-
15
- click_link "Gallery"
16
- expect(page).to have_content "You searched for: Toothbrush"
17
- within "#documents" do
18
- expect(page).to have_content "Toothbrush"
23
+
24
+ it "should not display search options for dashboard files" do
25
+ visit "/"
26
+ within(".input-group-btn") do
27
+ expect(page).to_not have_content("My Files")
28
+ expect(page).to_not have_content("My Collections")
29
+ expect(page).to_not have_content("My Shares")
30
+ end
19
31
  end
32
+
20
33
  end
21
34
  end
22
-
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe DashboardHelper do
4
+
5
+ describe "#render_recent_activity" do
6
+ context "when there is no activity" do
7
+ it "should return a messages stating the user has no recent activity" do
8
+ assign(:activity, [])
9
+ expect(helper.render_recent_activity).to include("no recent activity")
10
+ end
11
+ end
12
+ end
13
+
14
+ describe "#render_recent_notifications" do
15
+ context "when there are no notifications" do
16
+ it "should return a messages stating the user has no recent notifications" do
17
+ assign(:notifications, [])
18
+ expect(helper.render_recent_notifications).to include("no notifications")
19
+ end
20
+ end
21
+ end
22
+
23
+ describe "#on_the_dashboard?" do
24
+ it "should return false for controllers that aren't a part of the dashboard" do
25
+ allow(helper).to receive(:params).and_return({ controller: "foo" })
26
+ expect(helper.on_the_dashboard?).to be_false
27
+ end
28
+
29
+ it "should return true for controllers that are part of the dashboard" do
30
+ allow(helper).to receive(:params).and_return({ controller: "my/files" })
31
+ expect(helper.on_the_dashboard?).to be_true
32
+ allow(helper).to receive(:params).and_return({ controller: "my/collections" })
33
+ expect(helper.on_the_dashboard?).to be_true
34
+ allow(helper).to receive(:params).and_return({ controller: "my/highlights" })
35
+ expect(helper.on_the_dashboard?).to be_true
36
+ allow(helper).to receive(:params).and_return({ controller: "my/shares" })
37
+ expect(helper.on_the_dashboard?).to be_true
38
+ end
39
+ end
40
+
41
+ end
@@ -3,7 +3,9 @@ require 'spec_helper'
3
3
  describe SufiaHelper do
4
4
 
5
5
  describe "#link_to_facet_list" do
6
- before { helper.stub(blacklight_config: CatalogController.blacklight_config) }
6
+ before do
7
+ allow(helper).to receive(:blacklight_config).and_return(CatalogController.blacklight_config)
8
+ end
7
9
 
8
10
  context "with values" do
9
11
  subject { helper.link_to_facet_list(['car', 'truck'], 'vehicle_type') }
@@ -28,12 +30,12 @@ describe SufiaHelper do
28
30
  describe "has_collection_search_parameters?" do
29
31
  subject { helper }
30
32
  context "when cq is set" do
31
- before { helper.stub(params: { cq: 'foo'}) }
33
+ before { allow(helper).to receive(:params).and_return({ cq: 'foo'}) }
32
34
  it { should have_collection_search_parameters }
33
35
  end
34
36
 
35
37
  context "when cq is not set" do
36
- before { helper.stub(params: { cq: ''}) }
38
+ before { allow(helper).to receive(:params).and_return({ cq: ''}) }
37
39
  it { should_not have_collection_search_parameters }
38
40
  end
39
41
  end
@@ -62,4 +64,103 @@ describe SufiaHelper do
62
64
  end
63
65
  end
64
66
  end
67
+
68
+ describe "#link_to_telephone" do
69
+
70
+ before do
71
+ @user = mock_model(User)
72
+ allow(@user).to receive(:telephone).and_return('867-5309')
73
+ end
74
+
75
+ context "when @user is set" do
76
+ it "should return a link to the user's telephone" do
77
+ expect(helper.link_to_telephone).to eq("<a href=\"wtai://wp/mc;867-5309\">867-5309</a>")
78
+ end
79
+ end
80
+
81
+ context "when @user is not set" do
82
+ it "should return a link to the user's telephone" do
83
+ expect(helper.link_to_telephone(@user)).to eq("<a href=\"wtai://wp/mc;867-5309\">867-5309</a>")
84
+ end
85
+ end
86
+
87
+ end
88
+
89
+ describe "#current_search_parameters" do
90
+
91
+ context "when the user is not in the dashboard" do
92
+ it "should be whatever q is" do
93
+ allow(helper).to receive(:params).and_return({ controller: "catalog", q: "foo" })
94
+ expect(helper.current_search_parameters).to eq("foo")
95
+ end
96
+ end
97
+
98
+ context "when the user is on any dashboard page" do
99
+
100
+ it "should be ignored on dashboard" do
101
+ allow(helper).to receive(:params).and_return({ controller: "dashboard", q: "foo" })
102
+ expect(helper.current_search_parameters).to be_nil
103
+ end
104
+
105
+ it "should be ignored on dashboard files, collections, highlights and shares" do
106
+ allow(helper).to receive(:params).and_return({ controller: "my/files", q: "foo" })
107
+ expect(helper.current_search_parameters).to be_nil
108
+ allow(helper).to receive(:params).and_return({ controller: "my/collections", q: "foo" })
109
+ expect(helper.current_search_parameters).to be_nil
110
+ allow(helper).to receive(:params).and_return({ controller: "my/highlights", q: "foo" })
111
+ expect(helper.current_search_parameters).to be_nil
112
+ allow(helper).to receive(:params).and_return({ controller: "my/shares", q: "foo" })
113
+ expect(helper.current_search_parameters).to be_nil
114
+ end
115
+
116
+ end
117
+
118
+ end
119
+
120
+ describe "#search_form_action" do
121
+
122
+ context "when the user is not in the dashboard" do
123
+ it "should return the catalog index path" do
124
+ allow(helper).to receive(:params).and_return({ controller: "foo" })
125
+ expect(helper.search_form_action).to eq(catalog_index_path)
126
+ end
127
+ end
128
+
129
+ context "when the user is on the dashboard page" do
130
+ it "should default to My Files" do
131
+ allow(helper).to receive(:params).and_return({ controller: "dashboard" })
132
+ expect(helper.search_form_action).to eq(sufia.dashboard_files_path)
133
+ end
134
+ end
135
+
136
+ context "when the user is on the my files page" do
137
+ it "should return the my dashboard files path" do
138
+ allow(helper).to receive(:params).and_return({ controller: "my/files" })
139
+ expect(helper.search_form_action).to eq(sufia.dashboard_files_path)
140
+ end
141
+ end
142
+
143
+ context "when the user is on the my collections page" do
144
+ it "should return the my dashboard collections path" do
145
+ allow(helper).to receive(:params).and_return({ controller: "my/collections" })
146
+ expect(helper.search_form_action).to eq(sufia.dashboard_collections_path)
147
+ end
148
+ end
149
+
150
+ context "when the user is on the my highlights page" do
151
+ it "should return the my dashboard highlights path" do
152
+ allow(helper).to receive(:params).and_return({ controller: "my/highlights" })
153
+ expect(helper.search_form_action).to eq(sufia.dashboard_highlights_path)
154
+ end
155
+ end
156
+
157
+ context "when the user is on the my shares page" do
158
+ it "should return the my dashboard shares path" do
159
+ allow(helper).to receive(:params).and_return({ controller: "my/shares" })
160
+ expect(helper.search_form_action).to eq(sufia.dashboard_shares_path)
161
+ end
162
+ end
163
+
164
+ end
165
+
65
166
  end