Commit Graph

4289 Commits

Author SHA1 Message Date
Akira Matsuda
24889666c7 fix meaningless test case
Module#instance_methods returns an Array of Symbols in Ruby >= 1.9
So this was not actually testing anything
2012-06-06 18:56:49 +09:00
Yuki Nishijima
0ec88cd1c8 accept a block in button helper. 2012-06-05 04:30:40 +09:00
Piotr Sarnacki
60b4290f1b Allow to use mounted helpers in ActionView::TestCase
Similarly to 6525002, this allows to use routes helpers for mounted
helpers, but this time in ActionView::TestCase
2012-06-01 17:45:06 +02:00
José Valim
5c565a2942 Merge pull request #6588 from nbibler/polymorphic_to_model
Correct the use of to_model in polymorphic routing
2012-06-01 16:42:09 +02:00
Piotr Sarnacki
6525002297 Include routes.mounted_helpers into integration tests
In integration tests, you might want to use helpers from engines that
you mounted in your application. It's not hard to add it by yourself,
but it's unneeded boilerplate. mounted_helpers are now included by
default. That means that given engine mounted like:

    mount Foo::Engine => "/foo", :as => "foo"

you will be able to use paths from this engine in tests this way:

    foo.root_path #=> "/foo"

(closes #6573)
2012-06-01 16:14:08 +02:00
Aaron Patterson
5f91ea3dc1 Merge branch 'master-sec'
* master-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:25:19 -07:00
Jeremy Friesen
4791822368 Extracted redirect logic from ActionController::Force::ClassMethods.force_ssl
Prior to this patch the existing .force_ssl method handles both defining
the filter and handling the logic for performing the redirect.

With this patch the logic for redirecting to the HTTPS protocol is
separated from the filter logic that determines if a redirect should
occur.  By separating the two levels of behavior, an instance method
for ActionController (i.e. #force_ssl_redirect) is exposed and available
for more granular SSL enforcement.

Cleaned up indentation.
2012-05-31 12:39:28 -04:00
Carlos Antonio da Silva
e2f5f01675 Simplify link_to using content_tag
Add some tests for link_to with blocks and escaping content.
2012-05-31 09:44:10 -03:00
Aaron Patterson
060c91cd59 Strip [nil] from parameters hash.
Thanks to Ben Murphy for reporting this!

CVE-2012-2660
2012-05-30 15:13:03 -07:00
Sergey Nartimov
ab7a80ea22 accept a block in button_to helper
Make possible to use a block in button_to helper if button text is hard
to fit into the name parameter, e.g.:

    <%= button_to [:make_happy, @user] do %>
      Make happy <strong><%= @user.name %></strong>
    <% end %>
    # => "<form method="post" action="/users/1/make_happy" class="button_to">
    #      <div>
    #        <button type="submit">
    #          Make happy <strong>Name</strong>
    #        </button>
    #      </div>
    #    </form>"
2012-05-30 23:29:13 +03:00
Sergey Nartimov
1376f4cab1 no need to pass an empty block to button_to helper 2012-05-30 23:02:26 +03:00
José Valim
135f620535 Merge pull request #6315 from appfolio/moving_number_helper_methods_to_active_support
Moving number helper from ActionView to Active Support
2012-05-28 00:09:46 -07:00
Piotr Sarnacki
e4aaac1301 Fix sorting of helpers from different paths
When more than one directory for helpers is provided to a controller, it
should preserver the order of directories. Given 2 paths:

    MyController.helpers_paths = ["dir1/helpers", "dir2/helpers"]

helpers from dir1 should be loaded first. Before this commit, all
helpers were mixed and then sorted alphabetically, which essentially
would require to rename helpers to get desired order.

This is a problem especially for engines, where you would like to be
able to predict accurately which engine helpers will load first.

(closes #6496)
2012-05-28 06:58:48 +02:00
Andrew Mutz
155cd5e6b5 Moving NumberHelpers from ActionView to ActiveSupport 2012-05-27 18:14:21 -07:00
Rafael Mendonça França
2c2b0beaf4 Add :escape option for truncate
This options can be used to not escape the result by default.
2012-05-26 14:27:07 -03:00
Rafael Mendonça França
4ce3b5d6fe Test that the block used in truncate is escaped if it is not HTML safe
Refactoring the truncate method to not do a sort-circuit return
2012-05-26 13:57:15 -03:00
Li Ellis Gallardo
38813da6dc Truncate now has the ability to receive a html option that allows it to call rails helpers.
This way if my text is long I don't have to do something like this:

.text
= truncate(@text, :length => 27)

 if @text.size >= 27
    = link_to "continue", notes_path, ....."")
2012-05-26 10:24:17 -05:00
José Valim
73db73fee9 Remove implicit dependency on pathname 2012-05-25 09:27:39 +02:00
José Valim
cb92efbf04 Merge pull request #6453 from parndt/session_keys
Added session.keys and session.values back to ActionDispatch::Request::Session
2012-05-22 22:49:14 -07:00
Philip Arndt
6ac458d341 Added ActionDispatch::Request::Session#keys and ActionDispatch::Request::Session#values 2012-05-23 14:47:30 +12:00
Carlos Galdino
30847b499b Add tests for time_field and date_field helpers
These tests check the values of 'min' and 'max' input attrs
2012-05-22 23:33:07 -03:00
Jeremy Kemper
65d2a60a8c Merge pull request #6359 from carlosgaldino/add-html5-inputs
Add HTML5 color and date/time inputs
2012-05-22 16:17:40 -07:00
Philip Arndt
40c0b3a25d Fixed typo new_defautls -> new_defaults.
* Added tests for 'else' case in ActionView::Helpers::TranslationHelper#wrap_translate_defaults
* Also updated the testing syntax of translation.html_safe? asserts to provide better output upon failure.
2012-05-23 11:04:15 +12:00
Carlos Galdino
b02d14aad5 Add several HTML5 input helpers
The input types added are:

- input[type="month"]

- input[type="week"]

- input[type="datetime"]

- input[type="datetime-local"]
2012-05-21 17:23:56 -03:00
Carlos Galdino
1ce4b5b33d Add HTML5 input[type="color"] helper 2012-05-21 17:23:48 -03:00
Marc-Andre Lafortune
89ebd28d4e Fix bug when Rails.application is defined but is nil. See #881 2012-05-21 15:24:18 -04:00
José Valim
776ea1090f Revert "Merge pull request #6425 from pinetops/resolver_concurrency_fix"
This reverts commit 254c04286c5916ae7f91eb6e173b312e7a74e364, reversing
changes made to 513a0525c24c2944630acfa465b22cd2f4601adf.
2012-05-21 21:01:02 +02:00
Aaron Patterson
254c04286c Merge pull request #6425 from pinetops/resolver_concurrency_fix
Resolver concurrency fix
2012-05-21 11:29:25 -07:00
Tom Clarke
685192bbcb Make the Resolver template cache threadsafe - closes #6404
The Template cache in the Resolver can be accessed by multiple threads
similtaneously in multi-threaded environments. The cache is implemented
using a Hash, which isn't threadsafe in all VMs (notably JRuby).

This commit extracts the cache to a new Cache class and adds mutexes to
prevent concurrent access.
2012-05-21 14:24:30 -04:00
Aaron Patterson
513a0525c2 Merge pull request #2549 from trek/RoutingErrorForMissingControllers
When a route references a missing controller, raise ActionController::RoutingError with clearer message
2012-05-21 11:00:43 -07:00
Andrew White
79b38c386a Escape the extension when normalizing the action cache path.
Although no recognized formats use non-ASCII characters, sometimes they
can be included in the :format parameter because of invalid URLS. To
prevent encoding incompatibility errors we need to escape them before
passing the path to URI.unescape.

Closes #4379
2012-05-20 19:07:05 +01:00
Andrew White
3fc561a1f7 Return 400 Bad Request for URL paths with invalid encoding.
Passing path parameters with invalid encoding is likely to trigger errors
further on like `ArgumentError (invalid byte sequence in UTF-8)`. This will
result in a 500 error whereas the better error to return is a 400 error which
allows exception notification libraries to filter it out if they wish.

Closes #4450
2012-05-20 19:07:04 +01:00
Andrew White
66eb3f02cc Raise ActionController::BadRequest for malformed parameter hashes.
Currently Rack raises a TypeError when it encounters a malformed or
ambiguous hash like `foo[]=bar&foo[4]=bar`. Rather than pass this
through to the application this commit captures the exception and
re-raises it using a new ActionController::BadRequest exception.

The new ActionController::BadRequest exception returns a 400 error
instead of the 500 error that would've been returned by the original
TypeError. This allows exception notification libraries to ignore
these errors if so desired.

Closes #3051
2012-05-20 19:07:04 +01:00
David Chelimsky
dcce01132d Raise Assertion instead of RoutingError for routing assertion failures.
Before this change, assert_recognizes, assert_generates, and
assert_routing raised ActionController::RoutingError when they failed to
recognize the route.

This commit changes them to raise Assertion instead. This aligns with
convention for logical failures, and supports reporting tools that care
about the difference between logical failures and errors e.g. the
summary at the end of a test run.

- Fixes #5899
2012-05-20 06:21:32 -05:00
Dmitry Vorotilin
32a433e1c0 Show in log correct wrapped keys 2012-05-20 09:33:56 +04:00
kennyj
e5e2ba14c3 Don't use assert_block method. It will be deprecated. 2012-05-20 00:14:40 +09:00
Carlos Antonio da Silva
0e207a499f Clarify grouped_options_for_select method API, add changelog entry
Make the method API more clear by explicitly showing the expected
arguments. This means that the options cannot be passed as second
argument because we are not relying on extract_options! anymore,
you are expected to give a selected key or `nil` if you want to pass
options, as it is the last argument.

Notice that this does not change the current method arguments contract
available in 3.2, it just brings back the same functionality with the
divider addition.
2012-05-19 09:58:14 -03:00
Jeremy Kemper
49b72fa864 Merge pull request #6384 from ihid/tidy_text_helpers
Tidied and standardised text_helper implementations.
2012-05-18 17:15:32 -07:00
Jeremy Walker
7e82ebd25e Tidied and standardised text_helper implementations. 2012-05-19 00:39:31 +01:00
kennyj
130b0d215d Fix build: can't convert Regexp to String 2012-05-19 05:13:28 +09:00
Andrew Mutz
2c423b3f3f reverting decoupling of NumberHelper from safe_join and adding tests for escaping of delimiters and separators 2012-05-18 11:56:18 -07:00
José Valim
a6a8957132 Merge pull request #6372 from richo/bugs/middleware_stack_as_array
Add some common Array methods to the middleware stack
2012-05-17 23:45:43 -07:00
José Valim
6bb86e1f3f Merge pull request #5020 from KL-7/fix-blank-image_tag-source
Render img tag with empty src if empty string is passed to image_tag.
2012-05-17 23:42:37 -07:00
Rich Healey
793205cccf Add the #unshift method to the middleware stack
The docs suggest that the middleware stack is an Array, so I've added
the unshift method to it. Originally I added some more Array methods,
but it was agreed that they lacked usecases.
2012-05-18 16:41:52 +10:00
Alex Soulim
446940c366 Add HTML5 input[type="time"] helper 2012-05-18 08:38:19 +04:00
Kirill Lashuk
3e9ec2411a Render img tag with empty src if empty string is passed to image_tag. 2012-05-18 01:39:39 +03:00
Jeremy Walker
90ec863b1d Removed old text_helper apis for highlight, excerpt and word_wrap 2012-05-17 21:52:49 +01:00
Rafael Mendonça França
319903bde5 Merge pull request #2036 from Bodacious/tag_helper_data_fix
TagHelper creates invalid data attributes when value is a BigDecimal
2012-05-17 11:01:21 -07:00
José Valim
f5ebc9a232 Merge pull request #6309 from steveklabnik/fix-2394
Created a Raw handler for templates.
2012-05-17 10:19:27 -07:00
Bodacious
56aabfd559 Fixed tag_helper data-attribute bug with BigDecimals 2012-05-17 18:15:43 +01:00