From 0d533ce1d56e1ec1446774cc6fff52451a844f3f Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Sun, 9 Dec 2012 18:35:39 +1100 Subject: Switch to new method name --- spec/controllers/public_body_controller_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 29ece18cb..e97db5a12 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -44,14 +44,14 @@ describe PublicBodyController, "when showing a body" do end it "should assign the body using different locale from that used for url_name" do - PublicBody.with_locale(:es) do + PublicBody.with_locales(:es) do get :show, {:url_name => "dfh", :view => 'all'} assigns[:public_body].notes.should == "Baguette" end end it "should assign the body using same locale as that used in url_name" do - PublicBody.with_locale(:es) do + PublicBody.with_locales(:es) do get :show, {:url_name => "edfh", :view => 'all'} assigns[:public_body].notes.should == "Baguette" end @@ -87,7 +87,7 @@ describe PublicBodyController, "when listing bodies" do end it "should list all bodies from default locale, even when there are no translations for selected locale" do - PublicBody.with_locale(:en) do + PublicBody.with_locales(:en) do @english_only = PublicBody.new(:name => 'English only', :short_name => 'EO', :request_email => 'english@flourish.org', @@ -95,7 +95,7 @@ describe PublicBodyController, "when listing bodies" do :last_edit_comment => '') @english_only.save end - PublicBody.with_locale(:es) do + PublicBody.with_locales(:es) do get :list assigns[:public_bodies].include?(@english_only).should == true end -- cgit v1.2.3 From 1f8bc6560b5240a7aa84ac8d6bdc47eea5d2d781 Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Mon, 10 Dec 2012 00:09:55 +1100 Subject: The with_locale has been removed in Globalize3 I think Globalize is supposed to pick up the locale from I18n anyway so I don't know if these are needed. I think I still haven't done the right thing but it's time to move on. --- spec/controllers/public_body_controller_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 e97db5a12..9c7f7dc7f 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -44,14 +44,14 @@ describe PublicBodyController, "when showing a body" do end it "should assign the body using different locale from that used for url_name" do - PublicBody.with_locales(:es) do + I18n.with_locale(:es) do get :show, {:url_name => "dfh", :view => 'all'} assigns[:public_body].notes.should == "Baguette" end end it "should assign the body using same locale as that used in url_name" do - PublicBody.with_locales(:es) do + I18n.with_locale(:es) do get :show, {:url_name => "edfh", :view => 'all'} assigns[:public_body].notes.should == "Baguette" end @@ -87,7 +87,7 @@ describe PublicBodyController, "when listing bodies" do end it "should list all bodies from default locale, even when there are no translations for selected locale" do - PublicBody.with_locales(:en) do + I18n.with_locale(:en) do @english_only = PublicBody.new(:name => 'English only', :short_name => 'EO', :request_email => 'english@flourish.org', @@ -95,7 +95,7 @@ describe PublicBodyController, "when listing bodies" do :last_edit_comment => '') @english_only.save end - PublicBody.with_locales(:es) do + I18n.with_locale(:es) do get :list assigns[:public_bodies].include?(@english_only).should == true end -- cgit v1.2.3 From c9feb6a4002fc4b63021aeb5ffd6b2846ada7748 Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Tue, 11 Dec 2012 15:00:40 +1100 Subject: integrate_views is render_views RSpec 2 --- spec/controllers/public_body_controller_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 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 9c7f7dc7f..a0841b621 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe PublicBodyController, "when showing a body" do - integrate_views + render_views before(:each) do load_raw_emails_data @@ -79,7 +79,7 @@ describe PublicBodyController, "when showing a body" do end describe PublicBodyController, "when listing bodies" do - integrate_views + render_views it "should be successful" do get :list @@ -193,7 +193,7 @@ end describe PublicBodyController, "when doing type ahead searches" do - integrate_views + render_views before(:each) do load_raw_emails_data -- cgit v1.2.3 From 16abab79f431a5a6fa3d5980ef7747135bd436a0 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Wed, 16 Jan 2013 19:07:54 +1100 Subject: Set locale in controller test by passing parameter in get Also using I18n.locale to pass the current locale around. --- spec/controllers/public_body_controller_spec.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 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 29ece18cb..14d32f303 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -43,18 +43,14 @@ describe PublicBodyController, "when showing a body" do :conditions => ["public_body_id = ?", public_bodies(:humpadink_public_body).id]) end - it "should assign the body using different locale from that used for url_name" do - PublicBody.with_locale(:es) do - get :show, {:url_name => "dfh", :view => 'all'} - assigns[:public_body].notes.should == "Baguette" - 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 - PublicBody.with_locale(:es) do - get :show, {:url_name => "edfh", :view => 'all'} - assigns[:public_body].notes.should == "Baguette" - end + get :show, {:url_name => "edfh", :view => 'all', :show_locale => "es"} + response.should include_text("Baguette") end it "should redirect use to the relevant locale even when url_name is for a different locale" do -- cgit v1.2.3 From 5f6a7a29bc1ea3784728a9c57edfa4be73d4196f Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Thu, 17 Jan 2013 05:26:54 +1100 Subject: Set locale with I18n rather than through globalize --- spec/controllers/public_body_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 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 14d32f303..267a854cd 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -83,7 +83,7 @@ describe PublicBodyController, "when listing bodies" do end it "should list all bodies from default locale, even when there are no translations for selected locale" do - PublicBody.with_locale(:en) do + I18n.with_locale(:en) do @english_only = PublicBody.new(:name => 'English only', :short_name => 'EO', :request_email => 'english@flourish.org', @@ -91,7 +91,7 @@ describe PublicBodyController, "when listing bodies" do :last_edit_comment => '') @english_only.save end - PublicBody.with_locale(:es) do + I18n.with_locale(:es) do get :list assigns[:public_bodies].include?(@english_only).should == true end -- cgit v1.2.3 From 8ab884f0da68b17f33577a197ebd0e7d412a28ed Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 25 Jan 2013 11:23:43 +1100 Subject: Disable routing filter in tests by using RoutingFilter.active rather than writing to ActionController::Routing::Routes.filters --- spec/controllers/public_body_controller_spec.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 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 a0841b621..3a42b535f 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -58,13 +58,12 @@ describe PublicBodyController, "when showing a body" do end it "should redirect use to the relevant locale even when url_name is for a different locale" do - old_filters = ActionController::Routing::Routes.filters - ActionController::Routing::Routes.filters = RoutingFilter::Chain.new + RoutingFilter.active = false get :show, {:url_name => "edfh", :view => 'all'} response.should redirect_to "http://test.host/body/dfh" - ActionController::Routing::Routes.filters = old_filters + RoutingFilter.active = true end it "should redirect to newest name if you use historic name of public body in URL" do -- cgit v1.2.3 From 9fb05a3eea9836de793831cbf3ebfbf1363e0417 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Thu, 31 Jan 2013 11:21:49 +1100 Subject: Test result of test with examples rather than another implementation --- spec/controllers/public_body_controller_spec.rb | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 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 445128db7..38e874469 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -102,9 +102,11 @@ describe PublicBodyController, "when listing bodies" do response.should render_template('list') - assigns[:public_bodies].should == PublicBody.all( - :conditions => "id <> #{PublicBody.internal_admin_body.id}", - :order => "(select name from public_body_translations where public_body_id=public_bodies.id and locale='en')") + assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body), + public_bodies(:forlorn_public_body), + public_bodies(:geraldine_public_body), + public_bodies(:sensible_walks_public_body), + public_bodies(:silly_walks_public_body) ] assigns[:tag].should == "all" assigns[:description].should == "" end @@ -142,11 +144,18 @@ describe PublicBodyController, "when listing bodies" do get :list, :tag => "other" response.should render_template('list') - assigns[:public_bodies].should =~ PublicBody.all(:conditions => "id not in (#{public_bodies(:humpadink_public_body).id}, #{PublicBody.internal_admin_body.id})") + assigns[:public_bodies].should == [ public_bodies(:forlorn_public_body), + public_bodies(:geraldine_public_body), + public_bodies(:sensible_walks_public_body), + public_bodies(:silly_walks_public_body) ] get :list response.should render_template('list') - assigns[:public_bodies].should =~ PublicBody.all(:conditions => "id <> #{PublicBody.internal_admin_body.id}") + assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body), + public_bodies(:forlorn_public_body), + public_bodies(:geraldine_public_body), + public_bodies(:sensible_walks_public_body), + public_bodies(:silly_walks_public_body) ] end it "should list a machine tagged thing, should get it in both ways" do -- cgit v1.2.3 From c5a0ac1f191e1ca0b2bcd71f7949c12b214cd5bd Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Fri, 15 Mar 2013 17:03:47 +1100 Subject: Use a real example instead of a helper --- spec/controllers/public_body_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 7b2876aff..e9aff9c26 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -64,7 +64,7 @@ describe PublicBodyController, "when showing a body" do it "should remember the filter (view) setting on redirecting" do get :show, :show_locale => "es", :url_name => "tgq", :view => 'successful' - response.should redirect_to show_public_body_successful_url(:url_name => "etgq") + 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 -- cgit v1.2.3 From 4dbac2efe4bd002155e2eb9b79f41ce10d2c854e Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Fri, 15 Mar 2013 17:09:32 +1100 Subject: We've added a new fixture since the last merge --- spec/controllers/public_body_controller_spec.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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 e9aff9c26..22d8418c9 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -107,7 +107,8 @@ describe PublicBodyController, "when listing bodies" do response.should render_template('list') - assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body), + assigns[:public_bodies].should == [ public_bodies(:other_public_body), + public_bodies(:humpadink_public_body), public_bodies(:forlorn_public_body), public_bodies(:geraldine_public_body), public_bodies(:sensible_walks_public_body), @@ -149,14 +150,16 @@ describe PublicBodyController, "when listing bodies" do get :list, :tag => "other" response.should render_template('list') - assigns[:public_bodies].should == [ public_bodies(:forlorn_public_body), + assigns[:public_bodies].should == [ public_bodies(:other_public_body), + public_bodies(:forlorn_public_body), public_bodies(:geraldine_public_body), public_bodies(:sensible_walks_public_body), public_bodies(:silly_walks_public_body) ] get :list response.should render_template('list') - assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body), + assigns[:public_bodies].should == [ public_bodies(:other_public_body), + public_bodies(:humpadink_public_body), public_bodies(:forlorn_public_body), public_bodies(:geraldine_public_body), public_bodies(:sensible_walks_public_body), -- cgit v1.2.3