Commit Graph

754 Commits

Author SHA1 Message Date
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
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