Commit Graph

59 Commits

Author SHA1 Message Date
Josh Susser
c347b3c06c don't change class definition in test case 2011-11-29 09:14:21 -08:00
Josh Susser
9cdf33af0b add test for super-ing to association methods 2011-11-15 23:32:58 -08:00
Josh Susser
7cba6a3784 association methods are now generated in modules
Instead of generating association methods directly in the model
class, they are generated in an anonymous module which
is then included in the model class. There is one such module
for each association. The only subtlety is that the
generated_attributes_methods module (from ActiveModel) must
be forced to be included before association methods are created
so that attribute methods will not shadow association methods.
2011-11-15 23:32:58 -08:00
Jon Leighton
24f0a872e6 Add a proxy_association method to association proxies, which can be called by association extensions to access information about the association. This replaces proxy_owner etc with proxy_association.owner. 2011-07-27 12:36:00 +01:00
Aaron Patterson
61774e0d49 please use ruby -I lib:test path/to/test.rb, or export RUBY_OPT 2011-06-06 15:47:13 -07:00
Jon Leighton
253bb6b926 Refactor Active Record test connection setup. Please see the RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases. 2011-06-04 23:47:03 +01:00
Josh Kalderimis
542114e1d8 removed deprecated methods, and related tests, from ActiveRecord 2011-05-25 02:29:32 +02:00
Jon Leighton
0afd5850f5 Implement proxy_owner, proxy_target and proxy_reflection methods on CollectionProxy with deprecations. Fixes #1148. 2011-05-19 23:28:44 +01:00
Vishnu Atrai
33f0b6b67d minor cleaning 2011-05-10 22:51:54 +05:30
Sebastian Martinez
245542ea29 Added new #update_column method.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-03-27 21:47:38 -03:00
Sebastian Martinez
0e1fed537a Revert "Removed #update_attribute method. New #update_column method."
This reverts commit 45c233ef819dc7b67e259dd73f24721fec28b8c8.

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-03-27 18:55:30 -03:00
Sebastian Martinez
45c233ef81 Removed #update_attribute method. New #update_column method.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-03-26 12:09:04 -03:00
Jon Leighton
6975a41adf Remove test which was broken on 1.8. This test is now irrelevant since singular associations no longer return a proxy object. 2011-02-18 18:50:35 +00:00
Jon Leighton
1644663ba7 Split AssociationProxy into an Association class (and subclasses) which manages the association, and a CollectionProxy class which is *only* a proxy. Singular associations no longer have a proxy. See CHANGELOG for more. 2011-02-18 00:00:13 +00:00
Josh Kalderimis
d7db6a8873 class inheritable attributes is used no more! all internal use of class inheritable has been changed to class_attribute. class inheritable attributes has been deprecated.
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-11-20 19:40:29 +01:00
Aaron Patterson
2738ec891b removing many unused variables 2010-11-16 17:06:50 -08:00
Santiago Pastorino
b451de0d6d Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;) 2010-08-14 04:12:33 -03:00
Neeraj Singh
807239f5a1 Making Active Record base_test.rb thinner by moving tests
to relevant files.

Number of assertions before refactoring:
2391 tests, 7579 assertions, 0 failures, 0 errors

