mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge branch 'master' into asset-path-helper
Conflicts: railties/test/application/configuration_test.rb
This commit is contained in:
commit
c800e27ad3
123 changed files with 681 additions and 626 deletions
6
Gemfile
6
Gemfile
|
@ -6,7 +6,7 @@ gem 'arel', github: 'rails/arel', branch: 'master'
|
|||
|
||||
gem 'mocha', '>= 0.11.2', :require => false
|
||||
gem 'rack-test', github: 'brynary/rack-test'
|
||||
gem 'rack-cache', "~> 1.2"
|
||||
gem 'rack-cache', '~> 1.2'
|
||||
gem 'bcrypt-ruby', '~> 3.0.0'
|
||||
gem 'jquery-rails', '~> 2.1.4', github: 'rails/jquery-rails'
|
||||
gem 'turbolinks'
|
||||
|
@ -41,8 +41,8 @@ instance_eval File.read local_gemfile if File.exists? local_gemfile
|
|||
|
||||
platforms :mri do
|
||||
group :test do
|
||||
gem 'ruby-prof', '~> 0.11.2'
|
||||
gem 'debugger' if !ENV['TRAVIS'] && RUBY_VERSION < "2.0"
|
||||
gem 'ruby-prof', '~> 0.11.2' if RUBY_VERSION < '2.0'
|
||||
gem 'debugger' if !ENV['TRAVIS'] && RUBY_VERSION < '2.0' && RUBY_PATCHLEVEL < 286
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -217,8 +217,10 @@ module AbstractController
|
|||
# * <tt>string</tt> - The name of the method that handles the action
|
||||
# * <tt>nil</tt> - No method name could be found. Raise ActionNotFound.
|
||||
def method_for_action(action_name)
|
||||
if action_method?(action_name) then action_name
|
||||
elsif respond_to?(:action_missing, true) then "_handle_action_missing"
|
||||
if action_method?(action_name)
|
||||
action_name
|
||||
elsif respond_to?(:action_missing, true)
|
||||
"_handle_action_missing"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,10 +29,6 @@ module ActionView #:nodoc:
|
|||
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
extend SanitizeHelper::ClassMethods
|
||||
end
|
||||
|
||||
include ActiveModelHelper
|
||||
include AssetTagHelper
|
||||
include AssetUrlHelper
|
||||
|
|
|
@ -17,7 +17,7 @@ class SanitizeHelperTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
def test_sanitize_form
|
||||
assert_sanitized "<form action=\"/foo/bar\" method=\"post\"><input></form>", ''
|
||||
assert_equal '', sanitize("<form action=\"/foo/bar\" method=\"post\"><input></form>")
|
||||
end
|
||||
|
||||
def test_should_sanitize_illegal_style_properties
|
||||
|
@ -48,8 +48,4 @@ class SanitizeHelperTest < ActionView::TestCase
|
|||
def test_sanitize_is_marked_safe
|
||||
assert sanitize("<html><script></script></html>").html_safe?
|
||||
end
|
||||
|
||||
def assert_sanitized(text, expected = nil)
|
||||
assert_equal((expected || text), sanitize(text))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
## Rails 4.0.0 (unreleased) ##
|
||||
|
||||
* PostgreSQL adapter correctly fetches default values when using multiple schemas and domains in a db. Fixes #7914
|
||||
|
||||
*Arturo Pie*
|
||||
|
||||
* Learn ActiveRecord::QueryMethods#order work with hash arguments
|
||||
|
||||
When symbol or hash passed we convert it to Arel::Nodes::Ordering.
|
||||
|
|
|
@ -90,7 +90,7 @@ module ActiveRecord
|
|||
else super(value, column)
|
||||
end
|
||||
when IPAddr
|
||||
return super(value, column) unless ['inet','cidr'].includes? column.sql_type
|
||||
return super(value, column) unless ['inet','cidr'].include? column.sql_type
|
||||
PostgreSQLColumn.cidr_to_string(value)
|
||||
else
|
||||
super(value, column)
|
||||
|
|
|
@ -280,16 +280,13 @@ module ActiveRecord
|
|||
end_sql
|
||||
|
||||
if result.nil? or result.empty?
|
||||
# If that fails, try parsing the primary key's default value.
|
||||
# Support the 7.x and 8.0 nextval('foo'::text) as well as
|
||||
# the 8.1+ nextval('foo'::regclass).
|
||||
result = query(<<-end_sql, 'SCHEMA')[0]
|
||||
SELECT attr.attname,
|
||||
CASE
|
||||
WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN
|
||||
substr(split_part(def.adsrc, '''', 2),
|
||||
strpos(split_part(def.adsrc, '''', 2), '.')+1)
|
||||
ELSE split_part(def.adsrc, '''', 2)
|
||||
WHEN split_part(pg_get_expr(def.adbin, def.adrelid), '''', 2) ~ '.' THEN
|
||||
substr(split_part(pg_get_expr(def.adbin, def.adrelid), '''', 2),
|
||||
strpos(split_part(pg_get_expr(def.adbin, def.adrelid), '''', 2), '.')+1)
|
||||
ELSE split_part(pg_get_expr(def.adbin, def.adrelid), '''', 2)
|
||||
END
|
||||
FROM pg_class t
|
||||
JOIN pg_attribute attr ON (t.oid = attrelid)
|
||||
|
@ -297,7 +294,7 @@ module ActiveRecord
|
|||
JOIN pg_constraint cons ON (conrelid = adrelid AND adnum = conkey[1])
|
||||
WHERE t.oid = '#{quote_table_name(table)}'::regclass
|
||||
AND cons.contype = 'p'
|
||||
AND def.adsrc ~* 'nextval'
|
||||
AND pg_get_expr(def.adbin, def.adrelid) ~* 'nextval'
|
||||
end_sql
|
||||
end
|
||||
|
||||
|
|
|
@ -78,11 +78,8 @@ module ActiveRecord
|
|||
when /\A\(?(-?\d+(\.\d*)?\)?)\z/
|
||||
$1
|
||||
# Character types
|
||||
when /\A'(.*)'::(?:character varying|bpchar|text)\z/m
|
||||
when /\A\(?'(.*)'::.*\b(?:character varying|bpchar|text)\z/m
|
||||
$1
|
||||
# Character types (8.1 formatting)
|
||||
when /\AE'(.*)'::(?:character varying|bpchar|text)\z/m
|
||||
$1.gsub(/\\(\d\d\d)/) { $1.oct.chr }
|
||||
# Binary data types
|
||||
when /\A'(.*)'::bytea\z/m
|
||||
$1
|
||||
|
@ -763,7 +760,8 @@ module ActiveRecord
|
|||
# - ::regclass is a function that gives the id for a table name
|
||||
def column_definitions(table_name) #:nodoc:
|
||||
exec_query(<<-end_sql, 'SCHEMA').rows
|
||||
SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull, a.atttypid, a.atttypmod
|
||||
SELECT a.attname, format_type(a.atttypid, a.atttypmod),
|
||||
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
|
||||
FROM pg_attribute a LEFT JOIN pg_attrdef d
|
||||
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
|
||||
WHERE a.attrelid = '#{quote_table_name(table_name)}'::regclass
|
||||
|
|
|
@ -22,7 +22,17 @@ module ActiveRecord
|
|||
# the values.
|
||||
def other
|
||||
other = Relation.new(relation.klass, relation.table)
|
||||
hash.each { |k, v| other.send("#{k}!", v) }
|
||||
hash.each { |k, v|
|
||||
if k == :joins
|
||||
if Hash === v
|
||||
other.joins!(v)
|
||||
else
|
||||
other.joins!(*v)
|
||||
end
|
||||
else
|
||||
other.send("#{k}!", v)
|
||||
end
|
||||
}
|
||||
other
|
||||
end
|
||||
end
|
||||
|
@ -39,16 +49,18 @@ module ActiveRecord
|
|||
@values = other.values
|
||||
end
|
||||
|
||||
NORMAL_VALUES = Relation::SINGLE_VALUE_METHODS +
|
||||
Relation::MULTI_VALUE_METHODS -
|
||||
[:where, :order, :bind, :reverse_order, :lock, :create_with, :reordering, :from] # :nodoc:
|
||||
|
||||
def normal_values
|
||||
Relation::SINGLE_VALUE_METHODS +
|
||||
Relation::MULTI_VALUE_METHODS -
|
||||
[:where, :order, :bind, :reverse_order, :lock, :create_with, :reordering, :from]
|
||||
NORMAL_VALUES
|
||||
end
|
||||
|
||||
def merge
|
||||
normal_values.each do |name|
|
||||
value = values[name]
|
||||
relation.send("#{name}!", value) unless value.blank?
|
||||
relation.send("#{name}!", *value) unless value.blank?
|
||||
end
|
||||
|
||||
merge_multi_values
|
||||
|
|
|
@ -202,13 +202,13 @@ module ActiveRecord
|
|||
#
|
||||
# User.order('name DESC, email')
|
||||
# => SELECT "users".* FROM "users" ORDER BY name DESC, email
|
||||
#
|
||||
#
|
||||
# User.order(:name)
|
||||
# => SELECT "users".* FROM "users" ORDER BY "users"."name" ASC
|
||||
#
|
||||
#
|
||||
# User.order(email: :desc)
|
||||
# => SELECT "users".* FROM "users" ORDER BY "users"."email" DESC
|
||||
#
|
||||
#
|
||||
# User.order(:name, email: :desc)
|
||||
# => SELECT "users".* FROM "users" ORDER BY "users"."name" ASC, "users"."email" DESC
|
||||
def order(*args)
|
||||
|
@ -218,7 +218,7 @@ module ActiveRecord
|
|||
# Like #order, but modifies relation in place.
|
||||
def order!(*args)
|
||||
args.flatten!
|
||||
|
||||
|
||||
validate_order_args args
|
||||
|
||||
references = args.reject { |arg| Arel::Node === arg }
|
||||
|
@ -245,7 +245,7 @@ module ActiveRecord
|
|||
# Like #reorder, but modifies relation in place.
|
||||
def reorder!(*args)
|
||||
args.flatten!
|
||||
|
||||
|
||||
validate_order_args args
|
||||
|
||||
self.reordering_value = true
|
||||
|
@ -258,13 +258,11 @@ module ActiveRecord
|
|||
# User.joins(:posts)
|
||||
# => SELECT "users".* FROM "users" INNER JOIN "posts" ON "posts"."user_id" = "users"."id"
|
||||
def joins(*args)
|
||||
args.compact.blank? ? self : spawn.joins!(*args)
|
||||
args.compact.blank? ? self : spawn.joins!(*args.flatten)
|
||||
end
|
||||
|
||||
# Like #joins, but modifies relation in place.
|
||||
def joins!(*args)
|
||||
args.flatten!
|
||||
|
||||
self.joins_values += args
|
||||
self
|
||||
end
|
||||
|
@ -803,9 +801,9 @@ module ActiveRecord
|
|||
s.gsub!(/\sasc\Z/i, ' DESC') || s.gsub!(/\sdesc\Z/i, ' ASC') || s.concat(' DESC')
|
||||
end
|
||||
when Symbol
|
||||
{ o => :desc }
|
||||
{ o => :desc }
|
||||
when Hash
|
||||
o.each_with_object({}) do |(field, dir), memo|
|
||||
o.each_with_object({}) do |(field, dir), memo|
|
||||
memo[field] = (dir == :asc ? :desc : :asc )
|
||||
end
|
||||
else
|
||||
|
@ -817,25 +815,25 @@ module ActiveRecord
|
|||
def array_of_strings?(o)
|
||||
o.is_a?(Array) && o.all?{|obj| obj.is_a?(String)}
|
||||
end
|
||||
|
||||
|
||||
def build_order(arel)
|
||||
orders = order_values
|
||||
orders = reverse_sql_order(orders) if reverse_order_value
|
||||
|
||||
|
||||
orders = orders.uniq.reject(&:blank?).map do |order|
|
||||
case order
|
||||
when Symbol
|
||||
table[order].asc
|
||||
when Hash
|
||||
order.map { |field, dir| table[field].send(dir) }
|
||||
else
|
||||
else
|
||||
order
|
||||
end
|
||||
end.flatten
|
||||
|
||||
|
||||
arel.order(*orders) unless orders.empty?
|
||||
end
|
||||
|
||||
|
||||
def validate_order_args(args)
|
||||
args.select { |a| Hash === a }.each do |h|
|
||||
unless (h.values - [:asc, :desc]).empty?
|
||||
|
|
|
@ -26,11 +26,12 @@ module ActiveRecord
|
|||
relation = relation.and(table[finder_class.primary_key.to_sym].not_eq(record.send(:id))) if record.persisted?
|
||||
|
||||
Array(options[:scope]).each do |scope_item|
|
||||
scope_value = record.read_attribute(scope_item)
|
||||
reflection = record.class.reflect_on_association(scope_item)
|
||||
if reflection
|
||||
scope_value = record.send(reflection.foreign_key)
|
||||
scope_item = reflection.foreign_key
|
||||
else
|
||||
scope_value = record.read_attribute(scope_item)
|
||||
end
|
||||
relation = relation.and(table[scope_item].eq(scope_value))
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require "cases/helper"
|
||||
require 'ipaddr'
|
||||
|
||||
module ActiveRecord
|
||||
module ConnectionAdapters
|
||||
|
@ -20,6 +21,18 @@ module ActiveRecord
|
|||
assert_equal 'f', @conn.type_cast(false, c)
|
||||
end
|
||||
|
||||
def test_type_cast_cidr
|
||||
ip = IPAddr.new('255.0.0.0/8')
|
||||
c = Column.new(nil, ip, 'cidr')
|
||||
assert_equal ip, @conn.type_cast(ip, c)
|
||||
end
|
||||
|
||||
def test_type_cast_inet
|
||||
ip = IPAddr.new('255.1.0.0/8')
|
||||
c = Column.new(nil, ip, 'inet')
|
||||
assert_equal ip, @conn.type_cast(ip, c)
|
||||
end
|
||||
|
||||
def test_quote_float_nan
|
||||
nan = 0.0/0
|
||||
c = Column.new(nil, 1, 'float')
|
||||
|
|
|
@ -72,7 +72,7 @@ class SchemaTest < ActiveRecord::TestCase
|
|||
end
|
||||
|
||||
def test_schema_names
|
||||
assert_equal ["public", "test_schema", "test_schema2"], @connection.schema_names
|
||||
assert_equal ["public", "schema_1", "test_schema", "test_schema2"], @connection.schema_names
|
||||
end
|
||||
|
||||
def test_create_schema
|
||||
|
|
|
@ -109,3 +109,43 @@ if current_adapter?(:MysqlAdapter) or current_adapter?(:Mysql2Adapter)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
if current_adapter?(:PostgreSQLAdapter)
|
||||
class DefaultsUsingMultipleSchemasAndDomainTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@connection = ActiveRecord::Base.connection
|
||||
|
||||
@old_search_path = @connection.schema_search_path
|
||||
@connection.schema_search_path = "schema_1, pg_catalog"
|
||||
@connection.create_table "defaults" do |t|
|
||||
t.text "text_col", :default => "some value"
|
||||
t.string "string_col", :default => "some value"
|
||||
end
|
||||
Default.reset_column_information
|
||||
end
|
||||
|
||||
def test_text_defaults_in_new_schema_when_overriding_domain
|
||||
assert_equal "some value", Default.new.text_col, "Default of text column was not correctly parse"
|
||||
end
|
||||
|
||||
def test_string_defaults_in_new_schema_when_overriding_domain
|
||||
assert_equal "some value", Default.new.string_col, "Default of string column was not correctly parse"
|
||||
end
|
||||
|
||||
def test_bpchar_defaults_in_new_schema_when_overriding_domain
|
||||
@connection.execute "ALTER TABLE defaults ADD bpchar_col bpchar DEFAULT 'some value'"
|
||||
Default.reset_column_information
|
||||
assert_equal "some value", Default.new.bpchar_col, "Default of bpchar column was not correctly parse"
|
||||
end
|
||||
|
||||
def test_text_defaults_after_updating_column_default
|
||||
@connection.execute "ALTER TABLE defaults ALTER COLUMN text_col SET DEFAULT 'some text'::schema_1.text"
|
||||
assert_equal "some text", Default.new.text_col, "Default of text column was not correctly parse after updating default using '::text' since postgreSQL will add parens to the default in db"
|
||||
end
|
||||
|
||||
def teardown
|
||||
@connection.schema_search_path = @old_search_path
|
||||
Default.reset_column_information
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,6 +12,8 @@ ActiveRecord::Schema.define do
|
|||
|
||||
execute 'DROP FUNCTION IF EXISTS partitioned_insert_trigger()'
|
||||
|
||||
execute "DROP SCHEMA IF EXISTS schema_1 CASCADE"
|
||||
|
||||
%w(accounts_id_seq developers_id_seq projects_id_seq topics_id_seq customers_id_seq orders_id_seq).each do |seq_name|
|
||||
execute "SELECT setval('#{seq_name}', 100)"
|
||||
end
|
||||
|
@ -37,7 +39,12 @@ ActiveRecord::Schema.define do
|
|||
);
|
||||
_SQL
|
||||
|
||||
execute <<_SQL
|
||||
execute "CREATE SCHEMA schema_1"
|
||||
execute "CREATE DOMAIN schema_1.text AS text"
|
||||
execute "CREATE DOMAIN schema_1.varchar AS varchar"
|
||||
execute "CREATE DOMAIN schema_1.bpchar AS bpchar"
|
||||
|
||||
execute <<_SQL
|
||||
CREATE TABLE geometrics (
|
||||
id serial primary key,
|
||||
a_point point,
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
## Rails 4.0.0 (unreleased) ##
|
||||
|
||||
* Hash#extract! returns only those keys that present in the receiver.
|
||||
|
||||
{:a => 1, :b => 2}.extract!(:a, :x) # => {:a => 1}
|
||||
|
||||
*Mikhail Dieterle*
|
||||
|
||||
* Hash#extract! returns the same subclass, that the receiver is. I.e.
|
||||
HashWithIndifferentAccess#extract! returns HashWithIndifferentAccess instance.
|
||||
|
||||
*Mikhail Dieterle*
|
||||
|
||||
* Optimize ActiveSupport::Cache::Entry to reduce memory and processing overhead. *Brian Durand*
|
||||
|
||||
* Tests tag the Rails log with the current test class and test case:
|
||||
|
|
|
@ -32,9 +32,9 @@ class Hash
|
|||
|
||||
# Removes and returns the key/value pairs matching the given keys.
|
||||
#
|
||||
# { a: 1, b: 2, c: 3, d: 4 }.extract!(:a, :b)
|
||||
# # => {:a => 1, :b => 2}
|
||||
# { a: 1, b: 2, c: 3, d: 4 }.extract!(:a, :b) # => { a: 1, b: 2 }
|
||||
# { a: 1, b: 2 }.extract!(:a, :x) # => { a: 1 }
|
||||
def extract!(*keys)
|
||||
keys.each_with_object({}) { |key, result| result[key] = delete(key) }
|
||||
keys.each_with_object(self.class.new) { |key, result| result[key] = delete(key) if has_key?(key) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -56,32 +56,6 @@ module ActiveSupport
|
|||
end
|
||||
end
|
||||
|
||||
# A container for multiple queues. This class delegates to a default Queue
|
||||
# so that <tt>Rails.queue.push</tt> and friends will Just Work. To use this class
|
||||
# with multiple queues:
|
||||
#
|
||||
# # In your configuration:
|
||||
# Rails.queue[:image_queue] = SomeQueue.new
|
||||
# Rails.queue[:mail_queue] = SomeQueue.new
|
||||
#
|
||||
# # In your app code:
|
||||
# Rails.queue[:mail_queue].push SomeJob.new
|
||||
#
|
||||
class QueueContainer < DelegateClass(::Queue)
|
||||
def initialize(default_queue)
|
||||
@queues = { :default => default_queue }
|
||||
super(default_queue)
|
||||
end
|
||||
|
||||
def [](queue_name)
|
||||
@queues[queue_name]
|
||||
end
|
||||
|
||||
def []=(queue_name, queue)
|
||||
@queues[queue_name] = queue
|
||||
end
|
||||
end
|
||||
|
||||
# The threaded consumer will run jobs in a background thread in
|
||||
# development mode or in a VM where running jobs on a thread in
|
||||
# production mode makes sense.
|
||||
|
@ -90,10 +64,6 @@ module ActiveSupport
|
|||
# queue and joins the thread, which will ensure that all jobs
|
||||
# are executed before the process finally dies.
|
||||
class ThreadedQueueConsumer
|
||||
def self.start(*args)
|
||||
new(*args).start
|
||||
end
|
||||
|
||||
def initialize(queue, options = {})
|
||||
@queue = queue
|
||||
@logger = options[:logger]
|
||||
|
|
|
@ -723,8 +723,32 @@ class HashExtTest < ActiveSupport::TestCase
|
|||
def test_extract
|
||||
original = {:a => 1, :b => 2, :c => 3, :d => 4}
|
||||
expected = {:a => 1, :b => 2}
|
||||
remaining = {:c => 3, :d => 4}
|
||||
|
||||
assert_equal expected, original.extract!(:a, :b)
|
||||
assert_equal expected, original.extract!(:a, :b, :x)
|
||||
assert_equal remaining, original
|
||||
end
|
||||
|
||||
def test_extract_nils
|
||||
original = {:a => nil, :b => nil}
|
||||
expected = {:a => nil}
|
||||
extracted = original.extract!(:a, :x)
|
||||
|
||||
assert_equal expected, extracted
|
||||
assert_equal nil, extracted[:a]
|
||||
assert_equal nil, extracted[:x]
|
||||
end
|
||||
|
||||
def test_indifferent_extract
|
||||
original = {:a => 1, 'b' => 2, :c => 3, 'd' => 4}.with_indifferent_access
|
||||
expected = {:a => 1, :b => 2}.with_indifferent_access
|
||||
remaining = {:c => 3, :d => 4}.with_indifferent_access
|
||||
|
||||
[['a', 'b'], [:a, :b]].each do |keys|
|
||||
copy = original.dup
|
||||
assert_equal expected, copy.extract!(*keys)
|
||||
assert_equal remaining, copy
|
||||
end
|
||||
end
|
||||
|
||||
def test_except
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
require 'abstract_unit'
|
||||
require 'active_support/queueing'
|
||||
|
||||
module ActiveSupport
|
||||
class ContainerTest < ActiveSupport::TestCase
|
||||
def test_delegates_to_default
|
||||
q = Queue.new
|
||||
container = QueueContainer.new q
|
||||
job = Object.new
|
||||
|
||||
container.push job
|
||||
assert_equal job, q.pop
|
||||
end
|
||||
|
||||
def test_access_default
|
||||
q = Queue.new
|
||||
container = QueueContainer.new q
|
||||
assert_equal q, container[:default]
|
||||
end
|
||||
|
||||
def test_assign_queue
|
||||
container = QueueContainer.new Object.new
|
||||
q = Object.new
|
||||
container[:foo] = q
|
||||
assert_equal q, container[:foo]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -95,9 +95,9 @@ Railties
|
|||
|
||||
* Load all environments available in `config.paths["config/environments"]`.
|
||||
|
||||
* Add `config.queue_consumer` to allow the default consumer to be configurable.
|
||||
* Add `config.queue_consumer` to change the job queue consumer from the default `ActiveSupport::ThreadedQueueConsumer`.
|
||||
|
||||
* Add `Rails.queue` as an interface with a default implementation that consumes jobs in a separate thread.
|
||||
* Add `Rails.queue` for processing jobs in the background.
|
||||
|
||||
* Remove `Rack::SSL` in favour of `ActionDispatch::SSL`.
|
||||
|
||||
|
|
|
@ -2867,8 +2867,16 @@ The method `extract!` removes and returns the key/value pairs matching the given
|
|||
|
||||
```ruby
|
||||
hash = {:a => 1, :b => 2}
|
||||
rest = hash.extract!(:a) # => {:a => 1}
|
||||
hash # => {:b => 2}
|
||||
rest = hash.extract!(:a, :x) # => {:a => 1} # non-existing keys are ignored
|
||||
hash # => {:b => 2}
|
||||
```
|
||||
|
||||
The method `extract!` returns the same subclass of Hash, that the receiver is.
|
||||
|
||||
```ruby
|
||||
hash = {:a => 1, :b => 2}.with_indifferent_access
|
||||
rest = hash.extract!(:a).class
|
||||
# => ActiveSupport::HashWithIndifferentAccess
|
||||
```
|
||||
|
||||
NOTE: Defined in `active_support/core_ext/hash/slice.rb`.
|
||||
|
|
|
@ -115,9 +115,9 @@ NOTE. The `config.asset_path` configuration is ignored if the asset pipeline is
|
|||
|
||||
* `config.middleware` allows you to configure the application's middleware. This is covered in depth in the [Configuring Middleware](#configuring-middleware) section below.
|
||||
|
||||
* `config.queue` configures a different queue implementation for the application. Defaults to `ActiveSupport::SynchronousQueue`. Note that, if the default queue is changed, the default `queue_consumer` is not going to be initialized, it is up to the new queue implementation to handle starting and shutting down its own consumer(s).
|
||||
* `config.queue` configures the default job queue for the application. Defaults to `ActiveSupport::Queue.new` which processes jobs in a background thread. If you change the queue, you're responsible for running the jobs as well.
|
||||
|
||||
* `config.queue_consumer` configures a different consumer implementation for the default queue. Defaults to `ActiveSupport::ThreadedQueueConsumer`.
|
||||
* `config.queue_consumer` configures a different job consumer for the default queue. Defaults to `ActiveSupport::ThreadedQueueConsumer`. The job consumer must respond to `start`.
|
||||
|
||||
* `config.reload_classes_only_on_change` enables or disables reloading of classes only when tracked files change. By default tracks everything on autoload paths and is set to true. If `config.cache_classes` is true, this option is ignored.
|
||||
|
||||
|
|
|
@ -81,9 +81,9 @@
|
|||
|
||||
* Load all environments available in `config.paths["config/environments"]`. *Piotr Sarnacki*
|
||||
|
||||
* Add `config.queue_consumer` to allow the default consumer to be configurable. *Carlos Antonio da Silva*
|
||||
* Add `config.queue_consumer` to change the job queue consumer from the default `ActiveSupport::ThreadedQueueConsumer`. *Carlos Antonio da Silva*
|
||||
|
||||
* Add Rails.queue as an interface with a default implementation that consumes jobs in a separate thread. *Yehuda Katz*
|
||||
* Add `Rails.queue` for processing jobs in the background. *Yehuda Katz*
|
||||
|
||||
* Remove Rack::SSL in favour of ActionDispatch::SSL. *Rafael Mendonça França*
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ module Rails
|
|||
# * The environment variable RAILS_GROUPS;
|
||||
# * The optional envs given as argument and the hash with group dependencies;
|
||||
#
|
||||
# groups :assets => [:development, :test]
|
||||
# groups assets: [:development, :test]
|
||||
#
|
||||
# # Returns
|
||||
# # => [:default, :development, :assets] for Rails.env == "development"
|
||||
|
|
|
@ -71,7 +71,7 @@ module Rails
|
|||
attr_reader :reloaders
|
||||
attr_writer :queue
|
||||
|
||||
delegate :default_url_options, :default_url_options=, :to => :routes
|
||||
delegate :default_url_options, :default_url_options=, to: :routes
|
||||
|
||||
def initialize
|
||||
super
|
||||
|
@ -106,7 +106,7 @@ module Rails
|
|||
def key_generator
|
||||
# number of iterations selected based on consultation with the google security
|
||||
# team. Details at https://github.com/rails/rails/pull/6952#issuecomment-7661220
|
||||
@key_generator ||= ActiveSupport::KeyGenerator.new(config.secret_token, :iterations=>1000)
|
||||
@key_generator ||= ActiveSupport::KeyGenerator.new(config.secret_token, iterations: 1000)
|
||||
end
|
||||
|
||||
# Stores some of the Rails initial environment parameters which
|
||||
|
@ -198,11 +198,7 @@ module Rails
|
|||
end
|
||||
|
||||
def queue #:nodoc:
|
||||
@queue ||= ActiveSupport::QueueContainer.new(build_queue)
|
||||
end
|
||||
|
||||
def build_queue #:nodoc:
|
||||
config.queue.new
|
||||
@queue ||= config.queue || ActiveSupport::Queue.new
|
||||
end
|
||||
|
||||
def to_app #:nodoc:
|
||||
|
@ -300,9 +296,9 @@ module Rails
|
|||
|
||||
if rack_cache == true
|
||||
rack_cache = {
|
||||
:metastore => "rails:/",
|
||||
:entitystore => "rails:/",
|
||||
:verbose => false
|
||||
metastore: "rails:/",
|
||||
entitystore: "rails:/",
|
||||
verbose: false
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -7,13 +7,13 @@ module Rails
|
|||
module Bootstrap
|
||||
include Initializable
|
||||
|
||||
initializer :load_environment_hook, :group => :all do end
|
||||
initializer :load_environment_hook, group: :all do end
|
||||
|
||||
initializer :load_active_support, :group => :all do
|
||||
initializer :load_active_support, group: :all do
|
||||
require "active_support/all" unless config.active_support.bare
|
||||
end
|
||||
|
||||
initializer :set_eager_load, :group => :all do
|
||||
initializer :set_eager_load, group: :all do
|
||||
if config.eager_load.nil?
|
||||
warn <<-INFO
|
||||
config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:
|
||||
|
@ -28,7 +28,7 @@ INFO
|
|||
end
|
||||
|
||||
# Initialize the logger early in the stack in case we need to log some deprecation.
|
||||
initializer :initialize_logger, :group => :all do
|
||||
initializer :initialize_logger, group: :all do
|
||||
Rails.logger ||= config.logger || begin
|
||||
path = config.paths["log"].first
|
||||
unless File.exist? File.dirname path
|
||||
|
@ -56,7 +56,7 @@ INFO
|
|||
end
|
||||
|
||||
# Initialize cache early in the stack so railties can make use of it.
|
||||
initializer :initialize_cache, :group => :all do
|
||||
initializer :initialize_cache, group: :all do
|
||||
unless Rails.cache
|
||||
Rails.cache = ActiveSupport::Cache.lookup_store(config.cache_store)
|
||||
|
||||
|
@ -67,11 +67,11 @@ INFO
|
|||
end
|
||||
|
||||
# Sets the dependency loading mechanism.
|
||||
initializer :initialize_dependency_mechanism, :group => :all do
|
||||
initializer :initialize_dependency_mechanism, group: :all do
|
||||
ActiveSupport::Dependencies.mechanism = config.cache_classes ? :require : :load
|
||||
end
|
||||
|
||||
initializer :bootstrap_hook, :group => :all do |app|
|
||||
initializer :bootstrap_hook, group: :all do |app|
|
||||
ActiveSupport.run_load_hooks(:before_initialize, app)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,8 +43,8 @@ module Rails
|
|||
@exceptions_app = nil
|
||||
@autoflush_log = true
|
||||
@log_formatter = ActiveSupport::Logger::SimpleFormatter.new
|
||||
@queue = ActiveSupport::SynchronousQueue
|
||||
@queue_consumer = ActiveSupport::ThreadedQueueConsumer
|
||||
@queue = ActiveSupport::SynchronousQueue.new
|
||||
@queue_consumer = nil
|
||||
@eager_load = nil
|
||||
|
||||
@assets = ActiveSupport::OrderedOptions.new
|
||||
|
@ -75,10 +75,10 @@ module Rails
|
|||
def paths
|
||||
@paths ||= begin
|
||||
paths = super
|
||||
paths.add "config/database", :with => "config/database.yml"
|
||||
paths.add "config/environment", :with => "config/environment.rb"
|
||||
paths.add "config/database", with: "config/database.yml"
|
||||
paths.add "config/environment", with: "config/environment.rb"
|
||||
paths.add "lib/templates"
|
||||
paths.add "log", :with => "log/#{Rails.env}.log"
|
||||
paths.add "log", with: "log/#{Rails.env}.log"
|
||||
paths.add "public"
|
||||
paths.add "public/javascripts"
|
||||
paths.add "public/stylesheets"
|
||||
|
|
|
@ -72,7 +72,7 @@ module Rails
|
|||
|
||||
# Set app reload just after the finisher hook to ensure
|
||||
# paths added in the hook are still loaded.
|
||||
initializer :set_clear_dependencies_hook, :group => :all do
|
||||
initializer :set_clear_dependencies_hook, group: :all do
|
||||
callback = lambda do
|
||||
ActiveSupport::DescendantsTracker.clear
|
||||
ActiveSupport::Dependencies.clear
|
||||
|
@ -83,7 +83,7 @@ module Rails
|
|||
self.reloaders << reloader
|
||||
# We need to set a to_prepare callback regardless of the reloader result, i.e.
|
||||
# models should be reloaded if any of the reloaders (i18n, routes) were updated.
|
||||
ActionDispatch::Reloader.to_prepare(:prepend => true){ reloader.execute }
|
||||
ActionDispatch::Reloader.to_prepare(prepend: true){ reloader.execute }
|
||||
else
|
||||
ActionDispatch::Reloader.to_cleanup(&callback)
|
||||
end
|
||||
|
@ -97,8 +97,9 @@ module Rails
|
|||
end
|
||||
|
||||
initializer :activate_queue_consumer do |app|
|
||||
if config.queue == ActiveSupport::Queue
|
||||
app.queue_consumer = config.queue_consumer.start(app.queue, {logger: Rails.logger})
|
||||
if config.queue.class == ActiveSupport::Queue
|
||||
app.queue_consumer = config.queue_consumer || config.queue.consumer
|
||||
app.queue_consumer.start
|
||||
at_exit { app.queue_consumer.shutdown }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ module Rails
|
|||
class Application
|
||||
class RoutesReloader
|
||||
attr_reader :route_sets, :paths
|
||||
delegate :execute_if_updated, :execute, :updated?, :to => :updater
|
||||
delegate :execute_if_updated, :execute, :updated?, to: :updater
|
||||
|
||||
def initialize
|
||||
@paths = []
|
||||
|
|
|
@ -9,6 +9,30 @@ aliases = {
|
|||
"r" => "runner"
|
||||
}
|
||||
|
||||
help_message = <<-EOT
|
||||
Usage: rails COMMAND [ARGS]
|
||||
|
||||
The most common rails commands are:
|
||||
generate Generate new code (short-cut alias: "g")
|
||||
console Start the Rails console (short-cut alias: "c")
|
||||
server Start the Rails server (short-cut alias: "s")
|
||||
dbconsole Start a console for the database specified in config/database.yml
|
||||
(short-cut alias: "db")
|
||||
new Create a new Rails application. "rails new my_app" creates a
|
||||
new application called MyApp in "./my_app"
|
||||
|
||||
In addition to those, there are:
|
||||
application Generate the Rails application code
|
||||
destroy Undo code generated with "generate" (short-cut alias: "d")
|
||||
benchmarker See how fast a piece of code runs
|
||||
profiler Get profile information from a piece of code
|
||||
plugin new Generates skeleton for developing a Rails plugin
|
||||
runner Run a piece of code in the application environment (short-cut alias: "r")
|
||||
|
||||
All commands can be run with -h (or --help) for more information.
|
||||
EOT
|
||||
|
||||
|
||||
command = ARGV.shift
|
||||
command = aliases[command] || command
|
||||
|
||||
|
@ -81,29 +105,14 @@ when '--version', '-v'
|
|||
ARGV.unshift '--version'
|
||||
require 'rails/commands/application'
|
||||
|
||||
when '-h', '--help'
|
||||
puts help_message
|
||||
|
||||
else
|
||||
puts "Error: Command not recognized" unless %w(-h --help).include?(command)
|
||||
puts <<-EOT
|
||||
Usage: rails COMMAND [ARGS]
|
||||
|
||||
The most common rails commands are:
|
||||
generate Generate new code (short-cut alias: "g")
|
||||
console Start the Rails console (short-cut alias: "c")
|
||||
server Start the Rails server (short-cut alias: "s")
|
||||
dbconsole Start a console for the database specified in config/database.yml
|
||||
(short-cut alias: "db")
|
||||
new Create a new Rails application. "rails new my_app" creates a
|
||||
new application called MyApp in "./my_app"
|
||||
|
||||
In addition to those, there are:
|
||||
application Generate the Rails application code
|
||||
destroy Undo code generated with "generate" (short-cut alias: "d")
|
||||
benchmarker See how fast a piece of code runs
|
||||
profiler Get profile information from a piece of code
|
||||
plugin new Generates skeleton for developing a Rails plugin
|
||||
runner Run a piece of code in the application environment (short-cut alias: "r")
|
||||
|
||||
All commands can be run with -h (or --help) for more information.
|
||||
EOT
|
||||
puts "Error: Command '#{command}' not recognized"
|
||||
if %x{rake #{command} --dry-run 2>&1 } && $?.success?
|
||||
puts "Did you mean: `$ rake #{command}` ?\n\n"
|
||||
end
|
||||
puts help_message
|
||||
exit(1)
|
||||
end
|
||||
|
|
|
@ -6,4 +6,4 @@ if [nil, "-h", "--help"].include?(ARGV.first)
|
|||
end
|
||||
|
||||
name = ARGV.shift
|
||||
Rails::Generators.invoke name, ARGV, :behavior => :revoke, :destination_root => Rails.root
|
||||
Rails::Generators.invoke name, ARGV, behavior: :revoke, destination_root: Rails.root
|
||||
|
|
|
@ -8,4 +8,4 @@ end
|
|||
name = ARGV.shift
|
||||
|
||||
root = defined?(ENGINE_ROOT) ? ENGINE_ROOT : Rails.root
|
||||
Rails::Generators.invoke name, ARGV, :behavior => :invoke, :destination_root => root
|
||||
Rails::Generators.invoke name, ARGV, behavior: :invoke, destination_root: root
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'optparse'
|
||||
require 'rbconfig'
|
||||
|
||||
options = { :environment => (ENV['RAILS_ENV'] || "development").dup }
|
||||
options = { environment: (ENV['RAILS_ENV'] || "development").dup }
|
||||
code_or_file = nil
|
||||
|
||||
if ARGV.first.nil?
|
||||
|
|
|
@ -105,13 +105,13 @@ module Rails
|
|||
|
||||
def default_options
|
||||
super.merge({
|
||||
:Port => 3000,
|
||||
:DoNotReverseLookup => true,
|
||||
:environment => (ENV['RAILS_ENV'] || "development").dup,
|
||||
:daemonize => false,
|
||||
:debugger => false,
|
||||
:pid => File.expand_path("tmp/pids/server.pid"),
|
||||
:config => File.expand_path("config.ru")
|
||||
Port: 3000,
|
||||
DoNotReverseLookup: true,
|
||||
environment: (ENV['RAILS_ENV'] || "development").dup,
|
||||
daemonize: false,
|
||||
debugger: false,
|
||||
pid: File.expand_path("tmp/pids/server.pid"),
|
||||
config: File.expand_path("config.ru")
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,4 +6,4 @@ if ARGV.size == 0
|
|||
end
|
||||
|
||||
name = ARGV.shift
|
||||
Rails::Generators.invoke name, ARGV, :behavior => :skip
|
||||
Rails::Generators.invoke name, ARGV, behavior: :skip
|
||||
|
|
|
@ -251,7 +251,7 @@ module Rails
|
|||
#
|
||||
# # config/routes.rb
|
||||
# MyApplication::Application.routes.draw do
|
||||
# mount MyEngine::Engine => "/my_engine", :as => "my_engine"
|
||||
# mount MyEngine::Engine => "/my_engine", as: "my_engine"
|
||||
# get "/foo" => "foo#index"
|
||||
# end
|
||||
#
|
||||
|
@ -368,7 +368,7 @@ module Rails
|
|||
def isolate_namespace(mod)
|
||||
engine_name(generate_railtie_name(mod))
|
||||
|
||||
self.routes.default_scope = { :module => ActiveSupport::Inflector.underscore(mod.name) }
|
||||
self.routes.default_scope = { module: ActiveSupport::Inflector.underscore(mod.name) }
|
||||
self.isolated = true
|
||||
|
||||
unless mod.respond_to?(:railtie_namespace)
|
||||
|
@ -407,8 +407,8 @@ module Rails
|
|||
end
|
||||
end
|
||||
|
||||
delegate :middleware, :root, :paths, :to => :config
|
||||
delegate :engine_name, :isolated?, :to => "self.class"
|
||||
delegate :middleware, :root, :paths, to: :config
|
||||
delegate :engine_name, :isolated?, to: "self.class"
|
||||
|
||||
def initialize
|
||||
@_all_autoload_paths = nil
|
||||
|
@ -536,7 +536,7 @@ module Rails
|
|||
end
|
||||
|
||||
# Add configured load paths to ruby load paths and remove duplicates.
|
||||
initializer :set_load_path, :before => :bootstrap_hook do
|
||||
initializer :set_load_path, before: :bootstrap_hook do
|
||||
_all_load_paths.reverse_each do |path|
|
||||
$LOAD_PATH.unshift(path) if File.directory?(path)
|
||||
end
|
||||
|
@ -548,7 +548,7 @@ module Rails
|
|||
#
|
||||
# This needs to be an initializer, since it needs to run once
|
||||
# per engine and get the engine as a block parameter
|
||||
initializer :set_autoload_paths, :before => :bootstrap_hook do |app|
|
||||
initializer :set_autoload_paths, before: :bootstrap_hook do |app|
|
||||
ActiveSupport::Dependencies.autoload_paths.unshift(*_all_autoload_paths)
|
||||
ActiveSupport::Dependencies.autoload_once_paths.unshift(*_all_autoload_once_paths)
|
||||
|
||||
|
@ -581,13 +581,13 @@ module Rails
|
|||
end
|
||||
end
|
||||
|
||||
initializer :load_environment_config, :before => :load_environment_hook, :group => :all do
|
||||
initializer :load_environment_config, before: :load_environment_hook, group: :all do
|
||||
paths["config/environments"].existent.each do |environment|
|
||||
require environment
|
||||
end
|
||||
end
|
||||
|
||||
initializer :append_assets_path, :group => :all do |app|
|
||||
initializer :append_assets_path, group: :all do |app|
|
||||
app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
|
||||
app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
|
||||
app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
|
||||
|
|
|
@ -20,7 +20,7 @@ module Rails
|
|||
# Holds generators configuration:
|
||||
#
|
||||
# config.generators do |g|
|
||||
# g.orm :data_mapper, :migration => true
|
||||
# g.orm :data_mapper, migration: true
|
||||
# g.template_engine :haml
|
||||
# g.test_framework :rspec
|
||||
# end
|
||||
|
@ -38,26 +38,26 @@ module Rails
|
|||
def paths
|
||||
@paths ||= begin
|
||||
paths = Rails::Paths::Root.new(@root)
|
||||
paths.add "app", :eager_load => true, :glob => "*"
|
||||
paths.add "app/assets", :glob => "*"
|
||||
paths.add "app/controllers", :eager_load => true
|
||||
paths.add "app/helpers", :eager_load => true
|
||||
paths.add "app/models", :eager_load => true
|
||||
paths.add "app/mailers", :eager_load => true
|
||||
paths.add "app", eager_load: true, glob: "*"
|
||||
paths.add "app/assets", glob: "*"
|
||||
paths.add "app/controllers", eager_load: true
|
||||
paths.add "app/helpers", eager_load: true
|
||||
paths.add "app/models", eager_load: true
|
||||
paths.add "app/mailers", eager_load: true
|
||||
paths.add "app/views"
|
||||
paths.add "lib", :load_path => true
|
||||
paths.add "lib/assets", :glob => "*"
|
||||
paths.add "lib/tasks", :glob => "**/*.rake"
|
||||
paths.add "lib", load_path: true
|
||||
paths.add "lib/assets", glob: "*"
|
||||
paths.add "lib/tasks", glob: "**/*.rake"
|
||||
paths.add "config"
|
||||
paths.add "config/environments", :glob => "#{Rails.env}.rb"
|
||||
paths.add "config/initializers", :glob => "**/*.rb"
|
||||
paths.add "config/locales", :glob => "*.{rb,yml}"
|
||||
paths.add "config/environments", glob: "#{Rails.env}.rb"
|
||||
paths.add "config/initializers", glob: "**/*.rb"
|
||||
paths.add "config/locales", glob: "*.{rb,yml}"
|
||||
paths.add "config/routes.rb"
|
||||
paths.add "db"
|
||||
paths.add "db/migrate"
|
||||
paths.add "db/seeds.rb"
|
||||
paths.add "vendor", :load_path => true
|
||||
paths.add "vendor/assets", :glob => "*"
|
||||
paths.add "vendor", load_path: true
|
||||
paths.add "vendor/assets", glob: "*"
|
||||
paths
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,41 +23,41 @@ module Rails
|
|||
mattr_accessor :namespace
|
||||
|
||||
DEFAULT_ALIASES = {
|
||||
:rails => {
|
||||
:actions => '-a',
|
||||
:orm => '-o',
|
||||
:javascripts => '-j',
|
||||
:javascript_engine => '-je',
|
||||
:resource_controller => '-c',
|
||||
:scaffold_controller => '-c',
|
||||
:stylesheets => '-y',
|
||||
:stylesheet_engine => '-se',
|
||||
:template_engine => '-e',
|
||||
:test_framework => '-t'
|
||||
rails: {
|
||||
actions: '-a',
|
||||
orm: '-o',
|
||||
javascripts: '-j',
|
||||
javascript_engine: '-je',
|
||||
resource_controller: '-c',
|
||||
scaffold_controller: '-c',
|
||||
stylesheets: '-y',
|
||||
stylesheet_engine: '-se',
|
||||
template_engine: '-e',
|
||||
test_framework: '-t'
|
||||
},
|
||||
|
||||
:test_unit => {
|
||||
:fixture_replacement => '-r',
|
||||
test_unit: {
|
||||
fixture_replacement: '-r',
|
||||
}
|
||||
}
|
||||
|
||||
DEFAULT_OPTIONS = {
|
||||
:rails => {
|
||||
:assets => true,
|
||||
:force_plural => false,
|
||||
:helper => true,
|
||||
:integration_tool => nil,
|
||||
:javascripts => true,
|
||||
:javascript_engine => :js,
|
||||
:orm => false,
|
||||
:performance_tool => nil,
|
||||
:resource_controller => :controller,
|
||||
:resource_route => true,
|
||||
:scaffold_controller => :scaffold_controller,
|
||||
:stylesheets => true,
|
||||
:stylesheet_engine => :css,
|
||||
:test_framework => false,
|
||||
:template_engine => :erb
|
||||
rails: {
|
||||
assets: true,
|
||||
force_plural: false,
|
||||
helper: true,
|
||||
integration_tool: nil,
|
||||
javascripts: true,
|
||||
javascript_engine: :js,
|
||||
orm: false,
|
||||
performance_tool: nil,
|
||||
resource_controller: :controller,
|
||||
resource_route: true,
|
||||
scaffold_controller: :scaffold_controller,
|
||||
stylesheets: true,
|
||||
stylesheet_engine: :css,
|
||||
test_framework: false,
|
||||
template_engine: :erb
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ module Rails
|
|||
|
||||
# Adds an entry into Gemfile for the supplied gem.
|
||||
#
|
||||
# gem "rspec", :group => :test
|
||||
# gem "technoweenie-restful-authentication", :lib => "restful-authentication", :source => "http://gems.github.com/"
|
||||
# gem "rails", "3.0", :git => "git://github.com/rails/rails"
|
||||
# gem "rspec", group: :test
|
||||
# gem "technoweenie-restful-authentication", lib: "restful-authentication", source: "http://gems.github.com/"
|
||||
# gem "rails", "3.0", git: "git://github.com/rails/rails"
|
||||
def gem(*args)
|
||||
options = args.extract_options!
|
||||
name, version = args
|
||||
|
@ -33,7 +33,7 @@ module Rails
|
|||
str = "gem #{parts.join(", ")}"
|
||||
str = " " + str if @in_group
|
||||
str = "\n" + str
|
||||
append_file "Gemfile", str, :verbose => false
|
||||
append_file "Gemfile", str, verbose: false
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -47,13 +47,13 @@ module Rails
|
|||
log :gemfile, "group #{name}"
|
||||
|
||||
in_root do
|
||||
append_file "Gemfile", "\ngroup #{name} do", :force => true
|
||||
append_file "Gemfile", "\ngroup #{name} do", force: true
|
||||
|
||||
@in_group = true
|
||||
instance_eval(&block)
|
||||
@in_group = false
|
||||
|
||||
append_file "Gemfile", "\nend\n", :force => true
|
||||
append_file "Gemfile", "\nend\n", force: true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -64,7 +64,7 @@ module Rails
|
|||
log :source, source
|
||||
|
||||
in_root do
|
||||
prepend_file "Gemfile", "source #{source.inspect}\n", :verbose => false
|
||||
prepend_file "Gemfile", "source #{source.inspect}\n", verbose: false
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -77,7 +77,7 @@ module Rails
|
|||
# "config.autoload_paths += %W(#{config.root}/extras)"
|
||||
# end
|
||||
#
|
||||
# environment(nil, :env => "development") do
|
||||
# environment(nil, env: "development") do
|
||||
# "config.active_record.observers = :cacher"
|
||||
# end
|
||||
def environment(data=nil, options={}, &block)
|
||||
|
@ -87,10 +87,10 @@ module Rails
|
|||
|
||||
in_root do
|
||||
if options[:env].nil?
|
||||
inject_into_file 'config/application.rb', "\n #{data}", :after => sentinel, :verbose => false
|
||||
inject_into_file 'config/application.rb', "\n #{data}", after: sentinel, verbose: false
|
||||
else
|
||||
Array(options[:env]).each do |env|
|
||||
inject_into_file "config/environments/#{env}.rb", "\n #{data}", :after => env_file_sentinel, :verbose => false
|
||||
inject_into_file "config/environments/#{env}.rb", "\n #{data}", after: env_file_sentinel, verbose: false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -100,8 +100,8 @@ module Rails
|
|||
# Run a command in git.
|
||||
#
|
||||
# git :init
|
||||
# git :add => "this.file that.rb"
|
||||
# git :add => "onefile.rb", :rm => "badfile.cxx"
|
||||
# git add: "this.file that.rb"
|
||||
# git add: "onefile.rb", rm: "badfile.cxx"
|
||||
def git(commands={})
|
||||
if commands.is_a?(Symbol)
|
||||
run "git #{commands}"
|
||||
|
@ -123,7 +123,7 @@ module Rails
|
|||
# vendor("foreign.rb", "# Foreign code is fun")
|
||||
def vendor(filename, data=nil, &block)
|
||||
log :vendor, filename
|
||||
create_file("vendor/#{filename}", data, :verbose => false, &block)
|
||||
create_file("vendor/#{filename}", data, verbose: false, &block)
|
||||
end
|
||||
|
||||
# Create a new file in the lib/ directory. Code can be specified
|
||||
|
@ -136,7 +136,7 @@ module Rails
|
|||
# lib("foreign.rb", "# Foreign code is fun")
|
||||
def lib(filename, data=nil, &block)
|
||||
log :lib, filename
|
||||
create_file("lib/#{filename}", data, :verbose => false, &block)
|
||||
create_file("lib/#{filename}", data, verbose: false, &block)
|
||||
end
|
||||
|
||||
# Create a new Rakefile with the provided code (either in a block or a string).
|
||||
|
@ -156,7 +156,7 @@ module Rails
|
|||
# rakefile('seed.rake', 'puts "Planting seeds"')
|
||||
def rakefile(filename, data=nil, &block)
|
||||
log :rakefile, filename
|
||||
create_file("lib/tasks/#{filename}", data, :verbose => false, &block)
|
||||
create_file("lib/tasks/#{filename}", data, verbose: false, &block)
|
||||
end
|
||||
|
||||
# Create a new initializer with the provided code (either in a block or a string).
|
||||
|
@ -174,7 +174,7 @@ module Rails
|
|||
# initializer("api.rb", "API_KEY = '123456'")
|
||||
def initializer(filename, data=nil, &block)
|
||||
log :initializer, filename
|
||||
create_file("config/initializers/#{filename}", data, :verbose => false, &block)
|
||||
create_file("config/initializers/#{filename}", data, verbose: false, &block)
|
||||
end
|
||||
|
||||
# Generate something using a generator from Rails or a plugin.
|
||||
|
@ -186,19 +186,19 @@ module Rails
|
|||
log :generate, what
|
||||
argument = args.map {|arg| arg.to_s }.flatten.join(" ")
|
||||
|
||||
in_root { run_ruby_script("script/rails generate #{what} #{argument}", :verbose => false) }
|
||||
in_root { run_ruby_script("script/rails generate #{what} #{argument}", verbose: false) }
|
||||
end
|
||||
|
||||
# Runs the supplied rake task
|
||||
#
|
||||
# rake("db:migrate")
|
||||
# rake("db:migrate", :env => "production")
|
||||
# rake("gems:install", :sudo => true)
|
||||
# rake("db:migrate", env: "production")
|
||||
# rake("gems:install", sudo: true)
|
||||
def rake(command, options={})
|
||||
log :rake, command
|
||||
env = options[:env] || ENV["RAILS_ENV"] || 'development'
|
||||
sudo = options[:sudo] && RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ ? 'sudo ' : ''
|
||||
in_root { run("#{sudo}#{extify(:rake)} #{command} RAILS_ENV=#{env}", :verbose => false) }
|
||||
in_root { run("#{sudo}#{extify(:rake)} #{command} RAILS_ENV=#{env}", verbose: false) }
|
||||
end
|
||||
|
||||
# Just run the capify command in root
|
||||
|
@ -206,7 +206,7 @@ module Rails
|
|||
# capify!
|
||||
def capify!
|
||||
log :capify, ""
|
||||
in_root { run("#{extify(:capify)} .", :verbose => false) }
|
||||
in_root { run("#{extify(:capify)} .", verbose: false) }
|
||||
end
|
||||
|
||||
# Make an entry in Rails routing file config/routes.rb
|
||||
|
@ -217,7 +217,7 @@ module Rails
|
|||
sentinel = /\.routes\.draw do\s*$/
|
||||
|
||||
in_root do
|
||||
inject_into_file 'config/routes.rb', "\n #{routing_code}", { :after => sentinel, :verbose => false }
|
||||
inject_into_file 'config/routes.rb', "\n #{routing_code}", { after: sentinel, verbose: false }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ module Rails
|
|||
#
|
||||
# module Rails::Generators
|
||||
# class ControllerGenerator < Base
|
||||
# hook_for :test_framework, :aliases => "-t"
|
||||
# hook_for :test_framework, aliases: "-t"
|
||||
# end
|
||||
# end
|
||||
#
|
||||
|
@ -102,7 +102,7 @@ module Rails
|
|||
# :as option:
|
||||
#
|
||||
# class AwesomeGenerator < Rails::Generators::Base
|
||||
# hook_for :test_framework, :as => :controller
|
||||
# hook_for :test_framework, as: :controller
|
||||
# end
|
||||
#
|
||||
# And now it will lookup at:
|
||||
|
@ -113,7 +113,7 @@ module Rails
|
|||
# need to provide the :base value:
|
||||
#
|
||||
# class AwesomeGenerator < Rails::Generators::Base
|
||||
# hook_for :test_framework, :in => :rails, :as => :controller
|
||||
# hook_for :test_framework, in: :rails, as: :controller
|
||||
# end
|
||||
#
|
||||
# And the lookup is exactly the same as previously:
|
||||
|
@ -137,7 +137,7 @@ module Rails
|
|||
# developers might want to have webrat available on controller generator.
|
||||
# This can be achieved as:
|
||||
#
|
||||
# Rails::Generators::ControllerGenerator.hook_for :webrat, :type => :boolean
|
||||
# Rails::Generators::ControllerGenerator.hook_for :webrat, type: :boolean
|
||||
#
|
||||
# Then, if you want webrat to be invoked, just supply:
|
||||
#
|
||||
|
@ -171,9 +171,9 @@ module Rails
|
|||
defaults = if options[:type] == :boolean
|
||||
{ }
|
||||
elsif [true, false].include?(default_value_for_option(name, options))
|
||||
{ :banner => "" }
|
||||
{ banner: "" }
|
||||
else
|
||||
{ :desc => "#{name.to_s.humanize} to be invoked", :banner => "NAME" }
|
||||
{ desc: "#{name.to_s.humanize} to be invoked", banner: "NAME" }
|
||||
end
|
||||
|
||||
unless class_options.key?(name)
|
||||
|
@ -343,8 +343,8 @@ module Rails
|
|||
# Small macro to add ruby as an option to the generator with proper
|
||||
# default value plus an instance helper method called shebang.
|
||||
def self.add_shebang_option!
|
||||
class_option :ruby, :type => :string, :aliases => "-r", :default => Thor::Util.ruby_command,
|
||||
:desc => "Path to the Ruby binary of your choice", :banner => "PATH"
|
||||
class_option :ruby, type: :string, aliases: "-r", default: Thor::Util.ruby_command,
|
||||
desc: "Path to the Ruby binary of your choice", banner: "PATH"
|
||||
|
||||
no_tasks {
|
||||
define_method :shebang do
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'rails/generators/erb'
|
|||
module Erb # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
class ControllerGenerator < Base # :nodoc:
|
||||
argument :actions, :type => :array, :default => [], :banner => "action action"
|
||||
argument :actions, type: :array, default: [], banner: "action action"
|
||||
|
||||
def copy_view_files
|
||||
base_path = File.join("app/views", class_path, file_name)
|
||||
|
|
|
@ -6,7 +6,7 @@ module Erb # :nodoc:
|
|||
class ScaffoldGenerator < Base # :nodoc:
|
||||
include Rails::Generators::ResourceHelpers
|
||||
|
||||
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
||||
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
||||
|
||||
def create_root_folder
|
||||
empty_directory File.join("app/views", controller_file_path)
|
||||
|
|
|
@ -23,7 +23,7 @@ module Rails
|
|||
type = type.to_sym if type
|
||||
|
||||
if type && reference?(type)
|
||||
references_index = UNIQ_INDEX_OPTIONS.include?(has_index) ? { :unique => true } : true
|
||||
references_index = UNIQ_INDEX_OPTIONS.include?(has_index) ? { unique: true } : true
|
||||
attr_options[:index] = references_index
|
||||
end
|
||||
|
||||
|
@ -41,11 +41,11 @@ module Rails
|
|||
def parse_type_and_options(type)
|
||||
case type
|
||||
when /(string|text|binary|integer)\{(\d+)\}/
|
||||
return $1, :limit => $2.to_i
|
||||
return $1, limit: $2.to_i
|
||||
when /decimal\{(\d+)[,.-](\d+)\}/
|
||||
return :decimal, :precision => $1.to_i, :scale => $2.to_i
|
||||
return :decimal, precision: $1.to_i, scale: $2.to_i
|
||||
when /(references|belongs_to)\{polymorphic\}/
|
||||
return $1, :polymorphic => true
|
||||
return $1, polymorphic: true
|
||||
else
|
||||
return type, {}
|
||||
end
|
||||
|
|
|
@ -5,9 +5,9 @@ require 'rails/generators/generated_attribute'
|
|||
module Rails
|
||||
module Generators
|
||||
class NamedBase < Base
|
||||
argument :name, :type => :string
|
||||
class_option :skip_namespace, :type => :boolean, :default => false,
|
||||
:desc => "Skip namespace (affects only isolated applications)"
|
||||
argument :name, type: :string
|
||||
class_option :skip_namespace, type: :boolean, default: false,
|
||||
desc: "Skip namespace (affects only isolated applications)"
|
||||
|
||||
def initialize(args, *options) #:nodoc:
|
||||
@inside_template = nil
|
||||
|
@ -169,7 +169,7 @@ module Rails
|
|||
#
|
||||
# ==== Examples
|
||||
#
|
||||
# check_class_collision :suffix => "Observer"
|
||||
# check_class_collision suffix: "Observer"
|
||||
#
|
||||
# If the generator is invoked with class name Admin, it will check for
|
||||
# the presence of "AdminObserver".
|
||||
|
|
|
@ -96,7 +96,7 @@ module Rails
|
|||
end
|
||||
|
||||
def public_directory
|
||||
directory "public", "public", :recursive => false
|
||||
directory "public", "public", recursive: false
|
||||
if options[:skip_index_html]
|
||||
remove_file "public/index.html"
|
||||
remove_file 'app/assets/images/rails.png'
|
||||
|
@ -108,7 +108,7 @@ module Rails
|
|||
directory "script" do |content|
|
||||
"#{shebang}\n" + content
|
||||
end
|
||||
chmod "script", 0755, :verbose => false
|
||||
chmod "script", 0755, verbose: false
|
||||
end
|
||||
|
||||
def test
|
||||
|
@ -152,8 +152,8 @@ module Rails
|
|||
add_shared_options_for "application"
|
||||
|
||||
# Add bin/rails options
|
||||
class_option :version, :type => :boolean, :aliases => "-v", :group => :rails,
|
||||
:desc => "Show Rails version number and quit"
|
||||
class_option :version, type: :boolean, aliases: "-v", group: :rails,
|
||||
desc: "Show Rails version number and quit"
|
||||
|
||||
def initialize(*args)
|
||||
raise Error, "Options should be given after the application name. For details run: rails --help" if args[0].blank?
|
||||
|
|
|
@ -88,5 +88,5 @@
|
|||
|
||||
# Default the production mode queue to an synchronous queue. You will probably
|
||||
# want to replace this with an out-of-process queueing solution.
|
||||
# config.queue = ActiveSupport::SynchronousQueue
|
||||
# config.queue = ActiveSupport::SynchronousQueue.new
|
||||
end
|
||||
|
|
|
@ -35,5 +35,5 @@
|
|||
config.active_support.deprecation = :stderr
|
||||
|
||||
# Use the synchronous queue to run jobs immediately.
|
||||
config.queue = ActiveSupport::SynchronousQueue
|
||||
config.queue = ActiveSupport::SynchronousQueue.new
|
||||
end
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
module Rails
|
||||
module Generators
|
||||
class AssetsGenerator < NamedBase # :nodoc:
|
||||
class_option :javascripts, :type => :boolean, :desc => "Generate JavaScripts"
|
||||
class_option :stylesheets, :type => :boolean, :desc => "Generate Stylesheets"
|
||||
class_option :javascripts, type: :boolean, desc: "Generate JavaScripts"
|
||||
class_option :stylesheets, type: :boolean, desc: "Generate Stylesheets"
|
||||
|
||||
class_option :javascript_engine, :desc => "Engine for JavaScripts"
|
||||
class_option :stylesheet_engine, :desc => "Engine for Stylesheets"
|
||||
class_option :javascript_engine, desc: "Engine for JavaScripts"
|
||||
class_option :stylesheet_engine, desc: "Engine for Stylesheets"
|
||||
|
||||
protected
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
module Rails
|
||||
module Generators
|
||||
class ControllerGenerator < NamedBase # :nodoc:
|
||||
argument :actions, :type => :array, :default => [], :banner => "action action"
|
||||
check_class_collision :suffix => "Controller"
|
||||
argument :actions, type: :array, default: [], banner: "action action"
|
||||
check_class_collision suffix: "Controller"
|
||||
|
||||
def create_controller_files
|
||||
template 'controller.rb', File.join('app/controllers', class_path, "#{file_name}_controller.rb")
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
module Rails
|
||||
module Generators
|
||||
class GeneratorGenerator < NamedBase # :nodoc:
|
||||
check_class_collision :suffix => "Generator"
|
||||
check_class_collision suffix: "Generator"
|
||||
|
||||
class_option :namespace, :type => :boolean, :default => true,
|
||||
:desc => "Namespace generator under lib/generators/name"
|
||||
class_option :namespace, type: :boolean, default: true,
|
||||
desc: "Namespace generator under lib/generators/name"
|
||||
|
||||
def create_generator_files
|
||||
directory '.', generator_dir
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Rails
|
||||
module Generators
|
||||
class HelperGenerator < NamedBase # :nodoc:
|
||||
check_class_collision :suffix => "Helper"
|
||||
check_class_collision suffix: "Helper"
|
||||
|
||||
def create_helper_files
|
||||
template 'helper.rb', File.join('app/helpers', class_path, "#{file_name}_helper.rb")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Rails
|
||||
module Generators
|
||||
class IntegrationTestGenerator < NamedBase # :nodoc:
|
||||
hook_for :integration_tool, :as => :integration
|
||||
hook_for :integration_tool, as: :integration
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
module Rails
|
||||
module Generators
|
||||
class MigrationGenerator < NamedBase # :nodoc:
|
||||
argument :attributes, :type => :array, :default => [], :banner => "field[:type][:index] field[:type][:index]"
|
||||
hook_for :orm, :required => true
|
||||
argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
|
||||
hook_for :orm, required: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
module Rails
|
||||
module Generators
|
||||
class ModelGenerator < NamedBase # :nodoc:
|
||||
argument :attributes, :type => :array, :default => [], :banner => "field[:type][:index] field[:type][:index]"
|
||||
hook_for :orm, :required => true
|
||||
argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
|
||||
hook_for :orm, required: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Rails
|
||||
module Generators
|
||||
class ObserverGenerator < NamedBase # :nodoc:
|
||||
hook_for :orm, :required => true
|
||||
hook_for :orm, required: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Rails
|
||||
module Generators
|
||||
class PerformanceTestGenerator < NamedBase # :nodoc:
|
||||
hook_for :performance_tool, :as => :performance
|
||||
hook_for :performance_tool, as: :performance
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -68,7 +68,7 @@ module Rails
|
|||
append_file "Rakefile", <<-EOF
|
||||
#{rakefile_test_tasks}
|
||||
|
||||
task :default => :test
|
||||
task default: :test
|
||||
EOF
|
||||
if full?
|
||||
template "test/integration/navigation_test.rb"
|
||||
|
@ -89,10 +89,10 @@ task :default => :test
|
|||
end
|
||||
|
||||
def test_dummy_config
|
||||
template "rails/boot.rb", "#{dummy_path}/config/boot.rb", :force => true
|
||||
template "rails/application.rb", "#{dummy_path}/config/application.rb", :force => true
|
||||
template "rails/boot.rb", "#{dummy_path}/config/boot.rb", force: true
|
||||
template "rails/application.rb", "#{dummy_path}/config/application.rb", force: true
|
||||
if mountable?
|
||||
template "rails/routes.rb", "#{dummy_path}/config/routes.rb", :force => true
|
||||
template "rails/routes.rb", "#{dummy_path}/config/routes.rb", force: true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -135,10 +135,10 @@ task :default => :test
|
|||
def script(force = false)
|
||||
return unless full?
|
||||
|
||||
directory "script", :force => force do |content|
|
||||
directory "script", force: force do |content|
|
||||
"#{shebang}\n" + content
|
||||
end
|
||||
chmod "script", 0755, :verbose => false
|
||||
chmod "script", 0755, verbose: false
|
||||
end
|
||||
|
||||
def gemfile_entry
|
||||
|
@ -158,20 +158,20 @@ task :default => :test
|
|||
|
||||
alias_method :plugin_path, :app_path
|
||||
|
||||
class_option :dummy_path, :type => :string, :default => "test/dummy",
|
||||
:desc => "Create dummy application at given path"
|
||||
class_option :dummy_path, type: :string, default: "test/dummy",
|
||||
desc: "Create dummy application at given path"
|
||||
|
||||
class_option :full, :type => :boolean, :default => false,
|
||||
:desc => "Generate a rails engine with bundled Rails application for testing"
|
||||
class_option :full, type: :boolean, default: false,
|
||||
desc: "Generate a rails engine with bundled Rails application for testing"
|
||||
|
||||
class_option :mountable, :type => :boolean, :default => false,
|
||||
:desc => "Generate mountable isolated application"
|
||||
class_option :mountable, type: :boolean, default: false,
|
||||
desc: "Generate mountable isolated application"
|
||||
|
||||
class_option :skip_gemspec, :type => :boolean, :default => false,
|
||||
:desc => "Skip gemspec file"
|
||||
class_option :skip_gemspec, type: :boolean, default: false,
|
||||
desc: "Skip gemspec file"
|
||||
|
||||
class_option :skip_gemfile_entry, :type => :boolean, :default => false,
|
||||
:desc => "If creating plugin in application's directory " +
|
||||
class_option :skip_gemfile_entry, type: :boolean, default: false,
|
||||
desc: "If creating plugin in application's directory " +
|
||||
"skip adding entry to Gemfile"
|
||||
|
||||
def initialize(*args)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<title><%= camelized %></title>
|
||||
<%%= stylesheet_link_tag "<%= name %>/application", :media => "all" %>
|
||||
<%%= stylesheet_link_tag "<%= name %>/application", media: "all" %>
|
||||
<%%= javascript_include_tag "<%= name %>/application" %>
|
||||
<%%= csrf_meta_tags %>
|
||||
</head>
|
||||
|
|
|
@ -7,14 +7,14 @@ module Rails
|
|||
class ResourceGenerator < ModelGenerator # :nodoc:
|
||||
include ResourceHelpers
|
||||
|
||||
hook_for :resource_controller, :required => true do |controller|
|
||||
hook_for :resource_controller, required: true do |controller|
|
||||
invoke controller, [ controller_name, options[:actions] ]
|
||||
end
|
||||
|
||||
class_option :actions, :type => :array, :banner => "ACTION ACTION", :default => [],
|
||||
:desc => "Actions for the resource controller"
|
||||
class_option :actions, type: :array, banner: "ACTION ACTION", default: [],
|
||||
desc: "Actions for the resource controller"
|
||||
|
||||
hook_for :resource_route, :required => true
|
||||
hook_for :resource_route, required: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,10 +6,10 @@ module Rails
|
|||
remove_hook_for :resource_controller
|
||||
remove_class_option :actions
|
||||
|
||||
class_option :stylesheets, :type => :boolean, :desc => "Generate Stylesheets"
|
||||
class_option :stylesheet_engine, :desc => "Engine for Stylesheets"
|
||||
class_option :stylesheets, type: :boolean, desc: "Generate Stylesheets"
|
||||
class_option :stylesheet_engine, desc: "Engine for Stylesheets"
|
||||
|
||||
hook_for :scaffold_controller, :required => true
|
||||
hook_for :scaffold_controller, required: true
|
||||
|
||||
hook_for :assets do |assets|
|
||||
invoke assets, [controller_name]
|
||||
|
|
|
@ -5,21 +5,21 @@ module Rails
|
|||
class ScaffoldControllerGenerator < NamedBase # :nodoc:
|
||||
include ResourceHelpers
|
||||
|
||||
check_class_collision :suffix => "Controller"
|
||||
check_class_collision suffix: "Controller"
|
||||
|
||||
class_option :orm, :banner => "NAME", :type => :string, :required => true,
|
||||
:desc => "ORM to generate the controller for"
|
||||
class_option :orm, banner: "NAME", type: :string, required: true,
|
||||
desc: "ORM to generate the controller for"
|
||||
|
||||
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
||||
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
||||
|
||||
def create_controller_files
|
||||
template "controller.rb", File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
|
||||
end
|
||||
|
||||
hook_for :template_engine, :test_framework, :as => :scaffold
|
||||
hook_for :template_engine, :test_framework, as: :scaffold
|
||||
|
||||
# Invoke the helper using the controller name (pluralized)
|
||||
hook_for :helper, :as => :scaffold do |invoked|
|
||||
hook_for :helper, as: :scaffold do |invoked|
|
||||
invoke invoked, [ controller_name ]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Rails
|
||||
module Generators
|
||||
class TaskGenerator < NamedBase # :nodoc:
|
||||
argument :actions, :type => :array, :default => [], :banner => "action action"
|
||||
argument :actions, type: :array, default: [], banner: "action action"
|
||||
|
||||
def create_task_files
|
||||
template 'task.rb', File.join('lib/tasks', "#{file_name}.rake")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
namespace :<%= file_name %> do
|
||||
<% actions.each do |action| -%>
|
||||
desc "TODO"
|
||||
task :<%= action %> => :environment do
|
||||
task <%= action %>: :environment do
|
||||
end
|
||||
|
||||
<% end -%>
|
||||
|
|
|
@ -8,7 +8,7 @@ module Rails
|
|||
mattr_accessor :skip_warn
|
||||
|
||||
def self.included(base) #:nodoc:
|
||||
base.class_option :force_plural, :type => :boolean, :desc => "Forces the use of a plural ModelName"
|
||||
base.class_option :force_plural, type: :boolean, desc: "Forces the use of a plural ModelName"
|
||||
end
|
||||
|
||||
# Set controller variables on initialization.
|
||||
|
|
|
@ -200,12 +200,12 @@ module Rails
|
|||
# You can provide a configuration hash as second argument. This method returns the output
|
||||
# printed by the generator.
|
||||
def run_generator(args=self.default_arguments, config={})
|
||||
capture(:stdout) { self.generator_class.start(args, config.reverse_merge(:destination_root => destination_root)) }
|
||||
capture(:stdout) { self.generator_class.start(args, config.reverse_merge(destination_root: destination_root)) }
|
||||
end
|
||||
|
||||
# Instantiate the generator.
|
||||
def generator(args=self.default_arguments, options={}, config={})
|
||||
@generator ||= self.generator_class.new(args, options, config.reverse_merge(:destination_root => destination_root))
|
||||
@generator ||= self.generator_class.new(args, options, config.reverse_merge(destination_root: destination_root))
|
||||
end
|
||||
|
||||
# Create a Rails::Generators::GeneratedAttribute by supplying the
|
||||
|
|
|
@ -3,8 +3,8 @@ require 'rails/generators/test_unit'
|
|||
module TestUnit # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
class ControllerGenerator < Base # :nodoc:
|
||||
argument :actions, :type => :array, :default => [], :banner => "action action"
|
||||
check_class_collision :suffix => "ControllerTest"
|
||||
argument :actions, type: :array, default: [], banner: "action action"
|
||||
check_class_collision suffix: "ControllerTest"
|
||||
|
||||
def create_test_files
|
||||
template 'functional_test.rb',
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'rails/generators/test_unit'
|
|||
module TestUnit # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
class HelperGenerator < Base # :nodoc:
|
||||
check_class_collision :suffix => "HelperTest"
|
||||
check_class_collision suffix: "HelperTest"
|
||||
|
||||
def create_helper_files
|
||||
template 'helper_test.rb', File.join('test/helpers', class_path, "#{file_name}_helper_test.rb")
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'rails/generators/test_unit'
|
|||
module TestUnit # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
class IntegrationGenerator < Base # :nodoc:
|
||||
check_class_collision :suffix => "Test"
|
||||
check_class_collision suffix: "Test"
|
||||
|
||||
def create_test_files
|
||||
template 'integration_test.rb', File.join('test/integration', class_path, "#{file_name}_test.rb")
|
||||
|
|
|
@ -3,8 +3,8 @@ require 'rails/generators/test_unit'
|
|||
module TestUnit # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
class MailerGenerator < Base # :nodoc:
|
||||
argument :actions, :type => :array, :default => [], :banner => "method method"
|
||||
check_class_collision :suffix => "Test"
|
||||
argument :actions, type: :array, default: [], banner: "method method"
|
||||
check_class_collision suffix: "Test"
|
||||
|
||||
def create_test_files
|
||||
template "functional_test.rb", File.join('test/mailers', class_path, "#{file_name}_test.rb")
|
||||
|
|
|
@ -3,10 +3,10 @@ require 'rails/generators/test_unit'
|
|||
module TestUnit # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
class ModelGenerator < Base # :nodoc:
|
||||
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
||||
class_option :fixture, :type => :boolean
|
||||
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
||||
class_option :fixture, type: :boolean
|
||||
|
||||
check_class_collision :suffix => "Test"
|
||||
check_class_collision suffix: "Test"
|
||||
|
||||
def create_test_file
|
||||
template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_test.rb")
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'rails/generators/test_unit'
|
|||
module TestUnit # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
class ObserverGenerator < Base # :nodoc:
|
||||
check_class_collision :suffix => "ObserverTest"
|
||||
check_class_collision suffix: "ObserverTest"
|
||||
|
||||
def create_test_files
|
||||
template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_observer_test.rb")
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'rails/generators/test_unit'
|
|||
module TestUnit # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
class PerformanceGenerator < Base # :nodoc:
|
||||
check_class_collision :suffix => "Test"
|
||||
check_class_collision suffix: "Test"
|
||||
|
||||
def create_test_files
|
||||
template 'performance_test.rb', File.join('test/performance', class_path, "#{file_name}_test.rb")
|
||||
|
|
|
@ -3,8 +3,8 @@ require 'rails/performance_test_help'
|
|||
|
||||
class <%= class_name %>Test < ActionDispatch::PerformanceTest
|
||||
# Refer to the documentation for all available options
|
||||
# self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory],
|
||||
# :output => 'tmp/performance', :formats => [:flat] }
|
||||
# self.profile_options = { runs: 5, metrics: [:wall_time, :memory],
|
||||
# output: 'tmp/performance', formats: [:flat] }
|
||||
|
||||
test "homepage" do
|
||||
get '/'
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'rails/generators/test_unit'
|
|||
module TestUnit # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
class PluginGenerator < Base # :nodoc:
|
||||
check_class_collision :suffix => "Test"
|
||||
check_class_collision suffix: "Test"
|
||||
|
||||
def create_test_files
|
||||
directory '.', 'test'
|
||||
|
|
|
@ -6,9 +6,9 @@ module TestUnit # :nodoc:
|
|||
class ScaffoldGenerator < Base # :nodoc:
|
||||
include Rails::Generators::ResourceHelpers
|
||||
|
||||
check_class_collision :suffix => "ControllerTest"
|
||||
check_class_collision suffix: "ControllerTest"
|
||||
|
||||
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
||||
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
||||
|
||||
def create_test_files
|
||||
template "functional_test.rb",
|
||||
|
|
|
@ -23,7 +23,7 @@ class Rails::InfoController < ActionController::Base
|
|||
|
||||
def require_local!
|
||||
unless local_request?
|
||||
render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => :forbidden
|
||||
render text: '<p>For security purposes, this information is only available to local requests.</p>', status: :forbidden
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Rails
|
|||
# paths by a Hash like API. It requires you to give a physical path on initialization.
|
||||
#
|
||||
# root = Root.new "/rails"
|
||||
# root.add "app/controllers", :eager_load => true
|
||||
# root.add "app/controllers", eager_load: true
|
||||
#
|
||||
# The command above creates a new root object and add "app/controllers" as a path.
|
||||
# This means we can get a <tt>Rails::Paths::Path</tt> object back like below:
|
||||
|
@ -26,7 +26,7 @@ module Rails
|
|||
# contains the path with the same path value given to +add+. In some situations,
|
||||
# you may not want this behavior, so you can give :with as option.
|
||||
#
|
||||
# root.add "config/routes", :with => "config/routes.rb"
|
||||
# root.add "config/routes", with: "config/routes.rb"
|
||||
# root["config/routes"].inspect # => ["config/routes.rb"]
|
||||
#
|
||||
# The +add+ method accepts the following options as arguments:
|
||||
|
@ -52,7 +52,7 @@ module Rails
|
|||
|
||||
def []=(path, value)
|
||||
glob = self[path] ? self[path].glob : nil
|
||||
add(path, :with => value, :glob => glob)
|
||||
add(path, with: value, glob: glob)
|
||||
end
|
||||
|
||||
def add(path, options={})
|
||||
|
|
|
@ -172,7 +172,7 @@ module Rails
|
|||
end
|
||||
end
|
||||
|
||||
delegate :railtie_name, :to => "self.class"
|
||||
delegate :railtie_name, to: "self.class"
|
||||
|
||||
def config
|
||||
@config ||= Railtie::Configuration.new
|
||||
|
|
|
@ -6,7 +6,7 @@ module Rails
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
module ClassMethods
|
||||
delegate :config, :to => :instance
|
||||
delegate :config, to: :instance
|
||||
|
||||
def inherited(base)
|
||||
raise "You cannot inherit from a #{self.superclass.name} child"
|
||||
|
|
|
@ -50,23 +50,23 @@ module Rails
|
|||
|
||||
# First configurable block to run. Called before any initializers are run.
|
||||
def before_configuration(&block)
|
||||
ActiveSupport.on_load(:before_configuration, :yield => true, &block)
|
||||
ActiveSupport.on_load(:before_configuration, yield: true, &block)
|
||||
end
|
||||
|
||||
# Third configurable block to run. Does not run if +config.cache_classes+
|
||||
# set to false.
|
||||
def before_eager_load(&block)
|
||||
ActiveSupport.on_load(:before_eager_load, :yield => true, &block)
|
||||
ActiveSupport.on_load(:before_eager_load, yield: true, &block)
|
||||
end
|
||||
|
||||
# Second configurable block to run. Called before frameworks initialize.
|
||||
def before_initialize(&block)
|
||||
ActiveSupport.on_load(:before_initialize, :yield => true, &block)
|
||||
ActiveSupport.on_load(:before_initialize, yield: true, &block)
|
||||
end
|
||||
|
||||
# Last configurable block to run. Called after frameworks initialize.
|
||||
def after_initialize(&block)
|
||||
ActiveSupport.on_load(:after_initialize, :yield => true, &block)
|
||||
ActiveSupport.on_load(:after_initialize, yield: true, &block)
|
||||
end
|
||||
|
||||
# Array of callbacks defined by #to_prepare.
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'rails/source_annotation_extractor'
|
|||
|
||||
desc "Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)"
|
||||
task :notes do
|
||||
SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", :tag => true
|
||||
SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", tag: true
|
||||
end
|
||||
|
||||
namespace :notes do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
namespace :rails do
|
||||
desc "Update configs and some other initially generated files (or use just update:configs, update:scripts, or update:application_controller)"
|
||||
task :update => [ "update:configs", "update:scripts", "update:application_controller" ]
|
||||
task update: [ "update:configs", "update:scripts", "update:application_controller" ]
|
||||
|
||||
desc "Applies the template supplied by LOCATION=(/path/to/template) or URL"
|
||||
task :template do
|
||||
|
@ -9,8 +9,8 @@ namespace :rails do
|
|||
template = File.expand_path(template) if template !~ %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://}
|
||||
require 'rails/generators'
|
||||
require 'rails/generators/rails/app/app_generator'
|
||||
generator = Rails::Generators::AppGenerator.new [Rails.root], {}, :destination_root => Rails.root
|
||||
generator.apply template, :verbose => false
|
||||
generator = Rails::Generators::AppGenerator.new [Rails.root], {}, destination_root: Rails.root
|
||||
generator.apply template, verbose: false
|
||||
end
|
||||
|
||||
namespace :templates do
|
||||
|
@ -44,8 +44,8 @@ namespace :rails do
|
|||
@app_generator ||= begin
|
||||
require 'rails/generators'
|
||||
require 'rails/generators/rails/app/app_generator'
|
||||
gen = Rails::Generators::AppGenerator.new ["rails"], { :with_dispatchers => true },
|
||||
:destination_root => Rails.root
|
||||
gen = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true },
|
||||
destination_root: Rails.root
|
||||
File.exists?(Rails.root.join("config", "application.rb")) ?
|
||||
gen.send(:app_const) : gen.send(:valid_app_const?)
|
||||
gen
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
desc 'Prints out your Rack middleware stack'
|
||||
task :middleware => :environment do
|
||||
task middleware: :environment do
|
||||
Rails.configuration.middleware.each do |middleware|
|
||||
puts "use #{middleware.inspect}"
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ task :secret do
|
|||
end
|
||||
|
||||
desc 'List versions of all Rails frameworks and the environment'
|
||||
task :about => :environment do
|
||||
task about: :environment do
|
||||
puts Rails::Info
|
||||
end
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace :time do
|
|||
require 'active_support'
|
||||
require 'active_support/time'
|
||||
jan_offset = Time.now.beginning_of_year.utc_offset
|
||||
jul_offset = Time.now.beginning_of_year.change(:month => 7).utc_offset
|
||||
jul_offset = Time.now.beginning_of_year.change(month: 7).utc_offset
|
||||
offset = jan_offset < jul_offset ? jan_offset : jul_offset
|
||||
build_time_zone_list(:all, offset)
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.'
|
||||
task :routes => :environment do
|
||||
task routes: :environment do
|
||||
all_routes = Rails.application.routes.routes
|
||||
require 'action_dispatch/routing/inspector'
|
||||
inspector = ActionDispatch::Routing::RoutesInspector.new
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
namespace :tmp do
|
||||
desc "Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear)"
|
||||
task :clear => [ "tmp:sessions:clear", "tmp:cache:clear", "tmp:sockets:clear"]
|
||||
task clear: [ "tmp:sessions:clear", "tmp:cache:clear", "tmp:sockets:clear"]
|
||||
|
||||
tmp_dirs = [ 'tmp/sessions',
|
||||
'tmp/cache',
|
||||
|
@ -13,7 +13,7 @@ namespace :tmp do
|
|||
tmp_dirs.each { |d| directory d }
|
||||
|
||||
desc "Creates tmp directories for sessions, cache, sockets, and pids"
|
||||
task :create => tmp_dirs
|
||||
task create: tmp_dirs
|
||||
|
||||
namespace :sessions do
|
||||
# desc "Clears all files in tmp/sessions"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
module Rails
|
||||
class TestUnitRailtie < Rails::Railtie
|
||||
config.app_generators do |c|
|
||||
c.test_framework :test_unit, :fixture => true,
|
||||
:fixture_replacement => nil
|
||||
c.test_framework :test_unit, fixture: true,
|
||||
fixture_replacement: nil
|
||||
|
||||
c.integration_tool :test_unit
|
||||
c.performance_tool :test_unit
|
||||
|
|
|
@ -43,7 +43,7 @@ module Kernel
|
|||
end
|
||||
end
|
||||
|
||||
task :default => :test
|
||||
task default: :test
|
||||
|
||||
desc 'Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile)'
|
||||
task :test do
|
||||
|
@ -61,7 +61,7 @@ namespace :test do
|
|||
Rake::Task[task].invoke
|
||||
nil
|
||||
rescue => e
|
||||
{ :task => task, :exception => e }
|
||||
{ task: task, exception: e }
|
||||
end
|
||||
end.compact
|
||||
|
||||
|
@ -71,7 +71,7 @@ namespace :test do
|
|||
end
|
||||
end
|
||||
|
||||
Rake::TestTask.new(:recent => "test:prepare") do |t|
|
||||
Rake::TestTask.new(recent: "test:prepare") do |t|
|
||||
since = TEST_CHANGES_SINCE
|
||||
touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
|
||||
recent_tests('app/models/**/*.rb', 'test/models', since) +
|
||||
|
@ -84,7 +84,7 @@ namespace :test do
|
|||
end
|
||||
Rake::Task['test:recent'].comment = "Test recent changes"
|
||||
|
||||
Rake::TestTask.new(:uncommitted => "test:prepare") do |t|
|
||||
Rake::TestTask.new(uncommitted: "test:prepare") do |t|
|
||||
def t.file_list
|
||||
if File.directory?(".svn")
|
||||
changed_since_checkin = silence_stderr { `svn status` }.split.map { |path| path.chomp[7 .. -1] }
|
||||
|
@ -108,52 +108,52 @@ namespace :test do
|
|||
end
|
||||
Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)"
|
||||
|
||||
Rake::TestTask.new(:single => "test:prepare") do |t|
|
||||
Rake::TestTask.new(single: "test:prepare") do |t|
|
||||
t.libs << "test"
|
||||
end
|
||||
|
||||
Rails::SubTestTask.new(:models => "test:prepare") do |t|
|
||||
Rails::SubTestTask.new(models: "test:prepare") do |t|
|
||||
t.libs << "test"
|
||||
t.pattern = 'test/models/**/*_test.rb'
|
||||
end
|
||||
|
||||
Rails::SubTestTask.new(:helpers => "test:prepare") do |t|
|
||||
Rails::SubTestTask.new(helpers: "test:prepare") do |t|
|
||||
t.libs << "test"
|
||||
t.pattern = 'test/helpers/**/*_test.rb'
|
||||
end
|
||||
|
||||
Rails::SubTestTask.new(:units => "test:prepare") do |t|
|
||||
Rails::SubTestTask.new(units: "test:prepare") do |t|
|
||||
t.libs << "test"
|
||||
t.pattern = 'test/{models,helpers,unit}/**/*_test.rb'
|
||||
end
|
||||
|
||||
Rails::SubTestTask.new(:controllers => "test:prepare") do |t|
|
||||
Rails::SubTestTask.new(controllers: "test:prepare") do |t|
|
||||
t.libs << "test"
|
||||
t.pattern = 'test/controllers/**/*_test.rb'
|
||||
end
|
||||
|
||||
Rails::SubTestTask.new(:mailers => "test:prepare") do |t|
|
||||
Rails::SubTestTask.new(mailers: "test:prepare") do |t|
|
||||
t.libs << "test"
|
||||
t.pattern = 'test/mailers/**/*_test.rb'
|
||||
end
|
||||
|
||||
Rails::SubTestTask.new(:functionals => "test:prepare") do |t|
|
||||
Rails::SubTestTask.new(functionals: "test:prepare") do |t|
|
||||
t.libs << "test"
|
||||
t.pattern = 'test/{controllers,mailers,functional}/**/*_test.rb'
|
||||
end
|
||||
|
||||
Rails::SubTestTask.new(:integration => "test:prepare") do |t|
|
||||
Rails::SubTestTask.new(integration: "test:prepare") do |t|
|
||||
t.libs << "test"
|
||||
t.pattern = 'test/integration/**/*_test.rb'
|
||||
end
|
||||
|
||||
Rails::SubTestTask.new(:benchmark => 'test:prepare') do |t|
|
||||
Rails::SubTestTask.new(benchmark: 'test:prepare') do |t|
|
||||
t.libs << 'test'
|
||||
t.pattern = 'test/performance/**/*_test.rb'
|
||||
t.options = '-- --benchmark'
|
||||
end
|
||||
|
||||
Rails::SubTestTask.new(:profile => 'test:prepare') do |t|
|
||||
Rails::SubTestTask.new(profile: 'test:prepare') do |t|
|
||||
t.libs << 'test'
|
||||
t.pattern = 'test/performance/**/*_test.rb'
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ module ApplicationTests
|
|||
include Rack::Test::Methods
|
||||
|
||||
def setup
|
||||
build_app(:initializers => true)
|
||||
build_app(initializers: true)
|
||||
|
||||
app_file "app/assets/javascripts/application.js", "//= require_tree ."
|
||||
app_file "app/assets/javascripts/xmlhr.js", "function f1() { alert(); }"
|
||||
|
@ -15,7 +15,7 @@ module ApplicationTests
|
|||
|
||||
app_file "config/routes.rb", <<-RUBY
|
||||
AppTemplate::Application.routes.draw do
|
||||
get '/posts', :to => "posts#index"
|
||||
get '/posts', to: "posts#index"
|
||||
end
|
||||
RUBY
|
||||
|
||||
|
@ -36,9 +36,8 @@ module ApplicationTests
|
|||
test "assets are concatenated when debug is off and compile is off either if debug_assets param is provided" do
|
||||
# config.assets.debug and config.assets.compile are false for production environment
|
||||
ENV["RAILS_ENV"] = "production"
|
||||
capture(:stdout) do
|
||||
Dir.chdir(app_path){ `bundle exec rake assets:precompile` }
|
||||
end
|
||||
output = Dir.chdir(app_path){ `bundle exec rake assets:precompile --trace 2>&1` }
|
||||
assert $?.success?, output
|
||||
require "#{app_path}/config/environment"
|
||||
|
||||
class ::PostsController < ActionController::Base ; end
|
||||
|
|
|
@ -8,7 +8,7 @@ module ApplicationTests
|
|||
include Rack::Test::Methods
|
||||
|
||||
def setup
|
||||
build_app(:initializers => true)
|
||||
build_app(initializers: true)
|
||||
boot_rails
|
||||
end
|
||||
|
||||
|
@ -18,7 +18,7 @@ module ApplicationTests
|
|||
|
||||
def precompile!(env = nil)
|
||||
quietly do
|
||||
precompile_task = "bundle exec rake assets:precompile #{env} 2>&1"
|
||||
precompile_task = "bundle exec rake assets:precompile #{env} --trace 2>&1"
|
||||
output = Dir.chdir(app_path) { %x[ #{precompile_task} ] }
|
||||
assert $?.success?, output
|
||||
output
|
||||
|
@ -44,7 +44,7 @@ module ApplicationTests
|
|||
|
||||
app_file 'config/routes.rb', <<-RUBY
|
||||
AppTemplate::Application.routes.draw do
|
||||
get '*path', :to => lambda { |env| [200, { "Content-Type" => "text/html" }, "Not an asset"] }
|
||||
get '*path', to: lambda { |env| [200, { "Content-Type" => "text/html" }, "Not an asset"] }
|
||||
end
|
||||
RUBY
|
||||
|
||||
|
@ -353,7 +353,7 @@ module ApplicationTests
|
|||
class ::OmgController < ActionController::Base
|
||||
def index
|
||||
flash[:cool_story] = true
|
||||
render :text => "ok"
|
||||
render text: "ok"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -56,14 +56,6 @@ module ApplicationTests
|
|||
assert_match "ActiveRecord::PendingMigrationError", last_response.body
|
||||
end
|
||||
|
||||
test "multiple queue construction is possible" do
|
||||
require 'rails'
|
||||
require "#{app_path}/config/environment"
|
||||
mail_queue = Rails.application.build_queue
|
||||
image_processing_queue = Rails.application.build_queue
|
||||
assert_not_equal mail_queue, image_processing_queue
|
||||
end
|
||||
|
||||
test "Rails.groups returns available groups" do
|
||||
require "rails"
|
||||
|
||||
|
@ -242,7 +234,7 @@ module ApplicationTests
|
|||
class ::OmgController < ActionController::Base
|
||||
def index
|
||||
cookies.signed[:some_key] = "some_value"
|
||||
render :text => env["action_dispatch.secret_token"]
|
||||
render text: env["action_dispatch.secret_token"]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -255,7 +247,7 @@ module ApplicationTests
|
|||
|
||||
class ::OmgController < ActionController::Base
|
||||
def index
|
||||
render :inline => "<%= csrf_meta_tags %>"
|
||||
render inline: "<%= csrf_meta_tags %>"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -275,11 +267,11 @@ module ApplicationTests
|
|||
app_file 'app/controllers/posts_controller.rb', <<-RUBY
|
||||
class PostsController < ApplicationController
|
||||
def show
|
||||
render :inline => "<%= begin; form_for(Post.new) {}; rescue => e; e.to_s; end %>"
|
||||
render inline: "<%= begin; form_for(Post.new) {}; rescue => e; e.to_s; end %>"
|
||||
end
|
||||
|
||||
def update
|
||||
render :text => "update"
|
||||
render text: "update"
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
|
@ -294,7 +286,7 @@ module ApplicationTests
|
|||
|
||||
token = "cf50faa3fe97702ca1ae"
|
||||
PostsController.any_instance.stubs(:form_authenticity_token).returns(token)
|
||||
params = {:authenticity_token => token}
|
||||
params = {authenticity_token: token}
|
||||
|
||||
get "/posts/1"
|
||||
assert_match(/patch/, last_response.body)
|
||||
|
@ -319,7 +311,7 @@ module ApplicationTests
|
|||
|
||||
class ::OmgController < ActionController::Base
|
||||
def index
|
||||
render :inline => "<%= csrf_meta_tags %>"
|
||||
render inline: "<%= csrf_meta_tags %>"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -481,7 +473,7 @@ module ApplicationTests
|
|||
|
||||
class ::OmgController < ActionController::Base
|
||||
def index
|
||||
render :text => env["action_dispatch.show_exceptions"]
|
||||
render text: env["action_dispatch.show_exceptions"]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -491,7 +483,7 @@ module ApplicationTests
|
|||
|
||||
test "config.action_controller.wrap_parameters is set in ActionController::Base" do
|
||||
app_file 'config/initializers/wrap_parameters.rb', <<-RUBY
|
||||
ActionController::Base.wrap_parameters :format => [:json]
|
||||
ActionController::Base.wrap_parameters format: [:json]
|
||||
RUBY
|
||||
|
||||
app_file 'app/models/post.rb', <<-RUBY
|
||||
|
@ -511,7 +503,7 @@ module ApplicationTests
|
|||
app_file 'app/controllers/posts_controller.rb', <<-RUBY
|
||||
class PostsController < ApplicationController
|
||||
def create
|
||||
render :text => params[:post].inspect
|
||||
render text: params[:post].inspect
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
|
@ -532,7 +524,7 @@ module ApplicationTests
|
|||
app_file 'app/controllers/posts_controller.rb', <<-RUBY
|
||||
class PostsController < ActionController::Base
|
||||
def create
|
||||
render :text => params[:post].permitted? ? "permitted" : "forbidden"
|
||||
render text: params[:post].permitted? ? "permitted" : "forbidden"
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
|
@ -546,7 +538,7 @@ module ApplicationTests
|
|||
|
||||
require "#{app_path}/config/environment"
|
||||
|
||||
post "/posts", {:post => {"title" =>"zomg"}}
|
||||
post "/posts", {post: {"title" =>"zomg"}}
|
||||
assert_equal 'permitted', last_response.body
|
||||
end
|
||||
|
||||
|
@ -558,8 +550,8 @@ module ApplicationTests
|
|||
class ::OmgController < ActionController::Base
|
||||
def index
|
||||
respond_to do |format|
|
||||
format.html { render :text => "HTML" }
|
||||
format.xml { render :text => "XML" }
|
||||
format.html { render text: "HTML" }
|
||||
format.xml { render text: "XML" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -567,7 +559,7 @@ module ApplicationTests
|
|||
get "/", {}, "HTTP_ACCEPT" => "application/xml"
|
||||
assert_equal 'HTML', last_response.body
|
||||
|
||||
get "/", { :format => :xml }, "HTTP_ACCEPT" => "application/xml"
|
||||
get "/", { format: :xml }, "HTTP_ACCEPT" => "application/xml"
|
||||
assert_equal 'XML', last_response.body
|
||||
end
|
||||
|
||||
|
|
|
@ -48,22 +48,22 @@ module ApplicationTests
|
|||
c.generators.orm = :data_mapper
|
||||
c.generators.test_framework = :rspec
|
||||
c.generators.helper = false
|
||||
expected = { :rails => { :orm => :data_mapper, :test_framework => :rspec, :helper => false } }
|
||||
expected = { rails: { orm: :data_mapper, test_framework: :rspec, helper: false } }
|
||||
assert_equal(expected, c.generators.options)
|
||||
end
|
||||
end
|
||||
|
||||
test "generators set rails aliases" do
|
||||
with_config do |c|
|
||||
c.generators.aliases = { :rails => { :test_framework => "-w" } }
|
||||
expected = { :rails => { :test_framework => "-w" } }
|
||||
c.generators.aliases = { rails: { test_framework: "-w" } }
|
||||
expected = { rails: { test_framework: "-w" } }
|
||||
assert_equal expected, c.generators.aliases
|
||||
end
|
||||
end
|
||||
|
||||
test "generators aliases, options, templates and fallbacks on initialization" do
|
||||
add_to_config <<-RUBY
|
||||
config.generators.rails :aliases => { :test_framework => "-w" }
|
||||
config.generators.rails aliases: { test_framework: "-w" }
|
||||
config.generators.orm :data_mapper
|
||||
config.generators.test_framework :rspec
|
||||
config.generators.fallbacks[:shoulda] = :test_unit
|
||||
|
@ -76,7 +76,7 @@ module ApplicationTests
|
|||
|
||||
assert_equal :rspec, Rails::Generators.options[:rails][:test_framework]
|
||||
assert_equal "-w", Rails::Generators.aliases[:rails][:test_framework]
|
||||
assert_equal Hash[:shoulda => :test_unit], Rails::Generators.fallbacks
|
||||
assert_equal Hash[shoulda: :test_unit], Rails::Generators.fallbacks
|
||||
assert_equal ["some/where"], Rails::Generators.templates_path
|
||||
end
|
||||
|
||||
|
@ -95,31 +95,31 @@ module ApplicationTests
|
|||
test "generators with hashes for options and aliases" do
|
||||
with_bare_config do |c|
|
||||
c.generators do |g|
|
||||
g.orm :data_mapper, :migration => false
|
||||
g.plugin :aliases => { :generator => "-g" },
|
||||
:generator => true
|
||||
g.orm :data_mapper, migration: false
|
||||
g.plugin aliases: { generator: "-g" },
|
||||
generator: true
|
||||
end
|
||||
|
||||
expected = {
|
||||
:rails => { :orm => :data_mapper },
|
||||
:plugin => { :generator => true },
|
||||
:data_mapper => { :migration => false }
|
||||
rails: { orm: :data_mapper },
|
||||
plugin: { generator: true },
|
||||
data_mapper: { migration: false }
|
||||
}
|
||||
|
||||
assert_equal expected, c.generators.options
|
||||
assert_equal({ :plugin => { :generator => "-g" } }, c.generators.aliases)
|
||||
assert_equal({ plugin: { generator: "-g" } }, c.generators.aliases)
|
||||
end
|
||||
end
|
||||
|
||||
test "generators with string and hash for options should generate symbol keys" do
|
||||
with_bare_config do |c|
|
||||
c.generators do |g|
|
||||
g.orm 'data_mapper', :migration => false
|
||||
g.orm 'data_mapper', migration: false
|
||||
end
|
||||
|
||||
expected = {
|
||||
:rails => { :orm => :data_mapper },
|
||||
:data_mapper => { :migration => false }
|
||||
rails: { orm: :data_mapper },
|
||||
data_mapper: { migration: false }
|
||||
}
|
||||
|
||||
assert_equal expected, c.generators.options
|
||||
|
|
|
@ -52,14 +52,13 @@ module ApplicationTests
|
|||
|
||||
test "uses the default queue for ActionMailer" do
|
||||
require "#{app_path}/config/environment"
|
||||
assert_kind_of ActiveSupport::QueueContainer, ActionMailer::Base.queue
|
||||
assert_kind_of ActiveSupport::Queue, ActionMailer::Base.queue
|
||||
end
|
||||
|
||||
test "allows me to configure queue for ActionMailer" do
|
||||
app_file "config/environments/development.rb", <<-RUBY
|
||||
AppTemplate::Application.configure do
|
||||
Rails.queue[:mailer] = ActiveSupport::TestQueue.new
|
||||
config.action_mailer.queue = Rails.queue[:mailer]
|
||||
config.action_mailer.queue = ActiveSupport::TestQueue.new
|
||||
end
|
||||
RUBY
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ en:
|
|||
I18n::Railtie.config.i18n.fallbacks = true
|
||||
load_app
|
||||
assert I18n.backend.class.included_modules.include?(I18n::Backend::Fallbacks)
|
||||
assert_fallbacks :de => [:de, :en]
|
||||
assert_fallbacks de: [:de, :en]
|
||||
end
|
||||
|
||||
test "config.i18n.fallbacks = true initializes I18n.fallbacks with default settings even when backend changes" do
|
||||
|
@ -151,37 +151,37 @@ en:
|
|||
I18n::Railtie.config.i18n.backend = Class.new(I18n::Backend::Simple).new
|
||||
load_app
|
||||
assert I18n.backend.class.included_modules.include?(I18n::Backend::Fallbacks)
|
||||
assert_fallbacks :de => [:de, :en]
|
||||
assert_fallbacks de: [:de, :en]
|
||||
end
|
||||
|
||||
test "config.i18n.fallbacks.defaults = [:'en-US'] initializes fallbacks with en-US as a fallback default" do
|
||||
I18n::Railtie.config.i18n.fallbacks.defaults = [:'en-US']
|
||||
load_app
|
||||
assert_fallbacks :de => [:de, :'en-US', :en]
|
||||
assert_fallbacks de: [:de, :'en-US', :en]
|
||||
end
|
||||
|
||||
test "config.i18n.fallbacks.map = { :ca => :'es-ES' } initializes fallbacks with a mapping ca => es-ES" do
|
||||
I18n::Railtie.config.i18n.fallbacks.map = { :ca => :'es-ES' }
|
||||
load_app
|
||||
assert_fallbacks :ca => [:ca, :"es-ES", :es, :en]
|
||||
assert_fallbacks ca: [:ca, :"es-ES", :es, :en]
|
||||
end
|
||||
|
||||
test "[shortcut] config.i18n.fallbacks = [:'en-US'] initializes fallbacks with en-US as a fallback default" do
|
||||
I18n::Railtie.config.i18n.fallbacks = [:'en-US']
|
||||
load_app
|
||||
assert_fallbacks :de => [:de, :'en-US', :en]
|
||||
assert_fallbacks de: [:de, :'en-US', :en]
|
||||
end
|
||||
|
||||
test "[shortcut] config.i18n.fallbacks = [{ :ca => :'es-ES' }] initializes fallbacks with a mapping de-AT => de-DE" do
|
||||
I18n::Railtie.config.i18n.fallbacks.map = { :ca => :'es-ES' }
|
||||
load_app
|
||||
assert_fallbacks :ca => [:ca, :"es-ES", :es, :en]
|
||||
assert_fallbacks ca: [:ca, :"es-ES", :es, :en]
|
||||
end
|
||||
|
||||
test "[shortcut] config.i18n.fallbacks = [:'en-US', { :ca => :'es-ES' }] initializes fallbacks with the given arguments" do
|
||||
I18n::Railtie.config.i18n.fallbacks = [:'en-US', { :ca => :'es-ES' }]
|
||||
load_app
|
||||
assert_fallbacks :ca => [:ca, :"es-ES", :es, :'en-US', :en]
|
||||
assert_fallbacks ca: [:ca, :"es-ES", :es, :'en-US', :en]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ module ApplicationTests
|
|||
ActiveRecord::Base.logger = logger
|
||||
|
||||
# Mimic Active Record notifications
|
||||
instrument "sql.active_record", :name => "SQL", :sql => "SHOW tables"
|
||||
instrument "sql.active_record", name: "SQL", sql: "SHOW tables"
|
||||
wait
|
||||
|
||||
assert_equal 1, logger.logged(:debug).size
|
||||
|
|
|
@ -19,14 +19,14 @@ class LoadingTest < ActiveSupport::TestCase
|
|||
test "constants in app are autoloaded" do
|
||||
app_file "app/models/post.rb", <<-MODEL
|
||||
class Post < ActiveRecord::Base
|
||||
validates_acceptance_of :title, :accept => "omg"
|
||||
validates_acceptance_of :title, accept: "omg"
|
||||
end
|
||||
MODEL
|
||||
|
||||
require "#{rails_root}/config/environment"
|
||||
setup_ar!
|
||||
|
||||
p = Post.create(:title => 'omg')
|
||||
p = Post.create(title: 'omg')
|
||||
assert_equal 1, Post.count
|
||||
assert_equal 'omg', p.title
|
||||
p = Post.first
|
||||
|
@ -36,7 +36,7 @@ class LoadingTest < ActiveSupport::TestCase
|
|||
test "models without table do not panic on scope definitions when loaded" do
|
||||
app_file "app/models/user.rb", <<-MODEL
|
||||
class User < ActiveRecord::Base
|
||||
default_scope where(:published => true)
|
||||
default_scope where(published: true)
|
||||
end
|
||||
MODEL
|
||||
|
||||
|
@ -76,8 +76,8 @@ class LoadingTest < ActiveSupport::TestCase
|
|||
|
||||
app_file 'config/routes.rb', <<-RUBY
|
||||
AppTemplate::Application.routes.draw do
|
||||
get '/load', :to => lambda { |env| [200, {}, Post.all] }
|
||||
get '/unload', :to => lambda { |env| [200, {}, []] }
|
||||
get '/load', to: lambda { |env| [200, {}, Post.all] }
|
||||
get '/unload', to: lambda { |env| [200, {}, []] }
|
||||
end
|
||||
RUBY
|
||||
|
||||
|
@ -106,7 +106,7 @@ class LoadingTest < ActiveSupport::TestCase
|
|||
|
||||
app_file 'config/routes.rb', <<-RUBY
|
||||
AppTemplate::Application.routes.draw do
|
||||
get '/c', :to => lambda { |env| [200, {"Content-Type" => "text/plain"}, [User.counter.to_s]] }
|
||||
get '/c', to: lambda { |env| [200, {"Content-Type" => "text/plain"}, [User.counter.to_s]] }
|
||||
end
|
||||
RUBY
|
||||
|
||||
|
@ -145,7 +145,7 @@ class LoadingTest < ActiveSupport::TestCase
|
|||
|
||||
app_file 'config/routes.rb', <<-RUBY
|
||||
AppTemplate::Application.routes.draw do
|
||||
get '/c', :to => lambda { |env| [200, {"Content-Type" => "text/plain"}, [User.counter.to_s]] }
|
||||
get '/c', to: lambda { |env| [200, {"Content-Type" => "text/plain"}, [User.counter.to_s]] }
|
||||
end
|
||||
RUBY
|
||||
|
||||
|
@ -181,7 +181,7 @@ class LoadingTest < ActiveSupport::TestCase
|
|||
app_file 'config/routes.rb', <<-RUBY
|
||||
$counter = 0
|
||||
AppTemplate::Application.routes.draw do
|
||||
get '/c', :to => lambda { |env| User; [200, {"Content-Type" => "text/plain"}, [$counter.to_s]] }
|
||||
get '/c', to: lambda { |env| User; [200, {"Content-Type" => "text/plain"}, [$counter.to_s]] }
|
||||
end
|
||||
RUBY
|
||||
|
||||
|
@ -212,8 +212,8 @@ class LoadingTest < ActiveSupport::TestCase
|
|||
|
||||
app_file 'config/routes.rb', <<-RUBY
|
||||
AppTemplate::Application.routes.draw do
|
||||
get '/title', :to => lambda { |env| [200, {"Content-Type" => "text/plain"}, [Post.new.title]] }
|
||||
get '/body', :to => lambda { |env| [200, {"Content-Type" => "text/plain"}, [Post.new.body]] }
|
||||
get '/title', to: lambda { |env| [200, {"Content-Type" => "text/plain"}, [Post.new.title]] }
|
||||
get '/body', to: lambda { |env| [200, {"Content-Type" => "text/plain"}, [Post.new.body]] }
|
||||
end
|
||||
RUBY
|
||||
|
||||
|
@ -229,7 +229,7 @@ class LoadingTest < ActiveSupport::TestCase
|
|||
class CreatePosts < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :posts do |t|
|
||||
t.string :title, :default => "TITLE"
|
||||
t.string :title, default: "TITLE"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -244,7 +244,7 @@ class LoadingTest < ActiveSupport::TestCase
|
|||
app_file "db/migrate/2_add_body_to_posts.rb", <<-MIGRATION
|
||||
class AddBodyToPosts < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :posts, :body, :text, :default => "BODY"
|
||||
add_column :posts, :body, :text, default: "BODY"
|
||||
end
|
||||
end
|
||||
MIGRATION
|
||||
|
@ -297,9 +297,9 @@ class LoadingTest < ActiveSupport::TestCase
|
|||
protected
|
||||
|
||||
def setup_ar!
|
||||
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
||||
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
|
||||
ActiveRecord::Migration.verbose = false
|
||||
ActiveRecord::Schema.define(:version => 1) do
|
||||
ActiveRecord::Schema.define(version: 1) do
|
||||
create_table :posts do |t|
|
||||
t.string :title
|
||||
end
|
||||
|
|
|
@ -19,17 +19,17 @@ module ApplicationTests
|
|||
controller :expires, <<-RUBY
|
||||
class ExpiresController < ApplicationController
|
||||
def expires_header
|
||||
expires_in 10, :public => !params[:private]
|
||||
render :text => SecureRandom.hex(16)
|
||||
expires_in 10, public: !params[:private]
|
||||
render text: SecureRandom.hex(16)
|
||||
end
|
||||
|
||||
def expires_etag
|
||||
render_conditionally(:etag => "1")
|
||||
render_conditionally(etag: "1")
|
||||
end
|
||||
|
||||
def expires_last_modified
|
||||
$last_modified ||= Time.now.utc
|
||||
render_conditionally(:last_modified => $last_modified)
|
||||
render_conditionally(last_modified: $last_modified)
|
||||
end
|
||||
|
||||
def keeps_if_modified_since
|
||||
|
@ -37,8 +37,8 @@ module ApplicationTests
|
|||
end
|
||||
private
|
||||
def render_conditionally(headers)
|
||||
if stale?(headers.merge(:public => !params[:private]))
|
||||
render :text => SecureRandom.hex(16)
|
||||
if stale?(headers.merge(public: !params[:private]))
|
||||
render text: SecureRandom.hex(16)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -96,13 +96,13 @@ module ApplicationTests
|
|||
def test_cache_works_with_expires_private
|
||||
simple_controller
|
||||
|
||||
get "/expires/expires_header", :private => true
|
||||
get "/expires/expires_header", private: true
|
||||
assert_equal "miss", last_response.headers["X-Rack-Cache"]
|
||||
assert_equal "private, max-age=10", last_response.headers["Cache-Control"]
|
||||
|
||||
body = last_response.body
|
||||
|
||||
get "/expires/expires_header", :private => true
|
||||
get "/expires/expires_header", private: true
|
||||
assert_equal "miss", last_response.headers["X-Rack-Cache"]
|
||||
assert_not_equal body, last_response.body
|
||||
end
|
||||
|
@ -125,14 +125,14 @@ module ApplicationTests
|
|||
def test_cache_works_with_etags_private
|
||||
simple_controller
|
||||
|
||||
get "/expires/expires_etag", :private => true
|
||||
get "/expires/expires_etag", private: true
|
||||
assert_equal "miss", last_response.headers["X-Rack-Cache"]
|
||||
assert_equal "must-revalidate, private, max-age=0", last_response.headers["Cache-Control"]
|
||||
|
||||
body = last_response.body
|
||||
etag = last_response.headers["ETag"]
|
||||
|
||||
get "/expires/expires_etag", {:private => true}, "If-None-Match" => etag
|
||||
get "/expires/expires_etag", {private: true}, "If-None-Match" => etag
|
||||
assert_equal "miss", last_response.headers["X-Rack-Cache"]
|
||||
assert_not_equal body, last_response.body
|
||||
end
|
||||
|
@ -155,14 +155,14 @@ module ApplicationTests
|
|||
def test_cache_works_with_last_modified_private
|
||||
simple_controller
|
||||
|
||||
get "/expires/expires_last_modified", :private => true
|
||||
get "/expires/expires_last_modified", private: true
|
||||
assert_equal "miss", last_response.headers["X-Rack-Cache"]
|
||||
assert_equal "must-revalidate, private, max-age=0", last_response.headers["Cache-Control"]
|
||||
|
||||
body = last_response.body
|
||||
last = last_response.headers["Last-Modified"]
|
||||
|
||||
get "/expires/expires_last_modified", {:private => true}, "If-Modified-Since" => last
|
||||
get "/expires/expires_last_modified", {private: true}, "If-Modified-Since" => last
|
||||
assert_equal "miss", last_response.headers["X-Rack-Cache"]
|
||||
assert_not_equal body, last_response.body
|
||||
end
|
||||
|
|
|
@ -36,7 +36,7 @@ module ApplicationTests
|
|||
flash[:notice] = "notice"
|
||||
end
|
||||
|
||||
render :nothing => true
|
||||
render nothing: true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -81,10 +81,10 @@ module ApplicationTests
|
|||
|
||||
test "ActionDispatch::SSL is configured with options when given" do
|
||||
add_to_config "config.force_ssl = true"
|
||||
add_to_config "config.ssl_options = { :host => 'example.com' }"
|
||||
add_to_config "config.ssl_options = { host: 'example.com' }"
|
||||
boot!
|
||||
|
||||
assert_equal AppTemplate::Application.middleware.first.args, [{:host => 'example.com'}]
|
||||
assert_equal AppTemplate::Application.middleware.first.args, [{host: 'example.com'}]
|
||||
end
|
||||
|
||||
test "removing Active Record omits its middleware" do
|
||||
|
@ -169,9 +169,9 @@ module ApplicationTests
|
|||
class ::OmgController < ActionController::Base
|
||||
def index
|
||||
if params[:nothing]
|
||||
render :text => ""
|
||||
render text: ""
|
||||
else
|
||||
render :text => "OMG"
|
||||
render text: "OMG"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue