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.
- data/.gitignore +13 -0
- data/.gitmodules +3 -0
- data/.rvmrc +32 -0
- data/GETTING_STARTED.textile +109 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +320 -0
- data/Guardfile +10 -0
- data/README.mkd +56 -0
- data/Rakefile +6 -0
- data/app/assets/images/atrium/ajax-loader.gif +0 -0
- data/app/assets/images/atrium/lightbox-ico-loading.gif +0 -0
- data/app/assets/images/atrium/logo.png +0 -0
- data/app/assets/javascripts/atrium/atrium.js +281 -0
- data/app/assets/javascripts/chosen.jquery.js +899 -0
- data/app/assets/javascripts/ckeditor.warning.js +65 -0
- data/app/assets/javascripts/ckeditor/config.js.coffee +6 -0
- data/app/assets/javascripts/ckeditor/jquery.generateId.js +13 -0
- data/app/assets/javascripts/ckeditor/jquery.jeditable.ckeditor.js +59 -0
- data/app/assets/javascripts/ckeditor/plugins/linkItem/application_link.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/linkItem/dialogs/linkItem.js +1470 -0
- data/app/assets/javascripts/ckeditor/plugins/linkItem/plugin.js +16 -0
- data/app/assets/javascripts/ckeditor/plugins/linkItem/ui_toolbar_pencil.png +0 -0
- data/app/assets/javascripts/jquery.colorbox.js +864 -0
- data/app/assets/javascripts/jquery.jeditable.js +543 -0
- data/app/assets/stylesheets/atrium/atrium.css +216 -0
- data/app/assets/stylesheets/atrium/chosen-sprite.png +0 -0
- data/app/assets/stylesheets/atrium/chosen.css +367 -0
- data/app/assets/stylesheets/colorbox.css +42 -0
- data/app/assets/stylesheets/controls.png +0 -0
- data/app/assets/stylesheets/loading.gif +0 -0
- data/app/controllers/atrium/base_controller.rb +25 -0
- data/app/controllers/atrium/collection_exhibit_order_controller.rb +21 -0
- data/app/controllers/atrium/collections_controller.rb +165 -0
- data/app/controllers/atrium/customization_controller.rb +41 -0
- data/app/controllers/atrium/descriptions_controller.rb +177 -0
- data/app/controllers/atrium/exhibit_facet_order_controller.rb +19 -0
- data/app/controllers/atrium/exhibits_controller.rb +108 -0
- data/app/controllers/atrium/showcases_controller.rb +193 -0
- data/app/helpers/atrium/base_helper.rb +6 -0
- data/app/models/ability.rb +14 -0
- data/app/models/atrium/browse_level.rb +41 -0
- data/app/models/atrium/collection.rb +121 -0
- data/app/models/atrium/description.rb +128 -0
- data/app/models/atrium/essay.rb +21 -0
- data/app/models/atrium/exhibit.rb +58 -0
- data/app/models/atrium/search/facet.rb +29 -0
- data/app/models/atrium/search/facet_selection.rb +17 -0
- data/app/models/atrium/showcase.rb +173 -0
- data/app/models/atrium/showcase/facet_selection.rb +21 -0
- data/app/models/atrium/showcase/item.rb +19 -0
- data/app/models/role_mapper.rb +23 -0
- data/app/views/_user_util_links.html.erb +25 -0
- data/app/views/atrium/collections/_bookmark_control.html.erb +25 -0
- data/app/views/atrium/collections/_browse_index.html.erb +20 -0
- data/app/views/atrium/collections/_collection_items_index.html.erb +10 -0
- data/app/views/atrium/collections/_document.html.erb +24 -0
- data/app/views/atrium/collections/_document_list.html.erb +6 -0
- data/app/views/atrium/collections/_edit_navigation.html.erb +20 -0
- data/app/views/atrium/collections/_folder_control.html.erb +12 -0
- data/app/views/atrium/collections/_form.html.erb +93 -0
- data/app/views/atrium/collections/_listing.html.erb +18 -0
- data/app/views/atrium/collections/_navigation.html.erb +45 -0
- data/app/views/atrium/collections/_results_pagination.html.erb +9 -0
- data/app/views/atrium/collections/_sort_and_per_page.html.erb +23 -0
- data/app/views/atrium/collections/edit.html.erb +5 -0
- data/app/views/atrium/collections/new.html.erb +6 -0
- data/app/views/atrium/collections/show.html.erb +22 -0
- data/app/views/atrium/descriptions/_form.html.erb +64 -0
- data/app/views/atrium/descriptions/edit.html.erb +4 -0
- data/app/views/atrium/descriptions/index.html.erb +4 -0
- data/app/views/atrium/descriptions/new.html.erb +2 -0
- data/app/views/atrium/descriptions/show.html.erb +20 -0
- data/app/views/atrium/exhibits/_bookmark_control.html.erb +25 -0
- data/app/views/atrium/exhibits/_folder_control.html.erb +12 -0
- data/app/views/atrium/exhibits/_form.html.erb +108 -0
- data/app/views/atrium/exhibits/edit.html.erb +9 -0
- data/app/views/atrium/exhibits/new.html.erb +6 -0
- data/app/views/atrium/exhibits/show.html.erb +26 -0
- data/app/views/atrium/showcases/_showcase_navigation.html.erb +23 -0
- data/app/views/atrium/showcases/show.html.erb +1 -0
- data/app/views/catalog/_collection_home_text.html.erb +6 -0
- data/app/views/catalog/_constraints.html.erb +9 -0
- data/app/views/catalog/_default_collection_text.html.erb +18 -0
- data/app/views/catalog/_default_home_text.html.erb +6 -0
- data/app/views/catalog/_home_text.html.erb +6 -0
- data/app/views/catalog/_index_partials/_description.html.erb +8 -0
- data/app/views/catalog/_search_form.html.erb +66 -0
- data/app/views/catalog/_show_partials/_description.html.erb +15 -0
- data/app/views/catalog/browse_show.html.erb +18 -0
- data/app/views/catalog/index.html.erb +35 -0
- data/app/views/catalog/list_description.html.erb +24 -0
- data/app/views/catalog/list_item.html.erb +3 -0
- data/app/views/layouts/atrium.html.erb +86 -0
- data/app/views/layouts/atrium_themes/default.html.erb +4 -0
- data/app/views/layouts/item_listing.html.erb +36 -0
- data/app/views/listing/_document.html.erb +27 -0
- data/app/views/listing/_document_list.html.erb +3 -0
- data/app/views/listing/_item_search.html.erb +27 -0
- data/app/views/shared/_banner.html.erb +5 -0
- data/app/views/shared/_collection_complete_list.html.erb +33 -0
- data/app/views/shared/_collection_search_form.html.erb +12 -0
- data/app/views/shared/_collection_title_header.html.erb +3 -0
- data/app/views/shared/_featured_sources.html.erb +20 -0
- data/app/views/shared/_list_descriptions.html.erb +38 -0
- data/app/views/shared/_navigation_browse_levels.html.erb +34 -0
- data/app/views/shared/_showcase_configure_menu.html.erb +22 -0
- data/app/views/shared/_top_navigation.html.erb +9 -0
- data/atrium.gemspec +76 -0
- data/config/routes.rb +12 -0
- data/init.rb +3 -0
- data/lib/application_controller.rb +24 -0
- data/lib/atrium.rb +42 -0
- data/lib/atrium/application_helper.rb +24 -0
- data/lib/atrium/atrium_helper_behavior.rb +162 -0
- data/lib/atrium/catalog.rb +203 -0
- data/lib/atrium/collections_helper.rb +139 -0
- data/lib/atrium/controller.rb +10 -0
- data/lib/atrium/descriptions_helper.rb +23 -0
- data/lib/atrium/engine.rb +12 -0
- data/lib/atrium/layout_helper.rb +13 -0
- data/lib/atrium/routes.rb +99 -0
- data/lib/atrium/solr_helper.rb +440 -0
- data/lib/atrium/version.rb +3 -0
- data/lib/generators/atrium/assets_generator.rb +44 -0
- data/lib/generators/atrium/atrium_generator.rb +149 -0
- data/lib/generators/atrium/cucumber_support_generator.rb +29 -0
- data/lib/generators/atrium/templates/config/role_map_cucumber.yml +2 -0
- data/lib/generators/atrium/templates/config/role_map_development.yml +2 -0
- data/lib/generators/atrium/templates/config/role_map_production.yml +2 -0
- data/lib/generators/atrium/templates/config/role_map_test.yml +2 -0
- data/lib/generators/atrium/templates/config/solr.yml +10 -0
- data/lib/generators/atrium/templates/db/seeds.rb +87 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_browse_levels.rb +18 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_collections.rb +20 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_descriptions.rb +16 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_essays.rb +15 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_exhibits.rb +16 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_search_facets.rb +14 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_showcase_facet_selections.rb +15 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_showcase_items.rb +17 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_showcases.rb +16 -0
- data/lib/generators/atrium/templates/themes/example.html.erb +21 -0
- data/lib/railties/all_tests.rake +23 -0
- data/lib/railties/atrium_cucumber.rake +121 -0
- data/lib/railties/index.rake +37 -0
- data/tasks/atrium.rake +268 -0
- data/tasks/atrium_rspec.rake +91 -0
- data/test_support/etc/Gemfile +33 -0
- data/test_support/etc/bundle_config +3 -0
- data/test_support/etc/rvmrc +32 -0
- data/test_support/features/atrium_collections.feature +162 -0
- data/test_support/features/atrium_exhibits.feature +164 -0
- data/test_support/features/step_definitions/atrium_collection_steps.rb +102 -0
- data/test_support/features/step_definitions/atrium_exhibit_steps.rb +53 -0
- data/test_support/features/step_definitions/bookmarks_steps.rb +6 -0
- data/test_support/features/step_definitions/error_steps.rb +5 -0
- data/test_support/features/step_definitions/folder_steps.rb +27 -0
- data/test_support/features/step_definitions/general_steps.rb +50 -0
- data/test_support/features/step_definitions/record_view_steps.rb +12 -0
- data/test_support/features/step_definitions/saved_searches_steps.rb +22 -0
- data/test_support/features/step_definitions/search_facets_steps.rb +29 -0
- data/test_support/features/step_definitions/search_history_steps.rb +9 -0
- data/test_support/features/step_definitions/search_result_steps.rb +114 -0
- data/test_support/features/step_definitions/search_steps.rb +103 -0
- data/test_support/features/step_definitions/user_steps.rb +5 -0
- data/test_support/features/step_definitions/web_steps.rb +213 -0
- data/test_support/features/support/env.rb +67 -0
- data/test_support/features/support/paths.rb +76 -0
- data/test_support/features/support/selectors.rb +40 -0
- data/test_support/fixtures/atrium_exhibits.yml +3 -0
- data/test_support/spec/controllers/atrium/base_controller_spec.rb +13 -0
- data/test_support/spec/controllers/atrium/collection_exhibit_order_controller_spec.rb +29 -0
- data/test_support/spec/controllers/atrium/collections_controller_spec.rb +185 -0
- data/test_support/spec/controllers/atrium/customization_controller_spec.rb +38 -0
- data/test_support/spec/controllers/atrium/descriptions_controller_spec.rb +150 -0
- data/test_support/spec/controllers/atrium/exhibit_facet_order_controller_spec.rb +36 -0
- data/test_support/spec/controllers/atrium/exhibits_controller_spec.rb +192 -0
- data/test_support/spec/controllers/atrium/showcases_controller_spec.rb +185 -0
- data/test_support/spec/helpers/atrium_collections_helper_spec.rb +147 -0
- data/test_support/spec/helpers/atrium_description_helper_spec.rb +47 -0
- data/test_support/spec/helpers/atrium_solr_helper_spec.rb +512 -0
- data/test_support/spec/models/atrium/browse_level_spec.rb +31 -0
- data/test_support/spec/models/atrium/collection_spec.rb +30 -0
- data/test_support/spec/models/atrium/description_spec.rb +67 -0
- data/test_support/spec/models/atrium/essay_spec.rb +12 -0
- data/test_support/spec/models/atrium/exhibit_spec.rb +76 -0
- data/test_support/spec/models/atrium/search/facet_selection_spec.rb +24 -0
- data/test_support/spec/models/atrium/search/facet_spec.rb +11 -0
- data/test_support/spec/models/atrium/search_facet_spec.rb +54 -0
- data/test_support/spec/models/atrium/showcase/facet_selection_spec.rb +15 -0
- data/test_support/spec/models/atrium/showcase/item_spec.rb +12 -0
- data/test_support/spec/models/atrium/showcase_facet_selection_spec.rb +65 -0
- data/test_support/spec/models/atrium/showcase_spec.rb +134 -0
- data/test_support/spec/rcov.opts +3 -0
- data/test_support/spec/routing/atrium/collections_routing_spec.rb +33 -0
- data/test_support/spec/spec.opts +4 -0
- data/test_support/spec/spec_helper.rb +47 -0
- data/test_support/spec/support/be_accessible_matcher.rb +8 -0
- data/test_support/spec/support/be_routed_mixin.rb +7 -0
- data/test_support/tmp/step_definitions/catalog_index_steps.rb +14 -0
- data/test_support/tmp/step_definitions/edit_document_steps.rb +67 -0
- data/test_support/tmp/step_definitions/hydra_metadata_steps.rb +3 -0
- data/test_support/tmp/step_definitions/hydra_steps.rb +8 -0
- data/test_support/tmp/step_definitions/search_steps.rb +86 -0
- data/test_support/tmp/step_definitions/searching_steps.rb +22 -0
- data/test_support/tmp/step_definitions/select_steps.rb +8 -0
- data/test_support/tmp/step_definitions/show_document_steps.rb +73 -0
- data/test_support/tmp/step_definitions/user_steps.rb +15 -0
- data/test_support/tmp/step_definitions/web_steps.rb +273 -0
- data/test_support/tmp/support/env.rb +54 -0
- data/test_support/tmp/support/paths.rb +57 -0
- metadata +1047 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
|
+
|
|
3
|
+
describe Atrium::ShowcasesController 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
|
+
#before do
|
|
12
|
+
# @description = Atrium::Description.new(:atrium_showcase_id=>@collection_showcase.id)
|
|
13
|
+
# @description.save
|
|
14
|
+
# @collection_showcase.stub(:parent).returns(@collection)
|
|
15
|
+
#end
|
|
16
|
+
it 'should return collection id of collection showcase from params ' do
|
|
17
|
+
collection = Atrium::Collection.new
|
|
18
|
+
collection.save
|
|
19
|
+
showcase = Atrium::Showcase.new(:showcases_id=> collection.id, :showcases_type=>collection.class.name)
|
|
20
|
+
showcase.save
|
|
21
|
+
Atrium::Showcase.stubs(:find).with("1").returns(showcase)
|
|
22
|
+
controller.params[:id] = '1'
|
|
23
|
+
collection_id=controller.send(:determine_collection_id)
|
|
24
|
+
collection_id.should == 1
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'should return collection id of exhibit showcase from params ' do
|
|
28
|
+
collection = Atrium::Collection.new
|
|
29
|
+
collection.save
|
|
30
|
+
exhibit = Atrium::Exhibit.new(:atrium_collection_id=> collection.id, :set_number=>1)
|
|
31
|
+
exhibit.save
|
|
32
|
+
showcase = Atrium::Showcase.new(:showcases_id=> exhibit.id, :showcases_type=>exhibit.class.name)
|
|
33
|
+
showcase.save
|
|
34
|
+
Atrium::Showcase.stubs(:find).with("1").returns(showcase)
|
|
35
|
+
showcase.stubs(:parent).returns(exhibit)
|
|
36
|
+
#showcase.should_receive(:parent).and_return(exhibit)
|
|
37
|
+
controller.params[:id] = '1'
|
|
38
|
+
collection_id=controller.send(:determine_collection_id)
|
|
39
|
+
collection_id.should == 1
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'return nil if exhibit id not available in params' do
|
|
43
|
+
collection_id=controller.send(:determine_collection_id)
|
|
44
|
+
collection_id.should == nil
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe "Get New" do
|
|
49
|
+
before do
|
|
50
|
+
@collection = mock("atrium_collection")
|
|
51
|
+
@exhibit = mock("atrium_exhibit")
|
|
52
|
+
@showcase = mock("atrium_showcase")
|
|
53
|
+
@showcase.stubs(:showcases_id).returns(1)
|
|
54
|
+
@showcase.stubs(:build).returns(@showcase)
|
|
55
|
+
@showcase.stubs(:showcases_id).returns(1)
|
|
56
|
+
Atrium::Collection.stubs(:find_by_id).returns(@collection)
|
|
57
|
+
Atrium::Exhibit.stubs(:find_by_id).returns(@exhibit)
|
|
58
|
+
end
|
|
59
|
+
it "create showcase for collection" do
|
|
60
|
+
Atrium::Showcase.expects(:with_selected_facets).returns([])
|
|
61
|
+
@collection.expects(:showcases).returns(@showcase)
|
|
62
|
+
@showcase.stubs(:for_exhibit?).returns(false)
|
|
63
|
+
@showcase.expects(:save!)
|
|
64
|
+
xhr :get, :new, {:collection_id => 1}
|
|
65
|
+
session[:edit_showcase].should == true
|
|
66
|
+
response.should redirect_to atrium_collection_showcase_path(1,@showcase.id)
|
|
67
|
+
end
|
|
68
|
+
it "create showcase for exhibit" do
|
|
69
|
+
Atrium::Showcase.expects(:with_selected_facets).returns([])
|
|
70
|
+
@showcase.stubs(:for_exhibit?).returns(true)
|
|
71
|
+
@exhibit.expects(:showcases).returns(@showcase)
|
|
72
|
+
@showcase.expects(:save!)
|
|
73
|
+
xhr :get, :new, {:exhibit_id => 1}
|
|
74
|
+
session[:edit_showcase].should == true
|
|
75
|
+
response.should redirect_to atrium_exhibit_path(1)
|
|
76
|
+
end
|
|
77
|
+
it "return existing showcase for collection" do
|
|
78
|
+
Atrium::Showcase.expects(:with_selected_facets).returns([@showcase])
|
|
79
|
+
@showcase.expects(:for_exhibit?).returns(false)
|
|
80
|
+
xhr :get, :new, {:collection_id => 1}
|
|
81
|
+
assigns[:atrium_showcase].should == @showcase
|
|
82
|
+
end
|
|
83
|
+
it "show redirect to collection page" do
|
|
84
|
+
Atrium::Showcase.expects(:with_selected_facets).returns([@showcase])
|
|
85
|
+
@showcase.expects(:for_exhibit?).returns(false)
|
|
86
|
+
xhr :get, :new, {:collection_id => 1}
|
|
87
|
+
session[:edit_showcase].should == true
|
|
88
|
+
response.should redirect_to atrium_collection_showcase_path(1,@showcase.id)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
describe "Get Show" do
|
|
94
|
+
it "should assign showcase to mocked showcase" do
|
|
95
|
+
session[:folder_document_ids]=nil
|
|
96
|
+
@showcase = mock("atrium_showcase")
|
|
97
|
+
Atrium::Showcase.stubs(:find).returns(@showcase)
|
|
98
|
+
@showcase.stubs(:showcase_items=).returns({})
|
|
99
|
+
@showcase.stubs(:showcase_items).returns({})
|
|
100
|
+
@showcase.expects(:save)
|
|
101
|
+
get :show, {:id=>1}
|
|
102
|
+
assigns[:atrium_showcase].should == @showcase
|
|
103
|
+
end
|
|
104
|
+
it "redirect to show view when featured items are not selected" do
|
|
105
|
+
session[:folder_document_ids]=nil
|
|
106
|
+
@showcase = mock("atrium_showcase")
|
|
107
|
+
Atrium::Showcase.stubs(:find).returns(@showcase)
|
|
108
|
+
@showcase.stubs(:showcase_items=).returns({})
|
|
109
|
+
@showcase.stubs(:showcase_items).returns({})
|
|
110
|
+
@showcase.expects(:save)
|
|
111
|
+
get :show, {:id=>1}
|
|
112
|
+
response.should render_template 'layouts/atrium'
|
|
113
|
+
response.should render_template("show")
|
|
114
|
+
end
|
|
115
|
+
it "should not assign layout when params is passed" do
|
|
116
|
+
session[:folder_document_ids]=nil
|
|
117
|
+
@showcase = mock("atrium_showcase")
|
|
118
|
+
@showcase.stubs(:showcase_items=).returns({})
|
|
119
|
+
@showcase.stubs(:showcase_items).returns({})
|
|
120
|
+
@showcase.expects(:save)
|
|
121
|
+
Atrium::Showcase.stubs(:find).returns(@showcase)
|
|
122
|
+
get :show, { :id => "1", :no_layout=>true }
|
|
123
|
+
response.should_not render_template 'layouts/atrium'
|
|
124
|
+
response.should render_template("show")
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "save session documents to showcase showcase_items" do
|
|
128
|
+
@showcase = Atrium::Showcase.new({:showcases_id=>1, :showcases_type=>"Atrium::Collection"})
|
|
129
|
+
@showcase.save!
|
|
130
|
+
Atrium::Showcase.stubs(:find).returns(@showcase)
|
|
131
|
+
#@showcase.expects(:save)
|
|
132
|
+
session[:folder_document_ids]=["1", "2", "3"]
|
|
133
|
+
get :show, { :id => 1, :no_layout=>true }
|
|
134
|
+
assigns[:atrium_showcase].should == @showcase
|
|
135
|
+
response.should_not render_template 'layouts/atrium'
|
|
136
|
+
response.should render_template("show")
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
describe "Get featured" do
|
|
141
|
+
before do
|
|
142
|
+
session[:folder_document_ids]=nil
|
|
143
|
+
@showcase = mock("atrium_showcase")
|
|
144
|
+
Atrium::Showcase.stubs(:find).with("1").returns(@showcase)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it "set session documents to showcase featured items solr documents if present" do
|
|
148
|
+
@showcase.stubs(:showcase_items).returns(nil)
|
|
149
|
+
@showcase.stubs(:parent).returns(nil)
|
|
150
|
+
get :featured, {:id => "1"}
|
|
151
|
+
response.should redirect_to(catalog_index_path(:add_featured=>true, :search_field=>"all_fields"))
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it "set session documents to exhibit filter query params solr documents if present" do
|
|
155
|
+
@showcase.stubs(:showcase_items).returns({:solr_doc_ids=>"1,2,3"})
|
|
156
|
+
@showcase.stubs(:parent).returns(nil)
|
|
157
|
+
get :featured, {:id => "1"}
|
|
158
|
+
session[:folder_document_ids] == ["1", "2", "3"]
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
describe "Get refresh_showcase" do
|
|
163
|
+
before do
|
|
164
|
+
@showcase = mock("atrium_showcase")
|
|
165
|
+
Atrium::Showcase.stubs(:find).returns(@showcase)
|
|
166
|
+
end
|
|
167
|
+
it "should return collection path for collection showcase" do
|
|
168
|
+
@showcase.expects(:showcases_id).returns(1)
|
|
169
|
+
@showcase.stubs(:for_exhibit?).returns(false)
|
|
170
|
+
get :refresh_showcase, {:id=>1}
|
|
171
|
+
assigns[:atrium_showcase].should == @showcase
|
|
172
|
+
session[:edit_showcase].should be_nil
|
|
173
|
+
response.should redirect_to atrium_collection_path(1)
|
|
174
|
+
end
|
|
175
|
+
it "should return exhibit path for exhibit showcase" do
|
|
176
|
+
@showcase.expects(:showcases_id).returns(1)
|
|
177
|
+
@showcase.stubs(:for_exhibit?).returns(true)
|
|
178
|
+
get :refresh_showcase, {:id=>1, :f=>{"continent"=>["North America"]}}
|
|
179
|
+
assigns[:atrium_showcase].should == @showcase
|
|
180
|
+
session[:edit_showcase].should be_nil
|
|
181
|
+
response.should redirect_to atrium_exhibit_path(1, :f=>{"continent"=>["North America"]})
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
end
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
describe Atrium::CollectionsHelper do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@collection = Atrium::Collection.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
after(:each) do
|
|
10
|
+
begin
|
|
11
|
+
@collection.delete
|
|
12
|
+
rescue
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
describe "get_collections_list" do
|
|
16
|
+
it "should call find with all on Atrium::Collection class" do
|
|
17
|
+
Atrium::Collection.expects(:find).with(:all)
|
|
18
|
+
helper.get_collections_list
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe "edit_collection_link" do
|
|
23
|
+
it "should return properly formatted edit collection link" do
|
|
24
|
+
helper.stubs(:params).returns({:controller=>"atrium_collections", :id=>"my_collection_id"})
|
|
25
|
+
helper.edit_collection_link.should == "/atrium/collections/my_collection_id/edit?render_search=false"
|
|
26
|
+
helper.stubs(:params).returns({:collection_id=>"my_collection_id"})
|
|
27
|
+
helper.edit_collection_link.should == "/atrium/collections/my_collection_id/edit?render_search=false"
|
|
28
|
+
helper.edit_collection_link("my_class").should == "/atrium/collections/my_collection_id/edit?class=my_class&render_search=false"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe "browse_collection_link" do
|
|
33
|
+
it "should return properly formatted browse collection link" do
|
|
34
|
+
helper.stubs(:params).returns({:controller=>"atrium_collections",:id=>"my_collection_id"})
|
|
35
|
+
helper.browse_collection_link.should == "/atrium/collections/my_collection_id"
|
|
36
|
+
helper.stubs(:params).returns({:collection_id=>"my_collection_id"})
|
|
37
|
+
helper.browse_collection_link.should == "/atrium/collections/my_collection_id"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe "add_browse_facet_params" do
|
|
42
|
+
it "should return a params hash with a field pointing to an array with the new value" do
|
|
43
|
+
p = HashWithIndifferentAccess.new
|
|
44
|
+
helper.add_browse_facet_params(:test, "testing", p).should == {"f"=>{"test"=>["testing"]}}
|
|
45
|
+
#test if p is nil
|
|
46
|
+
helper.add_browse_facet_params(:test, "testing").should == {"f"=>{"test"=>["testing"]}}
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe "get_browse_facet_path" do
|
|
51
|
+
before do
|
|
52
|
+
catalog_facet_params = HashWithIndifferentAccess.new({:q => "query",
|
|
53
|
+
:search_field => "search_field",
|
|
54
|
+
:f => {"facet_field_1" => ["value1"], "facet_field_2" => ["value2", "value2a"]},
|
|
55
|
+
:exhibit_id => 'exhibit_PID',
|
|
56
|
+
:collection_id => 'collection_PID',
|
|
57
|
+
:controller => "catalog"
|
|
58
|
+
})
|
|
59
|
+
helper.stubs(:params).returns(catalog_facet_params)
|
|
60
|
+
end
|
|
61
|
+
it "should redirect to exhibit action" do
|
|
62
|
+
response = CGI::unescape(helper.get_browse_facet_path("facet_solr_field", "item_value", ["facet_field_1","facet_field_2"], "exhibit_number", "exhibit_id"))
|
|
63
|
+
response.should == "/atrium/exhibits/exhibit_id?class=browse_facet_select&collection_id=collection_PID&f[facet_field_1][]=value1&f[facet_field_2][]=value2&f[facet_field_2][]=value2a&f[facet_solr_field][]=item_value"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "if an item is selected and generating a path for alternate selection at the same level then the path should not include any child facet selections that may exist" do
|
|
67
|
+
catalog_facet_params = {:q => "query",
|
|
68
|
+
:search_field => "search_field",
|
|
69
|
+
:f => {"facet_field_1" => ["value1"], "facet_field_2" => ["value2a"]},
|
|
70
|
+
:exhibit_id => 'exhibit_PID',
|
|
71
|
+
:collection_id => 'collection_PID',
|
|
72
|
+
:controller => "catalog"
|
|
73
|
+
}
|
|
74
|
+
helper.stubs(:params).returns(catalog_facet_params)
|
|
75
|
+
# browse level data to work with.....
|
|
76
|
+
# browse_level_data = [{:solr_facet_name=>"facet_field_1",:label=>"my_label",:selected=>"value1",:values=>["value1","value1a","value1b"]},
|
|
77
|
+
# {:solr_facet_name=>"facet_field_2",:label=>"my_label2",:selected=>"value2a",:values=>["value2","value2a"]}]
|
|
78
|
+
#test making link for something not currently selected that should have child facet selection removed
|
|
79
|
+
browse_facets = ["facet_field_1","facet_field_2"]
|
|
80
|
+
response = CGI::unescape(helper.get_browse_facet_path("facet_field_1","value1a",browse_facets,"exhibit_number", "exhibit_id"))
|
|
81
|
+
response.should == "/atrium/exhibits/exhibit_id?class=browse_facet_select&collection_id=collection_PID&f[facet_field_1][]=value1a"
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe "get_selected_browse_facet_path" do
|
|
86
|
+
before do
|
|
87
|
+
@catalog_facet_params = {
|
|
88
|
+
:f => {"facet_field_1" => ["value1"], "facet_field_2" => ["value2", "value2a"]},
|
|
89
|
+
:id => 'exhibit_PID',
|
|
90
|
+
:controller => "atrium/exhibits",
|
|
91
|
+
:collection_id => 'collection_PID',
|
|
92
|
+
:action=>"show"
|
|
93
|
+
}
|
|
94
|
+
helper.stubs(:params).returns(@catalog_facet_params)
|
|
95
|
+
end
|
|
96
|
+
it "should redirect to exhibit action" do
|
|
97
|
+
helper.stubs(:params).returns(@catalog_facet_params)
|
|
98
|
+
item = {"facet_field" => ["facet_value"]}
|
|
99
|
+
item.stubs(:value).returns(["value1"])
|
|
100
|
+
#helper.stubs(:remove_facet_params).returns({"f" => {"facet_field_1" => ["value1"], "facet_field_2" => ["value2", "value2a"]},
|
|
101
|
+
# "id" => 'collection_PID',
|
|
102
|
+
# "controller" => "atrium/collections"
|
|
103
|
+
#})
|
|
104
|
+
response = CGI::unescape(helper.get_selected_browse_facet_path("facet_field_1", item, ["facet_field_1", "browse_facet"],"exhibit_number", "exhibit_id"))
|
|
105
|
+
#all browse facets should be removed since at the top, and the only current facet in the params is facet_field_1, so facet_field_2 stays
|
|
106
|
+
response.should == "/atrium/exhibits/exhibit_id?collection_id=collection_PID&f[facet_field_2][]=value2&f[facet_field_2][]=value2a"
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
describe "get_selected_browse_facets" do
|
|
111
|
+
before do
|
|
112
|
+
@catalog_facet_params = {
|
|
113
|
+
:f => {"facet_field_1" => ["value1"], "facet_field_2" => ["value2", "value2a"]},
|
|
114
|
+
:id => 'exhibit_PID',
|
|
115
|
+
:controller => "atrium/exhibits",
|
|
116
|
+
:action=>"show"
|
|
117
|
+
}
|
|
118
|
+
helper.stubs(:params).returns(@catalog_facet_params)
|
|
119
|
+
end
|
|
120
|
+
it "should return a hash of selected facet mapped to value not in array" do
|
|
121
|
+
browse_facets = ["facet_field_1","facet_field_2","facet_field_3"]
|
|
122
|
+
helper.get_selected_browse_facets(browse_facets).should == {:facet_field_1=>"value1",:facet_field_2=>"value2"}
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
describe "remove_related_facet_params" do
|
|
127
|
+
before(:each) do
|
|
128
|
+
@params = {
|
|
129
|
+
:f => {:facet_field_1 => ["value1"], :facet_field_2 => ["value2"], :facet_field_4=>["value4"]}
|
|
130
|
+
}
|
|
131
|
+
@browse_facets = [:facet_field_1,:facet_field_2,:facet_field_3]
|
|
132
|
+
helper.stubs(:params).returns(@params)
|
|
133
|
+
end
|
|
134
|
+
it "should return a params hash with a selected facet field removed" do
|
|
135
|
+
helper.remove_related_facet_params(:facet_field_2,@params,@browse_facets,"1").should == {:f=>{:facet_field_1 => ["value1"],:facet_field_4=>["value4"]}}
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
it "should remove any lower selected facets if parent facet is removed" do
|
|
139
|
+
helper.remove_related_facet_params(:facet_field_1,@params,@browse_facets,"1").should == {:f=>{:facet_field_4=>["value4"]}}
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it "should ignore one that is not a browse facet" do
|
|
143
|
+
helper.remove_related_facet_params(:facet_field_4,@params,@browse_facets,"1").should == {:f=>{:facet_field_1 => ["value1"], :facet_field_2 => ["value2"], :facet_field_4=>["value4"]}}
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
Blacklight::SolrHelper.stubs(:class_inheritable_accessor)
|
|
4
|
+
include Blacklight::SolrHelper
|
|
5
|
+
|
|
6
|
+
describe Atrium::DescriptionsHelper do
|
|
7
|
+
|
|
8
|
+
before(:each) do
|
|
9
|
+
@collection = Atrium::Collection.new
|
|
10
|
+
@collection.save
|
|
11
|
+
@collection_showcase = Atrium::Showcase.new(:showcases_id=>@collection.id, :showcases_type=>@collection.class.name)
|
|
12
|
+
@collection_showcase.save
|
|
13
|
+
@exhibit = Atrium::Exhibit.new
|
|
14
|
+
@exhibit_showcase = Atrium::Showcase.new(:showcases_id=>@exhibit.id, :showcases_type=>@exhibit.class.name)
|
|
15
|
+
@exhibit_showcase.save
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
after(:each) do
|
|
20
|
+
begin
|
|
21
|
+
@collection.delete
|
|
22
|
+
@collection_showcase.delete
|
|
23
|
+
rescue
|
|
24
|
+
end
|
|
25
|
+
begin
|
|
26
|
+
@exhibit.delete
|
|
27
|
+
@exhibit_showcase.delete
|
|
28
|
+
rescue
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe "get_description_for_showcase" do
|
|
33
|
+
it "return description hash from solr for any given collection" do
|
|
34
|
+
helper.stubs(:showcase).returns(@collection_showcase)
|
|
35
|
+
description_hash=helper.get_description_for_showcase(@collection_showcase)
|
|
36
|
+
description_hash.size.should == 0
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "returns description details from solr for given showcase" do
|
|
40
|
+
@description = Atrium::Description.new(:atrium_showcase_id=>@collection_showcase.id)
|
|
41
|
+
@description.save!
|
|
42
|
+
@description.update_attributes({:description_solr_id=>"RBSC-CURRENCY:715"})
|
|
43
|
+
helper.expects(:get_solr_response_for_field_values).with("id",["RBSC-CURRENCY:715"]).returns([[:docs => ["id"=>"RBSC-CURRENCY:715", "title_t"=>["title"],"description_content_s"=>["description content"]]],["id"=>"RBSC-CURRENCY:715", "title_t"=>["title"],"description_content_s"=>["description content"]]])
|
|
44
|
+
helper.get_description_for_showcase(@collection_showcase)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
Blacklight::SolrHelper.stubs(:class_inheritable_accessor)
|
|
4
|
+
include Blacklight::SolrHelper
|
|
5
|
+
|
|
6
|
+
describe Atrium::SolrHelper do
|
|
7
|
+
|
|
8
|
+
before(:each) do
|
|
9
|
+
@collection = Atrium::Collection.new
|
|
10
|
+
@collection.save
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
after(:each) do
|
|
14
|
+
begin
|
|
15
|
+
@collection.delete
|
|
16
|
+
rescue
|
|
17
|
+
end
|
|
18
|
+
begin
|
|
19
|
+
@exhibit.delete
|
|
20
|
+
rescue
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe "initialize_collection" do
|
|
25
|
+
before(:each) do
|
|
26
|
+
helper.stubs(:get_all_children).returns([])
|
|
27
|
+
end
|
|
28
|
+
it "atrium_collection should be nil if both :id (if atrium_collections controller) and :collection_id not in params" do
|
|
29
|
+
helper.stubs(:params).returns({:id=>"test_id"})
|
|
30
|
+
helper.__initialize_collection(nil)
|
|
31
|
+
helper.atrium_collection.should == nil
|
|
32
|
+
#helper.stubs(:params).returns({:controller=>"atrium_collections",:collection_id=>"test_id"})
|
|
33
|
+
#helper.atrium_collection.should == nil
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should raise an exception if the collection_id passed in does not exist" do
|
|
37
|
+
helper.expects(:params).returns({:id=>"test_id",:controller=>"atrium_collections"})
|
|
38
|
+
#these only get called once if an collection is found
|
|
39
|
+
helper.expects(:build_lucene_query).returns("_query_:id\:test_id")
|
|
40
|
+
helper.expects(:get_search_results)
|
|
41
|
+
@collection.save!
|
|
42
|
+
logger.expects(:error).twice
|
|
43
|
+
helper.__initialize_collection("test_id")
|
|
44
|
+
#check valid case as well
|
|
45
|
+
helper.expects(:params).returns({:id=>@collection.id,:controller=>"atrium_collections"})
|
|
46
|
+
helper.__initialize_collection(@collection.id)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should configure params correctly if facet selected and facet in filter" do
|
|
50
|
+
helper.stubs(:params).returns({:collection_id=>"test_id",:f=>{"continent"=>["North America"]}})
|
|
51
|
+
@collection.filter_query_params = {:q=>"testing",:f=>{"season"=>["spring"]}}
|
|
52
|
+
Atrium::Collection.expects(:find).with("test_id").returns(@collection)
|
|
53
|
+
helper.expects(:solr_search_params).with(@collection.filter_query_params).returns(:q=>"testing",:fq=>["{!raw f=season_facet}Spring"]).at_least_once
|
|
54
|
+
helper.expects(:solr_search_params).with({:collection_id=>"test_id",:f=>{"continent"=>["North America"]}}).returns(:fq=>["{!raw f=continent}North America"])
|
|
55
|
+
#it will combine param facet and filter facet into extra params so that the params facets are not overwritten when the filter facet is applied
|
|
56
|
+
extra_params = {:q=>"testing", :fq=>["{!raw f=continent}North America","{!raw f=season_facet}Spring"]}
|
|
57
|
+
helper.expects(:get_search_results).with({:collection_id=>"test_id",:f=>{"continent"=>["North America"]}},extra_params)
|
|
58
|
+
helper.__initialize_collection("test_id")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "should configure params correctly if facet selected and no facet in filter" do
|
|
62
|
+
helper.stubs(:params).returns({:collection_id=>"test_id",:f=>{"continent"=>["North America"]}})
|
|
63
|
+
@collection.filter_query_params = {:q=>"testing"}
|
|
64
|
+
Atrium::Collection.expects(:find).with("test_id").returns(@collection)
|
|
65
|
+
helper.expects(:prepare_extra_controller_params_for_collection_query).returns(:q=>"testing")
|
|
66
|
+
helper.expects(:reset_extra_controller_params_after_collection_query).returns(:fq=>["{!raw f=continent}North America"])
|
|
67
|
+
#it will combine param facet and filter facet into extra params so that the params facets are not overwritten when the filter facet is applied
|
|
68
|
+
extra_params = {:q=>"testing"}
|
|
69
|
+
helper.expects(:get_search_results).with({:collection_id=>"test_id",:f=>{"continent"=>["North America"]}},extra_params)
|
|
70
|
+
helper.__initialize_collection("test_id")
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should configure params correctly if facet selected with same facet in filter" do
|
|
74
|
+
helper.stubs(:params).returns({:collection_id=>"test_id",:f=>{"continent"=>["North America"]}})
|
|
75
|
+
@collection.filter_query_params = {:q=>"testing",:f=>{"continent"=>["North America"]}}
|
|
76
|
+
Atrium::Collection.expects(:find).with("test_id").returns(@collection)
|
|
77
|
+
helper.expects(:prepare_extra_controller_params_for_collection_query).returns(:q=>"testing",:fq=>["{!raw f=continent}North America"])
|
|
78
|
+
helper.expects(:reset_extra_controller_params_after_collection_query).returns(:fq=>["{!raw f=continent}North America"])
|
|
79
|
+
#it will combine param facet and filter facet into extra params so that the params facets are not overwritten when the filter facet is applied
|
|
80
|
+
extra_params = {:q=>"testing", :fq=>["{!raw f=continent}North America"]}
|
|
81
|
+
helper.expects(:get_search_results).with({:collection_id=>"test_id",:f=>{"continent"=>["North America"]}},extra_params)
|
|
82
|
+
helper.__initialize_collection("test_id")
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe "get_exhibit_navigation_data" do
|
|
87
|
+
it "if atrium collection still nil after calling initialize collection than should return empty array" do
|
|
88
|
+
helper.expects(:initialize_collection).returns(nil)
|
|
89
|
+
helper.expects(:params).returns({:collection_id=>"test_id"})
|
|
90
|
+
Atrium::Collection.expects(:find).with("test_id").returns(nil)
|
|
91
|
+
helper.expects(:get_browse_level_data).returns([])
|
|
92
|
+
helper.get_exhibit_navigation_data.should == []
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "if no atrium collection exhibits it should return an empty array" do
|
|
96
|
+
collection = mock()
|
|
97
|
+
collection.stubs(:exhibits).returns([])
|
|
98
|
+
helper.stubs(:atrium_collection).returns(collection)
|
|
99
|
+
helper.stubs(:check_for_scope).returns(false)
|
|
100
|
+
helper.get_exhibit_navigation_data.should == []
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "if atrium collection is not nil and has exhibits it should call get browse level data for each browse set" do
|
|
104
|
+
collection = Atrium::Collection.new
|
|
105
|
+
collection.save
|
|
106
|
+
collection.stubs(:exhibits).returns([])
|
|
107
|
+
helper.stubs(:atrium_collection).returns(collection)
|
|
108
|
+
exhibit1 = Atrium::Exhibit.new({:atrium_collection_id=>collection.id,:set_number=>1})
|
|
109
|
+
exhibit1.save
|
|
110
|
+
exhibit2 = Atrium::Exhibit.new({:atrium_collection_id=>collection.id,:set_number=>2})
|
|
111
|
+
exhibit2.save
|
|
112
|
+
browse_level1 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>exhibit1.id,:solr_facet_name=>"my_facet",:label=>"my_label"})
|
|
113
|
+
browse_level2 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>exhibit2.id,:solr_facet_name=>"my_facet2",:label=>"my_label2"})
|
|
114
|
+
browse_level3 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>exhibit2.id,:solr_facet_name=>"my_facet3",:label=>"my_label3"})
|
|
115
|
+
exhibit1.stubs(:browse_levels).returns([browse_level1])
|
|
116
|
+
exhibit2.stubs(:browse_levels).returns([browse_level2,browse_level3])
|
|
117
|
+
collection.expects(:exhibits).returns([exhibit1,exhibit2]).at_least_once
|
|
118
|
+
browse_response = mock()
|
|
119
|
+
helper.stubs(:browse_response).returns(browse_response)
|
|
120
|
+
extra_con_params = mock()
|
|
121
|
+
helper.stubs(:current_extra_controller_params).returns(extra_con_params)
|
|
122
|
+
updated_browse_level1 = browse_level1.clone
|
|
123
|
+
updated_browse_level1.expects(:values).returns(["test1","test2"])
|
|
124
|
+
updated_browse_level1.expects(:selected).returns("test1")
|
|
125
|
+
updated_browse_level2 = browse_level2.clone
|
|
126
|
+
updated_browse_level2.expects(:values).returns(["test3","test4"])
|
|
127
|
+
helper.expects(:get_browse_level_data).with(collection,exhibit1,[browse_level1],browse_response,extra_con_params,true).returns([updated_browse_level1])
|
|
128
|
+
helper.expects(:get_browse_level_data).with(collection,exhibit2,[browse_level2,browse_level3],browse_response,extra_con_params,true).returns([updated_browse_level2,browse_level3])
|
|
129
|
+
#check that the array returned is flattened appropriately on concat
|
|
130
|
+
browse_data = helper.get_exhibit_navigation_data
|
|
131
|
+
browse_data.size.should == 2
|
|
132
|
+
#order is important here for both browse sets and esp. nested levels
|
|
133
|
+
browse_data.first.should == exhibit1
|
|
134
|
+
browse_data.second.should == exhibit2
|
|
135
|
+
browse_data.first.browse_levels.first.values.should == ["test1","test2"]
|
|
136
|
+
browse_data.first.browse_levels.first.selected.should == "test1"
|
|
137
|
+
browse_data.second.browse_levels.first.values.should == ["test3","test4"]
|
|
138
|
+
browse_data.second.browse_levels.first.selected.should == nil
|
|
139
|
+
#for the other browse level of the second browse set values should be empty since nothing selected in parent
|
|
140
|
+
browse_data.second.browse_levels.second.values.should == []
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
describe "get_browse_level_data" do
|
|
145
|
+
it "should return an array of exhibit objects with browse levels objects sorted by level number if any defined" do
|
|
146
|
+
@exhibit = Atrium::Exhibit.new({:atrium_collection_id=>@collection.id,:set_number=>1})
|
|
147
|
+
@exhibit.save
|
|
148
|
+
@exhibit2 = Atrium::Exhibit.new({:atrium_collection_id=>@collection.id,:set_number=>2})
|
|
149
|
+
@exhibit2.save
|
|
150
|
+
helper.expects(:facet_field_labels).returns("my_label").times(3)
|
|
151
|
+
#label will be nil
|
|
152
|
+
browse_level1 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit.id,:solr_facet_name=>"my_facet", :level_number=>1})
|
|
153
|
+
browse_level1.save
|
|
154
|
+
browse_level2 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit.id,:solr_facet_name=>"my_facet2", :level_number=>2})
|
|
155
|
+
browse_level2.save
|
|
156
|
+
@exhibit.stubs(:browse_levels).returns([browse_level1,browse_level2])
|
|
157
|
+
browse_level3 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit2.id,:solr_facet_name=>"my_facet2", :level_number=>1})
|
|
158
|
+
browse_level3.save
|
|
159
|
+
browse_level4 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit2.id,:solr_facet_name=>"my_facet3", :level_number=>2})
|
|
160
|
+
browse_level4.save
|
|
161
|
+
@exhibit2.stubs(:browse_levels).returns([browse_level3,browse_level4])
|
|
162
|
+
@collection.expects(:exhibits).returns([@exhibit,@exhibit2]).at_least_once
|
|
163
|
+
helper.expects(:atrium_collection).returns(@collection).at_least_once
|
|
164
|
+
|
|
165
|
+
browse_response = mock()
|
|
166
|
+
facet1 = mock()
|
|
167
|
+
facet2 = mock()
|
|
168
|
+
facet3 = mock()
|
|
169
|
+
item1 = mock()
|
|
170
|
+
item2 = mock()
|
|
171
|
+
item3 = mock()
|
|
172
|
+
item4 = mock()
|
|
173
|
+
item5 = mock()
|
|
174
|
+
|
|
175
|
+
item1.expects(:value).returns("val1").at_least_once
|
|
176
|
+
item2.expects(:value).returns("val2").at_least_once
|
|
177
|
+
item3.expects(:value).returns("val3").at_least_once
|
|
178
|
+
item4.expects(:value).returns("val4").at_least_once
|
|
179
|
+
item5.expects(:value).returns("val5").at_least_once
|
|
180
|
+
|
|
181
|
+
facet1.expects(:items).returns([item1,item2]).at_least_once
|
|
182
|
+
facet1.expects(:name).returns("my_facet").at_least_once
|
|
183
|
+
facet2.expects(:items).returns([item3,item4,item5]).at_least_once
|
|
184
|
+
facet2.expects(:name).returns("my_facet2").at_least_once
|
|
185
|
+
browse_response.expects(:facets).returns([facet1,facet2,facet3]).at_least_once
|
|
186
|
+
helper.stubs(:browse_response).returns(browse_response)
|
|
187
|
+
helper.expects(:facet_in_params?).returns(false).at_least_once
|
|
188
|
+
#this will make it have something be selected
|
|
189
|
+
helper.expects(:facet_in_params?).with('my_facet','val2').returns(true)
|
|
190
|
+
helper.stubs(:get_search_results).returns([browse_response,mock()])
|
|
191
|
+
|
|
192
|
+
browse_data = helper.get_exhibit_navigation_data
|
|
193
|
+
browse_data.size.should == 2
|
|
194
|
+
browse_data.first.should == @exhibit
|
|
195
|
+
browse_data.second.should == @exhibit2
|
|
196
|
+
|
|
197
|
+
browse_data.first.browse_levels.first.should == browse_level1
|
|
198
|
+
browse_data.first.browse_levels.second.should == browse_level2
|
|
199
|
+
browse_data.second.browse_levels.first.should == browse_level3
|
|
200
|
+
browse_data.second.browse_levels.second.should == browse_level4
|
|
201
|
+
|
|
202
|
+
browse_data.first.browse_levels.first.values.should == ["val1","val2"]
|
|
203
|
+
browse_data.first.browse_levels.second.values.should == ["val3","val4","val5"]
|
|
204
|
+
browse_data.second.browse_levels.first.values.should == ["val3","val4","val5"]
|
|
205
|
+
browse_data.second.browse_levels.second.values.should == []
|
|
206
|
+
|
|
207
|
+
browse_data.first.browse_levels.first.selected.should == "val2"
|
|
208
|
+
browse_data.first.browse_levels.second.selected.should == nil
|
|
209
|
+
browse_data.second.browse_levels.first.selected.should == nil
|
|
210
|
+
browse_data.second.browse_levels.second.selected.should == nil
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
it "should use the blacklight facet field label if no label defined in a browse level" do
|
|
214
|
+
#must have a browse set and collection not nil
|
|
215
|
+
@collection.save
|
|
216
|
+
@exhibit = Atrium::Exhibit.new({:atrium_collection_id=>@collection.id,:set_number=>1})
|
|
217
|
+
@exhibit.save
|
|
218
|
+
#add a browse level with label nil
|
|
219
|
+
browse_level = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit.id,:solr_facet_name=>"my_facet",:level_number=>1})
|
|
220
|
+
@exhibit.expects(:browse_levels).returns([browse_level]).at_least_once
|
|
221
|
+
@collection.expects(:exhibits).returns([@exhibit]).at_least_once
|
|
222
|
+
helper.stubs(:atrium_collection).returns(@collection)
|
|
223
|
+
helper.expects(:facet_field_labels).returns({"my_facet"=>"my_label"}).times(2)
|
|
224
|
+
#response must have facet for this level
|
|
225
|
+
response = mock()
|
|
226
|
+
facet = mock()
|
|
227
|
+
facet.expects(:name).returns("my_facet").times(4)
|
|
228
|
+
#no items in facet to skip calling get_browse_set_data
|
|
229
|
+
facet.expects(:items).returns([]).twice
|
|
230
|
+
response.expects(:facets).returns([facet]).times(4)
|
|
231
|
+
helper.stubs(:browse_response).returns(response)
|
|
232
|
+
helper.stubs(:get_search_results).returns([response,mock()])
|
|
233
|
+
browse_data = helper.get_exhibit_navigation_data
|
|
234
|
+
browse_data.first.browse_levels.first.label.should == "my_label"
|
|
235
|
+
#check if label is blank instead
|
|
236
|
+
browse_level.label = ""
|
|
237
|
+
browse_data = helper.get_exhibit_navigation_data
|
|
238
|
+
browse_data.first.browse_levels.first.label.should == "my_label"
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
it "should use the label in a browse level if defined" do
|
|
242
|
+
helper.expects(:facet_field_labels).returns("my_label").times(0)
|
|
243
|
+
#must have a browse set and collection not nil
|
|
244
|
+
@collection.save
|
|
245
|
+
@exhibit = Atrium::Exhibit.new({:atrium_collection_id=>@collection.id,:set_number=>1})
|
|
246
|
+
@exhibit.save
|
|
247
|
+
browse_level = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit.id,:solr_facet_name=>"my_facet",:label=>"my_label_2"})
|
|
248
|
+
@exhibit.expects(:browse_levels).returns([browse_level]).at_least_once
|
|
249
|
+
@collection.expects(:exhibits).returns([@exhibit]).at_least_once
|
|
250
|
+
helper.stubs(:atrium_collection).returns(@collection)
|
|
251
|
+
response = mock()
|
|
252
|
+
facet = mock()
|
|
253
|
+
facet.expects(:items).returns([]).at_least_once
|
|
254
|
+
facet.expects(:name).returns("my_facet").at_least_once
|
|
255
|
+
response.expects(:facets).returns([facet]).at_least_once
|
|
256
|
+
helper.stubs(:browse_response).returns(response)
|
|
257
|
+
helper.stubs(:get_search_results).returns([response,mock()])
|
|
258
|
+
helper.get_exhibit_navigation_data.first.browse_levels.first.label.should == "my_label_2"
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
it "if no f param is defined it should set the response without f param to be response" do
|
|
262
|
+
#if they are the same then response.facets should be called twice
|
|
263
|
+
@collection.save
|
|
264
|
+
@exhibit = Atrium::Exhibit.new({:atrium_collection_id=>@collection.id,:set_number=>1})
|
|
265
|
+
@exhibit.save
|
|
266
|
+
browse_level = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit.id,:solr_facet_name=>"my_facet",:label=>"my_label"})
|
|
267
|
+
@exhibit.expects(:browse_levels).returns([browse_level]).at_least_once
|
|
268
|
+
@collection.expects(:exhibits).returns([@exhibit]).at_least_once
|
|
269
|
+
helper.stubs(:atrium_collection).returns(@collection)
|
|
270
|
+
response = mock()
|
|
271
|
+
facet = mock()
|
|
272
|
+
facet.expects(:name).returns("other_facet").at_least_once
|
|
273
|
+
#it will call this twice if response is same for without f param
|
|
274
|
+
response.expects(:facets).returns([facet]).twice
|
|
275
|
+
helper.expects(:browse_response).returns(response)
|
|
276
|
+
helper.stubs(:get_search_results).returns([response,mock()])
|
|
277
|
+
helper.get_exhibit_navigation_data
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
it "if multiple browse levels defined and f defined for anything but top level it should only have values set for the top level" do
|
|
281
|
+
#must have a browse set and collection not nil
|
|
282
|
+
@collection.save
|
|
283
|
+
@exhibit = Atrium::Exhibit.new({:atrium_collection_id=>@collection.id,:set_number=>1})
|
|
284
|
+
@exhibit.save
|
|
285
|
+
#add a browse level with label nil
|
|
286
|
+
browse_level1 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit.id,:solr_facet_name=>"my_facet",:level_number=>1})
|
|
287
|
+
browse_level2 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit.id,:solr_facet_name=>"my_facet2",:level_number=>2})
|
|
288
|
+
@exhibit.expects(:browse_levels).returns([browse_level1,browse_level2]).at_least_once
|
|
289
|
+
@collection.expects(:exhibits).returns([@exhibit]).at_least_once
|
|
290
|
+
helper.stubs(:atrium_collection).returns(@collection)
|
|
291
|
+
|
|
292
|
+
#put something in params different from our facet, use facet at second level but should be ignored
|
|
293
|
+
helper.expects(:params).returns({:f=>{"my_facet2"=>["val3"]}}).at_least_once
|
|
294
|
+
facet1 = mock()
|
|
295
|
+
facet1.expects(:name).returns("my_facet").at_least_once
|
|
296
|
+
item1 = mock()
|
|
297
|
+
item1.expects(:value).returns("val1").at_least_once
|
|
298
|
+
item2 = mock()
|
|
299
|
+
item2.expects(:value).returns("val2").at_least_once
|
|
300
|
+
item3 = mock()
|
|
301
|
+
item3.stubs(:value).returns("val3")
|
|
302
|
+
facet1.expects(:items).returns([item1,item2]).at_least_once
|
|
303
|
+
facet2 = mock()
|
|
304
|
+
facet2.expects(:name).returns("my_facet2").at_least_once
|
|
305
|
+
#stub so it can be called but not necessarily expected
|
|
306
|
+
facet2.stubs(:items).returns([item3])
|
|
307
|
+
response = mock()
|
|
308
|
+
response.expects(:facets).returns([facet2,facet1]).at_least_once
|
|
309
|
+
helper.expects(:browse_response).returns(response)
|
|
310
|
+
helper.expects(:facet_field_labels).returns("my_label")
|
|
311
|
+
helper.expects(:get_search_results).returns([response,mock()])
|
|
312
|
+
browse_data = helper.get_exhibit_navigation_data
|
|
313
|
+
browse_data.first.browse_levels.first.values.should == ["val1","val2"]
|
|
314
|
+
browse_data.first.browse_levels.first.selected.should == nil
|
|
315
|
+
browse_data.first.browse_levels.second.values.should == []
|
|
316
|
+
browse_data.first.browse_levels.second.selected.should == nil
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
it "if 3 browse levels defined and two items selected in each browse level then it should return 2 browse levels with values" do
|
|
320
|
+
#must have a browse set and collection not nil
|
|
321
|
+
@collection.save
|
|
322
|
+
@exhibit = Atrium::Exhibit.new({:atrium_collection_id=>@collection.id,:set_number=>1})
|
|
323
|
+
@exhibit.save
|
|
324
|
+
#add a browse level with label nil
|
|
325
|
+
browse_level1 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit.id,:solr_facet_name=>"my_facet",:level_number=>1})
|
|
326
|
+
browse_level2 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit.id,:solr_facet_name=>"my_facet2",:level_number=>2})
|
|
327
|
+
browse_level3 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit.id,:solr_facet_name=>"my_facet3",:level_number=>3})
|
|
328
|
+
@exhibit.expects(:browse_levels).returns([browse_level1,browse_level2,browse_level3]).at_least_once
|
|
329
|
+
@collection.expects(:exhibits).returns([@exhibit]).at_least_once
|
|
330
|
+
helper.stubs(:atrium_collection).returns(@collection)
|
|
331
|
+
helper.expects(:params).returns({:collection_id=>@collection.id,:f=>{"my_facet"=>["my_val2"],"my_facet2"=>"my_val3"}}).at_least_once
|
|
332
|
+
helper.expects(:atrium_collection).returns(@collection)
|
|
333
|
+
facet = mock()
|
|
334
|
+
facet.expects(:name).returns("my_facet").at_least_once
|
|
335
|
+
item = mock()
|
|
336
|
+
item.expects(:value).returns("my_val").at_least_once
|
|
337
|
+
item2 = mock()
|
|
338
|
+
item2.expects(:value).returns("my_val2").at_least_once
|
|
339
|
+
facet.expects(:items).returns([item,item2]).at_least_once
|
|
340
|
+
|
|
341
|
+
facet2 = mock()
|
|
342
|
+
facet2.expects(:name).returns("my_facet2").at_least_once
|
|
343
|
+
item3 = mock()
|
|
344
|
+
item3.expects(:value).returns("my_val3").at_least_once
|
|
345
|
+
item4 = mock()
|
|
346
|
+
item4.expects(:value).returns("my_val4").at_least_once
|
|
347
|
+
facet2.expects(:items).returns([item3,item4]).at_least_once
|
|
348
|
+
|
|
349
|
+
facet3 = mock()
|
|
350
|
+
facet3.expects(:name).returns("my_facet3").at_least_once
|
|
351
|
+
item5 = mock()
|
|
352
|
+
item5.expects(:value).returns("my_val5").at_least_once
|
|
353
|
+
item6 = mock()
|
|
354
|
+
item6.expects(:value).returns("my_val6").at_least_once
|
|
355
|
+
facet3.expects(:items).returns([item5,item6]).at_least_once
|
|
356
|
+
response = mock()
|
|
357
|
+
response.expects(:facets).returns([facet2,facet,facet3]).at_least_once
|
|
358
|
+
helper.expects(:browse_response).returns(response)
|
|
359
|
+
helper.expects(:facet_field_labels).returns("my_label").at_least_once
|
|
360
|
+
helper.expects(:get_search_results).returns([response,mock()]).at_least_once
|
|
361
|
+
browse_data = helper.get_exhibit_navigation_data
|
|
362
|
+
browse_data.first.browse_levels.first.values.should == ["my_val","my_val2"]
|
|
363
|
+
browse_data.first.browse_levels.first.selected.should == "my_val2"
|
|
364
|
+
browse_data.first.browse_levels.second.values.should == ["my_val3","my_val4"]
|
|
365
|
+
browse_data.first.browse_levels.second.selected.should == "my_val3"
|
|
366
|
+
browse_data.first.browse_levels.fetch(2).values.should == ["my_val5","my_val6"]
|
|
367
|
+
browse_data.first.browse_levels.fetch(2).selected.should == nil
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
it "should ignore a facet that is not present" do
|
|
371
|
+
#must have a browse set and collection not nil
|
|
372
|
+
@collection.save
|
|
373
|
+
@exhibit = Atrium::Exhibit.new({:atrium_collection_id=>@collection.id,:set_number=>1})
|
|
374
|
+
@exhibit.save
|
|
375
|
+
#add a browse level with label nil
|
|
376
|
+
browse_level1 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit.id,:solr_facet_name=>"my_facet",:level_number=>1})
|
|
377
|
+
browse_level2 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit.id,:solr_facet_name=>"my_facet2",:level_number=>2})
|
|
378
|
+
@exhibit.expects(:browse_levels).returns([browse_level1,browse_level2]).at_least_once
|
|
379
|
+
@collection.expects(:exhibits).returns([@exhibit]).at_least_once
|
|
380
|
+
helper.stubs(:atrium_collection).returns(@collection)
|
|
381
|
+
|
|
382
|
+
helper.expects(:params).returns({:collection_id=>@collection.id,:f=>{"my_facet"=>["my_val2"],"my_facet2"=>["my_val3"]}}).at_least_once
|
|
383
|
+
facet = mock()
|
|
384
|
+
facet.expects(:name).returns("my_facet").at_least_once
|
|
385
|
+
item = mock()
|
|
386
|
+
item.expects(:value).returns("my_val").at_least_once
|
|
387
|
+
item2 = mock()
|
|
388
|
+
item2.expects(:value).returns("my_val2").at_least_once
|
|
389
|
+
facet.expects(:items).returns([item,item2]).at_least_once
|
|
390
|
+
response = mock()
|
|
391
|
+
response.expects(:facets).returns([facet]).at_least_once
|
|
392
|
+
helper.expects(:browse_response).returns(response)
|
|
393
|
+
helper.expects(:facet_field_labels).returns("my_label").at_least_once
|
|
394
|
+
helper.expects(:get_search_results).returns([response,mock()]).at_least_once
|
|
395
|
+
#second level facet not present so it should only return second level with no values even though first level has something selected
|
|
396
|
+
browse_data = helper.get_exhibit_navigation_data
|
|
397
|
+
browse_data.first.browse_levels.size.should == 2
|
|
398
|
+
browse_data.first.browse_levels.first.values.should == ["my_val","my_val2"]
|
|
399
|
+
browse_data.first.browse_levels.first.selected.should == "my_val2"
|
|
400
|
+
browse_data.first.browse_levels.second.values.should == []
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
it "if 2 browse levels defined and two items selected it should handle having something selected at the lowest browse level" do
|
|
404
|
+
#must have a browse set and collection not nil
|
|
405
|
+
@collection.save
|
|
406
|
+
@exhibit = Atrium::Exhibit.new({:atrium_collection_id=>@collection.id,:set_number=>1})
|
|
407
|
+
@exhibit.save
|
|
408
|
+
#add a browse level with label nil
|
|
409
|
+
browse_level1 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit.id,:solr_facet_name=>"my_facet",:level_number=>1})
|
|
410
|
+
browse_level2 = Atrium::BrowseLevel.new({:atrium_exhibit_id=>@exhibit.id,:solr_facet_name=>"my_facet2",:level_number=>2})
|
|
411
|
+
@exhibit.expects(:browse_levels).returns([browse_level1,browse_level2]).at_least_once
|
|
412
|
+
@collection.expects(:exhibits).returns([@exhibit]).at_least_once
|
|
413
|
+
helper.stubs(:atrium_collection).returns(@collection)
|
|
414
|
+
|
|
415
|
+
helper.expects(:params).returns({:collection_id=>@collection.id,:f=>{"my_facet"=>["my_val2"],"my_facet2"=>["my_val3"]}}).at_least_once
|
|
416
|
+
facet = mock()
|
|
417
|
+
facet.expects(:name).returns("my_facet").at_least_once
|
|
418
|
+
item = mock()
|
|
419
|
+
item.expects(:value).returns("my_val").at_least_once
|
|
420
|
+
item2 = mock()
|
|
421
|
+
item2.expects(:value).returns("my_val2").at_least_once
|
|
422
|
+
facet.expects(:items).returns([item,item2]).at_least_once
|
|
423
|
+
facet2 = mock()
|
|
424
|
+
facet2.expects(:name).returns("my_facet2").at_least_once
|
|
425
|
+
item3 = mock()
|
|
426
|
+
item3.expects(:value).returns("my_val3").at_least_once
|
|
427
|
+
item4 = mock()
|
|
428
|
+
item4.expects(:value).returns("my_val4").at_least_once
|
|
429
|
+
facet2.expects(:items).returns([item3,item4]).at_least_once
|
|
430
|
+
response = mock()
|
|
431
|
+
response.expects(:facets).returns([facet2,facet]).at_least_once
|
|
432
|
+
helper.expects(:browse_response).returns(response)
|
|
433
|
+
helper.expects(:facet_field_labels).returns("my_label").at_least_once
|
|
434
|
+
helper.expects(:get_search_results).returns([response,mock()]).at_least_once
|
|
435
|
+
browse_data = helper.get_exhibit_navigation_data
|
|
436
|
+
browse_data.first.browse_levels.size.should == 2
|
|
437
|
+
browse_data.first.browse_levels.first.values.should == ["my_val","my_val2"]
|
|
438
|
+
browse_data.first.browse_levels.first.selected.should == "my_val2"
|
|
439
|
+
browse_data.first.browse_levels.second.values.should == ["my_val3","my_val4"]
|
|
440
|
+
browse_data.first.browse_levels.second.selected.should == "my_val3"
|
|
441
|
+
end
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
describe "add_exclude_fq_to_solr" do
|
|
445
|
+
before(:each) do
|
|
446
|
+
@exclude_facets = {:test=>'exclude'}
|
|
447
|
+
end
|
|
448
|
+
self.solr_search_params_logic += [:add_exclude_fq_to_solr]
|
|
449
|
+
it "should have exclude solr parameters included in proper way" do
|
|
450
|
+
solr_params = solr_search_params(:exclude => @exclude_facets)
|
|
451
|
+
solr_params[:q].should be_blank
|
|
452
|
+
solr_params["spellcheck.q"].should be_blank
|
|
453
|
+
solr_params[:"facet.field"].should == blacklight_config[:default_solr_params][:"facet.field"]
|
|
454
|
+
|
|
455
|
+
@exclude_facets.each_value do |value|
|
|
456
|
+
solr_params[:fq].should include("-({!raw f=#{@exclude_facets.keys[0]}}#{value})")
|
|
457
|
+
end
|
|
458
|
+
end
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
describe "get_current_filter_query_params" do
|
|
462
|
+
self.solr_search_params_logic += [:add_exclude_fq_to_solr]
|
|
463
|
+
it "should return filters from collection in solr way" do
|
|
464
|
+
@collection.filter_query_params = {:q=>"testing",:f=>{"continent"=>["North America"]}}
|
|
465
|
+
filter_queries= get_current_filter_query_params(@collection,nil,nil)
|
|
466
|
+
filter_queries[:q].should == "testing"
|
|
467
|
+
filter_queries[:fq].should_not be_blank
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
it "should return filters from collection, exhibit and browse level in solr way" do
|
|
471
|
+
@collection.filter_query_params = {:q=>"testing",:f=>{"continent"=>["North America"]}}
|
|
472
|
+
exhibit=mock("atrium_exhibit")
|
|
473
|
+
exhibit.stubs(:filter_query_params).returns({:f=>{"format"=>["books"]}})
|
|
474
|
+
browse_level=mock("atrium_browse_level")
|
|
475
|
+
browse_level.stubs(:filter_query_params).returns({:f=>{"bl"=>["exhibit_level_1"]}})
|
|
476
|
+
ex_facet={:bl_exclude=>["disc"]}
|
|
477
|
+
browse_level.stubs(:exclude_query_params).returns({:exclude=>ex_facet})
|
|
478
|
+
filter_queries= get_current_filter_query_params(@collection,exhibit,browse_level)
|
|
479
|
+
ex_facet.each_value do |value|
|
|
480
|
+
filter_queries[:fq].should include("-({!raw f=#{ex_facet.keys[0]}}#{value})")
|
|
481
|
+
end
|
|
482
|
+
##TODO need to test other filters in the same way as above test in different scenarios
|
|
483
|
+
end
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
describe "prepare_extra_controller_params_for_collection_query" do
|
|
488
|
+
|
|
489
|
+
it "should add collection query params with params to extra_controller_params" do
|
|
490
|
+
@collection.filter_query_params = {:q=>"testing",:f=>{"continent"=>["North America"]}}
|
|
491
|
+
helper.expects(:get_current_filter_query_params).returns({:q=>"testing", :fq=>["{!raw f=continent}North America"]})
|
|
492
|
+
extra_queries= prepare_extra_controller_params_for_collection_query(@collection,nil,nil,{:q=>"include params"},{})
|
|
493
|
+
extra_queries[:q].should == "testing AND include params"
|
|
494
|
+
extra_queries[:fq].should_not be_blank
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
end
|
|
498
|
+
|
|
499
|
+
describe "get_all_children" do
|
|
500
|
+
#TODO need to have solr running and process the real solr response for this test
|
|
501
|
+
#before do
|
|
502
|
+
# @mock_response = mock()
|
|
503
|
+
# @mock_response.stubs(:docs => [])
|
|
504
|
+
# @mock_document = mock()
|
|
505
|
+
# helper.expects(:get_solr_response_for_field_values).returns([@mock_response,@mock_document])
|
|
506
|
+
#end
|
|
507
|
+
# it "should return document matching given relationship name" do
|
|
508
|
+
# get_all_children([], "is_member_of")
|
|
509
|
+
# end
|
|
510
|
+
end
|
|
511
|
+
|
|
512
|
+
end
|