Number of assertions after refactoring:
2391 tests, 7579 assertions, 0 failures, 0 errors

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-03 10:45:54 +02:00
Neeraj Singh
009aa8825b Eager loading an association should not change the count of children
[#4971 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-02 17:12:59 +02:00
Subba Rao Pasupuleti
b0c7dee4f2 removing unused models from tests
[#5153 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-21 22:08:07 +02:00
Subba Rao Pasupuleti
96b2516c3c Strengthening the test for nested_attribute
Loading the associate target in nested_attributes
should load most recent attributes for child
records marked for destruction

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-21 14:25:34 +02:00
Ken Collins
0e9bc23c0e Fix the #using_limitable_reflections? helper to work correctly by not examining the length of an array which contains false/true, hence always passing. [#4869 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 22:34:34 +02:00
Xavier Noria
c8f1aac761 restricts a test to < 1.9, and rewrites it using a proper expectation
Signed-off-by: wycats <wycats@gmail.com>
2010-03-13 17:04:08 -06:00
Xavier Noria
89eae2d187 adds coverage for the issue addressed in fe43bbd
[#4166 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-03-12 13:22:47 -08:00
Will
bf6af5f719 When passing force_reload = true to an association, don't use the query cache [#1827 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-12-16 10:49:53 -06:00
Emilio Tagua
046c22c8c1 Removed legacy test. 2009-07-20 16:53:48 -03:00
Michael Koziarski
cb45ee344d Remove the functionality introduce in 28d3390
There are several situations it doesn't cater for, and the inconsistency isn't worth blocking 2.2.
2008-10-10 17:04:46 +02:00
Nathaniel Talbott
9d7f186f74 Fixed an error triggered by a reload followed by a foreign key assignment.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2008-09-20 14:16:43 +02:00
Jon Leighton
fcf31cb752 Support for updating a belongs to association from the foreign key (without saving and reloading the record)
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#142 state:committed]
2008-09-13 11:08:29 +02:00
Pratik Naik
9994f0d902 Revert "Add :accessible option to Associations for allowing mass assignments using hash. [#474 state:resolved]"
This reverts commit e0750d6a5c7f621e4ca12205137c0b135cab444a.

Conflicts:

	activerecord/CHANGELOG
	activerecord/lib/active_record/associations.rb
	activerecord/lib/active_record/associations/association_collection.rb
2008-09-10 18:50:01 +01:00
Jeremy Kemper
ab1e82b8f7 Include people and readers fixtures to fix test isolation error 2008-08-26 02:38:48 -07:00
Tarmo Tänav
656f0e7c6c Fix file permissions
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2008-07-31 16:36:23 -05:00
David Dollar
e0750d6a5c Add :accessible option to Associations for allowing mass assignments using hash. [#474 state:resolved]
Allows nested Hashes (i.e. from nested forms) to hydrate the appropriate
ActiveRecord models.

class Post < ActiveRecord::Base
  belongs_to :author,   :accessible => true
  has_many   :comments, :accessible => true
end

post = Post.create({
  :title    => 'Accessible Attributes',
  :author   => { :name => 'David Dollar' },
  :comments => [
    { :body => 'First Post!' },
    { :body => 'Nested Hashes are great!' }
  ]
})

post.comments << { :body => 'Another Comment' }

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2008-07-14 02:53:21 +01:00
Ryan Bates
6cba97d2a4 Create through associations can now work with blocks.
Signed-off-by: Michael Koziarski <michael@koziarski.com>

[#248 state:resolved]
2008-05-24 18:26:13 +12:00
Trevor Turk
b88ceb7dc8 add failing test case for block-setting of attributes via association
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2008-05-24 18:25:33 +12:00
Ryan Bates
73c5963854 Add first/last methods to associations/named_scope. [#226 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2008-05-20 12:27:14 +01:00
Andreas Neuhaus
bcb090c56b Calling ActiveRecord#inspect on an unloaded association won't wipe the collection [#9 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2008-05-08 00:04:53 -05:00
Frederick Cheung
a4fc93c3a9 Use schema.rb for all databases
Move adapter specific schema into their own files

Signed-off-by: Michael Koziarski <michael@koziarski.com>
2008-04-22 13:55:13 +12:00
Pratik Naik
5b822aca4b Split associations_test.rb into multiple files based on association type. [Pratik]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9233 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-04-06 03:01:09 +00:00
Pratik Naik
7ddc8f2e1b Ensure that save on parent object fails for invalid has_one association. Closes #10518. [Pratik]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9232 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-04-06 02:32:51 +00:00
Pratik Naik
f6b12c11cd Refactor HasManyThroughAssociation to inherit from HasManyAssociation. Association callbacks and <association>_ids= now work with hm:t. Closes #11516 [rubyruy]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9230 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-04-06 00:27:12 +00:00
Pratik Naik
15d88885ee Ensure HABTM#create and HABTM#build do not load entire association. [Pratik]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9229 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-04-05 16:25:48 +00:00
Rick Olson
e223216e9a Add efficient #include? to AssociationCollection (for has_many/has_many :through/habtm). [stopdropandrew]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9200 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-04-01 18:27:22 +00:00
Jeremy Kemper
6b9448cdd2 Partial updates include only unsaved attributes. Off by default; set YourClass.partial_updates = true to enable.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9157 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-31 01:10:04 +00:00
David Heinemeier Hansson
bdd88810c1 Fixed that has_many :through would ignore the hash conditions (closes #11447) [miloops]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9110 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-28 16:13:57 +00:00
Pratik Naik
533da24bbc Make sure ActiveRecord tests can run individually. Closes #11425 [thechrisoshow, h-lame]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9109 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-28 11:55:01 +00:00
Rick Olson
1648208ab0 Fix duplicate table alias error when including an association with a has_many :through association on the same join table. Closes #7310 [cavalle]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9095 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-26 15:36:17 +00:00
Jeremy Kemper
5c1be2812d has_one :through supports :source_type. Fix up some tests. References #4756.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9075 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-22 02:20:37 +00:00
Rick Olson
c23c9bd11b Allow association scoping for built/created records if :conditions is specified as a hash. Closes #11393 [miloops]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9068 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-21 18:21:56 +00:00
Rick Olson
273b21faa9 Add has_one :through support, finally. Closes #4756 [thechrisoshow]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9067 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-21 18:09:03 +00:00