Compare commits

..

1352 Commits

Author SHA1 Message Date
Charlie Somerville
b29a709afd cve-2014-0130 2014-05-12 10:55:01 +10:00
Charlie Somerville
29c0decb37 Merge pull request #66 from github/3-0-github-perf
Bring a few perf patches to 3-0-github from 2-3-github
2014-05-01 19:25:13 +10:00
Charlie Somerville
d1b7819eed short-circuit String#blank? if empty 2014-05-01 18:09:13 +10:00
Charlie Somerville
b22e96751d use faster regex for String#blank?
Calculating -------------------------------------
              before      2687 i/100ms
               after      3867 i/100ms
-------------------------------------------------
              before    27978.4 (±2.0%) i/s -     142411 in   5.092192s
               after    40533.0 (±2.8%) i/s -     204951 in   5.060652s
2014-05-01 18:05:11 +10:00
Charlie Somerville
68528d9c0e avoid html_safe? method call 2014-05-01 18:02:09 +10:00
Charlie Somerville
c9561099cd apply the newlines pending patch 2014-05-01 17:55:12 +10:00
Charlie Somerville
7d14c436ba Merge pull request #65 from github/3-0-github+faster-attr-lookup
[3.0] Faster attr lookup
2014-04-29 19:57:15 +10:00
Charlie Somerville
1aed8fbf40 don't bother checking for respond_to? here 2014-04-29 19:06:19 +10:00
Charlie Somerville
cab18f1607 allocate less objects 2014-04-29 19:06:19 +10:00
Charlie Somerville
7a04473603 Fewer object allocations
Conflicts:
	activemodel/lib/active_model/attribute_methods.rb
2014-04-29 19:06:19 +10:00
Charlie Somerville
e6fab3aba1 Cheaper attribute_method_matchers
Conflicts:
	activemodel/lib/active_model/attribute_methods.rb
2014-04-29 19:06:19 +10:00
Jeremy Kemper
3f0f6047ab Fix require for class_attribute 2014-04-29 19:06:19 +10:00
Charlie Somerville
5bfa1a0eb4 Merge pull request #62 from github/3-0-github+has_many-count-with-distinct
Fix weird unique has_many count bug we're seeing
2014-04-24 17:11:05 +10:00
Charlie Somerville
67709ccc58 properly set distinct if select_values starts with DISTINCT 2014-04-23 20:05:00 +10:00
Charlie Somerville
fd102d2987 add failing test for weird has_many :uniq count bug we're seeing 2014-04-23 18:19:25 +10:00
Charlie Somerville
494fc9ea8a fix flakey logger test 2014-04-11 16:37:54 +10:00
Charlie Somerville
de6c5564e4 check in Gemfile.lock 2014-04-11 16:35:06 +10:00
Charlie Somerville
3542d3d623 delegate pluck to scoped
cc @rsanheim
2014-04-10 17:20:30 +10:00
Charlie Somerville
b714de3f2b Merge pull request #55 from github/3-0-github+pluck
Backport pluck to 3-0-github
2014-04-10 15:58:34 +10:00
Charlie Somerville
3cf7ccde48 backport pluck to 3-0-github 2014-04-10 15:52:38 +10:00
Dirkjan Bussink
ad50d74a13 Merge pull request #54 from github/dbussink/bump-rails30-exception
Don't rescue toplevel Exception
2014-04-02 12:40:54 +00:00
Dirkjan Bussink
117dc4a85a Don't rescue toplevel Exception 2014-03-31 13:46:20 +02:00
Charlie Somerville
be36d0222b Merge pull request #52 from github/3-0-github-byteslice-cache
Use byteslice instead of slice in fragment_for
2014-03-31 19:15:33 +11:00
Charlie Somerville
1064e75c63 use byteslice instead of slice in fragment_for 2014-03-31 19:11:18 +11:00
Charlie Somerville
787f31dd95 Merge pull request #50 from github/3-0-github+ci
Run tests for 3-0-github in CI
2014-03-31 14:08:42 +11:00
Charlie Somerville
063f7ec6d9 delete debugging code 2014-03-20 13:48:55 +11:00
Charlie Somerville
512cc3fde1 in fact forget the railties tests 2014-03-20 13:44:04 +11:00
Charlie Somerville
a544354455 just test on sqlite3 2014-03-19 23:18:55 +11:00
Charlie Somerville
f973bd7a37 god rails is a shit show 2014-03-19 23:16:26 +11:00
Charlie Somerville
eedf2e0df5 add some skips and small tweaks to get tests passing 2014-03-19 22:57:30 +11:00
Charlie Somerville
478459b602 fix activesupport tests 2014-03-19 21:54:45 +11:00
Charlie Somerville
8405a07588 fix actionmailer tests 2014-03-19 21:42:36 +11:00
Charlie Somerville
8069888f39 some respond_to? fixes 2014-03-19 21:28:37 +11:00
Charlie Somerville
0d1e06e91a don't pass nil elements into Hash[] 2014-03-19 21:28:25 +11:00
Charlie Somerville
b7fdf446b3 raise on respond_to changes 2014-03-19 21:11:52 +11:00
Charlie Somerville
6a5c4448bf respond_to? 2014-03-19 21:11:45 +11:00
Charlie Somerville
7824f7fe96 respond_to? fix 2014-03-19 20:13:22 +11:00
Charlie Somerville
cc24b24b00 nil is now encoded as <blah nil="true"/> 2014-03-19 19:55:22 +11:00
Charlie Somerville
997fe9a94e fix for ruby 2.0+ respond_to? changes 2014-03-19 19:54:35 +11:00
Charlie Somerville
9527562a4a add pry to gemfile to aid debugging 2014-03-19 19:54:11 +11:00
Charlie Somerville
db8c48caf7 add magic encoding comments to files with dodgy chars 2014-03-19 19:14:34 +11:00
Charlie Somerville
60eb2e5586 delete troublesome platforms 2014-03-19 19:08:56 +11:00
Charlie Somerville
12b11ea207 announce what ruby version we're running 2014-03-19 19:07:46 +11:00
Charlie Somerville
0d0a061f27 add script/cibuild 2014-03-19 19:02:21 +11:00
Charlie Somerville
66f4a900c6 vendor gems 2014-03-19 19:00:48 +11:00
Charlie Somerville
5f31e732ce Merge pull request #49 from github/3-0-kill-backtick-monkey-patch
[3.0] Kill Object#` monkey patch
2014-02-23 23:20:55 +11:00
Charlie Somerville
04f3d5048e kill Object#` monkey patch 2014-02-23 23:19:13 +11:00
Aman Gupta
bfe82ff609 add RouteSet#recognize_path(path, :extras => params) for forward-compat with rails4 2014-02-17 18:42:50 -08:00
Charlie Somerville
5ce29715d5 backport rails 3.2 ActiveSupport::MessageVerifier 2014-02-07 11:31:09 +11:00
Charlie Somerville
ec4d0a393c use builder ~> 3.2.0 2014-02-04 22:12:35 +11:00
Aman Gupta
0be816038d skip nil relative_url_root 2014-01-14 01:53:36 -08:00
Aman Gupta
aba13cc14a ruby2 compat 2014-01-10 12:15:38 -08:00
Aman Gupta
bab6d7dc71 loosen mail dep 2014-01-10 11:35:15 -08:00
Aman Gupta
dc8dc40b43 loosen thor dep 2014-01-10 11:32:06 -08:00
Aman Gupta
346b254f05 fix layout assertions 2013-03-06 02:35:18 -08:00
Aman Gupta
9bb043d718 Merge remote-tracking branch 'upstream/3-0-stable' into 3-0-github 2013-03-05 19:00:12 -08:00
Steve Klabnik
9fdd56c515 Revert "Merge pull request #9210 from dylanahsmith/3-0-mysql-quote-numeric"
This reverts commit 663c9a6335, reversing
changes made to 10513d2eb9.
2013-02-27 08:31:29 -08:00
Aaron Patterson
f2839f1dba Revert "Merge pull request #9126 from mbarb0sa/bugfix/json-decoding-in-rails-3-0-stable"
This reverts commit 360af4eba6, reversing
changes made to f93d046770.
2013-02-11 14:19:19 -08:00
Aaron Patterson
182d4e3719 Merge branch '3-0-sec' into 3-0-stable
* 3-0-sec:
  fix serialization vulnerability
  Fix issue with attr_protected where malformed input could circumvent protection
2013-02-11 10:19:54 -08:00
Aaron Patterson
360af4eba6 Merge pull request #9126 from mbarb0sa/bugfix/json-decoding-in-rails-3-0-stable
fixed failing JSON decoding in rails 3-0-stable
2013-02-11 09:21:36 -08:00
Tobias Kraze
073d5a6137 fix serialization vulnerability 2013-02-10 19:09:00 -08:00
joernchen of Phenoelit
2dfd51247f Fix issue with attr_protected where malformed input could circumvent
protection

Fixes: CVE-2013-0276

Conflicts:
	activemodel/lib/active_model/attribute_methods.rb
	activerecord/test/cases/mass_assignment_security_test.rb
2013-02-09 15:56:49 -08:00
Guillermo Iguaran
f93d046770 Merge pull request #9223 from robertomiranda/fix-bigdecimal-typecast
Fix BigDecimal Typecast on 1.8.7
2013-02-08 06:34:37 -08:00
robertomiranda
a316c09900 Fix BigDecimal Typecast on 1.8.7 2013-02-08 09:27:53 -05:00
Guillermo Iguaran
663c9a6335 Merge pull request #9210 from dylanahsmith/3-0-mysql-quote-numeric
[3.0] active_record: Quote numeric values compared to string columns.
2013-02-07 18:45:12 -08:00
Dylan Smith
b4be619650 mysql2 adapter fixed upstream to delegate quoting of BigDecimal. 2013-02-07 14:31:16 -05:00
Dylan Smith
0fc58caf18 active_record: Quote numeric values compared to string columns. 2013-02-07 04:55:28 -05:00
Michel Barbosa
fdc42ad834 fixed failing JSON decoding in rails 3-0-stable 2013-01-30 23:48:59 +01:00
Aaron Patterson
10513d2eb9 Merge pull request #9111 from jsomara/3-0-json-fix
Fix #8832 - Parse '{"person":[]}' JSON/XML as {'person' => []}.
2013-01-30 11:07:25 -08:00
Carlos Antonio da Silva
20c3b4b751 Merge pull request #9123 from renatosnrg/3-0-stable
Fixing encoding to UTF-8 for OkJson backend. Closes #9122.
2013-01-30 07:45:57 -08:00
Renato Neves
d46c6aaf86 Fixing encoding to UTF-8 for OkJson backend 2013-01-30 13:24:01 -02:00
Nathan Broadbent
f20b598826 Fix #8832 - Parse '{"person":[]}' JSON/XML as {'person' => []}. 2013-01-29 11:59:29 -05:00
Aaron Patterson
b875be03b5 bumping to 3.0.20 2013-01-28 12:47:48 -08:00
Michael Koziarski
5375dce1ac Add an OkJson backend and remove the YAML backend
Fixes CVE-2013-0333.  The ActiveSupport::JSON::Backends::Yaml class is present but the functionality has been removed entirely.
2013-01-28 12:46:57 -08:00
Carlos Antonio da Silva
709fbd3f32 Fix failing test related to escaping include_blank in select_tag
Rails 3.0.x doesn't have the :prompt option in select_tag, it was
introduced in c5d54be746 that is only
available from 3.1.x on.

The test and related fix were introduced in
c9795871ba for Rails 3.0.17, as a fix for
a security vulnerability. The code is completely fine but the test was
using the invalid :prompt option for this version, probably because it
was cherry-picked from other branch which has the option.
2013-01-26 22:12:48 -02:00
Carlos Antonio da Silva
e8ac985fe0 Remove obsolete rake/rdoctask require
Requiring this now raises a RuntimeError, failing the test.
It also seems that the require is unnecessary to pass the test.
2013-01-26 20:12:43 -02:00
Carlos Antonio da Silva
597a70014e Update failing tests overriding destroy method instead of using mocha expectation
Mocha by default does not allow adding expectation to frozen objects,
just applying a workaround to ensure the method is never called, making
the tests pass without enabling this again in mocha.
2013-01-26 20:07:22 -02:00
kennyj
bb80a875da Fix build. It seems that the Mocha's behavior were changed. 2013-01-26 19:58:25 -02:00
dmathieu
18bce295c2 remove the warning when testing whiny_nil 2013-01-26 19:56:41 -02:00
Carlos Antonio da Silva
dd3caf6477 Fix indentation to remove warning 2013-01-26 19:56:10 -02:00
Carlos Antonio da Silva
ba6b243b61 Remove not used variable warning 2013-01-26 19:55:11 -02:00
Carlos Antonio da Silva
871a7dbb44 Update mocha version to 0.13.0 and change requires 2013-01-26 19:36:12 -02:00
Rafael Mendonça França
d116e902c9 Merge pull request #8872 from freerange/3-0-stable-with-mocha-fixes
Fix 3-0-stable to work with Mocha >= v0.13.0
2013-01-16 05:39:30 -08:00
James Mead
bf91545967 Fix 3-0-stable to work with Mocha >= v0.13.0
A) Update code in ActiveSupport which monkey-patches Test::Unit to
include Mocha bug fix.

A bug was fixed [1] in Mocha's integration with Test::Unit, but this
monkey-patching code was copied before the fix. We need to copy the
fixed version.

The bug meant that an unexpected invocation against a mock within the
teardown method caused a test *error* and not a test *failure*.

B) Fix for Test::Unit/Mocha compatibility.

Mocha is now using a single AssertionCounter which needs a reference to
the testcase as opposed to the result.

This change is an unfortunate consequence of the copying of a chunk of
Mocha's internal code in order to monkey-patch Test::Unit.

C) Avoid a Mocha deprecation warning.

[1]
f1ff6475ca (diff-5)
commit 0591f6d1e0b4768877559f85394947f94565fabf 1 parent 8b3109a441
2013-01-16 13:32:34 +00:00
Andrew White
4c525b2fc9 Remove unnecessary caching of ParameterFilter 2013-01-12 02:04:10 +00:00
Jeremy Kemper
9bc2b0904b Merge pull request #8890 from dylanahsmith/3-0-parse-non-object-json-params
3-0-stable: Fix JSON params parsing regression for non-object JSON content.
2013-01-10 22:54:23 -08:00
Dylan Smith
eede4ab852 Fix JSON params parsing regression for non-object JSON content.
Backports #8855.
2013-01-11 00:37:18 -05:00
Carlos Antonio da Silva
e5f4a397ed Update changelogs with release dates and minor improvements [ci skip] 2013-01-09 22:06:21 -02:00
Carlos Antonio da Silva
583e5fd208 Merge pull request #8853 from zmoazeni/3-0-xml-serialization-fix
Methods that return nil should not be considered YAML
2013-01-09 15:23:38 -08:00
Zach Moazeni
477f0e7981 Methods that return nil should not be considered YAML
This is a direct port of @jaw6's pull request
https://github.com/rails/rails/pull/492. His cleanly applied to Rails
v3.1 and v3.2, and this cleanly applies to v3.0.

With yesterday's security patches
http://weblog.rubyonrails.org/2013/1/8/Rails-3-2-11-3-1-10-3-0-19-and-2-3-15-have-been-released/
there is now an issue with Rails v3.0 serving XML to any of the latest
versions of ActiveResource.

Without this, Rails v3.0 can serve XML to ActiveResource consumers that
will see `Hash::DisallowedType: Disallowed type attribute: "yaml"`
2013-01-09 17:34:43 -05:00
Carlos Antonio da Silva
ca8b0bd0e0 Merge pull request #8836 from sikachu/3-0-stable-fix-ars
Remove test for XML YAML parsing
2013-01-08 17:09:21 -08:00
Prem Sichanugrist
f252755885 Remove test for XML YAML parsing
The support for YAML parsing in XML has been removed from Active Support
since it introduced an security risk. See a494824 for more detail.
2013-01-08 19:54:25 -05:00
Aaron Patterson
7909e7f10c bumping version 2013-01-08 11:13:57 -08:00
Jeremy Kemper
a494824efc CVE-2013-0156: Safe XML params parsing. Doesn't allow symbols or yaml. 2013-01-08 11:13:46 -08:00
Aaron Patterson
97b3b68d3a * Strip nils from collections on JSON and XML posts. [CVE-2013-0155] * dealing with empty hashes. Thanks Damien Mathieu
Conflicts:
	actionpack/CHANGELOG.md
	activerecord/CHANGELOG.md

Conflicts:
	actionpack/CHANGELOG.md
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/relation/predicate_builder.rb
2013-01-08 11:13:07 -08:00
Aaron Patterson
fb06fe48ef bumping to 3.0.18 2012-12-23 14:30:59 -08:00
Aaron Patterson
3542641ebd CVE-2012-5664 options hashes should only be extracted if there are extra parameters 2012-12-23 11:34:42 -08:00
Aaron Patterson
826548b80a updating changelogs 2012-12-23 11:30:36 -08:00
Aman Gupta
46bea10a72 Silence router dsl deprecation warning 2012-09-30 14:09:46 -10:00
Aman Gupta
351747b6c5 Silence constant redefinition warnings 2012-09-30 14:08:05 -10:00
Rafael Mendonça França
f93e3f0ec3 Remove warning when using html_escape with Ruby 1.9.
Closes #7430
2012-08-28 09:43:20 -03:00
Santiago Pastorino
954e262636 Merge pull request #7308 from amerine/3-0-stable
Add html_escape note to CHANGELOG
2012-08-09 16:57:30 -07:00
Mark Turner
cf6bb2a4ac Add html_escape note to CHANGELOG 2012-08-09 16:47:05 -07:00
Santiago Pastorino
77977f34a5 Bump to 3.0.17 2012-08-09 16:17:08 -03:00
Santiago Pastorino
6eda26a238 Add CHANGELOG entries 2012-08-09 16:09:22 -03:00
Santiago Pastorino
1151959f97 Do not mark strip_tags result as html_safe
Thanks to Marek Labos & Nethemba

CVE-2012-3465
2012-08-09 15:55:40 -03:00
Santiago Pastorino
c9795871ba escape select_tag :prompt values
CVE-2012-3463
2012-08-09 15:43:23 -03:00
Rafael Mendonça França
9ef905f198 Fix tests about single quote escaping 2012-08-07 22:38:40 -03:00
Santiago Pastorino
780a718723 html_escape should escape single quotes
https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content
Closes #7215

Conflicts:
	actionpack/test/controller/new_base/render_template_test.rb
	actionpack/test/template/asset_tag_helper_test.rb
	actionpack/test/template/erb_util_test.rb
	actionpack/test/template/javascript_helper_test.rb
	actionpack/test/template/template_test.rb
	activesupport/lib/active_support/core_ext/string/output_safety.rb
	activesupport/test/core_ext/string_ext_test.rb
	railties/test/application/assets_test.rb
2012-08-07 17:12:09 -07:00
Aman Gupta
b1cc85b7ab handle rails2 router subdomain conditions 2012-08-05 11:34:25 -07:00
Andrew White
f07c708579 Backport of fix from #5173 - fixes #7252
Rather than use the MySQL specific TINYTEXT, MEDIUMTEXT and LONGTEXT
datatypes, Active Record migrations use TEXT(n) where n is the limit
specified by the developer. Unfortunately how MySQL interprets n
depends on the column's encoding so any limit above 5592405 will be
interpreted as a LONGTEXT when the encoding is UTF-8.

This commit fixes this by interpreting the limit within the adapter
and using the specific MySQL datatype as appropriate.
2012-08-04 08:21:54 +01:00
Aman Gupta
7e8b4f108b upgrade gem requirements 2012-08-02 18:57:18 -07:00
Aaron Patterson
3166606dcb bumping to 3.0.16 2012-07-26 14:59:39 -07:00
Aaron Patterson
4a0370b6b8 updating release date 2012-07-26 14:57:45 -07:00
Aaron Patterson
fe48ad33cf updating changelog with CVE 2012-07-26 13:32:58 -07:00
Aaron Patterson
b88cc8aa31 * Do not convert digest auth strings to symbols. CVE-2012-3424 2012-07-26 13:32:23 -07:00
Aaron Patterson
32b4cbc856 updating changelogs 2012-07-23 14:38:48 -07:00
Aaron Patterson
def75432c9 3.0.15 2012-06-12 20:05:46 -07:00
Aaron Patterson
a5a0338b9b we haven't monkey patched the Result class, so use each 2012-06-12 17:05:57 -07:00
Aaron Patterson
4be9dbff20 updating changelogs 2012-06-12 14:05:21 -07:00
Aaron Patterson
3fb762a9fa bumping to 3.0.14 2012-06-11 16:08:58 -07:00
Aaron Patterson
8cecac7632 updating changelogs with security fixes 2012-06-11 16:07:42 -07:00
Aaron Patterson
2c959633f7 bumping versions in the CHANGELOG 2012-06-11 16:02:50 -07:00
Aaron Patterson
b9e048c7fb Merge branch '3-0-stable-sec' into 3-0-stable-rel
* 3-0-stable-sec:
  Array parameters should not contain nil values.
  Additional fix for CVE-2012-2661
2012-06-11 15:56:53 -07:00
kennyj
6c0c40be4b Fix GH #3163. Should quote database on mysql/mysql2.
Conflicts:

	activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb

Conflicts:

	activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
	activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb

Conflicts:

	activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
	activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
	activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb
	activerecord/test/cases/adapters/mysql2/schema_test.rb
2012-06-11 15:54:50 -07:00
Aaron Patterson
2f3bc04673 Array parameters should not contain nil values. 2012-06-10 22:47:08 -05:00
Ernie Miller
176af7eff2 Additional fix for CVE-2012-2661
While the patched PredicateBuilder in 3.0.13 prevents a user
from specifying a table name using the `table.column` format,
it doesn't protect against the nesting of hashes changing the
table context in the next call to build_from_hash. This fix
covers this case as well.
2012-06-08 17:27:52 -05:00
Aaron Patterson
b2feff233e Merge branch '3-0-rel' into 3-0-stable
* 3-0-rel:
  bumping to 3.0.13
  updating CHANGELOGs
  bumping to 3.0.13.rc1
2012-05-31 11:26:25 -07:00
Aaron Patterson
33f8e4bd2d Merge branch '3-0-stable-sec' into 3-0-stable
* 3-0-stable-sec:
  Strip [nil] from parameters hash. Thanks to Ben Murphy for reporting this!
  predicate builder should not recurse for determining where columns. Thanks to Ben Murphy for reporting this
2012-05-31 11:26:16 -07:00
Aaron Patterson
7102fe8d44 bumping to 3.0.13 2012-05-31 10:55:00 -07:00
Aaron Patterson
86c97e1af3 updating CHANGELOGs 2012-05-31 10:54:26 -07:00
Aaron Patterson
c8af45ec6a Merge branch '3-0-stable-sec' into 3-0-rel
* 3-0-stable-sec:
  Strip [nil] from parameters hash. Thanks to Ben Murphy for reporting this!
  predicate builder should not recurse for determining where columns. Thanks to Ben Murphy for reporting this
2012-05-31 10:43:19 -07:00
Aaron Patterson
c202638225 Strip [nil] from parameters hash.
Thanks to Ben Murphy for reporting this!

CVE-2012-2660

Conflicts:

	actionpack/lib/action_dispatch/http/request.rb
2012-05-30 15:24:21 -07:00
Aaron Patterson
99f030934e predicate builder should not recurse for determining where columns.
Thanks to Ben Murphy for reporting this

CVE-2012-2661
2012-05-30 15:06:12 -07:00
Aaron Patterson
88e7f5176c bumping to 3.0.13.rc1 2012-05-28 11:48:02 -07:00
Rafael Mendonça França
349fce26e3 Remove test for not accepted protocols to auto_link 2012-05-26 22:53:17 -03:00
Rafael Mendonça França
5989ffbe03 Merge pull request #6495 from homakov/3-0-stable
auto_link shouldn't always sanitize
2012-05-26 09:25:51 -07:00
homakov
f35c93f4b1 do not force sanitize and whitelist protocols for auto_link
sanitize is not always required so we cannot make it. let's just
whitelist protocols
2012-05-26 11:25:07 +04:00
Aaron Patterson
f7cf745e8e Merge pull request #6485 from homakov/3-0-stable
auto_link sanitize output
2012-05-25 10:31:24 -07:00
homakov
3af33856d7 auto_link final sanitize 2012-05-25 11:06:22 +04:00
Andrew White
e74e479529 Lock mocha gem to fix the build
New versions of mocha don't allow nil.stubs
2012-04-30 21:52:39 +01:00
Yehuda Katz
51582feb03 Merge pull request #5044 from dracco/3-0-stable
Backport Bugfix: Stack Overflow (3-0-stable)
2012-04-30 09:16:25 -07:00
Jeremy Kemper
f47a303c39 Merge pull request #5659 from carlosantoniodasilva/fix-build-3-0
Fix build for branch 3-0-stable - ARes and ordered hash keys
2012-03-29 16:34:36 -07:00
Carlos Antonio da Silva
d44ffb2bd5 Fix failing ARes test due to hash keys ordering 2012-03-29 19:49:49 -03:00
Santiago Pastorino
72dc7ae95e Merge pull request #5655 from yahonda/address_ora_00918_with_oracle_for_3_0
Address an error for test_has_many_through_polymorphic_has_one with Oracle
2012-03-29 13:11:10 -07:00
Yasuo Honda
60272ae5a6 Address an error for test_has_many_through_polymorphic_has_one
with Oracle for the 3-0-stable branch
2012-03-29 07:38:44 -04:00
Aaron Patterson
29320dc27c Merge pull request #5613 from carlosantoniodasilva/fix-build-3-0-193
Fix build for branch 3-0-stable - Ruby 1.9.3
2012-03-27 16:23:00 -07:00
José Valim
e0362f71c4 Avoid inspecting the whole route set, closes #1525 2012-03-27 19:58:37 +02:00
Arun Agrawal
4c9dec4f2b Fix broken encoding test 2012-03-27 09:19:14 -03:00
Aaron Patterson
289fe762d2 load the encoding converter to work around [ruby-core:41556] when switching encodings 2012-03-27 09:19:02 -03:00
Emilio Tagua
caebe85ed2 Use helper method here. 2012-03-27 09:18:56 -03:00
Emilio Tagua
923ba31657 Silence warnings here, only setting Encoding.default_external for testing. 2012-03-27 09:17:46 -03:00
José Valim
5790269af9 Merge pull request #5600 from carlosantoniodasilva/fix-build-3-0
Fix build for branch 3-0-stable - failing in ruby 1.8.8-p358
2012-03-27 00:58:09 -07:00
Aaron Patterson
3627cfab7e Merge pull request #2621 from icco/master
Issue with schema dump
2012-03-26 17:26:50 -07:00
Carlos Antonio da Silva
9698312704 Fix AV::FixtureResolver and rjs tests with random order errors
Due to the hash ordering changes on Ruby 1.8.7-p358.
2012-03-26 19:40:40 -03:00
Arun Agrawal
00726ea75a Build fix for form_options_helper_test.rb ruby-1.8.7 2012-03-24 11:49:04 -03:00
José Valim
728a65d2df Merge pull request #5565 from carlosantoniodasilva/fix-build-3-0
Fix build for branch 3-0-stable
2012-03-23 11:29:03 -07:00
Carlos Antonio da Silva
f748d36b40 Fix more failing tests related to ruby 1.8.7 p358 version change 2012-03-22 23:47:22 -03:00
Carlos Antonio da Silva
a9fdefd206 Add order to tests that rely on db ordering, to fix failing tests on pg
Also skip persistente tests related to UPDATE + ORDER BY for postgresql

PostgreSQL does not support updates with order by, and these tests are
failing randomly depending on the fixture loading order now.

Conflicts:

	activerecord/test/cases/associations/join_model_test.rb
	activerecord/test/cases/associations/nested_through_associations_test.rb
	activerecord/test/cases/clone_test.rb
	activerecord/test/cases/dup_test.rb
	activerecord/test/cases/relations_test.rb
	activerecord/test/cases/yaml_serialization_test.rb
2012-03-22 22:43:28 -03:00
Aaron Patterson
8645745d5f Merge pull request #5457 from brianmario/typo-fix
Fix typo in redirect test
2012-03-15 15:23:18 -07:00
Aaron Patterson
d14319cb2e Merge pull request #5456 from brianmario/redirect-sanitization
Strip null bytes from Location header
Conflicts:

	actionpack/test/controller/redirect_test.rb
2012-03-15 15:07:18 -07:00
Santiago Pastorino
61335d689a Merge pull request #5319 from arunagw/fix_test_ree
Fix test ree 3-0-stable
2012-03-07 11:42:17 -08:00
Arun Agrawal
f8f873a5d3 fixed test when running with latest 1.8.7-p357 and ree 2012-03-07 17:05:19 +05:30
Carlos Antonio da Silva
f1c6037aac Stop SafeBuffer#clone_empty from issuing warnings
Logic in clone_empty method was dealing with old @dirty variable, which
has changed by @html_safe in this commit:
139963c99a

This was issuing a "not initialized variable" warning - related to:
https://github.com/rails/rails/pull/5237

The logic applied by this method is already handled by the [] override,
so there is no need to reset the variable here.
2012-03-02 19:08:39 +01:00
Aaron Patterson
eeb715add2 Merge branch '3-0-12' into 3-0-stable
* 3-0-12:
  bumping to 3.0.12
  Ensure [] respects the status of the buffer.
  updating RAILS_VERSION
  use AS::SafeBuffer#clone_empty for flushing the output_buffer
  add AS::SafeBuffer#clone_empty
  fix output safety issue with select options
2012-03-01 09:50:37 -08:00
Aaron Patterson
9d6377ed73 bumping to 3.0.12 2012-03-01 09:22:25 -08:00
Aaron Patterson
9435f5a479 Merge branch '3-0-stable-security' into 3-0-12
* 3-0-stable-security:
  Ensure [] respects the status of the buffer.
  use AS::SafeBuffer#clone_empty for flushing the output_buffer
  add AS::SafeBuffer#clone_empty
  fix output safety issue with select options
2012-03-01 09:21:05 -08:00
José Valim
917fd1a038 Ensure [] respects the status of the buffer. 2012-02-29 16:25:56 -08:00
Noah Hendrix
c4f92646ea Fixed typo in composed_of example with Money#<=>, was comparing amount itself instead of other_money.amount 2012-02-25 21:58:27 +05:30
Aaron Patterson
2935435d70 updating RAILS_VERSION 2012-02-22 13:31:26 -08:00
Jon Leighton
67b6847e09 Merge commit 'v3.0.11' into 3-0-stable 2012-02-22 20:20:29 +00:00
Akira Matsuda
6adc417890 use AS::SafeBuffer#clone_empty for flushing the output_buffer 2012-02-20 16:27:50 -08:00
Akira Matsuda
e50ee96a0b add AS::SafeBuffer#clone_empty 2012-02-20 16:27:45 -08:00
Sergey Nartimov
5b4082fddf fix output safety issue with select options 2012-02-20 15:52:15 -08:00
Andy Pliszka
389d1c5b65 Test for circular reference while saving has_one relationship 2012-02-16 00:46:23 -05:00
Andy Pliszka
a97cf753a1 Bugfix circular reference while saving has_one relationship 2012-02-15 00:52:59 -05:00
Aaron Patterson
c67ff97ec3 Merge pull request #4514 from brainopia/update_timezone_offets
Update time zone offset information
2012-01-24 11:18:06 -08:00
José Valim
d4c26c4650 Merge pull request #4372 from arunagw/fixed_failing_test
Fixed failing test
2012-01-06 23:37:31 -08:00
Arun Agrawal
91a9b24417 Fixed failing test for ruby-1.8.7-p357
See #4292
2012-01-07 10:45:03 +05:30
José Valim
a048568b8d Merge pull request #4246 from amatsuda/hashdos_30
bump up rack version to the one that includes the Hash DoS fix
2011-12-31 05:09:23 -08:00
Akira Matsuda
7e03b9dc9b bump up rack version to the one that includes the Hash DoS fix 2011-12-31 21:33:29 +09:00
Santiago Pastorino
ce650ee478 Merge pull request #4031 from arunagw/3-0-stable
3 0 stable travis sync
2011-12-20 03:54:50 -08:00
Jon Leighton
ab05e2b52a Don't notify campfire when the build keeps passing 2011-12-19 23:25:19 +05:30
Jon Leighton
b7e45c3a81 Prefix newly added method to avoid breakings people's apps.
See
378ce0e89c

Fixes #3921.
2011-12-18 18:01:10 +00:00
José Valim
ad9a0e32e6 Update .travis.yml 2011-12-17 17:44:42 +01:00
Santiago Pastorino
10c8e8df68 Sync .travis.yml with master 2011-12-17 13:08:51 -02:00
Jon Leighton
51dcf85a8c Enable postgres on the CI ❤️ 🍺
Conflicts:

	Gemfile
2011-12-03 20:25:16 +00:00
Aaron Patterson
36b6c52f9c Merge pull request #3846 from sumbach/backport-load-and-require-fixes-to-3-0
Backport load and require fixes to 3 0
2011-12-03 11:24:27 -08:00
Aaron Patterson
cc3fb2e1c5 load should also return the value from super 2011-12-03 13:15:10 -05:00
Aaron Patterson
8fabf78708 require needs to return true or false. thank you Ryan "zenspider" Davis 2011-12-03 13:15:10 -05:00
Sam Umbach
289ae94b67 Simplify load and require tests
- These tests don't use autoloading so there's no need to add anything to autoload_paths
2011-12-03 13:15:10 -05:00
Sam Umbach
0531e26daa Test that require and load raise LoadError if file not found 2011-12-03 13:15:10 -05:00
Sam Umbach
9effced47f Test return value of ActiveSupport::Dependencies::Loadable#load 2011-12-03 13:15:10 -05:00
Sam Umbach
dea2e9cde6 Test return value of ActiveSupport::Dependencies::Loadable#require
- Add tests to protect from regressions in require's return value behavior
- See a10606c490 (require needs to return true or false) for the original bug fix
2011-12-03 12:41:54 -05:00
José Valim
9ebacf3bf5 Merge pull request #3805 from arunagw/active_model_patch_3-0-stable
Active model patch 3 0 stable
2011-11-30 02:43:22 -08:00
Arun Agrawal
be8485e77d ActiveModel confirmation validator fix fixes #1152
If you have an ActiveModel class that has a 
method email_address_confirmation. 
This method is being overwritten by the 
method defined in the Confirmation validator.
2011-11-30 16:09:13 +05:30
Jon Leighton
13ad87971c Don't html-escape the :count option to translate if it's a Numeric. Fixes #3685.
Conflicts:

	actionpack/CHANGELOG.md

Conflicts:

	actionpack/CHANGELOG.md
2011-11-19 13:31:03 +00:00
Jon Leighton
66a4beb0c9 Preparing for 3.0.11 release 2011-11-18 01:19:17 +00:00
Aaron Patterson
618300ec4a fixing test case test on 1.9.3dev 2011-11-17 23:29:44 +00:00
Aaron Patterson
0e9910eaff removing stubs. 1.9.3 implements Date.today in C so mocking the return value of Time.now does nothing 2011-11-17 23:22:56 +00:00
lest
ba2d850120 _html translation should escape interpolated arguments
Conflicts:

	actionpack/CHANGELOG.md
2011-11-17 23:10:03 +00:00
Jon Leighton
a03f0181a4 Implement a workaround for a bug in ruby-1.9.3p0.
The bug is that an error would be raised while attempting to convert a
template from one encoding to another.

Please see http://redmine.ruby-lang.org/issues/5564 for more details.

The workaround is to load all conversions into memory ahead of time,
and will only happen if the ruby version is *exactly* 1.9.3p0. The
hope is obviously that the underlying problem will be resolved in
the next patchlevel release of 1.9.3.

Conflicts:

	actionpack/CHANGELOG.md
2011-11-17 21:36:54 +00:00
Jon Leighton
961b4a0042 Use broken YAML that will fail with Syck as well as Psych. Fixes test_broken_yaml_exception in fixtures_test.rb on Ruby 1.8.7.
Cherry-pick from 3-1-stable: b8d46924e7

Conflicts:

	activerecord/test/cases/fixtures_test.rb
2011-11-17 21:16:33 +00:00
José Valim
de44773952 Merge pull request #3655 from arunagw/mysql_bump_3-0-stable
Mysql bump 3 0 stable
2011-11-17 00:01:54 -08:00
Arun Agrawal
4e72f59c5d Mysql2 version bump!
I saw one bug fixed here 

e60599b912
2011-11-17 12:17:44 +05:30
Aaron Patterson
2ba03098db Revert "Merge pull request #2122 from dyba/3-0-stable"
This reverts commit b81c3f7d6a, reversing
changes made to 6122924121.
2011-11-16 10:21:58 -08:00
Aaron Patterson
b81c3f7d6a Merge pull request #2122 from dyba/3-0-stable
Issue #1866: Changed Commands module to RailsCommands.
2011-11-16 10:18:38 -08:00
Yehuda Katz
6122924121 Merge pull request #3646 from mhuffnagle/3-0-stable
Fix for relative_url_root= missing parameter (issue 3645)
2011-11-16 09:38:04 -08:00
mhuffnagle
328ae5bb9b Added a missing parameter to relative_url_root= that was causing an ArgumentError: wrong number of arguments (1 for 0) to be thrown at actionpack-3.0.10/lib/action_controller/railtie.rb:54. 2011-11-15 22:32:49 -05:00
Josh Kalderimis
394dd6fa93 Remove a circular require in AS deprecations. This is safe as AS deprecations is autoloaded as needed. 2011-11-01 14:57:08 -02:00
Vijay Dev
fd677351ce Merge pull request #3330 from arunagw/ignore_sqlnet_3-0-stable
Ignore sqlnet 3 0 stable
2011-10-17 05:56:44 -07:00
Arun Agrawal
68ae66d025 activerecord/sqlnet.log into gitignore when running with oracle. 2011-10-14 17:50:44 +05:30
Vijay Dev
e2c03bfdd5 Merge pull request #3233 from benolee/fix_spelling_in_doc_app_rake_task
Fix spelling in doc:app rake task
2011-10-06 00:54:26 -07:00
Akira Matsuda
543b587c62 ruby193: String#prepend is also unsafe 2011-10-05 21:22:48 -02:00
Akira Matsuda
984d031490 override unsafe methods only if defined on String 2011-10-05 21:22:25 -02:00
Ben Holley
346973e3a3 Fix spelling in doc:app rake task 2011-10-05 13:41:35 -05:00
Jeremy Kemper
87bbf48567 Merge pull request #2801 from jeremyevans/patch-1
Fix obviously breakage of Time.=== for Time subclasses
2011-10-03 10:55:59 -07:00
José Valim
1000ada363 Merge pull request #3142 from parndt/3-0-stable
Fixes #3087
2011-09-27 00:58:18 -07:00
Philip Arndt
0dd7411c39 Fixes #3087 by removing autoload for non-existant DeprecatedBlockHelpers 2011-09-27 17:35:30 +13:00
Pratik Naik
378ce0e89c Dont use association proxy#reload to load the target for the first time 2011-09-12 12:50:54 +01:00
misfo
78a4aea83e prevent errors when passing a frozen string as a param to ActionController::TestCase#process
since ActionDispatch::Http::Parameters#encode_params will force encoding on all params strings (when using an encoding aware Ruby), dup all strings passed into process.  This prevents modification of params passed in and, more importantly, doesn't barf when a frozen string is passed
thanks and high fives to kinsteronline
2011-09-11 08:04:02 -07:00
Vijay Dev
813e288807 fix assert message 2011-09-10 15:45:25 +05:30
Aaron Patterson
a748c600dd Exceptions from database adapters should not lose their backtrace. 2011-09-09 14:24:12 -07:00
Vijay Dev
9c2ff32851 Merge pull request #2682 from guilleiguaran/3-0-stable-changelogs
Update changelogs (3-0-stable)
2011-09-08 11:50:48 -07:00
Guillermo Iguaran
5c10a535a5 Updating changelogs in 3-0-stable 2011-09-08 13:42:06 -05:00
José Valim
f863af968f Merge pull request #2939 from akaspick/url_for_fix_3_0
fix url_for when passing a hash to prevent unwanted additional values being added to the hash (backport to 3-0-stable)
2011-09-08 10:57:29 -07:00
Andrew Kaspick
a8cfc99714 fix url_for to not add additional unwanted options when called with a hash 2011-09-08 12:57:41 -05:00
Andrew Kaspick
45b7731838 when calling url_for with a hash, additional (likely unwanted) values (such as :host) would be returned in the hash... calling #dup on the hash prevents this 2011-09-08 12:50:21 -05:00
Sergio Gil Pérez de la Manga
de178dfeec Update changelog for 'Backport "ActiveRecord::Persistence#touch should not use default_scope" (pull request #1519)' 2011-09-07 23:29:38 +01:00
Dmitriy Kiriyenko
d93213f99f This way asserting that updated_at was changed in touch look more obvious. 2011-09-07 23:28:48 +01:00
Dmitriy Kiriyenko
4364157555 Do not use default_scope in ActiveRecord::Persistence#touch. 2011-09-07 23:28:47 +01:00
Jon Leighton
3a3344a456 Merge pull request #2918 from akaspick/assert_select_email_fix_3_0
assert_select_email fix for 3-0-stable
2011-09-07 14:35:30 -07:00
Andrew Kaspick
c7f3429c2f more descriptive CHANGELOG entry 2011-09-07 15:32:54 -05:00
Jon Leighton
9ef9f9884b Merge pull request #2919 from akaspick/exists_fix_3_0
fix exists? to return false if passed nil (backport to 3-0-stable)
2011-09-07 12:36:43 -07:00
Andrew Kaspick
3e00e49929 entry for fixing exists? 2011-09-07 14:49:59 -05:00
Andrew Kaspick
15dcdf6cf2 fix exists? to return false if passed nil (which may come from a missing URL param) 2011-09-07 14:48:13 -05:00
Andrew Kaspick
cf0ea79087 assert_select_email entry 2011-09-07 14:33:24 -05:00
Andrew Kaspick
8094d29d2b fix assert_select_email to work on non-multipart emails as well as converting the Mail::Body to a string to prevent errors. 2011-09-07 14:32:37 -05:00
Santiago Pastorino
59a64a8266 * is not allowed in windows file names. Closes #2574 #2847 2011-09-04 17:47:46 -03:00
Aaron Patterson
f2aa46b17c * Psych errors with poor yaml formatting are proxied. Fixes #2645, #2731 2011-09-01 15:20:57 -07:00
Aaron Patterson
b550eccc69 use String#start_with? rather than creating regexps or comparing character values 2011-08-31 11:30:54 -07:00
Aaron Patterson
0195846e58 Merge pull request #2744 from arunagw/mysql2_bump
Mysql2 bump
2011-08-30 10:16:11 -07:00
Arun Agrawal
941a9d0cfb MySQL2 Bump to 0.2.13 2011-08-30 14:26:44 +05:30
Aaron Patterson
d7d0c25665 Merge pull request #1995 from guilleiguaran/prototype-ujs-fix
Prototype rails.js fixes for 3-0-stable
2011-08-22 23:01:18 -07:00
Santiago Pastorino
c8ec8f78d3 Merge pull request #2524 from JonathonMA/fix_ecd37084b28a05f05251
Use mysql_creation_options inside rescue block
2011-08-22 15:06:26 -03:00
José Valim
0ebdef2c0b Edited .travis.yml via GitHub 2011-08-21 09:22:38 +03:00
Aaron Patterson
0b377044fa Merge branch '3-0-10' into 3-0-stable
* 3-0-10:
  bumping rails to 3.0.10
  properly subsituting bad utf8 characters
  Tags with invalid names should also be stripped in order to prevent XSS attacks.  Thanks Sascha Depold for the report.
  prevent sql injection attacks by escaping quotes in column names
  Properly escape glob characters.
  bumping to 3.0.10.rc1
  more changelog updates
  updating CHANGELOGs
2011-08-16 15:34:19 -07:00
Aaron Patterson
4f15f39260 bumping rails to 3.0.10 2011-08-16 15:10:17 -07:00
Aaron Patterson
b45dfc7278 properly subsituting bad utf8 characters 2011-08-16 15:09:28 -07:00
Aaron Patterson
3480d97b6c Tags with invalid names should also be stripped in order to prevent
XSS attacks.  Thanks Sascha Depold for the report.
2011-08-16 15:08:10 -07:00
Aaron Patterson
fb4747bcf1 prevent sql injection attacks by escaping quotes in column names 2011-08-16 15:07:36 -07:00
Aaron Patterson
e0c03f8a2e Properly escape glob characters. 2011-08-16 15:06:57 -07:00
Jon Leighton
4c8a211e00 Update travis config on @joshk's instructions 2011-08-15 17:23:42 +01:00
Santiago Pastorino
f45c372e43 Merge pull request #2494 from grzuy/3-0-stable
Porting changes on form_tag method signature to 3-0-stable
2011-08-11 09:05:07 -07:00
Gonzalo Rodriguez and Leonardo Capillera
11f65311a4 Remove 'parameters_for_url' from 'form_tag' method signature 2011-08-11 12:00:03 -03:00
Jason Weathered
1f6360621a Fix marshal round-tripping of fractional seconds (Time#subsec). 2011-08-07 18:25:22 -07:00
Santiago Pastorino
65a648be10 Merge pull request #2450 from guilleiguaran/activesupport-gzip-1.8
Fix ActiveSupport::Gzip under Ruby 1.8.7. Closes #2416
2011-08-06 17:22:58 -03:00
Aaron Patterson
521c9aa6a8 bumping to 3.0.10.rc1 2011-08-04 17:09:46 -07:00
Aaron Patterson
9d17458544 more changelog updates 2011-08-04 17:08:11 -07:00
Xavier Noria
e0b0da22f6 backports doc fix 9f9446f 2011-08-05 02:06:21 +02:00
Aaron Patterson
f54d0cfb24 updating CHANGELOGs 2011-08-04 16:53:26 -07:00
Aaron Patterson
df6b1e231e we should not ignore all gems in here 2011-08-04 16:33:28 -07:00
Jon Leighton
e42c544920 Quote these dates to prevent intermittent test failure. Suppose local time is 00:50 GMT+1. Without the quoting, the YAML parser would parse this as 00:50 UTC, into the local time of 01:50 GMT+1. Then, it would get written into the database in local time as 01:50. When it came back out the UTC date from the database and the UTC date of two weeks ago would be compared. The former would be 23:50, and the latter would be 00:50, so the two dates would differ, causing the assertion to fail. Quoting it prevents the YAML parser from getting involved. 2011-08-04 00:49:41 +01:00
Santiago Pastorino
a173bb328b Merge pull request #2393 from bdurand/fix_cache_read_multi
Fix ArgumentError in ActiveSupport::Cache::CacheStore.read_multi
2011-08-01 15:00:43 -03:00
Santiago Pastorino
564d39ec70 Merge pull request #2381 from vijaydev/rakeaboutfix3.0
Fix #2368 (3-0-stable)
2011-07-31 12:54:51 -07:00
Vijay Dev
773d21959e fixes #2368. rake about not showing the middleware, db adapter and db schema version 2011-08-01 00:55:03 +05:30
Santiago Pastorino
cb36585c27 Merge pull request #2374 from arunagw/30_schema_dumper_test_fix
3-0-stable schema dumper test fix
2011-07-31 09:59:48 -07:00
Arun Agrawal
b0334dbe47 skiping magic comment test. checking encoding_aware?
Loading AS encoding.
2011-07-31 21:43:20 +05:30
Aaron Patterson
553d9ea6dc updating the CHANGELOG 2011-07-29 14:47:41 -07:00
Aaron Patterson
b9f6798c21 delay backtrace scrubbing until we actually raise an exception. fixes #1936 2011-07-29 14:40:44 -07:00
Aaron Patterson
6631abd155 updating changelog with schema.rb changes 2011-07-29 12:31:00 -07:00
Aaron Patterson
3676af404d default writing the schema file as utf-8 2011-07-29 12:28:35 -07:00
Bhavin Kamani
5d7ed7a056 fix connection not established error while running rake task
db:schema:dump
2011-07-29 12:26:49 -07:00
Aaron Patterson
6c0beb521b dump IO encoding value along with schema.rb so the file can be reloaded. fixes #1592 2011-07-29 12:24:13 -07:00
Santiago Pastorino
a33fe79430 Merge pull request #2320 from amatsuda/callback_deprecation_message
callback methods are Class methods
2011-07-28 05:57:00 -07:00
Akira Matsuda
a8aa666f16 callback methods are Class methods 2011-07-28 19:31:54 +09:00
Xavier Noria
e93cff8979 contrib app minor tweak 2011-07-27 13:21:59 -07:00
Santiago Pastorino
43e6f82ac2 Remove cruise files 2011-07-26 18:11:55 -03:00
Santiago Pastorino
e18e8969c1 Merge pull request #2289 from joshk/3-0-stable
More Irc notifications (from Travis with love, again)
2011-07-26 14:08:14 -07:00
Josh Kalderimis
64c269a7b0 enable Travis CI irc notifications to #rails-contrib on irc.freenode.org 2011-07-26 22:26:21 +02:00
Santiago Pastorino
56c663b1ea Merge pull request #2249 from arunagw/rake_template_path_fix
Rake template path fix
2011-07-25 06:52:18 -07:00
Arun Agrawal
edfcf47026 Fix rake rails:template to tell user to pass LOCATION variable. 2011-07-25 16:13:10 +05:30
Santiago Pastorino
eead13f166 Merge pull request #2080 from lhahne/3-0-stable
Fix improper detection and handling of html_safe buffer in CacheHelper
2011-07-23 23:40:54 -07:00
Santiago Pastorino
19d968958d Merge pull request #2205 from arunagw/test_un_3_0_stable
rake test:uncommitted for 3-0-stable
2011-07-23 07:59:34 -07:00
Arun Agrawal
b490fd87f5 fixed task for rake test:uncommitted 2011-07-23 20:17:13 +05:30
Santiago Pastorino
c39bd5f1ce Merge pull request #2183 from castlerock/3-0-stable-duplicate_test
3 0 stable duplicate test
2011-07-22 07:53:27 -07:00
Karunakar (Ruby)
bd804d757d Duplicate tests removed. 2011-07-22 16:20:49 +05:30
Xavier Noria
80b1f9ea78 I actually love well-formed Gemfiles 2011-07-21 23:03:04 +02:00
Josh Kalderimis
047b979eae Added a .travis.yml config and travis specific ci script.
Don't install ruby-debug if running the test suite on Travis,
linecache19 is the main offender, very very slow.

And do not install pg if Travis is bundling the gems, pg will be setup
on Travis soon.

Conflicts:

	Gemfile
2011-07-18 23:51:08 +02:00
Josh Kalderimis
9ade587002 This fixes an issue when bundling to a local path (eg. /vendor/bundle).
If you bundle to a local path bundler is not included in it, so
calling "gem 'bundler'" will fail.

Conflicts:

	load_paths.rb
2011-07-18 23:38:49 +02:00
Santiago Pastorino
a6139b9d1c Merge pull request #2134 from jstorimer/ensure-status-codes-are-logged-properly-3-0-stable
Ensure status codes are logged properly (for 3-0-stable)
2011-07-18 12:30:36 -07:00
Jesse Storimer
5e64538435 Ensure that status codes are logged properly
Needed to move AC::Metal::Instrumentation before AM::Metal::Rescue
so that status codes rendered from rescue_from blocks are logged
properly.
2011-07-18 14:58:29 -04:00
Daniel Dyba
71c010d996 Substituted RailsCommands for Rails::Commands 2011-07-17 23:09:51 -07:00
Santiago Pastorino
1220b1615a Merge pull request #2047 from sikachu/3-0-stable-test_fix
Fix a wrong assertion on url_helper_test, and add missing `#html_safe?` a
2011-07-17 12:49:04 -07:00
Prem Sichanugrist
2cb29fabc1 Fix a wrong assertion on url_helper_test, and refactor html_safe test to be in its method 2011-07-17 15:40:05 -04:00
Lauri Hahne
39a4f67b5d made sure that the possible new output_buffer created by CacheHelper is of the same type as the original 2011-07-17 18:55:39 +03:00
Lauri Hahne
bc5ccd0179 Added tests for the output_buffer returned by CacheHelper
The output_buffer returned by CacheHelper should be html_safe if the original buffer is html_safe.
2011-07-17 18:42:34 +03:00
Daniel Dyba
c2d3a43eca Changed Commands module to RailsCommands.
This is to avoid a conflict that occurs when you add Rake to
your Gemfile. There is a Commands Object in Rake that conflicts
with the Commands module in plugin.rb. See rails issue #1866.
2011-07-16 16:54:03 -07:00
Santiago Pastorino
247a50b6c3 Merge pull request #2064 from elight/3-0-stable
Backports cache_key fix from master
2011-07-16 10:05:54 -07:00
Evan Light
b1b5d18042 Fixes #2064
Backport of cache_key fix from master
2011-07-16 12:07:12 -04:00
Lauri Hahne
c476a6be78 fixed CacheHelper to properly support html_safe output buffers 2011-07-15 09:12:11 +03:00
Aaron Patterson
9a4d2b27c8 Merge pull request #1607 from bradrobertson/pg_adapter
fix table_exists? in postgresql adapter to always use current search_path
2011-07-11 17:28:31 -07:00
Jon Leighton
fc4bce15fd Merge pull request #1797 from kuahyeow/3-0-stable
Through association condition clobbers join condition
2011-07-11 16:32:49 -07:00
kuahyeow
caec63929f Fix for 3-0-stable - Conditions specified on through association shouldn't clobber asssociation join condition.
This fix refactors processing of association join conditions so that both the join condition and the custom condition will be used when called by query_methods.rb, which expects a 1 or 2-sized array (depending on the type of association). Previously, a custom condition specified would create a 2 or 3-sized array which will clobber the association join condition.
2011-07-12 09:35:08 +12:00
Tomas D'Stefano
28f057c9d2 Destroy association habtm record before destroying the record itself. Fixes issue #402. 2011-07-08 22:25:40 +01:00
Guillermo Iguaran
8226dfce5f Update to latest rails.js for fix some bugs under IE 2011-07-07 13:23:11 -05:00
Santiago Pastorino
e9f2c67874 Merge pull request #2004 from knapo/3-0-stable
Backport of #1997
2011-07-07 09:29:01 -07:00
knapo
e2d90bf8f5 Make ActiveRecord::Batches#find_each to not return self.
This caused that `find_each` was producing extra db call taking all the records from db, and was less efficient than `ActiveRecord::Base#all`.
2011-07-07 18:20:08 +02:00
Santiago Pastorino
9e4d1565ad Merge pull request #1837 from msgehard/3-0-stable
Fix for empty string assigned to _type column of polymorphic association
2011-07-06 11:53:38 -07:00
Santiago Pastorino
2f3eb7aa95 Merge pull request #1952 from simonbaird/3-0-stable
rake db:test:purge creates mysql database with wrong charset & collation
2011-07-06 11:41:04 -07:00
Santiago Pastorino
7ff32e2564 Merge pull request #1894 from arunagw/fix_test_for_jruby_db-3-0-stable
Fix test for jruby db 3 0 stable
2011-07-06 11:16:17 -07:00
Andrew White
1b03f7fba7 Revert "The rails gem doesn't have a lib directory."
RubyGems requires at least one require_path.

This reverts commit 3001728325.
2011-07-04 16:58:59 +01:00
Andrew White
3001728325 The rails gem doesn't have a lib directory. 2011-07-04 14:55:51 +01:00
Simon Baird
3ba3125b24 Fix charset/collate in mysql recreate_database
See new method mysql_creation_options. It is used by both
create_database and recreate_database so they are consistent.
2011-07-04 12:00:26 +10:00
Bogdan Gusiev
c314203d87 Fixed ActionView::FormOptionsHelper#select with :multiple => false
(cherry picked from commit 0fdac01876)

Signed-off-by: Andrew White <andyw@pixeltrix.co.uk>
2011-07-01 13:04:15 +01:00
Santiago Pastorino
9663fad8e2 Allow CI to use the latest rubygems version 2011-06-30 08:35:37 -03:00
Santiago Pastorino
3d0fde5edb Update CI config 2011-06-30 08:35:34 -03:00
Santiago Pastorino
39d5350499 Merge pull request #1901 from arunagw/json_parse
It should be in Json format to work with JsonGem
2011-06-29 18:37:43 -07:00
Arun Agrawal
a13317d309 It should be in Json format to work with JsonGem 2011-06-29 15:26:25 +05:30
Aaron Patterson
a657a4b21c Merge pull request #1896 from guilleiguaran/issue-1893
Avoid extra call to Cache#read in case of a fragment cache hit (3-0-stable)
2011-06-28 20:32:07 -07:00
Guillermo Iguaran
e54d9c1eb7 Avoid extra call to Cache#read in case of a fragment cache hit 2011-06-28 22:24:05 -05:00
Vishnu Atrai
557d788792 3-0-stable fix test when running Jruby. If Jruby Platform is available the gem will change. 2011-06-29 08:12:20 +05:30
Arun Agrawal
0ed8dea9aa Using not effected timezone in tests. 2011-06-28 16:54:10 -07:00
Maxime RETY
b3e3c50add Fix JSON decoding of newline character with Yaml backend [#3479 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-06-28 11:59:43 -07:00
Aaron Patterson
a6495af688 Merge pull request #1649 from arunagw/jruby_3_0_stable
Jruby 3 0 stable
2011-06-28 11:40:30 -07:00
Xavier Noria
59f19a95bb updates the contributing guide 2011-06-24 17:20:29 +02:00
Santiago Pastorino
19392cf827 Add CHANGELOG entry 2011-06-23 16:29:28 -03:00
Santiago Pastorino
3add2ea56c Merge pull request #1834 from jeroenj/cachesweeper-fix-3-0
Fixes an issue where cache sweepers
2011-06-23 12:24:30 -07:00
Mike Gehard
5a44c701ee Fix issue where assigning a empty string to the _type column of a polymorphic association throws an error. Now it returns nil for the association as one would expect.
[Fixes #1824]
2011-06-23 12:59:25 -06:00
Jeroen Jacobs
2f9bd25a56 Fixes an issue where cache sweepers with only after filters would have no controller object
It would raise undefined method controller_name for nil
2011-06-23 17:56:56 +02:00
Jeroen Jacobs
8ebc17f5c6 Tests only after filters in cache sweepers 2011-06-23 17:56:54 +02:00
Arun Agrawal
2771b91db8 Test added to check default option with jruby. It should generate
sqlite3 bases app
2011-06-22 09:22:16 +05:30
Arun Agrawal
ecddc65104 Modified .yml files according to master changes. As this will also work. 2011-06-22 09:17:55 +05:30
Arun Agrawal
fb495cd0c2 Tests added for jdbc option 2011-06-22 09:00:05 +05:30
Arun Agrawal
2fc22bf156 Convert database names to ones appropriate for JRuby 2011-06-22 08:36:16 +05:30
Arun Agrawal
2aeabdc6e1 Add generic 'jdbc' database option 2011-06-22 08:35:00 +05:30
Arun Agrawal
25e5ad290a Remove superfluous pg driver install instructions 2011-06-22 08:28:51 +05:30
Arun Agrawal
4bfbdd1b67 Fixed for sqlite3 checking with jdbc 2011-06-21 22:37:24 +05:30
Arun Agrawal
3b05231002 Only mysql and jdbcmysql. 2011-06-21 22:30:48 +05:30
Arun Agrawal
14bfe83144 More specific for jdbc-sqlite 2011-06-21 22:28:21 +05:30
Arun Agrawal
3e7af4211b For more specific for jdbc postgresql databases. 2011-06-21 22:11:25 +05:30
José Valim
8467ea3051 Removed file added by accident. 2011-06-20 11:23:19 -03:00
José Valim
bc070baca3 Fix SafeBuffers by adding a dirty flag. 2011-06-20 08:52:55 -03:00
José Valim
22cc1e9f96 Merge pull request #1775 from bensie/class-attr-3-0-stable
Instance reader method on class_attribute - 3-0-stable
2011-06-19 16:29:50 -07:00
James Miller
ad06ddd731 Add option to omit creating an instance reader method on class_attribute 2011-06-19 13:08:23 -07:00
José Valim
8d9bc64808 Merge pull request #1772 from arunagw/require_rel_remove-3-0-stable
Require rel remove 3 0 stable
2011-06-19 04:52:56 -07:00
Arun Agrawal
48fcd225e4 Removing require_relative gem. Linecache new version 0.46 is out and
it's loading rbx-require-relative > 0.0.4
2011-06-19 15:11:19 +05:30
Santiago Pastorino
fccacae7be Bump mysql2 up 2011-06-17 17:44:06 -03:00
Jon Leighton
8742a97868 Add require 'pathname' as it has not already been required in some circumstances 2011-06-17 14:56:08 +01:00
Aaron Patterson
5e61d0b6fb Merge branch '3-0-9' into 3-0-stable
* 3-0-9:
  Preparing for 3.0.9 release
  avoid false positives caused by release candidates
  Preparing for 3.0.9.rc5 release
  bumping to rc4
  Make sure that we don't perform in-place mutation on SafeBuffer string
  Update CHANGELOG to mention the json_escape change
  Ensure number helpers can handle HTML safe strings - closes #1597.
  bumping to rc3 since syck is not playing nicely
  bumping to 3.0.9.rc2
  ensuring that json_escape returns html safe strings when passed an html safe string
  Make sure `escape_javascript` return `SafeBuffer` if the incoming argument is already html_safe
  Fix issue #1598 by adding a dependency to the RDoc gem.
  bumping to 3.0.9.rc1
2011-06-16 12:06:00 +02:00
Aaron Patterson
15e2b5887f Preparing for 3.0.9 release 2011-06-16 12:03:00 +02:00
Aaron Patterson
fad08a6e58 avoid false positives caused by release candidates 2011-06-16 12:02:49 +02:00
José Valim
95905c5098 Merge pull request #1714 from dmathieu/3-0-cherry
Cherry picking encoding for 3.0
2011-06-15 04:10:13 -07:00
Lukáš Konarovský
b869b8c008 Use assert_equal instead of assert in uploaded file test. 2011-06-15 13:00:43 +02:00
Damien Mathieu
71d7610e81 all requests are utf-8. Don't use the external encoding. 2011-06-15 12:59:58 +02:00
Damien Mathieu
991e3886a1 encode the uploaded file's name in the default external encoding - Closes #869 2011-06-15 12:59:51 +02:00
Damien Mathieu
6cfd1c7726 simplify to only one condition
Signed-off-by: Andrew White <andyw@pixeltrix.co.uk>
2011-06-15 09:54:06 +01:00
Andrew White
190101e154 Make MissingTranslation exception handler respect :rescue_format 2011-06-15 01:30:53 +01:00
Jon Leighton
4a96ab45aa Add Gemfile dependency for require_relative on mri18. This is a dependency of linecache which is a dependency of ruby-debug. However, the latest release of linecache (0.45) omits the dependency from its gemspec, causing the build to fail. I have emailed the maintainer so we should remove this when it's fixed upstream. 2011-06-13 22:20:43 +01:00
Andrew White
271bccbcef Remove obsolete compatibility module 2011-06-13 18:30:12 +01:00
Aaron Patterson
6824c5d1d3 Preparing for 3.0.9.rc5 release 2011-06-12 14:28:06 -07:00
Aaron Patterson
d9584284c2 Merge branch '3-0-9' of github.com:rails/rails into 3-0-9
* '3-0-9' of github.com:rails/rails:
  Make sure that we don't perform in-place mutation on SafeBuffer string
  Update CHANGELOG to mention the json_escape change
  Ensure number helpers can handle HTML safe strings - closes #1597.
2011-06-12 14:26:18 -07:00
Aaron Patterson
f283194234 bumping to rc4 2011-06-12 14:21:20 -07:00
Aaron Patterson
d5e28c313b Merge branch '3-0-stable' into 3-0-9
* 3-0-stable:
  Add support for using an ARCONFIG environment variable to specify the location of the config.yml file for running the tests
  Define ActiveSupport#to_param as to_str - closes #1663
  Revert "Make sure that we don't perform in-place mutation on SafeBuffer string"
  Make sure that we don't perform in-place mutation on SafeBuffer string
  Update CHANGELOG to mention the json_escape change
  Ensure number helpers can handle HTML safe strings - closes #1597.
  ensuring that json_escape returns html safe strings when passed an html safe string
  Fix issue #1598 by adding a dependency to the RDoc gem.
  Make sure `escape_javascript` return `SafeBuffer` if the incoming argument is already html_safe

Conflicts:
	actionpack/CHANGELOG
2011-06-12 13:57:05 -07:00
Jon Leighton
968816aa25 Add support for using an ARCONFIG environment variable to specify the location of the config.yml file for running the tests 2011-06-12 19:14:09 +01:00
Andrew White
a64b5dd6dc Define ActiveSupport#to_param as to_str - closes #1663 2011-06-12 15:28:45 +01:00
Arun Agrawal
110de0f076 Using different constant. 2011-06-11 16:46:59 +05:30
Arun Agrawal
2b4a7ca4a1 Modified database.rake file to run with jdbcsqlite3 2011-06-11 16:36:07 +05:30
Arun Agrawal
9da2a10037 Allow database.rake tasks to perform opreation with jdbcpostgresql 2011-06-11 16:31:45 +05:30
Arun Agrawal
d5b9ea3fed Fixed error when running db:create with jdbcmysql 2011-06-11 16:25:59 +05:30
Arun Agrawal
7f4bf0141e Adding Jruby-openssl in gemfile for 3-0-stable. 2011-06-11 16:22:12 +05:30
Arun Agrawal
bcd91457a0 Adding JDBCpostgresql template for Jruby in 3-0-stable. 2011-06-11 16:18:31 +05:30
Arun Agrawal
680e5d24bb Adding jdbcsqlite3 in comment 2011-06-11 16:14:38 +05:30
Arun Agrawal
871a0fc8e4 Adding JDBCsqlite3 template for Jruby in 3-0-stable. 2011-06-11 16:12:30 +05:30
Arun Agrawal
0e0be3546d Tests added for activerecord-jdbcmysql 2011-06-11 16:07:56 +05:30
Arun Agrawal
4448988b62 Adding JDBCmysql template for Jruby in 3-0-stable. 2011-06-11 16:06:09 +05:30
Santiago Pastorino and José Ignacio Costa
0019379e55 Revert "Make sure that we don't perform in-place mutation on SafeBuffer string"
This reverts commit 104e200a5e.
2011-06-10 23:11:13 -03:00
Aaron Patterson
f169dab5c7 Merge pull request #1640 from sikachu/3-0-9-render-inline
Render inline fix for 3-0-9
2011-06-10 16:26:24 -07:00
Aaron Patterson
70b4ea9764 Merge pull request #1639 from sikachu/3-0-stable-render-inline
Render inline fix for 3-0-stable
2011-06-10 16:25:30 -07:00
Prem Sichanugrist
fb706c75fc Make sure that we don't perform in-place mutation on SafeBuffer string
This will make sure `render :inline` is working.

Closes #1633
2011-06-10 18:34:22 -04:00
Prem Sichanugrist
564a655293 Update CHANGELOG to mention the json_escape change 2011-06-10 18:34:02 -04:00
Andrew White
60d4dc1166 Ensure number helpers can handle HTML safe strings - closes #1597. 2011-06-10 18:33:54 -04:00
Prem Sichanugrist
104e200a5e Make sure that we don't perform in-place mutation on SafeBuffer string
This will make sure `render :inline` is working.

Closes #1633
2011-06-10 18:31:46 -04:00
Prem Sichanugrist
c4fbb21bac Update CHANGELOG to mention the json_escape change 2011-06-10 18:31:46 -04:00
Andrew White
9b80f8dbcd Ensure number helpers can handle HTML safe strings - closes #1597. 2011-06-10 11:26:30 +01:00
Aaron Patterson
66ec7e84c9 bumping to rc3 since syck is not playing nicely 2011-06-09 15:48:19 -07:00
Aaron Patterson
0e1ecb2e15 bumping to 3.0.9.rc2 2011-06-09 15:36:44 -07:00
Aaron Patterson
cce7085693 ensuring that json_escape returns html safe strings when passed an html safe string 2011-06-09 15:29:41 -07:00
Aaron Patterson
88413efe5d ensuring that json_escape returns html safe strings when passed an html safe string 2011-06-09 15:29:36 -07:00
Prem Sichanugrist
8fcdc152d3 Make sure escape_javascript return SafeBuffer if the incoming argument is already html_safe 2011-06-09 14:28:35 -07:00
Jacob Poulsgaard Tjoernholm
b002181827 Fix issue #1598 by adding a dependency to the RDoc gem. 2011-06-09 14:26:28 -07:00
Jacob Poulsgaard Tjoernholm
caa977972f Fix issue #1598 by adding a dependency to the RDoc gem. 2011-06-09 14:25:53 -07:00
Aaron Patterson
b6a2157e2a Merge pull request #1611 from sikachu/3-0-stable-javascript
Make sure `escape_javascript` return `SafeBuffer` if the incoming argumen
2011-06-09 11:43:10 -07:00
Prem Sichanugrist
3d82d81f7d Make sure escape_javascript return SafeBuffer if the incoming argument is already html_safe 2011-06-09 14:24:45 -04:00
bradrobertson
0252376cc9 modified table_exists? to always use current search_path or schema if explicitly set 2011-06-09 11:37:50 -04:00
Aaron Patterson
0c1608c4ed bumping to 3.0.9.rc1 2011-06-08 14:17:03 -07:00
Aaron Patterson
1ae9b29a65 Merge pull request #1568 from sikachu/3-0-stable-mailto
Add proper fix to mail_to helper
2011-06-08 09:22:37 -07:00
Prem Sichanugrist
4b1309edfe Add proper fix to mail_to helper.
* Fix the problem on manipulating on the `ActiveSupport::SafeBuffer`
2011-06-08 12:16:31 -04:00
Prem Sichanugrist
f57c707f5f Revert "Fixed mailto for SafeBuffer#gsub"
It was fixing it in a bad way by changing test.

This reverts commit cdf617e9aa.
2011-06-08 12:13:24 -04:00
Aaron Patterson
02e65ef710 Merge pull request #1565 from sikachu/3-0-stable-changelog
Update CHANGELOG to mention the new SafeBuffer change
2011-06-08 09:01:50 -07:00
Prem Sichanugrist
4252a35609 Update CHANGELOG to mention the new SafeBuffer change 2011-06-08 11:55:43 -04:00
José Valim
910b34d3b0 Merge pull request #1558 from tardate/3-0-stable
Fix for issue 1553 - escape_javascript to support SafeBuffer strings
2011-06-08 08:01:28 -07:00
Paul Gallagher
75ecdfbd5c Make escape_javascript happy to handle SafeBuffers
* see GH#1553
* allow for the fact that gsub on SafeBuffer does not pass match variables $1, $2 etc to a block
2011-06-08 22:46:15 +08:00
Jon Leighton
eff72b26ed Merge pull request #1554 from rsim/assert_queries_oracle_fix_for_3_0
Assert queries oracle fix for 3 0
2011-06-08 04:40:07 -07:00
Raimonds Simanovskis
d909693299 Fix for Oracle adapter to count SELECT queries for assert_queries assertion
Needed just in 3-0-stable branch, query counting is refactored in 3-1-stable and master branches and do not need this patch anymore.
2011-06-08 13:23:43 +03:00
Aaron Patterson
211150908f Merge pull request #1545 from sikachu/30testbuffer
Fix test on 3-0-stable regarding SafeBuffer
2011-06-07 22:36:08 -07:00
Prem Sichanugrist
114b5e4b03 Adapt [059692a746] to make sure we perform correct cloning before manipulation on OutputBuffer.
This has been adapted from [823aa223ef]. However, after the fragment rendering, `Builder` returns the `String` object instead of `ActionView::OutputBuffer`. Somehow the same procedure which was in [823aa223ef] does not play nice with the String, and result in the fragment got lost.
2011-06-08 01:17:19 -04:00
Aaron Patterson
bdc80dd353 Merge pull request #1541 from arunagw/3-0-stable
Fixed for SafeBuffer
2011-06-07 20:25:47 -07:00
Arun Agrawal
059692a746 Cache helper fixed for SafeBuffer 2011-06-08 08:30:48 +05:30
Arun Agrawal
cdf617e9aa Fixed mailto for SafeBuffer#gsub 2011-06-08 08:21:22 +05:30
Aaron Patterson
54d262f6df Merge branch '3-0-8' into 3-0-stable
* 3-0-8:
  bumping to 3.0.8
  Do not modify a safe buffer in helpers
  Ensure that the strings returned by SafeBuffer#gsub and friends aren't considered html_safe?
2011-06-07 16:57:31 -07:00
Aaron Patterson
b341e45d8e bumping to 3.0.8 2011-06-07 16:51:58 -07:00
Bruno Michel
ed3796434a Do not modify a safe buffer in helpers
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2011-06-07 16:51:26 -07:00
Michael Koziarski
53a2c0baf2 Ensure that the strings returned by SafeBuffer#gsub and friends aren't considered html_safe?
Also make sure that the versions of those methods which modify a string in place such as gsub! can't be called on safe buffers at all.
2011-06-07 16:51:26 -07:00
Aaron Patterson
b3b747d94d make sure AR isolated tests set the environment variable 2011-06-06 18:01:11 -07:00
Aaron Patterson
1f02e3e283 oops! add parens so the block is properly bound 2011-06-06 16:59:59 -07:00
Aaron Patterson
f8301ebebe set the environment variable from the rake file 2011-06-06 16:51:52 -07:00
Aaron Patterson
f0cb0ed72e more oracle fixes 2011-06-06 15:51:29 -07:00
Aaron Patterson
3f3648cfd3 do not muck with the load path, that is the test task responsibility 2011-06-06 15:51:25 -07:00
Aaron Patterson
e6c2d5450b updating configs for oracle 2011-06-06 15:51:21 -07:00
Aaron Patterson
29c725882f add test to the include path 2011-06-06 15:51:16 -07:00
Aaron Patterson
1241997986 please use ruby -I lib:test path/to/test.rb, or export RUBY_OPT 2011-06-06 15:50:50 -07:00
Jon Leighton
0a4eb26f06 Make sure that the build/drop database rake tasks take account of the test/config.yml config 2011-06-06 21:26:02 +01:00
Jon Leighton
7497d27b9c Fix double definition of #teardown. Thanks @mike-burns 👍 2011-06-06 17:58:18 +01:00
Jon Leighton
5ffd03f423 Fix another CIfail 🔥 Deleting RAILS_ENV from ENV doesn't produce the desired result if RACK_ENV is still defined. And in any case it's better to be explicit here, so just set RALS_ENV=development. 2011-06-06 17:58:16 +01:00
Aaron Patterson
d55cf30383 Merge pull request #1511 from vijaydev/rake_rdoc_fixes_cherry_picks_3_0
Rake rdoc fixes cherry picks for 3-0-stable
2011-06-06 08:44:54 -07:00
Vijay Dev
bbfd65299f cherry picked 05adf524 for 3-0-stable. Original Author: amatsuda 2011-06-06 20:59:38 +05:30
Vijay Dev
81b01b75be cherry picked 24b28a2 for 3-0-stable. Original Author: amatsuda 2011-06-06 20:58:38 +05:30
Vijay Dev
91bdd36944 fixes Rake::RDocTask deprecation warnings from rake 0.9.0 (cherry picked
b921679 for 3-0-stable)
2011-06-06 20:52:17 +05:30
Vijay Dev
13c8ed3ec0 fixes Rake::GemPackageTask deprecation warnings from rake 0.9.0 2011-06-06 20:21:20 +05:30
Jon Leighton
6512af232c Solve the RAILS_ENV problem in the railties tests in a more generic way 2011-06-06 13:55:45 +01:00
José Valim
e9b025ef21 Merge pull request #1506 from arunagw/3-0-stable
Cherry-picked from master to fix the build
2011-06-06 04:00:53 -07:00
Arun Agrawal
101f0a6c6a Fix for CI server. Dependent on RAILS_ENV=development 2011-06-06 16:17:53 +05:30
Arun Agrawal
db9ad5e0e9 loading_test.rb with RAILS_ENV=development 2011-06-06 16:16:44 +05:30
Arun Agrawal
55b52ee9d6 framework_test.rb also dependent on RAILS_ENV=development 2011-06-06 16:16:38 +05:30
Jon Leighton
1debebc018 load_path_test.rb is also dependent on RAILS_ENV=development 2011-06-05 18:28:10 +01:00
Jon Leighton
6c1b7dc6cf Fix adapter_test.rb to make no assumptions about the database name 2011-06-05 11:29:17 +01:00
Jon Leighton
6764449471 Fix typo 2011-06-05 11:29:15 +01:00
Jon Leighton
9675ad6a00 Bring back oracle specific crap 2011-06-04 23:52:09 +01:00
Jon Leighton
93447be352 Refactor Active Record test connection setup. Please see the RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases. 2011-06-04 23:52:03 +01:00
Jon Leighton
11da7d32c6 Force RAILS_ENV=development in rackup_test.rb. This fixes a problem on the CI server. For some reason the RAILS_ENV on the CI server is production, which means that the ActionDispatch::Static middleware is not used, and so the request in 'config.ru can be racked up' returns a 404 rather than a 200. 2011-06-04 23:28:13 +01:00
Michael Koziarski
9f501230b3 Merge pull request #1454 from sikachu/revert_failing_commit
Revert failing commit
2011-06-01 21:05:06 -07:00
Prem Sichanugrist
4b8b16bf6b Revert "Fix broken test. You know, the merge button will be the end of us..."
The fix was intentionaly for this branch, but was applied to another
branches by mistake. This should fix the CI.

This reverts commit 4c0bed0cf0.
2011-06-01 23:45:55 -04:00
Jon Leighton
4c0bed0cf0 Fix broken test. You know, the merge button will be the end of us... 2011-06-01 23:20:22 +01:00
Jon Leighton
7bd80123c9 Merge pull request #1430 from vatrai/jruby_test_fix
test fixes for jruby
2011-06-01 10:41:31 -07:00
Arun Agrawal
bddf9ad3a9 Adding comment 2011-06-01 10:25:23 +00:00
Andrew White
91f6fba95f Make MemCacheStore work with Ruby 1.9 and -Ku 2011-05-31 23:25:43 +01:00
Vishnu Atrai
bd64cc99aa AttributeMethodTest test fix #jruby 2011-06-01 00:23:14 +05:30
Aaron Patterson
56f13a3341 Merge pull request #1400 from arunagw/query_cache_test
Query cache test
2011-05-30 18:45:15 -07:00
Aaron Patterson
ce23c6e47f rebuilding rc because of syck. :'( 2011-05-30 17:06:37 -07:00
Aaron Patterson
f4073d530f bumping to rc3 2011-05-30 12:54:16 -07:00
Aaron Patterson
636124eedc Merge branch '3-0-stable' into 3-0-8
* 3-0-stable:
  File From Xml is working now. #3-0-stable
  Fixing  XMLMini_JDOM #3-0-stable
  fixing test for mysql2
2011-05-30 12:49:52 -07:00
Arun Agrawal
fe99a8109d Fixed tests for #jruby 2011-05-30 08:44:32 +05:30
Aaron Patterson
60a7c34657 Merge pull request #1397 from sirlantis/3-0-8
Really fix #1322 (Rake::DSL issue)
2011-05-29 12:08:40 -07:00
Marcel Jackwerth
d92b22f22f Really fix #1322 (Rake::DSL issue) 2011-05-29 18:40:49 +02:00
Aaron Patterson
f07fd69e5b Merge pull request #1362 from sirlantis/patch-1
Unquoted query generated by through-association scope
2011-05-28 20:34:25 -07:00
Aaron Patterson
3332b495b9 Merge pull request #1369 from arunagw/3-0-stable
File From Xml is working now. #3-0-stable
2011-05-27 19:01:23 -07:00
Arun Agrawal
d8b6fcbf44 File From Xml is working now. #3-0-stable 2011-05-28 07:04:32 +05:30
Arun Agrawal
64310879e9 Fixing XMLMini_JDOM #3-0-stable 2011-05-28 06:59:29 +05:30
Marcel Jackwerth
d3cfb939e1 call .quote_value with column-parameter in patch #1362 2011-05-27 23:48:24 +02:00
Marcel Jackwerth
1df2286f81 added regression test 2011-05-27 23:05:46 +02:00
Marcel Jackwerth
152c41d524 Through-association owner's primary key wasn't quoted. Generates invalid SQL (id = ) if the record wasn't saved yet (i.e. the primary key's value is nil). 2011-05-27 12:57:05 -07:00
Aaron Patterson
c3cbd2c952 fixing test for mysql2 2011-05-27 11:44:00 -07:00
Aaron Patterson
d75652540e bumping to 3.0.8.rc2 2011-05-27 09:08:06 -07:00
Aaron Patterson
57958cb7b9 extend with Rake::DSL in case of rake 0.9.0. fixes #1322 2011-05-27 09:01:57 -07:00
José Valim
2ca0ae9cd5 Merge pull request #1351 from arunagw/3-0-stable-jruby-jdom-fixes
3 0 stable jruby jdom fixes
2011-05-27 05:33:13 -07:00
Arun Agrawal
4c330d6302 Loading files if PLATFORM available. #jruby 2011-05-27 08:25:41 +05:30
Arun Agrawal
993bd327d4 Using java_import instead of import. Need with rake 0.9.0 #jruby 2011-05-27 08:24:36 +05:30
Arun Agrawal
56097c0a71 Loading active_support/core_ext/hash/conversions fixed Undefined method from_xml 2011-05-27 08:23:05 +05:30
Aaron Patterson
179a8a46f9 quoting id columns when doing hm:t joins. fixes #1322 2011-05-26 16:11:57 -07:00
Aaron Patterson
579d044279 adding a test for #1322 2011-05-26 16:10:57 -07:00
Aaron Patterson
072e1ca5ea Merge pull request #1317 from parndt/3-0-stable
This fixes rake for me in RefineryCMS.
2011-05-25 18:11:38 -07:00
Philip Arndt
9e88b87285 This fixes rake for me in RefineryCMS. Otherwise, I get: undefined method 'prerequisites' for nil:NilClass (from rspec) 2011-05-26 13:07:29 +12:00
Aaron Patterson
8b0806e1b0 bumping to 3.0.8.rc1 2011-05-25 16:44:35 -07:00
Aaron Patterson
eecbc107ca updating changelogs 2011-05-25 16:35:51 -07:00
Aaron Patterson
cae1d46f1c add Psych::SyntaxError to the list of rescued YAML exceptions 2011-05-25 14:58:51 -07:00
Aaron Patterson
5856fc5ba6 use ! " " YAML string literal syntax rather than removing both quotes 2011-05-25 14:56:24 -07:00
Aaron Patterson
e4594f7294 load and prefer psych as the YAML parser when it is available 2011-05-25 14:52:09 -07:00
Aaron Patterson
03f0f3c571 require Psych if possible, use Psych output when enabled 2011-05-25 14:50:50 -07:00
Aaron Patterson
8e6b757dd4 load psych by default if possible 2011-05-25 14:50:04 -07:00
Aaron Patterson
f55a1715f8 prefering psych as the yaml parser if possible, fixing assertions for YAML 1.1 compatibility 2011-05-25 14:48:41 -07:00
Aaron Patterson
929e5c40f4 fixing psych support in big decimal, fixing tests to support YAML 1.1 2011-05-25 14:46:07 -07:00
Santiago Pastorino
79ed700c65 default_executable is deprecated since rubygems 1.7.0 2011-05-24 16:39:31 -07:00
Santiago Pastorino
352daffa4e Gem::Specification#has_rdoc= is deprecated since rubygems 1.7.0 2011-05-24 16:38:26 -07:00
Aaron Patterson
2649db7979 make open_log private 2011-05-24 16:35:49 -07:00
Aaron Patterson
79abb703e9 rescue record invalid exceptions and return false from the save method. fixes #796 2011-05-24 11:27:47 -07:00
Aaron Patterson
1c079c5fd7 add tests surrounding behavior of save and save! for associations that have validation errors 2011-05-24 11:27:42 -07:00
Aaron Patterson
f0c09f7c53 adding a test for create! with invalid associations 2011-05-24 11:27:38 -07:00
Aaron Patterson
99cfdba1e1 do not bother with assert_nothing_raised, the test will fail and we get a better trace without it 2011-05-24 11:27:34 -07:00
Joey Butler
d387a598bf Add failing test case for issue 796 2011-05-24 11:27:29 -07:00
José Valim
f236dbf1a6 Merge pull request #1269 from arunagw/fix_load_path_test_3_0
Fix load path test 3 0
2011-05-24 08:38:55 -07:00
Arun Agrawal
17c9efb76f Fixed failing tests. 2011-05-24 20:56:37 +05:30
José Valim
f505565d92 Merge pull request #1266 from arunagw/deprecation_warning_3_0_fix
Deprecation warning 3 0 fix
2011-05-24 07:48:43 -07:00
Arun Agrawal
89252c4fbe Fixed failing test against with 3-0-stable branch. 2011-05-24 19:33:58 +05:30
Patrick Quinn
83f257fc48 Make Rake::DSL methods available within Railtie rake_tasks block
Fixes incompatibility introduced by Rake 0.9.0
2011-05-23 15:26:54 -07:00
Xavier Noria
a37ae63969 set log encoding to BINARY, but still use text mode to output portable newlines 2011-05-18 12:44:35 +02:00
Aaron Patterson
78f855c641 bumping gem dependency for arel on 3.0.x 2011-05-17 18:10:33 -04:00
Michael Koziarski
b03da2417b Add a deprecation warning about config.action_view.debug_rjs.
Upgrading to 3.1 removes debug_rjs and upgraded apps will fail to start up.
2011-05-17 15:33:19 -04:00
Michael Koziarski
2004fb9c97 Make sure that 3.0.x apps generated reference a compatible mysql2 release. 2011-05-17 11:23:12 -04:00
Aaron Patterson
f2c6f04f3b make sure log file is written in binary mode. fixes #497 2011-05-16 09:53:20 -04:00
Aaron Patterson
a2b1be28c3 simplifying buffered logger for easier and slightly more performant codes. pumpkin 2011-05-16 09:53:15 -04:00
Bradley Harris
849007f743 Fix bug with empty CDATA not being handled in Hash.from_xml
Signed-off-by: José Valim <jose.valim@gmail.com>
2011-05-14 00:13:12 +02:00
Aaron Patterson
dc2b9990e4 supporting infinity and -infinity for timestamps in PG. fixes #544 2011-05-13 11:49:39 -07:00
Aaron Patterson
e4f48b97a4 backport skip to the AR base class 2011-05-13 10:28:47 -07:00
Aaron Patterson
7775670674 test/unit in ruby trunk adds a new instance variable. YAY! 2011-05-13 09:39:58 -07:00
Aaron Patterson
81535fa726 use encoding name since SJIS is Windows-31J on 1.9.3 2011-05-13 09:39:23 -07:00
Aaron Patterson
00da7bc5f8 use valid yaml in tests 2011-05-13 09:30:14 -07:00
Aaron Patterson
ea9ef39212 RedCloth will not install on 1.9.3 2011-05-13 09:30:06 -07:00
Doug Fales
56b6d7d901 A patch so that http status codes are still included in logs even during an exception [#6333 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2011-05-13 09:01:26 -07:00
Jon Leighton
f156258246 Merge pull request #352 from daphonz/polymorphic-join-sql-patch
Fixes for incorrect INNER JOIN through two polymorphic resources (NoMethodError: undefined method `to_sym' for nil:NilClass)
2011-05-10 15:57:20 -07:00
Aaron Patterson
840f0a9e23 removing splat flatten as we no longer support 1.8.6. fixes #485. Thanks @sztywny 2011-05-10 08:50:00 -07:00
José Valim
f1d09a2608 Merge pull request #465 from sven-q/3-0-stable
Issue #342: AssetTagHelper ensures that files are in the wrong directory (again)
2011-05-09 04:53:23 -07:00
Sven Winkler
7a79ab777e Fix Issue #342 2011-05-09 13:38:31 +02:00
José Valim
9575db6443 Revert "Pass the proper method_name instead of hardcoding to action_name."
This commit was actually correct. The first parameter in process_action
is not necessarily the same as the action_name. Use action_name to
retrieve the action instead.

This reverts commit 4e2bacdf7c.
2011-05-06 18:42:06 +02:00
José Valim
24fbc47043 Don't pluralize, camelize. 2011-05-06 17:02:24 +02:00
José Valim
957115f58a Merge pull request #383 from mathie/patch-1.
Extra requires for AR::Migration
2011-05-03 23:24:38 -07:00
Graeme Mathieson
cd028aaa19 Add a couple of missing activesupport requires so AR::Migration can be used independently. 2011-05-03 22:15:00 -07:00
Casey Dreier
05253064b7 This patch allows a user to join through a polymorphic has_one association to another has_one polymorphic association. This also includes a fix in to the Author model test to properly define two associations to taggings as a has_one and a has_many. 2011-04-29 23:26:31 -04:00
Casey Dreier
b538e8550b This patch ensures that an inner join performed to a polymorphic resource joins on both the polymorphic_id and polymorphic_type fields.
Previously, the inner joins were merely joining on the polymorphic_id field.
2011-04-29 23:19:02 -04:00
Aaron Patterson
c751d84971 only use mysql2 0.2.x with rails 3.0.x 2011-04-29 16:26:06 -07:00
Aaron Patterson
5663e635b0 Merged pull request #351 from vijaydev/3-0-stable.
Update the github url for the verification plugin
2011-04-29 16:16:42 -07:00
Aaron Patterson
d657b9eeb6 Merged pull request #351 from vijaydev/3-0-stable.
Update the github url for the verification plugin
2011-04-29 16:12:27 -07:00
Vijay Dev
6bcb352b8b update verification.git plugin url 2011-04-30 03:35:22 +05:30
José Valim
69079a1cac Make postgresql faster on development (thanks to @tapajos). 2011-04-29 21:41:51 +02:00
Aaron Patterson
1e19a0522f Merged pull request #347 from pkmiec/SyntacticalSugar30.
performance trumps syntactical sugar
2011-04-29 11:23:12 -07:00
Paul Kmiec
92e4cfb0eb perofrmance trumps syntactical sugar 2011-04-28 21:48:48 -07:00
José Valim
8dcaf4db55 Merged pull request #278 from miloops/fix_console.
Fix console to accept [environment] [options] as specified in docs.
2011-04-26 11:10:55 -07:00
Mikel Lindsaar
922fb1d8fc Update actionmailer to use Mail 2.2.19 2011-04-26 20:13:44 +10:00
Josh Kalderimis
030a9051e5 correction to the i18n locale filter examples 2011-04-23 00:56:39 +02:00
Pavel Forkert
3836dc6b4e Added test case and fix for proper eager loading associations 2011-04-21 22:52:23 -05:00
Rohit Arondekar
c1720fb553 Guides: Add test directory to load path to run individual test files. 2011-04-19 18:34:34 +02:00
Moiz Raja
1f92d13cf3 correct links to rack articles 2011-04-19 18:29:31 +02:00
José Valim
afcdf9b866 Avoid define_method if possible. 2011-04-19 18:05:10 +02:00
Aaron Patterson
d9bca64d1a adding a rake task to help generate changelog notes for release announcements 2011-04-18 14:43:24 -07:00
Aaron Patterson
9382cb468e Merge branch '3-0-7' into 3-0-stable
* 3-0-7:
  bumping version for release
  adding a rake task to update CHANGELOG dates
  Prepare for the 3.0.7.rc2 release
  Added missing CHANGELOG entries for 3.0.7
  Add missing CHANGELOG entries
  Update CHANGELOG
  Backport test assertions from 65469a6 (the behaviour is already the same, but we need to assertions to guard against regressions)
  Undo performances regressions I introduced in 36691ac9fc and add test for an edge case. Add comments to explain the intent of the code. Also fix the code (which previously worked differently on 1.8 and 1.9 due to Symbol#=~ being always false on 1.8)."
  Return nil from read_attribute if _foo is defined, but @attributes has no 'foo' key. Fixes breakage in test_find_only_some_columns on Ruby 1.9 which was introduced in a3639be4ed.
  Remove unnecessary code from define_read_method and add assertion to make sure the underscored version is actually generated

Conflicts:
	activerecord/CHANGELOG
2011-04-18 14:05:23 -07:00
Aaron Patterson
2c3260147f bumping version for release 2011-04-18 14:02:23 -07:00
Aaron Patterson
ff3cff894b adding a rake task to update CHANGELOG dates 2011-04-18 14:01:00 -07:00
Arun Agrawal
c6c46e1d1b File should be open in read/write mode. When doing lock on a file. 2011-04-18 09:07:54 -07:00
Mikel Lindsaar
2bd5e0287e Updating mail to 2.2.16 2011-04-16 23:32:56 +10:00
Santiago Pastorino
f96ad0d582 Prepare for the 3.0.7.rc2 release 2011-04-15 14:15:33 -03:00
Sebastian Martinez
de42af72e8 Added missing CHANGELOG entries for 3.0.7
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-04-15 11:53:25 -03:00
Andrew White
612afa20c6 Add missing CHANGELOG entries 2011-04-15 15:48:17 +01:00
Jon Leighton
20354b74f2 Update CHANGELOG 2011-04-15 15:07:39 +01:00
Jon Leighton
364a5d4ae1 Backport test assertions from 65469a6 (the behaviour is already the same, but we need to assertions to guard against regressions) 2011-04-15 15:06:50 +01:00
Jon Leighton
ef88c0c2bb Undo performances regressions I introduced in 36691ac9fc and add test for an edge case. Add comments to explain the intent of the code. Also fix the code (which previously worked differently on 1.8 and 1.9 due to Symbol#=~ being always false on 1.8)." 2011-04-15 15:06:35 +01:00
Jon Leighton
3609642ac9 Return nil from read_attribute if _foo is defined, but @attributes has no 'foo' key. Fixes breakage in test_find_only_some_columns on Ruby 1.9 which was introduced in a3639be4ed. 2011-04-15 15:06:19 +01:00
Jon Leighton
ef95df7067 Remove unnecessary code from define_read_method and add assertion to make sure the underscored version is actually generated 2011-04-15 15:06:10 +01:00
Jon Leighton
df6117ec47 Update CHANGELOG 2011-04-15 15:02:53 +01:00
Jon Leighton
bd0fe87501 Backport test assertions from 65469a6 (the behaviour is already the same, but we need to assertions to guard against regressions) 2011-04-15 13:28:20 +01:00
Jon Leighton
1302443d5c Undo performances regressions I introduced in 36691ac9fc and add test for an edge case. Add comments to explain the intent of the code. Also fix the code (which previously worked differently on 1.8 and 1.9 due to Symbol#=~ being always false on 1.8)." 2011-04-15 13:12:24 +01:00
Emilio Tagua
7d2f47234b Fix console to accept [environment] [options] as specified in docs. 2011-04-14 23:00:28 -03:00
Jon Leighton
9f5ab9a9ff Backported 14b880fd03 (Fix various issues with the :primary_key option in :through associations) 2011-04-15 02:18:08 +01:00
Jon Leighton
912e5ff790 Return nil from read_attribute if _foo is defined, but @attributes has no 'foo' key. Fixes breakage in test_find_only_some_columns on Ruby 1.9 which was introduced in a3639be4ed. 2011-04-15 01:52:16 +01:00
Jon Leighton
36691ac9fc Remove unnecessary code from define_read_method and add assertion to make sure the underscored version is actually generated 2011-04-15 01:45:49 +01:00
Santiago Pastorino
1787447ada Prepare for the 3.0.7.rc1 release 2011-04-14 18:16:26 -03:00
Santiago Pastorino
6bc9dd7cdb Add missing CHANGELOG entries 2011-04-14 17:49:55 -03:00
Stian Grytøyr
a3639be4ed Fixes performance issue introduced in 3.0.6 (issue #6695) 2011-04-14 08:55:56 -07:00
Andre Arko
3d150190d8 files are a special case and need whitespace to be significant 2011-04-14 11:09:48 +02:00
Andre Arko
45683fb6c2 gsub is not needed (thanks @fxn!) 2011-04-14 11:00:32 +02:00
Andre Arko
b41d8f30de attributes no longer disappear if a tag contains whitespace
old:
Hash.from_xml("<tag foo='bar'>\n</tag>")
=> {"tag"=>"\n"}

new:
Hash.from_xml("<tag foo='bar'>\n</tag>")
=> {"tag"=>{"foo"=>"bar", "__content__"=>"\n"}
2011-04-14 11:00:22 +02:00
Aaron Patterson
3940e345aa Merge branch '3-0-6' into 3-0-stable
* 3-0-6:
  bumping version to 3.0.6
  updating CHANGELOG
  updating CHANGELOG for actionpack
  do not return html safe strings from auto_link
  bumping to 3.0.6.rc2
  Support both conventions for translations for namespaced models.
  Added back the use of the Reflection module's cached sanitized_conditions in an AssociationProxy. This was recently removed and when a has_one association with conditions is eager loaded the conditions would be sanitized once for every result row, causing a database hit to fetch the columns.
  Bring back i18n_key to avoid regression
  Revert "Improve testing of cookies in functional tests:"
  bumping version to 3.0.6.rc1
  updating AR changelog
2011-04-05 16:20:03 -07:00
Aaron Patterson
38df020c95 bumping version to 3.0.6 2011-04-05 15:23:18 -07:00
Aaron Patterson
857ec16061 updating CHANGELOG 2011-04-05 15:22:40 -07:00
Aaron Patterson
6bb9efeb93 updating CHANGELOG for actionpack 2011-04-05 15:20:30 -07:00
Aaron Patterson
61ee344967 do not return html safe strings from auto_link 2011-04-05 13:59:35 -07:00
Josh Kalderimis
e6bc81837f remove AM delegating register_observer and register_interceptor to Mail and instead implement smarter versions allowing for string class names, also added proper Railtie support with tests
Signed-off-by: José Valim <jose.valim@gmail.com>
2011-04-05 20:47:39 +02:00
Durran Jordan
30264bb57b Destroying records via nested attributes works independent of reject_if:
- When a :_destroy truthiness is provided in the attributes hash, the
  record should get destroyed regardless of the result of the proc or
    method supplied to :reject_if. (If :allow_destroy is true)

[#6006 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-04-05 12:28:23 -03:00
Aaron Patterson
b13be616a1 bumping to 3.0.6.rc2 2011-03-30 22:26:41 -07:00
John Firebaugh
0307c538ec Support both conventions for translations for namespaced models.
3.0.0 - 3.0.1 required 'namespace/model'
3.0.2 - 3.0.5 required 'namespace.model' (nested). It has the advantage of
keeping the i18n file DRY when multiple models are in the same namespace,
but can lead to translation key conflicts if models are nested within
models.

[#6448, #5572]
2011-03-30 22:23:51 -07:00
John Firebaugh
5b8dbb0eee Support both conventions for translations for namespaced models.
3.0.0 - 3.0.1 required 'namespace/model'
3.0.2 - 3.0.5 required 'namespace.model' (nested). It has the advantage of
keeping the i18n file DRY when multiple models are in the same namespace,
but can lead to translation key conflicts if models are nested within
models.

[#6448, #5572]
2011-03-30 22:21:52 -07:00
Patrick Bacon
d6dbd54bec Added back the use of the Reflection module's cached sanitized_conditions in an AssociationProxy. This was recently removed and when a has_one association with conditions is eager loaded the conditions would be sanitized once for every result row, causing a database hit to fetch the columns. 2011-03-30 15:42:47 -07:00
Aaron Patterson
1f38cd7ac7 Merge branch 'eager_load_has_one_with_conditions_fix' of https://github.com/baconpat/rails into baconpat-eager_load_has_one_with_conditions_fix
* 'eager_load_has_one_with_conditions_fix' of https://github.com/baconpat/rails:
  Added back the use of the Reflection module's cached sanitized_conditions in an AssociationProxy. This was recently removed and when a has_one association with conditions is eager loaded the conditions would be sanitized once for every result row, causing a database hit to fetch the columns.
2011-03-30 15:39:27 -07:00
Santiago Pastorino
05f3df328c Bring back i18n_key to avoid regression 2011-03-30 15:37:29 -07:00
Santiago Pastorino
e413953cac Bring back i18n_key to avoid regression 2011-03-30 16:37:01 -03:00
Patrick Bacon
03852b6bcf Added back the use of the Reflection module's cached sanitized_conditions in an AssociationProxy. This was recently removed and when a has_one association with conditions is eager loaded the conditions would be sanitized once for every result row, causing a database hit to fetch the columns. 2011-03-29 20:44:11 -04:00
Aaron Patterson
ba117b2b43 Revert "Improve testing of cookies in functional tests:"
This reverts commit e2523ff683.
2011-03-29 13:38:24 -07:00
José Valim
4e2bacdf7c Pass the proper method_name instead of hardcoding to action_name. 2011-03-29 19:29:38 +02:00
Andrew White
3ed8a33197 Quote find_in_batches ORDER BY clause [#6620 state:resolved] 2011-03-29 17:25:56 +01:00
Andrew White
7f098a6696 Delegate any? and many? to scoped 2011-03-29 17:19:57 +01:00
Andrew White
827e5de60f Change exists? so that it doesn't instantiate records [#6127 state:resolved] 2011-03-29 13:09:17 +01:00
Aaron Patterson
f13fe8ff56 bumping version to 3.0.6.rc1 2011-03-28 13:32:09 -07:00
Aaron Patterson
90e9f2c2f4 updating AR changelog 2011-03-28 13:30:28 -07:00
Sebastian Martinez
235a4142aa Un-deprecate #reorder method
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-03-28 15:57:56 -03:00
Prem Sichanugrist
2dc297d0d7 Do not show optional (.:format) block for wildcard route [#6605 state:resolved]
This will make the output of `rake routes` to be correctly match to the behavior of the application, as the regular expression used to match the path is greedy and won't capture the format part by default

This commit is the second attempt on fixing the issue, as the regular expression on another commit on `master` was invalid.
2011-03-29 01:32:53 +08:00
Jeremy Kemper
86acbf1cc0 Cheaper attribute reads and respond_to?. Add underscore-prefixed method aliased to the attribute name so it can be overridden but still called internally. 2011-03-28 09:20:45 -07:00
Aaron Patterson
004fc1c694 cleaning up typecast test a little 2011-03-26 17:16:24 -07:00
Aaron Patterson
c9708ada21 refactoring tz to a variable rather than repeating it 2011-03-26 17:05:05 -07:00
Aaron Patterson
f28b08a7f7 adding a test for attributes after type cast. thanks nragaz. ❤️ 2011-03-26 11:47:20 -07:00
Aaron Patterson
7643dfd774 fixing whitespace errors. 💣 2011-03-26 11:24:46 -07:00
Jesse Storimer
9d7ef7967d Correct docs for after_find and after_initialize 2011-03-26 10:14:39 +00:00
Josh Kalderimis
c6b3b89d0e correction to the outputted controller name in the diagnostics error template, test included
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-03-24 19:46:11 -03:00
Andrew White
35de70fa2b Fix filter :only and :except with implicit actions
The method_name argument is "default_render" for implicit actions
so use the action_name attribute to determine which callbacks to run.

[#5673 state:resolved]
2011-03-23 23:29:54 +00:00
Adam Meehan
0823bbd757 Fix before_type_cast for timezone aware attributes by caching converted value on write. Also remove read method reload arg on timezone attributes. 2011-03-23 16:03:57 -07:00
Murray Steele
5d43977c7c Make clearing of HABTM join table contents happen in an after_destory callback.
The old method of redefining destroy meant that clearing the HABTM join table would happen as long as the call to destroy succeeded.  Which meant if there was a before_destroy that stopped the instance being destroyed using normal means (returning false, raising ActiveRecord::Rollback) rather than exceptional means the join table would be cleared even though the instance wasn't destroyed.  Doing it in an after_destroy hook avoids this and has the advantage of happening inside the DB transaction too.
2011-03-23 14:34:40 -07:00
Murray Steele
2f30cdc6ee Failing test case to show that habtm join table contents are removed when a model is destroyed but the destruction is blocked by a before_destroy. 2011-03-23 14:34:39 -07:00
Santiago Pastorino
63dca41fb6 use class_eval with a string when it's possible 2011-03-22 20:21:29 -03:00
Santiago Pastorino
1b7b724306 Allow to read and write AR attributes with non valid identifiers 2011-03-22 20:20:21 -03:00
Santiago Pastorino
7717fc375e Do not in place modify what table_name returns 2011-03-22 20:17:44 -03:00
Aaron Patterson
7222786c15 escaping binary data encoding when inserting to sqlite3. Thanks Naruse! [#6559 state:resolved] 2011-03-21 14:48:43 -07:00
Aaron Patterson
66c8c6cb0d oops, forgot to commit this test! 2011-03-21 11:39:24 -07:00
Aaron Patterson
eb1eac9315 schemas set by set_table_name are respected by the mysql adapter. [#5322 state:resolved] 2011-03-21 11:19:14 -07:00
Aaron Patterson
e508d9ebd7 updating ar changelog 2011-03-21 10:31:21 -07:00
Iain Hecker
b8ff5f0b67 Reapply extensions when using except and only 2011-03-21 10:16:06 -07:00
Santiago Pastorino
5ec780611c Update CHANGELOG entry 2011-03-17 23:21:30 -03:00
Santiago Pastorino
691530a19d Sync attribute_methods.rb with master code, tests added
[#6580 state:committed]
2011-03-17 23:18:10 -03:00
Santiago Pastorino
665065ca08 Add AMo CHANGELOG entry 2011-03-16 21:38:49 -03:00
Robert Pankowecki
c75e4aeca3 Fix when database column name has some symbolic characters. [#5818 state:resolved] 2011-03-16 21:21:50 -03:00
Santiago Pastorino
cb2c5c51cd Add number_to_human CHANGELOG entry 2011-03-16 15:21:00 -03:00
Josh Kalderimis
7c8a5f5759 fixes an issue with number_to_human when converting values which are less than 1 but greater than -1 [#6576 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-03-16 15:12:17 -03:00
Santiago Pastorino
1cbade35f9 Refactor length validation 2011-03-16 11:49:56 -03:00
Andrew White
c2b474af41 Remove invalid test
The test fails on PostgreSQL when trying to load the records as
the comments_count field is not included in the GROUP BY clause.
2011-03-13 08:51:24 +00:00
Santiago Pastorino
0d1ca43429 Add CHANGELOG entry 'Fix length validation for fixnums' 2011-03-12 21:17:58 -02:00
Andriy Tyurnikov
01cb81a66f length validation for fixnums
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-03-12 21:15:01 -02:00
Andrew White
3a22e74416 Fixed a bug when empty? was called on a grouped Relation that wasn't loaded
[#5829 state:resolved]
2011-03-12 22:38:36 +00:00
Santiago Pastorino
4a26cd04b5 require 'thread' in order to use Mutex 2011-03-12 14:05:46 -02:00
Rolf Timmermans
30dd1236b1 adds a couple of missing AS dependencies 2011-03-12 14:30:39 +01:00
Xavier Noria
c1f2d9be48 remove item in CHANGELOG that leaked in a merge 2011-03-11 00:38:32 +01:00
Prem Sichanugrist & Xavier Noria
434e451221 Filter sensitive query string parameters in the log [#6244 state:committed]
This provides more safety to applications that put secret information in the query string, such as API keys or SSO tokens.

Signed-off-by: Xavier Noria <fxn@hashref.com>
2011-03-11 00:23:45 +01:00
Andrew White
8dab7e5146 Filter params that return nil for to_param 2011-03-09 15:11:23 +00:00
Andrew White
824107b2ed Report the correct value of nil.id in the exception message
as different ruby implementations may have different values,
for example Rubinius returns 53 for nil.id.

[#6444 state:resolved]
2011-03-06 15:29:49 +00:00
Andrew White
e2523ff683 Improve testing of cookies in functional tests:
- cookies can be set using string or symbol keys
- cookies are preserved across calls to get, post, etc.
- cookie names and values are escaped
- cookies can be cleared using @request.cookies.clear

[#6272 state:resolved]
2011-03-06 12:59:52 +00:00
Andrew White
2437c78f40 Raise ArgumentError if route name is invalid [#6517 state:resolved] 2011-03-06 07:23:38 +00:00
José Valim
eff41a2c05 log and readme should respect --quiet 2011-03-04 13:06:04 +01:00
Santiago Pastorino
45d5663ec7 Add some CHANGELOG entries for 3.0.6 2011-03-02 13:50:18 -02:00
Santiago Pastorino
ea026f13ff Add missing versions to CHANGELOGs 2011-03-02 13:23:04 -02:00
Cheah Chu Yeow
beec6c8b2a Fix Action caching bug where an action that has a non-cacheable response always renders a nil response body. It now correctly renders the response body.
Note that only GET and HTTP 200 responses can be cached.

[#6480 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-03-02 13:14:18 -02:00
Aaron Patterson
cdfee8525b use a subclass of AS::TZ for testing html output 2011-02-28 16:30:25 -08:00
Josh Kalderimis
7180a326e7 Updated the AS guides with some information on the difference between Date.today and Date.current. 2011-02-28 14:04:44 -08:00
Josh Kalderimis
9ba0c7e216 updated Time, Date and DateTime current methods in AS to use Time.zone and not Time.zone_default.
[#6410 state:committed]
2011-02-28 14:04:43 -08:00
Santiago Pastorino
4c681f6ec5 javascript_include_tag shouldn't raise if you register an expansion key with nil or [] value 2011-02-28 12:01:06 -02:00
Santiago Pastorino
ff95f858d6 Add a test for passing :rescue_format => nil to #translate
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-28 10:31:01 -02:00
Sven Fuchs
1452571dee Make TranslationHelper#translate use the :rescue_format option in I18n 0.5.0 (backports 896e25e)
Don't catch exceptions here. Instead only declare that we want exceptions to be rescued as :html, but also let users configure reactions to exceptions in I18n.

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-28 10:30:50 -02:00
Santiago Pastorino
f80eea3bf3 Revert "Properly interpolate i18n keys in modules [#5572 state:resolved]"
This breaks #6448, you should use :"module/class" as key for namespacing
[#6448 state:committed]

This reverts commit 8d14fa8959.
2011-02-27 21:47:12 -02:00
Santiago Pastorino
d043d20eb0 failing test for i18n key collision with namespaced models 2011-02-27 21:44:26 -02:00
Santiago Pastorino
f7e17032e8 Bump i18n version 2011-02-27 19:13:09 -02:00
Aaron Patterson
ef5e817567 Merge branch '3-0-5' into 3-0-stable
* 3-0-5:
  prepping for 3.0.5 release
2011-02-26 18:29:20 -08:00
Aaron Patterson
ecc6bb597f prepping for 3.0.5 release 2011-02-26 18:20:22 -08:00
Prem Sichanugrist
2a67e69f1f Always use ActionDispatch::ShowExceptions middleware [#6462 state:resolved]
This will make sure the application will raise `ActionController::RoutingError` in case "X-Cascade: pass" header was set, usually when there's no route match.

(This is a backported version to 3-0-stable)
2011-02-25 10:38:15 -08:00
Prem Sichanugrist
69c0badec5 Make sure that we set env["action_dispatch.show_exceptions"]
This has been used by `show_exception` middleware even the setting wasn't get passed to `env` hash.

(This is the backported version to 3-0-stable)
2011-02-25 10:38:01 -08:00
Aaron Patterson
77d4211a62 observers leak across tests, so rather than modify the object, we should just count the number of times the observer was called 2011-02-23 16:06:46 -08:00
Aaron Patterson
ef31b87d82 updating to 3.0.5.rc1 2011-02-22 16:53:08 -08:00
Kamal Fariz Mahyuddin
ee491b064b Fix observer callbacks firing multiple times on descendant instances 2011-02-22 16:52:46 -08:00
Aaron Patterson
30a0e3f6d6 silencing deprecation spam 2011-02-22 12:08:37 -08:00
Michael Koziarski
90aede6771 Prepend the CSRF filter to make it much more difficult to execute application code before it fires. 2011-02-23 08:59:13 +13:00
Aaron Patterson
ac73f50e13 adding a test case for custom locking 2011-02-21 16:11:52 -08:00
Aaron Patterson
3ab82d8ad1 Gem.cache is going to be deprecated, use source_index instead 2011-02-21 13:58:24 -08:00
Frederick Cheung
d7b539aae2 Change validates inclusion to use cover? for Ranges in ruby 1.9 [#6453 state:committed]
Signed-off-by: Xavier Noria <fxn@hashref.com>
2011-02-18 21:32:01 +01:00
Aaron Patterson
ff5db1840e updating changelog 2011-02-17 08:52:24 -08:00
Aaron Patterson
41c35abed7 explicitly anding queries of the same column 2011-02-16 15:22:48 -08:00
Timothy N. Tsvetkov
149c3d687a Fixed issue #6363, avoid to pluralized already pluralized names and singularize a single in generators, for example stadia is a valid plural for stadium. But calling pluralize for stadia will return stadias which sematically is not corrent in this case
[#6363 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-16 15:31:11 -02:00
Dan Pickett
e925acb826 handle double pluralization for irregular plurals
[#6363]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-16 15:31:07 -02:00
Joel Nimety
0cee3034c4 GcTime incorrectly checks GC.respond_to?(:total_time), it should check GC::Profiler.respond_to?(:total_time)
[#6435 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-15 20:14:28 -02:00
Sergii Boiko
e08873fb24 fixed broken link to postgresql docs
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-15 12:01:48 -02:00
Aaron Patterson
2b8fad603f Merge remote branch 'jonleighton/deprecate_string_interpolation-3-0-stable' into 3-0-stable
* jonleighton/deprecate_string_interpolation-3-0-stable:
  Deprecated support for interpolated association conditions with the :conditions => 'foo = #{bar}' syntax, and added the new interpolation syntax which is :conditions => proc { "foo = #{bar}" }.
2011-02-14 11:52:32 -08:00
Andrew White
abea073dda Add test to prevent regression on namespace root nested in a resource
[#6389 state:resolved]
2011-02-14 06:16:37 +00:00
Andrew White
64ca278176 Fix named route helper for routes nested inside deeply nested resources
[#6416 state:resolved]
2011-02-14 03:03:24 +00:00
Andrew White
b4205b40ee Add notes on how to override the default :id constraint [#5994 state:resolved] 2011-02-14 00:58:58 +00:00
Andrew White
c6ab3d1b78 Remove incorrect assert_recognizes example 2011-02-14 00:09:59 +00:00
Andrew White
cb9745b82d Remove incorrect assert_recognizes example 2011-02-13 23:11:01 +00:00
Andrew White
e9ae88af20 Fix assert_recognizes with block constraints [#5805 state:resolved] 2011-02-13 23:09:20 +00:00
Jon Leighton
756e70cb44 Deprecated support for interpolated association conditions with the :conditions => 'foo = #{bar}' syntax, and added the new interpolation syntax which is :conditions => proc { "foo = #{bar}" }. 2011-02-13 22:39:44 +00:00
Ernie Miller
66003f5964 Deprecate Relation#& alias for Relation#merge 2011-02-12 17:05:56 -08:00
Santiago Pastorino
22d1fee921 Make gem "ruby-debug19" require ruby-debug 2011-02-12 22:44:35 -02:00
Wojciech Wnętrzak
9c6f9c98b8 added proper require for ruby-debug19 gem to generated Gemfile
[#6419 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-12 22:39:56 -02:00
Santiago Pastorino
4145810150 Backport fix from master: fields_for with inline blocks and nested attributes already persisted does not render properly
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-12 16:42:29 -02:00
Carlos Antonio da Silva
640b1f0fab Add tests showing the LH issue #6381: fields_for with inline blocks and nested attributes already persisted
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-12 16:42:11 -02:00
Akira Matsuda
cb045c02c7 do not to_s where you are testing that a string value is stored for the before_type_cast
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-12 13:58:41 -02:00
Akira Matsuda
6e04f58f0e avoid nil.dup
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-12 13:58:30 -02:00
Josh Kalderimis
73b9e43f5d Updated the json date regex to recognize xmlschema formatted date times during json decoding. [#3031 state:resolved]
Signed-off-by: Santiago Pastorino and Emilio Tagua <santiago+emilioe@wyeworks.com>
2011-02-12 13:33:05 -02:00
Josh Kalderimis
e605165d16 Fixes an issue when decoding a json string which looks like a date but is invalid. This DateTime parse error is now caught and the original string is instead passed back [#6286 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-12 13:32:12 -02:00
Aaron Patterson
4dc5505e18 psych does not emit a space after the type 2011-02-11 14:44:00 -08:00
Aaron Patterson
cab7cb4aa0 no more text-format for Ruby 1.9 compatibility 2011-02-11 14:41:35 -08:00
Aaron Patterson
4433b507a0 skip this test on mysql2 as well 2011-02-11 10:12:14 -08:00
Carlos Antonio da Silva
401ee98dac Add missing deprecation require
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-11 13:30:39 -02:00
Xavier Noria
3306314c50 now that the API guidelines are a guide, it is enough to assert that the names of Rails components have a space, no need to say it was checked with David in the past 2011-02-09 20:05:51 +01:00
Xavier Noria
01ca46bba9 getting started guide: the generated application README has no extension 2011-02-09 19:59:38 +01:00
Ken Collins
7530c5224c Allow limit values to accept an ARel SQL literal. 2011-02-09 08:32:17 -08:00
Santiago Pastorino and Emilio Tagua
54dca9864e Add missing require 2011-02-09 08:37:16 -02:00
Josh Kalderimis
31690ea8b3 fix for AS Gzip returning a UTF-8 string in Ruby 1.9 when it is actually binary [#6386 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2011-02-09 10:27:26 +01:00
Aaron Patterson
ff00cd2844 comma limits do not make sense on oracle or pg 2011-02-08 16:45:16 -08:00
Xavier Noria
27b8fb56c3 adds RedCloth to the Gemfile, and defines a :doc group 2011-02-09 01:24:18 +01:00
Michael Koziarski
84d608b406 Merge branch '3-0-4-security' into 3-0-stable 2011-02-09 10:29:44 +13:00
Michael Koziarski
1081ea66a3 Prepare for the 3.0.4 release 2011-02-09 09:18:48 +13:00
Santiago Pastorino
f2d0257237 Remove stupid mistake 2011-02-04 21:50:26 -02:00
Santiago Pastorino
d00ed5af77 git am is better here 2011-02-04 21:36:40 -02:00
Edward Faulkner
e142159de6 Fixing ordering of HABTM association deletion [#6191 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-04 19:40:29 -02:00
Ken Collins
068527baaf The type_cast_calculated_value method will trust DB types before casting to a BigDecimal.
[#6365 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-03 20:15:03 -02:00
Anton Astashov
53b0235282 Add a test for 'render :layout'
To make sure it will show block contents if it is placed after 'render
:partial'

[#5557 state:resolved]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-03 13:10:13 -02:00
Raimonds Simanovskis
8a73ebbcd6 fix for test_read_attributes_before_type_cast_on_datetime - Oracle adapter also returns Time value 2011-02-02 09:01:41 -08:00
Saimon Moore
effb582955 Ensure I18n setup is only executed once if triggered on eager loading [#6353 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-01 15:42:20 -02:00
Saimon Moore
979f38a4ff Additionally trigger i18n configuration setup before any eager loading [#6353 state:resolved]
This handles the case where config.cache_classes is true and classes
are loaded before the I18n load path has had a chance to be populated.

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-01 15:42:12 -02:00
Akira Matsuda
4e6a1026b7 before_type_cast on Datetime tests for Mysql2Adapter
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-01 12:23:43 -02:00
Akira Matsuda
c8b7606734 Make before_type_cast available for datetime fields
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-01 12:23:43 -02:00
Michael Koziarski
7b64adecf1 Make rails.js include the CSRF token in the X-CSRF-Token header with every ajax request. 2011-02-01 09:09:02 +13:00
Michael Koziarski
66ce3843d3 Change the CSRF whitelisting to only apply to get requests
Unfortunately the previous method of browser detection and XHR whitelisting is unable to prevent requests issued from some Flash animations and Java applets.  To ease the work required to include the CSRF token in ajax requests rails now supports providing the token in a custom http header:

 X-CSRF-Token: ...

This fixes CVE-2011-0447
2011-02-01 09:08:54 +13:00
Aaron Patterson
354da43ab0 limit() should sanitize limit values
This fixes CVE-2011-0448
2011-02-01 09:08:53 +13:00
José Valim
ad9d21d0d6 Use Mime::Type references. 2011-02-01 09:08:53 +13:00
José Valim
6f80224057 Ensure render is case sensitive even on systems with case-insensitive filesystems.
This fixes CVE-2011-0449
2011-02-01 09:08:47 +13:00
Michael Koziarski
e3dd2107c5 Be sure to javascript_escape the email address to prevent apostrophes inadvertently causing javascript errors.
This fixes CVE-2011-0446
2011-02-01 08:45:59 +13:00
José Valim
0448247e55 Fix AM tests 2011-01-31 11:10:02 +01:00
Michael Koziarski
0cbf9b2946 Prepare for the 3.0.4 release 2011-01-31 10:36:49 +13:00
Mikel Lindsaar
54e72a5c30 Fix gitignore to ignore tmp/ correctly, credit telemachus 2011-01-30 00:09:00 +11:00
Santiago Pastorino
5f509c2df4 Bump mail version up 2011-01-28 21:18:04 -02:00
Aaron Patterson
f420c2ece8 Merge remote branch 'jonleighton/deprecate_habtm_attributes-3-0-stable' into 3-0-stable
* jonleighton/deprecate_habtm_attributes-3-0-stable:
  Added deprecation warning for has_and_belongs_to_many associations where the join table has additional attributes other than the keys. Access to these attributes is removed in 3.1. Please use has_many :through instead.
2011-01-24 09:03:25 -08:00
Jamis Buck
683cb50f44 Revert "make TestCaseTest work for pre-1.9 rubies, too"
This reverts commit fd19aded49.
2011-01-19 15:56:18 -07:00
Jamis Buck
e5664b5046 Revert "scrub instance variables from test cases on teardown"
This reverts commit 1e989208ce.
2011-01-19 15:56:17 -07:00
Jamis Buck
039b807afd Revert "rein in GC during tests by making them run (at most) once per second"
This reverts commit 35984f50ec.
2011-01-19 15:56:14 -07:00
José Valim
46b23f8a7a Solve SystemStackError when changing locale inside ActionMailer [#5329 state:resolved] 2011-01-19 23:43:02 +01:00
Frank Fischer
b4bc49c673 Added a testcase for bug [#5329]
Signed-off-by: José Valim <jose.valim@gmail.com>
2011-01-19 23:42:54 +01:00
Jamis Buck
35984f50ec rein in GC during tests by making them run (at most) once per second
this can provide a significant performance boost during testing, by
preventing the GC from running too frequently.
2011-01-19 10:44:20 -07:00
Jamis Buck
1e989208ce scrub instance variables from test cases on teardown
this prevents test state from accumulating, resulting in leaked
objects and slow tests due to overactive GC.
2011-01-19 10:42:11 -07:00
Jamis Buck
fd19aded49 make TestCaseTest work for pre-1.9 rubies, too 2011-01-19 10:31:58 -07:00
Aaron Patterson
97d47661d7 Changing sqlite3-ruby to sqlite3. backporting 8f88a28416 to 3-0-stable. 2011-01-18 14:04:07 -08:00
Michael Koziarski
64c1cb3b3c Use the derived request_method from AD::Request rather than the raw REQUEST_METHOD from rack.
This takes _method into account so the log shows the method which ActionController sees.
2011-01-18 14:43:03 +13:00
Aaron Patterson
a58670b863 minitest added @__io__, so we should ignore it too 2011-01-17 14:53:59 -08:00
Jon Leighton
bcbff10fd7 Added deprecation warning for has_and_belongs_to_many associations where the join table has additional attributes other than the keys. Access to these attributes is removed in 3.1. Please use has_many :through instead. 2011-01-16 22:32:02 +00:00
Aaron Patterson
9d87f410f0 updating sqlite3-ruby => sqlite3 2011-01-16 12:56:17 -08:00
Santiago Pastorino
460f17368f sorry, the CI cannot lie to us anymore (Part II) 2011-01-13 10:56:08 -02:00
Santiago Pastorino
f4dcf19982 One more missing require 2011-01-13 10:00:37 -02:00
Santiago Pastorino
0f5e815c86 Add missing require 2011-01-13 09:58:50 -02:00
Aaron Patterson
10fa49bc1a include_in_memory? should check against @target list in case of new records. [#6257 state:resolved] 2011-01-12 18:07:24 -08:00
Santiago Pastorino
3667438da3 Allow generators nested in more than one level 2011-01-12 21:43:37 -02:00
Xavier Noria
5de1314dd9 upgrades RDoc and horo dependencies
RDoc 2.x was missing some stuff, let's align this with master
2011-01-12 21:28:49 +01:00
Santiago Pastorino
acecf0059e Reuse the view_context from the controller, this make the test environment more similar to the code applications uses 2011-01-12 17:09:45 -02:00
Aaron Patterson
58f90b206f remove locales external to the system before assertion 2011-01-12 10:44:35 -08:00
Aaron Patterson
88747336e8 use raise to create exceptions and to set the backtrace 2011-01-12 10:28:21 -08:00
Aaron Patterson
20062e7dc1 reraising should be in the rescue block 2011-01-12 10:01:31 -08:00
Aaron Patterson
4781673deb sorry, the CI cannot lie to us anymore 2011-01-12 09:46:56 -08:00
Josh Kalderimis
35d5b644ed Fixed various isolated test missing requires within AS.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-01-12 13:17:02 -02:00
Josh Kalderimis
c6d541402e In AS, only inflector/methods is need in proxy_wrappers.rb, as well as date, date_time, and time conversions.rb. This fixes an issue when requiring json and AS saying that i18n is also required.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-01-12 13:16:56 -02:00
Santiago Pastorino
3f247cb06d Allow view in AV::TestCase to access it's controller helpers methods 2011-01-12 12:43:03 -02:00
Santiago Pastorino
3b9e72b537 CI should run isolated tests 2011-01-12 12:39:33 -02:00
Ernie Miller
97eddc057d Fix polymorphic belongs_to associationproxy raising errors when loading target. 2011-01-11 09:21:06 -08:00
Aaron Patterson
2cb497b70c adding to_d to BigDecimal 2011-01-10 15:43:21 -08:00
Raimonds Simanovskis
e1a064ac3e Always return decimal average of integer fields
In previous version if database adapter (e.g. SQLite and Oracle) returned non-String calculated values then type_cast_using_column converted decimal average value of intefer field to integer value. Now operation parameter is always checked to decide which conversion of calculated value should be done.
2011-01-10 15:29:58 -08:00
Aaron Patterson
b7e5a64e16 use SQLite3::VERSION rather than the deprecated class 2011-01-10 11:36:23 -08:00
Aaron Patterson
09f37367f8 calculate to_s on the primary key once 2011-01-10 11:31:04 -08:00
Tomasz Pajor
2deaa2566f primary_key is returned as either string or symbol, in columns loop map everything to string 2011-01-10 11:28:47 -08:00
Krekoten' Marjan
117cad8f05 Refactor to handle the X-Cascade without having to raise an exception 2011-01-09 16:09:03 -08:00
Tomasz Pajor
9933859b73 use Object#class instead of Object#type 2011-01-09 15:47:52 -08:00
John Allison
9ab3cebe9f Improve select helpers by allowing a selected value of false. This is useful when using a select helper with a boolean attribute, and the attribute is false. (e.g. f.select :allow_comments) 2011-01-09 15:46:08 -08:00
Larry Sprock
9bc338ed2f Backport tests for subclassed arrays 2011-01-09 15:39:49 -08:00
Hemant Kumar
05da752847 fix difference between behaviour of blank and empty
Signed-off-by: José Valim <jose.valim@gmail.com>
2011-01-05 13:18:58 +01:00
Pratik Naik
b7bb795fd3 Bump rack-test version 2011-01-04 19:32:18 +00:00
Robert Pankowecki (Gavdi)
e95b5b301e Use id instead of quoted_id to prevent double quoting. Fixes failing test for bug #6036. 2011-01-04 01:24:40 +08:00
Robert Pankowecki (Gavdi)
af2999d364 Added one more failing test for bug #6036 2011-01-04 01:24:40 +08:00
Prem Sichanugrist
6ae9e9b9af Make sure that generator's default banner is showing its namespace
This will make `rails g rspec:install --help` shows "rails generate rspec:install [options]" and not "rails generate install  [options]"
2011-01-01 12:20:46 -08:00
Pratik Naik
a49a84f269 Make sure Model#touch doesn't try to update non existing columns 2010-12-30 18:43:50 +00:00
Xavier Noria
1a26036136 contrib_guide.gsub!("aptitude", "apt-get")
It turns out aptitude has been removed from Ubuntu 10.10
and while you can manually install it, apt-get is the
blessed package manager. Google for "aptitude removed
from Ubuntu" for more details. Thanks to Rafael Mendonça
França for pointing this out.
2010-12-30 07:14:07 +01:00
Nick Sutterer
8d1a318e9a process_action accepts multiple args, even with Callbacks. 2010-12-29 19:07:36 -08:00
Xavier Noria
a2ddf5a0c6 renames the contrib guide in the index 2010-12-29 23:44:25 +01:00
Xavier Noria
b9dd3f95ac since a lot of people use Ubuntu, document specific aptitude calls for some C dependencies in the contrib guide 2010-12-29 23:44:24 +01:00
Pratik Naik
b5dc2a2f48 Make serialized fixtures work again
Conflicts:

	activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
	activerecord/test/cases/base_test.rb
	activerecord/test/cases/quoting_test.rb
2010-12-29 18:18:16 +00:00
Xavier Noria
3b35ff451a complete revision of the Contributing to Ruby on Rails guide
* adds instructions for PostgreSQL
* adds references to mysql2 here and there
* puts documentation contributions on par with code contributions
* adds a section about Rails Contributors
* documents C dependencies for Nokogiri and the database libs
* everything double-checked and revised step by step
* adds a section about warnings in the test suite
* removes section about the Rails wiki
* title and filename renamed
* overall rewording
2010-12-28 20:37:25 +01:00
Jon Leighton
e4b384222c Fix problem where wrong keys are used in JoinAssociation when an association goes :through a belongs_to [#2801 state:resolved] 2010-12-23 15:46:37 +00:00
Jon Leighton
90f55bd93b Test to verify that #2189 (count with has_many :through and a named_scope) is fixed [#2189 state:resolved] 2010-12-23 15:45:45 +00:00
Xavier Noria
bbb2252235 API guidelines: RDoc markup documentation has been moved in RDoc 3 2010-12-23 00:24:52 +01:00
Santiago Pastorino
70dba7414b This can make make included javascripts/stylesheets from expansions to be duplicated
or grow forever if you call register_*_expansion more than once

Fix a Regression introduced here 55b13c532f
2010-12-22 21:07:53 -02:00
Santiago Pastorino
053031b3cc Avoid Bundler Resolver bug until they solve the issue 2010-12-22 19:32:41 -02:00
Piotr Sarnacki
725817e53a Ensure that uncountable are removed after test 2010-12-22 09:47:06 +01:00
John Paul Ashenfelter
cad4f00309 Added a word boundary to uncountable inflection regex for #singularize so short inflections like ors do not affect larger words like sponsors [#6093 state:resolved] 2010-12-22 09:46:58 +01:00
Piotr Sarnacki
d4cf636207 Fix activesupport tests. These classes are not used anywhere 2010-12-22 09:46:47 +01:00
David Heinemeier Hansson
c09c8be356 Merge branch '3-0-stable' of github.com:rails/rails into 3-0-stable 2010-12-18 13:02:39 -08:00
Piotr Sarnacki
f2fc81fe90 Use gemspec instead of gem rails in Gemfile 2010-12-18 19:46:23 +01:00
Don Wilson
177749b8bf Fixed number_with_precision rounding error [#6182 state:resolved] 2010-12-18 10:48:37 +01:00
Piotr Sarnacki
0646c706e6 Use require 'bundler/setup' instead of directly calling Bundler.setup in config/boot.rb 2010-12-17 19:29:33 +01:00
Piotr Sarnacki
d1b4f3ba9f Allow to use BUNDLE_GEMFILE env variable in boot.rb [#6184 state:resolved] 2010-12-17 16:06:38 +01:00
Vijay Dev
acd716b06e fixed link to ruby-prof 2010-12-15 20:49:12 +01:00
Vijay Dev
0a42961899 fixed font 2010-12-15 20:49:06 +01:00
Vijay Dev
34ed401063 filter_parameter_logging is deprecated in Rails 3. Changed it to config.filter_parameters 2010-12-15 20:49:04 +01:00
Aditya Sanghi
dfecb3f6f3 eternal confusion! fixed doco to inform correctly 2010-12-15 20:49:02 +01:00
Ryan Bigg
3392b56de7 Active Support coreext guide: Logger core extension documentation 2010-12-15 20:49:00 +01:00
Elben Shira
463522afc5 It should be ActiveModel::Validator, not ActiveRecord::Validator. 2010-12-15 20:48:47 +01:00
Ben Mills
becb008223 Added :placeholder option to ActionView::Helpers::FormTagHelper text_field_tag 2010-12-15 20:48:44 +01:00
Umar Sheikh
8fdf5315ab for the root route to work, we need to delete the public/index.html.erb
file as well
2010-12-15 20:48:00 +01:00
Ryan Bigg
6bf482ec59 Fix indentation on the namespace method's documentation 2010-12-15 20:47:56 +01:00
Ryan Bigg
7e0cc4344d Remove nodoc from FormBuilder because the methods inside are public API methods 2010-12-15 20:47:52 +01:00
Vijay Dev
f840d5c24b fixed typos in mailer 2010-12-15 20:47:21 +01:00
vijay
8000719923 fixed typos and rephrased a few sentences; also removed reference to status codes being located in action_controller/status_codes.rb 2010-12-15 20:44:47 +01:00
Paul Odeon
ee9fea67dd Updated generator guide for rails commit 7891de8939 2010-12-15 20:40:20 +01:00
Ryan Bigg
f5c15a481b Provide an example for ActionDispatch::Routing::Mapper#scope 2010-12-15 20:40:17 +01:00
Xavier Noria
9254750223 reviews commit 53bbbcc 2010-12-11 01:10:29 +01:00
Xavier Noria
37b9d02616 spaces with underscores, I mean 2010-12-11 01:10:27 +01:00
Xavier Noria
01c76d59e8 testing guide: revises explanation of the test macro 2010-12-11 01:10:07 +01:00
vijay
51202a1aea fixed typos and rephrased few sentences in routing 2010-12-11 01:09:19 +01:00
Ryan Bigg
6276334da9 Action Controller Overview: Remove dead link to the API docs for filters 2010-12-11 01:02:45 +01:00
Ryan Bigg
55a232a164 root method options are the same as the match method 2010-12-11 01:01:00 +01:00
Ryan Bigg
d575229ea4 root route should go at the *top* of the routes file, because it is the most popular route and should be matched first 2010-12-11 01:00:59 +01:00
Ryan Bigg
d3d23e2539 indent code samples for mount doc 2010-12-11 01:00:58 +01:00
Ryan Bigg
eb683d795a mapper.rb: add "options" to make the default-to-namespace-name line read better 2010-12-11 01:00:57 +01:00
Ryan Bigg
44f33805f8 Move ActiveModel::Lint::Tests documentation to be above module declaration so it appears in the API docs for this module. 2010-12-11 01:00:56 +01:00
Ryan Bigg
8aec8b88d4 Config guide: Use bold titles for initializers instead of headings. 2010-12-11 01:00:55 +01:00
Ryan Bigg
72476b6c8e Add note which links to documentation regarding the types of columns available. 2010-12-11 01:00:54 +01:00
Ryan Bigg
85a940f1a6 Config guide: Space out initialization events to improve readability 2010-12-11 01:00:52 +01:00
Ryan Bigg
f0029d0c05 Config guide: add further initializers 2010-12-11 01:00:51 +01:00
Ryan Bigg
92668f68a7 Config guide: add session store config option 2010-12-11 01:00:50 +01:00
Ryan Bigg
9d933581ec Config guide: eager_load_paths by default contains every directory in the app directory 2010-12-11 01:00:49 +01:00
Ivan Evtukhovich
3a62526294 Fix doc about nested transaction rollback
Because AR::Rollback do not reraise and inner transaction is not "real"
nothing rollback at all
2010-12-11 01:00:48 +01:00
Lucas Catón
6103f8ff4b Fix link on generations' page 2010-12-11 01:00:46 +01:00
Vijay Dev
ab880742de fixed typo in test method name 2010-12-11 01:00:15 +01:00
Samus_
b4b6ffe114 typo 2010-12-11 00:58:34 +01:00
Matthew Rudy Jacobs
d2003a2071 Cleaner way to extract the Postgres version 2010-12-09 11:36:55 -08:00
Matthew Rudy Jacobs
f33968ab7a Fix Bug: disable_referential_integrity doesn't work for postgres 9.0.1 2010-12-09 11:36:50 -08:00
Robert Pankowecki (Gavdi)
61f2d52d8a Simplifies observer implementation [#6065 state:resolved] 2010-12-09 10:43:42 -08:00
Aaron Patterson
60744d22cb just wrap as a sql literal 2010-12-09 09:39:47 -08:00
Neeraj Singh
d67464a160 Do not send id for quoting twice if the primary key is string.
[#6022 state:resolved]
2010-12-09 09:39:47 -08:00
Neeraj Singh
890d005d50 Ensure that while caching a page rails takes into
account the resolved mime type for the request

This is a port of fix on master to 3-0-stable

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-12-09 16:54:11 +01:00
Mike Dvorkin
6dcde27f3a Take into account current time zone when serializing datetime values [#6096 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-12-09 09:09:25 +01:00
Aditya Sanghi
97e9d8860b Ensure that boolean false is properly serialized [#6079 state:resolved] 2010-12-08 15:55:07 -08:00
Xavier Noria
75faf54449 makes a pass to the action caching rdoc 2010-12-08 21:31:06 +01:00
Neeraj Singh
ee6b45acb3 Add to documentation that action caching does
handle HTTP_ACCEPT attribute properly and might
provide wrong result. Use params[:format] to
avoid this issue.
2010-12-08 21:29:26 +01:00
Ryan Bigg
13a7302693 Config guide: continuing work on documenting the initializers 2010-12-05 10:40:09 +01:00
Ryan Bigg
2484b7e92b Config guide: begin documenting the initializers 2010-12-05 10:40:08 +01:00
Ryan Bigg
85ced0fc1f Config guide: Add javascript_expansions and stylesheet_expansions 2010-12-05 10:40:07 +01:00
Ryan Bigg
f0d893d518 Config guide: should use config.action_dispatch.tld_length to set the TLD 2010-12-05 10:40:07 +01:00
Ryan Bigg
1a7958d955 Config guide: Add cache_asset_ids 2010-12-05 10:40:06 +01:00
Ryan Bigg
488992fb6d Config guide: add tld_length to ActionDispatch section 2010-12-05 10:40:04 +01:00
Ryan Bigg
202159680a Remove extra f 2010-12-05 10:40:03 +01:00
Ryan Bigg
7174f147ec Config guide: Mention ActionDispatch::Callbacks methods: before, to_prepare and after 2010-12-05 10:40:02 +01:00
Ryan Bigg
c3e8bf0b41 Config guide: clarify what cache_store defaults to. 2010-12-05 10:40:02 +01:00
Ryan Bigg
f02c89f6c1 Clarify that preload_frameworks defaults to nil 2010-12-05 10:40:01 +01:00
Ryan Bigg
4e2f94732e Config guide: Add config.active_support.bare 2010-12-05 10:40:00 +01:00
Ryan Bigg
e523adbdf5 Config guide: separate the initialization events and initializer method documentation 2010-12-05 10:39:59 +01:00
Ryan Bigg
b181968aa7 Move Rails Environment settings to above the initialization events in the config guide 2010-12-05 10:39:59 +01:00
Ryan Bigg
f7c85da521 Configuring guide: Adding mention of the initializer method. 2010-12-05 10:39:58 +01:00
Ryan Bigg
ceb650a4a2 Config guide: Rails has *5* initialization events 2010-12-05 10:39:57 +01:00
Ryan Bigg
350818f281 Add mention of config.to_prepare in configuring guide 2010-12-05 10:39:56 +01:00
Ryan Bigg
741f7b500f Add missing colons on the end of before_initialize and after_initialize documentation in configuring guide 2010-12-05 10:39:55 +01:00
Ryan Bigg
a86be8cb35 Finish documenting generator / template methods for the generators guide 2010-12-05 10:39:54 +01:00
Ryan Bigg
9177e930fd Add gem method documentation to the generators guide 2010-12-05 10:39:53 +01:00
Ryan Bigg
4548c84e15 For templates' gem method, :env is deprecated, use :group instead 2010-12-05 10:39:52 +01:00
Ryan Bigg
feab0b8ad5 Covering generator methods provided by Rails in the generators guide 2010-12-05 10:39:51 +01:00
Ryan Bigg
40f7246cdc Begin covering application templates in the generators guide 2010-12-05 10:39:51 +01:00
Ryan Bigg
198c126d73 Mention that the documentation of create_file can be found on rdoc.info ino the generators guide 2010-12-05 10:39:50 +01:00
Neeraj Singh
2b26ba64a5 Rewording existing comment 2010-12-05 10:39:49 +01:00
Neeraj Singh
30d7a71bf0 Add comment for config_accessor method 2010-12-05 10:39:49 +01:00
Neeraj Singh
e6f2ef3a15 Rewording existing comment 2010-12-05 10:39:48 +01:00
Ryan Bigg
554e89f2cf Add perform_caching to config guide 2010-12-05 10:39:47 +01:00
Ryan Bigg
36fd1a9d40 Add documentation for page_cache_directory and page_cache_extension to config guide 2010-12-05 10:39:47 +01:00
Ryan Bigg
7d334c492f re-add config.action_controller.asset_host and asset_path to config guide 2010-12-05 10:39:46 +01:00
Ryan Bigg
abc7e38651 Bring order description in line with actual text. 2010-12-05 10:39:45 +01:00
Ryan Bigg
00fb5dc59d Use ARel for Range Conditions section, remove Date & Time section because users should *never* do that. 2010-12-05 10:39:44 +01:00
Ryan Bigg
04507acdb7 Fix documentation regarding the initialization events of the Rails stack 2010-12-05 10:39:44 +01:00
Ryan Bigg
a416766f58 asset_host and asset_path are now set at the global level 2010-12-05 10:39:43 +01:00
Ryan Bigg
b6bcfcb826 Reorder logger and middleware global config options 2010-12-05 10:39:42 +01:00
Ryan Bigg
730480abf0 Add mention of helper_paths to config guide 2010-12-05 10:39:42 +01:00
Ryan Bigg
78b480c2bd Mention encoding in config guide 2010-12-05 10:39:41 +01:00
Ryan Bigg
195d0b7744 Add asset_host and asset_path to the configuring guide 2010-12-05 10:39:40 +01:00
Ryan Bigg
ebc52a8fd4 No more app_generators method in 3.1 2010-12-05 10:39:39 +01:00
Ryan Bigg
95ac8b08a0 Mention controller_paths in the config guide 2010-12-05 10:39:39 +01:00
Ryan Bigg
9dc463b178 Move threadsafe warning to threadsafe's new location in config guide 2010-12-05 10:39:38 +01:00
Ryan Bigg
5969a847ed Move consider_all_requests_local to global config methods in config guide 2010-12-05 10:39:37 +01:00
Ryan Bigg
cbea902c2f Change coloriz_logging description to follow the standard for this guide 2010-12-05 10:39:37 +01:00
Ryan Bigg
08f6b4e941 Mention threadsafe! method in config guide 2010-12-05 10:39:36 +01:00
Ryan Bigg
a99dc086fc allow_concurrency is a "global" configuration option in Rails 3 2010-12-05 10:39:36 +01:00
Ryan Bigg
cbe64d01f5 Add documentation for secret_token to config guide 2010-12-05 10:39:35 +01:00
Ryan Bigg
27ce3e26ff Mention filter_parameters for config 2010-12-05 10:39:34 +01:00
Neeraj Singh
8ff7cd91bf make it clear that recompilation happens only in
development mode
2010-12-05 10:39:34 +01:00
Akira Matsuda
97e8bf6599 s/myqsl/mysql/ 2010-12-05 10:39:33 +01:00
Akira Matsuda
7da5f75875 Added a space before "do" keyword 2010-12-05 10:39:33 +01:00
Aditya Sanghi
c793baaf01 grammar fix 2010-12-05 10:39:32 +01:00
Aditya Sanghi
b05b8d9aa4 Resolves LH #6063, should be :expires_in not :expire_in 2010-12-05 10:39:32 +01:00
Ryan L. Cross
1c6effc8b1 Corrected typo and wording. 2010-12-05 10:39:31 +01:00
Greg Jastrab
6f328094ef fixed example code for i18n exception handling 2010-12-05 10:39:30 +01:00
Jared Crapo
6f6a24eaa8 Fixed typo in code for Session Expiry 2010-12-05 10:39:29 +01:00
Peter Baker
4808875bb7 Explain actionamailer authentication types 2010-12-05 10:39:27 +01:00
Aaron Patterson
873616c8e7 adding a test for YAML round trip 2010-12-02 08:44:31 -08:00
Aaron Patterson
c42a7c65c0 fixing space errors 2010-12-02 08:41:54 -08:00
Michael Koziarski
9381eb3dc3 Work around a strange piece of Syck behaviour where it checks Model#respond_to? before initializing the object.
Things like YAML.load(YAML.dump(@post)) won't work without this.
2010-12-02 15:36:05 +13:00
Aaron Patterson
a5e7d9f1e0 avoid deprecated methods 2010-12-01 14:49:33 -08:00
Thilo Utke
d321e78646 ActiveModel::Errors.to_hash returns plain OrderedHash and used in to_json serialization to properly handle multiple errors per attribute
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-12-01 12:03:13 +01:00
John Hawthorn
52e854e900 test case on has_one :through after a destroy
[#6037 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-11-29 10:54:36 +01:00
Santiago Pastorino
75015d1b5c Revert f1c13b0dd7 2010-11-28 20:01:34 -02:00
Santiago Pastorino
5c21c1ca62 Fix another error in tests 2010-11-28 12:09:02 -02:00
Santiago Pastorino
2f09a5a0d1 Fix test 2010-11-28 11:45:53 -02:00
Mikel Lindsaar
eb27d80383 Application templates should work with HTTPS too 2010-11-27 22:17:05 +11:00
Ryan Bigg
2d8c104677 Add methods for configuring middleware to config guide 2010-11-27 07:57:33 +01:00
Ryan Bigg
62164e0119 Add "Configuring Middleware" section to config guide, starting with mentioning what every bit of middleware does. 2010-11-27 07:57:33 +01:00
Ryan Bigg
2c4bab6e7b Add explicit statement that verify_authenticity_token can be turned off for actions. 2010-11-27 07:57:32 +01:00
Ryan Bigg
9c6afa70df Add mention of config.serve_static_assets to config guide 2010-11-27 07:57:31 +01:00
Andrés Mejía
a82c27253d Mentioning catch with Bundler remembering options between different calls 2010-11-27 07:57:30 +01:00
Andrés Mejía
ab425296b8 Added missing word. 2010-11-27 07:57:30 +01:00
Aditya Sanghi
abe28bf426 Resolving LH #5986, cookies doc updates 2010-11-27 07:57:29 +01:00
Ryan Bigg
550ac57375 Added documentation for config.generators to the config guide 2010-11-27 07:57:28 +01:00
Ryan Bigg
a571d4bcf3 Add mention of after_initialize to the config guide 2010-11-27 07:57:28 +01:00
Ryan Bigg
fb661f3ea7 There is no more load_application_initializers in Rails 3 2010-11-27 07:57:27 +01:00
Ryan Bigg
78d782fa51 root_path is now simply root in Rails 3 2010-11-27 07:57:26 +01:00
Ryan Bigg
5b5d3e5266 Update Changelog for configuring guide 2010-11-27 07:57:25 +01:00
Ryan Bigg
7a334b3032 There is no RAILS_GEM_VERSION environment variable or constant for Rails 3, since this is now managed by Bundler 2010-11-27 07:57:25 +01:00
Ryan Bigg
29a2e61498 There is no config.action_mailer.default_implicit_parts_order method for Rails 3 2010-11-27 07:57:24 +01:00
Ryan Bigg
de34a4df21 Mention the default config.action_mailer.default options in Configuration guide 2010-11-27 07:57:23 +01:00
Ryan Bigg
5483b35a84 There is no config.action_mailer.default_content_type method for Rails 3 2010-11-27 07:57:22 +01:00
Ryan Bigg
536bbf9c4e There is no config.action_mailer.default_charset method for Rails 3 2010-11-27 07:57:21 +01:00
Ryan Bigg
1b80352f84 Update ActionMailer documentation to not use deprecated template_root method as documentation, but rather raise_delivery_errors method 2010-11-27 07:57:21 +01:00
Ryan Bigg
723d3e22d5 There is no config.action_mailer.template_root method for Rails 3 2010-11-27 07:57:20 +01:00
Ryan Bigg
a6a50c204e There is no config.action_view.warn_cache_misses method for Rails 3 2010-11-27 07:57:19 +01:00
Ryan Bigg
c657649fd4 Separate Action Dispatch and Action Pack sections in Configuration Guide. 2010-11-27 07:57:18 +01:00
Ryan Bigg
caca1a5a5a There is no config.action_controller.params_parser method for Rails 3. This is now handled by the ActionDispatch::ParamsParser middleware. 2010-11-27 07:57:17 +01:00
Ryan Bigg
c6eae7ab59 There is no view_path config option in Rails 3 2010-11-27 07:57:17 +01:00
Ryan Bigg
f0cc3a1cf6 There is no root_path config option in Rails 3 2010-11-27 07:57:16 +01:00
Ryan Bigg
d626e136a5 There is no plugin_paths config option in Rails 3 2010-11-27 07:57:15 +01:00
Ryan Bigg
f74d7e8100 There is no plugin_locators config option in Rails 3 2010-11-27 07:57:14 +01:00
Ryan Bigg
555b184bfd There is no plugin_loader config option in Rails 3 2010-11-27 07:57:14 +01:00
Ryan Bigg
98156908c9 load_once_paths is now autoload_paths in Rails 3 2010-11-27 07:57:13 +01:00
Ryan Bigg
6ee6bad630 There is no database_configuration_file method in Rails 3 2010-11-27 07:57:12 +01:00
Ryan Bigg
b1f35774c2 There is no controller_paths method in Rails 3 2010-11-27 07:57:11 +01:00
Ryan Bigg
592c7aed12 Mention what cache_classes defaults to in all three default environments 2010-11-27 07:57:11 +01:00
Ryan Bigg
bc3d77b7d5 Don't mention Rails 2.3, given that this is supposed to be a guide for Rails *3*. 2010-11-27 07:57:10 +01:00
Ryan Bigg
d16067db2f There is no more routes_configuration_file method. 2010-11-27 07:57:10 +01:00
Cheah Chu Yeow
86dba29562 Fix missing word in ActionMailer::Base documentation. 2010-11-27 07:57:09 +01:00
Ryan Bigg
0fcd39acd4 Add mention of nested resource to resources documentation 2010-11-27 07:57:08 +01:00
Ryan Bigg
38246b3a1a Document the :path option for resources :posts 2010-11-27 07:57:07 +01:00
Ryan Bigg
2b13f845a0 Add :module option documentation for the resources method 2010-11-27 07:57:06 +01:00
Ryan Bigg
0f63a8ad42 Remove non-sensical first couple of lines for scope method documentation 2010-11-27 07:57:03 +01:00
Ryan Bigg
9f795e1123 Fix formatting issue with rake routes output for the namespace method 2010-11-27 07:56:36 +01:00
David Heinemeier Hansson
b7b28d5224 Merge branch '3-0-stable' of github.com:rails/rails into 3-0-stable 2010-11-26 15:42:58 -06:00
José Valim
6e66d6100b Only convert direct hash instances in hash with indifferent access. 2010-11-26 12:02:00 +01:00
José Valim
7e903a3d3a Dynamically generaeted helpers on collection should not clobber resources url helper [#6028 state:resolved] 2010-11-25 11:51:03 +01:00
raggi
08e9d0d65b Don't depend on rubygems loading thread (for Mutex) 2010-11-24 14:51:03 -08:00
Neeraj Singh
4e2a981bdd If a user wants json output then try best to render json output. In such cases prefer kind_of(String) over respond_to?(to_str)
[#5841 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-11-24 22:09:43 +01:00
Neeraj Singh
1e2981fa6b If a nested_attribute is being marked for destruction and at the same time an attr_accessor value is being assigned then the value being assigned is being ignored. This patch is a fix for that issue.
[#5939 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-11-24 22:09:33 +01:00
Sven Fuchs
55b13c532f Allow registering javascript/stylesheet_expansions to existing symbols 2010-11-23 15:14:42 -08:00
Jaime Iniesta
25467be1d3 i18n guide: fix RedCloth artifacts that were rendering bad format and broken links on 2.3 warnings 2010-11-23 22:03:45 +01:00
Ray Baxter
9332d2ee21 fix typo 2010-11-23 22:03:33 +01:00
Neeraj Singh
30b3a14c2b Revert "unscoped takes care of named_scopes too"
This reverts commit 126fbd7ed8.
2010-11-23 22:03:20 +01:00
David N. Welton
539e46d35d Explain that NamedBase makes the variable 'name' available to the script. 2010-11-23 22:02:47 +01:00
David N. Welton
45aca62ffe Slightly more natural sounding phrase. 2010-11-23 22:02:28 +01:00
Brian Alexander
58eaceb2f6 Previous version inaccurately suggested that
resources :posts, :path => "/admin"

would route "/admin/posts" to the PostsController but it actually routed "/admin" to the PostsController
2010-11-23 22:02:04 +01:00
Xavier Noria
28a0ee0f0c documents <%== in the AS guide 2010-11-21 10:25:59 +01:00
Xavier Noria
3565a2a993 Spanish for "project" is "proyecto" 2010-11-21 03:29:10 +01:00
Neeraj Singh
27f43cc583 use_accept_header is no longer supported 2010-11-21 03:29:10 +01:00
Xavier Noria
d2f3ef18a6 copy-edits d773ef8 2010-11-21 03:29:10 +01:00
Jamison Dance
255e47d72f fix some grammar issues with section 2.5 2010-11-21 03:29:10 +01:00
nosolopau
1e1711c914 Spelling mistake: "Projecto" instead of "projeto" 2010-11-21 03:29:10 +01:00
Jaime Iniesta
ebac0f4f90 i18n guide: fix external link to rack locale 2010-11-21 03:29:10 +01:00
Léo Hackin
be05561507 Fix code for customize the error messages html adding a .html_safe of 8.3 section 2010-11-21 03:29:10 +01:00
Neeraj Singh
a1786cfe6b unscoped takes care of named_scopes too 2010-11-21 03:29:10 +01:00
Jaime Iniesta
ff69c801ba i18n guide: this is not longer a problem 2010-11-21 03:29:10 +01:00
Jaime Iniesta
c0e7b7aec9 i18n guide: remove link to external page about 'How to encode the current locale in the URL' as it no longer exists 2010-11-21 03:29:09 +01:00
Jaime Iniesta
eec0a789a2 i18n guide: it's activerecord.errors.messages.record_invalid (instead of 'invalid'), and messagges typo 2010-11-21 03:29:09 +01:00
zhengjia
55759a66f4 Minor fix on Rails:Railtie documentation 2010-11-21 03:29:09 +01:00
José Valim
6e1410db89 Ensure session responds to destroy before calling it. 2010-11-20 21:58:50 +01:00
José Valim
6b00e8e0f0 Ensure calling reset session twice does not raise errors. 2010-11-20 21:56:37 +01:00
Xavier Noria
a7d322307d applies API conventions to the RDoc of json_encode
* Examples running with the text are preferred over separate Example
  sections.
* No need to call puts, in # => we show the return value, not STDOUT.
* Say explicitly that double quotes are removed.
* Specify that we are talking \uXXX, rather than, say, HTML entities.
2010-11-20 16:26:33 +01:00
Neeraj Singh
54828a1703 json_escape makes json invalid doc change [#1485 state:resolved] 2010-11-20 15:07:07 +01:00
Aaron Patterson
0d055de8b6 do not require ruby-debug automatically. please require it if you have declared it as a dependency 2010-11-19 16:29:57 -08:00
Xavier Noria
73680bb94c guides: gives clear instructions for feedback, removes links to the now archived LH project 2010-11-19 21:45:27 +01:00
Carl Lerche
dd3afdd33b Raise an ArgumentError when passing an invalid argument to a validator 2010-11-18 22:33:45 -08:00
Aaron Patterson
3c12ab9d78 testing multiple ORd queries 2010-11-18 13:39:21 -08:00
Aaron Patterson
cdf4055c88 delegating path and open to internal tempfile 2010-11-18 10:10:18 -08:00
Aaron Patterson
6da2a3e13c removing space errors 2010-11-18 10:01:21 -08:00
Alex Rothenberg
1fd3ac6b5f Adapters can specify maximum number of ids they support in a list of expressions
(default is nil meaning unlimited but Oracle imposes a limit of 1000)
Limit is used to make multiple queries when preloading associated has_many or habtm records
2010-11-18 09:59:40 -08:00
Aaron Patterson
ab299c54a2 group can be done by left side only 2010-11-17 17:28:49 -08:00
Aaron Patterson
fdc591351e collapsing same table / column WHERE clauses to be OR [#4598 state:resolved] 2010-11-17 17:10:40 -08:00
Aaron Patterson
044e23d1be use shorter form for sql literals 2010-11-17 16:14:17 -08:00
Santiago Pastorino
a4aac92baf When use where more than once on the same column, relation doesn't do an 'or' or 'in' with the values 2010-11-17 16:06:45 -08:00
Carl Lerche
22f8253e58 Anchors should be allowed on constraints that are not on path segments 2010-11-16 21:47:38 -08:00
David Heinemeier Hansson
6eab52d507 Preparing for 3.0.4.rc release 2010-11-16 21:39:45 -06:00
Carl Lerche
a46b77728a The PRE part of the rails version is a string or nil 2010-11-16 17:22:29 -08:00
Carl Lerche
65b6fb8090 Removing the old release.rb script 2010-11-16 16:37:23 -08:00
Carl Lerche
1e37653e38 Small cleanup of the release task 2010-11-16 16:30:53 -08:00
Carl Lerche
217a7de563 Add a task to tag the commit and push 2010-11-16 16:28:53 -08:00
Carl Lerche
161bd52623 Ignore the dist directory 2010-11-16 16:26:38 -08:00
Carl Lerche
f9bd6d8e7e Add a task to commit the changes 2010-11-16 16:24:52 -08:00
Carl Lerche
b3b6c71a77 Add some sanity checks to the gem push script 2010-11-16 16:08:13 -08:00
Carl Lerche
882d2c87c3 Remove some useless comments from the release task 2010-11-16 15:45:31 -08:00
Carl Lerche
2bf085ff45 Update the main Rakefile to use the new release tasks 2010-11-16 15:42:39 -08:00
Carl Lerche
6fb2913ad4 Add a new file containing tasks related to releasing 2010-11-16 15:42:14 -08:00
Carl Lerche
42ed7edc29 Bump up the version.rb file for ActiveRecord to 3.0.3 2010-11-16 15:36:49 -08:00
Carl Lerche
a27e80b161 Update the version.rb files to include a PRE part 2010-11-16 15:11:46 -08:00
Carl Lerche
9dd4db4962 Remove the old gem release task 2010-11-16 14:48:23 -08:00
Alexandru Catighera
8d6eb9b3fb Fix ActiveRecord calculations when grouped by multiple fields 2010-11-16 11:03:58 -08:00
Aaron Patterson
c9b273627a using a merge with a Hash[] rather than a loop to add SAX parsed attributes 2010-11-16 10:09:55 -08:00
David Heinemeier Hansson
0aca27d407 Prepare to release 2010-11-16 10:26:44 -06:00
Santiago Pastorino
8279c06525 Relax bundler dependency to allow the faster 1.1 2010-11-16 14:15:02 -02:00
Xavier Noria
34dc030177 revises RDoc of AR::Base#== 2010-11-16 15:58:59 +01:00
Santiago Pastorino
69f7d39945 Models should be equals even after destroyed
[#5978 state:committed]
2010-11-16 12:39:58 -02:00
Aaron Patterson
c7dd1e4df4 support finding by a ruby class [#5979 state:resolved] 2010-11-15 20:24:58 -08:00
Aaron Patterson
ed91716439 adding more test coverage around finding with active record objects 2010-11-15 15:30:27 -08:00
Aaron Patterson
e2266cfcbd updating CHANGELOG to reflect bug fixes 2010-11-15 15:08:52 -08:00
David Heinemeier Hansson
edafb49472 Get ready for the re-run of the earlier release -- now with less last minute bugs! 2010-11-15 17:07:41 -06:00
Aaron Patterson
fc69c64c84 use quoted id of single AR::Base objects in predicates 2010-11-15 14:35:28 -08:00
José Valim
bd944798a5 Relax i18n requirement. 2010-11-15 23:14:57 +01:00
Aaron Patterson
19ff18ed26 make sure we are only doing sanity checking against regular expressions 2010-11-15 13:37:13 -08:00
Santiago Pastorino
89b073b367 Bring back ruby-debug19 for Ruby versions < 1.9.3 2010-11-15 13:37:13 -08:00
José Valim
76efb921e3 Update abort message (ht: tilsammans).
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-11-15 22:30:05 +01:00
David Chelimsky
fb4dc1a512 only abort in test_help in production env
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-11-15 22:30:05 +01:00
David Heinemeier Hansson
186e3c71f9 Prep for relese 2010-11-15 13:23:02 -06:00
David Heinemeier Hansson
31b6a6a78b Prep for 3.0.2 release 2010-11-15 13:20:27 -06:00
James Miller
029c8ff46c Add HTTP Verb Constraints (:via) to routing guide 2010-11-15 19:59:52 +01:00
Jaime Iniesta
65fdd284e1 Getting Started guide: remove calls to f.error_messages as it has been removed from Rails 2010-11-15 19:59:37 +01:00
Rajinder Yadav
1540bf5816 removed unnecessary indentation 2010-11-15 19:59:15 +01:00
Rajinder Yadav
4369f132a6 added note with example for using flash in redirection 2010-11-15 19:59:06 +01:00
Rajinder Yadav
c41d9813be corrected sample code to clear @_current_user class variable also 2010-11-15 19:58:57 +01:00
Rajinder Yadav
7487767c31 the partial option is not required for simple partial rendering 2010-11-15 19:58:47 +01:00
Ryan Bigg
28f9d60f77 Document the constraints method 2010-11-15 19:58:37 +01:00
Paco Guzman
dbc0023d6d colorize_logging is a Rails General Configuration option not a specific option of ActiveRecord 2010-11-15 19:58:21 +01:00
Ryan Bigg
ccc8d9ce54 Add documentation for :path_names option on resources 2010-11-15 19:58:11 +01:00
Ryan Bigg
43b0fd7918 See the scope method for documentation for namespace's shallow_path option 2010-11-15 19:58:03 +01:00
Ryan Bigg
86534a35f9 Add documentation for the mount method in ActionDispatch's Mapper 2010-11-15 19:57:54 +01:00
Frederick Ros
13f10ac4ea Fixed the name of the 'generator option' 2010-11-15 19:57:45 +01:00
José Valim
4c3edae2bd Add a note to TextHelpers making explicit their default behavior of not escaping but sanitizing. 2010-11-15 19:57:09 +01:00
Rajinder Yadav
5d9219b1b5 removed indentation, for code style consistency and readibility 2010-11-15 19:57:00 +01:00
dmathieu
70e4403e46 Use Rails.logger, not ActiveRecord::Base.logger
Because everybody is not using ActiveRecord. And the logger is not specific to it.
2010-11-15 19:56:51 +01:00
Rajinder Yadav
41e5e4a7bd removed etc. not require 2010-11-15 19:56:42 +01:00
Rajinder Yadav
bad920f423 corrected to Rails 3 syntax for declaring resources 2010-11-15 19:56:13 +01:00
Francesc Esplugas
45c3abadfa Fixes ActionMailer example error 2010-11-15 19:56:04 +01:00
Ryan Bigg
205b24064e Fix indentation for :as option documentation on the namespace method 2010-11-15 19:55:56 +01:00
Ryan Bigg
4ffd31e195 Document the :shallow_path option for scope 2010-11-15 19:55:41 +01:00
Ryan Bigg
020f74b152 Indent final comment for :path option 2010-11-15 19:55:34 +01:00
Ryan Bigg
7a1f22ff33 Indent code example for :as option 2010-11-15 19:55:24 +01:00
Ryan Bigg
06402b03ea Document the :as option for the scope method 2010-11-15 19:55:15 +01:00
Ryan Bigg
0db841223a Space between module option documentation and path documentation 2010-11-15 19:55:04 +01:00
Ryan Bigg
34015296e0 Fix indentation on comment for :path option 2010-11-15 19:54:54 +01:00
Ryan Bigg
45525713f9 Document the :as option for the namespace method 2010-11-15 19:54:45 +01:00
Ryan Bigg
422831872e Document the :module option for namespace 2010-11-15 19:54:29 +01:00
Ryan Bigg
e777b914c8 Document the :path option for namespace 2010-11-15 19:54:05 +01:00
Ryan Bigg
1287fddff6 Begin to document the namespace method for AD's Mapper 2010-11-15 19:53:54 +01:00
Ryan Bigg
467d5844eb Document the controller method for AD's Mapper 2010-11-15 19:53:40 +01:00
Ryan Bigg
afc16f6dce Document the defaults method 2010-11-15 19:53:28 +01:00
Ryan Bigg
3551e254d2 Document the :module and :path options for the scope method. 2010-11-15 19:53:15 +01:00
Ryan Bigg
9078041ee8 Separate comments and examples with "Examples" header. 2010-11-15 19:53:02 +01:00
Ryan Bigg
9ccaf47012 Add further documentation + examples for the get, post, put and delete methods in ActionDispatch::Routing::Mapper::HttpHelpers 2010-11-15 19:50:40 +01:00
Mikel Lindsaar
10fc93b89e Revert "Bump up mail dependency to take advantage of relaxed i18n version requirement"
Locking to ~> 2.2.9.1 means locking to < 2.2.10, not intended behaviour.

This reverts commit e7de5dd11e.
2010-11-16 00:24:13 +11:00
Mikel Lindsaar
fc95196df0 Bump up mail dependency to take advantage of relaxed i18n version requirement 2010-11-16 00:08:04 +11:00
Santiago Pastorino
01ed7005e1 Remove unused var 2010-11-14 15:38:05 -02:00
Jason Cheow
f8b7c74f9b Fix bug where size of through association is not correct after adding a has_many association (occurs only before main object has been reloaded).
[#5968 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-11-14 15:37:58 -02:00
Carlos Antonio da Silva
4266e3e91a Remove lost commented debugger call
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-11-13 13:22:52 -02:00
Carlos Antonio da Silva
bdec56cbe7 Fix rendering partial with layout, when the partial contains another render layout with block call
In such situations, the first layout was not being applied. This fixes it by
storing the block variable before rendering the partial, so the variable
is not overrided, thus the layout is applied (bear in mind the renderer is
shared among all render calls).

This commit also adds some more tests to render partials with layouts and
nested render layout calls.

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-11-13 13:06:04 -02:00
Santiago Pastorino
b870193345 Make collection and collection_from_object methods return an array
This transforms for instance scoped objects into arrays and avoid
unneeded queries

[#5958 state:committed]
2010-11-13 04:06:53 -02:00
Santiago Pastorino
ed62b96e23 Use ! instead of not 2010-11-11 15:32:17 -02:00
Nathan B
d54ab371df Fixed bug in active_record/nested_attributes where an empty string id caused an ActiveRecord::RecordNotFound error. Found by [Ben Tillman]
[#5638 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-11-11 15:31:28 -02:00
Santiago Pastorino
30ae44a326 Bump Arel up to 2.0.2 2010-11-11 15:03:44 -02:00
Jeff Kreeftmeijer
be63e03fba The model generator shouldn't throw warnings when using mass nouns [#5363 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-11-11 17:24:37 +01:00
Neeraj Singh
86f66e9097 fields_for should treat ActiveRecord::Relation as an array
[#5795 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-11-11 17:18:12 +01:00
Marcelo Giorgi
0de95dfb2c Make after_filter halt when before_filter renders or redirects [#5648 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-11-11 17:07:31 +01:00
Carlos Antonio da Silva
d5fd83f4c7 Fix render partial with layout and no block
When using a render :partial with :layout call, without giving a block,
if the given :partial had another render :partial call, the layout was
not being rendered. This commit fixes this context by storing variables
before rendering the partial, so they are not overrided in any successive
call to render partials down the path. All ActionPack tests are ok.

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-11-11 16:24:01 +01:00
Carlos Antonio da Silva
3e86e4b34e Fix issue with rendering partials and then yielding inside a render layout call
The given block was never being executed when another render :partial call
existed before the yield call, due to the block being overriden.

This commit also adds some more tests to render with :layout option.

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-11-11 16:23:55 +01:00
Carlos Antonio da Silva
55a8bd666d Bring ActionPack tests back to life
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-11-11 16:23:32 +01:00
Aditya Sanghi
1b66a646db patching to ensure separator is printed with order [#5816 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-11-11 12:36:25 -02:00
Santiago Pastorino
2e4e1ed916 Duck typing here 2010-11-11 01:34:35 -02:00
Alvaro Bautista
387a1a6365 Fix ActiveSupport::TimeWithZone#localtime method with DateTime
[#5344 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-11-11 01:34:26 -02:00
Xavier Noria
7611a0925c registers number_to_currency's :negative_format in the CHANGELOG of AP 2010-11-09 20:55:14 +01:00
Santiago Pastorino
bf875b273d Double negation of an already boolean value produces the same result 2010-11-09 17:28:06 -02:00
Santiago Pastorino
b0f6349a07 Don't check if persisted is defined just initialize it properly 2010-11-09 17:28:06 -02:00
Santiago Pastorino
844b9a5018 Execute less operations 2010-11-09 17:28:05 -02:00
David Chelimsky
f1c13b0dd7 use persisted? instead of new_record? wherever possible
- persisted? is the API defined in ActiveModel
- makes it easier for extension libraries to conform to ActiveModel
  APIs
  without concern for whether the extended object is specifically
  ActiveRecord

[#5927 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-11-09 17:26:11 -02:00
Andrew White
4b33bd9888 Strip regexp anchors from rake routes output [#5934 state:resolved] 2010-11-09 05:20:15 +00:00
Santiago Pastorino
c7fac8c6ea Test cache.key_file_path with separators ht. Jim Wilson [#5611] 2010-11-07 20:03:41 -02:00
Denis Odorcic
ad2c0bdb9b Fix FileStore cache incorrectly regenerating its key from a pathname when a regexp is used in expire_fragment
[#5850 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-11-07 20:03:29 -02:00
Michael Koziarski
f676beb647 Make safe_append= live on AV::OutputBuffer not AS::SafeBuffer 2010-11-08 10:06:16 +13:00
Michael Koziarski
ea1fde6ae7 Added support for Erubis <%== tag
<%== x %> is syntactic sugar for <%= raw(x) %>

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#5918 status:committed]

Conflicts:

	actionpack/test/controller/new_base/render_template_test.rb
2010-11-08 10:03:33 +13:00
Chris Eppstein
d4b7fa5fb6 Correctly handle the case of an API response that returns a hash by treating a single hash argument as the resource instead of as options.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-11-07 18:19:52 -02:00
sblackstone
7ab940c7ad Association Proxy should not undefine the default respond_to_missing 2010-11-04 15:05:03 -07:00
José Valim
e6abfc46bf Update to latest thor with https bug fix. 2010-11-04 11:09:30 -02:00
Xavier Noria
a56142cc6b made a pass to the docs of :negative_format 2010-11-03 06:21:05 +01:00
Don Wilson
b91371763e Added :negative_format option to number_to_currency function [#5894 state:resolved]
Signed-off-by: Andrew White <andyw@pixeltrix.co.uk>
2010-11-02 23:06:08 +00:00
Santiago Pastorino
a682986d0d Test that capture doesn't escape twice 2010-11-02 20:18:26 -02:00
Santiago Pastorino
2c8bff3513 Call as ERB::Util.html_escape since is not the module is not included here 2010-11-02 20:18:22 -02:00
Jeff Kreeftmeijer
5cb1dad228 Make sure capture's output gets html_escaped [#5545 state:resolved]
Also remove a duplicate test_link_to_unless assertion and add .html_safe
to the remaining one.

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-11-02 20:17:37 -02:00
Andrew White
6c8982fa13 Add additional HTTP request methods from the following RFCs:
* Hypertext Transfer Protocol -- HTTP/1.1
  http://www.ietf.org/rfc/rfc2616.txt)

* HTTP Extensions for Distributed Authoring -- WEBDAV
  http://www.ietf.org/rfc/rfc2518.txt

* Versioning Extensions to WebDAV
  http://www.ietf.org/rfc/rfc3253.txt

* Ordered Collections Protocol (WebDAV)
  http://www.ietf.org/rfc/rfc3648.txt

* Web Distributed Authoring and Versioning (WebDAV) Access Control Protocol
  http://www.ietf.org/rfc/rfc3744.txt

* Web Distributed Authoring and Versioning (WebDAV) SEARCH
  http://www.ietf.org/rfc/rfc5323.txt

* PATCH Method for HTTP
  http://www.ietf.org/rfc/rfc5789.txt

[#2809 state:resolved] [#5895 state:resolved]
2010-11-02 11:06:54 +00:00
Jon Leighton
918bf847d8 Fix bug with 0bb85ed9ff which missed out a fixtures declaration in cascaded_eager_loading_test.rb 2010-10-31 20:02:32 -02:00
Ugis Ozols
3ca1bc381f Changed environment.rb to application.rb 2010-10-30 23:31:05 +02:00
Ugis Ozols
eca3791d0f Reworded sentence using text from rails source code. 2010-10-30 23:31:05 +02:00
Rob Zolkos
b5efa8fc67 added tip about ruby-debug needing a different gem if using 1.9 [#190 state:resolved] 2010-10-30 23:31:05 +02:00
Ugis Ozols
c95f155731 Changed environment.rb to application.rb 2010-10-30 23:31:05 +02:00
Aaron Patterson
29b3af539b only returning where values for the corresponding relation, also filtering where value hash based on table name [#5234 state:resolved] [#5184 state:resolved] 2010-10-30 13:34:23 -07:00
Aaron Patterson
3bc12d3ee6 adding tests for #5234 and #5184. Tests were from Akira Matsuda. Thanks Akira! 2010-10-30 13:32:09 -07:00
Aaron Patterson
ae7a354110 no need to merge where values if no new where values have been added 2010-10-30 13:31:59 -07:00
Aaron Patterson
4d2a53d9ea reduce duplicate where removal to one loop 2010-10-30 13:30:33 -07:00
Aaron Patterson
4772abc7d8 swap out some n^2 for some n 2010-10-30 13:30:26 -07:00
Aaron Patterson
4fd9c20fb3 dup rather than create so many arrays 2010-10-30 13:30:19 -07:00
Ernie Miller
c681df48e3 Fix issues when including the same association multiple times and mixing joins/includes together. 2010-10-30 11:19:26 -07:00
Andrew White
ddf73603c1 Backport of documentation fixes:
cfc8c7ab54
  dfebdb1b03

[#5520] [#5537] [#5581]
2010-10-29 07:23:17 +01:00
Aaron Patterson
f73a3e6838 reducing the number of parameters to select() 2010-10-27 04:15:17 -07:00
Andrew White
0d23c2160d Ensure that Rails.env is defined first 2010-10-27 10:31:29 +01:00
Andrew White
63b0d0e9d2 Allow generated url helpers to be overriden [#5243 state:resolved] 2010-10-26 14:33:34 +01:00
Mikel Lindsaar
5f6a02f4ba Updating mail dependency to 2.2.9 2010-10-26 18:51:06 +11:00
Andrew White
909c860a42 Don't write out secure cookies unless the request is secure 2010-10-25 16:47:17 +01:00
Xavier Noria
e9d593bc18 ensures that no browser shows a vertical scrollbar in the code blocks of guides, thanks to Marcelino Llano for a hint to fix this 2010-10-24 19:28:57 +02:00
Xavier Noria
ec23bc15ba configure a uniform font-family for code in guides 2010-10-24 16:23:02 +02:00
Xavier Noria
7ca9dcd434 use a gray a little darker in code blocks, for better contrast with the gray background 2010-10-24 16:22:52 +02:00
Xavier Noria
1a618e98e0 removes the toolbar from guides code blocks 2010-10-24 16:22:42 +02:00
Xavier Noria
5a4a2323b0 switches guides code syntax highlighting to the better SyntaxHighlighter, I did my best with the theme, I swear 2010-10-24 00:38:14 +02:00
Santiago Pastorino
c53f301b48 Revert "Bump bundler up to 1.0.3"
This reverts commit 0891f49075.
2010-10-21 15:12:07 -02:00
Jan
f294540154 default scope merge where clauses [#5488 state:resolved] 2010-10-20 08:54:02 -07:00
Aaron Patterson
4480521df9 bumping mysql2 requirement 2010-10-19 17:53:41 -07:00
Santiago Pastorino
adea1467f6 compact is unneeded here 2010-10-18 12:03:00 -02:00
Santiago Pastorino
14b33a4eb7 Merge 3.0.1 CHANGELOGs and prepare 3.0.2.pre 2010-10-18 12:00:46 -02:00
Andrew White
141cba8f1d Reset assert_template instance variables between requests [#5832 state:resolved] 2010-10-18 10:05:24 +01:00
Santiago Pastorino
0891f49075 Bump bundler up to 1.0.3 2010-10-16 18:24:18 -02:00
Michael Koziarski
37431bb34e Revert 0c0b0aa0f2 which introduced a security vulnerability.
This addresses  CVE-2010-3933

Conflicts:

	activerecord/lib/active_record/nested_attributes.rb
2010-10-15 10:25:49 +13:00
Santiago Pastorino
f7faa86690 Leave env :AREL only for testing purposes 2010-10-14 18:56:11 -02:00
Santiago Pastorino
10d3ab79dc Don't use Arel from git anymore 2010-10-14 18:25:34 -02:00
Aaron Patterson
85ffbfef9c stop using deprecated arel API 2010-10-12 14:32:48 -07:00
Xavier Noria
869118aaae getting started guide: deletes orphan <% end %>, reported by Michael L. Miller 2010-10-12 23:07:43 +02:00
Szymon Nowak
1556e0874d Return a valid empty JSON on successful PUT and DELETE requests. [#5199 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-10-12 00:56:44 +02:00
Aaron Patterson
0a8eaff3d1 we should always cast the value based on the column 2010-10-11 13:36:38 -07:00
Marcelo Giorgi
dba7de0da0 Honor distinct option when used with count operation after group clause [#5721 state:resolved] 2010-10-11 09:47:26 -07:00
Santiago Pastorino
0c56a27926 data-disable-with in button_to helper
[#4993 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-10-11 13:35:35 -02:00
Santiago Pastorino
448a187606 CHANGELOG of reorder deprecation 2010-10-11 11:48:54 -02:00
Santiago Pastorino
0b46f72226 Deprecate reorder in favor of except(:order).order(...) 2010-10-11 11:43:29 -02:00
Santiago Pastorino
d0d1acab58 Add except as AR public API 2010-10-11 11:39:46 -02:00
Santiago Pastorino
3021297e89 Revert "Make InstanceTagMethods#value_before_type_cast raise if the model don't respond to attr_before_type_cast or attr method"
And    "Makes form_helper use overriden model accessors"

This reverts commit 3ba8e31005 and fb0bd8c109.
2010-10-10 21:14:10 -02:00
wycats
b4954e81c1 Cherry pick didn't get this deletion 2010-10-10 16:13:35 -07:00
wycats
83d5180bec Always pull in version for frameworks (standardize autoload / require / none) 2010-10-10 16:12:57 -07:00
Barry Sears
4245dcd521 Make ActiveSupport load own version.
[#5739 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-10-10 19:48:11 -02:00
Wincent Colaiuta
3a6acb6162 Fix misleading advice to add 'memcache' to Gemfile
[#5539 state:committed]

Commit 57144388f removed the hard-coded dependency on the memcache-client
gem, and added this warning advising people to install it if needed. The
problem is, however, that if people follow the advice literally and install
the 'memcache' gem, they will wind up with a completely different thing,
which is not API compatible with the memcache-client gem and which Rails
can't work with.

So, be explicit and tell users to install the 'memcache-client' gem.

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-10-10 14:30:43 -02:00
Andrea Campi
61fc0f0ba0 Override #store to be consistent with #[].
[#5775 state:resolved]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-10-10 14:08:27 -02:00
wycats
b4b4a2aa28 Fix a few bugs when trying to use Head standalone 2010-10-10 00:53:52 -07:00
Santiago Pastorino
0b9eced70d Merge rails routing guide from master 2010-10-09 15:00:33 -02:00
Andrew White
d066ad638a Refactor resource action scope methods 2010-10-08 22:09:50 +01:00
Andrew White
981942a326 Backport ca3936d to 3-0-stable [#5274] 2010-10-08 11:20:21 +01:00
James MacAulay
2ded862226 fix rendering a partial with an array as its :object [#5746 state:resolved]
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2010-10-08 09:36:12 +13:00
Aaron Patterson
5e685caf1c only forwarding enough methods to work. People should grab the delegate tempfile if they really need to do hard work 2010-10-07 10:10:40 -06:00
Aaron Patterson
fc9e9ed406 making sure respond_to? works properly 2010-10-07 10:10:31 -06:00
Aaron Patterson
d75244785f raising an argument error if tempfile is not provided 2010-10-07 10:10:24 -06:00
Aaron Patterson
003d67efb2 if it walks like a duck and talks like a duck, it must be a duck 2010-10-07 10:10:17 -06:00
Aaron Patterson
c4528deec1 delegate to the @tempfile instance variable 2010-10-07 10:10:11 -06:00
Aaron Patterson
1e50fae259 adding tests for uploaded file 2010-10-07 10:10:06 -06:00
Santiago Pastorino
9eeb24cd57 Add a TODO to remove gem "jruby-openssl" when jruby-openssl is merge in jruby
[#5762]
2010-10-07 13:50:49 -02:00
Anil Wadghule
b9fd742bb6 Add jruby-openssl gem in Gemfile necessary for JRuby
[#5762 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-10-07 11:49:00 -02:00
Ryan Bigg
53def60d83 Add "a" to make it better English
[#3796 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-10-07 11:41:22 -02:00
Hemant Kumar
444aa9c735 fix ruby 1.9 deadlock problem, fixes #5736 add connection pool tests 2010-10-06 14:43:26 -06:00
Aditya Sanghi
af53ed89c4 adding test for namedspaced mailers 2010-10-06 19:28:47 +11:00
Aditya Sanghi
accc5676d6 mailer comment should use namespace in comment 2010-10-06 19:28:47 +11:00
Erik Michaels-Ober
3e958a5bf7 Fix copy/paste bug
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-10-06 09:22:15 +02:00
Xavier Noria
13a4d1436f a couple of touches to the guides guidelines 2010-10-05 22:53:18 +02:00
Xavier Noria
cec7129729 aaaaannnddd, your beloved typo only spotted in the github colored diff no matter how many passes you did before pushing 2010-10-05 19:38:23 +02:00
Xavier Noria
da927d2e16 new guide: Ruby on Rails Guides Guidelines 2010-10-05 19:35:31 +02:00
Aaron Patterson
c13aaaa2f0 calling correct method on minitest for test name when teardown callback fails 2010-10-04 09:35:11 -07:00
Aaron Patterson
4a77431b9a [#5406 state:resolved] calling the correct method on minitest to obtain the test name 2010-10-04 09:35:06 -07:00
David Chelimsky
86571a1f43 Add view_assigns and deprecate _assigns for AV::TC on 3-0-stable
branch.

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-10-04 18:09:44 +02:00
Santiago Pastorino
e5da873db1 _assigns can have more internal vars in this test 2010-10-04 10:20:40 -02:00
Santiago Pastorino
e99c894767 PERF: Hash[] + map is faster than this inject, and var[1..-1] is faster than var.sub('@', '') 2010-10-03 13:28:25 -02:00
David Chelimsky
2380c71601 Added test case to specify that _assigns returns a Hash in AV::TC
[#5751 state:resolved]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-10-03 13:16:08 -02:00
José Valim
ebfbb2a2e3 :'' is not valid ruby. 2010-10-02 19:01:57 +02:00
José Valim
fef42738d7 Deprecate config.generators in Rails::Engine in favor of config.app_generators.
config.generators still works fine in Rails::Application and Rails::Railtie, but it will be deprecated in the latter in Rails 3.1.
2010-10-02 19:01:00 +02:00
Aditya Sanghi
f283812bed added test for form_for with search_field
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-10-02 17:52:33 +02:00
Aditya Sanghi
3569bde28e Fixing search_field to remove object attribute from options hash [#5730 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-10-02 17:52:21 +02:00
José Valim
f9b5f63319 Revert "Perf: refactor _assign method to avoid inject and defining unneeded local var."
_assigns must return a hash.

This reverts commit e66c1cee86.
2010-10-02 08:39:09 +02:00
Aaron Patterson
87104a71a9 Arel::Sql::Engine.new does not do anything anymore 2010-09-30 16:28:22 -07:00
Aaron Patterson
fc1c799241 type_name should check for blank because people may have messed up databases 2010-09-30 16:03:14 -07:00
Aaron Patterson
b0b2d41a48 build_where should be private 2010-09-30 14:35:36 -07:00
Aaron Patterson
7e73344f7a type_name is never a blank string, so use faster .nil? call 2010-09-30 14:22:09 -07:00
Aaron Patterson
ea6305411f speeding up object instantiation by eliminating instance_eval 2010-09-30 13:33:38 -07:00
Marcelo Giorgi
2221b701b4 AssociationCollection#include? working properly for objects added with build method [#3472 state:resolved] 2010-09-30 12:13:42 -07:00
Aaron Patterson
fc1bd2bba4 [#5441 state:resolved] refactoring code to determine aggregate column 2010-09-30 10:17:49 -07:00
Aaron Patterson
de3c0d7eb4 group clause must be more specific 2010-09-30 10:17:49 -07:00
oleg dashevskii
43f404ed6e Tests proving #5441 2010-09-30 10:17:49 -07:00
yalab
b08175825e Fix 'rake db:create' is ignore encoding when using postgres [#5717 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-30 13:53:49 -03:00
José Valim
5704aa2e1a Use .find here as it is simpler and faster. 2010-09-30 07:25:45 +02:00
José Valim
1a2b28c9d9 Ensure that named routes do not overwrite previously defined routes. 2010-09-29 14:27:16 +02:00
Santiago Pastorino
9ddda10b67 Add gem 'arel' from git commented out as an example of how to Bundle egde Rails with Arel edge
[#5723 state:committed]
2010-09-29 00:15:53 -03:00
Aaron Patterson
f640af5a7a removing more useless code! yay! 2010-09-28 17:45:43 -07:00
Aaron Patterson
a35c8c6426 SqlLiteral is a string, so we can dry up these conditionals 2010-09-28 17:45:39 -07:00
Aaron Patterson
e080144242 shorten up or sql literal creation statements 2010-09-28 17:45:33 -07:00
Aaron Patterson
8ae8125e75 we only care about arrays and strings 2010-09-28 17:45:28 -07:00
Aaron Patterson
ddc2f2ee50 dry up calls to arel.join() 2010-09-28 17:45:23 -07:00
Aaron Patterson
a01547cc12 removing unused lasgns 2010-09-28 17:45:18 -07:00
Aaron Patterson
2e0114182c refactoring to remove crazy logic 2010-09-28 17:45:06 -07:00
Aaron Patterson
439a0ceb43 removing a conditional that is not used 2010-09-28 17:42:11 -07:00
Aaron Patterson
3daf8228f9 fisting the postgresql tests 2010-09-28 17:42:07 -07:00
Aaron Patterson
1685bd2e10 convert inject to map + join 2010-09-28 17:42:01 -07:00
Aaron Patterson
ede0466d13 each works well too 2010-09-28 17:41:57 -07:00
Aaron Patterson
bf388f37ac no need for splat and flatten 2010-09-28 17:41:53 -07:00
Aaron Patterson
93096aedcb avoid calling to_sql when we can 2010-09-28 17:41:49 -07:00
Aaron Patterson
c493624fc2 removing an inject + merge in favor of Hash#[] 2010-09-28 17:41:44 -07:00
Aaron Patterson
6059c9679e use new skool Ruby instead of Ruby Classic™ 2010-09-28 17:41:33 -07:00
Aaron Patterson
721f43498a be kind to the garbage collector: only instantiate objects when absolutely necessary 2010-09-28 17:41:28 -07:00
Aaron Patterson
e6e90839d0 adding test cases for the dynamic finder matcher match method 2010-09-28 17:41:24 -07:00
Aaron Patterson
ecbfed2f83 constructor should not do so much work; avoid allocating object if possible 2010-09-28 17:41:18 -07:00
Aaron Patterson
409bd22a2d @klass also uses DynamicFinderMatch, so no need for it on the relation 2010-09-28 17:41:13 -07:00
Aaron Patterson
1e687e98ac no need for a case / when statement 2010-09-28 17:41:08 -07:00
Aaron Patterson
cab12076d7 do not need intermediate variable, avoid lasgn 2010-09-28 17:41:03 -07:00
Aaron Patterson
1efeb5c935 DRY up our regular expression 2010-09-28 17:40:58 -07:00
Aaron Patterson
10d9740827 reduce method calls in the dynamic finder matcher 2010-09-28 17:40:50 -07:00
Aaron Patterson
40bc0cb34d where_values_hash always returns a hash 2010-09-28 17:39:06 -07:00
Marcelo Giorgi
9e5545cd66 Set attributes properly for model built from association with conditions [#5562 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-28 15:23:23 -03:00
Étienne Barrié
fae57ef4f5 Test add_index and remove_index with a symbol name #4891 2010-09-28 10:08:35 -07:00
Aaron Patterson
9edaf10fee porting 0665182950 to master. Thanks Marcelo Giorgi 2010-09-28 10:05:07 -07:00
Aaron Patterson
c2c6f12c84 porting 515917f5d8 to master 2010-09-28 10:05:02 -07:00
Neeraj Singh
2525bfc5dd backport of #5706 and #5579 to 3-0-stable
[#5706 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-28 10:32:24 +02:00
Neeraj Singh
e0411f3412 backport of #5705 to 3-0-stable
[#5705 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-28 10:32:20 +02:00
Xavier Noria
61e70bf623 revises RDoc of Hash#to_param to be more precise about ordering 2010-09-28 00:37:21 +02:00
Xavier Noria
6643929d5a let Hash#to_param and Hash#to_query sort again
This was a regression introduced in 5c85822008. We bring
sorting back because people rely on it, eg for constructing consistent cache keys.
2010-09-28 00:33:13 +02:00
Aaron Patterson
b32bd08622 make sure we use the engine assigned to the table when quoting 2010-09-27 14:29:21 -07:00
Neeraj Singh
9e32b1cbe5 after_create in ActiveModel should in the order specified
[#5650 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-27 23:18:05 +02:00
Diego Carrion
a56df5b052 renderer calls object.to_json when rendering :json => object [#5655 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-27 23:17:55 +02:00
Aaron Patterson
e677275068 depending on arel 2.0.0 2010-09-27 09:27:24 -07:00
Aaron Patterson
f38c46cfcf Revert "depend on the arel gem, not the arel git repo"
This reverts commit d5e916563e.
2010-09-27 09:26:32 -07:00
Aaron Patterson
a88af8a669 removing nonsensical tests, limit now actually adds a limit 2010-09-27 09:23:32 -07:00
Aaron Patterson
d5e916563e depend on the arel gem, not the arel git repo 2010-09-27 08:56:31 -07:00
Tim Connor
d3ffea25b2 Fix issue with remove_index and add unit test [#5645 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-27 14:59:59 +02:00
Tim Connor
2f618bf7da Raise errors when index creation fails
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-27 14:59:56 +02:00
Aaron Patterson
f90a29853f do not pass nil values to arel 2010-09-26 18:42:18 -07:00
Nic Benders
59ef0a2a50 db:structure:dump should list current Rails.env adapter in errors, not always the test adapter
[#5710 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-26 20:44:39 -03:00
Tim Connor
15fd9a21dc Fix remove_index issue when provided :name is a symbol
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-26 20:40:57 -03:00
Santiago Pastorino
19b71233fe Fix the precedence issue here 2010-09-26 17:55:13 -03:00
Santiago Pastorino
262319ab01 Not need to do this double ternary 2010-09-26 17:43:49 -03:00
Santiago Pastorino
268319c8ba port is appended twice to HTTP_HOST when host already has the port 2010-09-26 12:06:39 -03:00
Santiago Pastorino
c8bf9674dd Bump up more deps 2010-09-26 01:03:27 -03:00
Santiago Pastorino
c8b34f2d9f Bump up some deps 2010-09-26 00:43:09 -03:00
Andrew Kaspick
0387d5b6f2 memoized protected methods should remain protected
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-24 20:32:10 -03:00
Marcelo Giorgi
23f728abd5 Delegate ActiveRecord::Base.offset to scoped methods (analogous to limit) [#5688 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-24 20:25:24 -03:00
Brian Candler
4d023a6970 Fix warning message when db/schema.rb doesn't exist [#5625 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-24 17:43:02 -03:00
Emilio Tagua
e41add0d30 These tests shouldn't depend on local time to pass or fail, we can use utc here.
Signed-off-by: José Valim <jose.valim@gmail.com>
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-24 17:15:07 -03:00
Emilio Tagua
8a68862020 Fix typo and add sanity test for code statistics rake task.
Signed-off-by: José Valim <jose.valim@gmail.com>
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-24 17:15:07 -03:00
Emilio Tagua
49d54b4fb6 Refactor decode_credentials to avoid inject and use map instead.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-24 17:15:07 -03:00
Emilio Tagua
e66c1cee86 Perf: refactor _assign method to avoid inject and defining unneeded local var.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-24 17:15:06 -03:00
Emilio Tagua
8105bc022e Refactor methods in html node to avoid injects.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-24 17:15:06 -03:00
Emilio Tagua
abb99e3ac0 Refactor association_collection uniq method.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-24 17:15:06 -03:00
Emilio Tagua
e1e39a9a7b No need to use inject here.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-24 17:15:06 -03:00
Emilio Tagua
27cfb3e7bb Perf: refactor method.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-24 17:15:06 -03:00
Emilio Tagua
093a30a019 No need to use inject here, use map instead.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-24 17:15:06 -03:00
Emilio Tagua
68e1b5a397 Goodbye inject, hello map.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-24 17:15:06 -03:00
Jeff Kreeftmeijer
109c37b73f got rid of the "ambiguous first argument; put parentheses or even spaces" warnings in the scaffold_generator tests [#4872 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-24 16:18:50 -03:00
tnp
bdba74819c restore behavior of touch for models without :updated_xx [#5439 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-24 20:49:51 +02:00
Rodrigo Rosenfeld Rosas
8d14fa8959 Properly interpolate i18n keys in modules [#5572 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-24 20:49:33 +02:00
Aaron Patterson
1a61a797aa fixing bug with rails use of rack-test 2010-09-24 13:47:36 +02:00
Fred Wu
b0f059136b Ensures the app generator generates the correct @app_name. [#5434 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-24 13:12:25 +02:00
Carl Lerche
684bb86266 Improve performance of applications using file uploads by not busting the method cache on every request containing a file upload. 2010-09-22 17:37:00 -07:00
Santiago Pastorino
2db30351ed Missing the mysql2 gem here 2010-09-22 14:34:01 -03:00
Neeraj Singh
3c36c12a65 Error message should advice to use 'mysql2' gem.
If I create a new app using command
rails new demo -d mysql
then Gemfile contains 'mysql2' gem by default.

However if mysql gem is missing then error message says
raise "!!! Missing the mysql gem. Add it to your Gemfile: gem 'mysql', '2.8.1'"

[#5569 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-22 14:21:44 -03:00
Hemant Kumar
8765e06937 remove join table rows before removing owner row for habtm associations, fixes#5674 2010-09-22 08:36:29 -07:00
Aaron Patterson
7a6c715517 removing lolinject 2010-09-21 14:43:25 -07:00
Aaron Patterson
bfd4022075 fixing tests. woo 2010-09-21 14:43:20 -07:00
Aaron Patterson
a0fc2f7b74 providing arel with column information when possible [#5392 state:resolved] 2010-09-21 13:53:39 -07:00
Thiago Pradi
9d36e2ad2c Updating error message on ruby_version_check.rb
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-19 22:32:50 -07:00
rohit
39cb27b414 Fix output of 'rails runner --help' [#5661 state:committed]
Backport of 76266a

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-19 22:30:04 -07:00
rohit
68034efea1 Send 'rails runner' help message to stdout instead of stderr.
[#5661 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-19 16:47:46 -07:00
Santiago Pastorino
164e3b6612 application.js should be the last file on javascript_include_tag(:all) 2010-09-19 14:44:40 -07:00
Thiago Pradi
ab59522ea1 Exception handling more readable
[#5601 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-19 12:19:45 -07:00
Prem Sichanugrist
e125bf264e Use Time.current to maintain consistency with AS::Duration
In [32b82e4c6f], the committer has switch
methods in AS::Duration to use `Time.current` to return the correct
duration based on the `Time.default_zone` instead of using `Time.now`.

[#5607 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-19 11:47:25 -07:00
Andrew White
b79a782a05 Raise ArgumentError instead of normalizing controller name when there is a leading slash [#5651 state:resolved] 2010-09-18 17:59:24 +01:00
Andrew White
301462c89b Remove leading slash from controller [#5651 state:resolved] 2010-09-18 13:47:16 +01:00
rohit
7d54fba421 Application settings are specified in application.rb and not environment.rb 2010-09-14 20:08:08 +02:00
Carl Lerche
5391dd3821 Require lazy_load_hooks.rb with the correct path. 2010-09-14 10:40:15 -07:00
Jack Dempsey
a23bf047b6 require i18n in transliterate so it can run in isolated situations 2010-09-14 10:25:14 -07:00
Carl Lerche
b5a17d7648 Allow view helper's #initialize method to be called. [#5061 state:resolved] 2010-09-13 12:52:37 -07:00
Prem Sichanugrist
4ef2dead68 Add documentation for :spacer_template in Rails 3
This setting was existed since Rails 2.3.x, and seems like it have been left out when we rewriting the documentation.
2010-09-13 13:22:21 +10:00
Mikel Lindsaar
41807eb152 Backport of: added documentation for :as and :object in PartialRenderer
Commit: 02656ac397
2010-09-13 11:52:13 +10:00
Mikel Lindsaar
75b985e4e8 Fixing documentation to reflect deprecated add_to_base 2010-09-12 14:19:13 +10:00
Mikel Lindsaar
91693ddfe4 Backport of: added block arguments to ActionController::Metal#use
Commit: f0dbcc7a692bc375e3e52a9661af4037392ee52f
Useful for cases such as warden, where a block configuration is taken.

    class SomeController < ApplicationController
      use RailsWarden::Manager do |manager|
        manager.default_strategies :facebook_oauth
        manager.failure_app = SomeController.action(:authorize)
      end
    end
2010-09-12 11:47:25 +10:00
Mikel Lindsaar
14f1b09b46 Intersection between a relation and an array works in both directions.
Back port of commits a513f8f8bb marklazz (author) & 1c283765b6  Kanetontli (author)
2010-09-11 11:26:50 +10:00
Aaron Patterson
3479c1ea62 passing the quoted id to arel if the object has a quoted id 2010-09-10 15:30:48 -07:00
Aaron Patterson
89cc7426dd converting an inject to a map + Hash[] 2010-09-10 15:30:43 -07:00
Emilio Tagua
1817ae327e Add more examples in performance script.
[#5610 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-09-10 13:15:34 -07:00
Jeremy Kemper
c510870a8f Revert "Fix require for class_attribute"
This reverts commit 82ea5db030.
2010-09-10 12:17:02 -07:00
Jeremy Kemper
ceb193a201 Switch back to mysql for easier comparison 2010-09-10 12:17:02 -07:00
Jeremy Kemper
f6d5ff2f00 Ruby 1.9 compat: convert Pathname to string 2010-09-10 12:17:02 -07:00
Jeremy Kemper
b8ff3df6a4 Include addressable for AR perf bench 2010-09-10 12:17:02 -07:00
Aaron Patterson
465dd6f0e9 specific number of spaces should not be enforced 2010-09-10 11:51:47 -07:00
Aaron Patterson
2ef60690ff avoid method_missing and reduce method calls 2010-09-10 10:22:37 -07:00
Jeremy Kemper
ac89275f1d AR perf test: switch to mysql2, bundle faker and rbench 2010-09-09 14:42:55 -07:00
Jeremy Kemper
298da5b8a9 Fix require for class_attribute 2010-09-09 14:42:50 -07:00
Emilio Tagua
993572472a Refactor finder conditions look up and assigment for apply_finder_conditions. 2010-09-09 13:45:58 -07:00
Emilio Tagua
ab1ab5fcec Refactor Relation#only. No need to go through every option and test it. 2010-09-09 13:07:09 -07:00
Emilio Tagua
d30fb467c9 Add tests for Relation#only. 2010-09-09 13:07:05 -07:00
Emilio Tagua
172377df45 No need to go through every option and test it, just don't add skipped ones. 2010-09-09 13:07:01 -07:00
Neeraj Singh
733e928234 return is not needed here 2010-09-09 10:34:35 -07:00
Neeraj Singh
742da4b0d4 remove unnecessary call
if operation is count then column_name will never be blank
2010-09-09 10:34:05 -07:00
Aaron Patterson
2820addea7 creating a new array is required. who knew? :-( 2010-09-09 10:33:31 -07:00
Aaron Patterson
7108daf20e no need for Array.wrap, also avoid array creation 2010-09-09 09:44:25 -07:00
Neeraj Singh
a9b5b19d9a make apply_modules run faster 2010-09-09 09:44:20 -07:00
Mikel Lindsaar
ed9d30981f Fixing up rails application init command - Rails Guides ticket 32 2010-09-09 23:08:14 +10:00
Mikel Lindsaar
3de55aafbf Adding linkage to redirect_to from Base and adding status code option reference 2010-09-09 14:04:34 +10:00
Aaron Patterson
378728b5d1 eliminate present? for fewer method calls 2010-09-08 16:56:22 -07:00
Aaron Patterson
662ce52ed7 returning arrays lets us avoid Array.wrap 2010-09-08 16:53:41 -07:00
Aaron Patterson
ad781a175c removing unnecessary conditional test 2010-09-08 16:39:36 -07:00
Aaron Patterson
16cff17e53 switch to blank? to avoid method calls 2010-09-08 16:33:24 -07:00
Aaron Patterson
5297e641cd refactor to use faster empty? 2010-09-08 16:07:00 -07:00
Aaron Patterson
7ddf663c75 drying up joins() 2010-09-08 15:34:21 -07:00
Aaron Patterson
41e0f68474 reduce method calls, use reject + blank? instead of select + present? 2010-09-08 15:15:17 -07:00
Aaron Patterson
a746090a31 refactor a couple injects to map + Hash[] 2010-09-08 14:02:57 -07:00
Aaron Patterson
1276c28336 avoid an inject in favor of dup 2010-09-08 13:56:10 -07:00
Aaron Patterson
9a28d42d60 attributes should be constructed with table objects 2010-09-07 16:47:21 -07:00
Aaron Patterson
442e4d087b attributes should be associated with tables 2010-09-07 16:39:09 -07:00
Aaron Patterson
b1c104296e serialized attributes should be serialized before validation [#5525 state:resolved] 2010-09-07 13:39:37 -07:00
Aaron Patterson
ef66a08160 no need to freeze this string 2010-09-07 13:13:30 -07:00
Jeremy Kemper
33b954005c fixed some issues with JSON encoding
- as_json in ActiveModel should return a hash
  and handle :only/:except/:methods options
- Array and Hash should call as_json on their elements
- json methods should not modify options argument

[#5374 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>

Conflicts:

	activemodel/lib/active_model/serialization.rb
2010-09-07 11:33:46 -07:00
Aaron Patterson
3091cb386f removing useless code, cleaning variable names 2010-09-07 11:28:10 -07:00
Aaron Patterson
d73fcfeb52 select should raise error when no block or no parameter is passed 2010-09-07 10:48:24 -07:00
Aaron Patterson
b8899bba12 select does not need a *args 2010-09-07 10:33:43 -07:00
ISHIKAWA Takayuki
a461c2b595 revision of typo: crytographically [#5566 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-07 11:04:28 -03:00
Santiago Pastorino
c72140198d unscoped has nothing so merging with a relation just returns the relation 2010-09-07 03:33:42 -03:00
Aaron Patterson
bd1059f5ad cleaning up confusing logic 2010-09-06 18:56:38 -07:00
Santiago Pastorino
7020c92e0f Use scoped here to get the scoped where 2010-09-05 20:31:05 -03:00
Santiago Pastorino
817b8f0ac4 Make number_to_human and number_with_precision work with negatives 2010-09-05 10:26:03 -03:00
Santiago Pastorino
8c49666474 Fix indentation errors 2010-09-05 10:25:53 -03:00
Santiago Pastorino
9fe7ef65ea Fix code style a bit 2010-09-05 10:25:44 -03:00
Ben Sharpe
935fa9d6d5 Fix number_to_human(0) exception [#5532 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-05 10:25:35 -03:00
Santiago Pastorino
f0113e59c2 Make scoped reorder override previous applied orders
[5528 state:committed]
2010-09-05 09:29:57 -03:00
Nick Ragaz
02daf68e6a failing test for reorder overriding default_scope
[5528]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-05 09:29:51 -03:00
Neeraj Singh
1c7a7545eb order should always be concatenated.
order that is declared first has highest priority in all cases.

Here are some examples.

Car.order('name desc').find(:first, :order => 'id').name

Car.named_scope_with_order.named_scope_with_another_order

Car.order('id DESC').scoping do
  Car.find(:first, :order => 'id asc')
end

No special treatment to with_scope or scoping.

Also note that if default_scope declares an order then the order
declared in default_scope has the highest priority unless
with_exclusive_scope is used.

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-05 08:14:49 -03:00
Xavier Noria
29887510bf too many people are looking for the 2.3 guides, put by now a link at the top of the home, and add the Rails version in the main header 2010-09-03 22:00:42 +02:00
Andrew White
2ad2bd3644 Add missing lookup keys for error messages 2010-09-03 21:31:47 +02:00
Emilio Tagua
d7201210ba Use new finders syntax in docs. 2010-09-03 21:31:30 +02:00
Akira Matsuda
dcce930a8f fix typo(?) 2010-09-03 21:31:14 +02:00
Ken Collins
b1291836c3 A few schema changes for the SQL Server adapter.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2010-09-03 14:52:17 +12:00
rohit
6a60387dce Add two integration tests for GeneratedAttribute missing type error. [#5461 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-02 13:00:39 +02:00
rohit
233e0e8ce8 Output a friendly message when no type given for GeneratedAttribute [#5461 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-02 13:00:39 +02:00
rohit
5c06777293 Failing test for GeneratedAttribute [#5461 state:open]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-02 13:00:39 +02:00
Andreas Garnæs
86a96fb17c ActiveModel#to_xml fix (renamed parameter).
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-02 13:00:39 +02:00
José Valim
20866a5c95 Ensure routes are loaded only after the initialization process finishes, ensuring all configuration options were applied. 2010-09-02 13:00:39 +02:00
Akira Matsuda
3e931b1961 "rails console t" must not load "production" but "test" [#5527 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-02 11:55:33 +02:00
Santiago Pastorino
36e625df83 Add ruby-debug19 for mri 1.9 2010-09-01 21:24:51 -03:00
David Heinemeier Hansson
b227a9a948 Dont need to spell out the dependency 2010-09-01 19:09:48 -05:00
David Heinemeier Hansson
7221d6a841 Have sections for both Ruby 1.8.7 and 1.9.2 for the debugger since they use different gems 2010-09-01 17:38:48 -05:00
Andrew White
aefa11be11 Reset default scope in Thread.current when class is unloaded [#5497 state:resolved]
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-09-01 22:52:06 +02:00
Andrew White
bf87528b53 Add before_remove_const callback to ActiveSupport::Dependencies.remove_unloadable_constants!
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-09-01 22:52:06 +02:00
Emilio Tagua
93a716fb9c Fix test: this should return 0 not 7, since Arel was ignoring select clause and now it's fixed.
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-01 15:09:16 +02:00
Andrew White
9441eabbbf Move implicit nested call before options handling so that nested constraints work [#5513 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-01 10:15:24 +02:00
Alex Chrome
3b6d7f0df8 Added :format option for form_for helper and spec for this [#5226 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-01 10:15:24 +02:00
Jack Dempsey
c25c81e7c9 split out active_record migration logic so others can easily reuse [#5389 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-01 10:15:23 +02:00
Neeraj Singh
d1eb9ff8b1 delegate method should treat :prefix => false same as :prefix => nil
[#5375 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-01 10:15:23 +02:00
yury
3df90defa8 Remove unnecessary code from UrlHelper#link_to.
convert_options_to_data_attributes always returns not nil stringified html_options [#5445 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-01 10:15:23 +02:00
Krekoten' Marjan
2adad2a0cc Make ActiveSupport::Duration#method_missing delegate blocks to value [#5498 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-01 10:15:22 +02:00
Subba Rao Pasupuleti
9c5248f6f2 nested attributes tests should rely on associated objects to verify results not on assert_difference [#5206 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-01 10:15:22 +02:00
Thiago Pradi
fed73ffecf Use join instead of looping and calling to_s [#5492 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-01 10:15:21 +02:00
Andrew White
69ae216bcf Bump rack-mount to 0.6.13 and add test case for named character classes [#5509 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-08-31 21:28:44 -03:00
Pratik Naik
8cba115301 Make all the Relation finder methods consistent 2010-08-31 21:28:12 -03:00
Emilio Tagua
54b193fe16 Avoid calling build_where is no argument is given. 2010-08-31 21:27:49 -03:00
Emilio Tagua
5fc006a9a4 Improved conditionals usage to prevent calling methods. 2010-08-31 21:27:38 -03:00
Emilio Tagua
4144eace88 Don't test conditional in iteration if it is not present just clone it. 2010-08-31 21:27:27 -03:00
Pratik Naik
3746453c3a Remove default values for Relation#limit/offset/from/create_with 2010-08-31 21:26:26 -03:00
Pratik Naik
c2a87b45b8 Change relation merging to always append select, group and order values 2010-08-31 21:26:10 -03:00
Damien Mathieu
031b60d270 Fix benchmarking for rails3
* Fix the generated file examples
* Fix the generators commands
2010-09-01 00:06:41 +02:00
Jaime Iniesta
63306de3e7 Fix API docs for button_to options 2010-09-01 00:06:15 +02:00
Michael MacDonald
b29eb89be8 Corrected typo in example on rendering collections in partials changing @posts to @products to match the example 2010-09-01 00:05:52 +02:00
Pratik Naik
c1bafe07a9 Fix an english fail 2010-09-01 00:05:28 +02:00
Pratik Naik
e7b1b3f610 Fix the readonly section 2010-09-01 00:05:09 +02:00
Pratik Naik
3e786065f5 Update the section about joins 2010-09-01 00:04:55 +02:00
Pratik Naik
67b4c42b89 Fix pessimistic locking examples 2010-09-01 00:04:40 +02:00
Pratik Naik
bab620fe5c Reword calculations section 2010-09-01 00:04:24 +02:00
Pratik Naik
d37a44e42c Reword the section about exists? 2010-09-01 00:04:07 +02:00
Pratik Naik
c1915f5ff3 Improve example for having() 2010-09-01 00:03:48 +02:00
Pratik Naik
6ba646329b Remove {} from hash conditions. And more occurrences of [] in array conditions 2010-09-01 00:03:21 +02:00
Pratik Naik
9017e1f03f Array conditions dont need [] 2010-09-01 00:03:04 +02:00
Pratik Naik
6655a3c248 User.each is a lie 2010-08-31 00:28:16 +02:00
Joost Baaij
46fddc305a Remove mention of InstantRails, it is completely obsolete.
Mention RubyInstaller instead which is actually quite pleasant and runs Rails fine.

Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-08-31 00:28:01 +02:00
Joost Baaij
3e7f7668fc Remove beta and RC paths in documentation
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-08-31 00:27:41 +02:00
Damien Mathieu
3a96fa485c fix the cache_fu links
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-08-31 00:27:03 +02:00
Bryan Helmkamp
e709c97e08 Update README to match Rails 3 generated directory structure
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-08-31 00:26:43 +02:00
Akira Matsuda
050a345972 The command for creating the sessions table has changed
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-08-31 00:26:27 +02:00
Joost Baaij
e8d2002f21 Expanded routing documentation with current best practices
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-08-31 00:26:04 +02:00
Joost Baaij
05bb9cae95 Rework the routing documentation.
Move the default route to the bottom, as this practise should be discouraged.
Add documentation for resources, external redirects and Rack applications.

Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-08-31 00:25:35 +02:00
Xavier Noria
6ed616d51a let String#strip_heredoc handle blank lines even if they are not indented 2010-08-30 10:24:43 +02:00
Mikel Lindsaar
d9a323ea81 Adding option to ActiveResource to allow you to not reset the previously stored requests and responses by passing false to respond_to 2010-08-29 22:54:45 -07:00
Mikel Lindsaar
676b5bf970 Updating documentation on ActiveResource HTTP Mock and also adding test coverage 2010-08-29 22:54:45 -07:00
Jeremy Kemper
fcdedb2c00 Bump version to 3.0.1.pre 2010-08-29 21:59:53 -07:00
Jeremy Kemper
99a87e9dd0 Bump arel to 1.0.1 2010-08-29 16:33:09 -07:00
673 changed files with 18546 additions and 4727 deletions

4
.gitignore vendored
View File

@@ -1,18 +1,18 @@
*.gem
pkg
.bundle
Gemfile.lock
debug.log
doc/rdoc
activemodel/doc
activeresource/doc
activerecord/doc
activerecord/sqlnet.log
actionpack/doc
actionmailer/doc
activesupport/doc
activemodel/test/fixtures/fixture_database.sqlite3
actionpack/test/tmp
activesupport/test/fixtures/isolation_test
dist
railties/test/500.html
railties/test/fixtures/tmp
railties/test/initializer/root/log

25
.travis.yml Normal file
View File

@@ -0,0 +1,25 @@
script: 'ci/travis.rb'
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
env:
- "GEM=railties"
- "GEM=ap,am,amo,ares,as"
- "GEM=ar:mysql"
- "GEM=ar:mysql2"
- "GEM=ar:sqlite3"
- "GEM=ar:postgresql"
notifications:
email: false
irc:
on_success: change
on_failure: always
channels:
- "irc.freenode.org#rails-contrib"
campfire:
on_success: change
on_failure: always
rooms:
- secure: "CGWvthGkBKNnTnk9YSmf9AXKoiRI33fCl5D3jU4nx3cOPu6kv2R9nMjt9EAo\nOuS4Q85qNSf4VNQ2cUPNiNYSWQ+XiTfivKvDUw/QW9r1FejYyeWarMsSBWA+\n0fADjF1M2dkDIVLgYPfwoXEv7l+j654F1KLKB69F0F/netwP9CQ="
bundler_args: --path vendor/bundle

50
Gemfile
View File

@@ -1,53 +1,43 @@
source 'http://rubygems.org'
if ENV['AREL']
gem "arel", :path => ENV['AREL']
else
gem "arel", :git => "git://github.com/rails/arel.git"
end
gem "rails", :path => File.dirname(__FILE__)
gemspec
gem "rake", ">= 0.8.7"
gem "mocha", ">= 0.9.8"
gem "rdoc", ">= 2.5.10"
gem "horo", ">= 1.0.2"
gem 'mocha', '>= 0.13.0', :require => false
gem "pry"
group :doc do
gem "rdoc", "~> 3.4"
gem "horo", "= 1.0.3"
gem "RedCloth", "~> 4.2" if RUBY_VERSION < "1.9.3"
end
# for perf tests
gem "faker"
gem "rbench"
gem "addressable"
# AS
gem "memcache-client", ">= 1.8.5"
# AM
gem "text-format", "~> 1.0.0"
platforms :mri_18 do
gem "system_timer"
gem "ruby-debug", ">= 0.10.3"
end
platforms :ruby do
gem 'json'
gem 'yajl-ruby'
gem "nokogiri", ">= 1.4.3.1"
gem "nokogiri", ">= 1.4.4"
# AR
gem "sqlite3-ruby", "~> 1.3.1", :require => 'sqlite3'
gem "sqlite3", "~> 1.3.3"
group :db do
gem "pg", ">= 0.9.0"
gem "mysql", ">= 2.8.1"
gem "mysql2", ">= 0.2.3"
gem "mysql2", :git => "git://github.com/brianmario/mysql2.git", :branch => "0.2.x"
end
end
platforms :jruby do
gem "ruby-debug", ">= 0.10.3"
gem "activerecord-jdbcsqlite3-adapter"
group :db do
gem "activerecord-jdbcmysql-adapter"
gem "activerecord-jdbcpostgresql-adapter"
end
env :AREL do
gem "arel", :path => ENV['AREL']
end
# gems that are necessary for ActiveRecord tests with Oracle database

124
Gemfile.lock Normal file
View File

@@ -0,0 +1,124 @@
GIT
remote: git://github.com/brianmario/mysql2.git
revision: 3c7548851f5bf124eb23307286ef95d61172ac4b
branch: 0.2.x
specs:
mysql2 (0.2.22)
PATH
remote: .
specs:
actionmailer (3.0.20)
actionpack (= 3.0.20)
mail (~> 2.2)
actionpack (3.0.20)
activemodel (= 3.0.20)
activesupport (= 3.0.20)
builder (~> 3.2.0)
erubis (~> 2.7.0)
i18n (~> 0.6.0)
rack (~> 1.4.1)
rack-mount (~> 0.6.14)
rack-test (~> 0.6.1)
tzinfo (~> 0.3.23)
activemodel (3.0.20)
activesupport (= 3.0.20)
builder (~> 3.2.0)
i18n (~> 0.6.0)
activerecord (3.0.20)
activemodel (= 3.0.20)
activesupport (= 3.0.20)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
activeresource (3.0.20)
activemodel (= 3.0.20)
activesupport (= 3.0.20)
activesupport (3.0.20)
rails (3.0.20)
actionmailer (= 3.0.20)
actionpack (= 3.0.20)
activerecord (= 3.0.20)
activeresource (= 3.0.20)
activesupport (= 3.0.20)
bundler (~> 1.0)
railties (= 3.0.20)
railties (3.0.20)
actionpack (= 3.0.20)
activesupport (= 3.0.20)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.18)
GEM
remote: http://rubygems.org/
specs:
addressable (2.3.6)
arel (2.0.10)
builder (3.2.2)
coderay (1.1.0)
erubis (2.7.0)
faker (1.3.0)
i18n (~> 0.5)
horo (1.0.3)
rdoc (>= 2.5)
i18n (0.6.9)
json (1.8.1)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
memcache-client (1.8.5)
metaclass (0.0.4)
method_source (0.8.2)
mime-types (1.25.1)
mini_portile (0.5.3)
mocha (1.0.0)
metaclass (~> 0.0.1)
mysql (2.9.1)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
pg (0.17.1)
polyglot (0.3.4)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
rack (1.4.5)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.6.2)
rack (>= 1.0)
rake (10.2.2)
rbench (0.2.3)
rdoc (3.12.2)
json (~> 1.4)
slop (3.5.0)
sqlite3 (1.3.9)
thor (0.19.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.39)
yajl-ruby (1.2.0)
PLATFORMS
ruby
DEPENDENCIES
addressable
arel
faker
horo (= 1.0.3)
json
memcache-client (>= 1.8.5)
mocha (>= 0.13.0)
mysql (>= 2.8.1)
mysql2!
nokogiri (>= 1.4.4)
pg (>= 0.9.0)
pry
rails!
rake (>= 0.8.7)
rbench
rdoc (~> 3.4)
sqlite3 (~> 1.3.3)
yajl-ruby

View File

@@ -1 +1 @@
3.0.1
3.0.20

View File

@@ -3,7 +3,15 @@ require 'rdoc'
require 'rake'
require 'rdoc/task'
require 'rake/gempackagetask'
$:.unshift File.expand_path('..', __FILE__)
require "tasks/release"
desc "Build gem files for all projects"
task :build => "all:build"
desc "Release all gems to gemcutter and create a tag"
task :release => "all:release"
# RDoc skips some files in the Rails tree due to its binary? predicate. This is a quick
# hack for edge docs, until we decide which is the correct way to address this issue.
@@ -54,27 +62,6 @@ task :smoke do
system %(cd activerecord && #{$0} sqlite3:isolated_test)
end
spec = eval(File.read('rails.gemspec'))
Rake::GemPackageTask.new(spec) do |pkg|
pkg.gem_spec = spec
end
desc "Release all gems to gemcutter. Package rails, package & push components, then push rails"
task :release => :release_projects do
require 'rake/gemcutter'
Rake::Gemcutter::Tasks.new(spec).define
Rake::Task['gem:push'].invoke
end
desc "Release all components to gemcutter."
task :release_projects => :package do
errors = []
PROJECTS.each do |project|
system(%(cd #{project} && #{$0} release)) || errors << project
end
fail("Errors in #{errors.join(', ')}") unless errors.empty?
end
desc "Install gems for all projects."
task :install => :gem do
version = File.read("RAILS_VERSION").strip
@@ -144,6 +131,7 @@ task :rdoc do
FileUtils.copy "activerecord/examples/associations.png", "doc/rdoc/files/examples/associations.png"
end
desc 'Bump all versions to match version.rb'
task :update_versions do
require File.dirname(__FILE__) + "/version"

View File

@@ -1,6 +1,78 @@
## Rails 3.0.20 (unreleased)
## Rails 3.0.19 (Jan 8, 2013)
* No changes.
## Rails 3.0.18 (Jan 2, 2013)
* No changes.
## Rails 3.0.17 (Aug 9, 2012)
* No changes.
## Rails 3.0.16 (Jul 26, 2012)
* No changes.
## Rails 3.0.14 (Jun 12, 2012)
* No changes.
* Rails 3.0.13 (May 31, 2012)
* No changes.
*Rails 3.0.10 (August 16, 2011)*
*No changes.
*Rails 3.0.9 (June 16, 2011)*
*No changes.
*Rails 3.0.8 (June 7, 2011)*
* Mail dependency increased to 2.2.19
*Rails 3.0.7 (April 18, 2011)*
* remove AM delegating register_observer and register_interceptor to Mail [Josh Kalderimis]
*Rails 3.0.6 (April 5, 2011)
* Don't allow i18n to change the minor version, version now set to ~> 0.5.0 [Santiago Pastorino]
*Rails 3.0.5 (February 26, 2011)*
* No changes.
*Rails 3.0.4 (February 8, 2011)*
* No changes.
*Rails 3.0.3 (November 16, 2010)*
* No changes.
*Rails 3.0.2 (November 15, 2010)*
* No changes.
*Rails 3.0.1 (October 15, 2010)*
* No Changes, just a version bump.
* No Changes.
*Rails 3.0.0 (August 29, 2010)*

View File

@@ -1,7 +1,7 @@
require 'rake'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rubygems/package_task'
desc "Default Task"
task :default => [ :test ]
@@ -17,14 +17,14 @@ namespace :test do
task :isolated do
ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
Dir.glob("test/**/*_test.rb").all? do |file|
system(ruby, '-Ilib:test', file)
sh(ruby, '-Ilib:test', file)
end or raise "Failures"
end
end
spec = eval(File.read('actionmailer.gemspec'))
Rake::GemPackageTask.new(spec) do |p|
Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
end

View File

@@ -17,8 +17,6 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'
s.has_rdoc = true
s.add_dependency('actionpack', version)
s.add_dependency('mail', '~> 2.2.5')
s.add_dependency('mail', '~> 2.2')
end

View File

@@ -26,6 +26,7 @@ $:.unshift(actionpack_path) if File.directory?(actionpack_path) && !$:.include?(
require 'abstract_controller'
require 'action_view'
require 'action_mailer/version'
# Common Active Support usage in Action Mailer
require 'active_support/core_ext/class'

View File

@@ -4,6 +4,7 @@ require 'action_mailer/collector'
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/proc'
require 'active_support/core_ext/string/inflections'
require 'action_mailer/log_subscriber'
module ActionMailer #:nodoc:
@@ -234,8 +235,8 @@ module ActionMailer #:nodoc:
# default :sender => 'system@example.com'
# end
#
# You can pass in any header value that a <tt>Mail::Message</tt>, out of the box, <tt>ActionMailer::Base</tt>
# sets the following:
# You can pass in any header value that a <tt>Mail::Message</tt> accepts. Out of the box,
# <tt>ActionMailer::Base</tt> sets the following:
#
# * <tt>:mime_version => "1.0"</tt>
# * <tt>:charset => "UTF-8",</tt>
@@ -273,7 +274,7 @@ module ActionMailer #:nodoc:
# = Configuration options
#
# These options are specified on the class level, like
# <tt>ActionMailer::Base.template_root = "/my/templates"</tt>
# <tt>ActionMailer::Base.raise_delivery_errors = true</tt>
#
# * <tt>default</tt> - You can pass this in at a class level as well as within the class itself as
# per the above section.
@@ -290,7 +291,9 @@ module ActionMailer #:nodoc:
# * <tt>:password</tt> - If your mail server requires authentication, set the password in this setting.
# * <tt>:authentication</tt> - If your mail server requires authentication, you need to specify the
# authentication type here.
# This is a symbol and one of <tt>:plain</tt>, <tt>:login</tt>, <tt>:cram_md5</tt>.
# This is a symbol and one of <tt>:plain</tt> (will send the password in the clear), <tt>:login</tt> (will
# send password BASE64 encoded) or <tt>:cram_md5</tt> (combines a Challenge/Response mechanism to exchange
# information and a cryptographic Message Digest 5 algorithm to hash important information)
# * <tt>:enable_starttls_auto</tt> - When set to true, detects if STARTTLS is enabled in your SMTP server
# and starts to use it.
#
@@ -346,9 +349,6 @@ module ActionMailer #:nodoc:
include ActionMailer::OldApi
include ActionMailer::DeprecatedApi
delegate :register_observer, :to => Mail
delegate :register_interceptor, :to => Mail
private_class_method :new #:nodoc:
class_attribute :default_params
@@ -360,6 +360,31 @@ module ActionMailer #:nodoc:
}.freeze
class << self
# Register one or more Observers which will be notified when mail is delivered.
def register_observers(*observers)
observers.flatten.compact.each { |observer| register_observer(observer) }
end
# Register one or more Interceptors which will be called before mail is sent.
def register_interceptors(*interceptors)
interceptors.flatten.compact.each { |interceptor| register_interceptor(interceptor) }
end
# Register an Observer which will be notified when mail is delivered.
# Either a class or a string can be passed in as the Observer. If a string is passed in
# it will be <tt>constantize</tt>d.
def register_observer(observer)
delivery_observer = (observer.is_a?(String) ? observer.constantize : observer)
Mail.register_observer(delivery_observer)
end
# Register an Inteceptor which will be called before mail is sent.
# Either a class or a string can be passed in as the Observer. If a string is passed in
# it will be <tt>constantize</tt>d.
def register_interceptor(interceptor)
delivery_interceptor = (interceptor.is_a?(String) ? interceptor.constantize : interceptor)
Mail.register_interceptor(delivery_interceptor)
end
def mailer_name
@mailer_name ||= name.underscore

View File

@@ -3,17 +3,8 @@ module ActionMailer
# Uses Text::Format to take the text and format it, indented two spaces for
# each line, and wrapped at 72 columns.
def block_format(text)
begin
require 'text/format'
rescue LoadError => e
$stderr.puts "You don't have text-format installed in your application. Please add it to your Gemfile and run bundle install"
raise e
end unless defined?(Text::Format)
formatted = text.split(/\n\r\n/).collect { |paragraph|
Text::Format.new(
:columns => 72, :first_indent => 2, :body_indent => 2, :text => paragraph
).format
simple_format(paragraph)
}.join("\n")
# Make list points stand on their own line
@@ -37,5 +28,22 @@ module ActionMailer
def attachments
@_message.attachments
end
private
def simple_format(text, len = 72, indent = 2)
sentences = [[]]
text.split.each do |word|
if (sentences.last + [word]).join(' ').length > len
sentences << [word]
else
sentences.last << word
end
end
sentences.map { |sentence|
"#{" " * indent}#{sentence.join(' ')}"
}.join "\n"
end
end
end

View File

@@ -19,6 +19,10 @@ module ActionMailer
ActiveSupport.on_load(:action_mailer) do
include app.routes.url_helpers
register_interceptors(options.delete(:interceptors))
register_observers(options.delete(:observers))
options.each { |k,v| send("#{k}=", v) }
end
end

View File

@@ -2,8 +2,9 @@ module ActionMailer
module VERSION #:nodoc:
MAJOR = 3
MINOR = 0
TINY = 1
TINY = 20
PRE = nil
STRING = [MAJOR, MINOR, TINY].join('.')
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
end

View File

@@ -5,7 +5,7 @@ class <%= class_name %> < ActionMailer::Base
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.<%= file_name %>.<%= action %>.subject
# en.<%= file_path.gsub("/",".") %>.<%= action %>.subject
#
def <%= action %>
@greeting = "Hi"

View File

@@ -25,7 +25,6 @@ end
silence_warnings do
# These external dependencies have warnings :/
require 'text/format'
require 'mail'
end

View File

@@ -111,6 +111,7 @@ class BaseTest < ActiveSupport::TestCase
end
test "attachment with hash" do
skip "failed already"
email = BaseMailer.attachment_with_hash
assert_equal(1, email.attachments.length)
assert_equal('invoice.jpg', email.attachments[0].filename)
@@ -493,6 +494,11 @@ class BaseTest < ActiveSupport::TestCase
end
end
class MySecondObserver
def self.delivered_email(mail)
end
end
test "you can register an observer to the mail object that gets informed on email delivery" do
ActionMailer::Base.register_observer(MyObserver)
mail = BaseMailer.welcome
@@ -500,11 +506,31 @@ class BaseTest < ActiveSupport::TestCase
mail.deliver
end
test "you can register an observer using its stringified name to the mail object that gets informed on email delivery" do
ActionMailer::Base.register_observer("BaseTest::MyObserver")
mail = BaseMailer.welcome
MyObserver.expects(:delivered_email).with(mail)
mail.deliver
end
test "you can register multiple observers to the mail object that both get informed on email delivery" do
ActionMailer::Base.register_observers("BaseTest::MyObserver", MySecondObserver)
mail = BaseMailer.welcome
MyObserver.expects(:delivered_email).with(mail)
MySecondObserver.expects(:delivered_email).with(mail)
mail.deliver
end
class MyInterceptor
def self.delivering_email(mail)
end
end
class MySecondInterceptor
def self.delivering_email(mail)
end
end
test "you can register an interceptor to the mail object that gets passed the mail object before delivery" do
ActionMailer::Base.register_interceptor(MyInterceptor)
mail = BaseMailer.welcome
@@ -512,6 +538,21 @@ class BaseTest < ActiveSupport::TestCase
mail.deliver
end
test "you can register an interceptor using its stringified name to the mail object that gets passed the mail object before delivery" do
ActionMailer::Base.register_interceptor("BaseTest::MyInterceptor")
mail = BaseMailer.welcome
MyInterceptor.expects(:delivering_email).with(mail)
mail.deliver
end
test "you can register multiple interceptors to the mail object that both get passed the mail object before delivery" do
ActionMailer::Base.register_interceptors("BaseTest::MyInterceptor", MySecondInterceptor)
mail = BaseMailer.welcome
MyInterceptor.expects(:delivering_email).with(mail)
MySecondInterceptor.expects(:delivering_email).with(mail)
mail.deliver
end
test "being able to put proc's into the defaults hash and they get evaluated on mail sending" do
mail1 = ProcMailer.welcome
yesterday = 1.day.ago

View File

@@ -0,0 +1,4 @@
Hello there,
Mr. <%= @recipient %>. Be greeted, new member!

View File

@@ -0,0 +1,52 @@
require 'abstract_unit'
require 'action_controller'
require 'action_dispatch/testing/integration'
class I18nTestMailer < ActionMailer::Base
configure do |c|
c.assets_dir = ''
end
def mail_with_i18n_subject(recipient)
@recipient = recipient
I18n.locale = :de
mail(:to => recipient, :subject => "#{I18n.t :email_subject} #{recipient}",
:from => "system@loudthinking.com", :date => Time.local(2004, 12, 12))
end
end
class TestController < ActionController::Base
Routes = ActionDispatch::Routing::RouteSet.new
Routes.draw do
match ':controller(/:action(/:id))'
end
def self._routes
Routes
end
def send_mail
I18nTestMailer.mail_with_i18n_subject("test@localhost").deliver
render :text => 'Mail sent'
end
end
class ActionMailerI18nWithControllerTest < ActionDispatch::IntegrationTest
def app
TestController::Routes
end
def setup
I18n.backend.store_translations('de', :email_subject => '[Signed up] Welcome')
end
def teardown
I18n.locale = :en
end
def test_send_mail
get '/test/send_mail'
assert_equal "Mail sent", @response.body
end
end

View File

@@ -659,6 +659,8 @@ class ActionMailerTest < Test::Unit::TestCase
end
def test_performs_delivery_via_sendmail
skip "failed already"
IO.expects(:popen).once.with('/usr/sbin/sendmail -i -t -f "system@loudthinking.com" test@localhost', 'w+')
TestMailer.delivery_method = :sendmail
TestMailer.signed_up(@recipient).deliver
@@ -713,7 +715,7 @@ Content-Transfer-Encoding: quoted-printable
The=3Dbody
EOF
mail = Mail.new(msg)
mail = Mail.new(msg.strip)
assert_equal "The=body", mail.body.to_s.strip
assert_equal "The=3Dbody=", mail.body.encoded.strip
end
@@ -990,10 +992,10 @@ EOF
def test_recursive_multipart_processing
fixture = File.read(File.dirname(__FILE__) + "/../fixtures/raw_email7")
mail = Mail.new(fixture)
mail = Mail.new(fixture.strip)
assert_equal(2, mail.parts.length)
assert_equal(4, mail.parts.first.parts.length)
assert_equal("This is the first part.", mail.parts.first.parts.first.body.to_s)
assert_equal("This is the first part.\n", mail.parts.first.parts.first.body.to_s)
assert_equal("test.rb", mail.parts.first.parts.second.filename)
assert_equal("flowed", mail.parts.first.parts.fourth.content_type_parameters[:format])
assert_equal('smime.p7s', mail.parts.second.filename)
@@ -1132,6 +1134,8 @@ class MethodNamingTest < ActiveSupport::TestCase
end
def test_send_method
skip "failed already"
assert_nothing_raised do
assert_emails 1 do
assert_deprecated do

View File

@@ -58,12 +58,12 @@ class ActionMailerUrlTest < ActionMailer::TestCase
def test_signed_up_with_url
UrlTestMailer.delivery_method = :test
assert_deprecated do
# assert_deprecated do
AppRoutes.draw do |map|
map.connect ':controller/:action/:id'
map.welcome 'welcome', :controller=>"foo", :action=>"bar"
end
end
# end
expected = new_mail
expected.to = @recipient

View File

@@ -1,6 +1,202 @@
## Rails 3.0.20 (unreleased)
* Fixed JSON params parsing regression for non-object JSON content.
## Rails 3.0.19 (Jan 8, 2013)
* Strip nils from collections on JSON and XML posts. [CVE-2013-0155]
## Rails 3.0.18 (Jan 2, 2013)
* No changes.
## Rails 3.0.17 (Aug 9, 2012)
* There is an XSS vulnerability in the strip_tags helper in Ruby on Rails, the
helper doesn't correctly handle malformed html. As a result an attacker can
execute arbitrary javascript through the use of specially crafted malformed
html.
*Marek from Nethemba (www.nethemba.com) & Santiago Pastorino*
* When an "include_blank" value is supplied to the `select_tag` helper, the "include_blank" value is not escaped. If untrusted data is not escaped, and is supplied as the prompt value, there is a potential for XSS attacks.
Vulnerable code will look something like this:
select_tag("name", options, :include_blank => UNTRUSTED_INPUT)
*Santiago Pastorino*
## Rails 3.0.16 (Jul 26, 2012)
* Do not convert digest auth strings to symbols. CVE-2012-3424
## Rails 3.0.14 (Jun 12, 2012)
* nil is removed from array parameter values
CVE-2012-2694
* Rails 3.0.13 (May 31, 2012)
* Strip null bytes from Location header
* load the encoding converter to work around [ruby-core:41556] when switching
encodings
* Avoid inspecting the whole route set, closes #1525
* whitelist protocols for auto_link
* Strip [nil] from parameters hash. Thanks to Ben Murphy for reporting this!
CVE-2012-2660
*Rails 3.0.12 (unreleased)*
* Fix using `tranlate` helper with a html translation which uses the `:count` option for
pluralization.
*Jon Leighton*
*Rails 3.0.11 (unreleased)*
* Fix XSS security vulnerability in the `translate` helper method. When using interpolation
in combination with HTML-safe translations, the interpolated input would not get HTML
escaped. *GH 3664*
Before:
translate('foo_html', :something => '<script>') # => "...<script>..."
After:
translate('foo_html', :something => '<script>') # => "...&lt;script&gt;..."
*Sergey Nartimov*
* Implement a workaround for a bug in ruby-1.9.3p0 where an error would be
raised while attempting to convert a template from one encoding to another.
Please see http://redmine.ruby-lang.org/issues/5564 for details of the bug.
The workaround is to load all conversions into memory ahead of time, and will
only happen if the ruby version is exactly 1.9.3p0. The hope is obviously
that the underlying problem will be resolved in the next patchlevel release
of 1.9.3.
* Fix assert_select_email to work on multipart and non-multipart emails as the method stopped working correctly in Rails 3.x due to changes in the new mail gem.
* Fix url_for when passed a hash to prevent additional options (eg. :host, :protocol) from being added to the hash after calling it.
*Rails 3.0.10 (August 16, 2011)*
* Fixes an issue where cache sweepers with only after filters would have no
controller object, it would raise undefined method controller_name for nil [jeroenj]
* Ensure status codes are logged when exceptions are raised.
* Subclasses of OutputBuffer are respected.
* Fixed ActionView::FormOptionsHelper#select with :multiple => false
* Avoid extra call to Cache#read in case of a fragment cache hit
*Rails 3.0.9 (June 16, 2011)*
* json_escape will now return a SafeBuffer string if it receives SafeBuffer string [tenderlove]
* Make sure escape_js returns SafeBuffer string if it receives SafeBuffer string [Prem Sichanugrist]
* Fix text helpers to work correctly with the new SafeBuffer restriction [Paul Gallagher, Arun Agrawal, Prem Sichanugrist]
*Rails 3.0.8 (June 7, 2011)*
* It is prohibited to perform a in-place SafeBuffer mutation [tenderlove]
The old behavior of SafeBuffer allowed you to mutate string in place via
method like `sub!`. These methods can add unsafe strings to a safe buffer,
and the safe buffer will continue to be marked as safe.
An example problem would be something like this:
<%= link_to('hello world', @user).sub!(/hello/, params[:xss]) %>
In the above example, an untrusted string (`params[:xss]`) is added to the
safe buffer returned by `link_to`, and the untrusted content is successfully
sent to the client without being escaped. To prevent this from happening
`sub!` and other similar methods will now raise an exception when they are called on a safe buffer.
In addition to the in-place versions, some of the versions of these methods which return a copy of the string will incorrectly mark strings as safe. For example:
<%= link_to('hello world', @user).sub(/hello/, params[:xss]) %>
The new versions will now ensure that *all* strings returned by these methods on safe buffers are marked unsafe.
You can read more about this change in http://groups.google.com/group/rubyonrails-security/browse_thread/thread/2e516e7acc96c4fb
* Fixed github issue #342 with asset paths and relative roots.
*Rails 3.0.7 (April 18, 2011)*
*No changes.
*Rails 3.0.6 (April 5, 2011)
* Fixed XSS vulnerability in `auto_link`. `auto_link` no longer marks input as
html safe. Please make sure that calls to auto_link() are wrapped in a
sanitize(), or a raw() depending on the type of input passed to auto_link().
For example:
<%= sanitize(auto_link(some_user_input)) %>
Thanks to Torben Schulz for reporting this. The fix can be found here:
61ee3449674c591747db95f9b3472c5c3bd9e84d
* Fixes the output of `rake routes` to be correctly match to the behavior of the application, as the regular expression used to match the path is greedy and won't capture the format part by default [Prem Sichanugrist]
* Fixes an issue with number_to_human when converting values which are less than 1 but greater than -1 [Josh Kalderimis]
* Sensitive query string parameters (specified in config.filter_parameters) will now be filtered out from the request paths in the log file. [Prem Sichanugrist, fxn]
* URL parameters which return nil for to_param are now removed from the query string [Andrew White]
* Don't allow i18n to change the minor version, version now set to ~> 0.5.0 [Santiago Pastorino]
* Make TranslationHelper#translate use the :rescue_format option in I18n 0.5.0 [Sven Fuchs]
* Fix regression: javascript_include_tag shouldn't raise if you register an expansion key with nil or [] value [Santiago Pastorino]
* Fix Action caching bug where an action that has a non-cacheable response always renders a nil response body. It now correctly renders the response body. [Cheah Chu Yeow]
*Rails 3.0.5 (February 26, 2011)*
* No changes.
*Rails 3.0.4 (February 8, 2011)*
* No changes.
*Rails 3.0.3 (November 16, 2010)*
* When ActiveRecord::Base objects are sent to predicate methods, the id of the object should be sent to ARel, not the ActiveRecord::Base object.
* :constraints routing should only do sanity checks against regular expressions. String arguments are OK.
*Rails 3.0.2 (November 15, 2010)*
* The helper number_to_currency accepts a new :negative_format option to be able to configure how to render negative amounts. [Don Wilson]
*Rails 3.0.1 (October 15, 2010)*
* No Changes, just a version bump.
* No changes.
*Rails 3.0.0 (August 29, 2010)*
@@ -2008,7 +2204,7 @@ superclass' view_paths. [Rick Olson]
* Update documentation for erb trim syntax. #5651 [matt@mattmargolis.net]
* Pass :id => nil or :class => nil to error_messages_for to supress that html attribute. #3586 [olivier_ansaldi@yahoo.com, sebastien@goetzilla.info]
* Pass :id => nil or :class => nil to error_messages_for to supress that html attribute. #3586 [olivier_ansaldi@yahoo.com]
* Reset @html_document between requests so assert_tag works. #4810 [Jarkko Laine, easleydp@gmail.com]
@@ -2605,7 +2801,7 @@ superclass' view_paths. [Rick Olson]
* Provide support for decimal columns to form helpers. Closes #5672. [Dave Thomas]
* Pass :id => nil or :class => nil to error_messages_for to supress that html attribute. #3586 [olivier_ansaldi@yahoo.com, sebastien@goetzilla.info]
* Pass :id => nil or :class => nil to error_messages_for to supress that html attribute. #3586 [olivier_ansaldi@yahoo.com]
* Reset @html_document between requests so assert_tag works. #4810 [Jarkko Laine, easleydp@gmail.com]

View File

@@ -1,7 +1,7 @@
require 'rake'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rubygems/package_task'
desc "Default Task"
task :default => :test
@@ -35,7 +35,7 @@ end
spec = eval(File.read('actionpack.gemspec'))
Rake::GemPackageTask.new(spec) do |p|
Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
end

View File

@@ -17,15 +17,13 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'
s.has_rdoc = true
s.add_dependency('activesupport', version)
s.add_dependency('activemodel', version)
s.add_dependency('builder', '~> 2.1.2')
s.add_dependency('i18n', '~> 0.4.1')
s.add_dependency('rack', '~> 1.2.1')
s.add_dependency('rack-test', '~> 0.5.4')
s.add_dependency('rack-mount', '~> 0.6.12')
s.add_dependency('builder', '~> 3.2.0')
s.add_dependency('i18n', '~> 0.6.0')
s.add_dependency('rack', '~> 1.4.1')
s.add_dependency('rack-test', '~> 0.6.1')
s.add_dependency('rack-mount', '~> 0.6.14')
s.add_dependency('tzinfo', '~> 0.3.23')
s.add_dependency('erubis', '~> 2.6.6')
s.add_dependency('erubis', '~> 2.7.0')
end

View File

@@ -9,10 +9,11 @@ module AbstractController
# <tt>AbstractController::Base</tt> is a low-level API. Nobody should be
# using it directly, and subclasses (like ActionController::Base) are
# expected to provide their own +render+ method, since rendering means
# different things depending on the context.
# different things depending on the context.
class Base
attr_internal :response_body
attr_internal :action_name
attr_internal :formats
include ActiveSupport::Configurable
extend ActiveSupport::DescendantsTracker
@@ -30,10 +31,9 @@ module AbstractController
# A list of all internal methods for a controller. This finds the first
# abstract superclass of a controller, and gets a list of all public
# instance methods on that abstract class. Public instance methods of
# a controller would normally be considered action methods, so we
# are removing those methods on classes declared as abstract
# (ActionController::Metal and ActionController::Base are defined
# as abstract)
# a controller would normally be considered action methods, so methods
# declared on abstract classes are being removed.
# (ActionController::Metal and ActionController::Base are defined as abstract)
def internal_methods
controller = self
controller = controller.superclass until controller.abstract?
@@ -164,6 +164,8 @@ module AbstractController
action_missing(@_action_name)
end
CVE_2014_0130 = Class.new(StandardError)
# Takes an action name and returns the name of the method that will
# handle the action. In normal cases, this method returns the same
# name as it receives. By default, if #method_for_action receives
@@ -188,6 +190,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_name.include?("/")
raise CVE_2014_0130
end
if action_method?(action_name) then action_name
elsif respond_to?(:action_missing, true) then "_handle_action_missing"
end

View File

@@ -13,8 +13,8 @@ module AbstractController
# Override AbstractController::Base's process_action to run the
# process_action callbacks around the normal behavior.
def process_action(method_name)
run_callbacks(:process_action, method_name) do
def process_action(method_name, *args)
run_callbacks(:process_action, action_name) do
super
end
end
@@ -83,6 +83,7 @@ module AbstractController
# for details on the allowed parameters.
def #{filter}_filter(*names, &blk) # def before_filter(*names, &blk)
_insert_callbacks(names, blk) do |name, options| # _insert_callbacks(names, blk) do |name, options}
options[:if]=(Array.wrap(options[:if]) << "!halted") if #{filter == :after}
set_callback(:process_action, :#{filter}, name, options) # set_callback(:process_action, :before_filter, name, options)
end # end
end # end
@@ -91,6 +92,7 @@ module AbstractController
# for details on the allowed parameters.
def prepend_#{filter}_filter(*names, &blk) # def prepend_before_filter(*names, &blk)
_insert_callbacks(names, blk) do |name, options| # _insert_callbacks(names, blk) do |name, options|
options[:if]=(Array.wrap(options[:if]) << "!halted") if #{filter == :after}
set_callback(:process_action, :#{filter}, name, options.merge(:prepend => true)) # set_callback(:process_action, :before, name, options.merge(:prepend => true))
end # end
end # end

View File

@@ -235,13 +235,10 @@ module AbstractController
controller_path
end
# Takes the specified layout and creates a _layout method to be called
# by _default_layout
# Creates a _layout method to be called by _default_layout .
#
# If there is no explicit layout specified:
# If a layout is found in the view paths with the controller's
# name, return that string. Otherwise, use the superclass'
# layout (which might also be implied)
# If a layout is not explicitly mentioned then look for a layout with the controller's name.
# if nothing is found then try same procedure to find super class's layout.
def _write_layout_method
remove_possible_method(:_layout)

View File

@@ -14,14 +14,15 @@ module AbstractController
# it will trigger the lookup_context and consequently expire the cache.
# TODO Add some deprecation warnings to remove I18n.locale from controllers
class I18nProxy < ::I18n::Config #:nodoc:
attr_reader :i18n_config, :lookup_context
attr_reader :original_config, :lookup_context
def initialize(i18n_config, lookup_context)
@i18n_config, @lookup_context = i18n_config, lookup_context
def initialize(original_config, lookup_context)
original_config = original_config.original_config if original_config.respond_to?(:original_config)
@original_config, @lookup_context = original_config, lookup_context
end
def locale
@i18n_config.locale
@original_config.locale
end
def locale=(value)
@@ -47,13 +48,13 @@ module AbstractController
@view_context_class ||= begin
controller = self
Class.new(ActionView::Base) do
if controller.respond_to?(:_routes)
include controller._routes.url_helpers
end
if controller.respond_to?(:_helpers)
include controller._helpers
if controller.respond_to?(:_routes)
include controller._routes.url_helpers
end
# TODO: Fix RJS to not require this
self.helpers = controller._helpers
end

View File

@@ -148,6 +148,8 @@ module ActionController
#
# In this case, after saving our new entry to the database, the user is redirected to the <tt>show</tt> method which is then executed.
#
# Learn more about <tt>redirect_to</tt> and what options you have in ActionController::Redirecting.
#
# == Calling multiple redirects or renders
#
# An action may contain only a single render or a single redirect. Attempting to try to do either again will result in a DoubleRenderError:
@@ -202,16 +204,16 @@ module ActionController
HttpAuthentication::Digest::ControllerMethods,
HttpAuthentication::Token::ControllerMethods,
# Add instrumentations hooks at the bottom, to ensure they instrument
# all the methods properly.
Instrumentation,
# Before callbacks should also be executed the earliest as possible, so
# also include them at the bottom.
AbstractController::Callbacks,
# The same with rescue, append it at the end to wrap as much as possible.
Rescue
Rescue,
# Add instrumentations hooks at the bottom, to ensure they instrument
# all the methods properly.
Instrumentation
]
MODULES.each do |mod|

View File

@@ -4,29 +4,30 @@ module ActionController #:nodoc:
module Caching
# Action caching is similar to page caching by the fact that the entire
# output of the response is cached, but unlike page caching, every
# request still goes through the Action Pack. The key benefit
# of this is that filters are run before the cache is served, which
# allows for authentication and other restrictions on whether someone
# is allowed to see the cache. Example:
# request still goes through Action Pack. The key benefit of this is
# that filters run before the cache is served, which allows for
# authentication and other restrictions on whether someone is allowed
# to execute such action. Example:
#
# class ListsController < ApplicationController
# before_filter :authenticate, :except => :public
#
# caches_page :public
# caches_action :index, :show, :feed
# caches_action :index, :show
# end
#
# In this example, the public action doesn't require authentication,
# so it's possible to use the faster page caching method. But both
# the show and feed action are to be shielded behind the authenticate
# filter, so we need to implement those as action caches.
# In this example, the +public+ action doesn't require authentication
# so it's possible to use the faster page caching. On the other hand
# +index+ and +show+ require authentication. They can still be cached,
# but we need action caching for them.
#
# Action caching internally uses the fragment caching and an around
# filter to do the job. The fragment cache is named according to both
# the current host and the path. So a page that is accessed at
# http://david.somewhere.com/lists/show/1 will result in a fragment named
# "david.somewhere.com/lists/show/1". This allows the cacher to
# differentiate between "david.somewhere.com/lists/" and
# "jamis.somewhere.com/lists/" -- which is a helpful way of assisting
# Action caching uses fragment caching internally and an around
# filter to do the job. The fragment cache is named according to
# the host and path of the request. A page that is accessed at
# <tt>http://david.example.com/lists/show/1</tt> will result in a fragment named
# <tt>david.example.com/lists/show/1</tt>. This allows the cacher to
# differentiate between <tt>david.example.com/lists/</tt> and
# <tt>jamis.example.com/lists/</tt> -- which is a helpful way of assisting
# the subdomain-as-account-key pattern.
#
# Different representations of the same resource, e.g.
@@ -38,19 +39,23 @@ module ActionController #:nodoc:
# <tt>:action => 'list', :format => :xml</tt>.
#
# You can set modify the default action cache path by passing a
# :cache_path option. This will be passed directly to
# ActionCachePath.path_for. This is handy for actions with multiple
# possible routes that should be cached differently. If a block is
# given, it is called with the current controller instance.
# <tt>:cache_path</tt> option. This will be passed directly to
# <tt>ActionCachePath.path_for</tt>. This is handy for actions with
# multiple possible routes that should be cached differently. If a
# block is given, it is called with the current controller instance.
#
# And you can also use :if (or :unless) to pass a Proc that
# specifies when the action should be cached.
# And you can also use <tt>:if</tt> (or <tt>:unless</tt>) to pass a
# proc that specifies when the action should be cached.
#
# Finally, if you are using memcached, you can also pass :expires_in.
# Finally, if you are using memcached, you can also pass <tt>:expires_in</tt>.
#
# The following example depicts some of the points made above:
#
# class ListsController < ApplicationController
# before_filter :authenticate, :except => :public
# caches_page :public
#
# caches_page :public
#
# caches_action :index, :if => proc do |c|
# !c.request.format.json? # cache if is not a JSON request
# end
@@ -58,19 +63,28 @@ module ActionController #:nodoc:
# caches_action :show, :cache_path => { :project => 1 },
# :expires_in => 1.hour
#
# caches_action :feed, :cache_path => proc do |controller|
# if controller.params[:user_id]
# controller.send(:user_list_url,
# controller.params[:user_id], controller.params[:id])
# caches_action :feed, :cache_path => proc do |c|
# if c.params[:user_id]
# c.send(:user_list_url,
# c.params[:user_id], c.params[:id])
# else
# controller.send(:list_url, controller.params[:id])
# c.send(:list_url, c.params[:id])
# end
# end
# end
#
# If you pass :layout => false, it will only cache your action
# content. It is useful when your layout has dynamic information.
# If you pass <tt>:layout => false</tt>, it will only cache your action
# content. That's useful when your layout has dynamic information.
#
# Warning: If the format of the request is determined by the Accept HTTP
# header the Content-Type of the cached response could be wrong because
# no information about the MIME type is stored in the cache key. So, if
# you first ask for MIME type M in the Accept header, a cache entry is
# created, and then perform a second resquest to the same resource asking
# for a different MIME type, you'd get the content cached for M.
#
# The <tt>:format</tt> parameter is taken into account though. The safest
# way to cache by MIME type is to pass the format in the route.
module Actions
extend ActiveSupport::Concern
@@ -89,12 +103,14 @@ module ActionController #:nodoc:
end
def _save_fragment(name, options)
return unless caching_allowed?
content = response_body
content = content.join if content.is_a?(Array)
write_fragment(name, content, options)
if caching_allowed?
write_fragment(name, content, options)
else
content
end
end
protected

View File

@@ -71,9 +71,9 @@ module ActionController #:nodoc:
# Manually cache the +content+ in the key determined by +path+. Example:
# cache_page "I'm the cached content", "/lists/show"
def cache_page(content, path)
def cache_page(content, path, extension = nil)
return unless perform_caching
path = page_cache_path(path)
path = page_cache_path(path, extension)
instrument_page_cache :write_page, path do
FileUtils.makedirs(File.dirname(path))
@@ -98,14 +98,16 @@ module ActionController #:nodoc:
end
private
def page_cache_file(path)
def page_cache_file(path, extension)
name = (path.empty? || path == "/") ? "/index" : URI.unescape(path.chomp('/'))
name << page_cache_extension unless (name.split('/').last || name).include? '.'
unless (name.split('/').last || name).include? '.'
name << (extension || self.page_cache_extension)
end
return name
end
def page_cache_path(path)
page_cache_directory + page_cache_file(path)
def page_cache_path(path, extension = nil)
page_cache_directory + page_cache_file(path, extension)
end
def instrument_page_cache(name, path)
@@ -146,7 +148,12 @@ module ActionController #:nodoc:
request.path
end
self.class.cache_page(content || response.body, path)
if (type = Mime::LOOKUP[self.content_type]) && (type_symbol = type.symbol).present?
extension = ".#{type_symbol}"
end
self.class.cache_page(content || response.body, path, extension)
end
private

View File

@@ -61,6 +61,7 @@ module ActionController #:nodoc:
end
def after(controller)
self.controller = controller
callback(:after) if controller.perform_caching
# Clean up, so that the controller can be collected after this request
self.controller = nil

View File

@@ -8,7 +8,7 @@ module ActionController
"Please stop using it.", caller
end
def relative_url_root=
def relative_url_root=(value)
ActiveSupport::Deprecation.warn "ActionController::Base.relative_url_root= is ineffective. " <<
"Please stop using it.", caller
end
@@ -126,7 +126,7 @@ module ActionController
# This was moved to a plugin
def verify(*args)
ActiveSupport::Deprecation.warn "verify was removed from Rails and is now available as a plugin. " \
"Please install it with `rails plugin install git://github.com/rails/verification.git`.", caller
"Please install it with `rails plugin install git://github.com/sikachu/verification.git`.", caller
end
def exempt_from_layout(*)

View File

@@ -16,7 +16,11 @@ module ActionController
payload = event.payload
additions = ActionController::Base.log_process_action(payload)
message = "Completed #{payload[:status]} #{Rack::Utils::HTTP_STATUS_CODES[payload[:status]]} in %.0fms" % event.duration
status = payload[:status]
if status.nil? && payload[:exception].present?
status = Rack::Utils.status_code(ActionDispatch::ShowExceptions.rescue_responses[payload[:exception].first]) rescue nil
end
message = "Completed #{status} #{Rack::Utils::HTTP_STATUS_CODES[status]} in %.0fms" % event.duration
message << " (#{additions.join(" | ")})" unless additions.blank?
info(message)

View File

@@ -12,7 +12,7 @@ module ActionController
#
class MiddlewareStack < ActionDispatch::MiddlewareStack #:nodoc:
class Middleware < ActionDispatch::MiddlewareStack::Middleware #:nodoc:
def initialize(klass, *args)
def initialize(klass, *args, &block)
options = args.extract_options!
@only = Array(options.delete(:only)).map(&:to_s)
@except = Array(options.delete(:except)).map(&:to_s)
@@ -112,6 +112,11 @@ module ActionController
headers["Location"] = url
end
# basic url_for that can be overridden for more robust functionality
def url_for(string)
string
end
def status
@_status
end
@@ -147,8 +152,8 @@ module ActionController
super
end
def self.use(*args)
middleware_stack.use(*args)
def self.use(*args, &block)
middleware_stack.use(*args, &block)
end
def self.middleware

View File

@@ -60,7 +60,7 @@ module ActionController
end
def method_for_action(action_name)
super || (respond_to?(:method_missing) && "_handle_method_missing")
super || (defined?(self.method_missing) && "_handle_method_missing")
end
def performed?

View File

@@ -2,8 +2,6 @@ module ActionController
module Head
extend ActiveSupport::Concern
include ActionController::UrlFor
# Return a response that has no content (merely headers). The options
# argument is interpreted to be a hash of header names and values.
# This allows you to easily return a response that consists only of
@@ -27,8 +25,8 @@ module ActionController
self.status = status
self.location = url_for(location) if location
self.content_type = Mime[formats.first]
self.content_type = Mime[formats.first] if formats
self.response_body = " "
end
end
end
end

View File

@@ -95,12 +95,11 @@ module ActionController
# end
# end
#
# NOTE: The +authenticate_or_request_with_http_digest+ block must return the user's password or the ha1 digest hash so the framework can appropriately
# hash to check the user's credentials. Returning +nil+ will cause authentication to fail.
# Storing the ha1 hash: MD5(username:realm:password), is better than storing a plain password. If
# the password file or database is compromised, the attacker would be able to use the ha1 hash to
# authenticate as the user at this +realm+, but would not have the user's password to try using at
# other sites.
# === Notes
#
# The +authenticate_or_request_with_http_digest+ block must return the user's password
# or the ha1 digest hash so the framework can appropriately hash to check the user's
# credentials. Returning +nil+ will cause authentication to fail.
#
# On shared hosts, Apache sometimes doesn't pass authentication headers to
# FCGI instances. If your environment matches this description and you cannot
@@ -218,11 +217,10 @@ module ActionController
end
def decode_credentials(header)
header.to_s.gsub(/^Digest\s+/,'').split(',').inject({}) do |hash, pair|
HashWithIndifferentAccess[header.to_s.gsub(/^Digest\s+/,'').split(',').map do |pair|
key, value = pair.split('=', 2)
hash[key.strip.to_sym] = value.to_s.gsub(/^"|"$/,'').gsub(/'/, '')
hash
end
[key.strip, value.to_s.gsub(/^"|"$/,'').delete('\'')]
end]
end
def authentication_header(controller, realm)

View File

@@ -227,7 +227,7 @@ module ActionController #:nodoc:
"controller responds to in the class level" if self.class.mimes_for_respond_to.empty?
if response = retrieve_response_from_mimes(&block)
options = resources.extract_options!
options = resources.size == 1 ? {} : resources.extract_options!
options.merge!(:default_response => response)
(options.delete(:responder) || self.class.responder).call(self, resources, options)
end

View File

@@ -38,6 +38,9 @@ module ActionController
# redirect_to :action=>'atom', :status => :moved_permanently
# redirect_to post_url(@post), :status => 301
# redirect_to :action=>'atom', :status => 302
#
# The status code can either be a standard {HTTP Status code}[http://www.iana.org/assignments/http-status-codes] as an
# integer, or a symbol representing the downcased, underscored and symbolized description.
#
# It is also possible to assign a flash message as part of the redirection. There are two special accessors for commonly used the flash names
# +alert+ and +notice+ as well as a general purpose +flash+ bucket.
@@ -48,8 +51,7 @@ module ActionController
# redirect_to post_url(@post), :status => 301, :flash => { :updated_post_id => @post.id }
# redirect_to { :action=>'atom' }, :alert => "Something serious happened"
#
# When using <tt>redirect_to :back</tt>, if there is no referrer,
# RedirectBackError will be raised. You may specify some fallback
# When using <tt>redirect_to :back</tt>, if there is no referrer, RedirectBackError will be raised. You may specify some fallback
# behavior for this case by rescuing RedirectBackError.
def redirect_to(options = {}, response_status = {}) #:doc:
raise ActionControllerError.new("Cannot redirect to nil!") if options.nil?
@@ -85,7 +87,7 @@ module ActionController
refer
else
url_for(options)
end.gsub(/[\r\n]/, '')
end.gsub(/[\0\r\n]/, '')
end
end
end

View File

@@ -71,7 +71,7 @@ module ActionController
end
add :json do |json, options|
json = ActiveSupport::JSON.encode(json, options) unless json.respond_to?(:to_str)
json = json.to_json(options) unless json.kind_of?(String)
json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
self.content_type ||= Mime::JSON
self.response_body = json

View File

@@ -7,7 +7,7 @@ module ActionController
# Before processing, set the request formats in current controller formats.
def process_action(*) #:nodoc:
self.formats = request.formats.map { |x| x.to_sym }
self.formats = request.formats.map { |x| x.ref }
super
end

View File

@@ -71,39 +71,42 @@ module ActionController #:nodoc:
# class FooController < ApplicationController
# protect_from_forgery :except => :index
#
# # you can disable csrf protection on controller-by-controller basis:
# skip_before_filter :verify_authenticity_token
# end
# You can disable csrf protection on controller-by-controller basis:
#
# skip_before_filter :verify_authenticity_token
#
# It can also be disabled for specific controller actions:
#
# skip_before_filter :verify_authenticity_token, :except => [:create]
#
# Valid Options:
#
# * <tt>:only/:except</tt> - Passed to the <tt>before_filter</tt> call. Set which actions are verified.
def protect_from_forgery(options = {})
self.request_forgery_protection_token ||= :authenticity_token
before_filter :verify_authenticity_token, options
prepend_before_filter :verify_authenticity_token, options
end
end
protected
def protect_from_forgery(options = {})
self.request_forgery_protection_token ||= :authenticity_token
before_filter :verify_authenticity_token, options
end
# The actual before_filter that is used. Modify this to change how you handle unverified requests.
def verify_authenticity_token
verified_request? || raise(ActionController::InvalidAuthenticityToken)
verified_request? || handle_unverified_request
end
def handle_unverified_request
reset_session
end
# Returns true or false if a request is verified. Checks:
#
# * is the format restricted? By default, only HTML requests are checked.
# * is it a GET request? Gets should be safe and idempotent
# * Does the form_authenticity_token match the given token value from the params?
# * Does the X-CSRF-Token header match the form_authenticity_token
def verified_request?
!protect_against_forgery? || request.forgery_whitelisted? ||
form_authenticity_token == params[request_forgery_protection_token]
!protect_against_forgery? || request.get? ||
form_authenticity_token == params[request_forgery_protection_token] ||
form_authenticity_token == request.headers['X-CSRF-Token']
end
# Sets the token value for the current session.

View File

@@ -161,6 +161,8 @@ module ActionController #:nodoc:
display resource.errors, :status => :unprocessable_entity
elsif post?
display resource, :status => :created, :location => api_location
elsif has_empty_resource_definition?
display empty_resource, :status => :ok
else
head :ok
end
@@ -221,5 +223,23 @@ module ActionController #:nodoc:
def default_action
@action ||= ACTIONS_FOR_VERBS[request.request_method_symbol]
end
# Check whether resource needs a specific definition of empty resource to be valid
#
def has_empty_resource_definition?
respond_to?("empty_#{format}_resource", true)
end
# Delegate to proper empty resource method
#
def empty_resource
send("empty_#{format}_resource")
end
# Return a valid empty JSON resource
#
def empty_json_resource
"{}"
end
end
end

View File

@@ -40,6 +40,13 @@ module ActionController
ActiveSupport::Notifications.unsubscribe("!render_template.action_view")
end
def process(*args)
@partials = Hash.new(0)
@templates = Hash.new(0)
@layouts = Hash.new(0)
super
end
# Asserts that the request was rendered with the appropriate template file or partials.
#
# ==== Examples
@@ -92,11 +99,11 @@ module ActionController
elsif options.key?(:layout)
msg = build_message(message,
"expecting layout <?> but action rendered <?>",
expected_layout, @layouts.keys)
options[:layout], @layouts.keys)
case layout = options[:layout]
when String
assert(@layouts.include?(expected_layout), msg)
assert(@layouts.include?(layout), msg)
when Regexp
assert(@layouts.any? {|l| l =~ layout }, msg)
when nil
@@ -139,7 +146,9 @@ module ActionController
if value.is_a? Fixnum
value = value.to_s
elsif value.is_a? Array
value = Result.new(value)
value = Result.new(value.map { |v| v.is_a?(String) ? v.dup : v })
elsif value.is_a? String
value = value.dup
end
if extra_keys.include?(key.to_sym)

View File

@@ -38,18 +38,14 @@ module HTML #:nodoc:
private
def keys_to_strings(hash)
hash.keys.inject({}) do |h,k|
h[k.to_s] = hash[k]
h
end
Hash[hash.keys.map {|k| [k.to_s, hash[k]]}]
end
def keys_to_symbols(hash)
hash.keys.inject({}) do |h,k|
Hash[hash.keys.map do |k|
raise "illegal key #{k.inspect}" unless k.respond_to?(:to_sym)
h[k.to_sym] = hash[k]
h
end
[k.to_sym, hash[k]]
end]
end
end
@@ -77,9 +73,7 @@ module HTML #:nodoc:
# Return a textual representation of the node.
def to_s
s = ""
@children.each { |child| s << child.to_s }
s
@children.join()
end
# Return false (subclasses must override this to provide specific matching
@@ -162,7 +156,7 @@ module HTML #:nodoc:
end
closing = ( scanner.scan(/\//) ? :close : nil )
return Text.new(parent, line, pos, content) unless name = scanner.scan(/[\w:-]+/)
return Text.new(parent, line, pos, content) unless name = scanner.scan(/[^\s!>\/]+/)
name.downcase!
unless closing

View File

@@ -5,10 +5,10 @@ require 'active_support/core_ext/object/duplicable'
module ActionDispatch
module Http
# Allows you to specify sensitive parameters which will be replaced from
# the request log by looking in all subhashes of the param hash for keys
# to filter. If a block is given, each key and value of the parameter
# hash and all subhashes is passed to it, the value or key can be replaced
# using String#replace or similar method.
# the request log by looking in the query string of the request and all
# subhashes of the params hash to filter. If a block is given, each key and
# value of the params hash and all subhashes is passed to it, the value
# or key can be replaced using String#replace or similar method.
#
# Examples:
#
@@ -26,8 +26,6 @@ module ActionDispatch
module FilterParameters
extend ActiveSupport::Concern
@@parameter_filter_for = {}
# Return a hash of parameters with all sensitive data replaced.
def filtered_parameters
@filtered_parameters ||= parameter_filter.filter(parameters)
@@ -38,6 +36,11 @@ module ActionDispatch
@filtered_env ||= env_filter.filter(@env)
end
# Reconstructed a path with all sensitive GET parameters replaced.
def filtered_path
@filtered_path ||= query_string.empty? ? path : "#{path}?#{filtered_query_string}"
end
protected
def parameter_filter
@@ -49,7 +52,15 @@ module ActionDispatch
end
def parameter_filter_for(filters)
@@parameter_filter_for[filters] ||= ParameterFilter.new(filters)
ParameterFilter.new(filters)
end
KV_RE = '[^&;=]+'
PAIR_RE = %r{(#{KV_RE})=(#{KV_RE})}
def filtered_query_string
query_string.gsub(PAIR_RE) do |_|
parameter_filter.filter([[$1, $2]]).first.join("=")
end
end
end

View File

@@ -36,7 +36,7 @@ module ActionDispatch
#
# GET /posts/5.xml | request.format => Mime::XML
# GET /posts/5.xhtml | request.format => Mime::HTML
# GET /posts/5 | request.format => Mime::HTML or MIME::JS, or request.accepts.first depending on the value of <tt>ActionController::Base.use_accept_header</tt>
# GET /posts/5 | request.format => Mime::HTML or MIME::JS, or request.accepts.first
#
def format(view_path = [])
formats.first

View File

@@ -176,7 +176,11 @@ module Mime
end
def to_sym
@symbol || @string.to_sym
@symbol
end
def ref
to_sym || to_s
end
def ===(list)

View File

@@ -2,8 +2,10 @@ require 'tempfile'
require 'stringio'
require 'strscan'
require 'active_support/core_ext/module/deprecation'
require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/core_ext/string/access'
require 'active_support/inflector'
require 'action_dispatch/http/headers'
module ActionDispatch
@@ -44,8 +46,24 @@ module ActionDispatch
@env.key?(key)
end
HTTP_METHODS = %w(get head put post delete options)
HTTP_METHOD_LOOKUP = HTTP_METHODS.inject({}) { |h, m| h[m] = h[m.upcase] = m.to_sym; h }
# List of HTTP request methods from the following RFCs:
# Hypertext Transfer Protocol -- HTTP/1.1 (http://www.ietf.org/rfc/rfc2616.txt)
# HTTP Extensions for Distributed Authoring -- WEBDAV (http://www.ietf.org/rfc/rfc2518.txt)
# Versioning Extensions to WebDAV (http://www.ietf.org/rfc/rfc3253.txt)
# Ordered Collections Protocol (WebDAV) (http://www.ietf.org/rfc/rfc3648.txt)
# Web Distributed Authoring and Versioning (WebDAV) Access Control Protocol (http://www.ietf.org/rfc/rfc3744.txt)
# Web Distributed Authoring and Versioning (WebDAV) SEARCH (http://www.ietf.org/rfc/rfc5323.txt)
# PATCH Method for HTTP (http://www.ietf.org/rfc/rfc5789.txt)
RFC2616 = %w(OPTIONS GET HEAD POST PUT DELETE TRACE CONNECT)
RFC2518 = %w(PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK)
RFC3253 = %w(VERSION-CONTROL REPORT CHECKOUT CHECKIN UNCHECKOUT MKWORKSPACE UPDATE LABEL MERGE BASELINE-CONTROL MKACTIVITY)
RFC3648 = %w(ORDERPATCH)
RFC3744 = %w(ACL)
RFC5323 = %w(SEARCH)
RFC5789 = %w(PATCH)
HTTP_METHODS = RFC2616 + RFC2518 + RFC3253 + RFC3648 + RFC3744 + RFC5323 + RFC5789
HTTP_METHOD_LOOKUP = Hash.new { |h, m| h[m] = m.underscore.to_sym if HTTP_METHODS.include?(m) }
# Returns the HTTP \method that the application should see.
# In the case where the \method was overridden by a middleware
@@ -124,8 +142,9 @@ module ActionDispatch
end
def forgery_whitelisted?
get? || xhr? || content_mime_type.nil? || !content_mime_type.verify_request?
get?
end
deprecate :forgery_whitelisted? => "it is just an alias for 'get?' now, update your code"
def media_type
content_mime_type.to_s
@@ -199,7 +218,7 @@ module ActionDispatch
# TODO This should be broken apart into AD::Request::Session and probably
# be included by the session middleware.
def reset_session
session.destroy if session
session.destroy if session && session.respond_to?(:destroy)
self.session = {}
@env['action_dispatch.request.flash_hash'] = nil
end
@@ -238,5 +257,30 @@ module ActionDispatch
def local?
LOCALHOST.any? { |local_ip| local_ip === remote_addr && local_ip === remote_ip }
end
# Remove nils from the params hash
def deep_munge(hash)
hash.each do |k, v|
case v
when Array
if v.size > 0 && v.all?(&:nil?)
hash[k] = nil
next
end
v.grep(Hash) { |x| deep_munge(x) }
v.compact!
when Hash
deep_munge(v)
end
end
hash
end
protected
def parse_query(qs)
deep_munge(super)
end
end
end

View File

@@ -4,27 +4,26 @@ require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/class/attribute_accessors'
module ActionDispatch # :nodoc:
# Represents an HTTP response generated by a controller action. One can use
# an ActionDispatch::Response object to retrieve the current state
# of the response, or customize the response. An Response object can
# either represent a "real" HTTP response (i.e. one that is meant to be sent
# back to the web browser) or a test response (i.e. one that is generated
# from integration tests). See CgiResponse and TestResponse, respectively.
# Represents an HTTP response generated by a controller action. Use it to
# retrieve the current state of the response, or customize the response. It can
# either represent a real HTTP response (i.e. one that is meant to be sent
# back to the web browser) or a TestResponse (i.e. one that is generated
# from integration tests).
#
# Response is mostly a Ruby on Rails framework implement detail, and
# \Response is mostly a Ruby on \Rails framework implementation detail, and
# should never be used directly in controllers. Controllers should use the
# methods defined in ActionController::Base instead. For example, if you want
# to set the HTTP response's content MIME type, then use
# ActionControllerBase#headers instead of Response#headers.
#
# Nevertheless, integration tests may want to inspect controller responses in
# more detail, and that's when Response can be useful for application
# more detail, and that's when \Response can be useful for application
# developers. Integration test methods such as
# ActionDispatch::Integration::Session#get and
# ActionDispatch::Integration::Session#post return objects of type
# TestResponse (which are of course also of type Response).
# TestResponse (which are of course also of type \Response).
#
# For example, the following demo integration "test" prints the body of the
# For example, the following demo integration test prints the body of the
# controller response to the console:
#
# class DemoControllerTest < ActionDispatch::IntegrationTest

View File

@@ -1,32 +1,44 @@
require 'active_support/core_ext/object/blank'
module ActionDispatch
module Http
module UploadedFile
def self.extended(object)
object.class_eval do
attr_accessor :original_path, :content_type
alias_method :local_path, :path if method_defined?(:path)
end
class UploadedFile
attr_accessor :original_filename, :content_type, :tempfile, :headers
def initialize(hash)
@original_filename = encode_filename(hash[:filename])
@content_type = hash[:type]
@headers = hash[:head]
@tempfile = hash[:tempfile]
raise(ArgumentError, ':tempfile is required') unless @tempfile
end
# Take the basename of the upload's original filename.
# This handles the full Windows paths given by Internet Explorer
# (and perhaps other broken user agents) without affecting
# those which give the lone filename.
# The Windows regexp is adapted from Perl's File::Basename.
def original_filename
unless defined? @original_filename
@original_filename =
unless original_path.blank?
if original_path =~ /^(?:.*[:\\\/])?(.*)/m
$1
else
File.basename original_path
end
end
def open
@tempfile.open
end
def path
@tempfile.path
end
def read(*args)
@tempfile.read(*args)
end
def rewind
@tempfile.rewind
end
def size
@tempfile.size
end
private
def encode_filename(filename)
# Encode the filename in the utf8 encoding, unless it is nil or we're in 1.8
if "ruby".encoding_aware? && filename
filename.force_encoding("UTF-8").encode!
else
filename
end
@original_filename
end
end
@@ -35,11 +47,7 @@ module ActionDispatch
# file upload hash with UploadedFile objects
def normalize_parameters(value)
if Hash === value && value.has_key?(:tempfile)
upload = value[:tempfile]
upload.extend(UploadedFile)
upload.original_path = value[:filename]
upload.content_type = value[:type]
upload
UploadedFile.new(value)
else
super
end
@@ -47,4 +55,4 @@ module ActionDispatch
private :normalize_parameters
end
end
end
end

View File

@@ -16,17 +16,23 @@ module ActionDispatch
# Examples for writing:
#
# # Sets a simple session cookie.
# # This cookie will be deleted when the user's browser is closed.
# cookies[:user_name] = "david"
#
# # Assign an array of values to a cookie.
# cookies[:lat_lon] = [47.68, -122.37]
#
# # Sets a cookie that expires in 1 hour.
# cookies[:login] = { :value => "XJ-122", :expires => 1.hour.from_now }
#
# # Sets a signed cookie, which prevents a user from tampering with its value.
# # You must specify a value in ActionController::Base.cookie_verifier_secret.
# cookies.signed[:remember_me] = [current_user.id, current_user.salt]
# # The cookie is signed by your app's <tt>config.secret_token</tt> value.
# # Rails generates this value by default when you create a new Rails app.
# cookies.signed[:user_id] = current_user.id
#
# # Sets a "permanent" cookie (which expires in 20 years from now).
# cookies.permanent[:login] = "XJ-122"
#
# # You can also chain these methods:
# cookies.permanent.signed[:login] = "XJ-122"
#
@@ -34,6 +40,7 @@ module ActionDispatch
#
# cookies[:user_name] # => "david"
# cookies.size # => 2
# cookies[:lat_lon] # => [47.68, -122.37]
#
# Example for deleting:
#
@@ -98,17 +105,19 @@ module ActionDispatch
def self.build(request)
secret = request.env[TOKEN_KEY]
host = request.host
secure = request.ssl?
new(secret, host).tap do |hash|
new(secret, host, secure).tap do |hash|
hash.update(request.cookies)
end
end
def initialize(secret = nil, host = nil)
def initialize(secret = nil, host = nil, secure = false)
@secret = secret
@set_cookies = {}
@delete_cookies = {}
@host = host
@secure = secure
super()
end
@@ -193,9 +202,15 @@ module ActionDispatch
end
def write(headers)
@set_cookies.each { |k, v| ::Rack::Utils.set_cookie_header!(headers, k, v) }
@set_cookies.each { |k, v| ::Rack::Utils.set_cookie_header!(headers, k, v) if write_cookie?(v) }
@delete_cookies.each { |k, v| ::Rack::Utils.delete_cookie_header!(headers, k, v) }
end
private
def write_cookie?(cookie)
@secure || !cookie[:secure] || defined?(Rails.env) && Rails.env.development?
end
end
class PermanentCookieJar < CookieJar #:nodoc:
@@ -267,7 +282,7 @@ module ActionDispatch
"integrity hash for cookie session data. Use " +
"config.secret_token = \"some secret phrase of at " +
"least #{SECRET_MIN_LENGTH} characters\"" +
"in config/application.rb"
"in config/initializers/secret_token.rb"
end
if secret.length < SECRET_MIN_LENGTH

View File

@@ -38,7 +38,7 @@ module ActionDispatch
when Proc
strategy.call(request.raw_post)
when :xml_simple, :xml_node
data = Hash.from_xml(request.body.read) || {}
data = request.deep_munge(Hash.from_xml(request.body.read) || {})
request.body.rewind if request.body.respond_to?(:rewind)
data.with_indifferent_access
when :yaml
@@ -47,7 +47,7 @@ module ActionDispatch
data = ActiveSupport::JSON.decode(request.body)
request.body.rewind if request.body.respond_to?(:rewind)
data = {:_json => data} unless data.is_a?(Hash)
data.with_indifferent_access
request.deep_munge(data).with_indifferent_access
else
false
end

View File

@@ -43,20 +43,20 @@ module ActionDispatch
end
def call(env)
status, headers, body = @app.call(env)
begin
status, headers, body = @app.call(env)
exception = nil
# Only this middleware cares about RoutingError. So, let's just raise
# it here.
# TODO: refactor this middleware to handle the X-Cascade scenario without
# having to raise an exception.
if headers['X-Cascade'] == 'pass'
raise ActionController::RoutingError, "No route matches #{env['PATH_INFO'].inspect}"
# Only this middleware cares about RoutingError. So, let's just raise
# it here.
if headers['X-Cascade'] == 'pass'
raise ActionController::RoutingError, "No route matches #{env['PATH_INFO'].inspect}"
end
rescue Exception => exception
raise exception if env['action_dispatch.show_exceptions'] == false
end
[status, headers, body]
rescue Exception => exception
raise exception if env['action_dispatch.show_exceptions'] == false
render_exception(env, exception)
exception ? render_exception(env, exception) : [status, headers, body]
end
private

View File

@@ -1,7 +1,7 @@
<h1>
<%=h @exception.class.to_s %>
<% if @request.parameters['controller'] %>
in <%=h @request.parameters['controller'].humanize %>Controller<% if @request.parameters['action'] %>#<%=h @request.parameters['action'] %><% end %>
in <%=h @request.parameters['controller'].camelize %>Controller<% if @request.parameters['action'] %>#<%=h @request.parameters['action'] %><% end %>
<% end %>
</h1>
<pre><%=h @exception.message %></pre>

View File

@@ -8,10 +8,5 @@ module ActionDispatch
config.action_dispatch.ip_spoofing_check = true
config.action_dispatch.show_exceptions = true
config.action_dispatch.best_standards_support = true
# Prepare dispatcher callbacks and run 'prepare' callbacks
initializer "action_dispatch.prepare_dispatcher" do |app|
ActionDispatch::Callbacks.to_prepare { app.routes_reloader.execute_if_updated }
end
end
end

View File

@@ -2,31 +2,11 @@ require 'active_support/core_ext/object/to_param'
require 'active_support/core_ext/regexp'
module ActionDispatch
# = Routing
#
# The routing module provides URL rewriting in native Ruby. It's a way to
# redirect incoming requests to controllers and actions. This replaces
# mod_rewrite rules. Best of all, Rails' Routing works with any web server.
# mod_rewrite rules. Best of all, Rails' \Routing works with any web server.
# Routes are defined in <tt>config/routes.rb</tt>.
#
# Consider the following route, which you will find commented out at the
# bottom of your generated <tt>config/routes.rb</tt>:
#
# match ':controller(/:action(/:id(.:format)))'
#
# This route states that it expects requests to consist of a
# <tt>:controller</tt> followed optionally by an <tt>:action</tt> that in
# turn is followed optionally by an <tt>:id</tt>, which in turn is followed
# optionally by a <tt>:format</tt>
#
# Suppose you get an incoming request for <tt>/blog/edit/22</tt>, you'll end
# up with:
#
# params = { :controller => 'blog',
# :action => 'edit',
# :id => '22'
# }
#
# Think of creating routes as drawing a map for your requests. The map tells
# them where to go based on some predefined pattern:
#
@@ -43,6 +23,39 @@ module ActionDispatch
#
# Other names simply map to a parameter as in the case of <tt>:id</tt>.
#
# == Resources
#
# Resource routing allows you to quickly declare all of the common routes
# for a given resourceful controller. Instead of declaring separate routes
# for your +index+, +show+, +new+, +edit+, +create+, +update+ and +destroy+
# actions, a resourceful route declares them in a single line of code:
#
# resources :photos
#
# Sometimes, you have a resource that clients always look up without
# referencing an ID. A common example, /profile always shows the profile of
# the currently logged in user. In this case, you can use a singular resource
# to map /profile (rather than /profile/:id) to the show action.
#
# resource :profile
#
# It's common to have resources that are logically children of other
# resources:
#
# resources :magazines do
# resources :ads
# end
#
# You may wish to organize groups of controllers under a namespace. Most
# commonly, you might group a number of administrative controllers under
# an +admin+ namespace. You would place these controllers under the
# app/controllers/admin directory, and you can group them together in your
# router:
#
# namespace "admin" do
# resources :posts, :comments
# end
#
# == Named routes
#
# Routes can be named by passing an <tt>:as</tt> option,
@@ -131,6 +144,30 @@ module ActionDispatch
# Encoding regular expression modifiers are silently ignored. The
# match will always use the default encoding or ASCII.
#
# == Default route
#
# Consider the following route, which you will find commented out at the
# bottom of your generated <tt>config/routes.rb</tt>:
#
# match ':controller(/:action(/:id(.:format)))'
#
# This route states that it expects requests to consist of a
# <tt>:controller</tt> followed optionally by an <tt>:action</tt> that in
# turn is followed optionally by an <tt>:id</tt>, which in turn is followed
# optionally by a <tt>:format</tt>.
#
# Suppose you get an incoming request for <tt>/blog/edit/22</tt>, you'll end
# up with:
#
# params = { :controller => 'blog',
# :action => 'edit',
# :id => '22'
# }
#
# By not relying on default routes, you improve the security of your
# application since not all controller actions, which includes actions you
# might add at a later time, are exposed by default.
#
# == HTTP Methods
#
# Using the <tt>:via</tt> option when specifying a route allows you to restrict it to a specific HTTP method.
@@ -160,6 +197,20 @@ module ActionDispatch
# however if your route needs to respond to more than one HTTP method (or all methods) then using the
# <tt>:via</tt> option on <tt>match</tt> is preferable.
#
# == External redirects
#
# You can redirect any path to another path using the redirect helper in your router:
#
# match "/stories" => redirect("/posts")
#
# == Routing to Rack Applications
#
# Instead of a String, like <tt>posts#index</tt>, which corresponds to the
# index action in the PostsController, you can specify any Rack application
# as the endpoint for a matcher:
#
# match "/application.js" => Sprockets
#
# == Reloading routes
#
# You can reload routes if you feel you must:
@@ -208,7 +259,9 @@ module ActionDispatch
#
# == View a list of all your routes
#
# Run <tt>rake routes</tt>.
# rake routes
#
# Target specific controllers by prefixing the command with <tt>CONTROLLER=x</tt>.
#
module Routing
autoload :DeprecatedMapper, 'action_dispatch/routing/deprecated_mapper'

View File

@@ -31,8 +31,8 @@ module ActionDispatch
class DeprecatedMapper #:nodoc:
def initialize(set) #:nodoc:
ActiveSupport::Deprecation.warn "You are using the old router DSL which will be removed in Rails 3.1. " <<
"Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/"
# ActiveSupport::Deprecation.warn "You are using the old router DSL which will be removed in Rails 3.1. " <<
# "Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/"
@set = set
end
@@ -41,6 +41,7 @@ module ActionDispatch
if conditions = options.delete(:conditions)
conditions = conditions.dup
subdomain = conditions.delete(:subdomain)
method = [conditions.delete(:method)].flatten.compact
method.map! { |m|
m = m.to_s.upcase
@@ -123,6 +124,7 @@ module ActionDispatch
conditions = {}
conditions[:request_method] = method if method
conditions[:path_info] = path if path
conditions[:subdomain] = subdomain if subdomain
@set.add_route(app, conditions, requirements, defaults, name)
end

View File

@@ -1,6 +1,7 @@
require 'erb'
require 'active_support/core_ext/hash/except'
require 'active_support/core_ext/object/blank'
require 'active_support/inflector'
module ActionDispatch
module Routing
@@ -20,18 +21,22 @@ module ActionDispatch
@app, @constraints, @request = app, constraints, request
end
def call(env)
def matches?(env)
req = @request.new(env)
@constraints.each { |constraint|
if constraint.respond_to?(:matches?) && !constraint.matches?(req)
return [ 404, {'X-Cascade' => 'pass'}, [] ]
return false
elsif constraint.respond_to?(:call) && !constraint.call(*constraint_args(constraint, req))
return [ 404, {'X-Cascade' => 'pass'}, [] ]
return false
end
}
@app.call(env)
return true
end
def call(env)
matches?(env) ? @app.call(env) : [ 404, {'X-Cascade' => 'pass'}, [] ]
end
private
@@ -62,10 +67,21 @@ module ActionDispatch
if using_match_shorthand?(path_without_format, @options)
to_shorthand = @options[:to].blank?
@options[:to] ||= path_without_format[1..-1].sub(%r{/([^/]*)$}, '#\1')
@options[:as] ||= Mapper.normalize_name(path_without_format)
end
@options.merge!(default_controller_and_action(to_shorthand))
requirements.each do |name, requirement|
# segment_keys.include?(k.to_s) || k == :controller
next unless Regexp === requirement && !constraints[name]
if requirement.source =~ %r{\A(\\A|\^)|(\\Z|\\z|\$)\Z}
raise ArgumentError, "Regexp anchor characters are not allowed in routing requirements: #{requirement.inspect}"
end
if requirement.multiline?
raise ArgumentError, "Regexp multiline option not allowed in routing requirements: #{requirement.inspect}"
end
end
end
# match "account/overview"
@@ -90,7 +106,7 @@ module ActionDispatch
if @options[:format] == false
@options.delete(:format)
path
elsif path.include?(":format")
elsif path.include?(":format") || path.match(/\*[^\/]+$/)
path
else
"#{path}(.:format)"
@@ -140,6 +156,10 @@ module ActionDispatch
controller = [@scope[:module], controller].compact.join("/").presence
end
if controller.is_a?(String) && controller =~ %r{\A/}
raise ArgumentError, "controller name should not start with a slash"
end
controller = controller.to_s unless controller.is_a?(Regexp)
action = action.to_s unless action.is_a?(Regexp)
@@ -174,8 +194,8 @@ module ActionDispatch
def request_method_condition
if via = @options[:via]
via = Array(via).map { |m| m.to_s.upcase }
{ :request_method => Regexp.union(*via) }
via = Array(via).map { |m| m.to_s.dasherize.upcase }
{ :request_method => %r[^#{via.join('|')}$] }
else
{ }
end
@@ -226,16 +246,51 @@ module ActionDispatch
@set = set
end
# You can specify what Rails should route "/" to with the root method:
#
# root :to => 'pages#main'
#
# For options, see the +match+ method's documentation, as +root+ uses it internally.
#
# You should put the root route at the top of <tt>config/routes.rb</tt>,
# because this means it will be matched first. As this is the most popular route
# of most Rails applications, this is beneficial.
def root(options = {})
match '/', options.reverse_merge(:as => :root)
end
# When you set up a regular route, you supply a series of symbols that
# Rails maps to parts of an incoming HTTP request.
#
# match ':controller/:action/:id/:user_id'
#
# Two of these symbols are special: :controller maps to the name of a
# controller in your application, and :action maps to the name of an
# action within that controller. Anything other than :controller or
# :action will be available to the action as part of params.
def match(path, options=nil)
mapping = Mapping.new(@set, @scope, path, options || {}).to_route
@set.add_route(*mapping)
self
end
# Mount a Rack-based application to be used within the application.
#
# mount SomeRackApp, :at => "some_route"
#
# Alternatively:
#
# mount(SomeRackApp => "some_route")
#
# All mounted applications come with routing helpers to access them.
# These are named after the class specified, so for the above example
# the helper is either +some_rack_app_path+ or +some_rack_app_url+.
# To customize this helper's name, use the +:as+ option:
#
# mount(SomeRackApp => "some_route", :as => "exciting")
#
# This will generate the +exciting_path+ and +exciting_url+ helpers
# which can be used to navigate to this mounted app.
def mount(app, options = nil)
if options
path = options.delete(:at)
@@ -258,22 +313,49 @@ module ActionDispatch
end
module HttpHelpers
# Define a route that only recognizes HTTP GET.
# For supported arguments, see +match+.
#
# Example:
#
# get 'bacon', :to => 'food#bacon'
def get(*args, &block)
map_method(:get, *args, &block)
end
# Define a route that only recognizes HTTP POST.
# For supported arguments, see +match+.
#
# Example:
#
# post 'bacon', :to => 'food#bacon'
def post(*args, &block)
map_method(:post, *args, &block)
end
# Define a route that only recognizes HTTP PUT.
# For supported arguments, see +match+.
#
# Example:
#
# put 'bacon', :to => 'food#bacon'
def put(*args, &block)
map_method(:put, *args, &block)
end
# Define a route that only recognizes HTTP PUT.
# For supported arguments, see +match+.
#
# Example:
#
# delete 'broccoli', :to => 'food#broccoli'
def delete(*args, &block)
map_method(:delete, *args, &block)
end
# Redirect any path to another path:
#
# match "/stories" => redirect("/posts")
def redirect(*args, &block)
options = args.last.is_a?(Hash) ? args.pop : {}
@@ -314,12 +396,123 @@ module ActionDispatch
end
end
# You may wish to organize groups of controllers under a namespace.
# Most commonly, you might group a number of administrative controllers
# under an +admin+ namespace. You would place these controllers under
# the app/controllers/admin directory, and you can group them together
# in your router:
#
# namespace "admin" do
# resources :posts, :comments
# end
#
# This will create a number of routes for each of the posts and comments
# controller. For Admin::PostsController, Rails will create:
#
# GET /admin/photos
# GET /admin/photos/new
# POST /admin/photos
# GET /admin/photos/1
# GET /admin/photos/1/edit
# PUT /admin/photos/1
# DELETE /admin/photos/1
#
# If you want to route /photos (without the prefix /admin) to
# Admin::PostsController, you could use
#
# scope :module => "admin" do
# resources :posts, :comments
# end
#
# or, for a single case
#
# resources :posts, :module => "admin"
#
# If you want to route /admin/photos to PostsController
# (without the Admin:: module prefix), you could use
#
# scope "/admin" do
# resources :posts, :comments
# end
#
# or, for a single case
#
# resources :posts, :path => "/admin/posts"
#
# In each of these cases, the named routes remain the same as if you did
# not use scope. In the last case, the following paths map to
# PostsController:
#
# GET /admin/photos
# GET /admin/photos/new
# POST /admin/photos
# GET /admin/photos/1
# GET /admin/photos/1/edit
# PUT /admin/photos/1
# DELETE /admin/photos/1
module Scoping
def initialize(*args) #:nodoc:
@scope = {}
super
end
# Used to scope a set of routes to particular constraints.
#
# Take the following route definition as an example:
#
# scope :path => ":account_id", :as => "account" do
# resources :projects
# end
#
# This generates helpers such as +account_projects_path+, just like +resources+ does.
# The difference here being that the routes generated are like /rails/projects/2,
# rather than /accounts/rails/projects/2.
#
# === Supported options
# [:module]
# If you want to route /posts (without the prefix /admin) to
# Admin::PostsController, you could use
#
# scope :module => "admin" do
# resources :posts
# end
#
# [:path]
# If you want to prefix the route, you could use
#
# scope :path => "/admin" do
# resources :posts
# end
#
# This will prefix all of the +posts+ resource's requests with '/admin'
#
# [:as]
# Prefixes the routing helpers in this scope with the specified label.
#
# scope :as => "sekret" do
# resources :posts
# end
#
# Helpers such as +posts_path+ will now be +sekret_posts_path+
#
# [:shallow_path]
#
# Prefixes nested shallow routes with the specified path.
#
# scope :shallow_path => "sekret" do
# resources :posts do
# resources :comments, :shallow => true
# end
#
# The +comments+ resource here will have the following routes generated for it:
#
# post_comments GET /sekret/posts/:post_id/comments(.:format)
# post_comments POST /sekret/posts/:post_id/comments(.:format)
# new_post_comment GET /sekret/posts/:post_id/comments/new(.:format)
# edit_comment GET /sekret/comments/:id/edit(.:format)
# comment GET /sekret/comments/:id(.:format)
# comment PUT /sekret/comments/:id(.:format)
# comment DELETE /sekret/comments/:id(.:format)
def scope(*args)
options = args.extract_options!
options = options.dup
@@ -361,22 +554,139 @@ module ActionDispatch
@scope[:blocks] = recover[:block]
end
# Scopes routes to a specific controller
#
# Example:
# controller "food" do
# match "bacon", :action => "bacon"
# end
def controller(controller, options={})
options[:controller] = controller
scope(options) { yield }
end
# Scopes routes to a specific namespace. For example:
#
# namespace :admin do
# resources :posts
# end
#
# This generates the following routes:
#
# admin_posts GET /admin/posts(.:format) {:action=>"index", :controller=>"admin/posts"}
# admin_posts POST /admin/posts(.:format) {:action=>"create", :controller=>"admin/posts"}
# new_admin_post GET /admin/posts/new(.:format) {:action=>"new", :controller=>"admin/posts"}
# edit_admin_post GET /admin/posts/:id/edit(.:format) {:action=>"edit", :controller=>"admin/posts"}
# admin_post GET /admin/posts/:id(.:format) {:action=>"show", :controller=>"admin/posts"}
# admin_post PUT /admin/posts/:id(.:format) {:action=>"update", :controller=>"admin/posts"}
# admin_post DELETE /admin/posts/:id(.:format) {:action=>"destroy", :controller=>"admin/posts"}
# === Supported options
#
# The +:path+, +:as+, +:module+, +:shallow_path+ and +:shallow_prefix+ options all default to the name of the namespace.
#
# [:path]
# The path prefix for the routes.
#
# namespace :admin, :path => "sekret" do
# resources :posts
# end
#
# All routes for the above +resources+ will be accessible through +/sekret/posts+, rather than +/admin/posts+
#
# [:module]
# The namespace for the controllers.
#
# namespace :admin, :module => "sekret" do
# resources :posts
# end
#
# The +PostsController+ here should go in the +Sekret+ namespace and so it should be defined like this:
#
# class Sekret::PostsController < ApplicationController
# # code go here
# end
#
# [:as]
# Changes the name used in routing helpers for this namespace.
#
# namespace :admin, :as => "sekret" do
# resources :posts
# end
#
# Routing helpers such as +admin_posts_path+ will now be +sekret_posts_path+.
#
# [:shallow_path]
# See the +scope+ method.
def namespace(path, options = {})
path = path.to_s
options = { :path => path, :as => path, :module => path,
:shallow_path => path, :shallow_prefix => path }.merge!(options)
scope(options) { yield }
end
# === Parameter Restriction
# Allows you to constrain the nested routes based on a set of rules.
# For instance, in order to change the routes to allow for a dot character in the +id+ parameter:
#
# constraints(:id => /\d+\.\d+) do
# resources :posts
# end
#
# Now routes such as +/posts/1+ will no longer be valid, but +/posts/1.1+ will be.
# The +id+ parameter must match the constraint passed in for this example.
#
# You may use this to also resrict other parameters:
#
# resources :posts do
# constraints(:post_id => /\d+\.\d+) do
# resources :comments
# end
#
# === Restricting based on IP
#
# Routes can also be constrained to an IP or a certain range of IP addresses:
#
# constraints(:ip => /192.168.\d+.\d+/) do
# resources :posts
# end
#
# Any user connecting from the 192.168.* range will be able to see this resource,
# where as any user connecting outside of this range will be told there is no such route.
#
# === Dynamic request matching
#
# Requests to routes can be constrained based on specific critera:
#
# constraints(lambda { |req| req.env["HTTP_USER_AGENT"] =~ /iPhone/ }) do
# resources :iphones
# end
#
# You are able to move this logic out into a class if it is too complex for routes.
# This class must have a +matches?+ method defined on it which either returns +true+
# if the user should be given access to that route, or +false+ if the user should not.
#
# class Iphone
# def self.matches(request)
# request.env["HTTP_USER_AGENT"] =~ /iPhone/
# end
# end
#
# An expected place for this code would be +lib/constraints+.
#
# This class is then used like this:
#
# constraints(Iphone) do
# resources :iphones
# end
def constraints(constraints = {})
scope(:constraints => constraints) { yield }
end
# Allows you to set default parameters for a route, such as this:
# defaults :id => 'home' do
# match 'scoped_pages/(:id)', :to => 'pages#show'
# end
# Using this, the +:id+ parameter here will default to 'home'.
def defaults(defaults = {})
scope(:defaults => defaults) { yield }
end
@@ -441,6 +751,45 @@ module ActionDispatch
end
end
# Resource routing allows you to quickly declare all of the common routes
# for a given resourceful controller. Instead of declaring separate routes
# for your +index+, +show+, +new+, +edit+, +create+, +update+ and +destroy+
# actions, a resourceful route declares them in a single line of code:
#
# resources :photos
#
# Sometimes, you have a resource that clients always look up without
# referencing an ID. A common example, /profile always shows the profile of
# the currently logged in user. In this case, you can use a singular resource
# to map /profile (rather than /profile/:id) to the show action.
#
# resource :profile
#
# It's common to have resources that are logically children of other
# resources:
#
# resources :magazines do
# resources :ads
# end
#
# You may wish to organize groups of controllers under a namespace. Most
# commonly, you might group a number of administrative controllers under
# an +admin+ namespace. You would place these controllers under the
# app/controllers/admin directory, and you can group them together in your
# router:
#
# namespace "admin" do
# resources :posts, :comments
# end
#
# By default the :id parameter doesn't accept dots. If you need to
# use dots as part of the :id parameter add a constraint which
# overrides this restriction, e.g:
#
# resources :articles, :id => /[^\/]+/
#
# This allows any character other than a slash as part of your :id.
#
module Resources
# CANONICAL_ACTIONS holds all actions that does not need a prefix or
# a path appended since they fit properly in their scope level.
@@ -549,6 +898,24 @@ module ActionDispatch
@scope[:path_names].merge!(options)
end
# Sometimes, you have a resource that clients always look up without
# referencing an ID. A common example, /profile always shows the
# profile of the currently logged in user. In this case, you can use
# a singular resource to map /profile (rather than /profile/:id) to
# the show action:
#
# resource :geocoder
#
# creates six different routes in your application, all mapping to
# the GeoCoders controller (note that the controller is named after
# the plural):
#
# GET /geocoder/new
# POST /geocoder
# GET /geocoder
# GET /geocoder/edit
# PUT /geocoder
# DELETE /geocoder
def resource(*resources, &block)
options = resources.extract_options!
@@ -559,15 +926,15 @@ module ActionDispatch
resource_scope(SingletonResource.new(resources.pop, options)) do
yield if block_given?
collection_scope do
collection do
post :create
end if parent_resource.actions.include?(:create)
new_scope do
new do
get :new
end if parent_resource.actions.include?(:new)
member_scope do
member do
get :edit if parent_resource.actions.include?(:edit)
get :show if parent_resource.actions.include?(:show)
put :update if parent_resource.actions.include?(:update)
@@ -578,6 +945,61 @@ module ActionDispatch
self
end
# In Rails, a resourceful route provides a mapping between HTTP verbs
# and URLs and controller actions. By convention, each action also maps
# to particular CRUD operations in a database. A single entry in the
# routing file, such as
#
# resources :photos
#
# creates seven different routes in your application, all mapping to
# the Photos controller:
#
# GET /photos/new
# POST /photos
# GET /photos/:id
# GET /photos/:id/edit
# PUT /photos/:id
# DELETE /photos/:id
#
# Resources can also be nested infinitely by using this block syntax:
#
# resources :photos do
# resources :comments
# end
#
# This generates the following comments routes:
#
# GET /photos/:id/comments/new
# POST /photos/:id/comments
# GET /photos/:id/comments/:id
# GET /photos/:id/comments/:id/edit
# PUT /photos/:id/comments/:id
# DELETE /photos/:id/comments/:id
#
# === Supported options
# [:path_names]
# Allows you to change the paths of the seven default actions.
# Paths not specified are not changed.
#
# resources :posts, :path_names => { :new => "brand_new" }
#
# The above example will now change /posts/new to /posts/brand_new
#
# [:module]
# Set the module where the controller can be found. Defaults to nothing.
#
# resources :posts, :module => "admin"
#
# All requests to the posts resources will now go to +Admin::PostsController+.
#
# [:path]
#
# Set a path prefix for this resource.
#
# resources :posts, :path => "admin/posts"
#
# All actions for this resource will now be at +/admin/posts+.
def resources(*resources, &block)
options = resources.extract_options!
@@ -588,16 +1010,16 @@ module ActionDispatch
resource_scope(Resource.new(resources.pop, options)) do
yield if block_given?
collection_scope do
collection do
get :index if parent_resource.actions.include?(:index)
post :create if parent_resource.actions.include?(:create)
end
new_scope do
new do
get :new
end if parent_resource.actions.include?(:new)
member_scope do
member do
get :edit if parent_resource.actions.include?(:edit)
get :show if parent_resource.actions.include?(:show)
put :update if parent_resource.actions.include?(:update)
@@ -608,23 +1030,50 @@ module ActionDispatch
self
end
# To add a route to the collection:
#
# resources :photos do
# collection do
# get 'search'
# end
# end
#
# This will enable Rails to recognize paths such as <tt>/photos/search</tt>
# with GET, and route to the search action of PhotosController. It will also
# create the <tt>search_photos_url</tt> and <tt>search_photos_path</tt>
# route helpers.
def collection
unless @scope[:scope_level] == :resources
raise ArgumentError, "can't use collection outside resources scope"
unless resource_scope?
raise ArgumentError, "can't use collection outside resource(s) scope"
end
collection_scope do
yield
with_scope_level(:collection) do
scope(parent_resource.collection_scope) do
yield
end
end
end
# To add a member route, add a member block into the resource block:
#
# resources :photos do
# member do
# get 'preview'
# end
# end
#
# This will recognize <tt>/photos/1/preview</tt> with GET, and route to the
# preview action of PhotosController. It will also create the
# <tt>preview_photo_url</tt> and <tt>preview_photo_path</tt> helpers.
def member
unless resource_scope?
raise ArgumentError, "can't use member outside resource(s) scope"
end
member_scope do
yield
with_scope_level(:member) do
scope(parent_resource.member_scope) do
yield
end
end
end
@@ -633,8 +1082,10 @@ module ActionDispatch
raise ArgumentError, "can't use new outside resource(s) scope"
end
new_scope do
yield
with_scope_level(:new) do
scope(parent_resource.new_scope(action_path(:new))) do
yield
end
end
end
@@ -660,6 +1111,7 @@ module ActionDispatch
end
end
# See ActionDispatch::Routing::Mapper::Scoping#namespace
def namespace(path, options = {})
if resource_scope?
nested { super }
@@ -708,9 +1160,14 @@ module ActionDispatch
if action.to_s =~ /^[\w\/]+$/
options[:action] ||= action unless action.to_s.include?("/")
options[:as] = name_for_action(action, options[:as])
else
options[:as] = name_for_action(options[:as])
action = nil
end
if options.key?(:as) && !options[:as]
options.delete(:as)
else
options[:as] = name_for_action(options[:as], action)
end
super(path, options)
@@ -740,6 +1197,11 @@ module ActionDispatch
return true
end
if resource_scope?
nested { send(method, resources.pop, options, &block) }
return true
end
options.keys.each do |k|
(options[:constraints] ||= {})[k] = options.delete(k) if options[k].is_a?(Regexp)
end
@@ -756,13 +1218,6 @@ module ActionDispatch
options.merge!(scope_action_options) if scope_action_options?
end
if resource_scope?
nested do
send(method, resources.pop, options, &block)
end
return true
end
false
end
@@ -816,30 +1271,6 @@ module ActionDispatch
end
end
def new_scope
with_scope_level(:new) do
scope(parent_resource.new_scope(action_path(:new))) do
yield
end
end
end
def collection_scope
with_scope_level(:collection) do
scope(parent_resource.collection_scope) do
yield
end
end
end
def member_scope
with_scope_level(:member) do
scope(parent_resource.member_scope) do
yield
end
end
end
def nested_options
{}.tap do |options|
options[:as] = parent_resource.member_name
@@ -848,11 +1279,11 @@ module ActionDispatch
end
def id_constraint?
@scope[:id].is_a?(Regexp) || (@scope[:constraints] && @scope[:constraints][:id].is_a?(Regexp))
@scope[:constraints] && @scope[:constraints][:id].is_a?(Regexp)
end
def id_constraint
@scope[:id] || @scope[:constraints][:id]
@scope[:constraints][:id]
end
def canonical_action?(action, flag)
@@ -878,29 +1309,29 @@ module ActionDispatch
path || @scope[:path_names][name.to_sym] || name.to_s
end
def prefix_name_for_action(action, as)
if as.present?
def prefix_name_for_action(as, action)
if as
as.to_s
elsif as
nil
elsif !canonical_action?(action, @scope[:scope_level])
action.to_s
end
end
def name_for_action(action, as=nil)
prefix = prefix_name_for_action(action, as)
def name_for_action(as, action)
prefix = prefix_name_for_action(as, action)
prefix = Mapper.normalize_name(prefix) if prefix
name_prefix = @scope[:as]
if parent_resource
return nil if as.nil? && action.nil?
collection_name = parent_resource.collection_name
member_name = parent_resource.member_name
end
name = case @scope[:scope_level]
when :nested
[member_name, prefix]
[name_prefix, prefix]
when :collection
[prefix, name_prefix, collection_name]
when :new
@@ -913,7 +1344,8 @@ module ActionDispatch
[name_prefix, member_name, prefix]
end
name.select(&:present?).join("_").presence
candidate = name.select(&:present?).join("_").presence
candidate unless as.nil? && @set.routes.find { |r| r.name == candidate }
end
end

View File

@@ -17,7 +17,7 @@ module ActionDispatch
#
# == Usage within the framework
#
# Polymorphic URL helpers are used in a number of places throughout the Rails framework:
# Polymorphic URL helpers are used in a number of places throughout the \Rails framework:
#
# * <tt>url_for</tt>, so you can use it with a record as the argument, e.g.
# <tt>url_for(@article)</tt>;

View File

@@ -34,7 +34,8 @@ module ActionDispatch
if method = conditions[:request_method]
case method
when Regexp
method.source.upcase
source = method.source.upcase
source =~ /\A\^[-A-Z|]+\$\Z/ ? source[1..-2] : source
else
method.to_s.upcase
end

View File

@@ -6,6 +6,12 @@ require 'action_dispatch/routing/deprecated_mapper'
module ActionDispatch
module Routing
class RouteSet #:nodoc:
# Since the router holds references to many parts of the system
# like engines, controllers and the application itself, inspecting
# the route set can actually be really slow, therefore we default
# alias inspect to to_s.
alias inspect to_s
PARAMETERS_KEY = 'action_dispatch.request.path_parameters'
class Dispatcher #:nodoc:
@@ -295,6 +301,7 @@ module ActionDispatch
end
def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true)
raise ArgumentError, "Invalid route name: '#{name}'" unless name.blank? || name.to_s.match(/^[_a-z]\w*$/i)
route = Route.new(self, app, conditions, requirements, defaults, name, anchor)
@set.add_route(*route)
named_routes[name] = route if name
@@ -396,7 +403,7 @@ module ActionDispatch
raise_routing_error unless path
params.reject! {|k,v| !v }
params.reject! {|k,v| !v.to_param}
return [path, params.keys] if @extras
@@ -421,7 +428,7 @@ module ActionDispatch
end
def raise_routing_error
raise ActionController::RoutingError.new("No route matches #{options.inspect}")
raise ActionController::RoutingError, "No route matches #{options.inspect}"
end
def different_controller?
@@ -497,7 +504,7 @@ module ActionDispatch
path = Rack::Mount::Utils.normalize_path(path) unless path =~ %r{://}
begin
env = Rack::MockRequest.env_for(path, {:method => method})
env = Rack::MockRequest.env_for(path, {:method => method, :params => environment[:extras]})
rescue URI::InvalidURIError => e
raise ActionController::RoutingError, e.message
end
@@ -512,7 +519,9 @@ module ActionDispatch
end
dispatcher = route.app
dispatcher = dispatcher.app while dispatcher.is_a?(Mapper::Constraints)
while dispatcher.is_a?(Mapper::Constraints) && dispatcher.matches?(env) do
dispatcher = dispatcher.app
end
if dispatcher.is_a?(Dispatcher) && dispatcher.controller(params, false)
dispatcher.prepare_params!(params)

View File

@@ -1,6 +1,6 @@
module ActionDispatch
module Routing
# In <b>routes.rb</b> one defines URL-to-controller mappings, but the reverse
# In <tt>config/routes.rb</tt> you define URL-to-controller mappings, but the reverse
# is also possible: an URL can be generated from one of your routing definitions.
# URL generation functionality is centralized in this module.
#
@@ -12,15 +12,14 @@ module ActionDispatch
#
# == URL generation from parameters
#
# As you may know, some functions - such as ActionController::Base#url_for
# As you may know, some functions, such as ActionController::Base#url_for
# and ActionView::Helpers::UrlHelper#link_to, can generate URLs given a set
# of parameters. For example, you've probably had the chance to write code
# like this in one of your views:
#
# <%= link_to('Click here', :controller => 'users',
# :action => 'new', :message => 'Welcome!') %>
#
# # Generates a link to /users/new?message=Welcome%21
# # => "/users/new?message=Welcome%21"
#
# link_to, and all other functions that require URL generation functionality,
# actually use ActionController::UrlFor under the hood. And in particular,
@@ -61,7 +60,7 @@ module ActionDispatch
#
# UrlFor also allows one to access methods that have been auto-generated from
# named routes. For example, suppose that you have a 'users' resource in your
# <b>routes.rb</b>:
# <tt>config/routes.rb</tt>:
#
# resources :users
#
@@ -129,7 +128,7 @@ module ActionDispatch
when String
options
when nil, Hash
_routes.url_for((options || {}).reverse_merge!(url_options).symbolize_keys)
_routes.url_for((options || {}).reverse_merge(url_options).symbolize_keys)
else
polymorphic_url(options)
end

View File

@@ -94,7 +94,7 @@ module ActionDispatch
refer
else
@controller.url_for(fragment)
end.gsub(/[\r\n]/, '')
end.gsub(/[\0\r\n]/, '')
end
def validate_request!

View File

@@ -37,9 +37,6 @@ module ActionDispatch
#
# # Test a custom route
# assert_recognizes({:controller => 'items', :action => 'show', :id => '1'}, 'view/item1')
#
# # Check a Simply RESTful generated route
# assert_recognizes list_items_url, 'items/list'
def assert_recognizes(expected_options, path, extras={}, message=nil)
request = recognized_request_for(path)
@@ -124,7 +121,8 @@ module ActionDispatch
options[:controller] = "/#{controller}"
end
assert_generates(path.is_a?(Hash) ? path[:path] : path, options, defaults, extras, message)
generate_options = options.dup.delete_if{ |k,v| defaults.key?(k) }
assert_generates(path.is_a?(Hash) ? path[:path] : path, generate_options, defaults, extras, message)
end
# A helper to make it easier to test different route configurations.

View File

@@ -569,9 +569,9 @@ module ActionDispatch
assert !deliveries.empty?, "No e-mail in delivery list"
for delivery in deliveries
for part in delivery.parts
for part in (delivery.parts.empty? ? [delivery] : delivery.parts)
if part["Content-Type"].to_s =~ /^text\/html\W/
root = HTML::Document.new(part.body).root
root = HTML::Document.new(part.body.to_s).root
assert_select root, ":root", &block
end
end

View File

@@ -115,8 +115,8 @@ module ActionDispatch
end
end
# An integration Session instance represents a set of requests and responses
# performed sequentially by some virtual user. Because you can instantiate
# An instance of this class represents a set of requests and responses
# performed sequentially by a test process. Because you can instantiate
# multiple sessions and run them side-by-side, you can also mimic (to some
# limited extent) multiple simultaneous users interacting with your system.
#
@@ -257,12 +257,14 @@ module ActionDispatch
end
end
hostname, port = host.split(':')
env = {
:method => method,
:params => parameters,
"SERVER_NAME" => host.split(':')[0],
"SERVER_PORT" => (https? ? "443" : "80"),
"SERVER_NAME" => hostname,
"SERVER_PORT" => port || (https? ? "443" : "80"),
"HTTPS" => https? ? "on" : "off",
"rack.url_scheme" => https? ? "https" : "http",
@@ -373,12 +375,12 @@ module ActionDispatch
end
end
# An IntegrationTest is one that spans multiple controllers and actions,
# An test that spans multiple controllers and actions,
# tying them all together to ensure they work together as expected. It tests
# more completely than either unit or functional tests do, exercising the
# entire stack, from the dispatcher to the database.
#
# At its simplest, you simply extend IntegrationTest and write your tests
# At its simplest, you simply extend <tt>IntegrationTest</tt> and write your tests
# using the get/post methods:
#
# require "test_helper"
@@ -403,7 +405,7 @@ module ActionDispatch
# However, you can also have multiple session instances open per test, and
# even extend those instances with assertions and methods to create a very
# powerful testing DSL that is specific for your application. You can even
# reference any named routes you happen to have defined!
# reference any named routes you happen to have defined.
#
# require "test_helper"
#

View File

@@ -2,8 +2,9 @@ module ActionPack
module VERSION #:nodoc:
MAJOR = 3
MINOR = 0
TINY = 1
TINY = 20
PRE = nil
STRING = [MAJOR, MINOR, TINY].join('.')
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
end

View File

@@ -79,8 +79,8 @@ module ActionView #:nodoc:
#
# === Template caching
#
# By default, Rails will compile each template to a method in order to render it. When you alter a template, Rails will
# check the file's modification time and recompile it.
# By default, Rails will compile each template to a method in order to render it. When you alter a template,
# Rails will check the file's modification time and recompile it in development mode.
#
# == Builder
#
@@ -156,7 +156,7 @@ module ActionView #:nodoc:
#
# This refreshes the sidebar, removes a person element and highlights the user list.
#
# See the ActionView::Helpers::PrototypeHelper::GeneratorMethods documentation for more details.
# See the ActionView::Helpers::PrototypeHelper::JavaScriptGenerator::GeneratorMethods documentation for more details.
class Base
module Subclasses
end
@@ -165,8 +165,12 @@ module ActionView #:nodoc:
# Specify whether RJS responses should be wrapped in a try/catch block
# that alert()s the caught exception (and then re-raises it).
cattr_accessor :debug_rjs
cattr_reader :debug_rjs
@@debug_rjs = false
def self.debug_rjs=(new_value)
ActiveSupport::Deprecation.warn("config.action_view.debug_rjs will be removed in 3.1, from 3.1 onwards you will need to install prototype-rails to continue to use RJS templates ")
@@debug_rjs = new_value
end
# Specify the proc used to decorate input tags that refer to attributes with errors.
cattr_accessor :field_error_proc

View File

@@ -12,7 +12,6 @@ module ActionView #:nodoc:
autoload :CsrfHelper
autoload :DateHelper
autoload :DebugHelper
autoload :DeprecatedBlockHelpers
autoload :FormHelper
autoload :FormOptionsHelper
autoload :FormTagHelper

View File

@@ -375,7 +375,9 @@ module ActionView
# <script type="text/javascript" src="/javascripts/body.js"></script>
# <script type="text/javascript" src="/javascripts/tail.js"></script>
def self.register_javascript_expansion(expansions)
@@javascript_expansions.merge!(expansions)
expansions.each do |key, values|
@@javascript_expansions[key] = (@@javascript_expansions[key] || []) | Array(values)
end
end
# Register one or more stylesheet files to be included when <tt>symbol</tt>
@@ -390,7 +392,9 @@ module ActionView
# <link href="/stylesheets/body.css" media="screen" rel="stylesheet" type="text/css" />
# <link href="/stylesheets/tail.css" media="screen" rel="stylesheet" type="text/css" />
def self.register_stylesheet_expansion(expansions)
@@stylesheet_expansions.merge!(expansions)
expansions.each do |key, values|
@@stylesheet_expansions[key] = (@@stylesheet_expansions[key] || []) | Array(values)
end
end
def self.reset_javascript_include_default
@@ -738,11 +742,11 @@ module ActionView
return source if is_uri?(source)
source += ".#{ext}" if rewrite_extension?(source, dir, ext)
source = "/#{dir}/#{source}" unless source[0] == ?/
source = "/#{dir}/#{source}" unless source.start_with? '/'
source = rewrite_asset_path(source, config.asset_path)
has_request = controller.respond_to?(:request)
if has_request && include_host && source !~ %r{^#{controller.config.relative_url_root}/}
if has_request && include_host && controller.config.relative_url_root && !source.start_with?(controller.config.relative_url_root)
source = "#{controller.config.relative_url_root}#{source}"
end
source = rewrite_host_and_protocol(source, has_request) if include_host
@@ -836,7 +840,7 @@ module ActionView
def expand_javascript_sources(sources, recursive = false)
if sources.include?(:all)
all_javascript_files = collect_asset_files(config.javascripts_dir, ('**' if recursive), '*.js')
all_javascript_files = (collect_asset_files(config.javascripts_dir, ('**' if recursive), '*.js') - ['application']) << 'application'
((determine_source(:defaults, @@javascript_expansions).dup & all_javascript_files) + all_javascript_files).uniq
else
expanded_sources = sources.collect do |source|
@@ -868,14 +872,14 @@ module ActionView
def ensure_stylesheet_sources!(sources)
sources.each do |source|
asset_file_path!(path_to_stylesheet(source))
asset_file_path!(compute_public_path(source, 'stylesheets', 'css', false))
end
return sources
end
def ensure_javascript_sources!(sources)
sources.each do |source|
asset_file_path!(path_to_javascript(source))
asset_file_path!(compute_public_path(source, 'javascripts', 'js', false))
end
return sources
end

View File

@@ -46,14 +46,22 @@ module ActionView
private
# TODO: Create an object that has caching read/write on it
def fragment_for(name = {}, options = nil, &block) #:nodoc:
if controller.fragment_exist?(name, options)
controller.read_fragment(name, options)
if fragment = controller.read_fragment(name, options)
fragment
else
# VIEW TODO: Make #capture usable outside of ERB
# This dance is needed because Builder can't use capture
pos = output_buffer.length
pos = output_buffer.bytesize
yield
fragment = output_buffer.slice!(pos..-1)
if output_buffer.html_safe?
safe_output_buffer = output_buffer.to_str
fragment = safe_output_buffer.byteslice(pos..-1)
safe_output_buffer = safe_output_buffer.byteslice(0...pos)
self.output_buffer = output_buffer.class.new(safe_output_buffer)
else
fragment = output_buffer.byteslice(pos..-1)
self.output_buffer = output_buffer.byteslice(0...pos)
end
controller.write_fragment(name, fragment, options)
end
end

View File

@@ -1,4 +1,5 @@
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/string/output_safety'
module ActionView
# = Action View Capture Helper
@@ -38,7 +39,7 @@ module ActionView
value = nil
buffer = with_output_buffer { value = yield(*args) }
if string = buffer.presence || value and string.is_a?(String)
NonConcattingString.new(string)
NonConcattingString.new(ERB::Util.html_escape(string))
end
end
@@ -178,7 +179,7 @@ module ActionView
def flush_output_buffer #:nodoc:
if output_buffer && !output_buffer.empty?
response.body_parts << output_buffer
self.output_buffer = output_buffer[0,0]
self.output_buffer = output_buffer.respond_to?(:clone_empty) ? output_buffer.clone_empty : output_buffer[0, 0]
nil
end
end

View File

@@ -893,6 +893,8 @@ module ActionView
# Returns the separator for a given datetime component
def separator(type)
case type
when :year
@options[:discard_year] ? "" : @options[:date_separator]
when :month
@options[:discard_month] ? "" : @options[:date_separator]
when :day

View File

@@ -202,6 +202,12 @@ module ActionView
# ...
# <% end %>
#
# You can also set the answer format, like this:
#
# <%= form_for(@post, :format => :json) do |f| %>
# ...
# <% end %>
#
# If you have an object that needs to be represented as a different
# parameter, like a Client that acts as a Person:
#
@@ -332,7 +338,9 @@ module ActionView
options[:html] ||= {}
options[:html].reverse_merge!(html_options)
options[:url] ||= polymorphic_path(object_or_array)
options[:url] ||= options[:format] ? \
polymorphic_path(object_or_array, :format => options.delete(:format)) : \
polymorphic_path(object_or_array)
end
# Creates a scope around a specific model object like form_for, but
@@ -533,7 +541,10 @@ module ActionView
end
builder = options[:builder] || ActionView::Base.default_form_builder
capture(builder.new(object_name, object, self, options, block), &block)
builder = builder.new(object_name, object, self, options, block)
output = capture(builder, &block)
output.concat builder.hidden_field(:id) if output && options[:hidden_field_id] && !builder.emitted_hidden_id?
output
end
# Returns a label tag tailored for labelling an input field for a specified attribute (identified by +method+) on an object
@@ -803,7 +814,7 @@ module ActionView
options["incremental"] = true unless options.has_key?("incremental")
end
InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("search", options)
InstanceTag.new(object_name, method, self, options.delete("object")).to_input_field_tag("search", options)
end
# Returns a text_field of type "tel".
@@ -1006,14 +1017,9 @@ module ActionView
def value_before_type_cast(object, method_name)
unless object.nil?
if object.respond_to?(method_name)
object.send(method_name)
# FIXME: this is AR dependent
elsif object.respond_to?(method_name + "_before_type_cast")
object.send(method_name + "_before_type_cast")
else
raise NoMethodError, "Model #{object.class} does not respond to #{method_name}"
end
object.respond_to?(method_name + "_before_type_cast") ?
object.send(method_name + "_before_type_cast") :
object.send(method_name)
end
end
@@ -1060,7 +1066,7 @@ module ActionView
options["name"] ||= tag_name_with_index(@auto_index)
options["id"] = options.fetch("id"){ tag_id_with_index(@auto_index) }
else
options["name"] ||= tag_name + (options.has_key?('multiple') ? '[]' : '')
options["name"] ||= tag_name + (options['multiple'] ? '[]' : '')
options["id"] = options.fetch("id"){ tag_id }
end
end
@@ -1094,7 +1100,7 @@ module ActionView
include InstanceTagMethods
end
class FormBuilder #:nodoc:
class FormBuilder
# The methods which wrap a form helper call.
class_inheritable_accessor :field_helpers
self.field_helpers = (FormHelper.instance_method_names - ['form_for'])
@@ -1258,11 +1264,11 @@ module ActionView
if association.respond_to?(:persisted?)
association = [association] if @object.send(association_name).is_a?(Array)
elsif !association.is_a?(Array)
elsif !association.respond_to?(:to_ary)
association = @object.send(association_name)
end
if association.is_a?(Array)
if association.respond_to?(:to_ary)
explicit_child_index = options[:child_index]
output = ActiveSupport::SafeBuffer.new
association.each do |child|
@@ -1277,14 +1283,8 @@ module ActionView
def fields_for_nested_model(name, object, options, block)
object = object.to_model if object.respond_to?(:to_model)
if object.persisted?
@template.fields_for(name, object, options) do |builder|
block.call(builder)
@template.concat builder.hidden_field(:id) unless builder.emitted_hidden_id?
end
else
@template.fields_for(name, object, options, &block)
end
options[:hidden_field_id] = object.persisted?
@template.fields_for(name, object, options, &block)
end
def nested_child_index(name)

View File

@@ -299,12 +299,12 @@ module ActionView
container = container.to_a if Hash === container
selected, disabled = extract_selected_and_disabled(selected).map do | r |
Array.wrap(r).map(&:to_s)
Array.wrap(r).map { |item| item.to_s }
end
container.map do |element|
html_attributes = option_html_attributes(element)
text, value = option_text_and_value(element).map(&:to_s)
text, value = option_text_and_value(element).map { |item| item.to_s }
selected_attribute = ' selected="selected"' if option_value_selected?(value, selected)
disabled_attribute = ' disabled="disabled"' if disabled && option_value_selected?(value, disabled)
%(<option value="#{html_escape(value)}"#{selected_attribute}#{disabled_attribute}#{html_attributes}>#{html_escape(text)}</option>)
@@ -395,12 +395,12 @@ module ActionView
# <b>Note:</b> Only the <tt><optgroup></tt> and <tt><option></tt> tags are returned, so you still have to
# wrap the output in an appropriate <tt><select></tt> tag.
def option_groups_from_collection_for_select(collection, group_method, group_label_method, option_key_method, option_value_method, selected_key = nil)
collection.inject("") do |options_for_select, group|
collection.map do |group|
group_label_string = eval("group.#{group_label_method}")
options_for_select += "<optgroup label=\"#{html_escape(group_label_string)}\">"
options_for_select += options_from_collection_for_select(eval("group.#{group_method}"), option_key_method, option_value_method, selected_key)
options_for_select += '</optgroup>'
end.html_safe
"<optgroup label=\"#{html_escape(group_label_string)}\">" +
options_from_collection_for_select(eval("group.#{group_method}"), option_key_method, option_value_method, selected_key) +
'</optgroup>'
end.join.html_safe
end
# Returns a string of <tt><option></tt> tags, like <tt>options_for_select</tt>, but
@@ -534,7 +534,7 @@ module ActionView
else
selected = Array.wrap(selected)
options = selected.extract_options!.symbolize_keys
[ options[:selected] || selected , options[:disabled] ]
[ options.include?(:selected) ? options[:selected] : selected, options[:disabled] ]
end
end
@@ -596,13 +596,13 @@ module ActionView
private
def add_options(option_tags, options, value = nil)
if options[:include_blank]
option_tags = "<option value=\"\">#{html_escape(options[:include_blank]) if options[:include_blank].kind_of?(String)}</option>\n" + option_tags
option_tags = content_tag('option', options[:include_blank].kind_of?(String) ? options[:include_blank] : nil, :value => '') + "\n" + option_tags
end
if value.blank? && options[:prompt]
prompt = options[:prompt].kind_of?(String) ? options[:prompt] : I18n.translate('helpers.select.prompt', :default => 'Please select')
option_tags = "<option value=\"\">#{html_escape(prompt)}</option>\n" + option_tags
option_tags = content_tag('option', prompt, :value => '') + "\n" + option_tags
end
option_tags.html_safe
option_tags
end
end

View File

@@ -38,7 +38,7 @@ module ActionView
# form_tag('/upload', :multipart => true)
# # => <form action="/upload" method="post" enctype="multipart/form-data">
#
# <%= form_tag('/posts')do -%>
# <%= form_tag('/posts') do -%>
# <div><%= submit_tag 'Save' %></div>
# <% end -%>
# # => <form action="/posts" method="post"><div><input type="submit" name="submit" value="Save" /></div></form>
@@ -46,8 +46,8 @@ module ActionView
# <%= form_tag('/posts', :remote => true) %>
# # => <form action="/posts" method="post" data-remote="true">
#
def form_tag(url_for_options = {}, options = {}, *parameters_for_url, &block)
html_options = html_options_for_form(url_for_options, options, *parameters_for_url)
def form_tag(url_for_options = {}, options = {}, &block)
html_options = html_options_for_form(url_for_options, options)
if block_given?
form_tag_in_block(html_options, &block)
else
@@ -67,7 +67,7 @@ module ActionView
# * Any other key creates standard HTML attributes for the tag.
#
# ==== Examples
# select_tag "people", options_from_collection_for_select(@people, "name", "id")
# select_tag "people", options_from_collection_for_select(@people, "id", "name")
# # <select id="people" name="people"><option value="1">David</option></select>
#
# select_tag "people", "<option>David</option>"
@@ -100,9 +100,9 @@ module ActionView
html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name
if blank = options.delete(:include_blank)
if blank.kind_of?(String)
option_tags = "<option value=\"\">#{blank}</option>".html_safe + option_tags
option_tags = content_tag(:option, blank, :value => '').safe_concat(option_tags)
else
option_tags = "<option value=\"\"></option>".html_safe + option_tags
option_tags = content_tag(:option, '', :value => '').safe_concat(option_tags)
end
end
content_tag :select, option_tags, { "name" => html_name, "id" => sanitize_to_id(name) }.update(options.stringify_keys)
@@ -115,6 +115,7 @@ module ActionView
# * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
# * <tt>:size</tt> - The number of visible characters that will fit in the input.
# * <tt>:maxlength</tt> - The maximum number of characters that the browser will allow the user to enter.
# * <tt>:placeholder</tt> - The text contained in the field by default which is removed when the field receives focus.
# * Any other key creates standard HTML attributes for the tag.
#
# ==== Examples
@@ -124,6 +125,9 @@ module ActionView
# text_field_tag 'query', 'Enter your search query here'
# # => <input id="query" name="query" type="text" value="Enter your search query here" />
#
# text_field_tag 'search', nil, :placeholder => 'Enter search term...'
# # => <input id="search" name="search" placeholder="Enter search term..." type="text" />
#
# text_field_tag 'request', nil, :class => 'special_input'
# # => <input class="special_input" id="request" name="request" type="text" />
#
@@ -525,12 +529,12 @@ module ActionView
end
private
def html_options_for_form(url_for_options, options, *parameters_for_url)
def html_options_for_form(url_for_options, options)
options.stringify_keys.tap do |html_options|
html_options["enctype"] = "multipart/form-data" if html_options.delete("multipart")
# The following URL is unescaped, this is just a hash of options, and it is the
# responsability of the caller to escape all the values.
html_options["action"] = url_for(url_for_options, *parameters_for_url)
html_options["action"] = url_for(url_for_options)
html_options["accept-charset"] = "UTF-8"
html_options["data-remote"] = true if html_options.delete("remote")
end

View File

@@ -49,7 +49,8 @@ module ActionView
# Escape carrier returns and single and double quotes for JavaScript segments.
def escape_javascript(javascript)
if javascript
javascript.gsub(/(\\|<\/|\r\n|[\n\r"'])/) { JS_ESCAPE_MAP[$1] }
result = javascript.gsub(/(\\|<\/|\r\n|[\n\r"'])/) {|match| JS_ESCAPE_MAP[match] }
javascript.html_safe? ? result.html_safe : result
else
''
end
@@ -65,7 +66,8 @@ module ActionView
# //]]>
# </script>
#
# +html_options+ may be a hash of attributes for the <script> tag. Example:
# +html_options+ may be a hash of attributes for the <tt>\<script></tt> tag.
# Example:
# javascript_tag "alert('All is good')", :defer => 'defer'
# # => <script defer="defer" type="text/javascript">alert('All is good')</script>
#

View File

@@ -14,7 +14,7 @@ module ActionView
# unchanged if can't be converted into a valid number.
module NumberHelper
DEFAULT_CURRENCY_VALUES = { :format => "%u%n", :unit => "$", :separator => ".", :delimiter => ",",
DEFAULT_CURRENCY_VALUES = { :format => "%u%n", :negative_format => "-%u%n", :unit => "$", :separator => ".", :delimiter => ",",
:precision => 2, :significant => false, :strip_insignificant_zeros => false }
# Raised when argument +number+ param given to the helpers is invalid and
@@ -83,15 +83,18 @@ module ActionView
# in the +options+ hash.
#
# ==== Options
# * <tt>:locale</tt> - Sets the locale to be used for formatting (defaults to current locale).
# * <tt>:precision</tt> - Sets the level of precision (defaults to 2).
# * <tt>:unit</tt> - Sets the denomination of the currency (defaults to "$").
# * <tt>:separator</tt> - Sets the separator between the units (defaults to ".").
# * <tt>:delimiter</tt> - Sets the thousands delimiter (defaults to ",").
# * <tt>:format</tt> - Sets the format of the output string (defaults to "%u%n"). The field types are:
#
# %u The currency unit
# %n The number
# * <tt>:locale</tt> - Sets the locale to be used for formatting (defaults to current locale).
# * <tt>:precision</tt> - Sets the level of precision (defaults to 2).
# * <tt>:unit</tt> - Sets the denomination of the currency (defaults to "$").
# * <tt>:separator</tt> - Sets the separator between the units (defaults to ".").
# * <tt>:delimiter</tt> - Sets the thousands delimiter (defaults to ",").
# * <tt>:format</tt> - Sets the format for non-negative numbers (defaults to "%u%n").
# Fields are <tt>%u</tt> for the currency, and <tt>%n</tt>
# for the number.
# * <tt>:negative_format</tt> - Sets the format for negative numbers (defaults to prepending
# an hyphen to the formatted number given by <tt>:format</tt>).
# Accepts the same fields than <tt>:format</tt>, except
# <tt>%n</tt> is here the absolute value of the number.
#
# ==== Examples
# number_to_currency(1234567890.50) # => $1,234,567,890.50
@@ -99,6 +102,8 @@ module ActionView
# number_to_currency(1234567890.506, :precision => 3) # => $1,234,567,890.506
# number_to_currency(1234567890.506, :locale => :fr) # => 1 234 567 890,506 €
#
# number_to_currency(1234567890.50, :negative_format => "(%u%n)")
# # => ($1,234,567,890.51)
# number_to_currency(1234567890.50, :unit => "&pound;", :separator => ",", :delimiter => "")
# # => &pound;1234567890,50
# number_to_currency(1234567890.50, :unit => "&pound;", :separator => ",", :delimiter => "", :format => "%n %u")
@@ -112,11 +117,17 @@ module ActionView
currency = I18n.translate(:'number.currency.format', :locale => options[:locale], :default => {})
defaults = DEFAULT_CURRENCY_VALUES.merge(defaults).merge!(currency)
defaults[:negative_format] = "-" + options[:format] if options[:format]
options = defaults.merge!(options)
unit = options.delete(:unit)
format = options.delete(:format)
if number.to_f < 0
format = options.delete(:negative_format)
number = number.respond_to?("abs") ? number.abs : number.sub(/^-/, '')
end
begin
value = number_with_precision(number, options.merge(:raise => true))
format.gsub(/%n/, value).gsub(/%u/, unit).html_safe
@@ -202,7 +213,7 @@ module ActionView
defaults = I18n.translate(:'number.format', :locale => options[:locale], :default => {})
options = options.reverse_merge(defaults)
parts = number.to_s.split('.')
parts = number.to_s.to_str.split('.')
parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{options[:delimiter]}")
parts.join(options[:separator]).html_safe
@@ -260,13 +271,14 @@ module ActionView
if number == 0
digits, rounded_number = 1, 0
else
digits = (Math.log10(number) + 1).floor
rounded_number = BigDecimal.new((number / 10 ** (digits - precision)).to_s).round.to_f * 10 ** (digits - precision)
digits = (Math.log10(number.abs) + 1).floor
rounded_number = (BigDecimal.new(number.to_s) / BigDecimal.new((10 ** (digits - precision)).to_f.to_s)).round.to_f * 10 ** (digits - precision)
digits = (Math.log10(rounded_number.abs) + 1).floor # After rounding, the number of digits may have changed
end
precision = precision - digits
precision = precision > 0 ? precision : 0 #don't let it be negative
else
rounded_number = BigDecimal.new((number * (10 ** precision)).to_s).round.to_f / 10 ** precision
rounded_number = BigDecimal.new(number.to_s).round(precision).to_f
end
formatted_number = number_with_delimiter("%01.#{precision}f" % rounded_number, options)
if strip_insignificant_zeros
@@ -459,8 +471,8 @@ module ActionView
raise ArgumentError, ":units must be a Hash or String translation scope."
end.keys.map{|e_name| DECIMAL_UNITS.invert[e_name] }.sort_by{|e| -e}
number_exponent = Math.log10(number).floor
display_exponent = unit_exponents.find{|e| number_exponent >= e }
number_exponent = number != 0 ? Math.log10(number.abs).floor : 0
display_exponent = unit_exponents.find{ |e| number_exponent >= e } || 0
number /= 10 ** display_exponent
unit = case units

View File

@@ -130,7 +130,6 @@ module ActionView
"new Ajax.Updater(#{update}, "
url_options = options[:url]
url_options = url_options.merge(:escape => false) if url_options.is_a?(Hash)
function << "'#{html_escape(escape_javascript(url_for(url_options)))}'"
function << ", #{javascript_options})"
@@ -161,7 +160,7 @@ module ActionView
# JavaScriptGenerator generates blocks of JavaScript code that allow you
# to change the content and presentation of multiple DOM elements. Use
# this in your Ajax response bodies, either in a <script> tag or as plain
# this in your Ajax response bodies, either in a <tt>\<script></tt> tag or as plain
# JavaScript sent with a Content-type of "text/javascript".
#
# Create new instances with PrototypeHelper#update_page or with
@@ -224,7 +223,7 @@ module ActionView
#
# You can also use PrototypeHelper#update_page_tag instead of
# PrototypeHelper#update_page to wrap the generated JavaScript in a
# <script> tag.
# <tt>\<script></tt> tag.
module GeneratorMethods
def to_s #:nodoc:
(@lines * $/).tap do |javascript|
@@ -582,11 +581,11 @@ module ActionView
JavaScriptGenerator.new(view_context, &block).to_s.html_safe
end
# Works like update_page but wraps the generated JavaScript in a <script>
# Works like update_page but wraps the generated JavaScript in a <tt>\<script></tt>
# tag. Use this to include generated JavaScript in an ERb template.
# See JavaScriptGenerator for more information.
#
# +html_options+ may be a hash of <script> attributes to be passed
# +html_options+ may be a hash of <tt>\<script></tt> attributes to be passed
# to ActionView::Helpers::JavaScriptHelper#javascript_tag.
def update_page_tag(html_options = {}, &block)
javascript_tag update_page(&block), html_options

View File

@@ -81,7 +81,7 @@ module ActionView
# strip_tags("<div id='top-bar'>Welcome to my website!</div>")
# # => Welcome to my website!
def strip_tags(html)
self.class.full_sanitizer.sanitize(html).try(:html_safe)
self.class.full_sanitizer.sanitize(html)
end
# Strips all link tags from +text+ leaving just the link text.

View File

@@ -9,6 +9,24 @@ module ActionView
# and transforming strings, which can reduce the amount of inline Ruby code in
# your views. These helper methods extend Action View making them callable
# within your template files.
#
# ==== Sanitization
#
# Most text helpers by default sanitize the given content, but do not escape it.
# This means HTML tags will appear in the page but all malicious code will be removed.
# Let's look at some examples using the +simple_format+ method:
#
# simple_format('<a href="http://example.com/">Example</a>')
# # => "<p><a href=\"http://example.com/\">Example</a></p>"
#
# simple_format('<a href="javascript:alert('no!')">Example</a>')
# # => "<p><a>Example</a></p>"
#
# If you want to escape all content, you should invoke the +h+ method before
# calling the text helper.
#
# simple_format h('<a href="http://example.com/">Example</a>')
# # => "<p>&lt;a href=\"http://example.com/\"&gt;Example&lt;/a&gt;</p>"
module TextHelper
extend ActiveSupport::Concern
@@ -97,13 +115,12 @@ module ActionView
end
options.reverse_merge!(:highlighter => '<strong class="highlight">\1</strong>')
text = sanitize(text) unless options[:sanitize] == false
if text.blank? || phrases.blank?
text
else
if text.present? && phrases.present?
match = Array(phrases).map { |p| Regexp.escape(p) }.join('|')
text.gsub(/(#{match})(?!(?:[^<]*?)(?:["'])[^<>]*>)/i, options[:highlighter])
end.html_safe
text = text.to_str.gsub(/(#{match})(?!(?:[^<]*?)(?:["'])[^<>]*>)/i, options[:highlighter])
end
text = sanitize(text) unless options[:sanitize] == false
text
end
# Extracts an excerpt from +text+ that matches the first instance of +phrase+.
@@ -233,14 +250,16 @@ module ActionView
# simple_format("Look ma! A class!", :class => 'description')
# # => "<p class='description'>Look ma! A class!</p>"
def simple_format(text, html_options={}, options={})
text = ''.html_safe if text.nil?
text = text ? text.to_str : ''
text = text.dup if text.frozen?
start_tag = tag('p', html_options, true)
text = sanitize(text) unless options[:sanitize] == false
text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n
text.gsub!(/\n\n+/, "</p>\n\n#{start_tag}") # 2+ newline -> paragraph
text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
text.insert 0, start_tag
text.html_safe.safe_concat("</p>")
text.concat("</p>")
text = sanitize(text) unless options[:sanitize] == false
text
end
# Turns all URLs and e-mail addresses into clickable links. The <tt>:link</tt> option
@@ -281,7 +300,7 @@ module ActionView
# # => "Welcome to my new blog at <a href=\"http://www.myblog.com/\" target=\"_blank\">http://www.myblog.com</a>.
# Please e-mail me at <a href=\"mailto:me@email.com\">me@email.com</a>."
def auto_link(text, *args, &block)#link = :all, html = {}, &block)
return ''.html_safe if text.blank?
return '' if text.blank?
options = args.size == 2 ? {} : args.extract_options! # this is necessary because the old auto_link API has a Hash as its last parameter
unless args.empty?
@@ -444,7 +463,7 @@ module ActionView
end
AUTO_LINK_RE = %r{
(?: ([\w+.:-]+:)// | www\. )
(?: ((?:ed2k|ftp|http|https|irc|mailto|news|gopher|nntp|telnet|webcal|xmpp|callto|feed|svn|urn|aim|rsync|tag|ssh|sftp|rtsp|afs):)// | www\. )
[^\s<]+
}x
@@ -459,7 +478,7 @@ module ActionView
# is yielded and the result is used as the link text.
def auto_link_urls(text, html_options = {}, options = {})
link_attributes = html_options.stringify_keys
text.gsub(AUTO_LINK_RE) do
text.to_str.gsub(AUTO_LINK_RE) do
scheme, href = $1, $&
punctuation = []
@@ -476,33 +495,26 @@ module ActionView
end
end
link_text = block_given?? yield(href) : href
link_text = block_given? ? yield(href) : href
href = 'http://' + href unless scheme
unless options[:sanitize] == false
link_text = sanitize(link_text)
href = sanitize(href)
end
content_tag(:a, link_text, link_attributes.merge('href' => href), !!options[:sanitize]) + punctuation.reverse.join('')
sanitize_link = options[:sanitize] != false
content_tag(:a, link_text, link_attributes.merge('href' => href), sanitize_link) + punctuation.reverse.join('')
end
end.html_safe
end
end
# Turns all email addresses into clickable links. If a block is given,
# each email is yielded and the result is used as the link text.
def auto_link_email_addresses(text, html_options = {}, options = {})
text.gsub(AUTO_EMAIL_RE) do
text.to_str.gsub(AUTO_EMAIL_RE) do
text = $&
if auto_linked?($`, $')
text.html_safe
else
display_text = (block_given?) ? yield(text) : text
unless options[:sanitize] == false
text = sanitize(text)
display_text = sanitize(display_text) unless text == display_text
end
display_text = block_given? ? yield(text) : text
display_text = sanitize(display_text) unless options[:sanitize] == false
mail_to text, display_text, html_options
end
end

View File

@@ -1,13 +1,33 @@
require 'action_view/helpers/tag_helper'
require 'i18n/exceptions'
module I18n
class ExceptionHandler
include Module.new {
def call(exception, locale, key, options)
exception.is_a?(MissingTranslationData) && options[:rescue_format] == :html ? super.html_safe : super
end
}
end
end
module ActionView
# = Action View Translation Helpers
module Helpers
module TranslationHelper
# Delegates to I18n#translate but also performs three additional functions.
# First, it'll catch MissingTranslationData exceptions and turn them into
# inline spans that contains the missing key, such that you can see in a
# view what is missing where.
#
# First, it'll pass the :rescue_format => :html option to I18n so that any caught
# MissingTranslationData exceptions will be turned into inline spans that
#
# * have a "translation-missing" class set,
# * contain the missing key as a title attribute and
# * a titleized version of the last key segment as a text.
#
# E.g. the value returned for a missing translation key :"blog.post.title" will be
# <span class="translation_missing" title="translation missing: blog.post.title">Title</span>.
# This way your views will display rather reasonableful strings but it will still
# be easy to spot missing translations.
#
# Second, it'll scope the key by the current partial if the key starts
# with a period. So if you call <tt>translate(".foo")</tt> from the
@@ -24,15 +44,20 @@ module ActionView
# naming convention helps to identify translations that include HTML tags so that
# you know what kind of output to expect when you call translate in a template.
def translate(key, options = {})
translation = I18n.translate(scope_key_by_partial(key), options.merge!(:raise => true))
if html_safe_translation_key?(key) && translation.respond_to?(:html_safe)
translation.html_safe
options.merge!(:rescue_format => :html) unless options.key?(:rescue_format)
if html_safe_translation_key?(key)
html_safe_options = options.dup
options.except(*I18n::RESERVED_KEYS).each do |name, value|
unless name == :count && value.is_a?(Numeric)
html_safe_options[name] = ERB::Util.html_escape(value.to_s)
end
end
translation = I18n.translate(scope_key_by_partial(key), html_safe_options)
translation.respond_to?(:html_safe) ? translation.html_safe : translation
else
translation
I18n.translate(scope_key_by_partial(key), options)
end
rescue I18n::MissingTranslationData => e
keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])
content_tag('span', keys.join(', '), :class => 'translation_missing')
end
alias :t :translate

View File

@@ -13,7 +13,7 @@ module ActionView
module UrlHelper
# This helper may be included in any class that includes the
# URL helpers of a routes (routes.url_helpers). Some methods
# provided here will only work in the4 context of a request
# provided here will only work in the context of a request
# (link_to_unless_current, for instance), which must be provided
# as a method called #request on the context.
@@ -235,13 +235,8 @@ module ActionView
html_options = convert_options_to_data_attributes(options, html_options)
url = url_for(options)
if html_options
html_options = html_options.stringify_keys
href = html_options['href']
tag_options = tag_options(html_options)
else
tag_options = nil
end
href = html_options['href']
tag_options = tag_options(html_options)
href_attr = "href=\"#{html_escape(url)}\"" unless href
"<a #{href_attr}#{tag_options}>#{html_escape(name || url)}</a>".html_safe
@@ -269,8 +264,9 @@ module ActionView
# The +options+ hash accepts the same options as url_for.
#
# There are a few special +html_options+:
# * <tt>:method</tt> - Specifies the anchor name to be appended to the path.
# * <tt>:disabled</tt> - Specifies the anchor name to be appended to the path.
# * <tt>:method</tt> - Symbol of HTTP verb. Supported verbs are <tt>:post</tt>, <tt>:get</tt>,
# <tt>:delete</tt> and <tt>:put</tt>. By default it will be <tt>:post</tt>.
# * <tt>:disabled</tt> - If set to true, it will generate a disabled button.
# * <tt>:confirm</tt> - This will use the unobtrusive JavaScript driver to
# prompt with the question specified. If the user accepts, the link is
# processed normally, otherwise no action is taken.
@@ -487,14 +483,16 @@ module ActionView
extras << "subject=#{Rack::Utils.escape(subject).gsub("+", "%20")}" unless subject.nil?
extras = extras.empty? ? '' : '?' + html_escape(extras.join('&'))
email_address_obfuscated = email_address.dup
email_address_obfuscated = email_address.to_str
email_address_obfuscated.gsub!(/@/, html_options.delete("replace_at")) if html_options.has_key?("replace_at")
email_address_obfuscated.gsub!(/\./, html_options.delete("replace_dot")) if html_options.has_key?("replace_dot")
string = ''
if encode == "javascript"
"document.write('#{content_tag("a", name || email_address_obfuscated.html_safe, html_options.merge("href" => "mailto:#{email_address}#{extras}".html_safe))}');".each_byte do |c|
html = content_tag("a", name || email_address_obfuscated.html_safe, html_options.merge("href" => "mailto:#{email_address}#{extras}".html_safe))
html = escape_javascript(html)
"document.write('#{html}');".each_byte do |c|
string << sprintf("%%%x", c)
end
"<script type=\"#{Mime::JS}\">eval(decodeURIComponent('#{string}'))</script>".html_safe
@@ -593,6 +591,7 @@ module ActionView
html_options['data-remote'] = 'true'
end
disable_with = html_options.delete("disable_with")
confirm = html_options.delete("confirm")
if html_options.key?("popup")
@@ -601,6 +600,7 @@ module ActionView
method, href = html_options.delete("method"), html_options['href']
add_disable_with_to_attributes!(html_options, disable_with) if disable_with
add_confirm_to_attributes!(html_options, confirm) if confirm
add_method_to_attributes!(html_options, method) if method
@@ -611,6 +611,10 @@ module ActionView
html_options["data-confirm"] = confirm if confirm
end
def add_disable_with_to_attributes!(html_options, disable_with)
html_options["data-disable-with"] = disable_with if disable_with
end
def add_method_to_attributes!(html_options, method)
html_options["rel"] = "nofollow" if method && method.to_s.downcase != "get"
html_options["data-method"] = method if method

View File

@@ -145,11 +145,11 @@ module ActionView
@frozen_formats = true
end
# Overload formats= to reject [:"*/*"] values.
# Overload formats= to reject ["*/*"] values.
def formats=(values)
if values && values.size == 1
value = values.first
values = nil if value == :"*/*"
values = nil if value == "*/*"
values << :html if value == :js
end
super(values)
@@ -167,11 +167,11 @@ module ActionView
end
# Overload locale= to also set the I18n.locale. If the current I18n.config object responds
# to i18n_config, it means that it's has a copy of the original I18n configuration and it's
# to original_config, it means that it's has a copy of the original I18n configuration and it's
# acting as proxy, which we need to skip.
def locale=(value)
if value
config = I18n.config.respond_to?(:i18n_config) ? I18n.config.i18n_config : I18n.config
config = I18n.config.respond_to?(:original_config) ? I18n.config.original_config : I18n.config
config.locale = value
end
@@ -226,4 +226,4 @@ module ActionView
include Details
include ViewPaths
end
end
end

View File

@@ -26,6 +26,36 @@ module ActionView
# This would first render "advertiser/_account.erb" with @buyer passed in as the local variable +account+, then
# render "advertiser/_ad.erb" and pass the local variable +ad+ to the template for display.
#
# == The :as and :object options
#
# By default PartialRenderer uses the template name for the local name of the object passed into the template.
# These examples are effectively the same:
#
# <%= render :partial => "contract", :locals => { :contract => @contract } %>
#
# <%= render :partial => "contract" %>
#
# By specifying the :as option we can change the way the local variable is namedin the template.
# These examples are effectively the same:
#
# <%= render :partial => "contract", :as => :agreement
#
# <%= render :partial => "contract", :locals => { :agreement => @contract }
#
# The :object option can be used to directly specify which object is rendered into the partial.
#
# Revisiting a previous example we could have written this code.
#
# <%= render :partial => "account", :object => @buyer %>
#
# <% for ad in @advertisements %>
# <%= render :partial => "ad", :object => ad %>
# <% end %>
#
# The :object and :as options can be used together. We might have a partial which we have named genericly,
# such as 'form'. Using :object and :as together helps us.
#
# <%= render :partial => "form", :object => @contract, :as => :contract %>
# == Rendering a collection of partials
#
# The example of partial use describes a familiar pattern where a template needs to iterate over an array and
@@ -39,6 +69,13 @@ module ActionView
# iteration counter will automatically be made available to the template with a name of the form
# +partial_name_counter+. In the case of the example above, the template would be fed +ad_counter+.
#
# The :as option may be used when rendering partials.
#
# Also, you can specify a partial which will be render as a spacer between each element by passing partial name to
# +:spacer_template+. The following example will render "advertiser/_ad_divider.erb" between each ad partial.
#
# <%= render :partial => "ad", :collection => @advertisements, :spacer_template => "ad_divider" %>
#
# NOTE: Due to backwards compatibility concerns, the collection can't be one of hashes. Normally you'd also
# just keep domain objects, like Active Records, in there.
#
@@ -200,7 +237,7 @@ module ActionView
else
@object = partial
if @collection = collection
if @collection = collection_from_object || collection
paths = @collection_paths = @collection.map { |o| partial_path(o) }
@path = paths.uniq.size == 1 ? paths.first : nil
else
@@ -218,13 +255,15 @@ module ActionView
render_collection
end
else
block, options, locals = @block, @options, @locals
content = ActiveSupport::Notifications.instrument("render_partial.action_view",
:identifier => identifier) do
render_partial
end
if !@block && (layout = @options[:layout])
content = @view._render_layout(find_template(layout), @locals){ content }
if !block && (layout = options[:layout])
content = @view._render_layout(find_template(layout), locals){ content }
end
content
@@ -286,23 +325,28 @@ module ActionView
end
def render_partial(object = @object)
locals, view, template = @locals, @view, @template
locals, view, template, block = @locals, @view, @template, @block
object ||= locals[template.variable_name]
locals[@options[:as] || template.variable_name] = object
template.render(view, locals) do |*name|
view._layout_for(*name, &@block)
view._layout_for(*name, &block)
end
end
private
def collection
if @options.key?(:collection)
collection = @options[:collection]
collection.respond_to?(:to_ary) ? collection.to_ary : []
end
end
def collection_from_object
if @object.respond_to?(:to_ary)
@object
elsif @options.key?(:collection)
@options[:collection] || []
@object.to_ary
end
end

View File

@@ -17,7 +17,7 @@ module ActionView
case options
when Hash
if block_given?
_render_partial(options.merge(:partial => options[:layout]), &block)
_render_partial(options.merge(:partial => options.delete(:layout)), &block)
elsif options.key?(:partial)
_render_partial(options)
else

View File

@@ -117,7 +117,7 @@ module ActionView
@method_names = {}
format = details[:format] || :html
@formats = Array.wrap(format).map(&:to_sym)
@formats = Array.wrap(format).map { |f| f.is_a?(Mime::Type) ? f.ref : f }
@virtual_path = details[:virtual_path].try(:sub, ".#{format}", "")
end
@@ -192,6 +192,9 @@ module ActionView
locals_code = locals.keys.map! { |key| "#{key} = local_assigns[:#{key}];" }.join
if source.encoding_aware?
# Avoid performing in-place mutation for SafeBuffer
@source = source.to_str if source.html_safe?
# Look for # encoding: *. If we find one, we'll encode the
# String in that encoding, otherwise, we'll use the
# default external encoding.

View File

@@ -14,6 +14,7 @@ module ActionView
super(value.to_s)
end
alias :append= :<<
alias :safe_append= :safe_concat
def append_if_string=(value)
if value.is_a?(String) && !value.is_a?(NonConcattingString)
@@ -27,17 +28,28 @@ module ActionView
module Handlers
class Erubis < ::Erubis::Eruby
def add_preamble(src)
@newline_pending = 0
src << "@output_buffer = ActionView::OutputBuffer.new;"
end
def add_text(src, text)
return if text.empty?
src << "@output_buffer.safe_concat('" << escape_text(text) << "');"
if text == "\n"
@newline_pending += 1
else
src << "@output_buffer.safe_concat('"
src << "\n" * @newline_pending
src << escape_text(text)
src << "'.freeze);"
@newline_pending = 0
end
end
BLOCK_EXPR = /\s+(do|\{)(\s*\|[^|]*\|)?\s*\Z/
def add_expr_literal(src, code)
flush_newline_if_pending(src)
if code =~ BLOCK_EXPR
src << '@output_buffer.append= ' << code
else
@@ -46,6 +58,8 @@ module ActionView
end
def add_stmt(src, code)
flush_newline_if_pending(src)
if code =~ BLOCK_EXPR
src << '@output_buffer.append_if_string= ' << code
else
@@ -54,12 +68,29 @@ module ActionView
end
def add_expr_escaped(src, code)
src << '@output_buffer.append= ' << escaped_expr(code) << ';'
flush_newline_if_pending(src)
if code =~ BLOCK_EXPR
src << "@output_buffer.safe_append= " << code
else
src << "@output_buffer.safe_concat((" << code << ").to_s);"
end
end
def add_postamble(src)
flush_newline_if_pending(src)
src << '@output_buffer.to_s'
end
def flush_newline_if_pending(src)
if @newline_pending > 0
src << "@output_buffer.safe_concat('"
src << "\n" * @newline_pending
src << "'.freeze);"
@newline_pending = 0
end
end
end
class ERB < Handler

View File

@@ -63,7 +63,7 @@ module ActionView
end
def query(path, exts, formats)
query = File.join(@path, path)
query = escape_entry File.join(@path, path)
exts.each do |ext|
query << '{' << ext.map {|e| e && ".#{e}" }.join(',') << ',}'
@@ -72,14 +72,24 @@ module ActionView
query.gsub!(/\{\.html,/, "{.html,.text.html,")
query.gsub!(/\{\.text,/, "{.text,.text.plain,")
Dir[query].reject { |p| File.directory?(p) }.map do |p|
handler, format = extract_handler_and_format(p, formats)
templates = []
sanitizer = Hash.new { |h,k| h[k] = Dir["#{File.dirname(k)}/*"] }
Dir[query].each do |p|
next if File.directory?(p) || !sanitizer[p].include?(p)
handler, format = extract_handler_and_format(p, formats)
contents = File.open(p, "rb") {|io| io.read }
Template.new(contents, File.expand_path(p), handler,
templates << Template.new(contents, File.expand_path(p), handler,
:virtual_path => path, :format => format)
end
templates
end
def escape_entry(entry)
entry.gsub(/(\*|\[|\]|\{|\}|\?)/, "\\\\\\1")
end
# Extract handler and formats from path. If a format cannot be a found neither

View File

@@ -74,6 +74,11 @@ module ActionView
@helper_class ||= determine_default_helper_class(name)
end
def new(*)
include_helper_modules!
super
end
private
def include_helper_modules!
@@ -89,7 +94,6 @@ module ActionView
@output_buffer = ActiveSupport::SafeBuffer.new
@rendered = ''
self.class.send(:include_helper_modules!)
make_test_case_available_to_view!
say_no_to_protect_against_forgery!
end
@@ -99,7 +103,7 @@ module ActionView
end
def render(options = {}, local_assigns = {}, &block)
view.assign(_assigns)
view.assign(view_assigns)
@rendered << output = view.render(options, local_assigns, &block)
output
end
@@ -149,10 +153,8 @@ module ActionView
# The instance of ActionView::Base that is used by +render+.
def view
@view ||= begin
view = ActionView::Base.new(ActionController::Base.view_paths, {}, @controller)
view = @controller.view_context
view.singleton_class.send :include, _helpers
view.singleton_class.send :include, @controller._routes.url_helpers
view.singleton_class.send :delegate, :alert, :notice, :to => "request.flash"
view.extend(Locals)
view.locals = self.locals
view.output_buffer = self.output_buffer
@@ -162,34 +164,48 @@ module ActionView
alias_method :_view, :view
EXCLUDE_IVARS = %w{
INTERNAL_IVARS = %w{
@__name__
@__io__
@_assertion_wrapped
@_assertions
@_result
@_routes
@controller
@layouts
@locals
@method_name
@output_buffer
@partials
@passed
@rendered
@request
@routes
@templates
@options
@test_passed
@view
@view_context_class
}
def _instance_variables
instance_variables.map(&:to_s) - EXCLUDE_IVARS
def _user_defined_ivars
instance_variables.map(&:to_s) - INTERNAL_IVARS
end
# Returns a Hash of instance variables and their values, as defined by
# the user in the test case, which are then assigned to the view being
# rendered. This is generally intended for internal use and extension
# frameworks.
def view_assigns
Hash[_user_defined_ivars.map do |var|
[var[1..-1].to_sym, instance_variable_get(var)]
end]
end
def _assigns
_instance_variables.inject({}) do |hash, var|
name = var[1..-1].to_sym
hash[name] = instance_variable_get(var)
hash
end
ActiveSupport::Deprecation.warn "ActionView::TestCase#_assigns is deprecated and will be removed in future versions. " <<
"Please use view_assigns instead."
view_assigns
end
def _routes

View File

@@ -22,10 +22,11 @@ module ActionView #:nodoc:
end
templates = []
@hash.select { |k,v| k =~ /^#{query}$/ }.each do |path, source|
handler, format = extract_handler_and_format(path, formats)
templates << Template.new(source, path, handler,
:virtual_path => path, :format => format)
@hash.each do |_path, source|
next unless _path =~ /^#{query}$/
handler, format = extract_handler_and_format(_path, formats)
templates << Template.new(source, _path, handler,
:virtual_path => _path, :format => format)
end
templates.sort_by {|t| -t.identifier.match(/^#{query}$/).captures.reject(&:blank?).size }

View File

@@ -243,6 +243,27 @@ module AbstractController
assert_equal "Success", controller.response_body
end
end
class CallbacksWithArgs < ControllerWithCallbacks
set_callback :process_action, :before, :first
def first
@text = "Hello world"
end
def index(text)
self.response_body = @text + text
end
end
class TestCallbacksWithArgs < ActiveSupport::TestCase
test "callbacks still work when invoking process with multiple args" do
controller = CallbacksWithArgs.new
result = controller.process(:index, " Howdy!")
assert_equal "Hello world Howdy!", controller.response_body
end
end
end
end

View File

@@ -36,17 +36,14 @@ require 'active_record'
require 'action_controller/caching'
require 'action_controller/caching/sweeping'
begin
require 'ruby-debug'
Debugger.settings[:autoeval] = true
Debugger.start
rescue LoadError
# Debugging disabled. `gem install ruby-debug` to enable.
end
require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late
module Rails
class << self
def env
@_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "test")
end
end
end
# Monkey patch the old routes initialization to be silenced.

View File

@@ -23,6 +23,7 @@ class ActiveRecordStoreTest < ActionController::IntegrationTest
def call_reset_session
session[:foo]
reset_session
reset_session if params[:twice]
session[:foo] = "baz"
head :ok
end
@@ -74,6 +75,17 @@ class ActiveRecordStoreTest < ActionController::IntegrationTest
end
end
def test_calling_reset_session_twice_does_not_raise_errors
with_test_route_set do
get '/call_reset_session', :twice => "true"
assert_response :success
get '/get_session_value'
assert_response :success
assert_equal 'foo: "baz"', response.body
end
end
def test_setting_session_value_after_session_reset
with_test_route_set do
get '/set_session_value'

View File

@@ -234,6 +234,14 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
end
end
def test_string_constraint
with_routing do |set|
set.draw do |map|
match "photos", :to => 'action_pack_assertions#nothing', :constraints => {:subdomain => "admin"}
end
end
end
def test_assert_redirect_to_named_route_failure
with_routing do |set|
set.draw do |map|
@@ -547,6 +555,14 @@ class AssertTemplateTest < ActionController::TestCase
assert_template :hello_planet
end
end
def test_assert_template_reset_between_requests
get :hello_world
assert_template 'test/hello_world'
get :nothing
assert_template nil
end
end
class ActionPackHeaderTest < ActionController::TestCase

View File

@@ -22,6 +22,15 @@ class AssertSelectTest < ActionController::TestCase
end
end
class AssertMultipartSelectMailer < ActionMailer::Base
def test(options)
mail :subject => "Test e-mail", :from => "test@test.host", :to => "test <test@test.host>" do |format|
format.text { render :text => options[:text] }
format.html { render :text => options[:html] }
end
end
end
class AssertSelectController < ActionController::Base
def response_with=(content)
@content = content
@@ -461,8 +470,8 @@ class AssertSelectTest < ActionController::TestCase
assert_select_rjs :remove, "test1"
rescue Assertion
assert_equal "No RJS statement that removes 'test1' was rendered.", $!.message
rescue Assertion => e
assert_equal "No RJS statement that removes 'test1' was rendered.", e.message
end
def test_assert_select_rjs_for_remove_ignores_block
@@ -493,8 +502,8 @@ class AssertSelectTest < ActionController::TestCase
assert_select_rjs :show, "test1"
rescue Assertion
assert_equal "No RJS statement that shows 'test1' was rendered.", $!.message
rescue Assertion => e
assert_equal "No RJS statement that shows 'test1' was rendered.", e.message
end
def test_assert_select_rjs_for_show_ignores_block
@@ -525,8 +534,8 @@ class AssertSelectTest < ActionController::TestCase
assert_select_rjs :hide, "test1"
rescue Assertion
assert_equal "No RJS statement that hides 'test1' was rendered.", $!.message
rescue Assertion => e
assert_equal "No RJS statement that hides 'test1' was rendered.", e.message
end
def test_assert_select_rjs_for_hide_ignores_block
@@ -557,8 +566,8 @@ class AssertSelectTest < ActionController::TestCase
assert_select_rjs :toggle, "test1"
rescue Assertion
assert_equal "No RJS statement that toggles 'test1' was rendered.", $!.message
rescue Assertion => e
assert_equal "No RJS statement that toggles 'test1' was rendered.", e.message
end
def test_assert_select_rjs_for_toggle_ignores_block
@@ -724,6 +733,16 @@ EOF
end
end
def test_assert_select_email_multipart
AssertMultipartSelectMailer.test(:html => "<div><p>foo</p><p>bar</p></div>", :text => 'foo bar').deliver
assert_select_email do
assert_select "div:root" do
assert_select "p:first-child", "foo"
assert_select "p:last-child", "bar"
end
end
end
protected
def render_html(html)
@controller.response_with = html

View File

@@ -16,7 +16,14 @@ end
class PageCachingTestController < CachingController
caches_page :ok, :no_content, :if => Proc.new { |c| !c.request.format.json? }
caches_page :found, :not_found
caches_page :about_me
def about_me
respond_to do |format|
format.html {render :text => 'I am html'}
format.xml {render :text => 'I am xml'}
end
end
def ok
head :ok
@@ -74,6 +81,13 @@ class PageCachingTest < ActionController::TestCase
@controller.perform_caching = false
end
def test_should_obey_http_accept_attribute
@request.env['HTTP_ACCEPT'] = 'text/xml'
get :about_me
assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/about_me.xml")
assert_equal 'I am xml', @response.body
end
def test_page_caching_resources_saves_to_correct_path_with_extension_even_if_default_route
with_routing do |set|
set.draw do |map|
@@ -533,6 +547,11 @@ class ActionCacheTest < ActionController::TestCase
assert_response 404
end
def test_four_oh_four_renders_content
get :four_oh_four
assert_equal "404'd!", @response.body
end
def test_simple_runtime_error_returns_500_for_multiple_requests
get :simple_runtime_error
assert_response 500
@@ -766,3 +785,53 @@ CACHED
assert_equal " <p>Builder</p>\n", @store.read('views/test.host/functional_caching/formatted_fragment_cached')
end
end
class CacheHelperOutputBufferTest < ActionController::TestCase
class MockController
def read_fragment(name, options)
return false
end
def write_fragment(name, fragment, options)
fragment
end
end
def setup
super
end
def test_output_buffer
output_buffer = ActionView::OutputBuffer.new
controller = MockController.new
cache_helper = Object.new
cache_helper.extend(ActionView::Helpers::CacheHelper)
cache_helper.expects(:controller).returns(controller).at_least(0)
cache_helper.expects(:output_buffer).returns(output_buffer).at_least(0)
# if the output_buffer is changed, the new one should be html_safe and of the same type
cache_helper.expects(:output_buffer=).with(responds_with(:html_safe?, true)).with(instance_of(output_buffer.class)).at_least(0)
assert_nothing_raised do
cache_helper.send :fragment_for, 'Test fragment name', 'Test fragment', &Proc.new{ nil }
assert output_buffer.html_safe?, "Output buffer should stay html_safe"
end
end
def test_safe_buffer
output_buffer = ActiveSupport::SafeBuffer.new
controller = MockController.new
cache_helper = Object.new
cache_helper.extend(ActionView::Helpers::CacheHelper)
cache_helper.expects(:controller).returns(controller).at_least(0)
cache_helper.expects(:output_buffer).returns(output_buffer).at_least(0)
# if the output_buffer is changed, the new one should be html_safe and of the same type
cache_helper.expects(:output_buffer=).with(responds_with(:html_safe?, true)).with(instance_of(output_buffer.class)).at_least(0)
assert_nothing_raised do
cache_helper.send :fragment_for, 'Test fragment name', 'Test fragment', &Proc.new{ nil }
assert output_buffer.html_safe?, "Output buffer should stay html_safe"
end
end
end

View File

@@ -78,7 +78,8 @@ class FilterTest < ActionController::TestCase
end
class RenderingController < ActionController::Base
before_filter :render_something_else
before_filter :before_filter_rendering
after_filter :unreached_after_filter
def show
@ran_action = true
@@ -86,9 +87,59 @@ class FilterTest < ActionController::TestCase
end
private
def render_something_else
def before_filter_rendering
@ran_filter ||= []
@ran_filter << "before_filter_rendering"
render :inline => "something else"
end
def unreached_after_filter
@ran_filter << "unreached_after_filter_after_render"
end
end
class RenderingForPrependAfterFilterController < RenderingController
prepend_after_filter :unreached_prepend_after_filter
private
def unreached_prepend_after_filter
@ran_filter << "unreached_preprend_after_filter_after_render"
end
end
class BeforeFilterRedirectionController < ActionController::Base
before_filter :before_filter_redirects
after_filter :unreached_after_filter
def show
@ran_action = true
render :inline => "ran show action"
end
def target_of_redirection
@ran_target_of_redirection = true
render :inline => "ran target_of_redirection action"
end
private
def before_filter_redirects
@ran_filter ||= []
@ran_filter << "before_filter_redirects"
redirect_to(:action => 'target_of_redirection')
end
def unreached_after_filter
@ran_filter << "unreached_after_filter_after_redirection"
end
end
class BeforeFilterRedirectionForPrependAfterFilterController < BeforeFilterRedirectionController
prepend_after_filter :unreached_prepend_after_filter_after_redirection
private
def unreached_prepend_after_filter_after_redirection
@ran_filter << "unreached_prepend_after_filter_after_redirection"
end
end
class ConditionalFilterController < ActionController::Base
@@ -452,6 +503,22 @@ class FilterTest < ActionController::TestCase
render :text => 'hello world'
end
end
class ImplicitActionsController < ActionController::Base
before_filter :find_only, :only => :edit
before_filter :find_except, :except => :edit
private
def find_only
@only = 'Only'
end
def find_except
@except = 'Except'
end
end
def test_sweeper_should_not_block_rendering
response = test_process(SweeperTestController)
assert_equal 'hello world', response.body
@@ -462,6 +529,11 @@ class FilterTest < ActionController::TestCase
assert sweeper.before(TestController.new)
end
def test_after_method_of_sweeper_should_always_return_nil
sweeper = ActionController::Caching::Sweeper.send(:new)
assert_nil sweeper.after(TestController.new)
end
def test_non_yielding_around_filters_not_returning_false_do_not_raise
controller = NonYieldingAroundFilterController.new
controller.instance_variable_set "@filter_return_value", true
@@ -623,6 +695,32 @@ class FilterTest < ActionController::TestCase
assert !assigns["ran_action"]
end
def test_before_filter_rendering_breaks_filtering_chain_for_after_filter
response = test_process(RenderingController)
assert_equal %w( before_filter_rendering ), assigns["ran_filter"]
assert !assigns["ran_action"]
end
def test_before_filter_redirects_breaks_filtering_chain_for_after_filter
response = test_process(BeforeFilterRedirectionController)
assert_response :redirect
assert_equal "http://test.host/filter_test/before_filter_redirection/target_of_redirection", redirect_to_url
assert_equal %w( before_filter_redirects ), assigns["ran_filter"]
end
def test_before_filter_rendering_breaks_filtering_chain_for_preprend_after_filter
response = test_process(RenderingForPrependAfterFilterController)
assert_equal %w( before_filter_rendering ), assigns["ran_filter"]
assert !assigns["ran_action"]
end
def test_before_filter_redirects_breaks_filtering_chain_for_preprend_after_filter
response = test_process(BeforeFilterRedirectionForPrependAfterFilterController)
assert_response :redirect
assert_equal "http://test.host/filter_test/before_filter_redirection_for_prepend_after_filter/target_of_redirection", redirect_to_url
assert_equal %w( before_filter_redirects ), assigns["ran_filter"]
end
def test_filters_with_mixed_specialization_run_in_order
assert_nothing_raised do
response = test_process(MixedSpecializationController, 'bar')
@@ -704,6 +802,19 @@ class FilterTest < ActionController::TestCase
assert_equal("I rescued this: #<FilterTest::ErrorToRescue: Something made the bad noise.>", response.body)
end
def test_filters_obey_only_and_except_for_implicit_actions
test_process(ImplicitActionsController, 'show')
assert_nil assigns(:user)
assert_equal 'Except', assigns(:except)
assert_nil assigns(:only)
assert_equal 'show', response.body
test_process(ImplicitActionsController, 'edit')
assert_equal 'Only', assigns(:only)
assert_nil assigns(:except)
assert_equal 'edit', response.body
end
private
def test_process(controller, action = "show")
@controller = controller.is_a?(Class) ? controller.new : controller

Some files were not shown because too many files have changed in this diff Show More