提交 0dd3eac9 编写于 作者: R Rizwan Reza

Merge branch 'master' of git://github.com/rails/rails

......@@ -2,7 +2,7 @@ path File.dirname(__FILE__)
source 'http://rubygems.org'
gem "arel", :git => "git://github.com/rails/arel.git"
gem "rails", "3.0.0.beta1"
gem "rails", "3.0.0.beta2"
gem "rake", ">= 0.8.7"
gem "mocha", ">= 0.9.8"
......
*Rails 3.0 (pending)*
*Rails 3.0.0 [beta 2] (April 1st, 2010)*
* Added interceptors and observers from Mail [ML]
ActionMailer::Base.register_interceptor calls Mail.register_interceptor
ActionMailer::Base.register_observer calls Mail.register_observer
* Whole new API added with tests. See base.rb for full details. Old API is deprecated.
*Rails 3.0.0 [beta 1] (February 4, 2010)*
* The Mail::Message class has helped methods for all the field types that return 'common' defaults for the common use case, so to get the subject, mail.subject will give you a string, mail.date will give you a DateTime object, mail.from will give you an array of address specs (mikel@test.lindsaar.net) etc. If you want to access the field object itself, call mail[:field_name] which will return the field object you want, which you can then chain, like mail[:from].formatted
* Mail#content_type now returns the content_type field as a string. If you want the mime type of a mail, then you call Mail#mime_type (eg, text/plain), if you want the parameters of the content type field, you call Mail#content_type_parameters which gives you a hash, eg {'format' => 'flowed', 'charset' => 'utf-8'}
......
......@@ -3,7 +3,7 @@ module VERSION #:nodoc:
MAJOR = 3
MINOR = 0
TINY = 0
BUILD = "beta1"
BUILD = "beta2"
STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
end
......
此差异已折叠。
......@@ -48,7 +48,7 @@ def formats
@env["action_dispatch.request.formats"] ||=
if parameters[:format]
Array(Mime[parameters[:format]])
elsif xhr? || (accept && !accept.include?(?,))
elsif xhr? || (accept && accept !~ /,\s*\*\/\*/)
accepts
else
[Mime::HTML]
......@@ -87,4 +87,4 @@ def negotiate_mime(order)
end
end
end
end
\ No newline at end of file
end
......@@ -3,7 +3,7 @@ module VERSION #:nodoc:
MAJOR = 3
MINOR = 0
TINY = 0
BUILD = "beta1"
BUILD = "beta2"
STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
end
......
......@@ -93,6 +93,10 @@ def form_tag(url_for_options = {}, options = {}, *parameters_for_url, &block)
# # => <select disabled="disabled" id="destination" name="destination"><option>NYC</option>
# # <option>Paris</option><option>Rome</option></select>
def select_tag(name, option_tags = nil, options = {})
if Array === option_tags
ActiveSupport::Deprecation.warn 'Passing an array of option_tags to select_tag implicitly joins them without marking them as HTML-safe. Pass option_tags.join.html_safe instead.', caller
end
html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name
if blank = options.delete(:include_blank)
if blank.kind_of?(String)
......
......@@ -273,8 +273,12 @@ def number_with_precision(number, *args)
strip_insignificant_zeros = options.delete :strip_insignificant_zeros
if significant and precision > 0
digits = (Math.log10(number) + 1).floor
rounded_number = BigDecimal.new((number / 10 ** (digits - precision)).to_s).round.to_f * 10 ** (digits - precision)
if number == 0
digits, rounded_number = 1, 0
else
digits = (Math.log10(number) + 1).floor
rounded_number = BigDecimal.new((number / 10 ** (digits - precision)).to_s).round.to_f * 10 ** (digits - precision)
end
precision = precision - digits
precision = precision > 0 ? precision : 0 #don't let it be negative
else
......
......@@ -158,6 +158,12 @@ def test_select_tag_with_include_blank_with_string
assert_dom_equal expected, actual
end
def test_select_tag_with_array_options
assert_deprecated /array/ do
select_tag "people", ["<option>david</option>"]
end
end
def test_text_area_tag_size_string
actual = text_area_tag "body", "hello world", "size" => "20x40"
expected = %(<textarea cols="20" id="body" name="body" rows="40">hello world</textarea>)
......
......@@ -102,6 +102,9 @@ def test_number_with_precision
assert_equal("3268", number_with_precision((32.6751 * 100.00), :precision => 0))
assert_equal("112", number_with_precision(111.50, :precision => 0))
assert_equal("1234567892", number_with_precision(1234567891.50, :precision => 0))
assert_equal("0", number_with_precision(0, :precision => 0))
assert_equal("0.00100", number_with_precision(0.001, :precision => 5))
assert_equal("0.001", number_with_precision(0.00111, :precision => 3))
end
def test_number_with_precision_with_custom_delimiter_and_separator
......@@ -122,11 +125,17 @@ def test_number_with_precision_with_significant_digits
assert_equal "53", number_with_precision(52.7923, :precision => 2, :significant => true )
assert_equal "9775.00", number_with_precision(9775, :precision => 6, :significant => true )
assert_equal "5.392900", number_with_precision(5.3929, :precision => 7, :significant => true )
assert_equal "0.0", number_with_precision(0, :precision => 2, :significant => true )
assert_equal "0", number_with_precision(0, :precision => 1, :significant => true )
assert_equal "0.0001", number_with_precision(0.0001, :precision => 1, :significant => true )
assert_equal "0.000100", number_with_precision(0.0001, :precision => 3, :significant => true )
assert_equal "0.0001", number_with_precision(0.0001111, :precision => 1, :significant => true )
end
def test_number_with_precision_with_strip_insignificant_zeros
assert_equal "9775.43", number_with_precision(9775.43, :precision => 4, :strip_insignificant_zeros => true )
assert_equal "9775.2", number_with_precision(9775.2, :precision => 6, :significant => true, :strip_insignificant_zeros => true )
assert_equal "0", number_with_precision(0, :precision => 6, :significant => true, :strip_insignificant_zeros => true )
end
def test_number_with_precision_with_significant_true_and_zero_precision
......
*Edge*
*Rails 3.0.0 [beta 2] (April 1st, 2010)*
* #new_record? and #destroyed? were removed from ActiveModel::Lint. Use
persisted? instead. A model is persisted if it's not a new_record? and it was
not destroyed? [MG]
* Added validations reflection in ActiveModel::Validations [JV]
Model.validators
Model.validators_on(:field)
* #to_key was added to ActiveModel::Lint so we can generate DOM IDs for
AMo objects with composite keys [MG]
*Rails 3.0.0 [beta 1] (February 4, 2010)*
* ActiveModel::Observer#add_observer!
......
version = File.read(File.expand_path("../../RAILS_VERSION", __FILE__)).strip
version = File.read(File.expand_path('../../RAILS_VERSION', __FILE__)).strip
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'activemodel'
s.version = version
s.summary = 'A toolkit for building modeling frameworks (part of Rails).'
s.platform = Gem::Platform::RUBY
s.name = 'activemodel'
s.version = version
s.summary = 'A toolkit for building modeling frameworks (part of Rails).'
s.description = 'A toolkit for building modeling frameworks like Active Record and Active Resource. Rich support for attributes, callbacks, validations, observers, serialization, internationalization, and testing.'
s.required_ruby_version = '>= 1.8.7'
s.author = "David Heinemeier Hansson"
s.email = "david@loudthinking.com"
s.rubyforge_project = "activemodel"
s.homepage = "http://www.rubyonrails.org"
s.author = 'David Heinemeier Hansson'
s.email = 'david@loudthinking.com'
s.homepage = 'http://www.rubyonrails.org'
s.rubyforge_project = 'activemodel'
s.files = Dir['CHANGELOG', 'MIT-LICENSE', 'README', 'lib/**/*']
s.require_path = 'lib'
s.has_rdoc = true
s.add_dependency('activesupport', version)
s.require_path = 'lib'
s.files = Dir["CHANGELOG", "MIT-LICENSE", "README", "lib/**/*"]
end
......@@ -91,17 +91,12 @@ module Dirty
attribute_method_affix :prefix => 'reset_', :suffix => '!'
end
def initialize(*)
@changed_attributes = {}
super
end
# Do any attributes have unsaved changes?
# person.changed? # => false
# person.name = 'bob'
# person.changed? # => true
def changed?
!@changed_attributes.empty?
!changed_attributes.empty?
end
# List of attributes with unsaved changes.
......@@ -109,7 +104,7 @@ def changed?
# person.name = 'bob'
# person.changed # => ['name']
def changed
@changed_attributes.keys
changed_attributes.keys
end
# Map of changed attrs => [original value, new value].
......@@ -130,19 +125,24 @@ def previous_changes
end
private
# Map of change <tt>attr => original value</tt>.
def changed_attributes
@changed_attributes ||= {}
end
# Handle <tt>*_changed?</tt> for +method_missing+.
def attribute_changed?(attr)
@changed_attributes.include?(attr)
changed_attributes.include?(attr)
end
# Handle <tt>*_change</tt> for +method_missing+.
def attribute_change(attr)
[@changed_attributes[attr], __send__(attr)] if attribute_changed?(attr)
[changed_attributes[attr], __send__(attr)] if attribute_changed?(attr)
end
# Handle <tt>*_was</tt> for +method_missing+.
def attribute_was(attr)
attribute_changed?(attr) ? @changed_attributes[attr] : __send__(attr)
attribute_changed?(attr) ? changed_attributes[attr] : __send__(attr)
end
# Handle <tt>*_will_change!</tt> for +method_missing+.
......@@ -153,12 +153,12 @@ def attribute_will_change!(attr)
rescue TypeError, NoMethodError
end
@changed_attributes[attr] = value
changed_attributes[attr] = value
end
# Handle <tt>reset_*!</tt> for +method_missing+.
def reset_attribute!(attr)
__send__("#{attr}=", @changed_attributes[attr]) if attribute_changed?(attr)
__send__("#{attr}=", changed_attributes[attr]) if attribute_changed?(attr)
end
end
end
......@@ -3,7 +3,7 @@ module VERSION #:nodoc:
MAJOR = 3
MINOR = 0
TINY = 0
BUILD = "beta1"
BUILD = "beta2"
STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
end
......
......@@ -6,7 +6,6 @@ class DirtyModel
define_attribute_methods [:name]
def initialize
super
@name = nil
end
......
......@@ -6,6 +6,7 @@
s.version = version
s.summary = 'Object-relational mapper framework (part of Rails).'
s.description = 'Databases on Rails. Build a persistent domain model by mapping database tables to Ruby classes. Strong conventions for associations, validations, aggregations, migrations, and testing come baked-in.'
s.required_ruby_version = '>= 1.8.7'
s.author = 'David Heinemeier Hansson'
......
......@@ -23,7 +23,8 @@ module Format
#
# +name+ is the column's name, such as <tt>supplier_id</tt> in <tt>supplier_id int(11)</tt>.
# +default+ is the type-casted default value, such as +new+ in <tt>sales_stage varchar(20) default 'new'</tt>.
# +sql_type+ is only used to extract the column's length, if necessary. For example +60+ in <tt>company_name varchar(60)</tt>.
# +sql_type+ is used to extract the column's length, if necessary. For example +60+ in <tt>company_name varchar(60)</tt>.
# It will be mapped to one of the standard Rails SQL types in the <tt>type</tt> attribute.
# +null+ determines if this column allows +NULL+ values.
def initialize(name, default, sql_type = nil, null = true)
@name, @sql_type, @null = name, sql_type, null
......
......@@ -114,6 +114,12 @@ def simplified_type(field_type)
# Object identifier types
when /^oid$/
:integer
# UUID type
when /^uuid$/
:string
# Small and big integer types
when /^(?:small|big)int$/
:integer
# Pass through all types that are not specific to PostgreSQL.
else
super
......
......@@ -84,7 +84,7 @@ namespace :db do
end
end
when 'postgresql'
@encoding = config[:encoding] || ENV['CHARSET'] || 'utf8'
@encoding = config['encoding'] || ENV['CHARSET'] || 'utf8'
schema_search_path = config['schema_search_path'] || 'public'
first_in_schema_search_path = schema_search_path.split(',').first.strip
begin
......
......@@ -3,7 +3,7 @@ module VERSION #:nodoc:
MAJOR = 3
MINOR = 0
TINY = 0
BUILD = "beta1"
BUILD = "beta2"
STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
end
......
......@@ -67,4 +67,21 @@ def test_has_default_should_return_false_for_blog_and_test_data_types
assert !text_column.has_default?
end
end
if current_adapter?(:PostgreSQLAdapter)
def test_bigint_column_should_map_to_integer
bigint_column = ActiveRecord::ConnectionAdapters::PostgreSQLColumn.new('number', nil, "bigint")
assert_equal bigint_column.type, :integer
end
def test_smallint_column_should_map_to_integer
smallint_column = ActiveRecord::ConnectionAdapters::PostgreSQLColumn.new('number', nil, "smallint")
assert_equal smallint_column.type, :integer
end
def test_uuid_column_should_map_to_string
uuid_column = ActiveRecord::ConnectionAdapters::PostgreSQLColumn.new('unique_id', nil, "uuid")
assert_equal uuid_column.type, :string
end
end
end
*Edge*
*Rails 3.0.0 [beta 1] (February 4, 2010)*
* Add support for errors in JSON format. #1956 [Fabien Jakimowicz]
......
......@@ -6,6 +6,7 @@
s.version = version
s.summary = 'REST modeling framework (part of Rails).'
s.description = 'REST on Rails. Wrap your RESTful web app with Ruby classes and work with them like Active Record models.'
s.required_ruby_version = '>= 1.8.7'
s.author = 'David Heinemeier Hansson'
......
......@@ -3,7 +3,7 @@ module VERSION #:nodoc:
MAJOR = 3
MINOR = 0
TINY = 0
BUILD = "beta1"
BUILD = "beta2"
STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
end
......
*Rails 3.0 (pending)*
*Rails 3.0.0 [beta 2] (April 1st, 2010)*
* Reduced load time by deferring configuration of classes using
ActiveSupport::on_load(:component_name) [YK]
* Rename #metaclass to #singleton_class now that ruby-core has decided [JK]
* New assertions assert_blank and assert_present. #4299 [Juanjo Bazan]
......@@ -7,7 +12,7 @@
* JSON backend for YAJL. Preferred if available. #2666 [Brian Lopez]
*Rails 3.0.0 [beta] (February 4, 2010)*
*Rails 3.0.0 [beta 1] (February 4, 2010)*
* Introduce class_attribute to declare inheritable class attributes. Writing an attribute on a subclass behaves just like overriding the superclass reader method. Unifies and replaces most usage of cattr_accessor, class_inheritable_attribute, superclass_delegating_attribute, and extlib_inheritable_attribute. [Jeremy Kemper, Yehuda Katz]
......
......@@ -6,6 +6,7 @@
s.version = version
s.summary = 'A toolkit of support libraries and Ruby core extensions extracted from the Rails framework.'
s.description = 'A toolkit of support libraries and Ruby core extensions extracted from the Rails framework. Rich support for multibyte strings, internationalization, time zones, and testing.'
s.required_ruby_version = '>= 1.8.7'
s.author = 'David Heinemeier Hansson'
......
......@@ -50,7 +50,7 @@ def class_attribute(*attrs)
singleton_class.send(:define_method, attr) { value }
end
define_method(attr) { self.class.send(attr) }
define_method(attr) { self.singleton_class.send(attr) }
define_method(:"#{attr}?") { !!send(attr) }
define_method(:"#{attr}=") do |value|
singleton_class.remove_possible_method(attr)
......
......@@ -3,7 +3,7 @@ module VERSION #:nodoc:
MAJOR = 3
MINOR = 0
TINY = 0
BUILD = "beta1"
BUILD = "beta2"
STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
end
......
......@@ -59,4 +59,10 @@ def setup
object = Class.new { class_attribute :setting, :instance_writer => false }.new
assert_raise(NoMethodError) { object.setting = 'boom' }
end
test 'works well with singleton classes' do
object = @klass.new
object.singleton_class.setting = 'foo'
assert_equal 'foo', object.setting
end
end
......@@ -6,7 +6,8 @@
s.version = version
s.summary = 'Full-stack web application framework.'
s.description = 'Ruby on Rails is a full-stack web framework optimized for programmer happiness and sustainable productivity. It encourages beautiful code by favoring convention over configuration.'
s.required_ruby_version = '>= 1.8.7'
s.required_ruby_version = '>= 1.8.7'
s.required_rubygems_version = ">= 1.3.6"
s.author = 'David Heinemeier Hansson'
......@@ -17,11 +18,11 @@
s.files = []
s.require_path = []
s.add_dependency('activesupport', version)
s.add_dependency('actionpack', version)
s.add_dependency('activerecord', version)
s.add_dependency('activeresource', version)
s.add_dependency('actionmailer', version)
s.add_dependency('railties', version)
s.add_dependency('bundler', '>= 0.9.8')
s.add_dependency('activesupport', version)
s.add_dependency('actionpack', version)
s.add_dependency('activerecord', version)
s.add_dependency('activeresource', version)
s.add_dependency('actionmailer', version)
s.add_dependency('railties', version)
s.add_dependency('bundler', '>= 0.9.14')
end
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'rails3b'
s.version = '3.0.1'
s.summary = 'Just the Rails 3 beta dependencies. Works around prerelease RubyGems bug in versions before 1.3.6.'
s.required_ruby_version = '>= 1.8.7'
s.author = 'Jeremy Kemper'
s.email = 'jeremy@bitsweat.net'
s.files = []
s.require_path = []
s.add_dependency('mail', '~> 2.1.2')
s.add_dependency('text-format', '~> 1.0.0')
s.add_dependency('rack', '~> 1.1.0')
s.add_dependency('rack-test', '~> 0.5.0')
s.add_dependency('rack-mount', '= 0.4.7')
s.add_dependency('erubis', '~> 2.6.5')
s.add_dependency('i18n', '~> 0.3.0')
s.add_dependency('tzinfo', '~> 0.3.16')
s.add_dependency('builder', '~> 2.1.2')
s.add_dependency('memcache-client', '~> 1.7.5')
s.add_dependency('bundler', '>= 0.9.8')
s.add_dependency('rake', '>= 0.8.3')
s.add_dependency('thor', '~> 0.13')
end
*Edge*
*Rails 3.0.0 [beta 2] (April 1st, 2010)*
* Session store configuration has changed [YK & CL]
config.session_store :cookie_store, {:key => "..."}
config.cookie_secret = "fdsfhisdghfidugnfdlg"
* railtie_name and engine_name are deprecated. You can now add any object to
the configuration object: config.your_plugin = {} [JK]
* Added config.generators.templates to provide alternative paths for the generators
to look for templates [JV]
*Rails 3.0.0 [beta 1] (February 4, 2010)*
* Added "rake about" as a replacement for script/about [DHH]
......
......@@ -31,6 +31,9 @@ class AppGenerator < Base
class_option :edge, :type => :boolean, :default => false,
:desc => "Setup the application with Gemfile pointing to Rails repository"
class_option :skip_gemfile, :type => :boolean, :default => false,
:desc => "Don't create a Gemfile"
class_option :skip_activerecord, :type => :boolean, :aliases => "-O", :default => false,
:desc => "Skip ActiveRecord files"
......@@ -71,7 +74,7 @@ def create_root_files
copy_file "gitignore", ".gitignore" unless options[:skip_git]
template "Rakefile"
template "config.ru"
template "Gemfile"
template "Gemfile" unless options[:skip_gemfile]
end
def create_app_files
......
......@@ -11,8 +11,9 @@
require "rails/test_unit/railtie"
<% end -%>
# Auto-require default libraries and those for the current Rails environment.
Bundler.require :default, Rails.env
# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)
module <%= app_const_base %>
class Application < Rails::Application
......
# Use Bundler (preferred)
# Use locked gems if present.
begin
require File.expand_path('../../.bundle/environment', __FILE__)
rescue LoadError
# Otherwise, use RubyGems.
require 'rubygems'
require 'bundler'
Bundler.setup
# And set up the gems listed in the Gemfile.
if File.exist?(File.expand_path('../../Gemfile', __FILE__))
require 'bundler'
Bundler.setup
end
end
......@@ -3,7 +3,7 @@ module VERSION #:nodoc:
MAJOR = 3
MINOR = 0
TINY = 0
BUILD = "beta1"
BUILD = "beta2"
STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
end
......
......@@ -3,7 +3,7 @@ module VERSION #:nodoc:
MAJOR = 3
MINOR = 0
TINY = 0
BUILD = "beta1"
BUILD = "beta2"
STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册