Mailinglist Archive: yast-commit (1914 mails)

< Previous Next >
[yast-commit] <rest-service> basesystem : Moved the other controllers, adapted route ctrl test.
  • From: Martin Vidner <martin@xxxxxxxxxx>
  • Date: Tue, 1 Sep 2009 16:12:25 +0200
  • Message-id: <E1Mlezv-00048E-ST@xxxxxxxxxxxxxxxx>
ref: refs/heads/basesystem
commit 038b2cadbf4208635f7c23e764bd4164d8cc12d9
Author: Martin Vidner <martin@xxxxxxxxxx>
Date: Tue Sep 1 16:12:25 2009 +0200

Moved the other controllers, adapted route ctrl test.
---
plugins/network/app/controllers/dns_controller.rb | 45 ------------------
.../app/controllers/network/dns_controller.rb | 45 ++++++++++++++++++
.../app/controllers/network/routes_controller.rb | 49 ++++++++++++++++++++
.../network/app/controllers/routes_controller.rb | 49 --------------------
.../test/functional/routes_controller_test.rb | 26 +++++-----
5 files changed, 107 insertions(+), 107 deletions(-)

diff --git a/plugins/network/app/controllers/dns_controller.rb
b/plugins/network/app/controllers/dns_controller.rb
deleted file mode 100644
index 6e92ee0..0000000
--- a/plugins/network/app/controllers/dns_controller.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-# = Hostname controller
-# Provides access to hostname settings for authenticated users.
-# Main goal is checking permissions.
-class DnsController < ApplicationController
-
- before_filter :login_required
-
- # Sets hostname settings. Requires write permissions for network YaPI.
- def update
- unless permission_check( "org.opensuse.yast.modules.yapi.network.write")
- render ErrorResult.error(403, 1, "no permission") and return
- end
-
- root = params[:hostname]
- if root == nil
- render ErrorResult.error(404, 2, "format or internal error") and return
- end
-
- @dns = DNS.new(root)
- @dns.save
- render :show
- end
-
- # See update
- def create
- update
- end
-
- # Shows hostname settings. Requires read permission for network YaPI.
- def show
-
- unless permission_check( "org.opensuse.yast.modules.yapi.network.read")
- render ErrorResult.error( 403, 1, "no permission" ) and return
- end
-
- @dns = DNS.find
-
- respond_to do |format|
- format.html { render :xml => @dns.to_xml( :root => "dns", :dasherize =>
false ) }
- format.xml { render :xml => @dns.to_xml( :root => "dns", :dasherize =>
false ) }
- format.json { render :json => @dns.to_json }
- end
- end
-
-end
diff --git a/plugins/network/app/controllers/network/dns_controller.rb
b/plugins/network/app/controllers/network/dns_controller.rb
new file mode 100644
index 0000000..fa13f91
--- /dev/null
+++ b/plugins/network/app/controllers/network/dns_controller.rb
@@ -0,0 +1,45 @@
+# = Hostname controller
+# Provides access to hostname settings for authenticated users.
+# Main goal is checking permissions.
+class Network::DnsController < ApplicationController
+
+ before_filter :login_required
+
+ # Sets hostname settings. Requires write permissions for network YaPI.
+ def update
+ unless permission_check( "org.opensuse.yast.modules.yapi.network.write")
+ render ErrorResult.error(403, 1, "no permission") and return
+ end
+
+ root = params[:hostname]
+ if root == nil
+ render ErrorResult.error(404, 2, "format or internal error") and return
+ end
+
+ @dns = DNS.new(root)
+ @dns.save
+ render :show
+ end
+
+ # See update
+ def create
+ update
+ end
+
+ # Shows hostname settings. Requires read permission for network YaPI.
+ def show
+
+ unless permission_check( "org.opensuse.yast.modules.yapi.network.read")
+ render ErrorResult.error( 403, 1, "no permission" ) and return
+ end
+
+ @dns = DNS.find
+
+ respond_to do |format|
+ format.html { render :xml => @dns.to_xml( :root => "dns", :dasherize =>
false ) }
+ format.xml { render :xml => @dns.to_xml( :root => "dns", :dasherize =>
false ) }
+ format.json { render :json => @dns.to_json }
+ end
+ end
+
+end
diff --git a/plugins/network/app/controllers/network/routes_controller.rb
b/plugins/network/app/controllers/network/routes_controller.rb
new file mode 100644
index 0000000..dbf734e
--- /dev/null
+++ b/plugins/network/app/controllers/network/routes_controller.rb
@@ -0,0 +1,49 @@
+# = Routing controller
+# Provides access to hostname settings for authenticated users.
+# Main goal is checking permissions.
+class Network::RoutesController < ApplicationController
+
+ before_filter :login_required
+
+ # Sets hostname settings. Requires write permissions for network YaPI.
+ def update
+ unless permission_check( "org.opensuse.yast.modules.yapi.network.write")
+ render ErrorResult.error(403, 1, "no permission") and return
+ end
+
+ root = params[:routes]
+ if root == nil
+ render ErrorResult.error(404, 2, "format or internal error") and return
+ end
+
+ @routing = Route.new(root)
+ @routing.save
+ render :show
+ end
+
+ # See update
+ def create
+ update
+ end
+
+ # Shows hostname settings. Requires read permission for network YaPI.
+ def show
+
+ unless permission_check( "org.opensuse.yast.modules.yapi.network.read")
+ render ErrorResult.error( 403, 1, "no permission" ) and return
+ end
+
+ @route = Route.find(params[:id])
+
+ respond_to do |format|
+ format.html { render :xml => @route.to_xml( :root => "route", :dasherize
=> false ) }
+ format.xml { render :xml => @route.to_xml( :root => "route", :dasherize
=> false ) }
+ format.json { render :json => @route.to_json }
+ end
+ end
+
+ def index
+ show
+ end
+
+end
diff --git a/plugins/network/app/controllers/routes_controller.rb
b/plugins/network/app/controllers/routes_controller.rb
deleted file mode 100644
index dea97a8..0000000
--- a/plugins/network/app/controllers/routes_controller.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-# = Routing controller
-# Provides access to hostname settings for authenticated users.
-# Main goal is checking permissions.
-class RoutesController < ApplicationController
-
- before_filter :login_required
-
- # Sets hostname settings. Requires write permissions for network YaPI.
- def update
- unless permission_check( "org.opensuse.yast.modules.yapi.network.write")
- render ErrorResult.error(403, 1, "no permission") and return
- end
-
- root = params[:routes]
- if root == nil
- render ErrorResult.error(404, 2, "format or internal error") and return
- end
-
- @routing = Route.new(root)
- @routing.save
- render :show
- end
-
- # See update
- def create
- update
- end
-
- # Shows hostname settings. Requires read permission for network YaPI.
- def show
-
- unless permission_check( "org.opensuse.yast.modules.yapi.network.read")
- render ErrorResult.error( 403, 1, "no permission" ) and return
- end
-
- @route = Route.find(params[:id])
-
- respond_to do |format|
- format.html { render :xml => @route.to_xml( :root => "route", :dasherize
=> false ) }
- format.xml { render :xml => @route.to_xml( :root => "route", :dasherize
=> false ) }
- format.json { render :json => @route.to_json }
- end
- end
-
- def index
- show
- end
-
-end
diff --git a/plugins/network/test/functional/routes_controller_test.rb
b/plugins/network/test/functional/routes_controller_test.rb
index 68e1366..0bd377a 100644
--- a/plugins/network/test/functional/routes_controller_test.rb
+++ b/plugins/network/test/functional/routes_controller_test.rb
@@ -1,23 +1,23 @@
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
require 'test/unit'
-require 'rubygems'
require 'route'
-require "scr"
+require 'rubygems'
require 'mocha'
require File.expand_path( File.join("test","plugin_basic_tests"),
RailsParent.parent )

-class RoutesControllerTest < Test::Unit::TestCase
+class RoutesControllerTest < ActionController::TestCase
+
+ def setup
+ @model_class = Route
+ Route.stubs(:find).returns(Route.new({"via" => "42.42.42.42"}))
+ @controller = Network::RoutesController.new
+ @request = ActionController::TestRequest.new
+ # http://railsforum.com/viewtopic.php?id=1719
+ @request.session[:account_id] = 1 # defined in fixtures
+ end

- # this is test only for mocked data - not very useful
- # we need to extend it to test both model and controller
- # to extract routes data from all YaPI map
- #
- def test_show
- # if this code raises, test-unit 2.0.3 and mocha 0.9.5 fail
- # with PASSTHROUGH_EXCEPTIONS. version mismatch?!
- Route.expects(:find).returns({:routes=>{:default=>{'via'=>'10.20.30.40'}}})
- Route.find
- end
+ # some cases fail because PluginBasicTests expects a singular controller
+ #include PluginBasicTests

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