项目中使用的Rails版本升级 2.2.2=>2.3.8
2010-06-25 15:40
423 查看
项目中使用的Rails版本是2.2.2,想升级到到最新的2.3.8,因此做了相关的调查。调查分两方面进行:一方面是调查Rails的变更履历(在网上可以查到很多,JavaEye新闻就有,就不介绍了);一方面是在安装完Rails 2.3.8后,执行Rake测试(我们的测试Case还是很充分的,代码的覆盖率在90%以上)。
首先,要修改 environment.rb
rake时发生了下列错误
Test::Unit::TestCase 已经被要求切换为 ActiveSupport::TestCase。
xxx_controller_test中,又爆出了错误。
需要把 class XXXControllerTest < ActiveSupport::TestCase 改成 class XXXControllerTest < ActionController::TestCase。
ActionController的变化还是蛮大的。
[list]
[*]2.2.2中Response继承的是AbstractResponse,Request继承的是AbstractRequest,而2.3.8中Response继承的是Rack::Response,Request继承的是Rack::Request。
[*]2.3.8中,如果要在TestResponse中设定header信息,可以用 @header、headers、header 三种形式,Rack::Response中有 alias :headers, :header 的定义。而2.2.2中可用的 @headers 已经不能用了。
[*]ActionController::Base中的assign_default_content_type_and_charset也已经消失,需要改为调用response.assign_default_content_type_and_charset!
[*]2.2.2中如果在action中发生了RuntimeError,response的状态码是0(初始值为nil);而2.3.8中,返回的是200(初始值为200)。
[/list]
由于我们项目的代码覆写了ActionController中的一些方法,着实费了一番功夫。不过了解到了test执行时的方法调用顺序,总算是有些收获。
当在test中,执行 get :action 的时候,调用顺序如下:
首先,要修改 environment.rb
RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
...
config.action_controller.session = {
:key => '_quanp_auth_session_id', # session_key已经不推荐
:secret => secret
}
end
rake时发生了下列错误
./test/unit/../test_helper.rb:19: undefined method `use_transactional_fixtures='
for Test::Unit::TestCase:Class (NoMethodError)
Test::Unit::TestCase 已经被要求切换为 ActiveSupport::TestCase。
xxx_controller_test中,又爆出了错误。
NoMethodError: undefined method `get' for #<ServerControllerTest:0x47cc7e4>
需要把 class XXXControllerTest < ActiveSupport::TestCase 改成 class XXXControllerTest < ActionController::TestCase。
ActionController的变化还是蛮大的。
[list]
[*]2.2.2中Response继承的是AbstractResponse,Request继承的是AbstractRequest,而2.3.8中Response继承的是Rack::Response,Request继承的是Rack::Request。
[*]2.3.8中,如果要在TestResponse中设定header信息,可以用 @header、headers、header 三种形式,Rack::Response中有 alias :headers, :header 的定义。而2.2.2中可用的 @headers 已经不能用了。
[*]ActionController::Base中的assign_default_content_type_and_charset也已经消失,需要改为调用response.assign_default_content_type_and_charset!
[*]2.2.2中如果在action中发生了RuntimeError,response的状态码是0(初始值为nil);而2.3.8中,返回的是200(初始值为200)。
[/list]
由于我们项目的代码覆写了ActionController中的一些方法,着实费了一番功夫。不过了解到了test执行时的方法调用顺序,总算是有些收获。
当在test中,执行 get :action 的时候,调用顺序如下:
ActionController::TestProcess::get阅读更多
|- ActionController::TestProcess::process
| |- ActionController::ProcessWithTest::process_with_test
| | |- ActionController::Base::process
| | | |- ActionController::Base::initialize_template_class
| | | |- ActionController::Base::assign_shortcuts
| | | |- ActionController::Base::initialize_current_url
| | | |- ActionController::Base::assign_names
| | | |- ActionController::Base::log_processing
| | | |- send(method, *arguments)
| | | |- ActionController::Base::send_response
| | | | |- ActionController::Response::prepare!
| | | | | |- ActionController::Response::assign_default_content_type_and_charset!
| | | | | |- ActionController::Response::handle_conditional_get!
| | | | | |- ActionController::Response::set_content_length!
| | | | | |- ActionController::Response::convert_content_type!
| | | | | |- ActionController::Response::convert_language!
| | | | | |- ActionController::Response::convert_cookies!
相关文章推荐
- android 升级ADT22版本后,使用第三方类库项目报错:java.lang.NoClassDefFoundError:xx.xx.xx
- android 升级ADT22版本后,使用第三方类库项目报错:java.lang.NoClassDefFoundError:xx.xx.xx
- Mac升级git版本 以及 使用git和github管理自己的项目---基础操作学习
- [病毒?]您正使用低版本的IE浏览器,建议您升级到Firefox!
- eclipse中使用不同jdk版本的项目设置
- JavaWeb项目升级版本之后导入上一个版本
- 当前 Firefox Plus 的最新版本是 2.0.0.8,您正在使用的版本是 2.0.0.11,我们强烈建议您立即升级到最新版本。
- 图解持续集成--纯命令行实现.Net项目每日构建(升级版本)
- 使用Visual Studio .NET 2010的配置和条件编译在一个项目实现不同版本
- 使用SWFObject2检查flashplayer版本并自动升级
- Visual Studio 2010 Web项目的jQuery版本升级方案
- 升级Turnkey Rails虚拟机到最新Rails版本
- 因为此版本的应用程序不支持其项目类型(.csproj),若要打开它,请使用支持此类型项目的版本
- Google Code项目代码托管网站上Git版本控制系统使用简明教程
- 使用Tortoise SVN版本控制Android项目in eclipse的注意事项
- 如何在创建rails项目时指定版本
- 某公司的一程序使用Framework组件需要升级到3.5版本
- rails安装、卸载、和使用 指定版本
- 使用代码的当前SVN版本构建项目build版号
- 研发项目管理软件 免费版本下载使用