Skip to content

Commit 3d70998

Browse files
committed
Merge remote branch 'rails/master'
2 parents 0e20e3e + d3819da commit 3d70998

File tree

19 files changed

+99
-56
lines changed

19 files changed

+99
-56
lines changed

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ end
2727
platforms :ruby do
2828
gem 'json'
2929
gem 'yajl-ruby'
30-
gem "nokogiri", ">= 1.4.2"
30+
gem "nokogiri", ">= 1.4.3.1"
3131

3232
# AR
3333
gem "sqlite3-ruby", "~> 1.3.1", :require => 'sqlite3'
@@ -50,7 +50,7 @@ platforms :jruby do
5050
end
5151

5252
env 'CI' do
53-
gem "nokogiri", ">= 1.4.2"
53+
gem "nokogiri", ">= 1.4.3.1"
5454

5555
platforms :ruby_18 do
5656
# fcgi gem doesn't compile on 1.9

README.rdoc

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,38 @@ link:files/vendor/rails/actionpack/README.html.
2929
== Getting Started
3030

3131
1. Install Rails at the command prompt if you haven't yet:
32-
<tt>gem install rails</tt>
32+
33+
gem install rails
3334

3435
2. At the command prompt, create a new Rails application:
35-
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
3636

37-
3. Change directory to <tt>myapp</tt> and start the web server:
38-
<tt>cd myapp; rails server</tt> (run with --help for options)
37+
rails new myapp
38+
39+
where "myapp" is the application name.
40+
41+
3. Change directory to +myapp+ and start the web server:
42+
43+
cd myapp; rails server
44+
45+
Run with <tt>--help</tt> for options.
3946

4047
4. Go to http://localhost:3000/ and you'll see:
41-
"Welcome aboard: You're riding Ruby on Rails!"
48+
49+
"Welcome aboard: You're riding Ruby on Rails!"
4250

4351
5. Follow the guidelines to start developing your application. You can find
4452
the following resources handy:
4553

