Skip to content

Commit

Permalink
Fix scaffold controller template, ensure rake scaffold test pass by d…
Browse files Browse the repository at this point in the history
…efault
  • Loading branch information
carlosantoniodasilva committed Mar 14, 2012
1 parent da07433 commit 2963ee6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ def create
respond_to do |format|
if @<%= orm_instance.save %>
format.html { redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully created.'" %> }
format.json { render json: <%= "@#{singular_table_name}" %>, :status: :created, location: <%= "@#{singular_table_name}" %> }
format.json { render json: <%= "@#{singular_table_name}" %>, status: :created, location: <%= "@#{singular_table_name}" %> }
else
format.html { render action: "new" }
format.json { render json: <%= "@#{orm_instance.errors}" %>, status: :unprocessable_entity %> }
format.json { render json: <%= "@#{orm_instance.errors}" %>, status: :unprocessable_entity }
end
end
end
Expand Down
25 changes: 23 additions & 2 deletions railties/test/application/rake_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,33 @@ def test_loading_specific_fixtures
end

def test_scaffold_tests_pass_by_default
content = Dir.chdir(app_path) do
output = Dir.chdir(app_path) do
`rails generate scaffold user username:string password:string;
bundle exec rake db:migrate db:test:clone test`
end

assert_match(/\d+ tests, \d+ assertions, 0 failures, 0 errors/, content)
assert_match(/7 tests, 13 assertions, 0 failures, 0 errors/, output)
assert_no_match(/Errors running/, output)
end

def test_http_scaffold_tests_pass_by_default
add_to_config <<-RUBY
config.middleware.http_only!
config.generators.http_only!
RUBY

app_file "app/controllers/application_controller.rb", <<-RUBY
class ApplicationController < ActionController::HTTP
end
RUBY

output = Dir.chdir(app_path) do
`rails generate scaffold user username:string password:string;
bundle exec rake db:migrate db:test:clone test`
end

assert_match(/6 tests, 12 assertions, 0 failures, 0 errors/, output)
assert_no_match(/Errors running/, output)
end

def test_rake_dump_structure_should_respect_db_structure_env_variable
Expand Down
7 changes: 6 additions & 1 deletion railties/test/isolation/abstract_unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ def build_app(options = {})
end
end

add_to_config 'config.secret_token = "3b7cd727ee24e8444053437c36cc66c4"; config.session_store :cookie_store, :key => "_myapp_session"; config.active_support.deprecation = :log'
add_to_config <<-RUBY
config.secret_token = "3b7cd727ee24e8444053437c36cc66c4"
config.session_store :cookie_store, :key => "_myapp_session"
config.active_support.deprecation = :log
config.action_controller.allow_forgery_protection = false
RUBY
end

def teardown_app
Expand Down

0 comments on commit 2963ee6

Please sign in to comment.