aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-09-01 01:37:02 +0200
committerPiotr Sarnacki <drogus@gmail.com>2010-09-03 22:59:15 +0200
commit6f3119d3c298c007e7a4eed8375d9fc30b961d06 (patch)
tree053d9d33dd711f52c3767a4f4b07ea356a6f2fe2 /railties
parent2607def8621c41d5b0bee09e379ae26890b27f7d (diff)
downloadrails-6f3119d3c298c007e7a4eed8375d9fc30b961d06.tar.gz
rails-6f3119d3c298c007e7a4eed8375d9fc30b961d06.tar.bz2
rails-6f3119d3c298c007e7a4eed8375d9fc30b961d06.zip
Remove namespace for isolated namespaced models in forms
Diffstat (limited to 'railties')
-rw-r--r--railties/test/railties/engine_test.rb65
1 files changed, 64 insertions, 1 deletions
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb
index 56f9eae8ca..73d9b61719 100644
--- a/railties/test/railties/engine_test.rb
+++ b/railties/test/railties/engine_test.rb
@@ -360,7 +360,7 @@ module RailtiesTest
assert_equal "It's a bar.", response[2].body
end
- test "namespaced engine should include only its own routes and helpers" do
+ test "isolated engine should include only its own routes and helpers" do
@plugin.write "lib/bukkits.rb", <<-RUBY
module Bukkits
class Engine < ::Rails::Engine
@@ -478,5 +478,68 @@ module RailtiesTest
response = AppTemplate::Application.call(env)
assert_equal "/bukkits/posts/1", response[2].body
end
+
+ test "isolated engine should avoid namespace in names if that's possible" do
+ @plugin.write "lib/bukkits.rb", <<-RUBY
+ module Bukkits
+ class Engine < ::Rails::Engine
+ namespace Bukkits
+ end
+ end
+ RUBY
+
+ @plugin.write "app/models/bukkits/post.rb", <<-RUBY
+ module Bukkits
+ class Post
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+ attr_accessor :title
+
+ def to_param
+ "1"
+ end
+
+ def persisted?
+ false
+ end
+ end
+ end
+ RUBY
+
+ app_file "config/routes.rb", <<-RUBY
+ AppTemplate::Application.routes.draw do
+ mount Bukkits::Engine => "/bukkits", :as => "bukkits"
+ end
+ RUBY
+
+ @plugin.write "config/routes.rb", <<-RUBY
+ Bukkits::Engine.routes.draw do
+ scope(:module => :bukkits) do
+ resources :posts
+ end
+ end
+ RUBY
+
+ @plugin.write "app/controllers/bukkits/posts_controller.rb", <<-RUBY
+ class Bukkits::PostsController < ActionController::Base
+ def new
+ end
+ end
+ RUBY
+
+ @plugin.write "app/views/bukkits/posts/new.html.erb", <<-RUBY
+ <%= form_for(Bukkits::Post.new) do |f| %>
+ <%= f.text_field :title %>
+ <% end %>
+ RUBY
+
+ add_to_config("config.action_dispatch.show_exceptions = false")
+
+ boot_rails
+
+ env = Rack::MockRequest.env_for("/bukkits/posts/new")
+ response = AppTemplate::Application.call(env)
+ assert response[2].body =~ /name="post\[title\]"/
+ end
end
end