aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/public_body_controller_spec.rb
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2011-12-21 16:46:29 +0000
committerSeb Bacon <seb.bacon@gmail.com>2011-12-21 16:46:29 +0000
commit7ed887f0989425d9e412890800df05637b08c025 (patch)
tree6f1d3fb4d215f069995634907f2bb32e9220ac22 /spec/controllers/public_body_controller_spec.rb
parent21f1855560daa7992b058403938655ad229e0f71 (diff)
parent37b2fb482d31f77865bb889c049450d72876df92 (diff)
Merge branch 'cache-foi-attachments-seb'
Diffstat (limited to 'spec/controllers/public_body_controller_spec.rb')
-rw-r--r--spec/controllers/public_body_controller_spec.rb34
1 files changed, 24 insertions, 10 deletions
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index c5c9d60e1..8182e1331 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -4,7 +4,7 @@ require 'json'
describe PublicBodyController, "when showing a body" do
integrate_views
- fixtures :public_bodies, :public_body_translations, :public_body_versions
+ fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
it "should be successful" do
get :show, :url_name => "dfh", :view => 'all'
@@ -61,13 +61,28 @@ end
describe PublicBodyController, "when listing bodies" do
integrate_views
- fixtures :public_bodies, :public_body_translations, :public_body_versions
+ fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
it "should be successful" do
get :list
response.should be_success
end
+ 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
+ get :list
+ assigns[:public_bodies].length.should == 3
+ end
+ end
+
it "should list bodies in alphabetical order" do
get :list
@@ -110,7 +125,7 @@ describe PublicBodyController, "when listing bodies" do
get :list, :tag => "other"
response.should render_template('list')
assigns[:public_bodies].should == [ public_bodies(:geraldine_public_body) ]
-
+
get :list
response.should render_template('list')
assigns[:public_bodies].count.should == 2
@@ -142,7 +157,7 @@ end
describe PublicBodyController, "when showing JSON version for API" do
- fixtures :public_bodies, :public_body_translations
+ fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
it "should be successful" do
get :show, :url_name => "dfh", :format => "json", :view => 'all'
@@ -157,12 +172,12 @@ describe PublicBodyController, "when showing JSON version for API" do
end
describe PublicBodyController, "when doing type ahead searches" do
- fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments
+ fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
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
@@ -187,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