atrium 0.0.1.alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. data/.gitignore +13 -0
  2. data/.gitmodules +3 -0
  3. data/.rvmrc +32 -0
  4. data/GETTING_STARTED.textile +109 -0
  5. data/Gemfile +4 -0
  6. data/Gemfile.lock +320 -0
  7. data/Guardfile +10 -0
  8. data/README.mkd +56 -0
  9. data/Rakefile +6 -0
  10. data/app/assets/images/atrium/ajax-loader.gif +0 -0
  11. data/app/assets/images/atrium/lightbox-ico-loading.gif +0 -0
  12. data/app/assets/images/atrium/logo.png +0 -0
  13. data/app/assets/javascripts/atrium/atrium.js +281 -0
  14. data/app/assets/javascripts/chosen.jquery.js +899 -0
  15. data/app/assets/javascripts/ckeditor.warning.js +65 -0
  16. data/app/assets/javascripts/ckeditor/config.js.coffee +6 -0
  17. data/app/assets/javascripts/ckeditor/jquery.generateId.js +13 -0
  18. data/app/assets/javascripts/ckeditor/jquery.jeditable.ckeditor.js +59 -0
  19. data/app/assets/javascripts/ckeditor/plugins/linkItem/application_link.png +0 -0
  20. data/app/assets/javascripts/ckeditor/plugins/linkItem/dialogs/linkItem.js +1470 -0
  21. data/app/assets/javascripts/ckeditor/plugins/linkItem/plugin.js +16 -0
  22. data/app/assets/javascripts/ckeditor/plugins/linkItem/ui_toolbar_pencil.png +0 -0
  23. data/app/assets/javascripts/jquery.colorbox.js +864 -0
  24. data/app/assets/javascripts/jquery.jeditable.js +543 -0
  25. data/app/assets/stylesheets/atrium/atrium.css +216 -0
  26. data/app/assets/stylesheets/atrium/chosen-sprite.png +0 -0
  27. data/app/assets/stylesheets/atrium/chosen.css +367 -0
  28. data/app/assets/stylesheets/colorbox.css +42 -0
  29. data/app/assets/stylesheets/controls.png +0 -0
  30. data/app/assets/stylesheets/loading.gif +0 -0
  31. data/app/controllers/atrium/base_controller.rb +25 -0
  32. data/app/controllers/atrium/collection_exhibit_order_controller.rb +21 -0
  33. data/app/controllers/atrium/collections_controller.rb +165 -0
  34. data/app/controllers/atrium/customization_controller.rb +41 -0
  35. data/app/controllers/atrium/descriptions_controller.rb +177 -0
  36. data/app/controllers/atrium/exhibit_facet_order_controller.rb +19 -0
  37. data/app/controllers/atrium/exhibits_controller.rb +108 -0
  38. data/app/controllers/atrium/showcases_controller.rb +193 -0
  39. data/app/helpers/atrium/base_helper.rb +6 -0
  40. data/app/models/ability.rb +14 -0
  41. data/app/models/atrium/browse_level.rb +41 -0
  42. data/app/models/atrium/collection.rb +121 -0
  43. data/app/models/atrium/description.rb +128 -0
  44. data/app/models/atrium/essay.rb +21 -0
  45. data/app/models/atrium/exhibit.rb +58 -0
  46. data/app/models/atrium/search/facet.rb +29 -0
  47. data/app/models/atrium/search/facet_selection.rb +17 -0
  48. data/app/models/atrium/showcase.rb +173 -0
  49. data/app/models/atrium/showcase/facet_selection.rb +21 -0
  50. data/app/models/atrium/showcase/item.rb +19 -0
  51. data/app/models/role_mapper.rb +23 -0
  52. data/app/views/_user_util_links.html.erb +25 -0
  53. data/app/views/atrium/collections/_bookmark_control.html.erb +25 -0
  54. data/app/views/atrium/collections/_browse_index.html.erb +20 -0
  55. data/app/views/atrium/collections/_collection_items_index.html.erb +10 -0
  56. data/app/views/atrium/collections/_document.html.erb +24 -0
  57. data/app/views/atrium/collections/_document_list.html.erb +6 -0
  58. data/app/views/atrium/collections/_edit_navigation.html.erb +20 -0
  59. data/app/views/atrium/collections/_folder_control.html.erb +12 -0
  60. data/app/views/atrium/collections/_form.html.erb +93 -0
  61. data/app/views/atrium/collections/_listing.html.erb +18 -0
  62. data/app/views/atrium/collections/_navigation.html.erb +45 -0
  63. data/app/views/atrium/collections/_results_pagination.html.erb +9 -0
  64. data/app/views/atrium/collections/_sort_and_per_page.html.erb +23 -0
  65. data/app/views/atrium/collections/edit.html.erb +5 -0
  66. data/app/views/atrium/collections/new.html.erb +6 -0
  67. data/app/views/atrium/collections/show.html.erb +22 -0
  68. data/app/views/atrium/descriptions/_form.html.erb +64 -0
  69. data/app/views/atrium/descriptions/edit.html.erb +4 -0
  70. data/app/views/atrium/descriptions/index.html.erb +4 -0
  71. data/app/views/atrium/descriptions/new.html.erb +2 -0
  72. data/app/views/atrium/descriptions/show.html.erb +20 -0
  73. data/app/views/atrium/exhibits/_bookmark_control.html.erb +25 -0
  74. data/app/views/atrium/exhibits/_folder_control.html.erb +12 -0
  75. data/app/views/atrium/exhibits/_form.html.erb +108 -0
  76. data/app/views/atrium/exhibits/edit.html.erb +9 -0
  77. data/app/views/atrium/exhibits/new.html.erb +6 -0
  78. data/app/views/atrium/exhibits/show.html.erb +26 -0
  79. data/app/views/atrium/showcases/_showcase_navigation.html.erb +23 -0
  80. data/app/views/atrium/showcases/show.html.erb +1 -0
  81. data/app/views/catalog/_collection_home_text.html.erb +6 -0
  82. data/app/views/catalog/_constraints.html.erb +9 -0
  83. data/app/views/catalog/_default_collection_text.html.erb +18 -0
  84. data/app/views/catalog/_default_home_text.html.erb +6 -0
  85. data/app/views/catalog/_home_text.html.erb +6 -0
  86. data/app/views/catalog/_index_partials/_description.html.erb +8 -0
  87. data/app/views/catalog/_search_form.html.erb +66 -0
  88. data/app/views/catalog/_show_partials/_description.html.erb +15 -0
  89. data/app/views/catalog/browse_show.html.erb +18 -0
  90. data/app/views/catalog/index.html.erb +35 -0
  91. data/app/views/catalog/list_description.html.erb +24 -0
  92. data/app/views/catalog/list_item.html.erb +3 -0
  93. data/app/views/layouts/atrium.html.erb +86 -0
  94. data/app/views/layouts/atrium_themes/default.html.erb +4 -0
  95. data/app/views/layouts/item_listing.html.erb +36 -0
  96. data/app/views/listing/_document.html.erb +27 -0
  97. data/app/views/listing/_document_list.html.erb +3 -0
  98. data/app/views/listing/_item_search.html.erb +27 -0
  99. data/app/views/shared/_banner.html.erb +5 -0
  100. data/app/views/shared/_collection_complete_list.html.erb +33 -0
  101. data/app/views/shared/_collection_search_form.html.erb +12 -0
  102. data/app/views/shared/_collection_title_header.html.erb +3 -0
  103. data/app/views/shared/_featured_sources.html.erb +20 -0
  104. data/app/views/shared/_list_descriptions.html.erb +38 -0
  105. data/app/views/shared/_navigation_browse_levels.html.erb +34 -0
  106. data/app/views/shared/_showcase_configure_menu.html.erb +22 -0
  107. data/app/views/shared/_top_navigation.html.erb +9 -0
  108. data/atrium.gemspec +76 -0
  109. data/config/routes.rb +12 -0
  110. data/init.rb +3 -0
  111. data/lib/application_controller.rb +24 -0
  112. data/lib/atrium.rb +42 -0
  113. data/lib/atrium/application_helper.rb +24 -0
  114. data/lib/atrium/atrium_helper_behavior.rb +162 -0
  115. data/lib/atrium/catalog.rb +203 -0
  116. data/lib/atrium/collections_helper.rb +139 -0
  117. data/lib/atrium/controller.rb +10 -0
  118. data/lib/atrium/descriptions_helper.rb +23 -0
  119. data/lib/atrium/engine.rb +12 -0
  120. data/lib/atrium/layout_helper.rb +13 -0
  121. data/lib/atrium/routes.rb +99 -0
  122. data/lib/atrium/solr_helper.rb +440 -0
  123. data/lib/atrium/version.rb +3 -0
  124. data/lib/generators/atrium/assets_generator.rb +44 -0
  125. data/lib/generators/atrium/atrium_generator.rb +149 -0
  126. data/lib/generators/atrium/cucumber_support_generator.rb +29 -0
  127. data/lib/generators/atrium/templates/config/role_map_cucumber.yml +2 -0
  128. data/lib/generators/atrium/templates/config/role_map_development.yml +2 -0
  129. data/lib/generators/atrium/templates/config/role_map_production.yml +2 -0
  130. data/lib/generators/atrium/templates/config/role_map_test.yml +2 -0
  131. data/lib/generators/atrium/templates/config/solr.yml +10 -0
  132. data/lib/generators/atrium/templates/db/seeds.rb +87 -0
  133. data/lib/generators/atrium/templates/migrations/create_atrium_browse_levels.rb +18 -0
  134. data/lib/generators/atrium/templates/migrations/create_atrium_collections.rb +20 -0
  135. data/lib/generators/atrium/templates/migrations/create_atrium_descriptions.rb +16 -0
  136. data/lib/generators/atrium/templates/migrations/create_atrium_essays.rb +15 -0
  137. data/lib/generators/atrium/templates/migrations/create_atrium_exhibits.rb +16 -0
  138. data/lib/generators/atrium/templates/migrations/create_atrium_search_facets.rb +14 -0
  139. data/lib/generators/atrium/templates/migrations/create_atrium_showcase_facet_selections.rb +15 -0
  140. data/lib/generators/atrium/templates/migrations/create_atrium_showcase_items.rb +17 -0
  141. data/lib/generators/atrium/templates/migrations/create_atrium_showcases.rb +16 -0
  142. data/lib/generators/atrium/templates/themes/example.html.erb +21 -0
  143. data/lib/railties/all_tests.rake +23 -0
  144. data/lib/railties/atrium_cucumber.rake +121 -0
  145. data/lib/railties/index.rake +37 -0
  146. data/tasks/atrium.rake +268 -0
  147. data/tasks/atrium_rspec.rake +91 -0
  148. data/test_support/etc/Gemfile +33 -0
  149. data/test_support/etc/bundle_config +3 -0
  150. data/test_support/etc/rvmrc +32 -0
  151. data/test_support/features/atrium_collections.feature +162 -0
  152. data/test_support/features/atrium_exhibits.feature +164 -0
  153. data/test_support/features/step_definitions/atrium_collection_steps.rb +102 -0
  154. data/test_support/features/step_definitions/atrium_exhibit_steps.rb +53 -0
  155. data/test_support/features/step_definitions/bookmarks_steps.rb +6 -0
  156. data/test_support/features/step_definitions/error_steps.rb +5 -0
  157. data/test_support/features/step_definitions/folder_steps.rb +27 -0
  158. data/test_support/features/step_definitions/general_steps.rb +50 -0
  159. data/test_support/features/step_definitions/record_view_steps.rb +12 -0
  160. data/test_support/features/step_definitions/saved_searches_steps.rb +22 -0
  161. data/test_support/features/step_definitions/search_facets_steps.rb +29 -0
  162. data/test_support/features/step_definitions/search_history_steps.rb +9 -0
  163. data/test_support/features/step_definitions/search_result_steps.rb +114 -0
  164. data/test_support/features/step_definitions/search_steps.rb +103 -0
  165. data/test_support/features/step_definitions/user_steps.rb +5 -0
  166. data/test_support/features/step_definitions/web_steps.rb +213 -0
  167. data/test_support/features/support/env.rb +67 -0
  168. data/test_support/features/support/paths.rb +76 -0
  169. data/test_support/features/support/selectors.rb +40 -0
  170. data/test_support/fixtures/atrium_exhibits.yml +3 -0
  171. data/test_support/spec/controllers/atrium/base_controller_spec.rb +13 -0
  172. data/test_support/spec/controllers/atrium/collection_exhibit_order_controller_spec.rb +29 -0
  173. data/test_support/spec/controllers/atrium/collections_controller_spec.rb +185 -0
  174. data/test_support/spec/controllers/atrium/customization_controller_spec.rb +38 -0
  175. data/test_support/spec/controllers/atrium/descriptions_controller_spec.rb +150 -0
  176. data/test_support/spec/controllers/atrium/exhibit_facet_order_controller_spec.rb +36 -0
  177. data/test_support/spec/controllers/atrium/exhibits_controller_spec.rb +192 -0
  178. data/test_support/spec/controllers/atrium/showcases_controller_spec.rb +185 -0
  179. data/test_support/spec/helpers/atrium_collections_helper_spec.rb +147 -0
  180. data/test_support/spec/helpers/atrium_description_helper_spec.rb +47 -0
  181. data/test_support/spec/helpers/atrium_solr_helper_spec.rb +512 -0
  182. data/test_support/spec/models/atrium/browse_level_spec.rb +31 -0
  183. data/test_support/spec/models/atrium/collection_spec.rb +30 -0
  184. data/test_support/spec/models/atrium/description_spec.rb +67 -0
  185. data/test_support/spec/models/atrium/essay_spec.rb +12 -0
  186. data/test_support/spec/models/atrium/exhibit_spec.rb +76 -0
  187. data/test_support/spec/models/atrium/search/facet_selection_spec.rb +24 -0
  188. data/test_support/spec/models/atrium/search/facet_spec.rb +11 -0
  189. data/test_support/spec/models/atrium/search_facet_spec.rb +54 -0
  190. data/test_support/spec/models/atrium/showcase/facet_selection_spec.rb +15 -0
  191. data/test_support/spec/models/atrium/showcase/item_spec.rb +12 -0
  192. data/test_support/spec/models/atrium/showcase_facet_selection_spec.rb +65 -0
  193. data/test_support/spec/models/atrium/showcase_spec.rb +134 -0
  194. data/test_support/spec/rcov.opts +3 -0
  195. data/test_support/spec/routing/atrium/collections_routing_spec.rb +33 -0
  196. data/test_support/spec/spec.opts +4 -0
  197. data/test_support/spec/spec_helper.rb +47 -0
  198. data/test_support/spec/support/be_accessible_matcher.rb +8 -0
  199. data/test_support/spec/support/be_routed_mixin.rb +7 -0
  200. data/test_support/tmp/step_definitions/catalog_index_steps.rb +14 -0
  201. data/test_support/tmp/step_definitions/edit_document_steps.rb +67 -0
  202. data/test_support/tmp/step_definitions/hydra_metadata_steps.rb +3 -0
  203. data/test_support/tmp/step_definitions/hydra_steps.rb +8 -0
  204. data/test_support/tmp/step_definitions/search_steps.rb +86 -0
  205. data/test_support/tmp/step_definitions/searching_steps.rb +22 -0
  206. data/test_support/tmp/step_definitions/select_steps.rb +8 -0
  207. data/test_support/tmp/step_definitions/show_document_steps.rb +73 -0
  208. data/test_support/tmp/step_definitions/user_steps.rb +15 -0
  209. data/test_support/tmp/step_definitions/web_steps.rb +273 -0
  210. data/test_support/tmp/support/env.rb +54 -0
  211. data/test_support/tmp/support/paths.rb +57 -0
  212. metadata +1047 -0
