From 9fe48c5b9db1c0ba6c1a59f0d092c88e5cae1aa0 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 18 Jul 2013 15:33:05 +0100 Subject: Switch routing-filter (which takes locale out of the params and puts it in the URL) off by default in model, controller, and helper tests. This means we can supply the locale as a param. Turn it on specifically for a couple of controller tests that test routing, and change other url localization tests into integration tests. --- spec/controllers/public_body_controller_spec.rb | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'spec/controllers/public_body_controller_spec.rb') diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index e01bcb0a6..68e02e000 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -43,28 +43,14 @@ describe PublicBodyController, "when showing a body" do :conditions => ["public_body_id = ?", public_bodies(:humpadink_public_body).id]) end - it "should redirect to the canonical name in the chosen locale" do - get :show, {:url_name => "dfh", :view => 'all', :show_locale => "es"} - response.should redirect_to "http://test.host/es/body/edfh" - end - - it "should assign the body using same locale as that used in url_name" do - get :show, {:url_name => "edfh", :view => 'all', :show_locale => "es"} + it "should display the body using same locale as that used in url_name" do + get :show, {:url_name => "edfh", :view => 'all', :locale => "es"} response.should contain("Baguette") end it "should redirect use to the relevant locale even when url_name is for a different locale" do - RoutingFilter.active = false - get :show, {:url_name => "edfh", :view => 'all'} response.should redirect_to "http://test.host/body/dfh" - - RoutingFilter.active = true - end - - it "should remember the filter (view) setting on redirecting" do - get :show, :show_locale => "es", :url_name => "tgq", :view => 'successful' - response.should redirect_to 'http://test.host/es/body/etgq/successful' end it "should redirect to newest name if you use historic name of public body in URL" do @@ -95,10 +81,8 @@ describe PublicBodyController, "when listing bodies" do :last_edit_comment => '') @english_only.save end - I18n.with_locale(:es) do - get :list - assigns[:public_bodies].include?(@english_only).should == true - end + get :list, {:locale => 'es'} + assigns[:public_bodies].include?(@english_only).should == true end it "should list bodies in alphabetical order" do -- cgit v1.2.3 From 8c8ff1c840451c9ed598c1b8c68ed72a1a938a38 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 23 Jul 2013 18:23:35 +0100 Subject: Patch Globalize to compensate for the way gettext_i18n_rails patches 118n.locale in the handling of locales with underscores. Fixes #999. --- spec/controllers/public_body_controller_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'spec/controllers/public_body_controller_spec.rb') diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index 68e02e000..4e1841164 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -48,6 +48,12 @@ describe PublicBodyController, "when showing a body" do response.should contain("Baguette") end + it 'should show public body names in the selected locale language if present for a locale with underscores' do + AlaveteliLocalization.set_locales('he_IL en', 'en') + get :show, {:url_name => 'dfh', :view => 'all', :locale => 'he_IL'} + response.should contain('Hebrew Humpadinking') + end + it "should redirect use to the relevant locale even when url_name is for a different locale" do get :show, {:url_name => "edfh", :view => 'all'} response.should redirect_to "http://test.host/body/dfh" @@ -85,6 +91,18 @@ describe PublicBodyController, "when listing bodies" do assigns[:public_bodies].include?(@english_only).should == true end + it 'should show public body names in the selected locale language if present' do + get :list, {:locale => 'es'} + response.should contain('El Department for Humpadinking') + end + + it 'should show public body names in the selected locale language if present for a locale with underscores' do + AlaveteliLocalization.set_locales('he_IL en', 'en') + get :list, {:locale => 'he_IL'} + response.should contain('Hebrew Humpadinking') + end + + it "should list bodies in alphabetical order" do # Note that they are alphabetised by localised name get :list -- cgit v1.2.3