rails 0.13.1 → 0.14.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rails might be problematic. Click here for more details.
- data/CHANGELOG +105 -0
- data/Rakefile +39 -17
- data/bin/breakpointer +2 -2
- data/bin/console +2 -22
- data/bin/destroy +2 -6
- data/bin/generate +2 -6
- data/bin/performance/benchmarker +3 -0
- data/bin/performance/profiler +3 -0
- data/bin/process/reaper +3 -0
- data/bin/process/spawner +3 -0
- data/bin/process/spinner +3 -0
- data/bin/rails +4 -0
- data/bin/runner +2 -27
- data/bin/server +2 -48
- data/configs/apache.conf +8 -0
- data/configs/database.yml +8 -8
- data/environments/boot.rb +17 -0
- data/environments/development.rb +10 -7
- data/environments/environment.rb +37 -73
- data/environments/production.rb +15 -6
- data/environments/test.rb +12 -6
- data/fresh_rakefile +6 -198
- data/helpers/application.rb +2 -2
- data/helpers/application_helper.rb +1 -1
- data/helpers/test_helper.rb +6 -19
- data/html/javascripts/controls.js +427 -165
- data/html/javascripts/dragdrop.js +256 -277
- data/html/javascripts/effects.js +766 -277
- data/html/javascripts/prototype.js +903 -217
- data/html/javascripts/scriptaculous.js +47 -0
- data/html/javascripts/slider.js +258 -0
- data/html/robots.txt +1 -0
- data/lib/binding_of_caller.rb +3 -1
- data/lib/breakpoint.rb +5 -5
- data/lib/breakpoint_client.rb +1 -1
- data/lib/code_statistics.rb +7 -4
- data/lib/commands.rb +17 -0
- data/lib/commands/breakpointer.rb +1 -0
- data/lib/commands/console.rb +22 -0
- data/lib/commands/destroy.rb +6 -0
- data/lib/commands/generate.rb +6 -0
- data/{bin → lib/commands/ncgi}/listener +0 -0
- data/{bin → lib/commands/ncgi}/tracker +0 -0
- data/lib/commands/performance/benchmarker.rb +26 -0
- data/{bin/profiler → lib/commands/performance/profiler.rb} +3 -2
- data/lib/commands/process/reaper.rb +130 -0
- data/lib/commands/process/spawner.rb +52 -0
- data/lib/commands/process/spinner.rb +57 -0
- data/lib/commands/runner.rb +27 -0
- data/lib/commands/server.rb +59 -0
- data/{bin/update → lib/commands/update.rb} +1 -2
- data/lib/dispatcher.rb +20 -3
- data/lib/fcgi_handler.rb +59 -41
- data/lib/initializer.rb +479 -0
- data/lib/rails_generator/base.rb +2 -2
- data/lib/rails_generator/commands.rb +59 -7
- data/lib/rails_generator/generators/applications/app/app_generator.rb +26 -15
- data/lib/rails_generator/generators/components/controller/controller_generator.rb +3 -2
- data/lib/rails_generator/generators/components/controller/templates/view.rhtml +1 -1
- data/lib/rails_generator/generators/components/mailer/USAGE +2 -3
- data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +1 -1
- data/lib/rails_generator/generators/components/migration/migration_generator.rb +3 -1
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +32 -31
- data/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml +1 -1
- data/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +1 -1
- data/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml +1 -1
- data/lib/rails_generator/lookup.rb +3 -3
- data/lib/rails_generator/options.rb +1 -0
- data/lib/rails_generator/scripts.rb +1 -1
- data/lib/rails_version.rb +9 -0
- data/lib/railties_path.rb +1 -0
- data/lib/rubyprof_ext.rb +1 -1
- data/lib/tasks/databases.rake +152 -0
- data/lib/tasks/documentation.rake +44 -0
- data/lib/tasks/framework.rake +33 -0
- data/lib/tasks/javascripts.rake +6 -0
- data/lib/tasks/misc.rake +15 -0
- data/lib/tasks/rails.rb +7 -0
- data/lib/tasks/statistics.rake +16 -0
- data/lib/tasks/testing.rake +37 -0
- data/lib/test_help.rb +13 -0
- data/lib/webrick_server.rb +31 -9
- metadata +121 -85
- data/bin/benchmarker +0 -19
- data/bin/breakpointer_for_gem +0 -4
- data/bin/console_sandbox +0 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
unless defined?(RAILS_ROOT)
|
2
|
+
root_path = File.join(File.dirname(__FILE__), '..')
|
3
|
+
unless RUBY_PLATFORM =~ /mswin32/
|
4
|
+
require 'pathname'
|
5
|
+
root_path = Pathname.new(root_path).cleanpath.to_s
|
6
|
+
end
|
7
|
+
RAILS_ROOT = root_path
|
8
|
+
end
|
9
|
+
|
10
|
+
if File.directory?("#{RAILS_ROOT}/vendor/rails")
|
11
|
+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
12
|
+
else
|
13
|
+
require 'rubygems'
|
14
|
+
require 'initializer'
|
15
|
+
end
|
16
|
+
|
17
|
+
Rails::Initializer.run(:set_load_path)
|
data/environments/development.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
# In the development environment your application's code is reloaded on
|
2
2
|
# every request. This slows down response time but is perfect for development
|
3
3
|
# since you don't have to restart the webserver when you make code changes.
|
4
|
+
config.cache_classes = false
|
4
5
|
|
5
6
|
# Log error messages when you accidentally call methods on nil.
|
6
|
-
|
7
|
+
config.whiny_nils = true
|
7
8
|
|
8
|
-
#
|
9
|
-
|
10
|
-
ActionController::Base.consider_all_requests_local = true
|
11
|
-
ActionController::Base.perform_caching = false
|
9
|
+
# Enable the breakpoint server that script/breakpointer connects to
|
10
|
+
config.breakpoint_server = true
|
12
11
|
|
13
|
-
#
|
14
|
-
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.action_controller.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
data/environments/environment.rb
CHANGED
@@ -1,87 +1,51 @@
|
|
1
|
-
# Load the Rails framework and configure your application.
|
2
|
-
# You can include your own configuration at the end of this file.
|
3
|
-
#
|
4
1
|
# Be sure to restart your webserver when you modify this file.
|
5
2
|
|
6
|
-
#
|
7
|
-
|
3
|
+
# Uncomment below to force Rails into production mode
|
4
|
+
# (Use only when you can't set environment variables through your web/app server)
|
5
|
+
# ENV['RAILS_ENV'] = 'production'
|
8
6
|
|
9
|
-
#
|
10
|
-
|
11
|
-
# environment variable instead.
|
12
|
-
#
|
13
|
-
# See config/environments/*.rb for environment-specific configuration.
|
14
|
-
RAILS_ENV = ENV['RAILS_ENV'] || 'development'
|
7
|
+
# Bootstrap the Rails environment, frameworks, and default configuration
|
8
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
15
9
|
|
10
|
+
Rails::Initializer.run do |config|
|
11
|
+
# Skip frameworks you're not going to use
|
12
|
+
# config.frameworks -= [ :action_web_service, :action_mailer ]
|
16
13
|
|
17
|
-
#
|
18
|
-
|
14
|
+
# Add additional load paths for your own custom dirs
|
15
|
+
# config.load_paths += %W( #{RAILS_ROOT}/app/services )
|
19
16
|
|
20
|
-
#
|
21
|
-
|
22
|
-
|
17
|
+
# Force all environments to use the same logger level
|
18
|
+
# (by default production uses :info, the others :debug)
|
19
|
+
# config.log_level = :debug
|
23
20
|
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
app/models
|
28
|
-
app/controllers
|
29
|
-
app/helpers
|
30
|
-
app/apis
|
31
|
-
components
|
32
|
-
config
|
33
|
-
lib
|
34
|
-
vendor
|
35
|
-
vendor/rails/railties
|
36
|
-
vendor/rails/railties/lib
|
37
|
-
vendor/rails/actionpack/lib
|
38
|
-
vendor/rails/activesupport/lib
|
39
|
-
vendor/rails/activerecord/lib
|
40
|
-
vendor/rails/actionmailer/lib
|
41
|
-
vendor/rails/actionwebservice/lib
|
42
|
-
).map { |dir| "#{RAILS_ROOT}/#{dir}" }.select { |dir| File.directory?(dir) }
|
21
|
+
# Use the database for sessions instead of the file system
|
22
|
+
# (create the session table with 'rake create_sessions_table')
|
23
|
+
# config.action_controller.session_store = :active_record_store
|
43
24
|
|
44
|
-
#
|
45
|
-
|
25
|
+
# Enable page/fragment caching by setting a file-based store
|
26
|
+
# (remember to create the caching directory and make it readable to the application)
|
27
|
+
# config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache"
|
46
28
|
|
47
|
-
#
|
48
|
-
|
29
|
+
# Activate observers that should always be running
|
30
|
+
# config.active_record.observers = :cacher, :garbage_collector
|
49
31
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
32
|
+
# Make Active Record use UTC-base instead of local time
|
33
|
+
# config.active_record.default_timezone = :utc
|
34
|
+
|
35
|
+
# Use Active Record's schema dumper instead of SQL when creating the test database
|
36
|
+
# (enables use of different database adapters for development and test environments)
|
37
|
+
# config.active_record.schema_format = :ruby
|
55
38
|
|
56
|
-
#
|
57
|
-
require_dependency "environments/#{RAILS_ENV}"
|
58
|
-
ActiveRecord::Base.configurations = File.open("#{RAILS_ROOT}/config/database.yml") { |f| YAML::load(f) }
|
59
|
-
ActiveRecord::Base.establish_connection
|
60
|
-
|
61
|
-
|
62
|
-
# Configure defaults if the included environment did not.
|
63
|
-
begin
|
64
|
-
RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log")
|
65
|
-
RAILS_DEFAULT_LOGGER.level = (RAILS_ENV == 'production' ? Logger::INFO : Logger::DEBUG)
|
66
|
-
rescue StandardError
|
67
|
-
RAILS_DEFAULT_LOGGER = Logger.new(STDERR)
|
68
|
-
RAILS_DEFAULT_LOGGER.level = Logger::WARN
|
69
|
-
RAILS_DEFAULT_LOGGER.warn(
|
70
|
-
"Rails Error: Unable to access log file. Please ensure that log/#{RAILS_ENV}.log exists and is chmod 0666. " +
|
71
|
-
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
|
72
|
-
)
|
39
|
+
# See Rails::Configuration for more options
|
73
40
|
end
|
74
41
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
#
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
File.join(RAILS_ROOT, 'components')
|
84
|
-
)
|
85
|
-
|
86
|
-
# Include your app's configuration here:
|
42
|
+
# Add new inflection rules using the following format
|
43
|
+
# (all these examples are active by default):
|
44
|
+
# Inflector.inflections do |inflect|
|
45
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
46
|
+
# inflect.singular /^(ox)en/i, '\1'
|
47
|
+
# inflect.irregular 'person', 'people'
|
48
|
+
# inflect.uncountable %w( fish sheep )
|
49
|
+
# end
|
87
50
|
|
51
|
+
# Include your application configuration below
|
data/environments/production.rb
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
# The production environment is meant for finished, "live" apps.
|
2
|
-
# Code is not reloaded between requests
|
3
|
-
|
2
|
+
# Code is not reloaded between requests
|
3
|
+
config.cache_classes = true
|
4
4
|
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
# Use a different logger for distributed setups
|
6
|
+
# config.logger = SyslogLogger.new
|
7
|
+
|
8
|
+
|
9
|
+
# Full error reports are disabled and caching is turned on
|
10
|
+
config.action_controller.consider_all_requests_local = false
|
11
|
+
config.action_controller.perform_caching = true
|
12
|
+
|
13
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
14
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
15
|
+
|
16
|
+
# Disable delivery errors if you bad email addresses should just be ignored
|
17
|
+
# config.action_mailer.raise_delivery_errors = false
|
data/environments/test.rb
CHANGED
@@ -2,16 +2,22 @@
|
|
2
2
|
# test suite. You never need to work with it otherwise. Remember that
|
3
3
|
# your test database is "scratch space" for the test suite and is wiped
|
4
4
|
# and recreated between test runs. Don't rely on the data there!
|
5
|
+
config.cache_classes = true
|
5
6
|
|
6
7
|
# Log error messages when you accidentally call methods on nil.
|
7
|
-
|
8
|
+
config.whiny_nils = true
|
8
9
|
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
ActionController::Base.perform_caching = false
|
10
|
+
# Show full error reports and disable caching
|
11
|
+
config.action_controller.consider_all_requests_local = true
|
12
|
+
config.action_controller.perform_caching = false
|
13
13
|
|
14
14
|
# Tell ActionMailer not to deliver emails to the real world.
|
15
15
|
# The :test delivery method accumulates sent emails in the
|
16
16
|
# ActionMailer::Base.deliveries array.
|
17
|
-
|
17
|
+
config.action_mailer.delivery_method = :test
|
18
|
+
|
19
|
+
# Overwrite the default settings for fixtures in tests. See Fixtures
|
20
|
+
# for more details about these settings.
|
21
|
+
# config.transactional_fixtures = true
|
22
|
+
# config.instantiated_fixtures = false
|
23
|
+
# config.pre_loaded_fixtures = false
|
data/fresh_rakefile
CHANGED
@@ -1,202 +1,10 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/switchtower.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
5
|
+
|
1
6
|
require 'rake'
|
2
7
|
require 'rake/testtask'
|
3
8
|
require 'rake/rdoctask'
|
4
9
|
|
5
|
-
|
6
|
-
TEST_CHANGES_SINCE = Time.now - 600
|
7
|
-
|
8
|
-
desc "Run all the tests on a fresh test database"
|
9
|
-
task :default => [ :test_units, :test_functional ]
|
10
|
-
|
11
|
-
|
12
|
-
desc 'Require application environment.'
|
13
|
-
task :environment do
|
14
|
-
unless defined? RAILS_ROOT
|
15
|
-
require File.dirname(__FILE__) + '/config/environment'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
desc "Generate API documentation, show coding stats"
|
20
|
-
task :doc => [ :appdoc, :stats ]
|
21
|
-
|
22
|
-
|
23
|
-
# Look up tests for recently modified sources.
|
24
|
-
def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
|
25
|
-
FileList[source_pattern].map do |path|
|
26
|
-
if File.mtime(path) > touched_since
|
27
|
-
test = "#{test_path}/#{File.basename(path, '.rb')}_test.rb"
|
28
|
-
test if File.exists?(test)
|
29
|
-
end
|
30
|
-
end.compact
|
31
|
-
end
|
32
|
-
|
33
|
-
desc 'Test recent changes.'
|
34
|
-
Rake::TestTask.new(:recent => [ :clone_structure_to_test ]) do |t|
|
35
|
-
since = TEST_CHANGES_SINCE
|
36
|
-
touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
|
37
|
-
recent_tests('app/models/*.rb', 'test/unit', since) +
|
38
|
-
recent_tests('app/controllers/*.rb', 'test/functional', since)
|
39
|
-
|
40
|
-
t.libs << 'test'
|
41
|
-
t.verbose = true
|
42
|
-
t.test_files = touched.uniq
|
43
|
-
end
|
44
|
-
task :test_recent => [ :clone_structure_to_test ]
|
45
|
-
|
46
|
-
desc "Run the unit tests in test/unit"
|
47
|
-
Rake::TestTask.new("test_units") { |t|
|
48
|
-
t.libs << "test"
|
49
|
-
t.pattern = 'test/unit/**/*_test.rb'
|
50
|
-
t.verbose = true
|
51
|
-
}
|
52
|
-
task :test_units => [ :clone_structure_to_test ]
|
53
|
-
|
54
|
-
desc "Run the functional tests in test/functional"
|
55
|
-
Rake::TestTask.new("test_functional") { |t|
|
56
|
-
t.libs << "test"
|
57
|
-
t.pattern = 'test/functional/**/*_test.rb'
|
58
|
-
t.verbose = true
|
59
|
-
}
|
60
|
-
task :test_functional => [ :clone_structure_to_test ]
|
61
|
-
|
62
|
-
desc "Generate documentation for the application"
|
63
|
-
Rake::RDocTask.new("appdoc") { |rdoc|
|
64
|
-
rdoc.rdoc_dir = 'doc/app'
|
65
|
-
rdoc.title = "Rails Application Documentation"
|
66
|
-
rdoc.options << '--line-numbers --inline-source'
|
67
|
-
rdoc.rdoc_files.include('doc/README_FOR_APP')
|
68
|
-
rdoc.rdoc_files.include('app/**/*.rb')
|
69
|
-
}
|
70
|
-
|
71
|
-
desc "Generate documentation for the Rails framework"
|
72
|
-
Rake::RDocTask.new("apidoc") { |rdoc|
|
73
|
-
rdoc.rdoc_dir = 'doc/api'
|
74
|
-
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
75
|
-
rdoc.title = "Rails Framework Documentation"
|
76
|
-
rdoc.options << '--line-numbers --inline-source'
|
77
|
-
rdoc.rdoc_files.include('README')
|
78
|
-
rdoc.rdoc_files.include('CHANGELOG')
|
79
|
-
rdoc.rdoc_files.include('vendor/rails/railties/CHANGELOG')
|
80
|
-
rdoc.rdoc_files.include('vendor/rails/railties/MIT-LICENSE')
|
81
|
-
rdoc.rdoc_files.include('vendor/rails/activerecord/README')
|
82
|
-
rdoc.rdoc_files.include('vendor/rails/activerecord/CHANGELOG')
|
83
|
-
rdoc.rdoc_files.include('vendor/rails/activerecord/lib/active_record/**/*.rb')
|
84
|
-
rdoc.rdoc_files.exclude('vendor/rails/activerecord/lib/active_record/vendor/*')
|
85
|
-
rdoc.rdoc_files.include('vendor/rails/actionpack/README')
|
86
|
-
rdoc.rdoc_files.include('vendor/rails/actionpack/CHANGELOG')
|
87
|
-
rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_controller/**/*.rb')
|
88
|
-
rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_view/**/*.rb')
|
89
|
-
rdoc.rdoc_files.include('vendor/rails/actionmailer/README')
|
90
|
-
rdoc.rdoc_files.include('vendor/rails/actionmailer/CHANGELOG')
|
91
|
-
rdoc.rdoc_files.include('vendor/rails/actionmailer/lib/action_mailer/base.rb')
|
92
|
-
rdoc.rdoc_files.include('vendor/rails/actionwebservice/README')
|
93
|
-
rdoc.rdoc_files.include('vendor/rails/actionwebservice/CHANGELOG')
|
94
|
-
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service.rb')
|
95
|
-
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/*.rb')
|
96
|
-
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/api/*.rb')
|
97
|
-
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/client/*.rb')
|
98
|
-
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/container/*.rb')
|
99
|
-
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/dispatcher/*.rb')
|
100
|
-
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/protocol/*.rb')
|
101
|
-
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/support/*.rb')
|
102
|
-
rdoc.rdoc_files.include('vendor/rails/activesupport/README')
|
103
|
-
rdoc.rdoc_files.include('vendor/rails/activesupport/CHANGELOG')
|
104
|
-
rdoc.rdoc_files.include('vendor/rails/activesupport/lib/active_support/**/*.rb')
|
105
|
-
}
|
106
|
-
|
107
|
-
desc "Report code statistics (KLOCs, etc) from the application"
|
108
|
-
task :stats => [ :environment ] do
|
109
|
-
require 'code_statistics'
|
110
|
-
CodeStatistics.new(
|
111
|
-
["Helpers", "app/helpers"],
|
112
|
-
["Controllers", "app/controllers"],
|
113
|
-
["APIs", "app/apis"],
|
114
|
-
["Components", "components"],
|
115
|
-
["Functionals", "test/functional"],
|
116
|
-
["Models", "app/models"],
|
117
|
-
["Units", "test/unit"]
|
118
|
-
).to_s
|
119
|
-
end
|
120
|
-
|
121
|
-
desc "Recreate the test databases from the development structure"
|
122
|
-
task :clone_structure_to_test => [ :db_structure_dump, :purge_test_database ] do
|
123
|
-
abcs = ActiveRecord::Base.configurations
|
124
|
-
case abcs["test"]["adapter"]
|
125
|
-
when "mysql"
|
126
|
-
ActiveRecord::Base.establish_connection(:test)
|
127
|
-
ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0')
|
128
|
-
IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table|
|
129
|
-
ActiveRecord::Base.connection.execute(table)
|
130
|
-
end
|
131
|
-
when "postgresql"
|
132
|
-
ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
|
133
|
-
ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
|
134
|
-
ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
|
135
|
-
`psql -U "#{abcs["test"]["username"]}" -f db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}`
|
136
|
-
when "sqlite", "sqlite3"
|
137
|
-
`#{abcs[RAILS_ENV]["adapter"]} #{abcs["test"]["dbfile"]} < db/#{RAILS_ENV}_structure.sql`
|
138
|
-
when "sqlserver"
|
139
|
-
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
|
140
|
-
else
|
141
|
-
raise "Unknown database adapter '#{abcs["test"]["adapter"]}'"
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
desc "Dump the database structure to a SQL file"
|
146
|
-
task :db_structure_dump => :environment do
|
147
|
-
abcs = ActiveRecord::Base.configurations
|
148
|
-
case abcs[RAILS_ENV]["adapter"]
|
149
|
-
when "mysql"
|
150
|
-
ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
|
151
|
-
File.open("db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
|
152
|
-
when "postgresql"
|
153
|
-
ENV['PGHOST'] = abcs[RAILS_ENV]["host"] if abcs[RAILS_ENV]["host"]
|
154
|
-
ENV['PGPORT'] = abcs[RAILS_ENV]["port"].to_s if abcs[RAILS_ENV]["port"]
|
155
|
-
ENV['PGPASSWORD'] = abcs[RAILS_ENV]["password"].to_s if abcs[RAILS_ENV]["password"]
|
156
|
-
`pg_dump -U "#{abcs[RAILS_ENV]["username"]}" -s -x -O -f db/#{RAILS_ENV}_structure.sql #{abcs[RAILS_ENV]["database"]}`
|
157
|
-
when "sqlite", "sqlite3"
|
158
|
-
`#{abcs[RAILS_ENV]["adapter"]} #{abcs[RAILS_ENV]["dbfile"]} .schema > db/#{RAILS_ENV}_structure.sql`
|
159
|
-
when "sqlserver"
|
160
|
-
`scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /f db\\#{RAILS_ENV}_structure.sql /q /A /r`
|
161
|
-
`scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /F db\ /q /A /r`
|
162
|
-
else
|
163
|
-
raise "Unknown database adapter '#{abcs["test"]["adapter"]}'"
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
desc "Empty the test database"
|
168
|
-
task :purge_test_database => :environment do
|
169
|
-
abcs = ActiveRecord::Base.configurations
|
170
|
-
case abcs["test"]["adapter"]
|
171
|
-
when "mysql"
|
172
|
-
ActiveRecord::Base.establish_connection(:test)
|
173
|
-
ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"])
|
174
|
-
when "postgresql"
|
175
|
-
ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
|
176
|
-
ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
|
177
|
-
ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
|
178
|
-
`dropdb -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
|
179
|
-
`createdb -T template0 -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
|
180
|
-
when "sqlite","sqlite3"
|
181
|
-
File.delete(abcs["test"]["dbfile"]) if File.exist?(abcs["test"]["dbfile"])
|
182
|
-
when "sqlserver"
|
183
|
-
dropfkscript = "#{abcs["test"]["host"]}.#{abcs["test"]["database"]}.DP1".gsub(/\\/,'-')
|
184
|
-
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{dropfkscript}`
|
185
|
-
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
|
186
|
-
else
|
187
|
-
raise "Unknown database adapter '#{abcs["test"]["adapter"]}'"
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
desc "Clears all *.log files in log/"
|
192
|
-
task :clear_logs => :environment do
|
193
|
-
FileList["log/*.log"].each do |log_file|
|
194
|
-
f = File.open(log_file, "w")
|
195
|
-
f.close
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
desc "Migrate the database according to the migrate scripts in db/migrate (only supported on PG/MySQL). A specific version can be targetted with VERSION=x"
|
200
|
-
task :migrate => :environment do
|
201
|
-
ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/db/migrate/', ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
|
202
|
-
end
|
10
|
+
require 'tasks/rails'
|
data/helpers/application.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
2
|
-
# Likewise
|
1
|
+
# Filters added to this controller will be run for all controllers in the application.
|
2
|
+
# Likewise, all the methods added will be available for all controllers.
|
3
3
|
class ApplicationController < ActionController::Base
|
4
4
|
end
|
data/helpers/test_helper.rb
CHANGED
@@ -1,26 +1,13 @@
|
|
1
1
|
ENV["RAILS_ENV"] = "test"
|
2
|
-
|
3
|
-
# Expand the path to environment so that Ruby does not load it multiple times
|
4
|
-
# File.expand_path can be removed if Ruby 1.9 is in use.
|
5
2
|
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
6
|
-
require '
|
7
|
-
|
8
|
-
require 'test/unit'
|
9
|
-
require 'active_record/fixtures'
|
10
|
-
require 'action_controller/test_process'
|
11
|
-
require 'action_web_service/test_invoke'
|
12
|
-
require 'breakpoint'
|
13
|
-
|
14
|
-
Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
|
3
|
+
require 'test_help'
|
15
4
|
|
16
5
|
class Test::Unit::TestCase
|
17
|
-
# Turn
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
Fixtures.create_fixtures(File.dirname(__FILE__) + "/fixtures", table_names)
|
23
|
-
end
|
6
|
+
# Turn off transactional fixtures if you're working with MyISAM tables in MySQL
|
7
|
+
self.use_transactional_fixtures = true
|
8
|
+
|
9
|
+
# Instantiated fixtures are slow, but give you @david where you otherwise would need people(:david)
|
10
|
+
self.use_instantiated_fixtures = false
|
24
11
|
|
25
12
|
# Add more helper methods to be used by all tests here...
|
26
13
|
end
|