Commit Graph

1470 Commits

Author SHA1 Message Date
Gaurish Sharma 90c450f6cd Avoid Skip in test, have a unified test for order 2013-08-09 15:27:21 +05:30
Gaurish Sharma 9f8116fb77 Add tests for ActiveModel::Serializers::JSON#as_json ordering 2013-08-09 04:32:00 +05:30
Ryoji Yoshioka 23ef1dfd70 Fix: documentation for ActiveModel::Errors 2013-08-05 18:58:22 +09:00
Max Shytikov af1e3b7c48 fix tests 2013-07-30 20:03:57 +03:00
Arun Agrawal f52832de2a grab executable from rubygems
As done here d7fc97d3f9
2013-07-26 11:07:25 +02:00
Vladimir Kiselev 3be0cdfa55 Fix secure_password password_confirmation validations 2013-07-24 03:14:15 +04:00
Burkhard Vogel-Kreykenbohm ad62cf68f8 bcrypt-ruby stable is 3.1 2013-07-17 16:39:07 +02:00
John Gesimondo 0e945f8909 it's xml, not json
change docs for xml serializer to talk about xml
2013-07-13 16:25:04 -07:00
Ankit Gupta-FIR 6a71d09ad2 Replaced older rocket sign to new : 2013-07-04 17:25:50 +01:00
Aaron Patterson 09b31f08d4 eagerly initialize the attributes module to avoid check-then-set race conditions 2013-07-02 14:34:40 -07:00
Aaron Patterson 4c88f4ce16 remove wrong documentation from a :nodoc:'d method 2013-07-02 14:04:40 -07:00
Aaron Patterson d094aaad19 the data structure used to store attribute aliases should not be exposed 2013-07-01 16:23:08 -07:00
Vipul A M 404a61e19c Remove redundant escapes from xml serialization test 2013-07-01 10:17:33 +05:30
Steven Yang 6e583cdac3 fix typo in ActiveModel::Error docs [ci skip] 2013-06-30 18:38:29 -03:00
Steven Yang 5fe43ffcfb remove evals from AM::Validations::Callbacks
follow the same refactor at a63a964a5d
2013-06-30 18:47:55 +08:00
Steven Yang e8fe6660d2 provide a more sementicthe local variables name for ActiveModel::Validations::Clusivity#include? method
the original name `exclusion` is a bit confusing when using with the method `inclusion_method`
rename it to a more logic neutral name.
2013-06-29 18:36:40 +08:00
Paul Nikitochkin e63ba910ae Remove deprecation warning from AttributeMethodsMatcher 2013-06-28 00:16:42 +03:00
Łukasz Strzałkowski 468939297d Remove deprecated attr_protected/accessible
Rails 4.0 has removed attr_protected and attr_accessible feature in favor of Strong Parameters.
2013-06-27 20:38:30 +02:00
Carlos Antonio da Silva 48ab2c06e0 Merge pull request #11054 from senny/11048_make_default_value_explicit
make default value for `:message` on `AM::Errors` explicit.
2013-06-27 05:16:38 -07:00
Carlos Antonio da Silva 61346d1b42 Merge pull request #10774 from chuckbergeron/validates-inclusion-of-accuracy-for-non-numeric-ranges
Greater accuracy for validates_inclusion_of on non-numeric ranges

Closes #10774, fixes #10593
2013-06-25 21:48:41 -03:00
Akshay Khole 444d3412b9 Fixing Issue #11083
Removing other occurrences of `the` appearing twice
2013-06-25 16:47:29 +05:30
Rajarshi Das cbd4a2e317 replace all older rocket sign to new ":" from examples of active record and active models 2013-06-24 11:19:51 +05:30
José Valim e1f4f64434 Revert "Merge pull request #11053 from yangchenyun/mine"
Those two files are required by active_support/rails.rb
loaded in active_model.rb

It is common to require common dependencies on the root
files to avoid boilerplate in each file.

This reverts commit 763635e30f, reversing
changes made to 4f46ef36aa.
2013-06-22 18:36:26 +02:00
Yves Senn ca99ab2481 make default value for `:message` on `AM::Errors` explicit. 2013-06-22 13:48:42 +02:00
Yves Senn 763635e30f Merge pull request #11053 from yangchenyun/mine
Add explicit dependencies of ActiveSupport to enable independent usage of ActiveModel::Name
2013-06-22 03:32:15 -07:00
Steven Yang c20b5ca037 add explicit AS dependencies for ActiveModel::Naming
There are two missing ActiveSupport dependencies to use ActiveModel::Name class or ActiveModel::Naming module independently.

Missing dependencies for Module#delegate defined in `active_support/core_ext/module/delegation`, used at [L148](https://github.com/rails/rails/blob/master/activemodel/lib/active_model/naming.rb#L148)

