mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merged pull request #300 from arunagw/jdbc_test.
Start Adding jdbcmysql support to new rails template.
This commit is contained in:
commit
17fec021d1
4 changed files with 64 additions and 1 deletions
|
@ -10,6 +10,8 @@ module Rails
|
|||
module Generators
|
||||
class AppBase < Base
|
||||
DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
|
||||
JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 )
|
||||
DATABASES.concat(JDBC_DATABASES)
|
||||
JAVASCRIPTS = %w( jquery prototype )
|
||||
|
||||
attr_accessor :rails_template
|
||||
|
@ -156,12 +158,14 @@ module Rails
|
|||
end
|
||||
|
||||
def gem_for_database
|
||||
# %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
|
||||
# %w( mysql oracle postgresql sqlite3 frontbase ibm_db jdbcmysql jdbcsqlite3)
|
||||
case options[:database]
|
||||
when "oracle" then "ruby-oci8"
|
||||
when "postgresql" then "pg"
|
||||
when "frontbase" then "ruby-frontbase"
|
||||
when "mysql" then "mysql2"
|
||||
when "jdbcmysql" then "activerecord-jdbcmysql-adapter"
|
||||
when "jdbcsqlite3" then "activerecord-jdbcsqlite3-adapter"
|
||||
else options[:database]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
# MySQL. Versions 4.1 and 5.0 are recommended.
|
||||
#
|
||||
# Install the MySQL driver:
|
||||
# gem install activerecord-jdbcmysql-adapter
|
||||
#
|
||||
# And be sure to use new-style password hashing:
|
||||
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
|
||||
development:
|
||||
adapter: jdbcmysql
|
||||
database: <%= app_name %>_development
|
||||
username: root
|
||||
password:
|
||||
host: localhost
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
# Do not set this db to the same as development or production.
|
||||
test:
|
||||
adapter: jdbcmysql
|
||||
database: <%= app_name %>_test
|
||||
username: root
|
||||
password:
|
||||
host: localhost
|
||||
|
||||
production:
|
||||
adapter: jdbcmysql
|
||||
database: <%= app_name %>_production
|
||||
username: root
|
||||
password:
|
||||
host: localhost
|
|
@ -0,0 +1,17 @@
|
|||
# SQLite version 3.x
|
||||
# gem 'activerecord-jdbcsqlite3-adapter'
|
||||
|
||||
development:
|
||||
adapter: jdbcsqlite3
|
||||
database: db/development.sqlite3
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
# Do not set this db to the same as development or production.
|
||||
test:
|
||||
adapter: jdbcsqlite3
|
||||
database: db/test.sqlite3
|
||||
|
||||
production:
|
||||
adapter: jdbcsqlite3
|
||||
database: db/production.sqlite3
|
|
@ -131,6 +131,18 @@ class AppGeneratorTest < Rails::Generators::TestCase
|
|||
assert_file "Gemfile", /^gem\s+["']mysql2["']$/
|
||||
end
|
||||
|
||||
def test_config_jdbcmysql_database
|
||||
run_generator([destination_root, "-d", "jdbcmysql"])
|
||||
assert_file "config/database.yml", /jdbcmysql/
|
||||
assert_file "Gemfile", /^gem\s+["']activerecord-jdbcmysql-adapter["']$/
|
||||
end
|
||||
|
||||
def test_config_jdbcsqlite3_database
|
||||
run_generator([destination_root, "-d", "jdbcsqlite3"])
|
||||
assert_file "config/database.yml", /jdbcsqlite3/
|
||||
assert_file "Gemfile", /^gem\s+["']activerecord-jdbcsqlite3-adapter["']$/
|
||||
end
|
||||
|
||||
def test_generator_if_skip_active_record_is_given
|
||||
run_generator [destination_root, "--skip-active-record"]
|
||||
assert_no_file "config/database.yml"
|
||||
|
|
Loading…
Reference in a new issue