Commit Graph

309 Commits

Author SHA1 Message Date
Carlos Antonio da Silva
a50ab21cd1 Use 1.8 hash style in xml serialization test 2012-11-30 11:29:41 -02:00
Rafael Mendonça França
e8c360527d Merge pull request #8352 from steveklabnik/update_7858
Specify type of singular assication during serialization
Conflicts:
	activemodel/CHANGELOG.md
	activemodel/test/cases/serializers/xml_serialization_test.rb
2012-11-29 13:41:38 -02:00
Jeremy Kemper
4b1a7bcc4c Merge pull request #8038 from frodsan/fix_am_serializers_xml_dependency
Fix AM::Serializers::Xml dependency
2012-10-27 12:56:28 -02:00
Carlos Antonio da Silva
d65adc7425 Update Active Model xml serialization test to reflect a change in builder
Due to a change in builder, nil values and empty strings now generates
closed tags, so instead of this:

    <pseudonyms nil=\"true\"></pseudonyms>

It generates this:

    <pseudonyms nil=\"true\"/>

Document this change in Rails so that people can track it down easily if
necessary.

Conflicts:
	activemodel/CHANGELOG.md
2012-09-07 13:18:23 -03:00
Rafael Mendonça França
089371ac23 validates_inclusion_of and validates_exclusion_of now accept
`:within` option as alias of `:in` as documented.

Fix #7118
2012-07-20 14:19:26 -03:00
Francesco Rodríguez
eed1cfe058 Fix build 2012-06-12 17:10:10 -05:00
Angelo capilleri
b97e0a1127 Fix the the backport of the object dup with the ruby 1.9.3p194.
At the end of initialize_dup was added the call to super if it exists,
so it also works with 1.8.7 where initialize_dup doesn't exist.
This issu was introduced with the pull request #6324
2012-06-12 18:04:44 +02:00
Tsutomu Kuroda
029936efbe Fix human attribute_name to handle deeply nested attributes
This is a back-port of b0e2fc84 to Rails 3.2.
See #5843 and #3859 also.
2012-06-06 12:50:09 +09:00
Angelo capilleri
396e383286 clean the errors if an object that includes validations errors is duped,for 3-2-stable
It Fixes #5953 in 3-2-stable, it's the same pull request of #6284
2012-05-15 18:20:53 +02:00
Aaron Patterson
96d81e5df4 test against ruby features in order to fix tests on Ruby 2.0 2012-04-12 17:12:52 +05:30
José Valim
a1b9acb72e Merge pull request #5049 from fabioyamate/master
Fix sanitize_for_mass_assigment when role is nil
2012-02-15 14:24:35 +01:00
Carlos Antonio da Silva
91f8cf2264 Generate strict validation error messages with attribute name
Backported from master.
2012-02-01 11:55:07 -02:00
Paweł Kondzior
7021184f9c Fix ActiveModel::Errors#dup
Since ActiveModel::Errors instance keeps all error messages as hash
we should duplicate this object as well.

Previously ActiveModel::Errors was a subclass of ActiveSupport::OrderedHash,
which results in different behavior on dup, this may result in regression for
people relying on it.

Because Rails 3.2 stills supports Ruby 1.8.7 in order to properly fix this
regression we need to backport #initialize_dup.
2012-01-16 23:56:55 -08:00
Piotr Sarnacki
90aae070ed Apparently asssert_empty is not available in 1.8.7 2012-01-16 18:28:01 +01:00
Piotr Sarnacki
3430647434 Add ActiveModel::Errors#delete, which was not available after move to use delegation 2012-01-16 17:24:08 +01:00
Piotr Sarnacki
dee595ce04 Fix stack level too deep when model does not have attributes method.
Without that patch when using ActiveModel::AttributeMethods
in a class that does not respond to `attributes` method,
stack level too deep error will be raised on non existing
method. While documentation is clear that you need to define
`attributes` method in order to use AttributeMethods module,
`stack level too deep` is rather obscure and hard to debug,
therefore we should try to not break `method_missing` if
someone forgets about defining `attributes`.
2012-01-15 16:01:05 +01:00
Arun Agrawal
4fac64b1cc Fixed test "ArgumentError: wrong number of arguments(1 for 0)" 2011-12-17 16:49:01 +05:30
Antonio Roberto
66e747b461 Fixed bug when error message is an empty string. 2011-12-16 17:17:14 -02:00
José Valim
7280787a53 Improve cache on route_key lookup. 2011-12-08 19:53:16 +01:00
Marc-Andre Lafortune
d834755dad ActiveModel::Name#i18n_key: Fix doc and add tests 2011-12-05 22:02:53 -05:00
José Valim
d4964b3386 Namespaced attribute lookup now works as 'model/association.attribute'. 2011-12-05 15:39:41 +01:00
José Valim
2985151000 Merge pull request #3859 from kuroda/human_attribute_name
Fix human_attribute_name to handle names with dots
2011-12-05 06:09:33 -08:00
Tsutomu Kuroda
dff19f7be2 Fix human_attribute_name to handle names with dots
Nested I18n namespace lookup under activerecord.models is deprecated now (c19bd4f).
But when a model uses accepts_nested_attributes_for, its Errors object can have
an attribute name with "addresses.street" style. In this case, the dots should be
substituted with slashes so that we can provide the translation under the
"activemodel.attributes.person.addresses/street" key.
2011-12-05 22:57:47 +09:00
José Valim
5b2eb64ceb Revert "Implement ArraySerializer and move old serialization API to a new namespace."
This reverts commit 8896b4fdc8.

