aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/public_body_controller_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/public_body_controller_spec.rb')
-rw-r--r--spec/controllers/public_body_controller_spec.rb31
1 files changed, 16 insertions, 15 deletions
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index 53e6c169a..8182e1331 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -68,17 +68,19 @@ describe PublicBodyController, "when listing bodies" do
response.should be_success
end
- it "should list all bodies even when there are no translations for selected locale" do
+ it "should list all bodies from default locale, even when there are no translations for selected locale" do
+ PublicBody.with_locale(:en) do
+ english_only = PublicBody.new(:name => 'English only',
+ :short_name => 'EO',
+ :request_email => 'english@flourish.org',
+ :last_edit_editor => 'test',
+ :last_edit_comment => '')
+ english_only.save
+ end
PublicBody.with_locale(:es) do
-
- spanish_only = PublicBody.new(:name => 'Spanish only',
- :short_name => 'SO',
- :request_email => 'spanish@flourish.org',
- :last_edit_editor => 'test',
- :last_edit_comment => '')
- end
- get :list
- assigns[:public_bodies].length.should == 3
+ get :list
+ assigns[:public_bodies].length.should == 3
+ end
end
it "should list bodies in alphabetical order" do
@@ -175,7 +177,7 @@ describe PublicBodyController, "when doing type ahead searches" do
it "should return nothing for the empty query string" do
get :search_typeahead, :q => ""
response.should render_template('public_body/_search_ahead')
- assigns[:xapian_requests].results.size.should == 0
+ assigns[:xapian_requests].should be_nil
end
it "should return a body matching the given keyword, but not users with a matching description" do
@@ -200,10 +202,9 @@ describe PublicBodyController, "when doing type ahead searches" do
assigns[:xapian_requests].results[0][:model].name.should == public_bodies(:humpadink_public_body).name
end
- it "should return partial matches" do
- get :search_typeahead, :q => "geral" # 'geral' for 'Geraldine'
+ it "should not return matches for short words" do
+ get :search_typeahead, :q => "b"
response.should render_template('public_body/_search_ahead')
- assigns[:xapian_requests].results.size.should == 1
- assigns[:xapian_requests].results[0][:model].name.should == public_bodies(:geraldine_public_body).name
+ assigns[:xapian_requests].should be_nil
end
end