@@ -0,0 +1,102 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
2
+
3
+ Given /^"([^"]*)" exists with id (\d+)$/ do |model_str, model_id|
4
+ model_str = "atrium/"+model_str.gsub(/\s/, '_').singularize
5
+ klass = eval(model_str.camelize)
6
+ klass.find(model_id).should_not be_nil
7
+ end
8
+
9
+
10
+ Then /^I should see "([^"]*)" link(?: within "([^"]*)")?$/ do |link_locator, scope_selector|
11
+ with_scope(scope_selector) do
12
+ begin
13
+ find_link(link_locator)
14
+ rescue
15
+ raise "no link with value or id or text '#{link_locator}' found"
16
+ end
17
+ end
18
+ end
19
+
20
+ Then /^I (should not|should) see an? "([^\"]*)" tag with an? "([^\"]*)" attribute of "([^\"]*)"$/ do |bool,tag,attribute,value|
21
+ if bool == "should not"
22
+ page.should_not have_xpath("//#{tag}[contains(@#{attribute}, #{value})]")
23
+ else
24
+ page.should have_xpath("//#{tag}[contains(@#{attribute}, #{value})]")
25
+ end
26
+ end
27
+
28
+ Given /^User exists with a login of "([^\"]*)"$/ do |login|
29
+ email = "#{login}@#{login}.com"
30
+ User.find_by_email(email).should_not be_nil
31
+ visit destroy_user_session_path
32
+ visit new_user_session_path
33
+ fill_in "Email", :with => email
34
+ fill_in "Password", :with => "password"
35
+ click_button "Sign in"
36
+ step %{I should see "Log Out"}
37
+ end
38
+
39
+ Then /^I should have showcase for collection with id (\d+)$/ do |collection_id|
40
+ collection= Atrium::Collection.find(collection_id)
41
+ showcase= Atrium::Showcase.with_selected_facets(collection_id,collection.class.name, nil).first
42
+ showcase.should_not be nil
43
+ end
44
+
45
+ Then /^I should have "([^\"]*)" field$/ do |field_name|
46
+ page.should have_selector("textarea#atrium_description_#{field_name}_attributes_content")
47
+ end
48
+
49
+ When /^I add "([^"]*)" with content "([^"]*)" to the collection with id "([^"]*)"$/ do |field, content, collection_id|
50
+ collection= Atrium::Collection.find(collection_id)
51
+ showcase= Atrium::Showcase.with_selected_facets(collection_id,collection.class.name, nil).first
52
+ fill_in "atrium_description_#{field}_attributes_content", :with => content
53
+ click_button "Save"
54
+ page.should have_content(content)
55
+ visit atrium_collection_showcase_path(collection.id, showcase.id, nil)
56
+ end
57
+
58
+ When /^I (add|remove) record (.+) (to|from) featured for showcase with id (.+)$/ do |add_or_remove, id, wording,showcase_id|
59
+ click_button("folder_submit_#{id}")
60
+ showcase= Atrium::Showcase.find(showcase_id)
61
+ asset= showcase.showcases_type.find(showcase.showcases_id)
62
+ visit atrium_collection_atrium_showcases_path(asset, :showcase_id => showcase.id)
63
+ end
64
+
65
+ Then /^I should have link to "([^"]*)" in featured list$/ do |name|
66
+ #puts "#{page.find("span#show_selected div#documents div.document h3.index_title a")['href'].inspect}"
67
+ page.should have_selector("div#show-selected div#documents div.document h3.index_title", :content => name)
68
+ end
69
+
70
+ When /^I add record "([^"]*)" to featured to the "([^"]*)" with id "([^"]*)" and facet "([^"]*)"$/ do |record_id, collection_or_exhibit, id, facet|
71
+ click_button("folder_submit_#{record_id}")
72
+ asset= collection_or_exhibit.eql?("collection") ? Atrium::Collection.find(id) : Atrium::Exhibit.find(id)
73
+ selected_facet= collection_or_exhibit.eql?("collection") ? nil : {"pub_date"=>["#{facet}"]}
74
+ showcase= Atrium::Showcase.with_selected_facets(asset.id, asset.class.name, selected_facet).first
75
+ showcase.should_not be nil
76
+ @atrium_showcase=showcase
77
+ @atrium_collection = collection_or_exhibit.eql?("collection") ? asset : Atrium::Collection.find(asset.atrium_collection_id)
78
+ puts @atrium_collection.inspect
79
+ puts @atrium_showcase.inspect
80
+ path = collection_or_exhibit.eql?("collection") ? atrium_collection_showcase_path(asset, :showcase_id => showcase.id) : atrium_exhibit_path(asset.id, :f => selected_facet)
81
+ puts path.inspect
82
+ visit path
83
+ end
84
+
85
+ When /^I add description with id "([^"]*)" to (collection|exhibit) with id "([^"]*)" and facet "([^"]*)"$/ do |id, collection_or_exhibit, asset_id, facet|
86
+ click_button("folder_submit_#{id}")
87
+ asset= collection_or_exhibit.eql?("collection") ? Atrium::Collection.find(asset_id) : Atrium::Exhibit.find(asset_id)
88
+ #puts asset.inspect
89
+ selected_facet= collection_or_exhibit.eql?("collection") ? nil : {"pub_date"=>["#{facet}"]}
90
+ showcase= Atrium::Showcase.with_selected_facets(asset.id, asset.class.name, selected_facet).first
91
+ showcase.should_not be nil
92
+ #puts showcase.inspect
93
+ path = atrium_descriptions_link_path(:showcase_id=>showcase.id)
94
+ visit path
95
+ end
96
+
97
+ Then /^I should see description with title "([^"]*)" in description list$/ do |title|
98
+ content="Essay: #{title}"
99
+ page.should have_selector("div#show-description h3", :content => content)
100
+ end
101
+
102
+
@@ -0,0 +1,53 @@
1
+
2
+ Then /^"([^"]*)" should( not)? be an option for "([^"]*)"(?: within "([^\"]*)")?$/ do |value, negate, field, selector|
3
+ with_scope(selector) do
4
+ expectation = negate ? :should_not : :should
5
+ field_labeled(field).first(:xpath, ".//option[text() = '#{value}']").send(expectation, be_present)
6
+ end
7
+ end
8
+
9
+ Given /^I follow the "([^"]*)" link for exhibit with id (\d+)$/ do |link, id|
10
+ page.find(:xpath, ".//li[@data-id = #{id}]/span[@class='controls']/a[text()='#{link}']").click
11
+ end
12
+
13
+
14
+
15
+ Then /^I should have "([^"]*)" containing only (\d+) "([^"]*)"$/ do |selector, count, element |
16
+ page.should have_css("#{selector} #{element}", :count => count.to_i)
17
+ end
18
+
19
+ Then /^I should have the applied solr facet "([^\"]*)" with the value "([^\"]*)"$/ do |filter, text|
20
+ page.should have_selector("div.facet-list") do |node|
21
+ node.should have_selector("h3", :content => filter)
22
+ node.should have_selector("span.selected", :content => text)
23
+ end
24
+ end
25
+
26
+ Then /^I should have "([^\"]*)" facet inside "([^\"]*)" facet$/ do |string, filter|
27
+ #page.should have_selector("li.#{filter}") do |node|
28
+ # node.should have_selector("h3.facet-heading", :content => filter)
29
+ #end
30
+ page.should have_selector("span.selected", :content => filter)
31
+ step %{I should see "#{string}" within "li h3.facet-heading"}
32
+
33
+ end
34
+
35
+ Then /^I should have showcase for exhibit with id "([^"]*)" and facet "([^"]*)"$/ do |exhibit_id, facet|
36
+ exhibit= Atrium::Exhibit.find(exhibit_id)
37
+ showcase= Atrium::Showcase.with_selected_facets(exhibit_id,exhibit.class.name, {"pub_date"=>["#{facet}"]}).first
38
+ #puts "Showcase: #{showcase.inspect}"
39
+ showcase.should_not be nil
40
+ end
41
+
42
+
43
+ When /^I add "([^"]*)" with content "([^"]*)" to the exhibit with id "([^"]*)" and facet "([^"]*)"$/ do |field, content, id, facet|
44
+ exhibit= Atrium::Exhibit.find(id)
45
+ showcase= Atrium::Showcase.with_selected_facets(id,exhibit.class.name, {"pub_date"=>["#{facet}"]}).first
46
+ fill_in "atrium_description_#{field}_attributes_content", :with => content
47
+ click_button "Save"
48
+ page.should have_content(content)
49
+ visit atrium_exhibit_path(exhibit.id, :f=>{"pub_date"=>["#{facet}"]})
50
+ end
51
+
52
+
53
+
@@ -0,0 +1,6 @@
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
@@ -0,0 +1,5 @@
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", :content => message)
5
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding : utf-8 -*-
2
+ Then /^I should see an add to folder form$/ do
3
+ page.should have_selector("form.addFolder")
4
+ end
5
+
6
+ Then /^I should see a remove from folder form$/ do
7
+ page.should have_selector("form.deleteFolder")
8
+ end
9
+
10
+ When /^I (add|remove) record (.+) (to|from) my folder$/ do |add_or_remove, id, wording|
11
+ click_button("folder_submit_#{id}")
12
+ end
13
+
14
+ Given /^I have record (.+) in my folder$/ do |arg1|
15
+ visit catalog_path(arg1)
16
+ click_button("Select")
17
+ click_link("Selected Items")
18
+ end
19
+
20
+ Then /^I (should|should not) see the Folder tools$/ do |comparator|
21
+ case comparator
22
+ when "should"
23
+ page.should have_selector("ul.folderTools")
24
+ when "should not"
25
+ page.should_not have_selector("ul.folderTools")
26
+ end
27
+ end
@@ -0,0 +1,50 @@
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
@@ -0,0 +1,12 @@
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
@@ -0,0 +1,22 @@
1
+ # -*- encoding : utf-8 -*-
2
+ Given /^I am logged in as "([^\"]*)"$/ do |login|
3
+ email = "#{login}@#{login}.com"
4
+ user = User.create(:login => login, :email => email, :password => "password", :password_confirmation => "password")
5
+ # visit user_sessions_path(:user_session => {:login => login, :password => "password"}), :post
6
+ # User.find(user.id).should_not be_nil
7
+ visit new_user_session_path
8
+ fill_in("user_email", :with => email)
9
+ fill_in("user_password", :with => "password")
10
+ click_button("Sign in")
11
+ # response.body.should =~ /Logged/m
12
+ Then 'I should see "Log Out"'
13
+ end
14
+
15
+ Given /^"([^\"]*)" has saved a search with term "([^\"]*)"$/ do |user, term|
16
+ user = User.find_by_email("#{user}@#{user}.com")
17
+ user.searches << Search.create(:query_params => {:q => term})
18
+ user.save!
19
+ end
20
+
21
+
22
+
@@ -0,0 +1,29 @@
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", :content => filter)
6
+ node.should have_selector("span.selected", :content => 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", :content => filter)
13
+ node.should have_selector("span.selected", :content => 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", :content => filter)
20
+ node.should have_selector("a.label", :content => 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", :content => filter)
27
+ end
28
+ end
29
+
@@ -0,0 +1,9 @@
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
+
@@ -0,0 +1,114 @@
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
+ end
8
+
9
+
10
+ Then /^I should get (at least|at most|exactly) (\d+) results?$/i do |comparator, comparison_num|
11
+ number_of_records = get_number_of_results_from_page(page)
12
+
13
+ case comparator
14
+ when "at least"
15
+ number_of_records.should >= comparison_num.to_i
16
+ when "at most"
17
+ number_of_records.should <= comparison_num.to_i
18
+ when "exactly"
19
+ number_of_records.should == comparison_num.to_i
20
+ end
21
+ end
22
+
23
+
24
+ Then /^I should have (the same number of|fewer|more) results (?:than|as) a(?:n?) search for "(.*)"$/i do |comparator, query|
25
+ query.gsub!(/\\"/, '"')
26
+ number_of_records = get_number_of_results_from_page(page)
27
+
28
+ case comparator
29
+ when "the same number of"
30
+ get_number_of_results_for_query(query).should == number_of_records
31
+ when "fewer"
32
+ get_number_of_results_for_query(query).should > number_of_records
33
+ when "fewer"
34
+ get_number_of_results_for_query(query).should < number_of_records
35
+ end
36
+ end
37
+
38
+ Then /^I should get id "([^\"]+)" in the results$/i do |id|
39
+ page.should have_xpath("//a[contains(@href, #{id})]")
40
+ end
41
+
42
+ Then /^I should not get id "([^\"]+)" in the results$/i do |id|
43
+ page.should_not have_xpath("//a[contains(@href, #{id})]")
44
+ end
45
+
46
+ Then /^I should get id "([^\"]+)" in the first (\d+) results?$/i do |id, max_num|
47
+ pos = get_position_in_result_page(page, id)
48
+ pos.should_not == -1
49
+ pos.should < max_num.to_i
50
+ end
51
+
52
+ Then /^I should not get id "([^\"]+)" in the first (\d+) results?$/i do |id, max_num|
53
+ pos = get_position_in_result_page(page, id)
54
+ pos.should_not == -1
55
+
56
+ if pos > 0
57
+ pos.should >= max_num.to_i
58
+ else
59
+ pos.should == -1 if pos == -1
60
+ end
61
+ end
62
+
63
+ Then /^I should get id "([^\"]+)" before id "([^\"]+)"$/i do |id1, id2|
64
+ pos1 = get_position_in_result_page(page, id1)
65
+ pos2 = get_position_in_result_page(page, id2)
66
+ pos1.should_not == -1
67
+ pos2.should_not == -1
68
+
69
+ pos1.should < pos2
70
+ end
71
+
72
+ Then /^I should get id "([^\"]+)" and id "([^\"]+)" no more than (\d+) positions? from each other$/i do |id1, id2, limit|
73
+
74
+ pos1 = get_position_in_result_page(page, id1)
75
+ pos2 = get_position_in_result_page(page, id2)
76
+ pos1.should_not == -1
77
+ pos2.should_not == -1
78
+
79
+ (pos1 - pos2).abs.should <= limit.to_i
80
+ end
81
+
82
+ Then /^I should get at least (\d+) of these ids in the first (\d+) results: "([^\"]+)"$/i do |how_many, limit, id_string|
83
+ id_string.split(/,/).select do |id|
84
+ pos = get_position_in_result_page(page, id)
85
+ pos != -1 and pos < limit.to_i
86
+ end.length.should >= how_many.to_i
87
+ end
88
+
89
+ Then /^I (should not|should) see an? "([^\"]*)" element with an? "([^\"]*)" attribute of "([^\"]*)"$/ do |bool,elem,attribute,value|
90
+ if bool == "should not"
91
+ page.should_not have_selector("#{elem}[#{attribute}=#{value}]")
92
+ else
93
+ page.should have_selector("#{elem}[#{attribute}=#{value}]")
94
+ end
95
+ end
96
+
97
+ def get_position_in_result_page(page, id)
98
+ i = -1
99
+ page.all(".index_title a").each_with_index do |link, idx|
100
+ i = (idx+1) if link['href'] =~ Regexp.new(Regexp.escape(id) + "$")
101
+ end
102
+ i.to_i
103
+ end
104
+
105
+ def get_number_of_results_for_query(query)
106
+ visit root_path
107
+ fill_in "q", :with => query
108
+ click_button "search"
109
+ get_number_of_results_from_page(page)
110
+ end
111
+
112
+ def get_number_of_results_from_page(page)
113
+ page.find("meta[name=totalResults]")['content'].to_i rescue 0
114
+ end
@@ -0,0 +1,103 @@
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 a selectable list with per page choices$/ do
12
+ page.should have_selector("select#per_page")
13
+ end
14
+
15
+ Then /^I should see a "([^\"]*)" button$/ do |label|
16
+ page.should have_selector("input[type='submit'][value='#{label}']")
17
+ end
18
+
19
+ Then /^I should not see the "([^\"]*)" element$/ do |id|
20
+ page.should_not have_selector("##{id}")
21
+ end
22
+
23
+ Then /^I should see the "([^\"]*)" element$/ do |id|
24
+ page.should have_selector("##{id}")
25
+ end
26
+
27
+ Given /^the application is configured to have searchable fields "([^\"]*)" with values "([^\"]*)"$/ do |fields, values|
28
+ labels = fields.split(", ")
29
+ values = values.split(", ")
30
+ combined = labels.zip(values)
31
+ Blacklight.config[:search_fields] = []
32
+ combined.each do |pair|
33
+ Blacklight.config[:search_fields] << pair
34
+ end
35
+ end
36
+
37
+ Then /^I should see select list "([^\"]*)" with field labels "([^\"]*)"$/ do |list_css, names|
38
+ page.should have_selector(list_css) do
39
+ labels = names.split(", ")
40
+ labels.each do |label|
41
+ with_tag('option', label)
42
+ end
43
+ end
44
+ end
45
+
46
+ Then /^I should see select list "([^\"]*)" with "([^\"]*)" selected$/ do |list_css, label|
47
+ page.should have_selector(list_css) do |e|
48
+ with_tag("[selected=selected]", {:count => 1}) do
49
+ with_tag("option", {:count => 1, :text => label})
50
+ end
51
+ end
52
+ end
53
+
54
+ # Results Page
55
+ Given /^the application is configured to have sort fields "([^\"]*)" with values "([^\"]*)"$/ do |fields, values|
56
+ labels = fields.split(", ")
57
+ values = values.split(", ")
58
+ combined = labels.zip(values)
59
+ Blacklight.config[:sort_fields] = []
60
+ combined.each do |pair|
61
+ Blacklight.config[:sort_fields] << pair
62
+ end
63
+ end
64
+
65
+ Then /^I should get results$/ do
66
+ page.should have_selector("div.document")
67
+ end
68
+
69
+ Then /^I should not get results$/ do
70
+ page.should_not have_selector("div.document")
71
+ end
72
+
73
+ Then /^I should see the applied filter "([^\"]*)" with the value "([^\"]*)"$/ do |filter, text|
74
+ page.should have_selector("div#facets div h3", :content => filter)
75
+ page.should have_selector("div#facets div span.selected", :content => text)
76
+ end
77
+
78
+ Then /^I should see an rss discovery link/ do
79
+ page.should have_selector("link[rel=alternate][type='application/rss+xml']")
80
+ end
81
+
82
+ Then /^I should see an atom discovery link/ do
83
+ page.should have_selector("link[rel=alternate][type='application/atom+xml']")
84
+ end
85
+
86
+ Then /^I should see an unAPI discovery link/ do
87
+ page.should have_selector("link[rel=unapi-server][type='application/xml']")
88
+ end
89
+
90
+ Then /^I should see opensearch response metadata tags/ do
91
+ page.should have_selector("meta[name=totalResults]")
92
+ page.should have_selector("meta[name=startIndex]")
93
+ page.should have_selector("meta[name=itemsPerPage]")
94
+ end
95
+
96
+ # Then /^I should see the applied filter "([^\"]*)" with the value
97
+ # "([^\"]*)"$/ do |filter, text|
98
+ # page.should have_tag("div#facets div") do |node|
99
+ # node.should have_selector("h3", :content => filter)
100
+ # node.should have_selector("span.selected", :content => /#{text}.*/)
101
+ # end
102
+ # end
103
+