ref: refs/heads/master
commit f3d04e3694926c78d5b3aaf4323f5aee9c6b9f4d
Author: Josef Reidinger
Date: Thu Jul 9 09:13:50 2009 +0200
adapt to rails convention for model find/save
---
.../app/controllers/language_controller.rb | 2 +-
plugins/language/app/models/language.rb | 2 +-
.../test/functional/language_controller_test.rb | 2 +-
plugins/language/test/unit/language_test.rb | 2 +-
.../time/app/controllers/systemtimes_controller.rb | 2 +-
plugins/time/app/models/systemtime.rb | 2 +-
.../test/functional/systemtimes_controller_test.rb | 69 ++++----------------
plugins/time/test/unit/systemtime_test.rb | 2 +-
webservice/lib/plugin_basic_tests.rb | 8 +-
9 files changed, 24 insertions(+), 67 deletions(-)
diff --git a/plugins/language/app/controllers/language_controller.rb b/plugins/language/app/controllers/language_controller.rb
index de95cfc..33a0830 100644
--- a/plugins/language/app/controllers/language_controller.rb
+++ b/plugins/language/app/controllers/language_controller.rb
@@ -38,7 +38,7 @@ class LanguageController < ApplicationController
render ErrorResult.error(403, 1, "no permissions") and return
end
@language = Language.new
- @language.read
+ @language.find
end
diff --git a/plugins/language/app/models/language.rb b/plugins/language/app/models/language.rb
index f68fbb8..ab90259 100644
--- a/plugins/language/app/models/language.rb
+++ b/plugins/language/app/models/language.rb
@@ -44,7 +44,7 @@ class Language
return @@available
end
- def read
+ def find
parse_response YastService.Call("YaPI::LANGUAGE::Read",create_read_question)
end
diff --git a/plugins/language/test/functional/language_controller_test.rb b/plugins/language/test/functional/language_controller_test.rb
index 2bd3d81..0ecec92 100644
--- a/plugins/language/test/functional/language_controller_test.rb
+++ b/plugins/language/test/functional/language_controller_test.rb
@@ -16,7 +16,7 @@ class LanguageControllerTest < ActionController::TestCase
@data = Data
end
- include PluginBasicTests
+ include PluginBasicTests
Data = {:language => {
:current => "cs_CZ",
diff --git a/plugins/language/test/unit/language_test.rb b/plugins/language/test/unit/language_test.rb
index 861bd02..7af3ef9 100644
--- a/plugins/language/test/unit/language_test.rb
+++ b/plugins/language/test/unit/language_test.rb
@@ -44,7 +44,7 @@ class LanguageTest < ActiveSupport::TestCase
def test_getter
YastService.stubs(:Call).with("YaPI::LANGUAGE::Read",read_arguments).returns(read_response)
- @language.read
+ @language.find
assert_equal("en_US", @language.language)
assert_equal("ctype", @language.rootlocale)
assert_equal("true", @language.utf8)
diff --git a/plugins/time/app/controllers/systemtimes_controller.rb b/plugins/time/app/controllers/systemtimes_controller.rb
index 14951ba..e1b728f 100644
--- a/plugins/time/app/controllers/systemtimes_controller.rb
+++ b/plugins/time/app/controllers/systemtimes_controller.rb
@@ -40,7 +40,7 @@ class SystemtimesController < ApplicationController
end
@systemtime = Systemtime.new
- @systemtime.read
+ @systemtime.find
end
diff --git a/plugins/time/app/models/systemtime.rb b/plugins/time/app/models/systemtime.rb
index 52156aa..c4ee5a2 100644
--- a/plugins/time/app/models/systemtime.rb
+++ b/plugins/time/app/models/systemtime.rb
@@ -35,7 +35,7 @@ class Systemtime
def initialize
end
- def read
+ def find
parse_response YastService.Call("YaPI::TIME::Read",create_read_question)
end
diff --git a/plugins/time/test/functional/systemtimes_controller_test.rb b/plugins/time/test/functional/systemtimes_controller_test.rb
index 52dbd3d..f86e547 100644
--- a/plugins/time/test/functional/systemtimes_controller_test.rb
+++ b/plugins/time/test/functional/systemtimes_controller_test.rb
@@ -3,53 +3,27 @@ require 'test/unit'
require 'rubygems'
require "scr"
require 'mocha'
-
+require File.expand_path( File.join("lib","plugin_basic_tests"), RailsParent.parent )
class SystemtimesControllerTest < ActionController::TestCase
fixtures :accounts
+
+ Data = {:time => {
+ :timezone => "Europe/Prague",
+ :utcstatus => "true"
+ }}
+
def setup
+ @model_class = Systemtime
@controller = SystemtimesController.new
@request = ActionController::TestRequest.new
# http://railsforum.com/viewtopic.php?id=1719
@request.session[:account_id] = 1 # defined in fixtures
- end
-
- def test_access_show
- Systemtime.any_instance.stubs(:read)
- get :show
- assert_response :success
- end
-
- def test_access_denied
- #mock model to test only controller
- Systemtime.any_instance.stubs(:read)
- @controller.stubs(:permission_check).returns(false);
- get :show
- assert_response :forbidden
- end
-
-
- def test_access_show_xml
- Systemtime.any_instance.stubs(:read)
- 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
- Systemtime.any_instance.stubs(:read)
- mime = Mime::JSON
- @request.accept = mime.to_s
- get :show, :format => :json
- assert_equal mime.to_s, @response.content_type
- end
-
- Data = {:time => {
- :timezone => "Europe/Prague",
- :utcstatus => "true"
- }}
+ @data = Data
+ end
+ include PluginBasicTests
+
def test_update
Systemtime.any_instance.stubs(:save)
put :update, Data
@@ -69,22 +43,5 @@ class SystemtimesControllerTest < ActionController::TestCase
assert_equal Data[:time][:timezone], time.timezone
assert_equal Data[:time][:utcstatus], time.utcstatus
assert_nil time.datetime
- end
-
- def test_update_noparams
- Language.any_instance.stubs(:save)
- put :update
- assert_response :missing
- end
-
- def test_update_noperm
- #ensure that nothink is saved
- Language.any_instance.expects(:save).never
-
- @controller.stubs(:permission_check).returns(false);
-
- put :update, Data
-
- assert_response :forbidden
- end
+ end
end
\ No newline at end of file
diff --git a/plugins/time/test/unit/systemtime_test.rb b/plugins/time/test/unit/systemtime_test.rb
index 834caca..d2db794 100644
--- a/plugins/time/test/unit/systemtime_test.rb
+++ b/plugins/time/test/unit/systemtime_test.rb
@@ -56,7 +56,7 @@ class LanguageTest < ActiveSupport::TestCase
result = read_response
YastService.stubs(:Call).with("YaPI::TIME::Read",read_arguments).returns(result)
- @model.read
+ @model.find
assert_equal(result["time"], @model.datetime)
assert_equal("Europe/Prague", @model.timezone)
assert_equal("true", @model.utcstatus)
diff --git a/webservice/lib/plugin_basic_tests.rb b/webservice/lib/plugin_basic_tests.rb
index 1c071e6..7ac0864 100644
--- a/webservice/lib/plugin_basic_tests.rb
+++ b/webservice/lib/plugin_basic_tests.rb
@@ -44,21 +44,21 @@
module PluginBasicTests
def test_access_index
#mock model to test only controller
- @model_class.any_instance.stubs(:read)
+ @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(:read)
+ @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(:read)
+ @model_class.any_instance.stubs(:find)
mime = Mime::XML
@request.accept = mime.to_s
get :show, :format => :xml
@@ -66,7 +66,7 @@ module PluginBasicTests
end
def test_access_show_json
- @model_class.any_instance.stubs(:read)
+ @model_class.any_instance.stubs(:find)
mime = Mime::JSON
@request.accept = mime.to_s
get :show, :format => :json
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org