46-
* The README file created within your application
47-
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
48-
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
54+
* The README file created within your application.
55+
* The {Getting Started Guide}[http://guides.rubyonrails.org/getting_started.html].
56+
* The {Ruby on Rails Tutorial Book}[http://railstutorial.org/book].
4957

5058

5159
== Contributing
5260

53-
Check out the contributing guide at http://edgeguides.rubyonrails.org/contributing_to_rails.html
54-
61+
We encourage you to contribute to Ruby on Raills! Please check out the {Contributing to Rails
62+
guide}[http://edgeguides.rubyonrails.org/contributing_to_rails.html] for guidelines about how
63+
to proceed. {Join us}[http://contributors.rubyonrails.org]!
5564

5665
== License
5766

activerecord/lib/active_record/associations/belongs_to_association.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def replace(record)
2222
else
2323
raise_on_type_mismatch(record)
2424

25-
if counter_cache_name && !@owner.new_record?
25+
if counter_cache_name && !@owner.new_record? && record.id != @owner[@reflection.primary_key_name]
2626
@reflection.klass.increment_counter(counter_cache_name, record.id)
2727
@reflection.klass.decrement_counter(counter_cache_name, @owner[@reflection.primary_key_name]) if @owner[@reflection.primary_key_name]
2828
end

activerecord/lib/active_record/relation.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def many?
9999
if block_given?
100100
to_a.many? { |*block_args| yield(*block_args) }
101101
else
102-
@limit_value.present? ? to_a.many? : size > 1
102+
@limit_value ? to_a.many? : size > 1
103103
end
104104
end
105105

@@ -316,12 +316,12 @@ def to_sql
316316

317317
def scope_for_create
318318
@scope_for_create ||= begin
319-
@create_with_value || @where_values.inject({}) do |hash, where|
320-
if where.is_a?(Arel::Predicates::Equality)
321-
hash[where.operand1.name] = where.operand2.respond_to?(:value) ? where.operand2.value : where.operand2
322-
end
323-
hash
324-
end
319+
@create_with_value || Hash[
320+
@where_values.grep(Arel::Predicates::Equality).map { |where|
321+
[where.operand1.name,
322+
where.operand2.respond_to?(:value) ?
323+
where.operand2.value : where.operand2]
324+
}]
325325
end
326326
end
327327

activerecord/lib/active_record/relation/query_methods.rb

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def joins(*args)
4747
clone.tap {|r| r.joins_values += args if args.present? }
4848
end
4949

50-
def where(opts, other = nil)
51-
value = build_where(opts, other)
50+
def where(opts, *rest)
51+
value = build_where(opts, rest)
5252
value ? clone.tap {|r| r.where_values += Array.wrap(value) } : clone
5353
end
5454

@@ -129,7 +129,7 @@ def custom_join_sql(*joins)
129129
def build_arel
130130
arel = table
131131

132-
arel = build_joins(arel, @joins_values) if @joins_values.present?
132+
arel = build_joins(arel, @joins_values) unless @joins_values.empty?
133133

134134
@where_values.uniq.each do |where|
135135
next if where.blank?
@@ -143,33 +143,27 @@ def build_arel
143143
end
144144
end
145145

146-
arel = arel.having(*@having_values.uniq.select{|h| h.present?}) if @having_values.present?
146+
arel = arel.having(*@having_values.uniq.select{|h| h.present?}) unless @having_values.empty?
147147

148-
arel = arel.take(@limit_value) if @limit_value.present?
149-
arel = arel.skip(@offset_value) if @offset_value.present?
148+
arel = arel.take(@limit_value) if @limit_value
149+
arel = arel.skip(@offset_value) if @offset_value
150150

151-
arel = arel.group(*@group_values.uniq.select{|g| g.present?}) if @group_values.present?
151+
arel = arel.group(*@group_values.uniq.select{|g| g.present?}) unless @group_values.empty?
152152

153-
arel = arel.order(*@order_values.uniq.select{|o| o.present?}) if @order_values.present?
153+
arel = arel.order(*@order_values.uniq.select{|o| o.present?}) unless @order_values.empty?
154154

155155
arel = build_select(arel, @select_values.uniq)
156156

157-
arel = arel.from(@from_value) if @from_value.present?
158-
159-
case @lock_value
160-
when TrueClass
161-
arel = arel.lock
162-
when String
163-
arel = arel.lock(@lock_value)
164-
end if @lock_value.present?
157+
arel = arel.from(@from_value) if @from_value
158+
arel = arel.lock(@lock_value) if @lock_value
165159

166160
arel
167161
end
168162

169-
def build_where(opts, other = nil)
163+
def build_where(opts, other = [])
170164
case opts
171165
when String, Array
172-
@klass.send(:sanitize_sql, other ? [opts, other] : opts)
166+
@klass.send(:sanitize_sql, other.empty? ? opts : ([opts] + other))
173167
when Hash
174168
attributes = @klass.send(:expand_hash_conditions_for_aggregates, opts)
175169
PredicateBuilder.new(table.engine).build_from_hash(attributes, table)

activerecord/test/cases/associations/belongs_to_associations_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ def test_belongs_to_counter_with_reassigning
215215

216216
r1.topic = Topic.find(t2.id)
217217

218+
assert_no_queries do
219+
r1.topic = t2
220+
end
221+
218222
assert r1.save
219223
assert_equal 0, Topic.find(t1.id).replies.size
220224
assert_equal 1, Topic.find(t2.id).replies.size

activerecord/test/cases/relations_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ def test_apply_relation_as_where_id
2222
assert_equal 5, Post.where(:id => post_authors).size
2323
end
2424

25+
def test_multivalue_where
26+
posts = Post.where('author_id = ? AND id = ?', 1, 1)
27+
assert_equal 1, posts.to_a.size
28+
end
29+
2530
def test_scoped
2631
topics = Topic.scoped
2732
assert_kind_of ActiveRecord::Relation, topics

activesupport/lib/active_support/cache.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class Store
138138

139139
cattr_accessor :logger, :instance_writer => true
140140

141-
attr_reader :silence
141+
attr_reader :silence, :options
142142
alias :silence? :silence
143143

144144
# Create a new cache. The options will be passed to any write method calls except
@@ -147,11 +147,6 @@ def initialize (options = nil)
147147
@options = options ? options.dup : {}
148148
end
149149

150-
# Get the default options set when the cache was created.
151-
def options
152-
@options ||= {}
153-
end
154-
155150
# Silence the logger.
156151
def silence!
157152
@silence = true

activesupport/lib/active_support/core_ext/string/inflections.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'active_support/inflector/methods'
2+
require 'active_support/inflector/inflections'
23
# String inflections define new methods on the String class to transform names for different purposes.
34
# For instance, you can figure out the name of a database from the name of a class.
45
#

activesupport/lib/active_support/xml_mini/nokogiri.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
require 'nokogiri'
1+
begin
2+
require 'nokogiri'
3+
rescue LoadError => e
4+
$stderr.puts "You don't have nokogiri installed in your application. Please add it to your Gemfile and run bundle install"
5+
raise e
6+
end
27
require 'active_support/core_ext/object/blank'
38

49
# = XmlMini Nokogiri implementation

activesupport/lib/active_support/xml_mini/nokogirisax.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
require 'nokogiri'
1+
begin
2+
require 'nokogiri'
3+
rescue LoadError => e
4+
$stderr.puts "You don't have nokogiri installed in your application. Please add it to your Gemfile and run bundle install"
5+
raise e
6+
end
27
require 'active_support/core_ext/object/blank'
38

49
# = XmlMini Nokogiri implementation using a SAX-based parser
@@ -80,4 +85,4 @@ def parse(data)
8085
end
8186
end
8287
end
83-
end
88+
end

rails.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ Gem::Specification.new do |s|
2525
s.add_dependency('activeresource', version)
2626
s.add_dependency('actionmailer', version)
2727
s.add_dependency('railties', version)
28-
s.add_dependency('bundler', '>= 1.0.0.rc.1')
28+
s.add_dependency('bundler', '>= 1.0.0.rc.2')
2929
end

railties/guides/rails_guides.rb

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
pwd = File.dirname(__FILE__)
22
$:.unshift pwd
33

4+
# This is a predicate useful for the doc:guides task of applications.
5+
def bundler?
6+
# Note that rake sets the cwd to the one that contains the Rakefile
7+
# being executed.
8+
File.exists?('Gemfile')
9+
end
10+
411
# Loading Action Pack requires rack and erubis.
512
require 'rubygems'
613

@@ -20,7 +27,19 @@
2027
gem 'RedCloth', '>= 4.1.1'
2128
require 'redcloth'
2229
rescue Gem::LoadError
23-
$stderr.puts %(Generating Guides requires RedCloth 4.1.1+)
30+
$stderr.puts('Generating guides requires RedCloth 4.1.1+.')
31+
$stderr.puts(<<ERROR) if bundler?
32+
Please add
33+
34+
gem 'RedCloth', '>= 4.1.1'
35+
36+
to the Gemfile, run
37+
38+
bundle install
39+
40+
and try again.
41+
ERROR
42+
2443
exit 1
2544
end
2645

railties/guides/source/contributing_to_rails.textile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ All of the Rails tests must pass with any code you submit, otherwise you have no
6969
NOTE: Ensure you install bundler v1.0
7070

7171
<shell>
72-
gem install -v=1.0.0.rc.1 bundler
72+
gem install -v=1.0.0.rc.2 bundler
7373
bundle install --without db
7474
</shell>
7575

railties/guides/source/initialization.textile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Now with Rails 3 we have a Gemfile which defines the basics our application need
118118

119119
# Bundle the extra gems:
120120
# gem 'bj'
121-
# gem 'nokogiri', '1.4.1'
121+
# gem 'nokogiri'
122122
# gem 'sqlite3-ruby', :require => 'sqlite3'
123123
# gem 'aws-s3', :require => 'aws/s3'
124124

@@ -141,13 +141,13 @@ Here the only two gems we need are +rails+ and +sqlite3-ruby+, so it seems. This
141141
* activesupport-3.0.0.beta4.gem
142142
* arel-0.4.0.gem
143143
* builder-2.1.2.gem
144-
* bundler-1.0.0.beta.5.gem
144+
* bundler-1.0.0.rc.2.gem
145145
* erubis-2.6.6.gem
146146
* i18n-0.4.1.gem
147147
* mail-2.2.5.gem
148148
* memcache-client-1.8.5.gem
149149
* mime-types-1.16.gem
150-
* nokogiri-1.4.2.gem
150+
* nokogiri-1.4.3.1.gem
151151
* polyglot-0.3.1.gem
152152
* rack-1.2.1.gem
153153
* rack-mount-0.6.9.gem

railties/lib/rails/generators/rails/app/app_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def create_root
216216

217217
empty_directory '.'
218218
set_default_accessors!
219-
FileUtils.cd(destination_root)
219+
FileUtils.cd(destination_root) unless options[:pretend]
220220
end
221221

222222
def create_root_files

railties/lib/rails/generators/rails/app/templates/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ gem '<%= gem_for_database %>'<% if require_for_database %>, :require => '<%= req
2828
2929
# Bundle the extra gems:
3030
# gem 'bj'
31-
# gem 'nokogiri', '1.4.1'
31+
# gem 'nokogiri'
3232
# gem 'sqlite3-ruby', :require => 'sqlite3'
3333
# gem 'aws-s3', :require => 'aws/s3'
3434

railties/lib/rails/tasks/documentation.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ namespace :doc do
5555
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
5656
rdoc.title = "Rails Framework Documentation"
5757
rdoc.options << '--line-numbers' << '--inline-source'
58-
rdoc.rdoc_files.include('README.rdoc')
58+
rdoc.rdoc_files.include('README')
5959

6060
gem_path('actionmailer') do |actionmailer|
6161
%w(README.rdoc CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file|

railties/test/generators/app_generator_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ def test_application_skeleton_is_created
5858
DEFAULT_APP_FILES.each{ |path| assert_file path }
5959
end
6060

61+
def test_application_generate_pretend
62+
run_generator ["testapp", "--pretend"]
63+
64+
DEFAULT_APP_FILES.each{ |path| assert_no_file path }
65+
end
66+
6167
def test_application_controller_and_layout_files
6268
run_generator
6369
assert_file "app/views/layouts/application.html.erb", /stylesheet_link_tag :all/

0 commit comments

Comments
 (0)