blacklight 4.3.0 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +0 -6
  4. data/Gemfile +5 -0
  5. data/README.md +1 -1
  6. data/Rakefile +0 -1
  7. data/VERSION +1 -1
  8. data/app/assets/javascripts/blacklight/autofocus.js +16 -0
  9. data/app/assets/javascripts/blacklight/blacklight.js +1 -0
  10. data/app/assets/javascripts/blacklight/bookmark_toggle.js +2 -5
  11. data/app/assets/javascripts/blacklight/checkbox_submit.js +3 -6
  12. data/app/assets/javascripts/blacklight/core.js +24 -1
  13. data/app/assets/javascripts/blacklight/css_dropdowns.js +2 -2
  14. data/app/assets/javascripts/blacklight/facet_expand_contract.js +4 -3
  15. data/app/assets/javascripts/blacklight/lightbox_dialog.js +7 -1
  16. data/app/assets/javascripts/blacklight/search_context.js +1 -1
  17. data/app/assets/javascripts/blacklight/select_submit.js +1 -1
  18. data/app/assets/javascripts/blacklight/zebra_stripe.js +1 -1
  19. data/app/assets/stylesheets/blacklight/_blacklight_base.css.scss +1 -0
  20. data/app/assets/stylesheets/blacklight/_catalog.css.scss +5 -0
  21. data/app/assets/stylesheets/blacklight/_facets.css.scss +6 -0
  22. data/app/assets/stylesheets/blacklight/_group.css.scss +14 -0
  23. data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +1 -0
  24. data/app/controllers/bookmarks_controller.rb +2 -2
  25. data/app/helpers/blacklight/blacklight_helper_behavior.rb +41 -24
  26. data/app/helpers/blacklight/catalog_helper_behavior.rb +48 -28
  27. data/app/helpers/blacklight/facets_helper_behavior.rb +9 -75
  28. data/app/models/record_mailer.rb +1 -16
  29. data/app/views/bookmarks/index.html.erb +2 -0
  30. data/app/views/catalog/_bookmark_control.html.erb +3 -4
  31. data/app/views/catalog/_document.html.erb +2 -1
  32. data/app/views/catalog/_document_header.html.erb +6 -3
  33. data/app/views/catalog/_email_form.html.erb +0 -7
  34. data/app/views/catalog/_facet_layout.html.erb +1 -1
  35. data/app/views/catalog/_group_default.html.erb +12 -0
  36. data/app/views/catalog/_index_default.html.erb +1 -1
  37. data/app/views/catalog/_opensearch_response_metadata.html.erb +2 -3
  38. data/app/views/catalog/_paginate_compact.html.erb +2 -2
  39. data/app/views/catalog/_results_pagination.html.erb +2 -2
  40. data/app/views/catalog/_search_form.html.erb +1 -1
  41. data/app/views/catalog/_sms_form.html.erb +1 -21
  42. data/app/views/catalog/_thumbnail_default.html.erb +5 -0
  43. data/app/views/catalog/email_sent.html.erb +9 -0
  44. data/app/views/catalog/index.atom.builder +7 -8
  45. data/app/views/catalog/index.html.erb +6 -3
  46. data/app/views/catalog/librarian_view.html.erb +1 -1
  47. data/app/views/catalog/sms_sent.html.erb +9 -0
  48. data/app/views/feedback/complete.html.erb +2 -0
  49. data/app/views/feedback/show.html.erb +7 -5
  50. data/app/views/kaminari/blacklight_compact/_paginator.html.erb +1 -1
  51. data/app/views/layouts/blacklight.html.erb +1 -2
  52. data/app/views/saved_searches/index.html.erb +2 -0
  53. data/app/views/search_history/index.html.erb +1 -1
  54. data/blacklight.gemspec +1 -1
  55. data/config/locales/blacklight.en.yml +11 -0
  56. data/config/locales/blacklight.fr.yml +15 -1
  57. data/gemfiles/rails3.gemfile +7 -0
  58. data/gemfiles/rails4.gemfile +7 -0
  59. data/lib/blacklight.rb +1 -0
  60. data/lib/blacklight/catalog.rb +101 -56
  61. data/lib/blacklight/configuration.rb +1 -1
  62. data/lib/blacklight/controller.rb +7 -4
  63. data/lib/blacklight/facet.rb +79 -0
  64. data/lib/blacklight/routes.rb +0 -1
  65. data/lib/blacklight/solr/document.rb +4 -0
  66. data/lib/blacklight/solr/document/marc_export.rb +1 -1
  67. data/lib/blacklight/solr_helper.rb +39 -8
  68. data/lib/blacklight/solr_response.rb +35 -3
  69. data/lib/blacklight/solr_response/facets.rb +4 -0
  70. data/lib/blacklight/solr_response/group.rb +33 -0
  71. data/lib/blacklight/solr_response/group_response.rb +49 -0
  72. data/lib/blacklight/solr_response/pagination_methods.rb +27 -0
  73. data/lib/blacklight/user.rb +30 -32
  74. data/lib/generators/blacklight/assets_generator.rb +3 -1
  75. data/lib/generators/blacklight/blacklight_generator.rb +28 -125
  76. data/lib/generators/blacklight/marc_generator.rb +66 -0
  77. data/lib/generators/blacklight/models_generator.rb +113 -0
  78. data/lib/generators/blacklight/templates/alternate_controller.rb +9 -0
  79. data/lib/generators/blacklight/templates/config/solr.yml +0 -2
  80. data/lib/generators/blacklight/templates/solr_document.rb +1 -13
  81. data/lib/railties/all_tests.rake +5 -8
  82. data/spec/controllers/catalog_controller_spec.rb +185 -113
  83. data/spec/features/alternate_controller_spec.rb +34 -0
  84. data/spec/features/bookmarks_spec.rb +58 -0
  85. data/spec/features/did_you_mean_spec.rb +135 -0
  86. data/spec/features/librarian_view_spec.rb +13 -0
  87. data/spec/features/record_view_spec.rb +37 -0
  88. data/spec/features/saved_searches_spec.rb +47 -0
  89. data/spec/features/search_filters_spec.rb +137 -0
  90. data/spec/features/search_history_spec.rb +75 -0
  91. data/spec/features/search_pagination_spec.rb +91 -0
  92. data/spec/features/search_results_spec.rb +68 -0
  93. data/spec/features/search_sort_spec.rb +20 -0
  94. data/spec/features/search_spec.rb +108 -0
  95. data/spec/helpers/blacklight_helper_spec.rb +45 -2
  96. data/spec/helpers/catalog_helper_spec.rb +134 -1
  97. data/spec/helpers/facets_helper_spec.rb +8 -0
  98. data/spec/lib/blacklight/solr_response/group_response_spec.rb +78 -0
  99. data/spec/lib/blacklight/solr_response/group_spec.rb +70 -0
  100. data/spec/lib/blacklight_solr_response_spec.rb +11 -5
  101. data/spec/lib/blacklight_user_spec.rb +22 -41
  102. data/spec/lib/solr_helper_spec.rb +73 -1
  103. data/spec/models/record_mailer_spec.rb +3 -3
  104. data/spec/models/{solr_docment_spec.rb → solr_document_spec.rb} +1 -1
  105. data/spec/spec_helper.rb +0 -1
  106. data/spec/support/features.rb +7 -0
  107. data/spec/support/features/session_helpers.rb +22 -0
  108. data/spec/test_app_templates/Gemfile.extra +0 -4
  109. data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -6
  110. data/spec/test_app_templates/lib/tasks/blacklight_test_app.rake +1 -9
  111. data/spec/views/catalog/_facets.html.erb_spec.rb +2 -1
  112. data/tasks/blacklight.rake +0 -10
  113. metadata +49 -58
  114. data/features/bookmarks.feature +0 -68
  115. data/features/did_you_mean.feature +0 -123
  116. data/features/librarian_view.feature +0 -18
  117. data/features/record_view.feature +0 -40
  118. data/features/saved_searches.feature +0 -49
  119. data/features/search.feature +0 -83
  120. data/features/search_filters.feature +0 -119
  121. data/features/search_history.feature +0 -85
  122. data/features/search_pagination.feature +0 -53
  123. data/features/search_results.feature +0 -61
  124. data/features/search_sort.feature +0 -27
  125. data/features/step_definitions/bookmarks_steps.rb +0 -6
  126. data/features/step_definitions/error_steps.rb +0 -5
  127. data/features/step_definitions/general_steps.rb +0 -50
  128. data/features/step_definitions/record_view_steps.rb +0 -12
  129. data/features/step_definitions/saved_searches_steps.rb +0 -19
  130. data/features/step_definitions/search_facets_steps.rb +0 -29
  131. data/features/step_definitions/search_history_steps.rb +0 -9
  132. data/features/step_definitions/search_pagination_steps.rb +0 -29
  133. data/features/step_definitions/search_result_steps.rb +0 -115
  134. data/features/step_definitions/search_steps.rb +0 -118
  135. data/features/step_definitions/user_steps.rb +0 -5
  136. data/features/step_definitions/web_steps.rb +0 -217
  137. data/features/support/env.rb +0 -65
  138. data/features/support/paths.rb +0 -48
  139. data/features/support/selectors.rb +0 -40
  140. data/lib/railties/blacklight_cucumber.rake +0 -126
  141. data/lib/solrmarc.log.1 +0 -854
