aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/prototype_helper_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Added template lookup responsible to hold all information used in template ↵José Valim2010-03-071-2/+2
| | | | lookup.
* Change AV formats so they can delegate to the controller. Now users (or ↵Carlhuda2010-03-011-0/+1
| | | | plugins) can override details_for_render in their controllers and add appropriate additional details. Now if only they could *do* something with those details...
* AMo #key is now #to_key and CI is probably happysnusnu2010-02-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Obviously #key is a too common name to be included in the AMo interface, #to_key fits better and also relates nicely to #to_param. Thx wycats, koz and josevalim for the suggestion. AR's #to_key implementation now takes customized primary keys into account and there's a testcase for that too. The #to_param AMo lint makes no assumptions on how the method behaves in the presence of composite primary keys. It leaves the decision wether to provide a default, or to raise and thus signal to the user that implementing this method will need his special attention, up to the implementers. All AMo cares about is that #to_param is implemented and returns nil in case of a new_record?. The default CompliantObject used in lint_test provides a naive default implementation that just joins all key attributes with '-'. The #to_key default implementation in lint_test's CompliantObject now returns [id] instead of [1]. This was previously causing the (wrong) tests I added for AR's #to_key implementation to pass. The #to_key tests added with this patch should be better. The CI failure was caused by my lack of knowledge about the test:isolated task. The tests for the record_identifier code in action_controller are using fake non AR models and I forgot to stub the #to_key method over there. This issue didn't come up when running the test task, only test:isolated revealed it. This patch fixes that. All tests pass isolated or not, well, apart from one previously unpended test in action_controller that is unrelated to my patch.
* Adds #key and #to_param to the AMo interfacesnusnu2010-02-191-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces two new methods that every AMo compliant object must implement. Below are the default implementations along with the implied interface contract. # Returns an Enumerable of all (primary) key # attributes or nil if new_record? is true def key new_record? ? nil : [1] end # Returns a string representing the object's key # suitable for use in URLs, or nil if new_record? # is true def to_param key ? key.first.to_s : nil end 1) The #key method Previously rails' record_identifier code, which is used in the #dom_id helper, relied on calling #id on the record to provide a reasonable DOM id. Now with rails3 being all ORM agnostic, it's not safe anymore to assume that every record ever will have an #id as its primary key attribute. Having a #key method available on every AMo object means that #dom_id can be implemented using record.to_model.key # instead of record.id Using this we're able to take composite primary keys into account (e.g. available in datamapper) by implementing #dom_id using a newly added record_key_for_dom_id(record) method. The user can overwrite this method to provide customized versions of the object's key used in #dom_id. Also, dealing with more complex keys that can contain arbitrary strings, means that we need to make sure that we only provide DOM ids that are valid according to the spec. For this reason, this patch sends the key provided through a newly added sanitize_dom_id(candidate_id) method, that makes sure we only produce valid HTML The reason to not just add #dom_id to the AMo interface was that it feels like providing a DOM id should not be a model concern. Adding #dom_id to the AMo interface would force these concern on the model, while it's better left to be implemented in a helper. Now one could say the same is true for #to_param, and actually I think that it doesn't really fit into the model either, but it's used in AR and it's a main part of integrating into the rails router. This is different from #dom_id which is only used in view helpers and can be implemented on top of a semantically more meaningful method like #key. 2) The #to_param method Since the rails router relies on #to_param to be present, AR::Base implements it and returns the id by default, allowing the user to overwrite the method if desired. Now with different ORMs integrating into rails, every ORM railtie needs to implement it's own #to_param implementation while already providing code to be AMo compliant. Since the whole point of AMo compliance seems to be to integrate any ORM seamlessly into rails, it seems fair that all we really need to do as another ORM, is to be AMo compliant. By including #to_param into the official interface, we can make sure that this code can be centralized in the various AMo compliance layers, and not be added separately by every ORM railtie. 3) All specs pass
* Move form_remote_tag and remote_form_for into prototype_legacy_helperJoshua Peek2010-01-301-100/+0
|
* Move button_to_remote and submit_to_remote into prototype_legacy_helperJoshua Peek2010-01-301-18/+0
| | | | plugin
* Move link_to_function and link_to_remote into prototype_legacy_helperJoshua Peek2010-01-301-28/+0
| | | | plugin
* Move periodically_call_remote into prototype_legacy_helper pluginJoshua Peek2010-01-301-12/+0
|
* Move observe_field and observe_form to prototype_legacy_helper pluginJoshua Peek2010-01-301-37/+0
|
* Revert "Merge branch 'rails/master' into ujs"Joshua Peek2010-01-301-0/+193
| | | | | | | | | | | This reverts commit 3aa1ea1ae4baa4a03d03644e798eeb98a4745785, reversing changes made to 2c12a71378d2146c822acb389b00b866f6420ff5. Conflicts: actionpack/lib/action_view/helpers/javascript_helper.rb actionpack/lib/action_view/helpers/url_helper.rb actionpack/test/template/url_helper_test.rb
* Removed all helpers from PrototypeHelper that are implemented in AjaxHelper. ↵Erik St. Martin2010-01-271-193/+0
| | | | Modified tests that extended with PrototypeHelper to now extend using AjaxHelper. AjaxHelper is now included by default in view helper
* Javascript tests expects the old default of escaping HTML, make it so for nowDavid Heinemeier Hansson2010-01-101-0/+5
|
* Got tests to pass with some more changes.Yehuda Katz2009-08-151-0/+4
| | | | | | | | | | | | | | | | * request.formats is much simpler now * For XHRs or Accept headers with a single item, we use the Accept header * For other requests, we use params[:format] or fallback to HTML * This is primarily to work around the fact that browsers provide completely broken Accept headers, so we have to whitelist the few cases we can specifically isolate and treat other requests as coming from the browser * For APIs, we can support single-item Accept headers, which disambiguates from the browsers * Requests to an action that only has an XML template from the browser will no longer find the template. This worked previously because most browsers provide a catch-all */*, but this was mostly accidental behavior. If you want to serve XML, either use the :xml format in links, or explicitly specify the XML template: render "template.xml".
* AMo conversion helperJoshua Peek2009-07-211-4/+8
|
* Define ActiveModel API ComplianceYehuda Katz2009-07-201-3/+5
| | | | | | - Define to_model on AR - Define to_model on ActiveModel::APICompliant - Update test fixtures to be API Compliant - Start using to_model in AP
* Fixes a number of tests that inexplicably didn't fail when we committed the ↵Yehuda Katz + Carl Lerche2009-07-021-3/+3
| | | | original patch
* Move model naming into ActiveModelJoshua Peek2009-06-171-0/+3
|
* Added the :rjs render optionYehuda Katz + Carl Lerche2009-05-211-0/+4
|
* * Add pluggable JSON backends with support for the JSON gem. [rick]rick2009-04-231-8/+8
| | | | | | | | | | | | | | Example: ActiveSupport::JSON.backend = "JSONGem" All internal Rails JSON encoding is now handled by ActiveSupport::JSON.encode(). Use of #to_json is not recommended, as it may clash with other libraries that overwrite it. However, you can recover Rails specific functionality if you really want to use #to_json. gem 'json' ActiveSupport::JSON.backend = "JSONGem" class ActiveRecord::Base alias to_json rails_to_json end
* Temporarily modifies setup to call super directly. This can support more ↵Yehuda Katz and Carl Lerche2009-04-081-0/+1
| | | | T::U runners.
* Begin unifying the interface between ActionController and ActionViewYehuda Katz2009-01-221-1/+1
|
* Implement submit_to_remote as a wrapper around a more generic button_to_remoteTarmo Tänav2008-10-071-3/+3
| | | | | | | Removed the "return false" from submit_to_remote onclick end as button input elements have no default behavior to cancel. Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Allow prototype functions to receive position parameter as a symbol.miloops2008-08-301-0/+2
| | | | | | [#887 state:resolved] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Added button_to_remote helperTarmo Tänav2008-08-291-0/+13
| | | | | | Ticket originally from http://dev.rubyonrails.org/ticket/3641 Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Cache JavaScriptGenerator's helper module set on the templateJoshua Peek2008-08-261-4/+0
|
* Performance: Cache modules that extend the view context for JavaScriptGeneratorJoshua Peek2008-08-251-0/+4
|
* In javascript helpers option[:type] = :synchronous should work as described ↵miloops2008-07-311-0/+6
| | | | | | in docs. Signed-off-by: Michael Koziarski <michael@koziarski.com>
* Prototype helpers should generate Element.insert instead of Insertion.new, ↵miloops2008-07-301-6/+6
| | | | which has been deprecated in Prototype 1.6.
* JavaScriptGenerator should only sets output_buffer for the duration of the ↵Jeremy Kemper2008-07-151-1/+5
| | | | update block
* Get buffer for fragment cache from template's @output_bufferJoshua Peek2008-07-151-1/+1
|
* Changed PrototypeHelper#submit_to_remote to PrototypeHelper#button_to_remote ↵David Heinemeier Hansson2008-07-091-2/+2
| | | | to stay consistent with link_to_remote (submit_to_remote still works as an alias) (clemens) [#8994 status:closed]
* Check whether blocks are called from erb using a special __in_erb_template ↵Jeremy Kemper2008-06-191-68/+69
| | | | variable visible in block binding.
* Use output_buffer reader and writer methods exclusively instead of hitting ↵Jeremy Kemper2008-06-081-13/+7
| | | | the instance variable so others can override the methods.
* Merge branch 'master' into erboutJeremy Kemper2008-06-051-0/+5
|\
| * Add RJS#page.reload. [#277 state:resolved]Sean Huber2008-06-041-0/+5
| | | | | | | | Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* | Work with @output_buffer instead of _erboutJeremy Kemper2008-06-021-13/+13
|/
* Remove superfluous tests directiveJeremy Kemper2008-05-261-2/+0
|
* Ensure observe_field encodes value parameter. [#216 state:resolved]Frederick Cheung2008-05-191-2/+2
| | | | Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Fix remote_function to escape apostrophes inside the remote url passed to ↵Andre Arko2008-05-131-0/+5
| | | | | | Ajax.Update. [#180 state:resolved] Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Introduce ActionView::TestCase for testing view helpers.Joshua Peek2008-04-191-37/+19
|
* Ensure RJS redirect_to doesn't html-escapes string argument. Closes #8546Pratik Naik2008-04-021-0/+2
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9212 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* require abstract_unit directly since test is in load pathJeremy Kemper2008-01-051-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8564 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Don't escape forward slashes with String#to_json, our unicode encoding of < ↵Michael Koziarski2007-12-021-10/+10
| | | | | | and > prevent the XSS problems. [tpope] Closes #10273 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8255 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Change JSON to encode %w(< > &) as 4 digit hex codes to be in compliance ↵Rick Olson2007-10-291-9/+9
| | | | | | with the JSON spec. Closes #9975 [josh, chuyeow, tpope] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8050 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Update tests for ActiveSupport's JSON escaping change. [rick]Rick Olson2007-10-261-10/+10
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8034 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Allow ability to disable request forgery protection, disable it in test mode ↵Rick Olson2007-09-281-0/+4
| | | | | | by default. Closes #9693 [lifofifo] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7668 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed spelling errors (closes #9706) [tarmo/rmm5t]David Heinemeier Hansson2007-09-281-8/+8
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7666 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Merge csrf_killer plugin into rails. Adds RequestForgeryProtection model ↵Rick Olson2007-09-231-0/+5
| | | | | | that verifies session-specific _tokens for non-GET requests. [Rick] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7592 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Tidy up link to remote options. Closes #9505. [nik.wakelin]Michael Koziarski2007-09-121-0/+5
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7468 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Add array support to remote_form_for for polymorphic urls. Closes #8654 [jade]Michael Koziarski2007-09-021-13/+43
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7400 5ecf4fe2-1ee6-0310-87b1-e25e094e27de