Commit Graph

860 Commits

Author SHA1 Message Date
Sean Griffin
708e1109d1 Merge pull request #17771 from agis-/issue-17373
Local vars should exist in partials for falsy `:object:` values too
2014-11-25 15:03:23 -07:00
Rafael Mendonça França
e3f7817cec Use released rails-dom-testing 2014-11-25 19:43:36 -02:00
Agis-
8f7434adba Local vars should exist in partials for falsy :object: values too
c67005f221f102fe2caca231027d9b11cf630484 made the local var in partials
available only if what passed to `:object` was truthy.

For example this would not make the local variable `foo` available inside the
partial:

    render partial: 'foo', object: false

Fixes #17373.
2014-11-25 22:26:42 +02:00
Xavier Noria
9685080a76 let mailer templates generate URLs by default [Xavier Noria, Richard Schneeman] 2014-11-24 14:33:50 -08:00
claudiob
1000e4c51a Move test that depends on ActiveRecord
This commit moves a test from `test/template` to `test/activerecord` since the
test depends on ActiveRecord.

This matches the documentation from [RUNNING_UNIT_TESTS](f28d1ddd50/actionview/RUNNING_UNIT_TESTS.rdoc):

> Test cases in the test/activerecord/ directory depend on having activerecord and sqlite3 installed.
> If Active Record is not in actionview/../activerecord directory, or the sqlite3 rubygem is not installed, these tests are skipped.
> Other tests are runnable from a fresh copy of actionview without any configuration.

---

More details about this commit.

All the tests starting with `require 'active_record_unit'` are already
inside `test/activerecord`, except for the one test this commit moves.

If you don't have `active_record` on your machine, the following command
currently fails on master:

```bash
```
2014-11-21 12:38:28 -08:00
Santiago Pastorino
7e375afba3 Merge pull request #17702 from tgxworld/fix_select_tag_include_blank_false
Fix select_tag generating tag when set to false.
2014-11-21 13:13:03 -02:00
Guo Xiang Tan
e0e9d5bd86 Fix select_tag generating tag when set to false.
Fixes https://github.com/rails/rails/issues/17701.
2014-11-21 17:44:24 +08:00
claudiob
5aedabe82d Wrap code snippets in +, not backticks, in sdoc
I grepped the source code for code snippets wrapped in backticks in the comments
and replaced the backticks with plus signs so they are correctly displayed in
the Rails documentation.

[ci skip]
2014-11-20 15:45:15 -08:00
Rafael Mendonça França
8ed5b46ce6 Merge pull request #17685 from claudiob/document-form-for-extra-options
Document *all* the options accepted by form_for

Conflicts:
	actionview/lib/action_view/helpers/form_helper.rb
2014-11-20 19:03:53 -02:00
claudiob
b0cc858dd7 Add :enforce_utf8 option to form_for
Since 06388b0 `form_tag` accepts the option `enforce_utf8` which, when set to
false, prevents the hidden "UTF8 enforcer" field from appearing in the output.

This commit implements the same behavior for `form_for`.

Stems from https://github.com/rails/rails/pull/17685#issuecomment-63871395
2014-11-20 12:46:30 -08:00
claudiob
753600b240 Document *all* the options accepted by form_for
The [current documentation of form_for](http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_for) is incomplete:

> The rightmost argument to form_for is an optional hash of options -
>   :url - The URL the form is to be submitted to. This may be represented in the same way as values passed to url_for or link_to. So for example you may use a named route directly. When the model is represented by a string or symbol, as in the example above, if the :url option is not specified, by default the form will be sent back to the current url (We will describe below an alternative resource-oriented usage of form_for in which the URL does not need to be specified explicitly).
>   :namespace - A namespace for your form to ensure uniqueness of id attributes on form elements. The namespace attribute will be prefixed with underscore on the generated HTML id.
>   :html - Optional HTML attributes for the form tag.

This commit completes the documentation by specifying that:

* `:authenticity_token` is also a valid option (as [documented here](b0f44c9ff0/actionview/lib/action_view/helpers/form_helper.rb (L396)))
* `:method` is also a valid option (as [tested here](b0f44c9ff0/actionview/test/template/form_helper_test.rb (L1819)))
* `:remote` is also a valid option (as [tested here](b0f44c9ff0/actionview/test/template/form_helper_test.rb (L1850)))

