Commit Graph

856 Commits

Author SHA1 Message Date
Carlhuda
47fe14bfcc Silence test deprecation warnings 2010-02-26 15:34:12 -08:00
Carlhuda
226dfc2681 WIP: Remove the global router 2010-02-25 17:53:00 -08:00
Santiago Pastorino
f76eaa4b7c add time_separator for minutes only if minutes aren't hidden
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-02-25 08:31:02 -08:00
Carlhuda
24ab5665b2 Revert "Fix test load paths for those not using bundler"
This reverts commit eec2d301d4.

This commit broke tests. You cannot have a file called "bundler" on the load path.
2010-02-23 17:31:17 -08:00
José Valim
250c809246 Require persisted? in ActiveModel::Lint and remove new_record? and destroyed? methods. ActionPack does not care if the resource is new or if it was destroyed, it cares only if it's persisted somewhere or not. 2010-02-21 11:12:14 +01:00
snusnu
f81c6bc040 AMo #key is now #to_key and CI is probably happy
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.
2010-02-20 20:17:29 -08:00
snusnu
9acd686753 Adds #key and #to_param to the AMo interface
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
2010-02-19 23:31:25 -08:00
Yehuda Katz
bf8898b49b Revert "i18n translate with arrays issue solved"
This reverts commit e7055e5b08.
2010-02-19 15:05:46 -08:00
Santiago Pastorino
e7055e5b08 i18n translate with arrays issue solved 2010-02-19 13:59:15 -08:00
Santiago Pastorino
af05420d6b i18n translate with arrays issue solved
Signed-off-by: Yehuda Katz <yehudakatz@YK.local>
2010-02-18 16:41:00 -08:00
José Valim
3f948a0e29 Merge master. 2010-02-17 00:48:04 +01:00
Prem Sichanugrist
f0523f72b4 Rename Rails::Subscriber to Rails::LogSubscriber 2010-02-16 22:36:15 +01:00
Joshua Peek
eec2d301d4 Fix test load paths for those not using bundler 2010-02-15 10:20:11 -06:00
Bruno Michel
f86421fb28 content_tag should escape its input
Signed-off-by: Yehuda Katz <yehudakatz@YK.local>
2010-02-14 12:03:28 -08:00
David Heinemeier Hansson
d68f8ba5c3 simple_format returns a safe buffer escaping unsafe input [Santiago Pastorino] 2010-02-12 17:24:04 -08:00
Gabriel Mansour
b235af702a Fix pluralization for numbers formatted like '1.00'
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-02-07 12:12:09 -08:00
José Valim
de69c798db Fix nested attributes with specified collection. 2010-02-07 13:45:47 +01:00
José Valim
95eadb39bd Configuration values should be on AV::Base. 2010-02-02 11:32:28 +01:00
Prem Sichanugrist
c01014ac1c Modify the behavior of radio_button_tag to use sanitize_to_id for consistency [#1792 status:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-02-02 10:17:26 +01:00
Santiago Pastorino
1adfb92135 Deleted all references to ActionView::SafeBuffer in favor of ActiveSupport::SafeBuffer
Signed-off-by: Yehuda Katz <wycats@Yehuda-Katz.local>
2010-01-31 22:14:18 -08:00
Yehuda Katz
4cbb9db0a5 For performance reasons, you can no longer call html_safe! on Strings. Instead, all Strings are always not html_safe?. Instead, you can get a SafeBuffer from a String by calling #html_safe, which will SafeBuffer.new(self).
* Additionally, instead of doing concat("</form>".html_safe), you can do
    safe_concat("</form>"), which will skip both the flag set, and the flag
    check.
  * For the first pass, I converted virtually all #html_safe!s to #html_safe,
    and the tests pass. A further optimization would be to try to use
    #safe_concat as much as possible, reducing the performance impact if
    we know up front that a String is safe.
2010-01-31 19:39:13 -08:00
Erik St. Martin
e1618b9ac3 data-remote needs to be on the form and not the submit when using button_to :remote=>true 2010-01-31 14:43:07 -06:00
Stephen St. Martin
a9e89e82b6 add :remote option to form_tag 2010-01-31 13:46:33 -06:00
Stephen St. Martin
a3349f845f form_for should pass :remote to form_tag through html_options 2010-01-31 13:46:27 -06:00
Mikel Lindsaar
2ebea1c02d deOMGifying Railties, Active Support, and Action Pack 2010-01-31 09:46:30 -08:00
Joshua Peek
48459c8278 Add rel=nofollow on non get remote links 2010-01-30 20:26:30 -06:00
Joshua Peek
31820b9dd6 Generate UJS code for :disable_with 2010-01-30 20:22:15 -06:00
Erik St. Martin
392817cf11 updating link_to and button_to to support :remote => true and other options such as :confirm in a unobtrusive manor
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2010-01-30 19:44:35 -06:00
Joshua Peek
7d9ed8eec1 Include prototype ujs adapter with new apps 2010-01-30 19:20:49 -06:00
Joshua Peek
9c2c307ee4 Move form_remote_tag and remote_form_for into prototype_legacy_helper 2010-01-30 15:42:30 -06:00
Joshua Peek
779094a602 Move button_to_remote and submit_to_remote into prototype_legacy_helper
plugin
2010-01-30 15:28:31 -06:00
Joshua Peek
b3787643ec Move link_to_function and link_to_remote into prototype_legacy_helper
plugin
2010-01-30 15:20:00 -06:00
Joshua Peek
2de311a093 Drop AjaxHelper 2010-01-30 15:08:29 -06:00
Joshua Peek
95f317b020 Move periodically_call_remote into prototype_legacy_helper plugin 2010-01-30 15:01:02 -06:00
Joshua Peek
61c9b16487 Move observe_field and observe_form to prototype_legacy_helper plugin 2010-01-30 14:53:43 -06:00
Joshua Peek
4f7a85d2c6 Revert "Merge branch 'rails/master' into ujs"
This reverts commit 3aa1ea1ae4, reversing
changes made to 2c12a71378.

Conflicts:

	actionpack/lib/action_view/helpers/javascript_helper.rb
	actionpack/lib/action_view/helpers/url_helper.rb
	actionpack/test/template/url_helper_test.rb
2010-01-30 14:39:59 -06:00
Joshua Peek
ffc10731c3 Revert "fixed tests to also look for rails.js when using javascript_include_tag :defaults"
This reverts commit 7f181e4750.
2010-01-30 14:39:59 -06:00
Joshua Peek
bddd1bb626 Deprecate link_to :popup 2010-01-29 20:00:55 -06:00
Erik St. Martin
7f181e4750 fixed tests to also look for rails.js when using javascript_include_tag :defaults 2010-01-29 16:33:27 -06:00
Stefan Penner
2e338aed70 updated tests + docs, plus minor inconsistency fixes 2010-01-27 12:44:36 -06:00
Stefan Penner
1b8ced53c4 Added regression tests that discovered the previous issue. 2010-01-27 12:44:35 -06:00
Erik St. Martin
c0f63883ea :href should be comming in through html_options and not options 2010-01-27 12:44:35 -06:00
Erik St. Martin
f661a3bc59 removing container inline js function of observed elements :function callback 2010-01-27 12:44:35 -06:00
Erik St. Martin
0215466832 periodically_call_remote does not need data-observe=true 2010-01-27 12:44:35 -06:00
Erik St. Martin
ad26b3934e test to go with last commit, explicit :href for link_to_remote 2010-01-27 12:44:35 -06:00
Stephen St. Martin
8b7cd5ae7e fix duplidate data-submit attribute, submit_to_remote should test url 2010-01-27 12:44:34 -06:00
Erik St. Martin
44542bd7da account for the fact a few options may be passed as symbols and need to be converted to string 2010-01-27 12:44:34 -06:00
Erik St. Martin
06dd23d671 removing Prototype inline js for attributes for :with and :condition, it now is free form js that can be placed there, also moved :submit out into AjaxHelper, updated tests to reflect changes 2010-01-27 12:44:34 -06:00
Stephen St. Martin
a5e9d033e8 add missing test for :with option to link_to_remote 2010-01-27 12:44:33 -06:00
Stephen St. Martin
133f6011d0 add missing :before and :after callbacks for link_to_remote 2010-01-27 12:44:33 -06:00