@@ -1,53 +0,0 @@
1
- @search_pagination
2
- Feature: Search Pagination
3
- In order to find lower ranked documents
4
- As a user
5
- I want to be able to page through search results and be able to choose how
6
- many documents to display per page
7
-
8
- Background:
9
- Given the application is configured to have per page with values "10, 20, 50"
10
-
11
- Scenario: Results Page Supports Paging
12
- Given I am on the home page
13
- When I fill in "q" with ""
14
- And I press "search"
15
- Then I should see "1 - 10 of"
16
- When I follow "Next »"
17
- Then I should see "11 - 20 of"
18
- When I follow "« Previous"
19
- Then I should see "1 - 10 of"
20
-
21
- Scenario: Results Page Has Per Page Available
22
- Given I am on the home page
23
- When I fill in "q" with ""
24
- And I press "search"
25
- Then I should see "per page"
26
- And I should see the per_page dropdown with values "10, 20, 50"
27
-
28
- Scenario: Results Page Can Display 20 Items Per Page
29
- Given I am on the home page
30
- And I fill in "q" with ""
31
- When I press "search"
32
- Then I should see "1 - 10 of"
33
- When I show 20 per page
34
- Then I should see "1 - 20 of"
35
-
36
- Scenario: Application Can Be Configured for Other Per Page Values
37
- Given the application is configured to have per page with values "15, 30"
38
- And I am on the home page
39
- When I fill in "q" with ""
40
- And I press "search"
41
- Then I should see the per_page dropdown with values "15, 30"
42
- And I should see "1 - 15 of"
43
- When I show 30 per page
44
- Then I should see "1 - 30 of"
45
-
46
- Scenario: Page Offset Resets to 1 When Changing Per Page
47
- Given I am on the home page
48
- And I fill in "q" with ""
49
- When I press "search"
50
- And I follow "Next »"
51
- Then I should see "11 - 20 of"
52
- When I show 20 per page
53
- Then I should see "1 - 20 of"
@@ -1,61 +0,0 @@
1
- @search
2
- Feature: Search Results
3
- In order to find documents
4
- As a user
5
- I want to enter terms, select fields, and select number of results per page
6
-
7
- Scenario: Empty query
8
- Given I am on the catalog page
9
- When I fill in the search box with ""
10
- And I press "search"
11
- Then I should get at least 30 results
12
- And I should get exactly 30 results
13
- And I should get at most 30 results
14
- And I should get id "2007020969" in the results
15
- And I should have more results than a search for "korea"
16
-
17
- Scenario: "inmul" query
18
- Given I am on the catalog page
19
- When I fill in the search box with "inmul"
20
- And I press "search"
21
- Then I should get exactly 1 result
22
- And I should get id "77826928" in the results
23
- And I should not get id "00282214" in the results
24
- And I should have fewer results than a search for ""
25
-
26
- Scenario: Diacritics stripping
27
- Given I am on the catalog page
28
- When I fill in the search box with "inmül"
29
- And I press "search"
30
- Then I should have the same number of results as a search for "inmul"
31
-
32
-
33
- Scenario: case-insensitive
34
- Given I am on the catalog page
35
- When I fill in the search box with "inmul"
36
- And I press "search"
37
- Then I should have the same number of results as a search for "INMUL"
38
-
39
- Scenario: Relevancy ordering
40
- Given I am on the catalog page
41
- When I fill in the search box with "Korea"
42
- And I press "search"
43
- Then I should get id "77826928" in the first 5 results
44
- And I should get id "77826928" before id "94120425"
45
- And I should get id "77826928" and id "94120425" no more than 5 positions from each other
46
-
47
- Scenario: Excluded items
48
- Given I am on the catalog page
49
- When I fill in the search box with "Korea"
50
- And I press "search"
51
- Then I should not get id "94120425" in the first 1 result
52
-
53
- Scenario: Top 5 results
54
- Given I am on the catalog page
55
- When I fill in the search box with "Korea"
56
- And I press "search"
57
- Then I should get at least 1 of these ids in the first 5 results: "77826928,94120425"
58
-
59
-
60
-
61
-
@@ -1,27 +0,0 @@
1
- @search_sort
2
- Feature: Search Sort
3
- In order to sort searches
4
- As a user
5
- I want select a sort field and have the search results reordered by that field
6
-
7
- Scenario: Sort on facet results with no search terms
8
- Given I am on the home page
9
- When I follow "English"
10
- Then I should see "Sort by"
11
- # 2009-08-25 I don't know why this isn't working ... Naomi.
12
- # And I should see select list "select#sort" with "relevance" selected
13
- When I sort by "title"
14
- Then I should see "Sort by"
15
- And I should see the sort list with "title" selected
16
-
17
- Scenario: Sort on result set from fielded search
18
- Given I am on the home page
19
- And I fill in "q" with "bod"
20
- And I select "Title" from "search_field"
21
- And I press "search"
22
- Then I should see "Sort by"
23
- When I sort by "title"
24
- Then I should see "Sort by"
25
- And I should see select list "select#search_field" with "Title" selected
26
- And I should see the sort list with "title" selected
27
-
@@ -1,6 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- Given /^"([^\"]*)" has bookmarked an item with title "([^\"]*)"$/ do |user, title|
3
- user = User.find_by_email("#{user}@#{user}.com")
4
- user.bookmarks << Bookmark.create(:title => title, :document_id => "123456")
5
- user.save!
6
- end
@@ -1,5 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- # checkout http://blog.codefront.net/2007/03/31/testing-rescue_action_in_public-with-rspec/
3
- Then /^I should see a flash error "([^\"]*)"$/ do |message|
4
- pageshould have_selector("div.notice", :text => message)
5
- end
@@ -1,50 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- When /^I follow "([^\"]*)" in "([^\"]*)"$/ do |link, scope|
3
- within(scope) do
4
- click_link(link)
5
- end
6
- end
7
-
8
- Then /^I should see a stylesheet/ do
9
- page.should have_selector("link[rel=stylesheet]")
10
- end
11
-
12
- Then /I should see "(.*)" (at least|at most|exactly) (.*) times?$/i do |target, comparator, expected_num|
13
- actual_num = page.split(target).length - 1
14
- case comparator
15
- when "at least"
16
- actual_num.should >= expected_num.to_i
17
- when "at most"
18
- actual_num.should <= expected_num.to_i
19
- when "exactly"
20
- actual_num.should == expected_num.to_i
21
- end
22
- end
23
-
24
- Then /I should see a "(.*)" element with "(.*)" = "(.*)" (at least|at most|exactly) (.*) times?$/i do |target, type, selector,comparator, expected_num|
25
- actual_num = page.all("#{target}[#{type}=\"#{selector}\"]").length
26
- case comparator
27
- when "at least"
28
- actual_num.should >= expected_num.to_i
29
- when "at most"
30
- actual_num.should <= expected_num.to_i
31
- when "exactly"
32
- actual_num.should == expected_num.to_i
33
- end
34
- end
35
-
36
- Then /^I (should not|should) see an? "([^\"]*)" element with an? "([^\"]*)" attribute of "([^\"]*)"$/ do |bool,elem,attribute,value|
37
- if bool == "should not"
38
- page.should_not have_selector("#{elem}[#{attribute}=#{value}]")
39
- else
40
- page.should have_selector("#{elem}[#{attribute}=#{value}]")
41
- end
42
- end
43
-
44
- Then /^I (should not|should) see an? "([^\"]*)" element with an? "([^\"]*)" attribute of "([^\"]*)" and an? "([^\"]*)" attribute of "([^\"]*)"$/ do |bool,elem,attribute,value,attribute2,value2|
45
- if bool == "should not"
46
- page.should_not have_selector("#{elem}[#{attribute}=#{value}][#{attribute2}=#{value2}]")
47
- else
48
- page.should have_selector("#{elem}[#{attribute}=#{value}][#{attribute2}=#{value2}]")
49
- end
50
- end
@@ -1,12 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- Then /^I (should|should not) see an? "([^\"]*)" element containing "([^\"]*)"$/ do |bool,elem,content|
3
- if bool == "should"
4
- page.should have_xpath("//#{elem}[text()='#{content}']")
5
- else
6
- page.should have_no_xpath("//#{elem}[text()='#{content}']")
7
- end
8
- end
9
-
10
- Then /^I should see link rel=alternate tags/ do
11
- page.should have_selector("link[rel=alternate]")
12
- end
@@ -1,19 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- Given /^I am logged in as "([^\"]*)"$/ do |login|
3
- email = "#{login}@#{login}.com"
4
- user = User.create(:email => email, :password => "password", :password_confirmation => "password")
5
- visit new_user_session_path
6
- fill_in("user_email", :with => email)
7
- fill_in("user_password", :with => "password")
8
- click_button("Sign in")
9
- step 'I should see "Log Out"'
10
- end
11
-
12
- Given /^"([^\"]*)" has saved a search with term "([^\"]*)"$/ do |user, term|
13
- user = User.find_by_email("#{user}@#{user}.com")
14
- user.searches << Search.create(:query_params => {:q => term})
15
- user.save!
16
- end
17
-
18
-
19
-
@@ -1,29 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- # deprecated
3
- Then /^I should see the applied filter "([^\"]*)" with the value "([^\"]*)"$/ do |filter, text|
4
- page.should have_selector(".facet_limit") do |node|
5
- node.should have_selector("h3", :text => filter)
6
- node.should have_selector("span.selected", :text => text)
7
- end
8
- end
9
-
10
- Then /^I should see the applied facet "([^\"]*)" with the value "([^\"]*)"$/ do |filter, text|
11
- page.should have_selector(".facet_limit") do |node|
12
- node.should have_selector("h3", :text => filter)
13
- node.should have_selector("span.selected", :text => text)
14
- end
15
- end
16
-
17
- Then /^I should see the facet "([^\"]*)" with the value "([^\"]*)"$/ do |filter, text|
18
- page.should have_selector(".facet_limit") do |node|
19
- node.should have_selector("h3", :text => filter)
20
- node.should have_selector("a.label", :text => text)
21
- end
22
- end
23
-
24
- Then /^the facet "([^\"]+)" should display$/ do |filter|
25
- page.should have_selector(".facet_limit") do |node|
26
- node.should have_selector("h3", :text => filter)
27
- end
28
- end
29
-
@@ -1,9 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- Given /^no previous searches$/ do
3
- # nothing to do
4
- end
5
-
6
- Given /^I have done a search with term "([^\"]*)"$/ do |term|
7
- visit catalog_index_path(:q => term)
8
- end
9
-
@@ -1,29 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- Given /^the application is configured to have per page with values "([^\"]*)"$/ do |values|
3
- values = values.split(", ")
4
- CatalogController.blacklight_config[:per_page] = []
5
- values.each do |value|
6
- CatalogController.blacklight_config[:per_page] << value
7
- end
8
- CatalogController.blacklight_config[:default_solr_params][:rows] = values[0]
9
- end
10
-
11
-
12
- Then /^I should see a selectable list with per page choices$/ do
13
- page.should have_selector("#per_page-dropdown")
14
- end
15
-
16
- Then /^I should see the per_page dropdown with values "(.*?)"$/ do |arg1|
17
- page.should have_selector('#per_page-dropdown') do
18
- labels = values.split(", ")
19
- labels.each do |label|
20
- with_tag('li', label)
21
- end
22
- end
23
- end
24
-
25
- When /^I show (\d+) per page$/ do |value|
26
- within('#per_page-dropdown .css-dropdown ul') do
27
- click_link("#{value} per page")
28
- end
29
- end
@@ -1,115 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- #include Blacklight::SolrHelper
3
-
4
- When /^I fill in the search box with "(.*?)"$/ do |query|
5
- query.gsub!(/\\"/, '"')
6
- # fill_in(:q, :with => query)
7
- find('#q').set(query)
8
- end
9
-
10
-
11
- Then /^I should get (at least|at most|exactly) (\d+) results?$/i do |comparator, comparison_num|
12
- number_of_records = get_number_of_results_from_page(page)
13
-
14
- case comparator
15
- when "at least"
16
- number_of_records.should >= comparison_num.to_i
17
- when "at most"
18
- number_of_records.should <= comparison_num.to_i
19
- when "exactly"
20
- number_of_records.should == comparison_num.to_i
21
- end
22
- end
23
-
24
-
25
- Then /^I should have (the same number of|fewer|more) results (?:than|as) a(?:n?) search for "(.*)"$/i do |comparator, query|
26
- query.gsub!(/\\"/, '"')
27
- number_of_records = get_number_of_results_from_page(page)
28
-
29
- case comparator
30
- when "the same number of"
31
- get_number_of_results_for_query(query).should == number_of_records
32
- when "fewer"
33
- get_number_of_results_for_query(query).should > number_of_records
34
- when "fewer"
35
- get_number_of_results_for_query(query).should < number_of_records
36
- end
37
- end
38
-
39
- Then /^I should get id "([^\"]+)" in the results$/i do |id|
40
- page.should have_xpath("//a[contains(@href, #{id})]")
41
- end
42
-
43
- Then /^I should not get id "([^\"]+)" in the results$/i do |id|
44
- page.should_not have_xpath("//a[contains(@href, #{id})]")
45
- end
46
-
47
- Then /^I should get id "([^\"]+)" in the first (\d+) results?$/i do |id, max_num|
48
- pos = get_position_in_result_page(page, id)
49
- pos.should_not == -1
50
- pos.should < max_num.to_i
51
- end
52
-
53
- Then /^I should not get id "([^\"]+)" in the first (\d+) results?$/i do |id, max_num|
54
- pos = get_position_in_result_page(page, id)
55
- pos.should_not == -1
56
-
57
- if pos > 0
58
- pos.should >= max_num.to_i
59
- else
60
- pos.should == -1 if pos == -1
61
- end
62
- end
63
-
64
- Then /^I should get id "([^\"]+)" before id "([^\"]+)"$/i do |id1, id2|
65
- pos1 = get_position_in_result_page(page, id1)
66
- pos2 = get_position_in_result_page(page, id2)
67
- pos1.should_not == -1
68
- pos2.should_not == -1
69
-
70
- pos1.should < pos2
71
- end
72
-
73
- Then /^I should get id "([^\"]+)" and id "([^\"]+)" no more than (\d+) positions? from each other$/i do |id1, id2, limit|
74
-
75
- pos1 = get_position_in_result_page(page, id1)
76
- pos2 = get_position_in_result_page(page, id2)
77
- pos1.should_not == -1
78
- pos2.should_not == -1
79
-
80
- (pos1 - pos2).abs.should <= limit.to_i
81
- end
82
-
83
- Then /^I should get at least (\d+) of these ids in the first (\d+) results: "([^\"]+)"$/i do |how_many, limit, id_string|
84
- id_string.split(/,/).select do |id|
85
- pos = get_position_in_result_page(page, id)
86
- pos != -1 and pos < limit.to_i
87
- end.length.should >= how_many.to_i
88
- end
89
-
90
- Then /^I (should not|should) see an? "([^\"]*)" element with an? "([^\"]*)" attribute of "([^\"]*)"$/ do |bool,elem,attribute,value|
91
- if bool == "should not"
92
- page.should_not have_selector("#{elem}[#{attribute}=#{value}]")
93
- else
94
- page.should have_selector("#{elem}[#{attribute}=#{value}]")
95
- end
96
- end
97
-
98
- def get_position_in_result_page(page, id)
99
- i = -1
100
- page.all(".index_title a").each_with_index do |link, idx|
101
- i = (idx+1) if link['href'] =~ Regexp.new(Regexp.escape(id) + "$")
102
- end
103
- i.to_i
104
- end
105
-
106
- def get_number_of_results_for_query(query)
107
- visit root_path
108
- fill_in "q", :with => query
109
- click_button "search"
110
- get_number_of_results_from_page(page)
111
- end
112
-
113
- def get_number_of_results_from_page(page)
114
- page.find("meta[name=totalResults]")['content'].to_i rescue 0
115
- end
@@ -1,118 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- # User added
3
- Then /^I should see a search field$/ do
4
- page.should have_selector("input#q")
5
- end
6
-
7
- Then /^I should see a selectable list with field choices$/ do
8
- page.should have_selector("select#search_field")
9
- end
10
-
11
- Then /^I should see the sort dropdown$/ do
12
- page.should have_selector("#sort-dropdown")
13
- end
14
-
15
- Then /^I should see the sort dropdown with values "([^\"]*)"$/ do |values|
16
- page.should have_selector('#sort-dropdown') do
17
- labels = values.split(", ")
18
- labels.each do |label|
19
- with_tag('li', label)
20
- end
21
- end
22
- end
23
-
24
- Then /^I should see the sort list with "([^\"]*)" selected$/ do |value|
25
- page.should have_selector('#sort-dropdown .css-dropdown a', :text => value)
26
- end
27
-
28
- When /^I sort by "([^\"]*)"$/ do |value|
29
- page.should have_selector('#sort-dropdown') do
30
- click_link(value)
31
- end
32
- end
33
-
34
- Then /^I should see a "([^\"]*)" button$/ do |label|
35
- page.should have_selector("button[type='submit'] .submit-search-text")
36
- end
37
-
38
- Then /^I should not see the "([^\"]*)" element$/ do |id|
39
- page.should_not have_selector("##{id}")
40
- end
41
-
42
- Then /^I should see the "([^\"]*)" element$/ do |id|
43
- page.should have_selector("##{id}")
44
- end
45
-
46
- Given /^the application is configured to have searchable fields "([^\"]*)" with values "([^\"]*)"$/ do |fields, values|
47
- labels = fields.split(", ")
48
- values = values.split(", ")
49
- combined = labels.zip(values)
50
- CatalogController.blacklight_config[:search_fields] = []
51
- combined.each do |pair|
52
- CatalogController.blacklight_config[:search_fields] << pair
53
- end
54
- end
55
-
56
- Then /^I should see select list "([^\"]*)" with field labels "([^\"]*)"$/ do |list_css, names|
57
- page.should have_selector(list_css) do
58
- labels = names.split(", ")
59
- labels.each do |label|
60
- with_tag('option', label)
61
- end
62
- end
63
- end
64
-
65
- Then /^I should see select list "([^\"]*)" with "([^\"]*)" selected$/ do |list_css, label|
66
- page.should have_selector(list_css) do |e|
67
- with_tag("[selected=selected]", {:count => 1}) do
68
- with_tag("option", {:count => 1, :text => label})
69
- end
70
- end
71
- end
72
-
73
- # Results Page
74
- Given /^the application is configured to have sort fields "([^\"]*)" with values "([^\"]*)"$/ do |fields, values|
75
- labels = fields.split(", ")
76
- values = values.split(", ")
77
- combined = labels.zip(values)
78
- CatalogController.blacklight_config[:sort_fields] = []
79
- combined.each do |pair|
80
- CatalogController.blacklight_config[:sort_fields] << pair
81
- end
82
- end
83
-
84
- Then /^I should get results$/ do
85
- page.should have_selector("div.document")
86
- end
87
-
88
- Then /^I should not get results$/ do
89
- page.should_not have_selector("div.document")
90
- end
91
-
92
- Then /^I should see the applied filter "([^\"]*)" with the value "([^\"]*)"$/ do |filter, text|
93
- page.should have_selector("div#facets div h3", :text => filter)
94
- page.should have_selector("div#facets div span.selected", :text => text)
95
- end
96
-
97
- Then /^I should see an rss discovery link/ do
98
- page.should have_selector("link[rel=alternate][type='application/rss+xml']")
99
- end
100
-
101
- Then /^I should see an atom discovery link/ do
102
- page.should have_selector("link[rel=alternate][type='application/atom+xml']")
103
- end
104
-
105
- Then /^I should see opensearch response metadata tags/ do
106
- page.should have_selector("meta[name=totalResults]")
107
- page.should have_selector("meta[name=startIndex]")
108
- page.should have_selector("meta[name=itemsPerPage]")
109
- end
110
-
111
- # Then /^I should see the applied filter "([^\"]*)" with the value
112
- # "([^\"]*)"$/ do |filter, text|
113
- # page.should have_tag("div#facets div") do |node|
114
- # node.should have_selector("h3", :content => filter)
115
- # node.should have_selector("span.selected", :content => /#{text}.*/)
116
- # end
117
- # end
118
-