[ci skip]
2014-11-20 12:39:58 -08:00
Akira Matsuda
7839e27b4e Some valid block calls in templates caused syntax errors
Now ActionView accepts <%= foo(){ %> and <%= foo()do %> 
2014-11-20 07:21:50 +09:00
Christopher Dell
4dbce79e95 Fix I18n regression introduced by #13832
Previously, when the `:raise` options was set to `false`, it would get overwritten to `true`, preventing custom exception handlers to be used.
2014-11-19 16:33:50 +01:00
Ryan Bigg
97f2c4129a Add space in :start_year description for date_select 2014-11-19 19:20:37 +11:00
Akira Matsuda
644696e2ac Duplicated Hash key :prompt 2014-11-19 08:29:22 +09:00
Rafael Mendonça França
1b9e85dbbd Make sure assert_select can assert body tag
This reverts commit f93df52845766216f0fe36a4586f8abad505cac4, reversing
changes made to a455e3f4e9dbfb9630d47878e1239bc424fb7d13.

Conflicts:
	actionpack/lib/action_controller/test_case.rb
	actionview/lib/action_view/test_case.rb
2014-11-18 18:47:22 -02:00
Rafael Mendonça França
5b7b98d590 document_root_element need to be public 2014-11-17 16:37:17 -02:00
Pablo Herrero
861b70e92f Call gsub with a Regexp instead of a String for better performance 2014-11-01 20:23:29 -03:00
Rafael Mendonça França
0d6a56d635 Improve test of private properties of objects in form tags 2014-10-31 16:41:51 -02:00
agius
1ff67d8286 Use public_send for form tags 2014-10-31 16:34:02 -02:00
Tobias Pfeiffer
f0570a3d3f Honor public/private in ActionView::Helpers::Tags::Base#value
* use public_send instead of send to avoid calling private
  methods in form helpers
2014-10-31 16:33:42 -02:00
Godfrey Chan
4daebedcc4 Prepare for 4.2.0.beta4 release 2014-10-30 14:12:24 -07:00
Pablo Herrero
724db9eb62 Fix typo at form_helper docs [ci skip] 2014-10-29 21:03:26 -03:00
Xavier Noria
e595d91ac2 edit pass over all warnings
This patch uniformizes warning messages. I used the most common style
already present in the code base:

* Capitalize the first word.

* End the message with a full stop.

* "Rails 5" instead of "Rails 5.0".

* Backticks for method names and inline code.

Also, converted a few long strings into the new heredoc convention.
2014-10-28 17:47:32 -07:00
Xavier Noria
b3bfa361c5 let's warn with heredocs
The current style for warning messages without newlines uses
concatenation of string literals with manual trailing spaces
where needed.

Heredocs have better readability, and with `squish` we can still
produce a single line.

This is a similar use case to the one that motivated defining
`strip_heredoc`, heredocs are super clean.
2014-10-28 16:35:24 -07:00
Ryunosuke SATO
44260581be Fix doc markup for NumberHelper [ci skip]
The character "*" is unnecessary in option candidates.
This incorrect markup was injected in e8c9aeca .
2014-10-29 00:32:43 +09:00
Rafael Mendonça França
450743cf56 Add CHANGELOG entry for #17064 2014-10-25 16:20:44 -07:00
Rafael Mendonça França
b2278aa1a0 Use new hash syntax 2014-10-25 16:20:41 -07:00
Rafael Mendonça França
f28340a5ef ✂️ 2014-10-25 16:14:23 -07:00
Rafael Mendonça França
0afbe74c3b Merge pull request #17064 from frenkel/fix_select_tag_include_blank
Use include_blank value as option label
2014-10-25 16:10:31 -07:00
Prathamesh Sonpatki
95acea5498 Clarify comments about sanitized_allowed_tags
- Clarify that arguments are expected in array format.
- Extension of https://github.com/rails/rails/pull/17390.
- https://github.com/rails/rails/pull/17390 was targeted against
  4-1-stable branch. This commit updates master.
- [ci skip]
2014-10-25 23:19:27 +05:30
Akira Matsuda
a60e6ddb83 Reduce object allocation 2014-10-25 12:59:37 +09:00
Akira Matsuda
f888448ed2 Reduce object allocation 2014-10-25 12:59:37 +09:00
Akira Matsuda
9461583d3f Avoid creating unneeded Hash instance and calling slow Hash#fetch 2014-10-25 12:59:37 +09:00
Frank Groeneveld
d611036c77 Use include_blank value as option label
Update select_tag to reflect documentation and behave the same as form builder select. If the value of include_blank is not boolean true, use that value as the option label.
2014-10-17 08:21:56 +02:00
Rafael Mendonça França
be5521eb4e Use released rails-dom-testing 2014-10-16 16:53:46 -03:00
claudiob
dee00df11c Fix how file_ and password_field_tag edit options
This commit fixes the behavior of `file_field_tag` and `password_field_tag`
when invoked with a hash of options.

These two helpers are different from all the other ones in that they modify the
options hash passed as a parameter, whereas all the other helpers duplicate it
before updating it.

The result is that *bad things* can happen if the user re-uses the same hash.
For instance, users who write the following code to display a file field
followed by a text field (both with the same class):

```rhtml
<% options = {class: 'important'} %>
<%= file_field_tag 'Upload', options %>
<%= text_field_tag 'Name', options %>
```

would instead see **two file fields!**

```html
<input class="important" id="Upload" name="Upload" type="file">
<input class="important" id="Name" name="Name" type="file" value="value">
```

This PR replaces `update` with `merge` in the code of the two helpers,
fixing the issue above.

The included test verifies the change, since it passes after this PR, but
fails before with the following error:

```
Expected: <input type="text" name="title" id="title" value="Hello!" class="important" />
Actual: <input type="password" name="title" id="title" value="Hello!" class="important" />
```
2014-10-15 10:15:45 -07:00
Rafael Mendonça França
dedeb8420e Merge pull request #17271 from claudiob/remove-duplicate-stringify-keys
Remove duplicate stringify_keys in text_field_tag and number_field_tag
2014-10-15 13:51:52 -03:00
claudiob
a9050e71bf Remove duplicate stringify_keys in text_field_tag
All the methods that invoke `text_field_tag` (such as `hidden_field_tag`)
and all the methods that invoke `number_field_tag` (that is `range_field_tag`)
do not need to call `stringify_keys` on their `options` parameter since the
`text_field_tag` method [is already doing it internally](4159134524/actionview/lib/action_view/helpers/form_tag_helper.rb (L182)):

```ruby
def text_field_tag(name, value = nil, options = {})
  tag :input, { "type" => "text", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(options.stringify_keys)
end
```

and `number_field_tag` is [already doing it internally](e3207bdbba/actionview/lib/action_view/helpers/form_tag_helper.rb (L780)) as well:

```ruby
def number_field_tag(name, value = nil, options = {})
  options = options.stringify_keys
  ...
end

[Note #1: My code uses `merge` to respect the existing behavior of
duplicating the `options` hash before updating its keys, see https://github.com/rails/rails/pull/17096#issuecomment-57223827]

[Note #2: My code uses symbols instead of strings (e.g.: `:hidden`) to look
forward to future version of Ruby/Raiks (GC symbols); the result of the method,
however, is the same, because the symbols are stringified inside `text_field_tag`]

[Note #3: I had previously created a similar PR #17096 but decided to
split it into multiple PRs given the feedback received in the comments]
2014-10-15 09:41:24 -07:00
Erik Michaels-Ober
8bb33e920a Replace Enumerable#reverse.each with Enumerable#reverse_each 2014-10-13 11:47:16 +01:00
schneems
03d30ce71c remove un-needed sort
HTML doesn't care what order the elements are rendered in, so why should we?

Updates tests to use proper `assert_dom_equal` instead of `assert_equal` /cc @jeremy
2014-10-07 16:54:38 -05:00
Rafael Mendonça França
fbfc4ac298 Merge pull request #17146 from divineforest/active-record-gsub-to-tr
Change `gsub` to `tr` where possible
2014-10-07 12:07:56 -03:00
Alexander Balashov
8764ef95dc Change gsub to tr where possible 2014-10-06 14:03:06 +04:00
Alex Weidmann
afb92754c8 Use #tr instead of #gsub where possible 2014-10-02 17:35:13 -06:00
Rafael Mendonça França
7b740f31cc Merge pull request #17088 from robin850/jruby-dev
Follow up to #16613
2014-10-01 22:56:08 -03:00
Adrian Rangel
56d26d1d9f use tr instead of gsub when possible 2014-10-01 02:19:52 -05:00
igor04
0e50b7bdf4 Added processing of nil to highlight helper method 2014-09-30 14:48:48 +03:00
Kasper Timm Hansen
f939904f23 Parse HTML as document fragment.
This is to match the changes in Rails Dom Testing rails/rails-dom-testing#20.
2014-09-29 21:41:52 +02:00
Robin Dupret
1fac7b79f3 Follow up to #16613
Since we want this flag to be enabled anytime we are running the tests
under JRuby, let's enable this at the Rakefile level so people get the
performance boost on their local checkout.

Moreover, we avoid having to update this particular line anytime the
option changes on the JRuby side.

The only drawback is that we have to define it in every Rakefile but
there's no big deal, this is already the case for other options.
2014-09-28 12:04:06 +02:00
Rafael Mendonça França
4581d04477 Preparing for 4.2.0.beta2 release 2014-09-26 17:19:53 -03:00
claudiofullscreen
0b725aa7d6 Don’t require already required modules
abstract_unit.rb requires `action_controller` which [already includes the following lines of code](64fcdce1d3/actionpack/lib/action_controller.rb (L2L3)):

```ruby
require 'abstract_controller'
require 'action_dispatch'
```
2014-09-26 13:05:00 -07:00
Felipe Oliveira
0d49841187 Add +variants to ActionView::FileSystemResolver documentation. 2014-09-26 14:26:16 -03:00
Rafael Mendonça França
f82ecef9ae Merge pull request #17058 from eval/issue-17057
Remove internal options from query string of paths
2014-09-25 17:15:00 -03:00
Godfrey Chan
b5571b3ccf Revert "Revert "Merge pull request #16888 from jejacks0n/render_template""
This reverts commit 585e75696b31395aee895e5366e331c07c3f5ee1.
2014-09-26 01:42:18 +09:00
Godfrey Chan
b008e4bd8a Use released rails-html-sanitizer and rails-deprecated_sanitizer 2014-09-26 01:37:05 +09:00
Gert Goet
2d08fd2506 Remove internal options from query string of paths
Fixes #17057
2014-09-25 17:50:16 +02:00
Rafael Mendonça França
2c0cad8034 Use released rails-dom-testing 2014-09-25 12:31:42 -03:00
Godfrey Chan
585e75696b Revert "Merge pull request #16888 from jejacks0n/render_template"
This reverts commit 07635a74b5ee08dcba3f6617def6230d8f114fe5, reversing
changes made to 1b5f61a025b6ce1ee52b7148e3ed2a9acbde28b9.

Reason: it's not ready 💣, see https://github.com/rails/rails/pull/16888#issuecomment-56400816
2014-09-23 02:06:08 +09:00
Godfrey Chan
b04ac976d9 CHANGELOG for 07635a7 2014-09-23 00:48:06 +09:00
Godfrey Chan
07635a74b5 Merge pull request #16888 from jejacks0n/render_template
Changes default render behavior from file to template.
2014-09-23 00:34:36 +09:00
claudiob
606ce3f907 Remove wrapping <div> in form helpers from doc
[ci skip]

89ff1f8 and 1de258e6 removed from the HTML generated by the form helpers
the <div> that was wrapping the field elements inside the <form>.

This commit updates the documentation of the methods to reflect the
two commits above.
2014-09-22 00:37:03 -07:00
Akshay Vishnoi
8841f45129 [ci skip] ActionView and ActionMailer CHANGELOG docs fixes 2014-09-18 03:40:51 +05:30
Rafael Mendonça França
1bdb233bc2 Merge pull request #16790 from cirosantilli/explain-erb-space-removal
Explain ERB space removal.

[ci skip]
2014-09-16 11:14:28 -03:00
Aaron Patterson
8a47e87267 handle <%== nil %> cases
This is much less common than string literal appends, so add a special
case method for it.  Maybe fixes bug reported by @jeremy on 97ef636191933f1d4abc92fc10871e6d1195285c
2014-09-14 17:11:13 -07:00
Aaron Patterson
97ef636191 Stop nil checking on safe_append=
ERB compiler guarantees safe_append= will be called with a string, so
nil checks don't make sense.  Anything else calling this method should
check for nil themselves before calling
2014-09-14 13:26:39 -07:00
Matthew Draper
457c876b15 Revert "Merge pull request #15312 from JuanitoFatas/action_view/asset_path"
This reverts commit 21ec7fefea5a1b823cb88733b019b3d52240801d.

Per #16911, there's actually a good reason for a "blank" value to have a
useful `to_s` here. So let's also add some tests to prove that.
2014-09-14 07:04:47 +09:30
jejacks0n
428722ba4f Changes default render behavior from file to template. 2014-09-11 21:54:49 -06:00
Ciro Santilli
700ec897f9 Explain ERB space removal. [ci skip] 2014-09-11 09:55:57 +02:00
Rafael Mendonça França
412f651665 Merge pull request #16839 from chancancode/default_test_order
Default to sorting user's test cases for now
2014-09-10 22:34:06 -03:00
Rafael Mendonça França
fb11038148 Do not memoize document_root_element in view tests
Memoizing will not make possible to assert the output of the view if it
is changed after the first assert_select call

Related with plataformatec/simple_form#1130 and rails/rails-dom-testing#15
2014-09-08 18:04:45 -03:00
Godfrey Chan
2b41343c34 Default to sorting user's test cases for now
Goals:

1. Default to :random for newly generated applications
2. Default to :sorted for existing applications with a warning
3. Only show the warning once
4. Only show the warning if the app actually uses AS::TestCase

Fixes #16769
2014-09-08 05:32:16 -07:00
Rajarshi Das
ab2ace6bbe fix the undefined method content_tag #15245
not required include ActionView::Helpers::TagHelper in test as well
2014-09-06 12:09:01 +05:30
Matthew Draper
7025d7769d For now, we will keep sorting the tests.
This reverts commits e969c928463e329fd6529ac59cad96385c538ffb and
bd2b3fbe54e750ba97469a7896e8d143d6dfd465.
2014-09-05 23:33:27 +09:30
Rafael Mendonça França
faa0f32434 Extract data/aria attribute prefixes to a constant 2014-09-03 18:31:04 -03:00
PaoMar
ee61b76a81 Add support for ARIA attributes in tags 2014-09-03 16:14:21 -05:00
Kasper Timm Hansen
28eecd934b Ship with rails-html-sanitizer instead. 2014-09-03 20:27:59 +02:00
Ciro Santilli
247cc94574 Shorten ActionView::Base doc summary line. [ci skip] 2014-09-02 19:09:42 +02:00
Ciro Santilli
afb230ec93 Clarify Rails uses erubis not stdlin ERB. [ci skip] 2014-09-02 18:12:04 +02:00
Matthew Draper
2f52f96988 Leave all our tests as order_dependent! for now
We're seeing too many failures to believe otherwise.

This reverts commits bc116a55ca3dd9f63a1f1ca7ade3623885adcc57,
cbde413df3839e06dd14e3c220e9800af91e83ab,
bf0a67931dd8e58f6f878b9510ae818ae1f29a3a, and
2440933fe2c27b27bcafcd9019717800db2641aa.
2014-09-02 23:55:34 +09:30
Rafael Mendonça França
67b42cb4aa Move implementation to the gems
Now we keep only the common code and move the specific code to the gems
2014-09-01 23:26:10 -03:00
Rafael Mendonça França
5c057f9255 Remove warning 2014-09-01 22:20:39 -03:00
Sammy Larbi
2fae37f0ac Allow polymorphic routes with nil when a route can still be drawn
Suppose you have two resources routed in the following manner:

```ruby
resources :blogs do
  resources :posts
end

resources :posts
```

When using polymorphic resource routing like `url_for([@blog, @post])`, and `@blog` is `nil` Rails should still try to match the route to the top-level posts resource.

Fixes #16754
2014-08-31 11:39:46 -05:00
Robin Dupret
84c0f73c8d Refer to the library name instead of the constant
When we are loading a component and we want to know its version, we are
actually not speaking about the constant but the library itself.

[ci skip]

[Godfrey Chan & Xavier Noria]
2014-08-30 11:58:23 +02:00
David Heinemeier Hansson
7475b43cdb Merge branch 'master' of github.com:rails/rails 2014-08-29 14:54:08 -07:00
Akira Matsuda
bd2b3fbe54 No need to sort tests
Dir.glob result must be already sorted anyway
2014-08-28 14:41:00 +09:00
Aaron Patterson
cab85e9926 remove useless parameter 2014-08-27 17:59:34 -07:00
Aaron Patterson
7a2622bcbd remove dead code
the ERB has already been compiled to Ruby code by the time we're calling
module_eval.  Nothing that module eval raises will be caught by a blank
`rescue`, so I think we can remove this
2014-08-27 17:59:09 -07:00
Yves Senn
20e7f08ecc minor changelog formatting changes. 2014-08-27 12:09:21 +02:00
Jeremy Kemper
0b7edd4418 Merge pull request #16488 from agrobbin/form-label-builder
Provide a builder for form labels to customize wrapping around I18n content
2014-08-25 07:22:17 -07:00
Jeremy Kemper
671615ac2a Merge pull request #16639 from agrobbin/input-placeholder-i18n
Add I18n support for `:placeholder` HTML option is passed to form fields
2014-08-24 15:26:24 -07:00
T.J. Schuck
0387591c05 Remove erroneous form_tag option docs
This is true of the first param (url_for_options),
not of the second options param which is being
documented here.

[ci skip]
2014-08-22 15:22:59 -04:00
T.J. Schuck
60da337a00 Clarify that unknown keys will become HTML attrs
Docs for all the other form tag helpers in this
file already clarify this.

[ci skip]
2014-08-22 15:20:53 -04:00
Alex Robbin
f99e62e2d9 just use the placeholder tag value if it is passed as a String 2014-08-22 09:54:54 -04:00
Alex Robbin
fea7fe1fd2 add I18n support for :placeholder HTML option is passed to form fields 2014-08-22 09:22:26 -04:00
Jeremy Kemper
81b14b7c5c Revert "Add I18n support for :placeholder HTML option is passed to form fields" 2014-08-21 22:07:33 -07:00
Alex Robbin
ce8e4a43b3 provide a builder for form labels to customize wrapping around I18n content 2014-08-20 09:59:28 -04:00
David Heinemeier Hansson
6a23bf0f4c Preparing for 4.2.0.beta1 release 2014-08-19 19:32:51 -07:00
Rafael Mendonça França
08f209614b Use released rails-deprecated_sanitizer 2014-08-19 16:45:31 -03:00
Rafael Mendonça França
fad9e729f1 Fix the rails-dom-testing dependecy 2014-08-19 16:41:38 -03:00
Vijay Dev
41231ef6c6 Merge branch 'master' of github.com:rails/docrails
Conflicts:
	actionpack/lib/action_controller/metal/mime_responds.rb
	actionview/lib/action_view/vendor/html-scanner/html/sanitizer.rb
	activerecord/lib/active_record/type/value.rb
2014-08-19 16:28:53 +00:00
Rafael Mendonça França
5e6c45a7db Removed warning 2014-08-18 20:41:03 -03:00
Rafael Mendonça França
8d0d051680 Fix assertion to map the behaviour of the old sanitizer 2014-08-18 16:04:45 -03:00
Rafael Mendonça França
d2d809868c Merge pull request #15889 from carnesmedia/model-name
Use #model_name on instances instead of classes
2014-08-17 23:01:13 -03:00
Rafael Mendonça França
c78da4d5c4 Merge branch 'master' into loofah
Conflicts:
	actionpack/CHANGELOG.md
2014-08-17 22:38:22 -03:00
Kasper Timm Hansen
1e2ffe7ae6 Prepare for partial release.
- Default to Rails::DeprecatedSanitizer in ActionView::Helpers::SanitizeHelper.
- Add upgrade notes.
- Add sanitizer to new applications Gemfiles.
- Remove 'rails-dom-testing' as a dependency.
2014-08-17 19:25:47 +02:00
José Valim
2b0c602bc3 Remove usafe of respond_to in ActionView tests 2014-08-17 13:20:22 -04:00
schneems
4d47220d7c Perf optimization for url_for called w/ Hash
Benchmarking the existing code:

```ruby
{ :only_path => options[:host].nil? }.merge!(options.symbolize_keys)) 
```

Against optimized code, that does not require a new hash or a merge:

```ruby
options = options.symbolize_keys
options[:only_path] = options[:host].nil? unless options.key?(:only_path)
options
```

We see a statistically significant performance gain:

![](https://www.dropbox.com/s/onocpc0zfw4kjxl/Screenshot%202014-08-14%2012.45.30.png?dl=1)

Updated to not mutate incoming parameters
2014-08-14 12:46:06 -05:00
Jeremy Kemper
dfc3f88311 Merge pull request #16438 from agrobbin/input-placeholder-i18n
Add I18n support for `:placeholder` HTML option is passed to form fields
2014-08-14 06:46:17 -07:00
Akira Matsuda
1a299b6ca6 Missing ActiveSupport require for calling String#first 2014-08-14 01:06:34 +09:00
Akira Matsuda
bc116a55ca AM, AP, AV, and AMo tests are already order_independent! 2014-08-13 21:25:10 +09:00
Alex Robbin
8b02832500 add I18n support for :placeholder HTML option is passed to form fields 2014-08-12 23:11:43 -04:00
Rafael Mendonça França
a2400308ea Merge branch 'master' into loofah
Conflicts:
	actionpack/CHANGELOG.md
	actionpack/test/controller/integration_test.rb
	actionview/CHANGELOG.md
2014-08-12 11:10:42 -03:00
Rafael Mendonça França
e81f3c210e Nobody sucks so nobody should call this awful method name 2014-08-12 10:51:41 -03:00
Akira Matsuda
6ffb29d24e users_dont_suck_but_only_we_suck_and_only_our_tests_are_order_dependent!
Calling ActiveSupport::TestCase.i_suck_and_my_tests_are_order_dependent! in AS::TestCase makes
everyone's tests order dependent, which should never be done by the framework.
2014-08-12 19:37:04 +09:00
Hendy Tanata
71c7fd1013 Uppercase HTML in docs.
[skip ci]
2014-08-08 14:27:05 -07:00
Akira Matsuda
3dfcae6afa defined? should actually work in current implementation
So this trick is not needed to be documented anymore.
2014-08-07 01:59:58 +09:00
Bogdan Gusiev
7a0c2ba48b Fixed #select form builder helper to support block with html output 2014-08-05 17:23:00 +03:00
Carlos Antonio da Silva
29a6a17a11 Properly assert for the expected messages
The message passed to Minitest's assert_raise is used as output in case
the assertion fails, but we can test against the exact message by using
the actual exception object that is returned from the assert_raise call.
2014-07-30 23:41:19 -03:00
Aaron Patterson
20a277c9a2 don't access named routes internals
just ask whether or not the route is defined
2014-07-30 15:27:20 -07:00
@schneems and @sgrif
2bbcca004c Deprecate *_path methods in mailers
Email does not support relative links since there is no implicit host. Therefore all links inside of emails must be fully qualified URLs. All path helpers are now deprecated. When removed, the error will give early indication to developers to use `*_url` methods instead.

Currently if a developer uses a `*_path` helper, their tests and `mail_view` will not catch the mistake. The only way to see the error is by sending emails in production. Preventing sending out emails with non-working path's is the desired end goal of this PR.

Currently path helpers are mixed-in to controllers (the ActionMailer::Base acts as a controller). All `*_url` and `*_path` helpers are made available through the same module. This PR separates this behavior into two modules so we can extend the `*_path` methods to add a Deprecation to them. Once deprecated we can use this same area to raise a NoMethodError and add an informative message directing the developer to use `*_url` instead.

The module with warnings is only mixed in when a controller returns false from the newly added `supports_relative_path?`.

Paired @sgrif & @schneems
2014-07-30 12:01:45 -05:00
Yves Senn
aade0a0412 docs, cleanup mixed indents within form_options_helper.rb RDoc.
[ci skip]

This fixes the broken code block rendering and indents the examples
within the parameter list.
2014-07-29 14:57:48 +02:00
David Heinemeier Hansson
da1b8a786c Fix that render layout should also be picked up by the template dependency tracker, but only half-ways. You can add that layout option on the same render call, and both templates should be added to the dependency tree. But thats going to require a more serious rework of the tracker. Please do help fix this part of it too. For now, render layout needs to be on its own line. 2014-07-25 16:37:18 -07:00
Rafael Mendonça França
08754f12e6 Merge branch 'rm-remove-mocha'
Conflicts:
	actionpack/test/abstract_unit.rb
2014-07-19 18:17:13 -03:00
Rafael Mendonça França
fd6aaaa0c3 Stop requiring mocha automatically
We are planning to remove mocha from our test suite because of
performance problems. To make this possible we should stop require mocha
on ActionSupport::TestCase.

This should not affect applications since users still need to add mocha
to Gemfile and this already load mocha.

Added FIXME notes to place that still need mocha removal
2014-07-19 17:35:12 -03:00
Eugene Gilburg
afc928445d adding missing test for text area value before type cast 2014-07-19 12:06:36 -07:00
Eugene Gilburg
080c2ba0ca adding missing test coverage 2014-07-18 21:08:11 -07:00
Eugene Gilburg
348de3a06e marking private methods which dont work if called on their own anyways 2014-07-18 20:54:30 -07:00
Eugene Gilburg
38117adfe3 small refactors to actionview renderers 2014-07-18 20:54:03 -07:00
Guo Xiang Tan
ee35b79d4c Prefer to pass block when logging.
The Logger by default includes a guard which checks for the
logging level. By removing the custom logging guards, we can decouple
the logging guard from the logging action to be done.

This also follows the good practice listed on http://guides.rubyonrails.org/debugging_rails_applications.html#impact-of-logs-on-performance.
2014-07-18 15:04:43 +08:00
Yves Senn
246f07c751 docs, select and friends with multiple=true include a blank string.
[Jonas Baumann & Yves Senn]

The submitted params from a select with `multiple: true` look as follows:

```
{post: {category: [""]}}

