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,31 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Atrium::BrowseLevel do
4
+ Given (:browse_level) { Atrium::BrowseLevel.new }
5
+
6
+ it { should belong_to :exhibit }
7
+
8
+ it { should be_accessible :filter_query_params }
9
+
10
+ it { should be_accessible :label }
11
+
12
+ it { should be_accessible :level_number }
13
+ it { should validate_presence_of :level_number }
14
+
15
+ it { should be_accessible :solr_facet_name }
16
+ it { should validate_presence_of :solr_facet_name }
17
+
18
+ it { should respond_to :selected }
19
+ it { should respond_to :selected= }
20
+
21
+ context '#values' do
22
+ Then { browse_level.values.should be_kind_of Enumerable }
23
+ end
24
+
25
+ describe '#to_s' do
26
+ Given(:comparison_string) { 'Hello'}
27
+ When { browse_level.solr_facet_name = comparison_string }
28
+ Then { browse_level.to_s.should == comparison_string }
29
+ end
30
+
31
+ end
@@ -0,0 +1,30 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Atrium::Collection do
4
+ Given(:collection) { Atrium::Collection.new }
5
+ it { should have_many :showcases }
6
+ it { should have_many :search_facets }
7
+ it { should have_many :exhibits }
8
+
9
+ context "#theme_path" do
10
+ context 'default value' do
11
+ Then { collection.theme_path.should == "atrium_themes/default" }
12
+ end
13
+ context 'set value' do
14
+ Given(:theme_name) { 'chunky_bacon' }
15
+ When { collection.theme = theme_name }
16
+ Then { collection.theme_path.should == "atrium_themes/#{theme_name}" }
17
+ end
18
+ end
19
+
20
+ context "#display_title" do
21
+ context 'default value' do
22
+ Then { collection.display_title.should == "<h2>#{subject.pretty_title}</h2>" }
23
+ end
24
+ context 'set value' do
25
+ Given(:title_markup_to_use) { '<h2>Saving <em>the World</em></h2>' }
26
+ When { collection.title_markup = title_markup_to_use }
27
+ Then { collection.display_title.should == title_markup_to_use }
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,67 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Atrium::Description do
4
+ before(:each) do
5
+ @collection = Atrium::Collection.new
6
+ @collection.save
7
+ #@exhibit = Atrium::Exhibit.new(:atrium_collection_id=>@collection.id,:set_number=>1)
8
+ #@exhibit.save
9
+ @showcase = Atrium::Showcase.new(:showcases_id=>@collection.id, :showcases_type=>@collection.class.name)
10
+ @showcase.save
11
+ @description = Atrium::Description.new(:atrium_showcase_id=>@showcase.id)
12
+ @description.save!
13
+ end
14
+
15
+ after(:each) do
16
+ begin
17
+ @description.delete
18
+ @showcase.delete
19
+ @collection.delete
20
+ rescue
21
+ end
22
+ end
23
+
24
+ describe "#descriptions" do
25
+ it "should throw exception if try to create without showcase id" do
26
+ threw_exception = false
27
+ begin
28
+ description=Atrium::Description.new
29
+ description.save!
30
+ rescue
31
+ threw_exception = true
32
+ end
33
+ threw_exception.should == true
34
+ end
35
+
36
+ it "should be able to delete an existing description" do
37
+ Atrium::Description.destroy(@description.id)
38
+ end
39
+ end
40
+
41
+
42
+ describe "#descriptions from solr description" do
43
+ it "should be able to create new description with solr id" do
44
+ pending
45
+ end
46
+ end
47
+
48
+ describe "#summary" do
49
+ it "should be able to create summary" do
50
+ pending
51
+ end
52
+ it "should be able to retrieve summary" do
53
+ pending
54
+ end
55
+ end
56
+
57
+ describe "#essay" do
58
+ it "should be able to create essay" do
59
+ pending
60
+ end
61
+ it "should be able to retrieve essay" do
62
+ pending
63
+ end
64
+ end
65
+
66
+
67
+ end
@@ -0,0 +1,12 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Atrium::Essay do
4
+
5
+ it { should belong_to :description }
6
+
7
+ it { should be_accessible :content }
8
+ it { should be_accessible :content_type }
9
+
10
+ it { should validate_presence_of :atrium_description_id }
11
+
12
+ end
@@ -0,0 +1,76 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Atrium::Exhibit do
4
+ subject { Atrium::Exhibit.new }
5
+
6
+ it { should be_accessible :label }
7
+
8
+ it { should belong_to :collection }
9
+
10
+ it { should have_many :showcases }
11
+
12
+ it { should have_many :browse_levels }
13
+
14
+ context '#pretty_title' do
15
+ Given(:collection) { Atrium::Exhibit.new }
16
+ Given(:set_number) { 1234 }
17
+ When { collection.set_number = set_number }
18
+ When { collection.label = label }
19
+ context 'default' do
20
+ Given(:label) { '' }
21
+ Then { collection.pretty_title.should == "Exhibit #{set_number}" }
22
+ end
23
+
24
+ context 'overwritten' do
25
+ Given(:label) { 'Hello World'}
26
+ Then { collection.pretty_title.should == label }
27
+ end
28
+ end
29
+
30
+
31
+ context 'with database' do
32
+ before(:each) do
33
+ @collection = Atrium::Collection.new
34
+ @collection.save
35
+ @exhibit = Atrium::Exhibit.new(:atrium_collection_id=>@collection.id,:set_number=>1)
36
+ @exhibit.save
37
+ end
38
+
39
+ after(:each) do
40
+ @exhibit.delete
41
+ @collection.delete
42
+ end
43
+
44
+ describe "browse_facet_names" do
45
+ it "should return an array of browse facet names" do
46
+ @exhibit.browse_levels.create({:solr_facet_name=>"my_facet_1",:label=>"My Category",:level_number=>1})
47
+ @exhibit.browse_levels.create({:solr_facet_name=>"my_facet_2",:label=>"",:level_number=>2})
48
+ @exhibit.browse_facet_names.size.should == 2
49
+ @exhibit.browse_facet_names.include?("my_facet_1").should == true
50
+ @exhibit.browse_facet_names.include?("my_facet_2").should == true
51
+ end
52
+
53
+ it "should remove associated showcases if a browse facet removed" do
54
+ pending "need to test that associated showcases are removed if a browse facet is removed..."
55
+ end
56
+
57
+ it "if no browse facets defined it should return an empty array" do
58
+ @exhibit.browse_facet_names.should == []
59
+ end
60
+ end
61
+
62
+ describe "browse_levels" do
63
+ it "should return array of levels used in browsing" do
64
+ @exhibit.browse_levels.create({:solr_facet_name=>"my_facet_1",:label=>"My Category",:level_number=>1})
65
+ @exhibit.browse_levels.create({:solr_facet_name=>"my_facet_2",:label=>"",:level_number=>2})
66
+ (@exhibit.browse_levels.collect {|x| x.solr_facet_name}).should == ["my_facet_1","my_facet_2"]
67
+ end
68
+
69
+ it "should return browse levels sorted by level number" do
70
+ @exhibit.browse_levels.create({:solr_facet_name=>"my_facet_1",:label=>"My Category",:level_number=>2})
71
+ @exhibit.browse_levels.create({:solr_facet_name=>"my_facet_2",:label=>"",:level_number=>1})
72
+ (@exhibit.browse_levels.collect {|x| x.solr_facet_name}).should == ["my_facet_2","my_facet_1"]
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,24 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
2
+
3
+ describe Atrium::Search::FacetSelection do
4
+ subject { Atrium::Search::FacetSelection.new(field_name)}
5
+ let(:field_name) { 'frodo-baggins' }
6
+
7
+ describe "#label" do
8
+ it 'should retrieve from facet_configuration' do
9
+ subject.
10
+ expects(:facet_configuration).
11
+ returns({
12
+ :label => 'Publication Year'
13
+ })
14
+ subject.label.should == 'Publication Year'
15
+ end
16
+ end
17
+
18
+ describe "#lable without without Dependency Injection replacement" do
19
+ let(:field_name) { 'pub_date' }
20
+ it 'should retrieve when found' do
21
+ subject.label.should == 'Publication Year'
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
2
+
3
+ describe Atrium::Search::Facet do
4
+ it { should belong_to :collection }
5
+
6
+ it { should validate_presence_of :atrium_collection_id }
7
+ it { should be_accessible :atrium_collection_id }
8
+
9
+ it { should validate_presence_of :name }
10
+ it { should be_accessible :name }
11
+ end
@@ -0,0 +1,54 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Atrium::Search::Facet do
4
+ before(:each) do
5
+ @collection = Atrium::Collection.new
6
+ @collection.save
7
+ @filter_facet = Atrium::Search::Facet.new({:atrium_collection_id=>@collection.id,:name=>"my_facet"})
8
+ @filter_facet.save
9
+ end
10
+
11
+ after(:each) do
12
+ @filter_facet.delete
13
+ @collection.delete
14
+ begin
15
+ @fail_facet.delete
16
+ rescue
17
+ end
18
+ end
19
+
20
+ describe "#name" do
21
+ it "should return correct name if set" do
22
+ @filter_facet.name = "my_facet"
23
+ @filter_facet.name.should == "my_facet"
24
+ end
25
+
26
+ it "name must be defined" do
27
+ @fail_facet = Atrium::Search::Facet.new({:atrium_collection_id=>@collection.id})
28
+ threw_exception = false
29
+ begin
30
+ @fail_facet.save!
31
+ rescue
32
+ threw_exception = true
33
+ end
34
+ threw_exception.should == true
35
+ end
36
+ end
37
+
38
+ describe "#atrium_collection" do
39
+ it "atrium collection cannot be null" do
40
+ @fail_facet = Atrium::Search::Facet.new({:name=>"my_facet"})
41
+ threw_exception = false
42
+ begin
43
+ @fail_facet.save!
44
+ rescue
45
+ threw_exception = true
46
+ end
47
+ threw_exception.should == true
48
+ end
49
+
50
+ it "atrium collection should be correct" do
51
+ @filter_facet.collection.should == @collection
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
2
+
3
+ describe Atrium::Showcase::FacetSelection do
4
+
5
+ it { should belong_to :showcase }
6
+
7
+ it { should validate_presence_of :value }
8
+ it { should be_accessible :value }
9
+
10
+ it { should validate_presence_of :atrium_showcase_id }
11
+
12
+ it { should validate_presence_of :solr_facet_name }
13
+ it { should be_accessible :solr_facet_name }
14
+
15
+ end
@@ -0,0 +1,12 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
2
+
3
+ describe Atrium::Showcase::Item do
4
+
5
+ it { should belong_to :showcase }
6
+
7
+ it { should be_accessible :type }
8
+
9
+ it { should validate_presence_of :atrium_showcase_id }
10
+
11
+ it { should validate_presence_of :solr_doc_id }
12
+ end
@@ -0,0 +1,65 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Atrium::Showcase::FacetSelection do
4
+ before(:each) do
5
+ @showcase = Atrium::Showcase.new
6
+ @showcase.save
7
+ @facet_selection = Atrium::Showcase::FacetSelection.new({:atrium_showcase_id=>@showcase.id, :value=>"connecticut", :solr_facet_name=>"publisher_facet"})
8
+ end
9
+
10
+ after(:each) do
11
+ @facet_selection.delete
12
+ @showcase.delete
13
+ begin
14
+ @fail_facet_selection.delete
15
+ rescue
16
+ end
17
+ end
18
+
19
+ describe "#value" do
20
+ it "value cannot be nil" do
21
+ @fail_facet_selection = Atrium::Showcase::FacetSelection.new({:atrium_showcase_id=>@showcase.id,:solr_facet_name=>"my_facet"})
22
+ threw_exception = false
23
+ begin
24
+ @fail_facet_selection.save!
25
+ rescue
26
+ threw_exception = true
27
+ end
28
+ threw_exception.should == true
29
+ end
30
+
31
+ it "should return the correct value if set" do
32
+ @facet_selection.value.should == "connecticut"
33
+ end
34
+ end
35
+
36
+ describe "#solr_facet_name" do
37
+ it "facet cannot be null" do
38
+ @fail_facet_selection = Atrium::Showcase::FacetSelection.new({:atrium_showcase_id=>@showcase.id})
39
+ threw_exception = false
40
+ begin
41
+ @fail_facet_selection.save!
42
+ rescue
43
+ threw_exception = true
44
+ end
45
+ threw_exception.should == true
46
+ end
47
+
48
+ it "should return the correct value if set" do
49
+ @facet_selection.solr_facet_name.should == "publisher_facet"
50
+ end
51
+ end
52
+
53
+ describe "#showcase" do
54
+ it "showcase cannot be null" do
55
+ @fail_facet_selection = Atrium::Showcase::FacetSelection.new({:solr_facet_name=>"my_facet"})
56
+ threw_exception = false
57
+ begin
58
+ @fail_facet_selection.save!
59
+ rescue
60
+ threw_exception = true
61
+ end
62
+ threw_exception.should == true
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,134 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Atrium::Showcase do
4
+ before(:each) do
5
+ @collection = Atrium::Collection.new
6
+ @collection.save
7
+ @exhibit = Atrium::Exhibit.new(:atrium_collection_id=>@collection.id,:set_number=>1)
8
+ @exhibit.save
9
+ @collection_showcase = Atrium::Showcase.new(:showcases_id=>@collection.id, :showcases_type=>@collection.class.name)
10
+ @collection_showcase.save
11
+ @exhibit_showcase = Atrium::Showcase.new(:showcases_id=>@exhibit.id, :showcases_type=>@exhibit.class.name)
12
+ @exhibit_showcase.save
13
+ end
14
+
15
+ after(:each) do
16
+ @collection_showcase.delete
17
+ @collection.delete
18
+ @exhibit_showcase.delete
19
+ @exhibit.delete
20
+ begin
21
+ @item.delete
22
+ rescue
23
+ end
24
+ begin
25
+ @fail_showcase.delete
26
+ rescue
27
+ end
28
+ begin
29
+ @showcase2.delete
30
+ rescue
31
+ end
32
+ begin
33
+ @exhibit2.delete
34
+ rescue
35
+ end
36
+ begin
37
+ @facet_selection.delete
38
+ rescue
39
+ end
40
+ begin
41
+ @facet_selection2.delete
42
+ rescue
43
+ end
44
+ end
45
+
46
+ describe "#featured_items" do
47
+ it "should throw exception if try to create without solr_doc_id" do
48
+ threw_exception = false
49
+ begin
50
+ @showcase.featured_items.create
51
+ @showcase.save!
52
+ rescue
53
+ threw_exception = true
54
+ end
55
+ threw_exception.should == true
56
+ end
57
+
58
+ it "should be able to add featured item" do
59
+ @showcase = Atrium::Showcase.new(:showcases_id=>@collection.id, :showcases_type=>@collection.class.name)
60
+ @showcase.save!
61
+ @showcase.showcase_items[:type]="featured"
62
+ @showcase.showcase_items[:solr_doc_ids]="item1, item2, item3"
63
+ @showcase.save
64
+ @showcase.showcase_items[:solr_doc_ids].should == "item1, item2, item3"
65
+ @showcase.showcase_items[:solr_doc_ids].split(',').first.should == "item1"
66
+ end
67
+ end
68
+
69
+ describe "#parent" do
70
+ it "should return correct parent" do
71
+ @exhibit_showcase.parent.should == @exhibit
72
+ end
73
+ end
74
+
75
+ describe "#initialize" do
76
+ it "should allow no facet selections defined" do
77
+ @collection = Atrium::Collection.new
78
+ @collection.save
79
+ @showcase = Atrium::Showcase.new(:showcases_id=>@collection.id, :showcases_type=>@collection.class.name)
80
+ @showcase.save!
81
+ @showcase.facet_selections.should == []
82
+ end
83
+ end
84
+
85
+ describe "#with_selected_facets" do
86
+ it "should return correct showcase with no facets selected" do
87
+ @showcase2 = Atrium::Showcase.new({:showcases_id=>@exhibit.id, :showcases_type=>@exhibit.class.name})
88
+ @showcase2.save!
89
+ @facet_selection2 = @showcase2.facet_selections.create({:solr_facet_name=>"my_facet2",:value=>"testing2"})
90
+ Atrium::Showcase.with_selected_facets(@exhibit.id).first.should == @showcase
91
+ end
92
+
93
+ it "should return correct showcase with one facet selected" do
94
+ @showcase = Atrium::Showcase.new({:showcases_id=>@exhibit.id, :showcases_type=>@exhibit.class.name})
95
+ @showcase.save!
96
+ @facet_selection = @showcase.facet_selections.create({:solr_facet_name=>"my_facet",:value=>"testing"})
97
+ @showcase.save!
98
+ Atrium::Showcase.with_selected_facets(@exhibit.id, @exhibit.class.name, {@facet_selection.solr_facet_name=>@facet_selection.value}).first.should == @showcase
99
+ end
100
+
101
+ it "should return correct showcase with one facet selected but a showcase exists with same facet plus another" do
102
+ @showcase = Atrium::Showcase.new({:showcases_id=>@exhibit.id, :showcases_type=>@exhibit.class.name})
103
+ @showcase.save!
104
+ @facet_selection = @showcase.facet_selections.create({:solr_facet_name=>"my_facet",:value=>"testing"})
105
+ @showcase.save!
106
+ @showcase2 = Atrium::Showcase.new({:showcases_id=>@exhibit.id, :showcases_type=>@exhibit.class.name})
107
+ @showcase2.save!
108
+ @facet_selection2 = @showcase2.facet_selections.create({:solr_facet_name=>"my_facet2",:value=>"testing2"})
109
+ Atrium::Showcase.with_selected_facets(@exhibit.id, @exhibit.class.name, {@facet_selection.solr_facet_name=>@facet_selection.value}).first.should == @showcase
110
+ end
111
+
112
+ it "should return correct showcase with two facets selected" do
113
+ @showcase = Atrium::Showcase.new({:showcases_id=>@exhibit.id, :showcases_type=>@exhibit.class.name})
114
+ @showcase.save!
115
+ @facet_selection = @showcase.facet_selections.create({:solr_facet_name=>"my_facet",:value=>"testing"})
116
+ @facet_selection2 = @showcase.facet_selections.create({:solr_facet_name=>"my_facet2",:value=>"testing2"})
117
+ @showcase.save!
118
+ Atrium::Showcase.with_selected_facets(@exhibit.id, @exhibit.class.name, {@facet_selection2.solr_facet_name=>@facet_selection2.value,
119
+ @facet_selection.solr_facet_name=>@facet_selection.value}).first.should == @showcase
120
+ end
121
+
122
+ it "should return correct showcase with same facet selections but different exhibit" do
123
+ @showcase = Atrium::Showcase.new({:showcases_id=>@exhibit.id, :showcases_type=>@exhibit.class.name})
124
+ @showcase.save!
125
+ @facet_selection = @showcase.facet_selections.create({:solr_facet_name=>"my_facet",:value=>"testing"})
126
+ @exhibit2 = Atrium::Exhibit.new(:atrium_collection_id=>@collection.id,:set_number=>2)
127
+ @exhibit2.save!
128
+ @showcase2 = Atrium::Showcase.new({:showcases_id=>@exhibit2.id, :showcases_type=>@exhibit2.class.name})
129
+ @showcase2.save!
130
+ @facet_selection2 = @showcase2.facet_selections.create({:solr_facet_name=>"my_facet",:value=>"testing"})
131
+ Atrium::Showcase.with_selected_facets(@exhibit2.id,@exhibit2.class.name, {@facet_selection2.solr_facet_name=>@facet_selection2.value}).first.should == @showcase2
132
+ end
133
+ end
134
+ end