Commit Graph

4702 Commits

Author SHA1 Message Date
Rafael Mendonça França
3148ed9a4b Merge pull request #8115 from senny/7842_handle_trailing_slash_with_engines
handle trailing slash with engines (test case for #7842)
2012-11-08 11:50:08 -08:00
Benjamin Quorning
478d80fd57 Test that permitted? is sticky on accessors, mutators, and merges 2012-11-06 21:30:12 +01:00
Benjamin Quorning
1a0f14e045 Test that not permitted is sticky on #except 2012-11-06 21:24:14 +01:00
Benjamin Quorning
93eaffe59b Current tests are testing stickiness of non-permitted parameters 2012-11-06 21:23:24 +01:00
Benjamin Quorning
5b3b9b0ebc Fix buggy tests 2012-11-06 21:22:57 +01:00
Carlos Antonio da Silva
7fb536972e Add ensure block to make sure the state is properly restored 2012-11-04 19:50:56 -02:00
Yves Senn
88ba1fb03e test case to lock down the behavior of #7842 2012-11-04 15:15:29 +01:00
Santiago Pastorino
c2a7956eb7 Move ensure_secret_secure to DummyKeyGenerator 2012-11-03 14:57:54 -02:00
Santiago Pastorino
47da574474 Allow users to change the default salt if they want, shouldn't be necessary 2012-11-03 14:57:54 -02:00
Santiago Pastorino
5d23925f84 Use derived keys everywhere, http_authentication was missing it 2012-11-03 14:57:54 -02:00
Santiago Pastorino
38c40dbbc1 Add cookie.encrypted which returns an EncryptedCookieJar
How to use it?

cookies.encrypted[:discount] = 45
=> Set-Cookie: discount=ZS9ZZ1R4cG1pcUJ1bm80anhQang3dz09LS1mbDZDSU5scGdOT3ltQ2dTdlhSdWpRPT0%3D--ab54663c9f4e3bc340c790d6d2b71e92f5b60315; path=/
cookies.encrypted[:discount]
=> 45
2012-11-03 14:57:53 -02:00
Santiago Pastorino
60609bb50d Sign cookies using key deriver 2012-11-03 14:57:53 -02:00
James Coglan
76a0237cf0 Store FlashHashes in the session as plain hashes rather than custom objects with unstable class names and instance variables.
Refactor FlashHash to take values for its ivars in the constructor, to pretty up FlashHash.from_session_value.

Remove stale comment on FlashHash: it is no longer Marshaled in the session so we can change its implementation.

Remove blank lines I introduced in controller/test_case.rb.

Unit tests for FlashHash#to_session_value.

Put in a compatibility layer to accept FlashHash serializations from Rails 3.0+.

Test that Rails 3.2 session flashes are correctly converted to the new format.

Remove code path for processing Rails 3.0 FlashHashes since they can no longer deserialize.
2012-11-03 15:22:35 +00:00
Daniel Fox, Grant Hutchins & Trace Wax
175ba04cf3 Support :multiple option on input tags with :index
When you have an explicit index set, then when you build an input tag
with :multiple => true, it doesn't add [] to the end of its name, although
it should.
2012-11-02 18:14:04 -04:00
Rafael Mendonça França
974467d70d Add test to avoid regression of 1bfc5b4 2012-11-02 18:16:27 -02:00
Rafael Mendonça França
1bfc5b4068 Revert "Merge pull request #7668 from Draiken/fix_issue_6497"
This reverts commit f4ad0ebe7a6b17658bddfeb996e3c34835b75623, reversing
changes made to 8b2cbb3a832101f0e672ee309beca0f8c555b292.

Conflicts:
	actionpack/CHANGELOG.md

REASON: This added introduced a bug when you have a shorthand route
inside a nested namespace.

See
281367eb77
2012-11-02 14:49:12 -02:00
Nikita Afanasenko
d8c1404107 Fix #8086 (BestStandardsSupport rewrites app X-UA-Compatible header, now appends).
Now `BestStandardsSupport` middleware appends it's `X-UA-Compatible` value to app's value.
Also test for `BestStandardsSupport` middleware added.
2012-11-01 15:15:46 +04:00
Carlos Antonio da Silva
b31ea0c240 Add test to ensure data attributes are properly escaped with tag helpers
Closes #8091
2012-11-01 08:49:47 -02:00
David Heinemeier Hansson
750a30b19f No need for the debugger 2012-10-31 16:35:20 +01:00
David Heinemeier Hansson
954c350daf Allow #permit to take its list of permitted parameters as an array 2012-10-31 16:33:54 +01:00
Guillermo Iguaran
4b20cd9c66 Revert "if format is unknown NullMimeTypeObject is returned"
This reverts commit a8560fa361958b33d76e4468eb5c07d82a20196e.
2012-10-31 10:01:39 -05:00
Angelo capilleri
a8560fa361 if format is unknown NullMimeTypeObject is returned
If a unknown format is passed in a request, the methods html?, xml?, json? ...etc
Nil Exception.

This patch add a class NullMimeTypeObject, that is returned when  request.format is unknown
and it responds false to the methods that ends with '?'.

It refers to #7837, not fixes because it's not considered a improvement not a bug.
2012-10-31 15:07:37 +01:00
Carlos Antonio da Silva
008154e237 Fix failing tests and use new hash style in deprecation messages 2012-10-29 13:57:00 -02:00
Rafael Mendonça França
a4c3d5ae1d Improve the deprecation message of link_to_function and
button_to_function

Point the the Unobtrusive JavaScript secion in the JavaScript guide
2012-10-27 15:40:21 -02:00
Yves Senn
4d7f53379a cleanup, remove trailing whitespace within actionpack 2012-10-27 16:03:18 +02:00
Aaron Patterson
cde326bcef give access to the original exception raised in case of a parse error 2012-10-25 11:34:37 -07:00
Aaron Patterson
facd3e8710 do not lose backtrace information from the raised exception 2012-10-25 11:25:29 -07:00
Vasiliy Ermolovich
3ee6bcfc3d check_box value can be not only an object of Array class
there is a chance that `value` is a Set or an object that reponses to `include?` method so let's handle this case
2012-10-20 22:35:31 +03:00
Steve Klabnik
e22e785451 Add i18n scope to disance_of_time_in_words.
This fixes #733.
2012-10-19 18:35:23 -03:00
Aaron Patterson
b2debfb005 add test for fetch with a block 2012-10-18 15:22:58 -07:00
Aaron Patterson
6ea781c9a7 prefer composition over inheritence 2012-10-18 15:20:30 -07:00
Rafael Mendonça França
11acaa172c Merge pull request #7975 from butcher/extend_date_select_helper_functionality
Extend date_select helper functionality.

Conflicts:
	actionpack/CHANGELOG.md
2012-10-18 14:35:31 -03:00
Pavel Nikitin
a48ef9b879 Extend date_select helper functionality. 2012-10-18 19:21:20 +03:00
Rafael Mendonça França
0c3ca0f013 Permit string and float values in the multiparameter attributes 2012-10-18 00:31:46 -03:00
Aaron Patterson
d410ac5136 use the tmp filesystem rather than our own thing. 2012-10-17 11:30:08 -07:00
Joshua Peek
c4276ddf38 Ignore asset url query string or anchor when appending extensions and computing public path 2012-10-15 13:30:24 -05:00
Joshua Peek
6601917ad9 Extract compute_asset_extname and allow extname to be disabled 2012-10-15 10:57:32 -05:00
Joshua Peek
c800e27ad3 Merge branch 'master' into asset-path-helper
Conflicts:
	railties/test/application/configuration_test.rb
2012-10-15 10:20:50 -05:00
Joshua Peek
3db69909b9 🔥 Rails asset id support 2012-10-15 09:47:16 -05:00
Ayrton De Craene
a0f97e467d Minor cleanup, helper method was only used once 2012-10-15 11:30:54 +02:00
Joshua Peek
60a4fffd83 Allow asset url config to be undefined 2012-10-13 10:13:47 -05:00
Joshua Peek
5dfeb1b852 Add a few more compute_asset_path tests 2012-10-13 09:59:57 -05:00
Joshua Peek
dee3a19274 JAVASCRIPTS_DIR, STYLESHEETS_DIR, ASSETS_DIR don't even exist anymore 2012-10-12 17:09:32 -05:00
Joshua Peek
c3cff4d421 Ensure AssetUrlHelper can be mixed into AC::Base 2012-10-12 17:07:17 -05:00
Joshua Peek
1e2b0ce95e Refactor AssetUrlHelper to make it friendly for plugins and extensions
Add asset_path/url helper for a consolidated entry point
Expose compute_asset_path as a public API
Expose compute_asset_host as a public API
Move RAILS_ASSET_ID to its own module, AssetIdHelper
Removed AV::AssetPaths
2012-10-12 16:56:00 -05:00
Joshua Peek
bd38d9f211 Add asset_path and asset_url helpers 2012-10-12 14:57:38 -05:00
dfens
ab9140ff02 Cleanup trailing whitespaces 2012-10-12 09:56:39 +02:00
Santiago Pastorino
bdd105d8b9 When executing permit with just a key that points to a hash, DO NOT allow all the hash
params.require(:person).permit(:projects_attributes) was returning
=> {"projects_attributes"=>{"0"=>{"name"=>"Project 1"}}}

When should return
=> {}

You should be doing ...
params.require(:person).permit(projects_attributes: :name)
to get just the projects attributes you want to allow
2012-10-12 01:01:26 -02:00
Andy Shipman
2938ef7a65 Allow for deep directory path for view templates. 2012-10-11 17:36:58 +01:00
Yves Senn
ed9567401d recognizes when a partial was rendered twice. Closes #3675 2012-10-11 08:46:49 +02:00
Joshua Peek
607829a364 Remove old asset tag concatenation
Use sprockets, jammit, or some other asset bundler
2012-10-10 10:53:27 -05:00
Alexey Muranov
a94220b66c Rename "Fixtures" class to "FixtureSet"
Rename `ActiveRecord::Fixtures` class to `ActiveRecord::FixtureSet`.  Instances of this class normally hold a collection of fixtures (records) loaded either from a single YAML file, or from a file and a folder with the same name.  This change make the class name singular and makes the class easier to distinguish from the modules like `ActiveRecord::TestFixtures`, which operates on multiple fixture sets, or `DelegatingFixtures`, `::Fixtures`, etc., and from the class `ActiveRecord::Fixture`, which corresponds to a single fixture.
2012-10-07 19:15:58 +02:00
Jeremy Kemper
3f97ee8014 Ruby 2 compat. CGI.escapeHTML has changed the way it escapes apostrophes a few times, so fix up the test to work with however it chooses to escape. 2012-10-06 21:06:10 -07:00
Rafael Mendonça França
d76ef6fa6c Update some code styles.
* Uses the Ruby 1.9 hash syntax
* Avoid escaping " inside string using the %{} syntax
2012-10-06 22:01:32 -03:00
Riley Lynch
6caae0231c Accept :remote as symbol in link_to options
Accept either :remote or 'remote' in both the html_options and
(url_)options hash arguments to link_to.
2012-10-06 17:14:10 -04:00
Yves Senn
af677da84c can't pass :locals to #assert_template without a view test case. Closes #3415
the documentation on #assert_template states that the :locals option is
only available in view test cases:

    # In a view test case, you can also assert that specific locals are passed
    # to partials:

I added a warning when it's passed in an inapropriate context to prevent
a NoMethodError.
2012-10-06 12:23:02 +02:00
Rafael Mendonça França
62aff55706 Allow parameter filters to match multi-parameter attributes
This will make easier to permit date/time attributes generated by
helpers like date_select.

[Sven Schwyn + Rafael Mendonça França]
2012-10-05 18:25:45 -03:00
Brendan Loudermilk
1aa522dc4e ActionController::Parameters#permit! is recursive 2012-10-04 11:51:08 -07:00
Francesco Rodriguez
e4d5b69b57 rename page_cache_extension option to default_static_extension 2012-10-03 15:35:19 -05:00
Francesco Rodriguez
2f81be178f extract AP Page and Action caching to actionpack-deprecated_caching gem 2012-10-03 11:14:28 -05:00
Steve Klabnik
561edbe71f Failsafe exception returns text/plain.
It's best to just return text/plain when something has gone terribly
wrong.

Fixes #5660.
2012-10-01 21:30:21 -07:00
Yves Senn
b30ce03715 resource and resources do no longer modify passed options
this is a patch for #7777.
2012-10-01 15:52:56 +02:00
Steve Klabnik
55eba0affc fix cache store test
Pull #7800 broke the build, this should fix it.
2012-09-30 19:45:43 -07:00
Hugo Roque
19dff78d02 assert_template no more passing with what ever string that matches.
Given Im rendering an template `/layout/hello.html.erb`, assert_template was
passing with any string that matches. This behavior allowed false passing like:

	assert_template "layout"
	assert_template "out/hello"

Now the passing possibilities are:

	assert_template "layout/hello"
	assert_template "hello"

fixing assert_template bug when template matches expected, but not ends with

Cherry Pick Merge: Fixes issue #3849 assert_template false positive

taking redundant test off

prevening incorrect assert_template when rendering with repeated names in path

updating CHANGELOG with bugfix: assert_template false passing
2012-09-29 23:31:49 -03:00
Francesco Rodriguez
9142da09e5 move metal/caching_test into controller/caching_test 2012-09-27 23:10:53 -05:00
Rafael Mendonça França
610cf9da96 remove method redefinition warnings
actionpack/test/template/spec_type_test.rb:32: warning: method redefined; discarding old test_spec_type_wont_match_non_space_characters
actionpack/test/controller/spec_type_test.rb:30: warning: previous definition of test_spec_type_wont_match_non_space_characters was here
2012-09-27 18:44:25 -03:00
Aaron Patterson
8156178894 Merge pull request #7444 from szimek/params_parser_raises_parsing_error
Raise generic ParseError exception when ParamsParser fails parsing request params
2012-09-26 10:55:29 -07:00
Aaron Patterson
59f83153ca fixing most tests on Ruby 2.0 2012-09-25 15:30:22 -07:00
Nihad Abbasov
2b9bce88e1 allow to pass numerical value to size option in image_tag
This will set image's both width and height attributes to
value passed in size option.
2012-09-25 21:47:55 +05:00
Aaron Patterson
c96b20f8d9 Merge pull request #7749 from blowmage/minitest
Improve support for minitest's spec DSL
2012-09-25 09:26:42 -07:00
grosser
9e2948e750 depreacte unused Mime::Type#verify_request? and Mime::Type.browser_generated_types 2012-09-24 17:24:18 -07:00
Mike Moore
64f254ccf7 Register AD::IntegrationTest for minitest's spec DSL 2012-09-24 15:49:40 -06:00
Mike Moore
c0a24555f9 Support helper tests using spec DSL
Improve how helper tests to resolve the helper class from the test name.
Add tests for helper tests using the minitest spec DSL.
2012-09-24 15:37:45 -06:00
Mike Moore
1949d1f6b2 Register helper and view tests for minitest's spec DSL 2012-09-24 14:54:59 -06:00
Mike Moore
b2e5db9c71 Allow strings in the controller test describe blocks
Allow controller tests using the spec DSL to match strings.
Add test coverage for the register_spec_type calls.
2012-09-24 14:21:47 -06:00
Mike Moore
fdc11fd01a Support controller tests using spec DSL - fixes #7743
Add tests for controller tests using the minitest spec DSL.
2012-09-24 14:15:21 -06:00
Xavier Noria
133d42bc0f fixes the suite for uploaded files 2012-09-23 00:50:30 +02:00
Sergio Gil Pérez de la Manga
e9ba548baf Accept parameters in methods delegated to tempfile 2012-09-22 22:37:00 +02:00
Sergio Gil Pérez de la Manga
dab0859741 Delegate ActionDispatch::Http::UploadedFile#close to tempfile 2012-09-20 11:57:38 +02:00
Luiz Felipe
641ea69257 Removing to_shorthand from default_controller_and_action. Fixes #6497
When using shortcut routes inside an engine the "to_shorthand" variable
is set to true, causing the module scope of the route to not be applied.
2012-09-19 08:02:37 -03:00
Philip Arndt
45d6944afa Correct parameter access.
* The params as supplied pass born in authors[0] but not authors[1] so it seems like the test isn't covering what it should be covering.
2012-09-19 13:46:01 +12:00
David Heinemeier Hansson
c49d959e9d Merge pull request #7251 from rails/integrate-strong_parameters
Integrate strong_parameters in Rails 4
2012-09-18 12:33:13 -07:00
Yves Senn
370dcd99b7 log 404 status when ActiveRecord::RecordNotFound was raised (#7646) 2012-09-17 18:16:41 +02:00
Carlos Antonio da Silva
a2194990fa Merge pull request #7669 from guilleiguaran/rename-rb-handler
Rename .rb template handler to .ruby to avoid conflicts with mustache classes
2012-09-17 08:13:08 -07:00
Guillermo Iguaran
de1060f4e0 Rename .rb template handler to .ruby to avoid conflicts with mustache views classes 2012-09-17 10:07:08 -05:00
Tima Maslyuchenko
13b0af736e allowing pass couple extension to register_template_handler call 2012-09-17 17:16:05 +03:00
Guillermo Iguaran
91bcebbdef Support fields_for attributes, which may have numeric symbols as hash keys 2012-09-16 23:58:21 -05:00
Guillermo Iguaran
1aaf4490b2 Add config.action_controller.permit_all_attributes to bypass StrongParameters protection 2012-09-16 23:58:21 -05:00
Guillermo Iguaran
1e1bee3ab9 Change tainted/untainted wording to permitted/forbidden 2012-09-16 23:58:21 -05:00
Guillermo Iguaran
8cfe95d719 Don't use assert_nothing_raised when assert_equal is used 2012-09-16 23:58:21 -05:00
Guillermo Iguaran
b4d9a586bc require abstract_unit in parameters tests 2012-09-16 23:58:20 -05:00
Guillermo Iguaran
8c4de0e67f Remove integration between attr_accessible/protected and AC::Metal::ParamsWrapper 2012-09-16 23:58:20 -05:00
Guillermo Iguaran
885005461b Integrate ActionController::Parameters from StrongParameters gem 2012-09-16 23:58:19 -05:00
Travis Warlick
cd461c3e64 Support for multiple etags in an If-None-Match header
This is a rebased version of #2520.

Conflicts:

	actionpack/test/dispatch/request_test.rb
2012-09-15 15:01:59 +04:00
Michael Koziarski
bb732beba7 Merge pull request #7616 from lest/null-session-forgery-protection
Implement :null_session CSRF protection method
2012-09-13 20:44:45 -07:00
Sergey Nartimov
95be790ece Implement :null_session CSRF protection method
It's further work on CSRF after 245941101b1ea00a9b1af613c20b0ee994a43946.

The :null_session CSRF protection method provide an empty session during
request processing but doesn't reset it completely (as :reset_session
does).
2012-09-13 12:07:37 +03:00
Rafael Mendonça França
d0c25f253f Define a SynchronousQueue for test in Action Pack.
We don't need to rely on rails/queueing in Action Pack tests
2012-09-12 15:33:42 -03:00
Carlos Antonio da Silva
d46c36258b Merge pull request #7612 from arunagw/build_fix_queue
Fix build Rails.queue
2012-09-12 05:00:56 -07:00
Arun Agrawal
a28efd8ac6 Fix build Rails.queue
see 34b23e7110a3a13cf157608cefc9b5701017bf39
2012-09-12 09:50:16 +05:30
Arun Agrawal
84a52c6c7a warning removed.
1. Unused variable
2. possibly useless use of a variable in 
void context
2012-09-12 09:28:14 +05:30
Rafael Mendonça França
db17046bc1 Merge pull request #7594 from guilleiguaran/rb-template-handler
Add .rb template handler
2012-09-10 23:20:12 -07:00
Guillermo Iguaran
ab7ae689e9 Add .rb template handler
This handler simply allows arbitrary Ruby code as a template
2012-09-11 01:17:43 -05:00
Carlos Antonio da Silva
be8685d922 Merge pull request #7513 from kalys/master
ERB::Util.html_escape encodes single quote as #39. Decimal form has better support in old browsers.
2012-09-09 06:57:28 -07:00
Kalys Osmonov
6b2a24c3bd &#39 dates back to SGML when &#x27 was introduced in HTML 4.0 2012-09-09 19:48:32 +06:00
Sam Pohlenz
a79f8bd252 Use internal instance variable naming scheme for mounted URL helper proxies 2012-09-09 16:29:21 +09:30
Francesco Rodriguez
8cbd563edf set default_headers to nil after use it to avoid order dependent tests 2012-09-08 14:51:22 -05:00
Carlos Antonio da Silva
bf27f6b2f7 Merge pull request #7189 from GCorbel/excerpt_with_separation
Add a separator option for the excerpt function.
2012-09-08 05:02:18 -07:00
Guirec Corbel
963c50eca8 Add a separation option for the excerpt function
The separation option enable to keep entire words, lines or anything.
To split by line, like github, we can set the separation option as \n.
To split by word, like google, we can set the separation option as " ".
The radius option represent the number of lines or words we want to
have in the result.
The default behaviour is the same. If we don't set the separation
option, it split the text any where.
2012-09-08 07:24:17 -04:00
Andreas Loupasakis
e282a0a3b7 Add integration tests for reset_session in cookie store 2012-09-08 11:05:04 +03:00
Andreas Loupasakis
207bad422b Add test for clear in ActionDispatch::Request::Session 2012-09-08 11:04:45 +03:00
Santiago Pastorino
35a8920cdd Merge pull request #7552 from guilleiguaran/dalli-session-store
Use Dalli for memcache session store
2012-09-07 06:52:06 -07:00
Bogdan Gusiev
6777f7b75d AS::Callbacks: deprecate monkey patch of object callbacks 2012-09-07 14:42:31 +03:00
Guillermo Iguaran
f6f406696f Dalli doesn't support autoloading of unloaded classes 2012-09-06 18:26:20 -05:00
Arun Agrawal
dd62069991 Let's run action pack tests with Dalli
There is no memcache gem left in repo.
2012-09-06 17:36:50 -05:00
Rafael Mendonça França
d8dee214e3 Use the same logger that ActionView::Base for the Digestor 2012-09-05 13:51:24 -03:00
Rafael Mendonça França
7995c03dc0 Merge pull request #7522 from lexmag/mime_type
Refactor `Mime::Type`
2012-09-04 15:56:29 -07:00
Aleksey Magusev
69723138ad Refactor Mime::Type
`parse` method performance improvements - ~27-33%:

    accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword,  , pronto/1.00.00, sslvpn/1.00.00.00, */*"

    Benchmark.measure{ 1_000_0.times { Mime::Type.parse(accept) }}

    old: 1.430000   0.000000   1.430000 (  1.440977)
    new: 0.920000   0.000000   0.920000 (  0.921813)
2012-09-05 02:49:10 +04:00
Ernie Miller
05136e5c0b Make enhanced routing Concerns more tell-don't-ask 2012-09-03 13:13:17 -04:00
Ernie Miller
eb43d3d1d9 Fix concerns not executing block in mapper
Also, add documentation for alternate usage.
2012-09-03 13:13:16 -04:00
Ernie Miller
4037e31d88 Allow routing concerns to accept a callable
This allows us to make alterations to the generated routes based on the
scope of the current mapper, and otherwise allows us to move larger
blocks of concerns out of the routes file, altogether.
2012-09-03 13:13:16 -04:00
Jon Leighton
ae79c7a201 Revert "Merge pull request #7452 from arunagw/memcached_dalli"
This reverts commit 7256cb53e0c34e510a4d59a50d120c0358cf1d99, reversing
changes made to 6ebe22c3ae716d089af1e5090ddb0d12b31af8ac.

Reason: A test was failing.
2012-08-31 15:54:31 +01:00
Jon Leighton
cd150c96e3 Revert "Add missing require"
This reverts commit e4b33b08d6d2b88b627b1e52c4f349e57c5b89fc.

https://github.com/rails/rails/pull/7452#issuecomment-8094302
2012-08-31 15:54:31 +01:00
kennyj
5225c1a472 Fix build about TemplateDigestorTest. 2012-08-30 23:55:42 +09:00
Christos Zisopoulos
17f2499f04 Digestor can now parse old style hash syntax for render 2012-08-30 13:13:47 +02:00
Christos Zisopoulos
21bad7445b Digestor ignores most whitespace when parsing render invocations 2012-08-30 13:01:25 +02:00
David Heinemeier Hansson
ed5c938fa3 Added controller-level etag additions that will be part of the action etag computation *Jeremy Kemper/DHH* 2012-08-29 15:06:30 -05:00
David Heinemeier Hansson
502d5e24e2 Add automatic template digests to all CacheHelper#cache calls (originally spiked in the cache_digests plugin) *DHH* 2012-08-29 14:23:56 -05:00
schneems
0b6175ac2d Add Missing Keys from Journey on failed URL format
Many named routes have keys that are required to successfully resolve. If a key is left off like this:

    <%= link_to 'user', user_path %>

This will produce an error like this:

    No route matches {:action=>"show", :controller=>"users"}

Since we know that the :id is missing, we can add extra debugging information to the error message.

    No route matches {:action=>"show", :controller=>"users"} missing required keys: [:id]


This will help new and seasoned developers look closer at their parameters. I've also subclassed the routing error to be clear that this error is a result of attempting to generate a url and not because the user is trying to visit a bad url. 

While this may sound trivial this error message is misleading and confuses most developers. The important part isn't what's in the options its's what's missing. Adding this information to the error message will make debugging much more obvious. 

This is the sister pull request of https://github.com/rails/journey/pull/44 which will be required to get they missing keys into the correct error message. 

Example Development Error in Rails: http://cl.ly/image/3S0T0n1T3421
2012-08-28 08:53:45 -07:00
Rafael Mendonça França
e4b33b08d6 Add missing require 2012-08-28 10:12:49 -03:00
Rafael Mendonça França
7256cb53e0 Merge pull request #7452 from arunagw/memcached_dalli
Memcached to dalli for actionpack test.
2012-08-28 05:27:34 -07:00
Piotr Sarnacki
e1ffd82e76 Deprecate AV::RecordIdentifier in controllers
Methods provided by RecordIdentifier are not widely used in controllers
nowadays as they're view specific (this is probably a legacy left after
RJS rendering directly in controllers). However if people still need to
use it, it's trivial to include ActionView::RecordIdentifier by
themselves.
2012-08-28 11:19:37 +02:00
Piotr Sarnacki
f4d493ed7c Fix ActionView::RecordIdentifier to work as a singleton
We extend it with self, but the methods were not working properly were
used directly on module.
2012-08-28 11:19:37 +02:00
Piotr Sarnacki
582a7f4599 Deprecate Template#mime_type 2012-08-28 11:19:36 +02:00
Piotr Sarnacki
dc663dd52c Don't require action_dispatch in ActionView::UrlHelpers
ActionDispatch::Routing::UrlFor was always required in UrlHelpers. This
was changed by splitting previous implementation of UrlHelper into 2
modules: ActionView::Helpers::UrlHelper and
ActionView::Routing::UrlHelper. The former one keeps only basic
implementation of url_for. The latter adds features that allow to use
routes and is only required when url_helpers or mounted_helpers are
required.
2012-08-28 11:19:29 +02:00
Piotr Sarnacki
9b0ac0bc74 Use ActionView::Base.logger instead of AC::Base.logger 2012-08-28 10:51:05 +02:00
Piotr Sarnacki
45efb665f0 Add ActionView::Base.default_formats
default_formats array is used by LookupContext in order to allow
rendering templates when :formats option is not passed. Previously it
was always set to Mime::SET, which created dependency on Action Pack. In
order to remove this dependency, Mime::SET is used only if
ActionController is loaded.
2012-08-28 10:51:04 +02:00
Piotr Sarnacki
7abc0c73bd Deprecate mime types lookup in auto_discovery_link_tag
Automatically handling mime types for things other than :rss and :atom
is not functionality that justifies dependency on Mime::Type from
actionpack.
2012-08-28 10:51:04 +02:00
Piotr Sarnacki
731bb2fe68 Remove stubs from LogSubscriber tests
We can use another way to instantiate ActionView::Base, by passing
renderer as a first option. Thanks to that we can just pass prefixes to
LookupContext instead stubbing them on the controller. This is also good,
because that kind of API is used in Rails code.
2012-08-28 10:51:04 +02:00
Piotr Sarnacki
ba83aa7f03 Move action_controller/vendor/html-scanner to action_view
This is another step in moving Action View's dependencies in Action Pack
to Action View itself. Also, HtmlScanner seems to be better suited for
views rather than controllers.
2012-08-28 10:51:03 +02:00
Piotr Sarnacki
264624049e Move ActionController::RecordIdentifier to ActionView
Since it's more about DOM classes and ids it belongs to Action View
better. What's more, it's more convenient to make it part of Action View
to follow the rule that Action Pack can depend on Action View, but not
the other way round.
2012-08-28 10:51:03 +02:00
Szymon Nowak
fd99bb8926 Make ActionDispatch::ParamsParser::ParseError#original_exception return the original exception. 2012-08-27 23:46:53 +02:00
Arun Agrawal
834a5a9c7e Let's run action pack tests with Dalli
There is no memcache gem left in repo.
2012-08-27 09:46:35 +05:30
Carlos Antonio da Silva
af31cf0672 Create variable only in the test that uses it
Instead of building a Blog::Post instance for every test in form helper
tests, just build it in the test that uses it.
2012-08-25 21:52:24 -03:00
Vasiliy Ermolovich
130fe2b172 correct handling of date selects when using both disabled and discard options
we should take disabled option not only from `html_options` hash but from
`options` hash too like `build_select` method does it. So

datetime_select("post", "updated_at", { :discard_minute => true }, { :disabled => true })
datetime_select("post", "updated_at", :discard_minute => true , :disabled => true)

both these variants work now

closes #7431
2012-08-25 19:02:41 +03:00
Szymon Nowak
b6ba012032 Fix ActionDispatch::ParamsParser::ParseError message for XML and JSON parsers. 2012-08-24 21:55:41 +02:00
Prem Sichanugrist
0ffe19056c Extract ActiveRecord::SessionStore from Rails
This functionality will be available from gem
`active_record-session_store` instead.
2012-08-24 15:24:19 -04:00
Szymon Nowak
d14e2e5a21 Raise generic ParseError exception when ActionDispatch::ParamsParser fails parsing request params. 2012-08-24 18:08:06 +02:00
Sandeep
99322266b8 option_tags coerced to "" instead of nil 2012-08-21 21:59:05 +05:30
Pratik Naik
6a5d1c765f Make sure :via works with mount 2012-08-20 10:25:23 -05:00
tomykaira
503c1c04ad Access @rs only through attr_accessor 2012-08-20 21:47:00 +09:00
Jim Jones
4848bf321b Added X-Content-Type-Options to the header defaults.
With a value of "nosniff", this prevents Internet Explorer from MIME-sniffing a response away from the declared content-type.
2012-08-18 15:29:58 -07:00
Carlos Antonio da Silva
ebb4a3d5be Merge pull request #7244 from lucasuyezu/master
Fix indentation on template errors to consider line number character count.

For instance, when an error is shown, if the related source code snippet has line numbers from, lets say, 8-12, the lines are left aligned, which means the code indent is wrong:

    8: foo
    9: bar
    10: raise
    11: baz
    12: ...

This changes it to right align the source code snippet, so that the indentation is correct:

     8: foo
     9: bar
    10: raise
    11: baz
    12: ...
2012-08-15 09:15:31 -07:00
Rafael Mendonça França
546497d027 Extract common controllers to abstract_unit 2012-08-13 21:43:18 -03:00
Rafael Mendonça França
0dd24728a0 Implementing Routing Concerns
This pattern was introduced as a plugin by @dhh.

The original implementation can be found in
https://github.com/rails/routing_concerns
2012-08-13 21:41:53 -03:00
Lucas Uyezu
6446e84c1a Indentation should consider line number character count. 2012-08-13 18:49:47 -03:00
Aaron Patterson
38a3fed404 push header merge down to a private method so that live responses can have their own header object 2012-08-13 14:20:04 -04:00
Aaron Patterson
8f0541b702 live response headers can be merged with a hash 2012-08-13 13:57:26 -04:00
Evan Tann
1edc7cd78b Add support for start_hour and end_hour options in select_hour helper
Updated documentation to demonstrate start_hour and end_hour options
2012-08-13 12:26:23 -04:00
Carlos Antonio da Silva
a513cc1862 Ensure option_html_attributes does not modify the given option hashes
We can avoid creating extra hashes with #merge, and use #merge! instead.
2012-08-11 14:17:01 -03:00
Carlos Antonio da Silva
e8e8617c39 Simplify html attributes generation for options_for_select
Further simplify the option_html_attributes method after the changes
introduced in dacbcbe55745aa9e5484b10b11f65ccca7db1c54 to not escape the
html options here (since they're going to be escaped down the chain in
content tag).
2012-08-11 14:04:22 -03:00
Rafael Mendonça França
a6e0d8cfcf Merge pull request #7314 from schneems/schneems/form_for_error
Check for Blank Record in form_for
2012-08-10 20:09:21 -07:00
schneems
60b650b18c check for nil or empty record in form_for
if nil or an empty array is passed into form_for you get a horrible error message, this one is much more indicative of what the programmer needs to know to fix the problem.
2012-08-10 22:02:48 -05:00
Piotr Sarnacki
5b3bb61f3f Fix handling SCRIPT_NAME from within mounted engine's
When you mount your application at a path, for example /myapp, server
should set SCRIPT_NAME to /myapp. With such information, rails
application knows that it's mounted at /myapp path and it should generate
routes relative to that path.

Before this patch, rails handled SCRIPT_NAME correctly only for regular
apps, but it failed to do it for mounted engines. The solution was to
hardcode default_url_options[:script_name], which is not the best answer
- it will work only when application is mounted at a fixed path.

This patch fixes the situation by respecting original value of
SCRIPT_NAME when generating application's routes from engine and the
other way round - when you generate engine's routes from application.

This is done by using one of 2 pieces of information in env - current
SCRIPT_NAME or SCRIPT_NAME for a corresponding router. This is because
we have 2 cases to handle:

- generating engine's route from application: in this situation
  SCRIPT_NAME is basically SCRIPT_NAME set by the server and it
  indicates the place where application is mounted, so we can just pass
  it as :original_script_name in url_options. :original_script_name is
  used because if we use :script_name, router will ignore generating
  prefix for engine

- generating application's route from engine: in this situation we
  already lost information about the SCRIPT_NAME that server used. For
  example if application is mounted at /myapp and engine is mounted at
  /blog, at this point SCRIPT_NAME is equal /myapp/blog. Because of that
  we need to keep reference to /myapp SCRIPT_NAME by binding it to the
  current router. Later on we can extract it and use when generating url

Please note that starting from now you *should not* use
default_url_options[:script_name] explicitly if your server already
passes correct SCRIPT_NAME to rack env.

(closes #6933)
2012-08-11 00:21:46 +02:00
brainopia
e157903310 Test actual content of permanent cookie 2012-08-10 09:48:26 +04:00
Aaron Patterson
581a927710 set the controller under test so we no longer need the reset! method 2012-08-09 18:06:13 -07:00
Santiago Pastorino
d8cf713afa Do not mark strip_tags result as html_safe
Thanks to Marek Labos & Nethemba

CVE-2012-3465
2012-08-09 18:51:05 -03:00
Aaron Patterson
c63d17c2be push drawing once to it's own module 2012-08-09 14:50:27 -07:00
Aaron Patterson
1e8c0a29d0 refactor the before_setup hooks to a module 2012-08-09 14:50:26 -07:00
Aaron Patterson
0b29c7bb7b switch callbacks to minitest hooks 2012-08-09 14:50:26 -07:00
Egor Homakov
98c18d0058 some tests 2012-08-09 17:12:11 +03:00
David Heinemeier Hansson
b540f4c1b8 Allow data attributes to be set as a first-level option for form_for, so you can write form_for @record, data: { behavior: 'autosave' } instead of form_for @record, html: { data: { behavior: 'autosave' } } *DHH* 2012-08-08 16:36:46 -05:00
Rafael Mendonça França
5d1528740a Deprecate button_to_function and link_to_function helpers.
We recommend the use of Unobtrusive JavaScript instead. For example:

  link_to "Greeting", "#", :class => "nav_link"

  $(function() {
    $('.nav_link').click(function() {
      // Some complex code

      return false;
    });
  });

or

  link_to "Greeting", '#', onclick: "alert('Hello world!'); return false", class: "nav_link"

for simple cases.

This reverts commit 3acdd652e9fe99481c879c84c5807a84eb9ad724.
2012-08-07 20:57:42 -03:00
David Heinemeier Hansson
666d3fd0c1 Revert "Merge pull request #7033 from kron4eg/master". Not a a fan at all of what this makes ERB files look like.
This reverts commit 46b8bceedd3e47169c50a04c93161424909c75fb, reversing
changes made to 2f58795e783150f2e1b1f6c64e305703f0061129.
2012-08-07 11:44:24 -05:00
Artiom Di
e82ffeaa0a Restoring the '%' trim mode for ERb templates, allowing for a leading percent sign on a line to indicate non-inserted Ruby code. 2012-08-07 12:37:56 +03:00
Prem Sichanugrist
02c9654b9b Do not include application.js if it doesn't exists
Rails were including 'application.js' to the pack when using
`javascript_include_tag :all` even there's no application.js in the
public directory.
2012-08-06 16:45:10 -04:00
Rafael Mendonça França
5edfc46348 Don't use html_escape to test the escaping 2012-08-05 21:21:14 -03:00
Xavier Noria
447b6a4e67 removes usage of Object#in? from the code base (the method remains defined by Active Support)
Selecting which key extensions to include in active_support/rails
made apparent the systematic usage of Object#in? in the code base.
After some discussion in

    5ea6b0df9a

we decided to remove it and use plain Ruby, which seems enough
for this particular idiom.

In this commit the refactor has been made case by case. Sometimes
include? is the natural alternative, others a simple || is the
way you actually spell the condition in your head, others a case
statement seems more appropriate. I have chosen the one I liked
the most in each case.
2012-08-06 00:30:02 +02:00
Andrew White
c5807728d5 Revert "polymorphic_url with an array generates a query string"
Passing options as the last value in an array doesn't work with form_for.
This reverts commit 61c8a4d926343903593a27080216af7e4ed81268.
2012-08-04 19:02:58 +01:00
Andrew White
4059423809 Revert "Refactor passing url options via array for polymorphic_url"
Passing options as the last value in an array doesn't work with form_for.
This reverts commit 6be564c7a087773cb0b51c54396cc190e4f5c983.
2012-08-04 19:02:57 +01:00
Bogdan Gusiev
d89161e7cc Renamed _path_segments to _recall 2012-08-04 14:55:00 +03:00
Andrew White
6be564c7a0 Refactor passing url options via array for polymorphic_url
Rather than keep the url options in record_or_hash_or_array, extract it
and reverse merge with options as it may contain important private keys
like `:routing_type`.

Closes #7259
2012-08-04 11:24:53 +01:00
Romain Tribes
61c8a4d926 polymorphic_url with an array generates a query string
Generating an URL with an array of records is now able to build a query
string if the last item of the array is a hash.
2012-08-04 10:04:05 +02:00
Santiago Pastorino
c8a613b978 Add test select_tag escapes prompt 2012-08-03 10:00:55 -03:00
Aaron Patterson
c391919180 make sure the body finishes rendering before checking response closure 2012-08-03 00:27:39 -04:00
Armand du Plessis
c62abed8ca Collapsed dual checks (one for content headers and one for content) into a single check.
Rails includes a single character body to a head(:no_content) response to work around an old Safari bug where headers were ignored if no body sent.

This patch brings the behavior slightly closer to spec if :no_content/204 is explicity requested via a head only response.

Status comparison done on symbolic and numeric values

Not returning any content when responding with head and limited to a status code that explicitly states no content will be returned - 100..199, 204, 205, 304.
2012-08-02 16:01:08 -07:00
Rafael Mendonça França
6e523766d8 Merge pull request #7240 from steveklabnik/fix_2301
Fix for digest authentication bug - issue #2301 in rails/rails
2012-08-02 13:50:54 -07:00
Xavier Noria
5ea6b0df9a load active_support/core_ext/object/inclusion in active_support/rails 2012-08-02 21:59:22 +02:00
Arthur Smith
b3e2abc4b1 Fix for digest authentication bug - issue #2301 in rails/rails 2012-08-02 15:24:08 -04:00
kennyj
a8d68d89e3 Improve error handling when using partial name with hyphen. Fix #7079 2012-08-03 02:05:47 +09:00
Santiago Pastorino
b6ab441772 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
2012-07-31 22:26:52 -03:00
Aaron Patterson
fa3c4ea6d0 close the response when the response body is set so that normal render calls will work 2012-07-29 21:43:07 -07:00
Aaron Patterson
4509494f70 header hash is duped before being sent up the rack stack 2012-07-29 21:43:07 -07:00
Aaron Patterson
b3d1f5b630 freeze the header object 2012-07-29 21:43:06 -07:00
Aaron Patterson
619e7c8db8 make sure set_response! sets the correct response object 2012-07-29 21:43:06 -07:00
Aaron Patterson
38cfbb8aa7 Controller actions are processed in a separate thread for live
responses.

Processing controller actions in a separate thread allows us to work
around the rack api - we can allow the user to set status and headers,
then block until the first bytes are written.  As soon as the first
bytes are written, the main thread can return the status, headers, and
(essentially) a queue for the body.
2012-07-29 21:43:05 -07:00
Aaron Patterson
06c9e176ca raise exceptions on header set after response committed 2012-07-29 21:43:05 -07:00
Aaron Patterson
01b812672a make sure appropriate headers are set and deleted 2012-07-29 21:43:05 -07:00
Aaron Patterson
af0a9f9eef added live responses which can be written and read in separate threads 2012-07-29 21:43:05 -07:00
Aaron Patterson
a6bdae1c19 flushing output should write to the stream rather than mutating the response object 2012-07-29 17:02:00 -07:00
Aaron Patterson
19e68e9d47 remove dead test 2012-07-29 16:00:50 -07:00