ref: refs/heads/network commit a6f19cb468eb55695ea01fbffe514a930d480409 Author: Josef Reidinger <jreidinger@suse.cz> Date: Thu Sep 10 09:05:56 2009 +0200 add test for wizard redirect in systemtime module --- .../app/controllers/systemtime_controller.rb | 3 +- .../test/functional/systemtime_controller_test.rb | 25 ++++++++++--------- .../app/controllers/application_controller.rb | 1 + webclient/lib/authenticated_system.rb | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/plugins/systemtime/app/controllers/systemtime_controller.rb b/plugins/systemtime/app/controllers/systemtime_controller.rb index 470b4a7..7f79a3b 100644 --- a/plugins/systemtime/app/controllers/systemtime_controller.rb +++ b/plugins/systemtime/app/controllers/systemtime_controller.rb @@ -47,7 +47,7 @@ class SystemtimeController < ApplicationController # Index handler. Loads information from backend and if success all required # fields is filled. In case of errors redirect to help page, main page or just # show flash with partial problem. - def index + def index systemtime = load_proxy 'org.opensuse.yast.modules.yapi.time' unless systemtime @@ -55,6 +55,7 @@ class SystemtimeController < ApplicationController end unless @permissions[:read] + logger.debug "No permissions for time module" flash[:warning] = _("No permissions for time module") redirect_to root_path return false diff --git a/plugins/systemtime/test/functional/systemtime_controller_test.rb b/plugins/systemtime/test/functional/systemtime_controller_test.rb index c2a258f..b42f503 100644 --- a/plugins/systemtime/test/functional/systemtime_controller_test.rb +++ b/plugins/systemtime/test/functional/systemtime_controller_test.rb @@ -43,12 +43,6 @@ class SystemtimeControllerTest < ActionController::TestCase @date = "07/02/2009" @utcstatus = "true" @timezone = "Europe/Prague" -# @available = [Lang.new("cs_CZ","cestina"), -# Lang.new("en_US","English (US)") -# ]; -# @current = "cs_CZ" -# @utf8 = "true" -# @rootlocale = "false" end def save @@ -87,8 +81,6 @@ class SystemtimeControllerTest < ActionController::TestCase def test_access_without_write_permissions @permissions[:write] = false -# @result.utf8 = "false" -# @result.rootlocale = "true" YaST::ServiceResource.stubs(:proxy_for).with('org.opensuse.yast.modules.yapi.time').returns(@proxy) get :index @@ -104,14 +96,11 @@ class SystemtimeControllerTest < ActionController::TestCase def test_commit YaST::ServiceResource.stubs(:proxy_for).with('org.opensuse.yast.modules.yapi.time').returns(@proxy) - post :update_time, { :currenttime => "2009-07-02 - 12:18:00", :date => { :date => "2009-07-02 - 12:18:00/2009-07-02 - 12:18:00" }, :utc => "true" } + post :update, { :currenttime => "2009-07-02 - 12:18:00", :date => { :date => "2009-07-02 - 12:18:00/2009-07-02 - 12:18:00" }, :utc => "true" } assert_response :redirect assert_redirected_to :action => "index" -# assert_equal "en_US", @result.current -# assert_equal "false", @result.utf8 -# assert_equal "ctype", @result.rootlocale assert @result.saved end @@ -127,4 +116,16 @@ class SystemtimeControllerTest < ActionController::TestCase assert_redirected_to "/bad_permissions" end + def test_commit_wizard + YaST::ServiceResource.stubs(:proxy_for).with('org.opensuse.yast.modules.yapi.time').returns(@proxy) + session[:wizard_current] = "test" + post :update, { :currenttime => "2009-07-02 - 12:18:00", :date => { :date => "2009-07-02 - 12:18:00/2009-07-02 - 12:18:00" }, :utc => "true" } + + puts @response.body + assert_response :redirect + assert_redirected_to :action => "index" + + assert @result.saved + end + end diff --git a/webclient/app/controllers/application_controller.rb b/webclient/app/controllers/application_controller.rb index 902764c..e0f8d2b 100644 --- a/webclient/app/controllers/application_controller.rb +++ b/webclient/app/controllers/application_controller.rb @@ -9,6 +9,7 @@ class ApplicationController < ActionController::Base logger.debug "wizard redirect DONE" redirect_to :controller => "controlpanel", :action => "nextstep" else + logger.debug "Success non-wizard redirect" redirect_to :action => :index end end diff --git a/webclient/lib/authenticated_system.rb b/webclient/lib/authenticated_system.rb index 628a346..bb36639 100644 --- a/webclient/lib/authenticated_system.rb +++ b/webclient/lib/authenticated_system.rb @@ -81,7 +81,7 @@ module AuthenticatedSystem # Redirect to the URI stored by the most recent store_location call or # to the passed default. - def redirect_back_or_default(default) + def redirect_back_or_default(default) redirect_to(session[:return_to] || default) session[:return_to] = nil end -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org