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,185 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Atrium::CollectionsController do
4
+
5
+ describe '#determine_collection_id' do
6
+ it 'should return collection id from params id' do
7
+ controller.params[:id] = '1'
8
+ collection_id=controller.send(:determine_collection_id)
9
+ collection_id.should == '1'
10
+ end
11
+
12
+ it 'should return collection id from params collection id' do
13
+ controller.params[:collection_id] = '1'
14
+ collection_id=controller.send(:determine_collection_id)
15
+ collection_id.should == '1'
16
+ end
17
+
18
+ it 'return nil if collection id not available in params' do
19
+ collection_id=controller.send(:determine_collection_id)
20
+ collection_id.should == nil
21
+ end
22
+ end
23
+
24
+ before do
25
+ @collection = mock("atrium_collection")
26
+ Atrium::Collection.stubs(:find).with("1").returns(@collection)
27
+ controller.stubs(:current_layout).returns("atrium")
28
+ end
29
+
30
+ describe "Get New" do
31
+ it "build new collection form" do
32
+ controller.stubs(:initialize_collection).returns(@collection)
33
+ get :new
34
+ response.should redirect_to(edit_atrium_collection_path(:id=>1))
35
+ end
36
+ end
37
+
38
+ describe "POST create" do
39
+ it "redirects to the edit page" do
40
+ controller.stubs(:initialize_collection).returns(@collection)
41
+ post :create
42
+ response.code.should == "302"
43
+ response.should redirect_to(edit_atrium_collection_path(:id=>1))
44
+ end
45
+ end
46
+
47
+ #describe "Get home_page_text_config" do
48
+ # it "home_page_text_config" do
49
+ # get :home_page_text_config, { :id => "1" }
50
+ # pending
51
+ # end
52
+ #end
53
+
54
+ describe "Get Set Collection Scope" do
55
+ before do
56
+ session[:folder_document_ids]=[]
57
+ controller.stubs(:initialize_collection).returns(@collection)
58
+ end
59
+
60
+ it "set session documents to exhibit filter query params solr documents if present" do
61
+ @collection.stubs(:filter_query_params).returns(nil)
62
+ get :set_collection_scope, {:id => "1"}
63
+ response.should redirect_to(catalog_index_path)
64
+ end
65
+
66
+ it "set session documents to exhibit filter query params solr documents if present" do
67
+ @collection.stubs(:filter_query_params).returns({:solr_doc_ids=>"1,2,3"})
68
+ get :set_collection_scope, {:id => "1"}
69
+ session[:folder_document_ids] == ["1", "2", "3"]
70
+ end
71
+ end
72
+
73
+
74
+ describe "Get Unset Collection Scope" do
75
+ before do
76
+ session[:folder_document_ids]=[]
77
+ @exhibit = mock("atrium_exhibit")
78
+ Atrium::Exhibit.stubs(:new).returns(@exhibit)
79
+ @collection.expects(:update_attributes).returns(true)
80
+ controller.stubs(:initialize_collection).returns(@collection)
81
+ end
82
+
83
+ it "sets a flash[:notice] after removing scope of the collection" do
84
+ get :unset_collection_scope, {:id => "1"}
85
+ flash[:notice].should eq('Collection scope removed successfully')
86
+ end
87
+
88
+ it "redirects to the edit page" do
89
+ put :unset_collection_scope, {:id => "1"}
90
+ response.code.should == "200"
91
+ response.should render_template("edit")
92
+ end
93
+ end
94
+
95
+ describe "Get Edit" do
96
+ before do
97
+ @exhibit = mock("atrium_exhibit")
98
+ Atrium::Exhibit.stubs(:new).returns(@exhibit)
99
+ controller.stubs(:initialize_collection).returns(@collection)
100
+ end
101
+ it "build collection form for given collection id" do
102
+ get :edit, { :id => "1" }
103
+ response.should render_template 'layouts/atrium'
104
+ response.should render_template("edit")
105
+ end
106
+ end
107
+
108
+ describe "Put Update" do
109
+ before do
110
+ @exhibit = mock("atrium_exhibit")
111
+ Atrium::Exhibit.stubs(:new).returns(@exhibit)
112
+ controller.stubs(:get_exhibit_navigation_data).returns([])
113
+ controller.stubs(:initialize_collection).returns(@collection)
114
+ end
115
+ it "sets a flash[:notice] after successful update" do
116
+ @collection.expects(:update_attributes).returns(true)
117
+ put :update, {:id => "1", :atrium_collection =>{:title => "testing collection controller"}}
118
+ flash[:notice].should eq('Collection was successfully updated.')
119
+ end
120
+
121
+ it "redirects to the edit page" do
122
+ @collection.expects(:update_attributes).returns(true)
123
+ put :update, {:id => "1", :atrium_collection =>{:title => "testing collection controller"}}
124
+ response.code.should == "200"
125
+ response.should render_template("edit")
126
+ end
127
+
128
+ it "redirects to the edit page with error message" do
129
+ @collection.expects(:update_attributes).returns(false)
130
+ put :update, {:id => "1", :atrium_collection =>{:title => "testing collection controller"}}
131
+ flash[:notice].should_not eq('Collection was successfully updated.')
132
+ response.should render_template("edit")
133
+ end
134
+ end
135
+
136
+ describe "Get Show" do
137
+ before do
138
+ controller.stubs(:get_exhibit_navigation_data).returns([])
139
+ end
140
+ it "returns collection of the given collection id with template" do
141
+ Atrium::Showcase.expects(:with_selected_facets).returns([])
142
+ @collection.expects(:filter_query_params).returns(nil)
143
+ get :show, { :id => "1" }
144
+ response.should render_template 'layouts/atrium'
145
+ response.should render_template("show")
146
+ end
147
+
148
+ it "should return only items that are added through collection scope filter" do
149
+ @collection.stubs(:filter_query_params).returns({:solr_doc_ids=>"1,2,3"})
150
+ controller.expects(:get_solr_response_for_field_values).returns([])
151
+ assigns(:items_document_ids) == ["1", "2", "3"]
152
+ end
153
+
154
+ #it "should return any featured item added through showcase" do
155
+ # @showcase = mock("atrium_showcase")
156
+ # Atrium::Showcase.expects(:with_selected_facets).returns([@showcase])
157
+ # @collection.stubs(:filter_query_params).returns({:solr_doc_ids=>"1,2,3"})
158
+ # controller.expects(:get_solr_response_for_field_values).returns([])
159
+ # assigns(:items_document_ids) == ["1", "2", "3"]
160
+ #end
161
+ #
162
+ #it "should return any descriptions added through showcase" do
163
+ # pending
164
+ #end
165
+ end
166
+
167
+ describe "Delete" do
168
+ before do
169
+ @exhibit = mock("atrium_exhibit")
170
+ Atrium::Exhibit.stubs(:new).returns(@exhibit)
171
+ @collection.expects(:destroy).returns(true)
172
+ controller.stubs(:initialize_collection).returns(@collection)
173
+ end
174
+ it "destroy exhibit successfully" do
175
+ delete :destroy, { :id => "1" }
176
+ flash[:notice].should == "Collection deleted."
177
+ end
178
+
179
+ it "redirects to catalog index" do
180
+ delete :destroy, { :id => "1" }
181
+ response.should redirect_to(catalog_index_path)
182
+ end
183
+ end
184
+
185
+ end
@@ -0,0 +1,38 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Atrium::CustomizationController do
4
+
5
+ describe "Get start" do
6
+ before do
7
+ session[:edit_showcase]=true
8
+ end
9
+
10
+ it "should render html response" do
11
+ xhr :get, :start, :type=>"collection", :id=>"1"
12
+ response.should redirect_to(atrium_collection_path(:id=>1))
13
+ end
14
+
15
+ it "should render JSON of session" do
16
+ xhr :get, :start, :format=>"json"
17
+ response.body.should == session[:edit_showcase].to_json
18
+ end
19
+
20
+ end
21
+
22
+ describe "Get stop" do
23
+ before do
24
+ session[:edit_showcase]=nil
25
+ end
26
+ it "should render html response" do
27
+ xhr :get, :stop, :type=>"collection", :id=>"1"
28
+ response.should redirect_to(atrium_collection_path(:id=>1))
29
+ end
30
+
31
+ it "should render JSON of session" do
32
+ xhr :get, :stop, :format=>"json"
33
+ response.body.should == session[:edit_showcase].to_json
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,150 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Atrium::DescriptionsController do
4
+ before do
5
+ #Atrium::Description.stubs(:new).returns(@atrium_description)
6
+ @collection = Atrium::Collection.new
7
+ @collection.save
8
+ @collection_showcase = Atrium::Showcase.new(:showcases_id=>@collection.id, :showcases_type=>@collection.class.name)
9
+ @collection_showcase.save
10
+ controller.stubs(:initialize_collection).returns(@collection)
11
+ controller.stubs(:get_exhibit_navigation_data).returns([])
12
+ end
13
+
14
+ describe '#determine_collection_id' do
15
+ before do
16
+ @description = Atrium::Description.new(:atrium_showcase_id=>@collection_showcase.id)
17
+ @description.save
18
+ Atrium::Description.stubs(:find).with(1).returns(@description)
19
+ end
20
+ it 'should return collection id from params id' do
21
+ Atrium::Showcase.stubs(:find).with(1).returns(@collection_showcase)
22
+ @collection_showcase.stubs(:parent).returns(@collection)
23
+ controller.params[:id] = @description.id
24
+ collection_id=controller.send(:determine_collection_id)
25
+ collection_id.should == @collection.id
26
+ end
27
+
28
+ it 'return nil if exhibit id not available in params' do
29
+ collection_id=controller.send(:determine_collection_id)
30
+ collection_id.should == nil
31
+ end
32
+ end
33
+
34
+ describe "Get index" do
35
+ before do
36
+ @description = Atrium::Description.new(:atrium_showcase_id=>@collection_showcase.id)
37
+ @description.save
38
+ Atrium::Showcase.stubs(:find).with("1").returns(@collection_showcase)
39
+ #@collection_showcase.expects(:descriptions).returns([@description])
40
+ end
41
+ it "returns list of descriptions for given showcase" do
42
+ get :index, {:showcase_id => @collection_showcase.id}
43
+ response.should render_template 'layouts/atrium'
44
+ response.should render_template("index")
45
+ end
46
+ it "returns list of descriptions for given showcase without layout" do
47
+ get :index, {:showcase_id => @collection_showcase.id, :no_layout=>true}
48
+ puts "Res: #{response.body.inspect}"
49
+ response.should render_template("index")
50
+ end
51
+ end
52
+
53
+ describe "Get New" do
54
+ it "build new description form" do
55
+ get :new, {:showcase_id => @collection_showcase.id}
56
+ response.should render_template 'layouts/atrium'
57
+ response.should render_template("new")
58
+ end
59
+ end
60
+
61
+ describe "POST create" do
62
+ let(:@atrium_description) { mock_model(Atrium::Description) }
63
+ it "sets a flash[:notice] message" do
64
+ post :create, {:showcase_id => @collection_showcase.id,:atrium_description =>{:atrium_showcase_id => @collection_showcase.id}}
65
+ flash[:notice].should eq('Description was successfully created.')
66
+ end
67
+ it "redirects to the edit page" do
68
+ post :create, {:showcase_id => @collection_showcase.id,:atrium_description =>{:atrium_showcase_id => @collection_showcase.id}}
69
+ response.code.should == "302"
70
+ response.should redirect_to(edit_atrium_description_path(:id=>1))
71
+ end
72
+ it "create fails if showcase id not passed" do
73
+ threw_exception = false
74
+ begin
75
+ post :create
76
+ rescue
77
+ threw_exception = true
78
+ end
79
+ threw_exception.should == true
80
+ end
81
+ end
82
+
83
+ describe "Get Edit" do
84
+ before do
85
+ @description = mock()
86
+ @essay=mock()
87
+ @summary=mock()
88
+ Atrium::Description.stubs(:find).with("1").returns(@description)
89
+ @description.expects(:essay).returns(nil)
90
+ @description.expects(:summary).returns(nil)
91
+ @description.stubs(:build_essay).with(:content_type=>"essay").returns(@essay)
92
+ @description.stubs(:build_summary).with(:content_type=>"summary").returns(@summary)
93
+ end
94
+ it "returns description of the given description id" do
95
+ get :edit, { :id => "1" }
96
+ assigns[:atrium_description].should == @description
97
+ end
98
+ it "build description form for given description id" do
99
+ get :edit, { :id => "1" }
100
+ response.should render_template 'layouts/atrium'
101
+ response.should render_template("edit")
102
+ end
103
+ end
104
+
105
+ describe "Put Update" do
106
+ before do
107
+ @description = mock()
108
+ Atrium::Description.stubs(:find).with("1").returns(@description)
109
+ @description.stubs(:update_attributes).returns(true)
110
+ @description.expects(:essay).returns(nil)
111
+ end
112
+ it "sets a flash[:notice] message" do
113
+ put :update, {:id => "1", :atrium_description =>{:atrium_showcase_id => @collection_showcase.id}}
114
+ flash[:notice].should eq('Description was successfully updated.')
115
+ end
116
+ end
117
+
118
+ describe "Get Show" do
119
+ before do
120
+ @description = mock()
121
+ Atrium::Description.stubs(:find).with("1").returns(@description)
122
+ @description.expects(:description_solr_id).returns(nil)
123
+ end
124
+ it "returns description of the given description id" do
125
+ get :show, { :id => "1" }
126
+ response.should render_template 'layouts/atrium'
127
+ response.should render_template("show")
128
+ end
129
+
130
+ end
131
+
132
+ describe "Delete" do
133
+ before do
134
+ @description = mock()
135
+ Atrium::Description.stubs(:find).with("1").returns(@description)
136
+ end
137
+ it "returns description of the given description id" do
138
+ Atrium::Description.expects(:destroy).with("1").returns(true)
139
+ delete :destroy, { :id => "1" }
140
+ response.body.should == "Description 1 was deleted successfully."
141
+ end
142
+
143
+ end
144
+
145
+ describe "atrium_descriptions_add"
146
+
147
+
148
+ describe "atrium_descriptions_link"
149
+
150
+ end
@@ -0,0 +1,36 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Atrium::ExhibitFacetOrderController do
4
+
5
+ describe "Get index" do
6
+ it "returns facet order" do
7
+ mock_exhibit = mock("exhibit")
8
+ mock_facet_order = mock({})
9
+ Atrium::Exhibit.stubs(:find).with("1").returns(mock_exhibit)
10
+ mock_exhibit.expects("facet_order").returns(mock_facet_order)
11
+ get :index,{ :id=>"1"}
12
+ assigns[:facet_order].should == mock_facet_order
13
+ end
14
+
15
+ it "should render JSON of session" do
16
+ mock_exhibit = mock("exhibit")
17
+ Atrium::Exhibit.stubs(:find).with("1").returns(mock_exhibit)
18
+ mock_exhibit.expects("facet_order").returns({})
19
+ get :index,{ :id=>"1", :format=> "json"}
20
+ response.body.should == {}.to_json
21
+ end
22
+ end
23
+
24
+ describe "Post update" do
25
+ it "should render JSON of facet order after updating the facet order" do
26
+ mock_exhibit = mock("exhibit")
27
+ mock_facet_order = {"1"=>"2", "2"=>"3","3"=>"1"}
28
+ Atrium::Exhibit.stubs(:find).with("1").returns(mock_exhibit)
29
+ mock_exhibit.expects(:facet_order=).with({"3"=>"1", "2"=>"3", "1"=>"2"}).returns(mock_facet_order)
30
+ mock_exhibit.expects("facet_order").returns(mock_facet_order)
31
+ post :update,{ :id=>"1", :collection =>{"1"=>"2", "2"=>"3", "3"=>"1"}, :format=> "json"}
32
+ response.body.should == mock_facet_order.to_json
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,192 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Atrium::ExhibitsController do
4
+ before do
5
+ @collection = mock("atrium_collection")
6
+ controller.stubs(:initialize_collection).returns(@collection)
7
+ controller.stubs(:current_layout).returns("atrium")
8
+ end
9
+
10
+ describe '#determine_collection_id' do
11
+ it 'should return collection id from params id' do
12
+ exhibit = Atrium::Exhibit.new(:atrium_collection_id=>1)
13
+ Atrium::Exhibit.expects(:find).with("1").returns(exhibit)
14
+ controller.params[:id] = '1'
15
+ collection_id=controller.send(:determine_collection_id)
16
+ collection_id.should == 1
17
+ end
18
+
19
+ it 'return nil if exhibit id not available in params' do
20
+ collection_id=controller.send(:determine_collection_id)
21
+ collection_id.should == nil
22
+ end
23
+ end
24
+
25
+ describe "Get New" do
26
+ it "build new exhibit form" do
27
+ get :new
28
+ response.should render_template 'layouts/atrium'
29
+ response.should render_template("new")
30
+ end
31
+ end
32
+
33
+ describe "POST create" do
34
+ it "sets a flash[:notice] exhibit" do
35
+ @exhibit = mock("atrium_exhibit")
36
+ Atrium::Exhibit.stubs(:new).returns(@exhibit)
37
+ @exhibit.expects(:update_attributes).returns(true)
38
+ @exhibit.expects(:atrium_collection_id).returns(1)
39
+ post :create, {:atrium_exhibit =>{:atrium_collection_id => 1, :set_number=>1}}
40
+ flash[:notice].should eq('Exhibit was successfully created.')
41
+ end
42
+ it "redirects to the edit page" do
43
+ @exhibit = mock("atrium_exhibit")
44
+ Atrium::Exhibit.stubs(:new).returns(@exhibit)
45
+ @exhibit.expects(:update_attributes).returns(true)
46
+ @exhibit.expects(:atrium_collection_id).returns(1)
47
+ post :create, {:atrium_exhibit =>{:atrium_collection_id => 1, :set_number=>1}}
48
+ response.code.should == "302"
49
+ response.should redirect_to(edit_atrium_collection_path(:id=>1))
50
+ end
51
+ #it "create fails if collection id not passed" do
52
+ # threw_exception = false
53
+ # begin
54
+ # post :create
55
+ # rescue
56
+ # threw_exception = true
57
+ # end
58
+ # threw_exception.should == true
59
+ #end
60
+ end
61
+
62
+ describe "Get Edit" do
63
+ before do
64
+ @exhibit = mock("atrium_exhibit")
65
+ Atrium::Exhibit.stubs(:find).with("1").returns(@exhibit)
66
+ @exhibit.expects(:collection).returns(@collection)
67
+ controller.stubs(:get_exhibit_navigation_data).returns([])
68
+ end
69
+ it "returns exhibit of the given exhibit id" do
70
+ get :edit, { :id => "1" }
71
+ assigns[:exhibit].should == @exhibit
72
+ end
73
+ it "build exhibit form for given exhibit id" do
74
+ get :edit, { :id => "1" }
75
+ response.should render_template 'layouts/atrium'
76
+ response.should render_template("edit")
77
+ end
78
+ end
79
+
80
+ describe "Put Update" do
81
+ before do
82
+ @exhibit = mock("atrium_exhibit")
83
+ Atrium::Exhibit.stubs(:find).with("1").returns(@exhibit)
84
+ @exhibit.expects(:update_attributes).returns(true)
85
+ end
86
+ it "sets a flash[:notice] after successful update" do
87
+ put :update, {:id => "1", :atrium_exhibit =>{:atrium_collection_id => 1, :set_number=>1}}
88
+ flash[:notice].should eq('Exhibit was successfully updated.')
89
+ end
90
+
91
+ it "redirects to the edit page" do
92
+ put :update, {:id => "1", :atrium_exhibit =>{:atrium_collection_id => 1, :set_number=>1}}
93
+ response.code.should == "302"
94
+ response.should redirect_to(edit_atrium_exhibit_path(:id=>1))
95
+ end
96
+ end
97
+
98
+ describe "Get Show" do
99
+ before do
100
+ @exhibit = mock("atrium_exhibit")
101
+ Atrium::Exhibit.stubs(:find).with("1").returns(@exhibit)
102
+ controller.stubs(:get_all_children).returns([])
103
+ controller.stubs(:get_exhibit_navigation_data).returns([])
104
+ @exhibit.expects(:filter_query_params).returns(nil)
105
+ end
106
+ it "returns exhibit of the given exhibit id with template" do
107
+ Atrium::Showcase.expects(:with_selected_facets).returns([])
108
+ get :show, { :id => "1" }
109
+ response.should render_template 'layouts/atrium'
110
+ response.should render_template("show")
111
+ end
112
+
113
+ it "returns exhibit of the given exhibit id without template" do
114
+ Atrium::Showcase.expects(:with_selected_facets).returns([])
115
+ get :show, { :id => "1", :no_layout=>true }
116
+ response.should_not render_template 'layouts/atrium'
117
+ response.should render_template("show")
118
+ end
119
+
120
+ it "should return only items that are through exhibit scope filter" do
121
+ pending
122
+ end
123
+
124
+ it "should return any featured item added through showcase" do
125
+ pending
126
+ end
127
+
128
+ it "should return any descriptions added through showcase" do
129
+ pending
130
+ end
131
+ end
132
+
133
+ describe "Get Set Exhibit Scope" do
134
+ before do
135
+ session[:folder_document_ids]=[]
136
+ @exhibit = mock("atrium_exhibit")
137
+ Atrium::Exhibit.stubs(:find).with("1").returns(@exhibit)
138
+ end
139
+
140
+ it "set session documents to exhibit filter query params solr documents if present" do
141
+ @exhibit.stubs(:filter_query_params).returns(nil)
142
+ get :set_exhibit_scope, {:id => "1"}
143
+ response.should redirect_to(catalog_index_path)
144
+ end
145
+
146
+ it "set session documents to exhibit filter query params solr documents if present" do
147
+ @exhibit.stubs(:filter_query_params).returns({:solr_doc_ids=>"1,2,3"})
148
+ get :set_exhibit_scope, {:id => "1"}
149
+ session[:folder_document_ids] == ["1", "2", "3"]
150
+ end
151
+ end
152
+
153
+
154
+ describe "Get Unset Exhibit Scope" do
155
+ before do
156
+ session[:folder_document_ids]=[]
157
+ @exhibit = mock("atrium_exhibit")
158
+ Atrium::Exhibit.stubs(:find).with("1").returns(@exhibit)
159
+ @exhibit.expects(:update_attributes).returns(true)
160
+ end
161
+
162
+ it "sets a flash[:notice] after removing scope of the exhibit update" do
163
+ get :unset_exhibit_scope, {:id => "1"}
164
+ flash[:notice].should eq('Exhibit scope removed successfully')
165
+ end
166
+
167
+ it "redirects to the edit page" do
168
+ put :unset_exhibit_scope, {:id => "1"}
169
+ response.code.should == "200"
170
+ response.should render_template("edit")
171
+ end
172
+ end
173
+
174
+ describe "Delete" do
175
+ before do
176
+ @exhibit = mock("atrium_exhibit")
177
+ Atrium::Exhibit.stubs(:find).with("1").returns(@exhibit)
178
+ Atrium::Exhibit.expects(:destroy).with("1").returns(true)
179
+ @exhibit.expects(:atrium_collection_id).returns(1)
180
+ end
181
+ it "destroy exhibit successfully" do
182
+ delete :destroy, { :id => "1" }
183
+ flash[:notice].should == "Exhibit 1 was deleted successfully."
184
+ end
185
+
186
+ it "redirects to collection edit page" do
187
+ delete :destroy, { :id => "1" }
188
+ response.should redirect_to(edit_atrium_collection_path(:id=>1))
189
+ end
190
+
191
+ end
192
+ end