Conflicts:

	activemodel/lib/active_model.rb
	activemodel/lib/active_model/serializable.rb
	activemodel/lib/active_model/serializer.rb
	activemodel/test/cases/serializer_test.rb
2011-11-30 18:48:17 +01:00
lest
6ce924fa9f fix method redefined warning in activemodel 2011-11-30 18:57:17 +03:00
Jon Leighton
8df787d428 Deprecated define_attr_method in ActiveModel::AttributeMethods
This only existed to support methods like `set_table_name` in Active
Record, which are themselves being deprecated.
2011-11-29 20:13:37 +00:00
Arun Agrawal
9817a8b7d6 Warning removed unused variable 2011-11-26 19:30:11 +05:30
José Valim
0a4035b12a Revert the serializers API as other alternatives are now also under discussion 2011-11-25 19:29:39 +00:00
José Valim
fcacc6986a Merge branch 'serializers'
This implements the ActiveModel::Serializer object. Includes code, tests, generators and guides.

From José and Yehuda with love.

Conflicts:
	railties/CHANGELOG.md
2011-11-25 09:59:35 +00:00
Jakub Kuźma
dc39af0a9a make ActiveModel::Name fail gracefully with anonymous classes 2011-11-24 15:50:21 +01:00
José Valim
28bcda4098 Rename UserSerializer to DefaultUserSerializer in tests. 2011-11-23 23:53:20 +00:00
José Valim
7fcc8c0a1f Rely solely on active_model_serializer and remove the fancy constant lookup. 2011-11-23 23:45:27 +00:00
José Valim
8896b4fdc8 Implement ArraySerializer and move old serialization API to a new namespace.
The following constants were renamed:

  ActiveModel::Serialization     => ActiveModel::Serializable
  ActiveModel::Serializers::JSON => ActiveModel::Serializable::JSON
  ActiveModel::Serializers::Xml  => ActiveModel::Serializable::XML

The main motivation for such a change is that `ActiveModel::Serializers::JSON`
was not actually a serializer, but a module that when included allows the target to be serializable to JSON.

With such changes, we were able to clean up the namespace to add true serializers as the ArraySerializer.
2011-11-23 23:18:15 +00:00
José Valim
e62de52aa3 Merge branch 'master' into serializers 2011-11-23 20:43:06 +00:00
José Valim
fd86a1b6b0 Rely on a public contract between railties instead of accessing railtie methods directly. 2011-11-23 19:06:45 +00:00
Prem Sichanugrist
0e2156d334 Update variable's name in the test case to reflect the class we're testing 2011-11-18 11:51:05 -05:00
Jon Leighton
f140445b1d Revert "Merge pull request #2378 from cesario/remove_warnings_activemodel"
This reverts commit 6aaae3de27, reversing
changes made to fdbc4e5f4e.

Reason: build failure.
2011-11-05 17:21:58 +00:00
Vijay Dev
6aaae3de27 Merge pull request #2378 from cesario/remove_warnings_activemodel
Remove warnings by calling remove_method
2011-11-05 08:44:16 -07:00
Martin Svalin
c9ca86c29d New #added? method on ActiveModel::Errors
The #added? method makes it possible to check if a specific error has been added, using the same parameters as for #add.
2011-10-19 21:29:20 +02:00
Vijay Dev
8dffc62a9b use variables from test setup 2011-10-17 19:15:24 +05:30
Martin Svalin
180d4137ca ActiveModel::Errors#generate_message without i18n_scope, and more test cases for #add 2011-10-17 09:22:08 +02:00
Jose and Yehuda
afd7140b66 Remove 1.9 Hash syntax - tests passing on 1.8.7 2011-10-15 22:33:58 +02:00
Jose and Yehuda
2abb2e617a Add initial support for embed API 2011-10-15 19:22:16 +02:00
Jose and Yehuda
a230f040ff Add support for the root attribute 2011-10-15 18:56:47 +02:00
Jose and Yehuda
7a28498b55 Fix nil has_one association 2011-10-15 18:40:38 +02:00
Jose and Yehuda
322f47898e Add association_ids 2011-10-15 18:40:38 +02:00
Jose and Yehuda
22c322f056 Add support for overriding associations, mostly used for authorization 2011-10-15 18:40:38 +02:00
Jose and Yehuda
776da539d7 Add support for implicit serializers 2011-10-15 18:40:38 +02:00
Jose and Yehuda
2a4aaae72a Added has_one and has_many 2011-10-15 18:40:37 +02:00
Jose and Yehuda
e407dfb9bf Don't require serializable_hash to take options. 2011-10-15 18:40:37 +02:00