atrium 0.0.1.alpha

Sign up to get free protection for your applications and to get access to all the features.
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,15 @@
1
+ class CreateAtriumShowcaseFacetSelections < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :atrium_showcase_facet_selections do |t|
4
+ t.integer :atrium_showcase_id
5
+ t.string :solr_facet_name
6
+ t.string :value
7
+ end
8
+ add_index :atrium_showcase_facet_selections, :id
9
+ add_index :atrium_showcase_facet_selections, :atrium_showcase_id, :name =>'atrium_facet_showcase_index'
10
+ end
11
+
12
+ def self.down
13
+ drop_table :atrium_showcase_facet_selections
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ class CreateAtriumShowcaseItems < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :atrium_showcase_items do |t|
4
+ t.string :solr_doc_id, :null=>false
5
+ t.string :type
6
+ t.integer :atrium_showcase_id, :null=>false
7
+ end
8
+
9
+ add_index :atrium_showcase_items, :solr_doc_id
10
+ add_index :atrium_showcase_items, :id
11
+ add_index :atrium_showcase_items, :atrium_showcase_id
12
+ end
13
+
14
+ def self.down
15
+ drop_table :atrium_showcase_items
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ class CreateAtriumShowcases < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :atrium_showcases do |t|
4
+ t.text :showcase_items
5
+ #t.integer :atrium_parent_id
6
+ #t.string :atrium_parent_type
7
+ t.references :showcases, :polymorphic=>true
8
+ end
9
+ add_index :atrium_showcases, :id
10
+ #add_index :atrium_showcases, :atrium_parent_id, :atrium_parent_type
11
+ end
12
+
13
+ def self.down
14
+ drop_table :atrium_showcases
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ <%#
2
+ Theming in Atrium isn't very sophisticated. When a collection is given a
3
+ theme it renders all the atrium views using a different layout file.
4
+
5
+ A custom layout file can be as simple as this one. It simply fills in the
6
+ content blocks present in the default layout. For a greater degree of freedom
7
+ you can copy the default layout from within the gem to the 'atrium_layouts'
8
+ directory in this application and make whatever changes you want to it.
9
+
10
+ For more information about nesting layouts see:
11
+ http://guides.rubyonrails.org/layouts_and_rendering.html#using-nested-layouts
12
+ %>
13
+ <% content_for :theme_styles do %>
14
+ <style type="text/css">
15
+ /* Theme-specific styles */
16
+ body {background: #497EC9;}
17
+ </style>
18
+ <% end %>
19
+ <%# content_for :main_header do %>
20
+ <%# end %>
21
+ <%= render :template => 'layouts/atrium' %>
@@ -0,0 +1,23 @@
1
+ namespace :atrium do
2
+ begin
3
+ require 'cucumber/rake/task'
4
+ require 'rspec/core'
5
+ require 'rspec/core/rake_task'
6
+
7
+ desc "Run Atrium cucumber and rspec, with test solr"
8
+ task :all_tests => ['atrium:spec:with_solr', 'atrium:cucumber:with_solr']
9
+
10
+ namespace :all_tests do
11
+ desc "Run Atrium rspec and cucumber tests with rcov"
12
+ rm "atrium-coverage.data" if File.exist?("atrium-coverage.data")
13
+ task :rcov => ['atrium:spec:rcov', 'atrium:cucumber:rcov']
14
+ end
15
+
16
+ rescue LoadError
17
+ desc "Not available! (cucumber and rspec not avail)"
18
+ task :all_tests do
19
+ abort 'Not available. Both cucumber and rspec need to be installed to run atrium:all_tests'
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,121 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+ # Atrium customization, trick Cucumber into looking in our current
8
+ # location for Rails.root, even though we're going to give it features
9
+ # from elsewhere.
10
+ #ENV['RAILS_ROOT'] = Rails.root.to_s
11
+ #ENV['RAILS_ENV'] = 'test'
12
+
13
+ # atrium_features, where to find features inside atrium source?
14
+ atrium_features = File.expand_path("../test_support/features",File.dirname(__FILE__))
15
+ unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
16
+
17
+ vendored_cucumber_bin = Dir[File.expand_path("../vendor/{gems,plugins}/cucumber*/bin/cucumber",File.dirname(__FILE__))].first
18
+ $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
19
+
20
+ begin
21
+ require 'cucumber/rake/task'
22
+
23
+ namespace :atrium do
24
+ desc 'Alias for atrium:cucumber:ok'
25
+ task :cucumber => 'atrium:cucumber:ok'
26
+ namespace :cucumber do
27
+ Cucumber::Rake::Task.new({:ok => ['atrium:test:prepare', 'db:seed']}, 'Run features that should pass') do |t|
28
+ # Atrium customization, call features from external location, pass
29
+ # in feature location wtih cucumber_opts, yeah it's weird but that's how.
30
+ t.cucumber_opts = atrium_features
31
+
32
+ t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
33
+ t.fork = true # You may get faster startup if you set this to false
34
+ t.profile = 'default'
35
+ end
36
+
37
+ Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
38
+ # Atrium customization, call features from external location, pass
39
+ # in feature location wtih cucumber_opts, yeah it's weird but that's how.
40
+ t.cucumber_opts = atrium_features
41
+ t.binary = vendored_cucumber_bin
42
+ t.fork = true # You may get faster startup if you set this to false
43
+ t.profile = 'wip'
44
+ end
45
+
46
+ Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
47
+ # Atrium customization, call features from external location, pass
48
+ # in feature location wtih cucumber_opts, yeah it's weird but that's how.
49
+ t.cucumber_opts = atrium_features
50
+
51
+ t.binary = vendored_cucumber_bin
52
+ t.fork = true # You may get faster startup if you set this to false
53
+ t.profile = 'rerun'
54
+ end
55
+
56
+ if (RUBY_VERSION.to_f < 1.9) then
57
+ Cucumber::Rake::Task.new({:rcov => 'db:test:prepare'}, 'Run features with rcov') do |t|
58
+ # Atrium customization, call features from external location, pass
59
+ # in feature location wtih cucumber_opts, yeah it's weird but that's how.
60
+ t.cucumber_opts = atrium_features
61
+
62
+
63
+ t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
64
+ t.fork = true # You may get faster startup if you set this to false
65
+ t.profile = 'default'
66
+
67
+ end
68
+ end
69
+
70
+ desc 'Run all features'
71
+ task :all => [:ok]
72
+
73
+
74
+ # Solr wrapper. for now just for atrium:cucumber, plan to
75
+ # provide it for all variants eventually.
76
+ # if you would like to see solr startup messages on STDERR
77
+ # when starting solr test server during functional tests use:
78
+ #
79
+ # rake SOLR_CONSOLE=true
80
+ require File.expand_path('../jetty_solr_server.rb', __FILE__)
81
+ desc "atrium:cucumber with jetty/solr launch"
82
+ task :with_solr do
83
+ # wrap tests with a test-specific Solr server
84
+ # Need to look up where the test jetty is located
85
+ # from solr.yml, we don't hardcode it anymore.
86
+
87
+ solr_yml_path = locate_path("config", "solr.yml")
88
+ jetty_path = if ( File.exists?( solr_yml_path ))
89
+ solr_config = YAML::load(File.open(solr_yml_path))
90
+ solr_config["test"]["jetty_path"] if solr_config["test"]
91
+ end
92
+ raise Exception.new("Can't find jetty path to start test jetty. Expect a jetty_path key in config/solr.yml for test environment.") unless jetty_path
93
+
94
+ JettySolrServer.new(
95
+ :jetty_home => File.expand_path(jetty_path, Rails.root),
96
+ :sleep_after_start => 2).wrap do
97
+ Rake::Task["atrium:cucumber"].invoke
98
+ end
99
+ end
100
+
101
+ end
102
+
103
+
104
+ end
105
+
106
+
107
+ task :features => :cucumber do
108
+ STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
109
+ end
110
+
111
+ # In case we don't have ActiveRecord, append a no-op task that we can depend upon.
112
+ task 'db:test:prepare' do
113
+ end
114
+ rescue LoadError
115
+ desc 'cucumber rake task not available (cucumber not installed)'
116
+ task :cucumber do
117
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
118
+ end
119
+ end
120
+
121
+ end
@@ -0,0 +1,37 @@
1
+ namespace :solr do
2
+ namespace :index do
3
+
4
+ desc "Index all description records WITHOUT commiting changes to the index."
5
+ task :description => :environment do
6
+ puts "Desc: #{Atrium::Description.find(:all).inspect}"
7
+ Atrium::Description.all.each do |desc|
8
+ puts "Indexing Description ID:#{desc.id}"
9
+ Blacklight.solr.add desc.as_solr
10
+ end
11
+ end
12
+
13
+ desc "Index all description records AND commit changes to the index"
14
+ task :all => :environment do
15
+ Rake::Task['solr:index:description'].execute
16
+ Rake::Task['solr:index:commit'].execute
17
+ Rake::Task['solr:index:optimize'].execute
18
+ end
19
+
20
+ desc "Commit changes to solr index"
21
+ task :commit => :environment do
22
+ puts "Commiting Solr index."
23
+ start = Time.now
24
+ Blacklight.solr.commit
25
+ puts "Commiting took #{Time.now - start}s"
26
+ end
27
+
28
+ desc "Optimize solr index"
29
+ task :optimize => :environment do
30
+ puts "Optimizing Solr index."
31
+ start = Time.now
32
+ Blacklight.solr.optimize
33
+ puts "Optimization took #{Time.now - start}s"
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,268 @@
1
+ require 'rspec/core'
2
+ require 'rspec/core/rake_task'
3
+ require 'thor/core_ext/file_binary_read'
4
+ require 'jettywrapper'
5
+
6
+ namespace :atrium do
7
+
8
+ desc "Execute Continuous Integration build (docs, tests with coverage)"
9
+ task :ci do
10
+ Rake::Task["atrium:doc"].invoke
11
+
12
+ jetty_params = {
13
+ :jetty_home => File.expand_path(File.dirname(__FILE__) + '/../jetty'),
14
+ :quiet => false,
15
+ :jetty_port => 8983,
16
+ :solr_home => File.expand_path(File.dirname(__FILE__) + '/../jetty/solr'),
17
+ :startup_wait => 30
18
+ }
19
+ error = Jettywrapper.wrap(jetty_params) do
20
+ Rake::Task['atrium:setup_test_app'].invoke
21
+ Rake::Task['atrium:test'].invoke
22
+ end
23
+ raise "test failures: #{error}" if error
24
+ end
25
+
26
+
27
+ desc "Easiest way to run rspec tests. Copies code to host plugins dir, loads fixtures, then runs specs - need to have jetty running."
28
+ #task :spec => "rspec:setup_and_run"
29
+
30
+ namespace :rspec do
31
+
32
+ desc "Run the atrium specs - need to have jetty running, test host set up and fixtures loaded."
33
+ task :run => :use_test_app do
34
+ puts "Running rspec tests"
35
+ puts Rake::Task["atrium:spec"].invoke
36
+ FileUtils.cd('../../')
37
+ end
38
+
39
+ desc "Sets up test host, loads fixtures, then runs specs - need to have jetty running."
40
+ task :setup_and_run => ["atrium:setup_test_app"] do
41
+ puts "Reloading fixtures"
42
+ Rake::Task["atrium:rspec:run"].invoke
43
+
44
+ end
45
+
46
+ end
47
+
48
+
49
+ # The following is a task named :doc which generates documentation using yard
50
+ begin
51
+ require 'yard'
52
+ require 'yard/rake/yardoc_task'
53
+ project_root = File.expand_path("#{File.dirname(__FILE__)}/../")
54
+ doc_destination = File.join(project_root, 'doc')
55
+ if !File.exists?(doc_destination)
56
+ FileUtils.mkdir_p(doc_destination)
57
+ end
58
+
59
+ YARD::Rake::YardocTask.new(:doc) do |yt|
60
+ readme_filename = 'README.textile'
61
+ textile_docs = []
62
+ Dir[File.join(project_root, "*.textile")].each_with_index do |f, index|
63
+ unless f.include?("/#{readme_filename}") # Skip readme, which is already built by the --readme option
64
+ textile_docs << '-'
65
+ textile_docs << f
66
+ end
67
+ end
68
+ yt.files = Dir.glob(File.join(project_root, '*.rb')) +
69
+ Dir.glob(File.join(project_root, 'app', '**', '*.rb')) +
70
+ Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) +
71
+ textile_docs
72
+ yt.options = ['--output-dir', doc_destination, '--readme', readme_filename]
73
+ end
74
+ rescue LoadError
75
+ desc "Generate YARD Documentation"
76
+ task :doc do
77
+ abort "Please install the YARD gem to generate rdoc."
78
+ end
79
+ end
80
+
81
+ #
82
+ # Cucumber
83
+ #
84
+
85
+
86
+ desc "Run cucumber tests for atrium - need to have jetty running, test host set up and fixtures loaded."
87
+ task :cucumber => ['test:prepare'] do
88
+ within_test_app do
89
+ puts "Running cucumber features in test host app #{Dir.pwd}"
90
+ puts Rake::Task["atrium:cucumber:cmd"].invoke
91
+ end
92
+ end
93
+
94
+
95
+ namespace :cucumber do
96
+ # atrium_features, where to find features inside atrium source?
97
+ atrium_features = File.expand_path("../test_support/features",File.dirname(__FILE__))
98
+ vendored_cucumber_bin = Dir[File.expand_path("../vendor/{gems,plugins}/cucumber*/bin/cucumber",File.dirname(__FILE__))].first
99
+ $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
100
+ require 'cucumber/rake/task'
101
+ ### Don't call this directly, use atrium:cucumber
102
+ #Cucumber::Rake::Task.new(:cmd => 'atrium:db:seed') do |t|
103
+ Cucumber::Rake::Task.new(:cmd => 'atrium:db:seed') do |t|
104
+ t.cucumber_opts = atrium_features
105
+ t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
106
+ end
107
+ end
108
+
109
+ #
110
+ # Misc Tasks
111
+ #
112
+
113
+ desc "Creates a new test app"
114
+ task :setup_test_app => [:set_test_host_path] do
115
+ path = TEST_HOST_PATH
116
+ errors = []
117
+ puts "Cleaning out test app path #{path}"
118
+ puts %x[rm -fr #{path}]
119
+ errors << 'Error removing test app' unless $?.success?
120
+
121
+ ###puts "Freezing gems to project vendor/cache"
122
+ ###puts %x[bundle package]
123
+ ###errors << 'Bundle package failed' unless $?.success?
124
+
125
+ puts "Creating test app directory"
126
+ FileUtils.mkdir_p(path)
127
+
128
+ puts "Installing rails, bundler and devise"
129
+ %x[gem install --no-rdoc --no-ri 'rails' -v "<4"]
130
+ %x[gem install --no-rdoc --no-ri 'bundler']
131
+
132
+ #puts "Copying over .rvmrc file"
133
+ #FileUtils.cp("./test_support/etc/rvmrc",File.join(path,".rvmrc"))
134
+ FileUtils.cd("tmp")
135
+ #system("source ./test_app/.rvmrc")
136
+
137
+ puts "Generating new rails app"
138
+ %x[bundle exec rails new test_app]
139
+ errors << 'Error generating new rails test app' unless $?.success?
140
+ FileUtils.cd('test_app')
141
+ FileUtils.rm('public/index.html')
142
+
143
+ puts "Copying Gemfile from test_support/etc"
144
+ FileUtils.cp('../../test_support/etc/Gemfile','./Gemfile')
145
+
146
+ #puts "Creating local vendor/cache dir and copying gems from atrium gemset"
147
+ #FileUtils.cp_r(File.join('..','..','vendor','cache'), './vendor')
148
+
149
+ #puts "Configure bundler to only look at the local vendor/cache"
150
+ #FileUtils.mkdir_p( File.expand_path('./.bundle') )
151
+ #FileUtils.cp_r(File.expand_path('../../test_support/etc/bundle_config'), File.expand_path('./.bundle/config'))
152
+
153
+ puts "Copying fixtures into test app spec/fixtures directory"
154
+ FileUtils.mkdir_p( File.join('.','test_support') )
155
+ FileUtils.cp_r(File.join('..','..','test_support','fixtures'), File.join('.','test_support','fixtures'))
156
+
157
+ puts "Executing bundle install"
158
+ puts %x[bundle install]
159
+ errors << 'Error running bundle install in test app' unless $?.success?
160
+
161
+ puts "Installing jQuery UJS in test app"
162
+ puts %x[bundle exec rails g jquery:install]
163
+ errors << 'Error installing jquery-rails in test app' unless $?.success?
164
+
165
+ puts "Installing cucumber in test app"
166
+ puts %x[bundle exec rails g cucumber:install]
167
+ errors << 'Error installing cucumber in test app' unless $?.success?
168
+
169
+ puts "Generating default blacklight install"
170
+ puts %x[bundle exec rails g blacklight --devise]
171
+ errors << 'Error generating default blacklight install' unless $?.success?
172
+
173
+ puts "Generating default atrium install"
174
+ puts %x[bundle exec rails g atrium -df] # using -f to force overwriting of solr.yml
175
+ errors << 'Error generating default atrium install' unless $?.success?
176
+
177
+ after = 'TestApp::Application.configure do'
178
+ replace!( "#{path}/config/environments/test.rb", /#{after}/, "#{after}\n config.log_level = :warn\n")
179
+
180
+ puts FileUtils.cp('../../lib/generators/atrium/templates/db/seeds.rb','db/seeds.rb')
181
+
182
+ #puts "Loading blacklight marc test data into Solr"
183
+ #%x[bundle exec rake solr:marc:index_test_data]
184
+
185
+ puts "Running rake db:migrate"
186
+ puts %x[bundle exec rake db:migrate]
187
+ errors << 'Error running db:migrate in test app' unless $?.success?
188
+
189
+ puts %x[bundle exec rake db:migrate RAILS_ENV=test]
190
+ errors << 'Error running db:migrate RAILS_ENV=test in test app' unless $?.success?
191
+
192
+ #raise "Errors: #{errors.join("; ")}" unless errors.empty?
193
+
194
+ FileUtils.cd('../../')
195
+ end
196
+
197
+
198
+ task :set_test_host_path do
199
+ TEST_HOST_PATH = File.join(File.expand_path(File.dirname(__FILE__)),'..','tmp','test_app')
200
+ puts "Test app path:\n#{TEST_HOST_PATH}"
201
+ end
202
+
203
+ #
204
+ # Test
205
+ #
206
+
207
+ desc "Run tests against test app"
208
+ task :test => [:use_test_app] do
209
+
210
+ puts "Running rspec tests"
211
+ puts %x[bundle exec rake atrium:spec:rcov]
212
+ puts %x[bundle exec rake atrium:rspec:run]
213
+
214
+ puts "Running cucumber tests"
215
+ puts %x[bundle exec rake atrium:cucumber]
216
+
217
+ FileUtils.cd(File.expand_path(File.dirname(__FILE__)))
218
+ puts "Completed test suite"
219
+ end
220
+
221
+ namespace :test do
222
+
223
+ desc "run db:test:prepare in the test app"
224
+ task :prepare => :test_app_exists do
225
+ within_test_app do
226
+ %x[rake db:test:prepare]
227
+ end
228
+ end
229
+
230
+ desc "Make sure the test app is installed"
231
+ task :test_app_exists => [:set_test_host_path] do
232
+ Rake::Task['atrium:setup_test_app'].invoke unless File.exist?(TEST_HOST_PATH)
233
+ end
234
+
235
+ end
236
+
237
+ namespace :db do
238
+ desc "Seed the database with once/ and always/ fixtures."
239
+ task :seed => ["atrium:test:test_app_exists"] do
240
+ within_test_app do
241
+ puts %x[bundle exec rake db:seed RAILS_ENV=test]
242
+ end
243
+ end
244
+ end
245
+
246
+ desc "Make sure the test app is installed, then run the tasks from its root directory"
247
+ task :use_test_app => [:set_test_host_path] do
248
+ Rake::Task['atrium:setup_test_app'].invoke unless File.exist?(TEST_HOST_PATH)
249
+ FileUtils.cd(TEST_HOST_PATH)
250
+ end
251
+ end
252
+
253
+
254
+
255
+
256
+ # Adds the content to the file.
257
+ #
258
+ def replace!(destination, regexp, string)
259
+ content = File.binread(destination)
260
+ content.gsub!(regexp, string)
261
+ File.open(destination, 'wb') { |file| file.write(content) }
262
+ end
263
+
264
+ def within_test_app
265
+ FileUtils.cd(TEST_HOST_PATH)
266
+ yield
267
+ FileUtils.cd('../../')
268
+ end