Missing dependencies for Object#blank? defined in `active_support/core_ext/object/blank`, used at [L131](https://github.com/rails/rails/blob/master/activemodel/lib/active_model/naming.rb#L131)
2013-06-22 18:24:29 +08:00
Arun Agrawal 67f668845e Saying gemcutter => rubygems [ci skip] 2013-06-21 11:04:52 +02:00
Fred Wu 85750d43fa ActiveModel::Model inclusion chain backward compatibility 2013-06-20 12:16:17 +10:00
Fred Wu 0b502cb879 Fixes AciveModel::Model with no ancestors, fixes #11004
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2013-06-19 17:16:04 +02:00
Fred Wu e3dc10f133 Fixed ActiveModel::Model's inclusion chain 2013-06-19 11:25:10 +10:00
Aaron Patterson 47617ecdf7 expose a few attribute changed methods 2013-06-11 13:39:46 -07:00
Aaron Patterson a63a964a5d remove some evals from callback conditionals 2013-06-11 10:20:29 -07:00
Daichi Arai d61241b060 fix ActiveModel::Validations.validators_on doc 2013-06-10 18:34:34 +09:00
Carlos Antonio da Silva 94725b81f5 Merge pull request #10860 from ka8725/activemodel_log
Ignore activemodel/log/ folder
2013-06-07 05:27:29 -07:00
Richard Livsey 9906eb1355 Docfix: Use public interface instead of setting instance variables
Dynamically setting instance variables based on user input probably isn't a great idea. Better to go through the setter methods provided by attr_accessor.
2013-06-07 12:41:05 +02:00
Andrey Koleshko 120f6e07f6 Stub logger for tests 2013-06-06 19:47:57 +03:00
Arun Agrawal a84a08ecea No need to load 'rake/packagetask' as it's already
in 'rubygems/package_task'
2013-06-02 20:41:21 +02:00
Phil Calvin 5d93ef8f45 Fix regression in has_secure_password.
If the confirmation was blank, but the password wasn't, it would still save.
2013-05-30 11:18:43 -07:00
Charles Bergeron 0317b93c17 Use Range#cover? for Numeric ranges (tests via endpoints) and use Range#include? for non-numeric ranges
added changelog message
2013-05-27 23:54:25 -07:00
William Myers 0e655873d4 DirtyModel uses a hash to keep track of any changes made to attributes
of an instance. When using the attribute_will_change! method, you must
supply a string and not a symbol or the *_changed? method will break
(because it is looking for the attribute name as a string in the keys
of the underlying hash). To remedy this, I simply made the underlying
hash a HashWithIndifferentAccess so it won't matter if you supply
the attribute name as a symbol or string to attribute_will_change!.
2013-05-27 23:41:26 -04:00
Nick Sutterer 7d84c3a2f7 deprecate Validator#setup (to get rid of a respond_to call). validators do their setup in their constructor now. 2013-05-23 10:00:44 -03:00
Aaron Patterson 9fef7c8dc9 Merge pull request #10527 from zenspider/squishy_minitest5
Squishy minitest5
2013-05-16 13:41:54 -07:00
Aaron Patterson ba55276434 deprecating string based terminators 2013-05-14 16:03:09 -07:00
Aaron Patterson d53b5f0739 Merge branch 'master' into normalizecb
* master: (61 commits)
  add tests for reset_calbacks
  Fixing build broken by this change
  Extract variable out of loop
  Updated comment to Rails 4
  Fixes NoMethodError: `alias_method_chain` when requiring just active_support/core_ext
  better error message when app name is not passed in `rails new`
  Code cleanup for ActionDispatch::Flash#call
  Fix typo: require -> requires
  Add CHANGELOG entry for #10576
  Merge pull request #10556 from Empact/deprecate-schema-statements-distinct
  Some editorial changes on the documentation.
  respond_to -> respond to in a message from AM::Lint
  specify that dom_(id|class) are deprecated in controllers, views are fine
  copy edits [ci skip]
  Fix class and method name typos
  Replace multi_json with json
  ruby -> Ruby
  Adding documentation to the automatic inverse_of finder.
  Improve CHANGELOG entry [ci kip]
  Call assume_migrated_upto_version on connection
  ...

Conflicts:
	activesupport/lib/active_support/callbacks.rb
2013-05-13 11:51:10 -07:00
Xavier Noria 19c6c8f5d7 respond_to -> respond to in a message from AM::Lint
The error message uses English to say that the object should respond
to a certain method. You check that with respond_to, but that's not
English.

This makes this error message also consistent with the rest.
2013-05-12 13:59:51 +02:00
Aaron Patterson 23122ab2d4 callbacks are wrapped with lambdas 2013-05-10 10:13:21 -07:00
wangjohn eb93d16e49 Using define method instead of class eval when defining model callbacks.
Based on my benchmark results, this change improves performance
substantially when defining callbacks.

