diff options
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/admin_public_body_controller_spec.rb | 54 | ||||
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 22 | ||||
-rw-r--r-- | spec/controllers/track_controller_spec.rb | 4 | ||||
-rw-r--r-- | spec/controllers/user_controller_spec.rb | 5 |
4 files changed, 80 insertions, 5 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 diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index fbab832f6..6b55bc09a 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_versions + fixtures :public_bodies, :public_body_versions, :public_body_translations it "should be successful" do get :show, :url_name => "dfh" @@ -21,6 +21,16 @@ describe PublicBodyController, "when showing a body" do assigns[:public_body].should == public_bodies(:humpadink_public_body) end + it "should assign the body using different locale from that used for url_name" do + get :show, {:url_name => "dfh", :locale => 'es'} + assigns[:public_body].notes.should == "Baguette" + end + + it "should assign the body using same locale as that used in url_name" do + get :show, {:url_name => "edfh", :locale => 'es'} + assigns[:public_body].notes.should == "Baguette" + end + it "should redirect to newest name if you use historic name of public body in URL" do get :show, :url_name => "hdink" response.should redirect_to(:controller => 'public_body', :action => 'show', :url_name => "dfh") @@ -51,6 +61,16 @@ describe PublicBodyController, "when listing bodies" do assigns[:description].should == "all" end + it "should list bodies in alphabetical order with different locale" do + get :list, :locale => "es" + + response.should render_template('list') + + assigns[:public_bodies].should == [ public_bodies(:geraldine_public_body), public_bodies(:humpadink_public_body) ] + assigns[:tag].should == "all" + assigns[:description].should == "all" + end + it "should list a tagged thing on the appropriate list page, and others on the other page, and all still on the all page" do public_bodies(:humpadink_public_body).tag_string = "foo local_council" diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb index c31491375..a37b1ea01 100644 --- a/spec/controllers/track_controller_spec.rb +++ b/spec/controllers/track_controller_spec.rb @@ -37,11 +37,11 @@ describe TrackController, "when sending alerts for a track" do integrate_views fixtures :info_requests, :outgoing_messages, :incoming_messages, :raw_emails, :info_request_events, :users, :track_things, :track_things_sent_emails include LinkToHelper # for main_url - + before do rebuild_xapian_index end - + it "should send alerts" do # set the time the comment event happened at to within the last week ire = info_request_events(:silly_comment_event) diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 90f90860a..81da94e67 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -125,7 +125,7 @@ describe UserController, "when signing in" do # check is right confirmation URL mail_token.should == post_redirect.email_token - params_from(:get, mail_path).should == { :controller => 'user', :action => 'confirm', :email_token => mail_token } + params_from(:get, mail_path).should == { :controller => 'user', :action => 'confirm', :email_token => mail_token, :locale => "en" } # check confirmation URL works session[:user_id].should be_nil @@ -421,7 +421,8 @@ describe UserController, "when changing email address" do "old_email"=>"bob@localhost", "new_email"=>"newbob@localhost", "password"=>"jonespassword"}, - "controller"=>"user"} + "controller"=>"user", + "locale"=>"en"} post :signchangeemail, post_redirect.post_params response.should redirect_to(:controller => 'user', :action => 'show', :url_name => 'bob_smith') |