aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/application')
-rw-r--r--railties/test/application/default_stack_test.rb41
-rw-r--r--railties/test/application/rake/dbs_test.rb26
2 files changed, 67 insertions, 0 deletions
diff --git a/railties/test/application/default_stack_test.rb b/railties/test/application/default_stack_test.rb
new file mode 100644
index 0000000000..4778cdd74c
--- /dev/null
+++ b/railties/test/application/default_stack_test.rb
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+require 'isolation/abstract_unit'
+require 'rack/test'
+require 'active_support/json'
+
+module ApplicationTests
+ class DefaultStackTest < ActiveSupport::TestCase
+ include ActiveSupport::Testing::Isolation
+ include Rack::Test::Methods
+
+ def setup
+ build_app(initializers: true)
+ boot_rails
+ end
+
+ def teardown
+ teardown_app
+ end
+
+ test "the sanitizer helper" do
+ controller :foo, <<-RUBY
+ class FooController < ApplicationController
+ def index
+ render text: self.class.helpers.class.sanitizer_vendor
+ end
+ end
+ RUBY
+
+ app_file 'config/routes.rb', <<-RUBY
+ Rails.application.routes.draw do
+ get ':controller(/:action)'
+ end
+ RUBY
+
+ require "#{app_path}/config/environment"
+
+ get "/foo"
+ assert_equal 'Rails::Html::Sanitizer', last_response.body.strip
+ end
+ end
+end
diff --git a/railties/test/application/rake/dbs_test.rb b/railties/test/application/rake/dbs_test.rb
index 15414db00f..c727e0e46d 100644
--- a/railties/test/application/rake/dbs_test.rb
+++ b/railties/test/application/rake/dbs_test.rb
@@ -173,6 +173,32 @@ module ApplicationTests
"your test schema automatically, see the release notes for details.\n", output
end
end
+
+ test 'db:setup loads schema and seeds database' do
+ begin
+ @old_env = ENV["RAILS_ENV"]
+ ENV.delete "RAILS_ENV"
+
+ app_file 'db/schema.rb', <<-RUBY
+ ActiveRecord::Schema.define(version: "1") do
+ create_table :users do |t|
+ t.string :name
+ end
+ end
+ RUBY
+
+ app_file 'db/seeds.rb', <<-RUBY
+ puts ActiveRecord::Base.connection_config[:database]
+ RUBY
+
+ Dir.chdir(app_path) do
+ database_path = `bundle exec rake db:setup`
+ assert_equal "development.sqlite3", File.basename(database_path.strip)
+ end
+ ensure
+ ENV["RAILS_ENV"] = @old_env
+ end
+ end
end
end
end