This benchmark (https://gist.github.com/wangjohn/5542610) was run using
the current master and also using my experimental branch which replaced
class_eval with define_single_method.

Using class_eval (current master):

                    user     system      total        real
10 trials       0.000000   0.000000   0.000000 (  0.001568)
50 trials       0.020000   0.000000   0.020000 (  0.021715)
500 trials      0.110000   0.000000   0.110000 (  0.115357)
1000 trials     0.250000   0.000000   0.250000 (  0.260025)
10000 trials    2.560000   0.000000   2.560000 (  2.568408)
50000 trials   12.800000   0.010000  12.810000 ( 12.886871)

Using define_single_method (experimental branch):

                    user     system      total        real
10 trials       0.000000   0.000000   0.000000 (  0.000790)
50 trials       0.000000   0.000000   0.000000 (  0.002960)
500 trials      0.050000   0.010000   0.060000 (  0.055690)
1000 trials     0.100000   0.000000   0.100000 (  0.094073)
10000 trials    0.890000   0.000000   0.890000 (  0.900364)
50000 trials    4.650000   0.000000   4.650000 (  4.686127)
2013-05-08 13:47:56 -04:00
Ryan Davis 3073c53198 Updates to make rails 4 happy with minitest 5:
+ Namespace changes, overhaul of runners.
+ Internal ivar name changes
- Removed a logger globally applied to tests that spew everywhere?!?
+ Override Minitest#__run to sort tests by name.
+ Reworked testing isolation to work with the new cleaner architecture.
- Removed a bunch of tests that just test minitest straight up. I think these changes were all merged to minitest 4 a long time ago.
- Minor report output differences.
2013-05-06 17:38:45 -07:00
Patrick Robertson eebb9ddf9b Convert ActiveModel to 1.9 hash syntax.
I also attempted to fix other styleguide violations such as
{ a: :b } over {a: :b} and foo(b: 'bar') over foo( b: 'bar' ).
2013-05-01 18:01:46 -07:00
Rafael Mendonça França feb44b9213 rails/master is now 4.1.0.beta 2013-04-29 13:15:24 -03:00
David Heinemeier Hansson 1ec64297f9 Bump version to rc1 2013-04-29 08:29:18 -07:00
Xavier Noria 31aab3ee57 pass over the code comments
* Highlights the requirement of an attributes method.
* Removes some details that depend on the implementation of the class including the module.
* Applies guidelines here and there.
2013-04-28 12:03:59 +02:00
Carlos Antonio da Silva 3e47e193c6 Merge pull request #10286 from neerajdotname/fix-wrong-test-name-and-failure-message
fix wrong test description and failure message
2013-04-21 09:22:51 -07:00
Neeraj Singh 2242317fdd fix wrong test description and failure message 2013-04-21 12:00:38 -04:00
Neeraj Singh cf69d527fe Added tests for if condition in Active Model callbacks 2013-04-21 11:34:12 -04:00
Yves Senn 068289f239 align the result of expressions vertically [ci skip]. 2013-04-12 17:22:39 +02:00
Yves Senn c245437de7 use unified and clean formatting in CHANGELOGS. [ci skip] 2013-04-12 15:52:43 +02:00
Anupam Choudhury e000aa92dd Removed unused setup 2013-04-09 20:57:55 +05:30
Sam Ruby 04cda1848c Prefer find_by over dynamic finders in rdoc 2013-04-02 15:09:15 -04:00
Carlos Antonio da Silva 09c55dcc5d Review some tests from AMo::Errors to remove "should" usage
Also remove duplicated tests for Errors#as_json and minor improvements
in some tests.
2013-03-30 15:04:09 -03:00
Carlos Antonio da Silva 3d0c0c6c95 Improve changelog entry for ActiveModel::Errors#full_messages_for [ci skip]
Add a working example of how to use this new method.
2013-03-30 14:38:13 -03:00
Vijay Dev 6d8c070821 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
	activerecord/test/cases/adapter_test.rb
	guides/source/testing.md

[ci skip]
2013-03-30 15:46:14 +05:30
Rafael Mendonça França b8b3df0e63 Merge pull request #8527 from shockone/patch-1
Add a method full_messages_for to the Errors class
2013-03-25 09:04:25 -07:00
Rafael Mendonça França ba012fa04d Merge pull request #9864 from vipulnsward/fix_test_AR_v2
Introduce test on Error#full_message for attribute with underscores; Fix...
2013-03-25 08:56:29 -07:00
shock_one ec1b715b0e Add a method full_messages_for to the Errors class 2013-03-24 09:38:28 +02:00
Rafael Mendonça França e600384515 Merge pull request #8501 from charliesome/version-to-s
Add #to_s method to VERSION modules
2013-03-23 18:51:16 -07:00
Prathamesh Sonpatki 5f59317ec6 Fixed typo in activemodel/CHANGELOG 2013-03-24 02:27:43 +05:30
Prathamesh Sonpatki 33d1e37408 Reverted change in activemodel/CHANGELOG.md introduced by d45145acdc 2013-03-24 02:14:21 +05:30
Prathamesh Sonpatki d45145acdc Changed 'args' to 'arguments' when used in places other than code with fixing few more typos 2013-03-24 00:34:06 +05:30
Carlos Antonio da Silva a03ab8cef8 Remove exception variable from rescue block
Just raising from the rescue block will re-raise the exception, so the
variable is not necessary.
2013-03-22 14:00:06 -03:00
Vipul A M 24fee97581 Add Error#full_message test; Fix typos
Introduce test on Error#full_message for attribute with underscores; Fix
some typos
2013-03-22 14:53:32 +05:30
robertomiranda 7e07b7bb5d Change Standard error when is required bcrypt-ruby and fails 2013-03-21 22:52:42 -05:00
Charlie Somerville c07e1515f7 Add version method to top level modules 2013-03-21 19:56:07 +11:00
Intrepidd 9c025ab6e9 Tidying up some require : removing useless sort and homogenizing with the rest of the code the wat the includes are done 2013-03-20 18:24:48 +00:00
wangjohn 3ee30ca44a The repair_validations helper was not working correctly before because
it only cleared the validations that created :validate callbacks. This
didn't include the validates created by validates_with, so I've added a
method to clear all validations.
2013-03-19 12:23:20 -04:00
Xavier Noria ddd2c75b26 Revert "instruct RDoc to only parse Ruby files under lib [Fixes #9779]"
This reverts commit c24528fbc9.
2013-03-18 21:19:47 +01:00
Xavier Noria c24528fbc9 instruct RDoc to only parse Ruby files under lib [Fixes #9779] 2013-03-18 20:36:32 +01:00
Vipul A M 233737706c fix some typos found in activemodel 2013-03-18 17:20:05 +05:30
Vipul A M 29dcf096b0 Small typos here and there. 2013-03-15 11:55:03 +05:30
Waynn Lue 008fd54e74 clarify verbiage 2013-03-12 18:44:10 -07:00
Carlos Antonio da Silva b3a31e9363 Fix AMo code example indent, add missing author to entry [ci skip] 2013-03-09 14:57:31 -03:00
Rafael Mendonça França cf09ac380e Merge pull request #9545 from senny/9535_secure_password_blank
`has_secure_password` is not invalid when assigning empty Strings
2013-03-07 08:05:05 -08:00
Vijay Dev 6ea48ebfa6 Merge branch 'master' of github.com:lifo/docrails 2013-03-05 22:51:48 +05:30
Yves Senn 8c1687bbf8 `has_secure_password` is not invalid when assigning empty Strings.
Closes #9535.

With 692b3b6 the `password=` setter does no longer set blank passwords.
This triggered validation errors when assigning empty Strings to `password`
and `password_confirmation`.

This patch only sets the confirmation if it is not `blank?`.
2013-03-04 18:56:05 +01:00
Yves Senn b501ee47fa `validates_confirmation_of` does not override writer methods. 2013-03-04 18:51:34 +01:00
Lebin Sebastian F 50b3b968d4 Small Typo 2013-03-04 13:23:23 +05:30
Rafael Mendonça França 0f75e2c51f Update CHANGELOGS 2013-02-26 13:45:57 -03:00
David Heinemeier Hansson c0bc9ce38c Preparing for 4.0.0.beta1 release 2013-02-25 08:31:50 -06:00
Xavier Noria 05857ec30e did a pass over the AM changelog [ci skip] 2013-02-24 20:37:15 +01:00
Angelo capilleri 40c1ee8b7d added more accurate test for add_on_empty
with the current tests, if delete the assignment of is_empty in add_on_empty method
the tests not fail. With this test, if we delete is_empty, the test fails
2013-02-19 18:48:37 +01:00
Vijay Dev 0c145448c4 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	guides/source/upgrading_ruby_on_rails.md
2013-02-15 22:06:17 +05:30
Henrik Nyh 53c22e097a Clarify ActiveModel::Validator initialization in docs.
As discussed with @josevalim on Ruby Rogues Parley.
2013-02-09 15:54:14 +01:00
Rafael Mendonça França e16110c4b8 Take care of whitespaces and changing the hash syntax 2013-02-04 09:59:22 -02:00
David 6e2cba1c8b test for issue 8931 2013-02-02 13:00:52 +08:00
Akira Matsuda ee4a2bb23d Missing require extract_options 2013-01-31 23:45:36 +09:00
Attila Domokos 69b6129fd4 Adding the route_key and param_key tests
This way all the tests are testing the same fields
2013-01-22 22:13:43 -05:00
Guillermo Iguaran 8aebe30ef4 Revert "Merge pull request #8989 from robertomiranda/use-rails-4-find-by"
This reverts commit 637a7d9d35, reversing
changes made to 5937bd02de.
2013-01-18 09:15:19 -05:00
robertomiranda 7baecc4802 User Rails 4 find_by 2013-01-18 07:56:05 -05:00
Carlos Antonio da Silva 203f787321 Merge pull request #8940 from adomokos/adding_tests_for_changed_attributes
Cleaning up ActiveModel::Dirty tests
2013-01-15 13:02:57 -08:00
Attila Domokos 63333e600f Cleaning up ActiveModel::Dirty tests
* Clarifying what the #changed method returns
* Adding tests to describe what the #changed_attributes returns
* Updating test name based on pull request comment
* Moving the test lower in the file per pull request comment
2013-01-15 10:24:57 -05:00
Trung Lê 86c4fe8191 ActiveRecord <-> Active Record [ci skip] 2013-01-15 10:52:02 +00:00
Yves Senn bc19c0d09c test for ActiveModel::Conversion#to_partial_path and namespaced models 2013-01-14 21:17:22 +01:00
Attila Domokos 01434a5ee6 Adding tests for ActiveModel::Model
* Verifying persisted? is false when Model initialized
* Passing nil to Model should not blow up
* Changing test name to the one suggested in pull request comment
2013-01-12 20:04:24 -05:00
Attila Domokos 7171f9cc8f Covering untested methods for ActiveModel::Errors 2013-01-10 21:41:35 -05:00
Irio Irineu Musskopf Junior d4f46ee4fd Set default value to ActiveModel::Validator initializer attribute
Makes it easier to test its objects.
2013-01-09 13:50:27 -02:00
Vijay Dev f049016cd3 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	guides/source/getting_started.md
2013-01-09 01:04:15 +05:30
Gosha Arinich 0acf92184d prefer american spelling of 'behavior' 2013-01-07 11:47:27 +03:00
Akira Matsuda 3c21237c37 Reduce number of Strings a bit 2013-01-07 07:37:23 +09:00
Akira Matsuda c8e632bd9f Namespace HashWithIndifferentAccess 2013-01-07 07:37:23 +09:00
Akira Matsuda 7f495993bb Observers was extracted from Active Model as `rails-observers` gem 2013-01-02 06:23:12 +09:00
Andrew Nesbitt d814284506 Updated copyright notices for 2013 2012-12-31 20:35:29 +00:00
Rafael Mendonça França 5da4d5142a Add active_support/testing/autorun
minitest/autorun load minitest/spec polluting the global namespace with
the DSL that we don't want on Rails
2012-12-31 13:57:24 -03:00
Rafael Mendonça França b05819fd28 This change doesn't need a CHANGELOG entry.
[ci skip]
2012-12-26 20:39:32 -03:00
Rafael Mendonça França 9647d4b6f4 Add CHANGELOG entry for #8622 2012-12-26 19:22:38 -03:00
Rafael Mendonça França 78fd14c8de Revert the change at ActiveModel::Errors#add_on_blank and fix in the
right place.

The EachValidator#validate already handle :allow_blank and :allow_nil,
correctly.

Closes #8622.

Fix #8621.
2012-12-26 18:55:47 -03:00
Colin Kelley d4c30a0226 Tests and fix for validates_presence of :allow_nil, :allow_blank
Conflicts:
	activemodel/lib/active_model/errors.rb
2012-12-26 18:19:27 -03:00
Akira Matsuda 08cf17d708 chmod -x from non-script files 2012-12-24 23:36:19 +09:00
Rafael Mendonça França bda1937f28 Remove CHANGELOG entry for ActiveModel::Errors#add_on_present 2012-12-21 17:10:41 -03:00
Rafael Mendonça França ac6941fb71 Use :present as key for the absence validatior message 2012-12-21 17:10:16 -03:00
Rafael Mendonça França b437053b5b Remove ActiveModel::Errors#add_on_present method.
We don't need to define a new method in ActiveMode::Errors for each
validatior.

See
d72a07f1d1 (commitcomment-2325333)
2012-12-21 17:06:18 -03:00
Carlos Antonio da Silva 42b555dcf3 Fix Action Mailer changelog indenation to match other changelogs
Also some minor improvements to other changelogs. [ci skip]
2012-12-19 23:09:04 -02:00
Carlos Antonio da Silva 05b80a1cce Improve AMo changelog example to not rely on AR [ci skip] 2012-12-19 23:03:32 -02:00
Roberto Vasquez Angel d72a07f1d1 Add `ActiveModel::Validations::AbsenceValidator`, a validator to check the absence of attributes.
Add `ActiveModel::Errors#add_on_present` method. Adds error messages to present attributes.
2012-12-15 16:27:44 -05:00
Carlos Antonio da Silva df9f9b7f3e Convert changelogs to 1.9 hash style and fix some formatting [ci skip] 2012-12-14 20:25:22 -02:00
Aaron Patterson 49219293e5 Merge pull request #8510 from thedarkone/thread_safety_improvements
Thread safety improvements
2012-12-14 11:12:50 -08:00
thedarkone 45448a5788 Replace some global Hash usages with the new thread safe cache.
Summary of the changes:
 * Add thread_safe gem.
 * Use thread safe cache for digestor caching.
 * Replace manual synchronization with ThreadSafe::Cache in Relation::Delegation.
 * Replace @attribute_method_matchers_cache Hash with ThreadSafe::Cache.
 * Use TS::Cache to avoid the synchronisation overhead on listener retrieval.
 * Replace synchronisation with TS::Cache usage.
 * Use a preallocated array for performance/memory reasons.
 * Update the controllers cache to the new AS::Dependencies::ClassCache API.
   The original @controllers cache no longer makes much sense after @tenderlove's
   changes in 7b6bfe84f3 and f345e2380c.
 * Use TS::Cache in the connection pool to avoid locking overhead.
 * Use TS::Cache in ConnectionHandler.
2012-12-14 12:18:47 +01:00
Andrew White 4dd5635922 Only call `in_time_zone` on Time or DateTime instances
Both String and Date now respond to in_time_zone so we need to
check if the value is a Time or a DateTime.
2012-12-11 12:35:30 +00:00
Jeremy Kemper 8110035623 Revert "Omit directories from gemspec.files for RubyGems 2 compat."
Obviated by rubygems/rubygems@486ed83cc8

This reverts commit bb8923dee0.
2012-12-09 17:14:27 -07:00
Jeremy Kemper bb8923dee0 Omit directories from gemspec.files for RubyGems 2 compat.
RG2 packager expects each spec.files path to be a file and bombs when it tries to tarball a dir.

May revert if rubygems/rubygems#413 is accepted.
2012-12-08 17:18:46 -07:00
claudiob 019df98875 Replace comments' non-breaking spaces with spaces
Sometimes, on Mac OS X, programmers accidentally press Option+Space
rather than just Space and don’t see the difference. The problem is
that Option+Space writes a non-breaking space (0XA0) rather than a
normal space (0x20).

This commit removes all the non-breaking spaces inadvertently
introduced in the comments of the code.
2012-12-04 22:11:54 -08:00
Renato Mascarenhas cc62ec1e8c Actually test that ActiveModel::Errors#add defaults to :invalid. 2012-12-01 22:30:34 -02:00
Renato Mascarenhas 703b6387ee Call `full_messages` instead of `to_a` in its spec. 2012-12-01 22:30:33 -02:00
Renato Mascarenhas cf7ab6056a Reset attributes should not report changes.
When resetting an attribute, you expect it to return to the state it was
before any changes. Namely, this fixes this unexpected behavior:

~~~ruby
model.name = "Bob"
model.reset_name!
model.name_changed? #=> true
~~~
2012-12-01 16:58:09 -02:00
Carlos Antonio da Silva c2be9b0c3e Simplify keys order test for as_json in Active Model 2012-11-30 10:21:24 -02:00
Rafael Mendonça França ec17f0d352 Add CHANGELOG entries for the observes extraction
[ci skip]
2012-11-29 01:08:36 -02:00
Rafael Mendonça França ccecab3ba9 Remove observers and sweepers
They was extracted from a plugin.

See https://github.com/rails/rails-observers

[Rafael Mendonça França + Steve Klabnik]
2012-11-28 22:46:49 -02:00
Steve Klabnik 9504b44cf6 Specify type of singular association during serialization
When serialising a class, specify the type of any singular associations, if
necessary. Rails already correctly specifies the :type of any enumerable
association (e.g. a has_many association), but made no attempt to do so for
non-enumerables (e.g. a has_one association).
We must specify the :type of any STI association. A has_one
association to a class which uses single-table inheritance is an example of
this type of association.

Fixes #7471
2012-11-28 11:48:32 -08:00
Rafael Mendonça França 5658923daa Merge pull request #7282 from xHire/validates_length_of_fix
Length validation handles correctly nil. Fix #7180

Conflicts:
	activemodel/CHANGELOG.md
2012-11-26 18:44:07 -02:00
Carlos Antonio da Silva 26a3b70cc4 Merge pull request #8320 from senny/active_model_log_folder
Log output from activemodel's railtie_test directly to STDOUT.

There's no logging going on here, but since we initialize the app, the
logger is set and the folder is automatically created. With this change,
the default logger is not created, so there is no logging folder anymore.

Conflicts:
	activemodel/test/cases/railtie_test.rb
2012-11-26 15:32:25 -02:00
Yves Senn 6fc83201db log output from activemodel's railtie_test directly to STDOUT
after this patch, running the tests in activemodel will no longer
create an untracked log/ folder inside of activemodel
2012-11-26 17:23:20 +01:00
Rafael Mendonça França 3ec443086b Merge pull request #8312 from senny/make_active_model_parts_individually_loadable
make sure that individual parts `ActiveModel` can be required by itself
2012-11-26 04:11:17 -08:00
Michal Zima ea76e9a312 Length validation handles correctly nil. Fix #7180
When nil or empty string are not allowed, they are not valid.
2012-11-26 12:34:32 +01:00
Carlos Antonio da Silva 3da1649828 Require active_model/railtie directly instead of rails/all
Use Class.new with a block instead of tap to configure it.
2012-11-26 09:19:57 -02:00
Yves Senn 22598ee599 cleanup, removed dispensable `require` statements from `ActiveModel` 2012-11-25 17:08:57 +01:00
Yves Senn b7edbc718b cleanup, remove broken whitespace 2012-11-25 16:57:29 +01:00
Carlos Antonio da Silva c2c1ecb05e Use secure password min cost option in its own tests for a speed up
Around 0.564359s => 0.092244s speed up in my machine.
2012-11-21 19:34:55 -02:00
Carlos Antonio da Silva ea0056f52a Merge pull request #8256 from nalwayaabhishek/master
Displaying error message if validation fail in examples (p tag was missing)
2012-11-19 02:49:00 -08:00
Abhishek Nalwaya c33e893775 displaying error message(p tag was missing) and adding output as comment 2012-11-19 07:03:40 +05:30
Saulius Grigaliunas 61edea05c3 Point user to strong_parameters as the new protection model [ci skip] 2012-11-18 15:40:41 +02:00
Carlos Antonio da Silva 0b63da9d5a Initialize #min_cost to avoid warning in Ruby 2.0 2012-11-17 18:40:01 -02:00
Vijay Dev 7b70eeed43 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	actionpack/lib/action_dispatch/routing/redirection.rb
2012-11-17 01:50:49 +05:30
Trevor Turk 06faa6da80 Use BCrypt's MIN_COST in the test environment for speedier tests 2012-11-14 09:42:54 -06:00
Daniel Lopes d7536e6108 add details on password confirmation used with has_secure_password 2012-11-13 17:31:46 -06:00
Dennis Taylor ba291a67df Trivial documentation fix for ActiveModel::Naming comment. 2012-11-09 11:23:51 -08:00
Aaron Patterson 72f5085404 rm dead code 2012-11-09 10:31:23 +09:00
Vinny Diehl a96a176930 Clean up gemspecs
Organized the gemspec files a bit.

 * Made quotes more consistent (single quotes dominated, so I used
   that).
 * Moved license line down a line, separating it logically, and removed
   the extra whitespace before its = operator.
 * Minor whitespace fixes.
2012-11-08 19:09:43 -05:00
Vasiliy Ermolovich 70ecf6c518 use Array() instead flatten
* move ActiveModel::Errors tests to errors_test.rb
* add spec coverage for add_on_empty and add_on_blank
2012-11-05 18:29:31 +03:00
Carlos Antonio da Silva b1fe78e0cb Raise ArgumentError when no attribute is given to AMo::EachValidator
ArgumentError is better suited than RuntimeError for this.
2012-11-04 11:41:05 -02:00
Carlos Antonio da Silva d9f20c575a Set hash value instead of using merge! 2012-11-04 11:35:01 -02:00
Vijay Dev 3b0bb08699 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	actionpack/lib/action_controller/metal/mime_responds.rb
	activerecord/lib/active_record/attribute_methods.rb
	guides/source/working_with_javascript_in_rails.md
2012-11-03 01:56:16 +05:30
Alexey Gaziev b955939d55 Make caller attribute in deprecation methods optional 2012-10-30 10:23:41 +08:00
Cédric FABIANSKI 3152ee878a Add test for code change introduced in this commit f20032f 2012-10-29 21:55:09 +01:00
Nikita Afanasenko 0b7067d849 Provide a call stack for deprecation warnings where needed.
It's sometimes hard to quickly find where deprecated call was performed, especially in case of migrating between Rails versions. So this is an attempt to improve the call stack part of the warning message by providing caller explicitly.
2012-10-29 19:22:59 +04:00
Francesco Rodriguez df2b60cd41 fix failing isolated tests 2012-10-26 23:03:36 -05:00
Francesco Rodriguez 10d9cb2052 fix AM::Serializers titles [ci skip] 2012-10-26 21:46:15 -05:00
Francesco Rodriguez 070329596f AM::Serializers::Xml depends on AM::Naming 2012-10-26 21:45:40 -05:00
Francesco Rodriguez 9ac095fef5 minor edits and remove mixed titles in AM::Validations docs [ci skip] 2012-10-25 20:41:35 -05:00
Francesco Rodriguez 2ef4d5ed5c fix output messages - docs [ci skip] 2012-10-22 14:27:55 -05:00
AvnerCohen 77eb1fb22d convert comments to 1.9 hash syntax 2012-10-22 19:34:24 +02:00
Vijay Dev f938019da2 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	activesupport/lib/active_support/core_ext/hash/slice.rb
	guides/source/active_support_core_extensions.md
2012-10-21 18:49:19 +05:30
Francesco Rodriguez c9a88a2c26 minor edits in AM documentation [ci skip] 2012-10-21 01:26:01 -05:00
Hrvoje Šimić aee07fe135 include serializers in ActiveModel::Serialization example 2012-10-19 17:24:34 +02:00
Hrvoje Šimić 2d2c82354f better examples in ActiveModel readme 2012-10-19 16:58:30 +02:00
Jan Berdajs a774354dfe add credit to committer of pull request #6569 2012-10-18 16:29:17 +02:00
Francesco Rodriguez f12244b6d7 remove non-breaking spaces [ci skip] 2012-10-18 01:23:26 -05:00
Yves Senn a06012c81f active_model/validations requires necessary files to run 2012-10-18 07:44:41 +02:00
Yves Senn f00b33e173 cleanup, replace non-breaking spaces with spaces 2012-10-18 07:44:41 +02:00
dfens ab9140ff02 Cleanup trailing whitespaces 2012-10-12 09:56:39 +02:00
Vijay Dev f638ef951b Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	activerecord/lib/active_record/persistence.rb
	railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb
2012-10-11 01:05:14 +05:30
Vijay Dev 43f32f2f5d Revert "Fix Example in active model attribute methods"
This reverts commit 1c02b98864.
2012-10-11 00:43:52 +05:30
Vijay Dev d5802adf83 Revert "Fix all examples in comments in active_model attribute methods"
This reverts commit 93b1ca8bd3.
2012-10-11 00:43:17 +05:30
Robin Dupret f839e619d4 Use a 1.9 Hash syntax in README files (fixes thanks to @vijaydev) 2012-10-10 15:14:03 +02:00
Rafael Mendonça França d56b5dacb1 Use the `flat_map` method.
Thanks to @jeremy to teach me this one.
2012-10-03 00:17:10 -03:00
Rafael Mendonça França 86062005a7 Revert "Merge pull request #7826 from sikachu/master-validators-kind"
This reverts commit 4e9f53f973, reversing
changes made to 6b802cdb4f.

Revert "Don't use tap in this case."

This reverts commit 454d820bf0.

Reason: Is not a good idea to add options to this method since we can do
the same thing using method composition.

    Person.validators_on(:name).select { |v| v.kind == :presence }

Also it avoids to change the method again to add more options.
2012-10-02 23:57:00 -03:00
Rafael Mendonça França 454d820bf0 Don't use tap in this case.
The use of tap in this case is very confusing since we are mutating the
return value inside the block
2012-10-02 23:24:42 -03:00
Prem Sichanugrist 4f9b59dba0 Make `.validators_on` accept `:kind` option
This will filter out the validators on a particular attribute based on
its kind.
2012-10-02 22:09:06 -04:00
Nick Rowe 93b1ca8bd3 Fix all examples in comments in active_model attribute methods 2012-10-02 15:35:12 -07:00
Nick Rowe 1c02b98864 Fix Example in active model attribute methods 2012-10-02 15:18:08 -07:00
John Foley 60c65ca8df Switch to using include? on validation callbacks 2012-09-23 12:53:50 -06:00
John Foley d66d6076b2 Fix collisions with before and after validation callbacks.
This commit allows a user to do something like:
    before_validation :do_stuff, :on => [ :create, :update ]
    after_validation :do_more, :on => [ :create, :update ]
2012-09-23 12:53:50 -06:00
Francesco Rodriguez 356eed9c60 add :nodoc: to AMo::DeprecatedMassAssignmentSecurity::ClassMethods [ci skip] 2012-09-20 12:18:59 -05:00
Francesco Rodriguez 6783c3f449 change AMo::ForbiddenAttributesProtection#sanitize_for_mass_assignment to protected 2012-09-20 12:18:59 -05:00
Francesco Rodriguez 1e56f1f14c update AMo::ForbiddenAttributesError documentation [ci skip] 2012-09-20 12:18:59 -05:00
Francesco Rodriguez 3759e32882 add :nodoc: directives to AMo::DeprecatedMassAssignmentSecurity [ci skip] 2012-09-20 12:18:58 -05:00
Guillermo Iguaran 1f4c89fbde Update changelogs to add entries about strong_parameters integration 2012-09-19 17:50:39 -05:00
Guillermo Iguaran 9bfa13bb06 attr_accessible and attr_protected raise an exception pointing to use plugin or new protection model 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 1fa4f9243d Rename ForbiddenAttributes exception to ForbiddenAttributesError 2012-09-16 23:58:21 -05:00
Guillermo Iguaran 52aa5343f4 Change AMo::ForbiddenAttributesProtection tests to use a subclass of Hash instead of monkey patch permitted? method in regular hashes 2012-09-16 23:58:19 -05:00
Guillermo Iguaran f8c9a4d3e8 Remove MassAssignmentSecurity from ActiveModel
This will be moved out to protected_attributes gem
2012-09-16 23:58:19 -05:00