Mailinglist Archive: yast-commit (2114 mails)

< Previous Next >
[yast-commit] <web-client> use-activeresource : code cleanup, fixed tests
  • From: Michal Zugec <mzugec@xxxxxxx>
  • Date: Thu, 10 Sep 2009 13:32:49 +0200
  • Message-id: <E1MoJ2R-0003Gp-53@xxxxxxxxxxxxxxxx>
ref: refs/heads/use-activeresource
commit b8f84fe1b5d5004a53a009a7a64300417b081300
Author: Michal Zugec <mzugec@xxxxxxx>
Date: Thu Sep 10 13:32:49 2009 +0200

code cleanup, fixed tests
---
.../network/app/controllers/network_controller.rb | 62 +++++---------------
.../test/functional/network_controller_test.rb | 2 +
2 files changed, 16 insertions(+), 48 deletions(-)

diff --git a/plugins/network/app/controllers/network_controller.rb
b/plugins/network/app/controllers/network_controller.rb
index 07b6e35..d644539 100644
--- a/plugins/network/app/controllers/network_controller.rb
+++ b/plugins/network/app/controllers/network_controller.rb
@@ -9,21 +9,13 @@ class NetworkController < ApplicationController
# Initialize GetText and Content-Type.
init_gettext "yast_webclient_network"

- private
- def network_permissions
- @client =
YaST::ServiceResource.proxy_for('org.opensuse.yast.modules.yapi.network')
- unless @client
- # FIXME: check the reason why proxy_for failed, i.e.
- # - no server known
- # - no permission to connect to server
- # - server does not provide interface
- # - server does not respond (timeout, etc.)
- # - invalid session
- flash[:notice] = _("Invalid session, please login again.")
- redirect_to( logout_path ) and return
- end
+ public
+ def initialize
+ end
+
+ # GET /network
+ def index

- @permissions = @client.permissions
@ifcs = load_proxy "org.opensuse.yast.modules.yapi.network.interfaces",
:all
@iface = params[:interface] || @ifcs[0].id

@@ -39,13 +31,14 @@ class NetworkController < ApplicationController
rt = load_proxy "org.opensuse.yast.modules.yapi.network.routes", "default"
return false unless rt

-# # FIXME mixed up by multiple load_proxy
-# unless @permissions[:read]
-# flash[:warning] = _("No permissions for network module")
-# redirect_to root_path
-# return false
-# end
-#
+
+ # FIXME mixed up by multiple load_proxy
+ unless @permissions[:read]
+ flash[:warning] = _("No permissions for network module")
+ redirect_to root_path
+ return false
+ end
+

@conf_mode = ifc.bootproto
if @conf_mode == "static"
@@ -62,32 +55,8 @@ class NetworkController < ApplicationController

@default_route = rt.via

-# @network =
YaST::ServiceResource.proxy_for('org.opensuse.yast.system.network')
-# unless @network
-# flash[:notice] = _("Invalid session, please login again.")
-# redirect_to( logout_path ) and return
-# end
end
-
- public
- def initialize
- end
-
- # GET /network
- def index
- return unless network_permissions
- @networks = []
- begin
- @networks = @client.find(:all)
- rescue ActiveResource::ClientError => e
- flash[:error] = YaST::ServiceResource.error(e)
- end

- respond_to do |format|
- format.html # index.html.erb
- format.xml { render :xml => @networks }
- end
- end

# GET /users/1/edit
def edit
@@ -103,7 +72,6 @@ class NetworkController < ApplicationController
end

rt.via = params["default_route"]
-# fill_proxy_with_time t,params

begin
rt.save
@@ -116,8 +84,6 @@ class NetworkController < ApplicationController
logger.warn e
end

-# redirect_to :action => :index
-# index
redirect_to :action => 'index'
end
end
diff --git a/plugins/network/test/functional/network_controller_test.rb
b/plugins/network/test/functional/network_controller_test.rb
index 02520a7..e527e1c 100644
--- a/plugins/network/test/functional/network_controller_test.rb
+++ b/plugins/network/test/functional/network_controller_test.rb
@@ -66,6 +66,7 @@ class NetworkControllerTest < ActionController::TestCase
assert_response :success
# test just the last assignment, for brevity
assert_not_nil assigns(:default_route)
+ assert_not_nil assigns(:name)
end

def test_with_dhcp
@@ -74,6 +75,7 @@ class NetworkControllerTest < ActionController::TestCase
assert_response :success
# test just the last assignment, for brevity
assert_not_nil assigns(:default_route)
+ assert_not_nil assigns(:name)
end

end
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages