Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit df40dbe

Browse files
committedJun 8, 2010
Merge branch 'master' of github.com:rails/rails
2 parents 6ebc7c8 + 5c9f27a commit df40dbe

24 files changed

+667
-114
lines changed
 

Diff for: ‎Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if mri || RUBY_ENGINE == "rbx"
3232
gem "sqlite3-ruby", "~> 1.3.0", :require => 'sqlite3'
3333

3434
group :db do
35-
# gem "pg", ">= 0.9.0"
35+
gem "pg", ">= 0.9.0"
3636
gem "mysql", ">= 2.8.1"
3737
end
3838
elsif RUBY_ENGINE == "jruby"

Diff for: ‎actionpack/CHANGELOG

-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
*Rails 3.0.0 [beta 4] (June 8th, 2010)*
22

3-
* Add shallow routes back to the new router [Diego Carrion]
4-
5-
resources :posts do
6-
shallow do
7-
resources :comments
8-
end
9-
end
10-
11-
You can now use comment_path for /comments/1 instead of post_comment_path for /posts/1/comments/1.
12-
133
* Remove middleware laziness [José Valim]
144

155
* Make session stores rely on request.cookie_jar and change set_session semantics to return the cookie value instead of a boolean. [José Valim]

Diff for: ‎actionpack/lib/action_controller/caching/sweeping.rb

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class Sweeper < ActiveRecord::Observer #:nodoc:
5757
def before(controller)
5858
self.controller = controller
5959
callback(:before) if controller.perform_caching
60+
true # before method from sweeper should always return true
6061
end
6162

6263
def after(controller)

Diff for: ‎actionpack/lib/action_dispatch/routing/mapper.rb

+11-26
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,6 @@ def constraints(constraints = {})
350350
scope(:constraints => constraints) { yield }
351351
end
352352

353-
def shallow
354-
scope(:shallow => true) { yield }
355-
end
356-
357353
def defaults(defaults = {})
358354
scope(:defaults => defaults) { yield }
359355
end
@@ -378,21 +374,12 @@ def scope_options
378374
@scope_options ||= private_methods.grep(/^merge_(.+)_scope$/) { $1.to_sym }
379375
end
380376

381-
def merge_shallow_scope(parent, child)
382-
parent or child
383-
end
384-
385377
def merge_path_scope(parent, child)
386-
parent_path = (@scope[:shallow] and child.eql?(':id')) ? parent.split('/').last : parent
387-
Mapper.normalize_path "#{parent_path}/#{child}"
378+
Mapper.normalize_path("#{parent}/#{child}")
388379
end
389380

390381
def merge_name_prefix_scope(parent, child)
391-
if @scope[:shallow]
392-
child
393-
else
394-
parent ? "#{parent}_#{child}" : child
395-
end
382+
parent ? "#{parent}_#{child}" : child
396383
end
397384

398385
def merge_module_scope(parent, child)
@@ -535,10 +522,6 @@ def nested_options
535522
options["#{singular}_id".to_sym] = id_constraint if id_constraint?
536523
options
537524
end
538-
539-
def shallow?
540-
options[:shallow]
541-
end
542525
end
543526

544527
class SingletonResource < Resource #:nodoc:
@@ -620,12 +603,8 @@ def resources(*resources, &block)
620603

621604
resource = Resource.new(resources.pop, options)
622605

623-
scope(:path => resource.path, :controller => resource.controller, :shallow => resource.shallow?) do
606+
scope(:path => resource.path, :controller => resource.controller) do
624607
with_scope_level(:resources, resource) do
625-
if @scope[:shallow] && @scope[:name_prefix]
626-
@scope[:path] = "/#{@scope[:name_prefix].pluralize}/:#{@scope[:name_prefix]}_id/#{resource.path}"
627-
end
628-
629608
yield if block_given?
630609

631610
with_scope_level(:collection) do
@@ -639,8 +618,6 @@ def resources(*resources, &block)
639618
with_scope_level(:member) do
640619
scope(':id') do
641620
scope(resource.options) do
642-
@scope[:name_prefix] = nil if @scope[:shallow]
643-
644621
get :show if resource.actions.include?(:show)
645622
put :update if resource.actions.include?(:update)
646623
delete :destroy if resource.actions.include?(:destroy)
@@ -702,6 +679,14 @@ def nested
702679
end
703680
end
704681

682+
def namespace(path)
683+
if resource_scope?
684+
nested { super }
685+
else
686+
super
687+
end
688+
end
689+
705690
def match(*args)
706691
options = args.extract_options!
707692

Diff for: ‎actionpack/lib/action_view/test_case.rb

+8-6
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,14 @@ def make_test_case_available_to_view!
131131
end
132132

133133
def _view
134-
view = ActionView::Base.new(ActionController::Base.view_paths, _assigns, @controller)
135-
view.singleton_class.send :include, _helpers
136-
view.singleton_class.send :include, @controller._router.url_helpers
137-
view.singleton_class.send :delegate, :alert, :notice, :to => "request.flash"
138-
view.output_buffer = self.output_buffer
139-
view
134+
@_view ||= begin
135+
view = ActionView::Base.new(ActionController::Base.view_paths, _assigns, @controller)
136+
view.singleton_class.send :include, _helpers
137+
view.singleton_class.send :include, @controller._router.url_helpers
138+
view.singleton_class.send :delegate, :alert, :notice, :to => "request.flash"
139+
view.output_buffer = self.output_buffer
140+
view
141+
end
140142
end
141143

142144
EXCLUDE_IVARS = %w{

Diff for: ‎actionpack/test/abstract_unit.rb

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
require 'action_dispatch'
2525
require 'active_support/dependencies'
2626
require 'active_model'
27+
require 'active_record'
28+
require 'action_controller/caching'
29+
require 'action_controller/caching/sweeping'
2730

2831
begin
2932
require 'ruby-debug'

Diff for: ‎actionpack/test/controller/filters_test.rb

+6
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,12 @@ def filter_three
445445

446446
end
447447

448+
449+
def test_before_method_of_sweeper_should_always_return_true
450+
sweeper = ActionController::Caching::Sweeper.send(:new)
451+
assert sweeper.before(TestController.new)
452+
end
453+
448454
def test_non_yielding_around_filters_not_returning_false_do_not_raise
449455
controller = NonYieldingAroundFilterController.new
450456
controller.instance_variable_set "@filter_return_value", true

Diff for: ‎actionpack/test/dispatch/routing_test.rb

+22-39
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,6 @@ def self.matches?(request)
3434
end
3535
end
3636

37-
resources :users do
38-
shallow do
39-
resources :photos do
40-
resources :types do
41-
member do
42-
post :preview
43-
end
44-
collection do
45-
delete :erase
46-
end
47-
end
48-
end
49-
end
50-
end
51-
52-
shallow do
53-
resources :teams do
54-
resources :players
55-
end
56-
57-
resources :countries do
58-
resources :cities do
59-
resources :places
60-
end
61-
end
62-
end
63-
6437
match 'account/logout' => redirect("/logout"), :as => :logout_redirect
6538
match 'account/login', :to => redirect("/login")
6639

@@ -171,6 +144,16 @@ def self.matches?(request)
171144

172145
resources :sheep
173146

147+
resources :clients do
148+
namespace :google do
149+
resource :account do
150+
namespace :secret do
151+
resource :info
152+
end
153+
end
154+
end
155+
end
156+
174157
match 'sprockets.js' => ::TestRoutingMapper::SprocketsApp
175158

176159
match 'people/:id/update', :to => 'people#update', :as => :update_person
@@ -779,18 +762,6 @@ def test_update_person_route
779762
end
780763
end
781764

782-
def test_shallow_routes
783-
with_test_routes do
784-
assert_equal '/photos/4', photo_path(4)
785-
assert_equal '/types/10/edit', edit_type_path(10)
786-
assert_equal '/types/5/preview', preview_type_path(5)
787-
assert_equal '/photos/2/types', photo_types_path(2)
788-
assert_equal '/cities/1/places', url_for(:controller => :places, :action => :index, :city_id => 1, :only_path => true)
789-
assert_equal '/teams/new', url_for(:controller => :teams, :action => :new, :only_path => true)
790-
assert_equal '/photos/11/types/erase', url_for(:controller => :types, :action => :erase, :photo_id => 11, :only_path => true)
791-
end
792-
end
793-
794765
def test_update_project_person
795766
with_test_routes do
796767
get '/projects/1/people/2/update'
@@ -852,6 +823,18 @@ def test_nested_namespace
852823
assert_equal '/account/admin/subscription', account_admin_subscription_path
853824
end
854825
end
826+
827+
def test_namespace_nested_in_resources
828+
with_test_routes do
829+
get '/clients/1/google/account'
830+
assert_equal '/clients/1/google/account', client_google_account_path(1)
831+
assert_equal 'google/accounts#show', @response.body
832+
833+
get '/clients/1/google/account/secret/info'
834+
assert_equal '/clients/1/google/account/secret/info', client_google_account_secret_info_path(1)
835+
assert_equal 'google/secret/infos#show', @response.body
836+
end
837+
end
855838

856839
def test_articles_with_id
857840
with_test_routes do

Diff for: ‎actionpack/test/template/test_case_test.rb

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ class GeneralViewTest < ActionView::TestCase
3737
include SharedTests
3838
test_case = self
3939

40+
test "memoizes the _view" do
41+
assert_same _view, _view
42+
end
43+
4044
test "works without testing a helper module" do
4145
assert_equal 'Eloy', render('developers/developer', :developer => stub(:name => 'Eloy'))
4246
end

Diff for: ‎activerecord/CHANGELOG

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
*Rails 3.0.0 [beta 4] (June 8th, 2010)*
22

3+
* Fixed that ActiveRecord::Base.compute_type would swallow NoMethodError #4751 [Andrew Bloomgarden, Andrew White]
4+
35
* Add index length support for MySQL. #1852 [Emili Parreno, Pratik Naik]
46

57
Example:
@@ -12,6 +14,8 @@
1214

1315
* find_or_create_by_attr(value, ...) works when attr is protected. #4457 [Santiago Pastorino, Marc-André Lafortune]
1416

17+
* New callbacks: after_commit and after_rollback. Do expensive operations like image thumbnailing after_commit instead of after_save. #2991 [Brian Durand]
18+
1519
* Serialized attributes are not converted to YAML if they are any of the formats that can be serialized to XML (like Hash, Array and Strings). [José Valim]
1620

1721
* Destroy uses optimistic locking. If lock_version on the record you're destroying doesn't match lock_version in the database, a StaleObjectError is raised. #1966 [Curtis Hawthorne]

Diff for: ‎activerecord/lib/active_record/base.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,9 @@ def compute_type(type_name)
12191219
begin
12201220
constant = candidate.constantize
12211221
return constant if candidate == constant.to_s
1222-
rescue NameError
1222+
rescue NameError => e
1223+
# We don't want to swallow NoMethodError < NameError errors
1224+
raise e unless e.instance_of?(NameError)
12231225
rescue ArgumentError
12241226
end
12251227
end

Diff for: ‎activerecord/lib/active_record/callbacks.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module ActiveRecord
3131
# class CreditCard < ActiveRecord::Base
3232
# # Strip everything but digits, so the user can specify "555 234 34" or
3333
# # "5552-3434" or both will mean "55523434"
34-
# def before_validation_on_create
34+
# before_validation(:on => :create) do
3535
# self.number = number.gsub(/[^0-9]/, "") if attribute_present?("number")
3636
# end
3737
# end

0 commit comments

Comments
 (0)
Please sign in to comment.