Merge remote branch 'rails/master'

This commit is contained in:
Xavier Noria 2010-07-31 11:55:24 +02:00
commit 3d7099891f
19 changed files with 99 additions and 56 deletions

@ -27,7 +27,7 @@ end
platforms :ruby do
gem 'json'
gem 'yajl-ruby'
gem "nokogiri", ">= 1.4.2"
gem "nokogiri", ">= 1.4.3.1"
# AR
gem "sqlite3-ruby", "~> 1.3.1", :require => 'sqlite3'
@ -50,7 +50,7 @@ platforms :jruby do
end
env 'CI' do
gem "nokogiri", ">= 1.4.2"
gem "nokogiri", ">= 1.4.3.1"
platforms :ruby_18 do
# fcgi gem doesn't compile on 1.9

@ -29,29 +29,38 @@ link:files/vendor/rails/actionpack/README.html.
== Getting Started
1. Install Rails at the command prompt if you haven't yet:
<tt>gem install rails</tt>
gem install rails
2. At the command prompt, create a new Rails application:
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
3. Change directory to <tt>myapp</tt> and start the web server:
<tt>cd myapp; rails server</tt> (run with --help for options)
rails new myapp
where "myapp" is the application name.
3. Change directory to +myapp+ and start the web server:
cd myapp; rails server
Run with <tt>--help</tt> for options.
4. Go to http://localhost:3000/ and you'll see:
"Welcome aboard: You're riding Ruby on Rails!"
"Welcome aboard: You're riding Ruby on Rails!"
5. Follow the guidelines to start developing your application. You can find
the following resources handy:
* The README file created within your application
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
* The README file created within your application.
* The {Getting Started Guide}[http://guides.rubyonrails.org/getting_started.html].
* The {Ruby on Rails Tutorial Book}[http://railstutorial.org/book].
== Contributing
Check out the contributing guide at http://edgeguides.rubyonrails.org/contributing_to_rails.html
We encourage you to contribute to Ruby on Raills! Please check out the {Contributing to Rails
guide}[http://edgeguides.rubyonrails.org/contributing_to_rails.html] for guidelines about how
to proceed. {Join us}[http://contributors.rubyonrails.org]!
== License

@ -22,7 +22,7 @@ def replace(record)
else
raise_on_type_mismatch(record)
if counter_cache_name && !@owner.new_record?
if counter_cache_name && !@owner.new_record? && record.id != @owner[@reflection.primary_key_name]
@reflection.klass.increment_counter(counter_cache_name, record.id)
@reflection.klass.decrement_counter(counter_cache_name, @owner[@reflection.primary_key_name]) if @owner[@reflection.primary_key_name]
end

@ -99,7 +99,7 @@ def many?
if block_given?
to_a.many? { |*block_args| yield(*block_args) }
else
@limit_value.present? ? to_a.many? : size > 1
@limit_value ? to_a.many? : size > 1
end
end
@ -316,12 +316,12 @@ def to_sql
def scope_for_create
@scope_for_create ||= begin
@create_with_value || @where_values.inject({}) do |hash, where|
if where.is_a?(Arel::Predicates::Equality)
hash[where.operand1.name] = where.operand2.respond_to?(:value) ? where.operand2.value : where.operand2
end
hash
end
@create_with_value || Hash[
@where_values.grep(Arel::Predicates::Equality).map { |where|
[where.operand1.name,
where.operand2.respond_to?(:value) ?
where.operand2.value : where.operand2]
}]
end
end

@ -47,8 +47,8 @@ def joins(*args)
clone.tap {|r| r.joins_values += args if args.present? }
end
def where(opts, other = nil)
value = build_where(opts, other)
def where(opts, *rest)
value = build_where(opts, rest)
value ? clone.tap {|r| r.where_values += Array.wrap(value) } : clone
end
@ -129,7 +129,7 @@ def custom_join_sql(*joins)
def build_arel
arel = table
arel = build_joins(arel, @joins_values) if @joins_values.present?
arel = build_joins(arel, @joins_values) unless @joins_values.empty?
@where_values.uniq.each do |where|
next if where.blank?
@ -143,33 +143,27 @@ def build_arel
end
end
arel = arel.having(*@having_values.uniq.select{|h| h.present?}) if @having_values.present?
arel = arel.having(*@having_values.uniq.select{|h| h.present?}) unless @having_values.empty?
arel = arel.take(@limit_value) if @limit_value.present?
arel = arel.skip(@offset_value) if @offset_value.present?
arel = arel.take(@limit_value) if @limit_value
arel = arel.skip(@offset_value) if @offset_value
arel = arel.group(*@group_values.uniq.select{|g| g.present?}) if @group_values.present?
arel = arel.group(*@group_values.uniq.select{|g| g.present?}) unless @group_values.empty?
arel = arel.order(*@order_values.uniq.select{|o| o.present?}) if @order_values.present?
arel = arel.order(*@order_values.uniq.select{|o| o.present?}) unless @order_values.empty?
arel = build_select(arel, @select_values.uniq)
arel = arel.from(@from_value) if @from_value.present?
case @lock_value
when TrueClass
arel = arel.lock
when String
arel = arel.lock(@lock_value)
end if @lock_value.present?
arel = arel.from(@from_value) if @from_value
arel = arel.lock(@lock_value) if @lock_value
arel
end
def build_where(opts, other = nil)
def build_where(opts, other = [])
case opts
when String, Array
@klass.send(:sanitize_sql, other ? [opts, other] : opts)
@klass.send(:sanitize_sql, other.empty? ? opts : ([opts] + other))
when Hash
attributes = @klass.send(:expand_hash_conditions_for_aggregates, opts)
PredicateBuilder.new(table.engine).build_from_hash(attributes, table)

@ -215,6 +215,10 @@ def test_belongs_to_counter_with_reassigning
r1.topic = Topic.find(t2.id)
assert_no_queries do
r1.topic = t2
end
assert r1.save
assert_equal 0, Topic.find(t1.id).replies.size
assert_equal 1, Topic.find(t2.id).replies.size

@ -22,6 +22,11 @@ def test_apply_relation_as_where_id
assert_equal 5, Post.where(:id => post_authors).size
end
def test_multivalue_where
posts = Post.where('author_id = ? AND id = ?', 1, 1)
assert_equal 1, posts.to_a.size
end
def test_scoped
topics = Topic.scoped
assert_kind_of ActiveRecord::Relation, topics

@ -138,7 +138,7 @@ class Store
cattr_accessor :logger, :instance_writer => true
attr_reader :silence
attr_reader :silence, :options
alias :silence? :silence
# Create a new cache. The options will be passed to any write method calls except
@ -147,11 +147,6 @@ def initialize (options = nil)
@options = options ? options.dup : {}
end
# Get the default options set when the cache was created.
def options
@options ||= {}
end
# Silence the logger.
def silence!
@silence = true

@ -1,4 +1,5 @@
require 'active_support/inflector/methods'
require 'active_support/inflector/inflections'
# String inflections define new methods on the String class to transform names for different purposes.
# For instance, you can figure out the name of a database from the name of a class.
#

@ -1,4 +1,9 @@
require 'nokogiri'
begin
require 'nokogiri'
rescue LoadError => e
$stderr.puts "You don't have nokogiri installed in your application. Please add it to your Gemfile and run bundle install"
raise e
end
require 'active_support/core_ext/object/blank'
# = XmlMini Nokogiri implementation

@ -1,4 +1,9 @@
require 'nokogiri'
begin
require 'nokogiri'
rescue LoadError => e
$stderr.puts "You don't have nokogiri installed in your application. Please add it to your Gemfile and run bundle install"
raise e
end
require 'active_support/core_ext/object/blank'
# = XmlMini Nokogiri implementation using a SAX-based parser
@ -80,4 +85,4 @@ def parse(data)
end
end
end
end
end

@ -25,5 +25,5 @@
s.add_dependency('activeresource', version)
s.add_dependency('actionmailer', version)
s.add_dependency('railties', version)
s.add_dependency('bundler', '>= 1.0.0.rc.1')
s.add_dependency('bundler', '>= 1.0.0.rc.2')
end

@ -1,6 +1,13 @@
pwd = File.dirname(__FILE__)
$:.unshift pwd
# This is a predicate useful for the doc:guides task of applications.
def bundler?
# Note that rake sets the cwd to the one that contains the Rakefile
# being executed.
File.exists?('Gemfile')
end
# Loading Action Pack requires rack and erubis.
require 'rubygems'
@ -20,7 +27,19 @@
gem 'RedCloth', '>= 4.1.1'
require 'redcloth'
rescue Gem::LoadError
$stderr.puts %(Generating Guides requires RedCloth 4.1.1+)
$stderr.puts('Generating guides requires RedCloth 4.1.1+.')
$stderr.puts(<<ERROR) if bundler?
Please add
gem 'RedCloth', '>= 4.1.1'
to the Gemfile, run
bundle install
and try again.
ERROR
exit 1
end

@ -69,7 +69,7 @@ All of the Rails tests must pass with any code you submit, otherwise you have no
NOTE: Ensure you install bundler v1.0
<shell>
gem install -v=1.0.0.rc.1 bundler
gem install -v=1.0.0.rc.2 bundler
bundle install --without db
</shell>

@ -118,7 +118,7 @@ Now with Rails 3 we have a Gemfile which defines the basics our application need
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri', '1.4.1'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
@ -141,13 +141,13 @@ Here the only two gems we need are +rails+ and +sqlite3-ruby+, so it seems. This
* activesupport-3.0.0.beta4.gem
* arel-0.4.0.gem
* builder-2.1.2.gem
* bundler-1.0.0.beta.5.gem
* bundler-1.0.0.rc.2.gem
* erubis-2.6.6.gem
* i18n-0.4.1.gem
* mail-2.2.5.gem
* memcache-client-1.8.5.gem
* mime-types-1.16.gem
* nokogiri-1.4.2.gem
* nokogiri-1.4.3.1.gem
* polyglot-0.3.1.gem
* rack-1.2.1.gem
* rack-mount-0.6.9.gem

@ -216,7 +216,7 @@ def create_root
empty_directory '.'
set_default_accessors!
FileUtils.cd(destination_root)
FileUtils.cd(destination_root) unless options[:pretend]
end
def create_root_files

@ -28,7 +28,7 @@ gem '<%= gem_for_database %>'<% if require_for_database %>, :require => '<%= req
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri', '1.4.1'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'

@ -55,7 +55,7 @@ namespace :doc do
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
rdoc.title = "Rails Framework Documentation"
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('README')
gem_path('actionmailer') do |actionmailer|
%w(README.rdoc CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file|

@ -58,6 +58,12 @@ def test_application_skeleton_is_created
DEFAULT_APP_FILES.each{ |path| assert_file path }
end
def test_application_generate_pretend
run_generator ["testapp", "--pretend"]
DEFAULT_APP_FILES.each{ |path| assert_no_file path }
end
def test_application_controller_and_layout_files
run_generator
assert_file "app/views/layouts/application.html.erb", /stylesheet_link_tag :all/