{post: {category: ["", "Category 1", "Category 2"]}}
```

This is a follow up to #1552.
2014-07-17 17:28:58 +02:00
Godfrey Chan
b062d5d967 Merge pull request #16201 from noinkling/master
Fix broken list formatting in API docs [ci skip]
2014-07-16 22:58:15 -07:00
Aaron Patterson
c6a97b8d4d subclass Rails::Engine 2014-07-16 21:48:26 -07:00
noinkling
f5d79d7650 Fix broken list formatting [ci skip] 2014-07-17 15:24:52 +12:00
Rafael Mendonça França
9bbb3ca306 Use &= instead of select with include?
The performance is almost the same with both implementations but this is
clear.

Before this patch:

Calculating -------------------------------------
  small erb template      1452 i/100ms
-------------------------------------------------
  small erb template    17462.1 (±13.3%) i/s -      85668 in   5.031395s
.Calculating -------------------------------------
small erb template with 1 partial
                           887 i/100ms
-------------------------------------------------
small erb template with 1 partial
                         8899.6 (±18.8%) i/s -      42576 in   5.009453s
.Calculating -------------------------------------
small erb template with 2 partials
                           666 i/100ms
-------------------------------------------------
small erb template with 2 partials
                         6821.5 (±8.8%) i/s -      33966 in   5.020791s

After the patch:

Calculating -------------------------------------
  small erb template      1479 i/100ms
-------------------------------------------------
  small erb template    15956.6 (±7.6%) i/s -      79866 in   5.036001s
.Calculating -------------------------------------
small erb template with 1 partial
                           841 i/100ms
-------------------------------------------------
small erb template with 1 partial
                         9242.2 (±6.9%) i/s -      46255 in   5.029497s
.Calculating -------------------------------------
small erb template with 2 partials
                           615 i/100ms
-------------------------------------------------
small erb template with 2 partials
                         6524.7 (±6.8%) i/s -      32595 in   5.020456s

You can find the benchmark code at
https://gist.github.com/rafaelfranca/dee31120cfdb1ddc3b56
2014-07-16 16:42:53 -03:00
Rafael Mendonça França
b5fbcc5d52 Merge pull request #15917 from luke-gru/actionview_perf
remove Set.new from DetailsKey::get, impacts rendering overhead
2014-07-16 16:14:42 -03:00
Rafael Mendonça França
d4df7ce7b3 Fix typo on the variable name 2014-07-16 14:59:55 -03:00
Rafael Mendonça França
03d77504be Add CHANGELOG entry for PartialIteration.
Closes #7698.
2014-07-16 14:54:23 -03:00
Rafael Mendonça França
7dc0f3fc8d Document the PartialIteration object 2014-07-16 14:54:23 -03:00
Rafael Mendonça França
9290fc5ce2 Build only one PartialIteration object for loop 2014-07-16 14:54:22 -03:00
Rafael Mendonça França
9830ebbeaf No need to have a file to PartialIteration class
This class is only used on the PartialRenderer.
2014-07-16 14:50:51 -03:00
Joel Junström
1f5b360466 Added PartialIteration class used when rendering collections
The iteration object is available as the local variable
"template_name_iteration" when rendering partials with collections.

It gives access to the +size+ of the collection beeing iterated over,
the current +index+ and two convinicence methods +first?+ and +last?+

"template_name_counter" variable is kept but is deprecated.

[Joel Junström + Lucas Uyezu]
2014-07-16 14:50:51 -03:00
Rafael Mendonça França
045d717316 Use the plugin API to the getter and setters
To avoid having to redefine these methods on the deprecated plugin we
should be using the sanitizer_vendor API.
2014-07-15 20:19:59 -03:00
Rafael Mendonça França
82e478836f Use regexp instead exact match for atom test
There are two xml namespaces in the response body and the xhtml
namespace is not registered in the root node. This create an invalid XML
and nokogiri can't navigate using xpath on that node.
2014-07-15 14:42:36 -03:00
Rafael Mendonça França
f5426315d9 All these tests are passing now 2014-07-15 13:59:10 -03:00
Rafael Mendonça França
a8c667e8f1 Defining the right dependencies 2014-07-15 13:40:22 -03:00
Rafael Mendonça França
158a6dfcd2 We don't need loofah for the assertions
We can just use nokogiri
2014-07-15 13:40:21 -03:00
Rafael Mendonça França
126a15e0fe Include the selector assertions on the test case
We don't need to require users to include this module on
ActionMailer::TestCase
2014-07-15 13:40:18 -03:00
Rafael Mendonça França
04e7ea3e92 Merge pull request #16175 from skorks/log_digestor_as_debug
Log digest as :debug instead of :info
2014-07-15 11:12:27 -03:00
Andrew White
c3f4d6c8fe Merge pull request #16161 from jpawlyn/master
Fix empty host for an asset url when asset_host proc returns nil
2014-07-15 09:32:01 +01:00
Jolyon Pawlyn
d005777469 Return an absolute instead of relative path from an asset url in the case of the asset_host proc returning nil 2014-07-15 08:32:55 +01:00