Mailinglist Archive: yast-commit (1914 mails)

< Previous Next >
[yast-commit] <rest-service> basesystem : Implemented routes :index
  • From: Martin Vidner <mvidner@xxxxxxx>
  • Date: Fri, 4 Sep 2009 17:45:26 +0200
  • Message-id: <E1Mlf01-0004Dj-Ic@xxxxxxxxxxxxxxxx>
ref: refs/heads/basesystem
commit 7f90415baec0c982246263e5cfa5aba16fafa87d
Author: Martin Vidner <mvidner@xxxxxxx>
Date: Fri Sep 4 17:24:52 2009 +0200

Implemented routes :index
---
.../app/controllers/network/routes_controller.rb | 11 ++++++++++-
.../test/functional/routes_controller_test.rb | 17 ++++++++++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/plugins/network/app/controllers/network/routes_controller.rb
b/plugins/network/app/controllers/network/routes_controller.rb
index dbf734e..d1740d1 100644
--- a/plugins/network/app/controllers/network/routes_controller.rb
+++ b/plugins/network/app/controllers/network/routes_controller.rb
@@ -43,7 +43,16 @@ class Network::RoutesController < ApplicationController
end

def index
- show
+ unless permission_check( "org.opensuse.yast.modules.yapi.network.read")
+ render ErrorResult.error( 403, 1, "no permission" ) and return
+ end
+
+ routes_a = Route.find(:all).values
+ respond_to do |format|
+ format.html { render :xml => routes_a.to_xml( :root => "routes",
:dasherize => false ) }
+ format.xml { render :xml => routes_a.to_xml( :root => "routes",
:dasherize => false ) }
+ format.json { render :json => routes_a.to_json }
+ end
end

end
diff --git a/plugins/network/test/functional/routes_controller_test.rb
b/plugins/network/test/functional/routes_controller_test.rb
index 0bd377a..d460aae 100644
--- a/plugins/network/test/functional/routes_controller_test.rb
+++ b/plugins/network/test/functional/routes_controller_test.rb
@@ -9,7 +9,9 @@ class RoutesControllerTest < ActionController::TestCase

def setup
@model_class = Route
- Route.stubs(:find).returns(Route.new({"via" => "42.42.42.42"}))
+ d = Route.new({"id" => "default", "via" => "42.42.42.42"})
+ Route.stubs(:find).with("default").returns(d)
+ Route.stubs(:find).with(:all).returns({"default" => d})
@controller = Network::RoutesController.new
@request = ActionController::TestRequest.new
# http://railsforum.com/viewtopic.php?id=1719
@@ -19,5 +21,18 @@ class RoutesControllerTest < ActionController::TestCase
# some cases fail because PluginBasicTests expects a singular controller
#include PluginBasicTests

+ def test_show_xml
+ get :show, :format => 'xml', :id => 'default'
+ h = Hash.from_xml @response.body
+ assert_instance_of String, h['route']['via']
+ end
+
+ def test_index_xml
+ get :index, :format => 'xml'
+ h = Hash.from_xml @response.body
+ assert_instance_of Array, h["routes"]
+ assert_equal "default", h["routes"][0]["id"]
+ 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