aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/admin_public_body_controller_spec.rb
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2011-02-25 13:14:48 +0000
committerSeb Bacon <seb.bacon@gmail.com>2011-03-10 10:51:44 +0000
commit4c4a4f7adae3d629b3bca37d3f7c8a11f5997664 (patch)
treea992674afc4c75f92713d6ab995d01fccdfecc3d /spec/controllers/admin_public_body_controller_spec.rb
parenta984a4726625d98bc1b7e55f59b25794e2429076 (diff)
new i18n tests for controllers and associated fixes
Diffstat (limited to 'spec/controllers/admin_public_body_controller_spec.rb')
-rw-r--r--spec/controllers/admin_public_body_controller_spec.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/controllers/admin_public_body_controller_spec.rb b/spec/controllers/admin_public_body_controller_spec.rb
index db2e449f8..a48367ae1 100644
--- a/spec/controllers/admin_public_body_controller_spec.rb
+++ b/spec/controllers/admin_public_body_controller_spec.rb
@@ -43,3 +43,57 @@ describe AdminPublicBodyController, "when administering public bodies" do
end
+
+describe AdminPublicBodyController, "when administering public bodies with i18n" do
+ integrate_views
+ fixtures :public_bodies, :public_body_translations
+
+ it "shows the index page" do
+ get :index
+ end
+
+ it "searches for 'humpa'" do
+ get :index, {:query => "humpa", :locale => "es"}
+ assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body) ]
+ end
+
+ it "shows a public body" do
+ get :show, {:id => 2, :locale => "es" }
+ end
+
+ it "creates a new public body" do
+ PublicBody.count.should == 2
+ post :create, { :public_body => { :name => "New Quango", :short_name => "", :tag_string => "blah", :request_email => 'newquango@localhost', :last_edit_comment => 'From test code' } }
+ PublicBody.count.should == 3
+ end
+
+ it "edits a public body" do
+ get :edit, {:id => 3, :locale => 'es'}
+ response.body.should include('Baguette')
+ end
+
+ it "saves edits to a public body" do
+ PublicBody.with_locale(:es) do
+ pb = PublicBody.find(id=3)
+ pb.name.should == "El Department for Humpadinking"
+ end
+
+ post :update, { :id => 3, :public_body => { :name => "Renamed", :short_name => "", :tag_string => "some tags", :request_email => 'edited@localhost', :last_edit_comment => 'From test code' }, :locale => "es" }
+ response.flash[:notice].should include('successful')
+ pb = PublicBody.find(public_bodies(:humpadink_public_body).id)
+ PublicBody.with_locale(:es) do
+ pb.name.should == "Renamed"
+ end
+ PublicBody.with_locale(:en) do
+ pb.name.should == "Department for Humpadinking"
+ end
+ end
+
+ it "destroy a public body" do
+ PublicBody.count.should == 2
+ post :destroy, { :id => 3 }
+ PublicBody.count.should == 1
+ end
+
+
+end