ref: refs/heads/master
commit 8f286b82a9512275c7f5c970eaf68c5478f40d2c
Author: Josef Reidinger
Date: Thu Jul 9 12:03:59 2009 +0200
move plugin_basic_tests from lib to test
---
webservice/lib/plugin_basic_tests.rb | 93 ---------------------------------
webservice/test/plugin_basic_tests.rb | 93 +++++++++++++++++++++++++++++++++
2 files changed, 93 insertions(+), 93 deletions(-)
diff --git a/webservice/lib/plugin_basic_tests.rb b/webservice/lib/plugin_basic_tests.rb
deleted file mode 100644
index 1ac1760..0000000
--- a/webservice/lib/plugin_basic_tests.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-# = PluginBasicTests module
-# The module is designed to perform few basic tests of webservice plugin
-# controller behavior. Its goal is provide same unify behavior to each
-# webservice plugin like unified response if user doesn't have permissions
-# or same content type.
-# == Prerequisites
-# The module expect some hints from controller test file for correct work.
-# It needs model class specified at @*model_class* field, controller instance at
-# @*controller* and request specification at @*request* field. Field @*data* is
-# used to test update with valid data but without permissions.
-# Controller is expected to be thin layer and all dbus or system call is done
-# at model code. Controller use during reading only *find* metode of model
-# and during writing only *save* method.
-# == Example usage
-# This example show basic testing of controller of plugin
-# require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
-# require 'test/unit'
-# require 'rubygems'
-# require 'mocha'
-# require File.expand_path( File.join("lib","plugin_basic_tests"), RailsParent.parent )
-#
-# class LanguageControllerTest < ActionController::TestCase
-# fixtures :accounts
-#
-# Test_data = {:language => {
-# :current => "cs_CZ",
-# :utf8 => "true",
-# :rootlocale => "false"
-# }}
-# def setup
-# @model_class = Language
-# @controller = LanguageController.new
-# @request = ActionController::TestRequest.new
-# # http://railsforum.com/viewtopic.php?id=1719
-# @request.session[:account_id] = 1 # defined in fixtures
-# @data = Test_data
-# end
-#
-# include PluginBasicTests
-# #another specific controller test like correct parsing arguments
-# #or specific exceptions
-# end
-
-module PluginBasicTests
- def test_access_index
- #mock model to test only controller
- @model_class.any_instance.stubs(:find)
- get :show
- assert_response :success
- end
-
- def test_access_denied
- #mock model to test only controller
- @model_class.any_instance.stubs(:find)
- @controller.stubs(:permission_check).returns(false);
- get :show
- assert_response :forbidden
- end
-
- def test_access_show_xml
- @model_class.any_instance.stubs(:find)
- mime = Mime::XML
- @request.accept = mime.to_s
- get :show, :format => :xml
- assert_equal mime.to_s, @response.content_type
- end
-
- def test_access_show_json
- @model_class.any_instance.stubs(:find)
- mime = Mime::JSON
- @request.accept = mime.to_s
- get :show, :format => :json
- assert_equal mime.to_s, @response.content_type
- end
-
- def test_update_noparams
- @model_class.any_instance.stubs(:save)
- put :update
- assert_response :missing
- end
-
- def test_update_noperm
- #ensure that nothink is saved
- @model_class.any_instance.expects(:save).never
-
- @controller.stubs(:permission_check).returns(false);
-
- put :update, @data
-
- assert_response :forbidden
- end
-end
-
diff --git a/webservice/test/plugin_basic_tests.rb b/webservice/test/plugin_basic_tests.rb
new file mode 100644
index 0000000..1ac1760
--- /dev/null
+++ b/webservice/test/plugin_basic_tests.rb
@@ -0,0 +1,93 @@
+# = PluginBasicTests module
+# The module is designed to perform few basic tests of webservice plugin
+# controller behavior. Its goal is provide same unify behavior to each
+# webservice plugin like unified response if user doesn't have permissions
+# or same content type.
+# == Prerequisites
+# The module expect some hints from controller test file for correct work.
+# It needs model class specified at @*model_class* field, controller instance at
+# @*controller* and request specification at @*request* field. Field @*data* is
+# used to test update with valid data but without permissions.
+# Controller is expected to be thin layer and all dbus or system call is done
+# at model code. Controller use during reading only *find* metode of model
+# and during writing only *save* method.
+# == Example usage
+# This example show basic testing of controller of plugin
+# require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
+# require 'test/unit'
+# require 'rubygems'
+# require 'mocha'
+# require File.expand_path( File.join("lib","plugin_basic_tests"), RailsParent.parent )
+#
+# class LanguageControllerTest < ActionController::TestCase
+# fixtures :accounts
+#
+# Test_data = {:language => {
+# :current => "cs_CZ",
+# :utf8 => "true",
+# :rootlocale => "false"
+# }}
+# def setup
+# @model_class = Language
+# @controller = LanguageController.new
+# @request = ActionController::TestRequest.new
+# # http://railsforum.com/viewtopic.php?id=1719
+# @request.session[:account_id] = 1 # defined in fixtures
+# @data = Test_data
+# end
+#
+# include PluginBasicTests
+# #another specific controller test like correct parsing arguments
+# #or specific exceptions
+# end
+
+module PluginBasicTests
+ def test_access_index
+ #mock model to test only controller
+ @model_class.any_instance.stubs(:find)
+ get :show
+ assert_response :success
+ end
+
+ def test_access_denied
+ #mock model to test only controller
+ @model_class.any_instance.stubs(:find)
+ @controller.stubs(:permission_check).returns(false);
+ get :show
+ assert_response :forbidden
+ end
+
+ def test_access_show_xml
+ @model_class.any_instance.stubs(:find)
+ mime = Mime::XML
+ @request.accept = mime.to_s
+ get :show, :format => :xml
+ assert_equal mime.to_s, @response.content_type
+ end
+
+ def test_access_show_json
+ @model_class.any_instance.stubs(:find)
+ mime = Mime::JSON
+ @request.accept = mime.to_s
+ get :show, :format => :json
+ assert_equal mime.to_s, @response.content_type
+ end
+
+ def test_update_noparams
+ @model_class.any_instance.stubs(:save)
+ put :update
+ assert_response :missing
+ end
+
+ def test_update_noperm
+ #ensure that nothink is saved
+ @model_class.any_instance.expects(:save).never
+
+ @controller.stubs(:permission_check).returns(false);
+
+ put :update, @data
+
+ assert_response :forbidden
+ end
+end
+
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org