diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-02-23 16:51:54 -0800 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-02-23 16:51:54 -0800 |
commit | da667908f6c84ecb5dbf7c3e2b9d22ffe4c386a7 (patch) | |
tree | df5722ef994955a30502b71db31235fdec969470 | |
parent | d3c7c37658aeba0c9cedb3c3a57e2a5a8968d58f (diff) | |
download | rails-da667908f6c84ecb5dbf7c3e2b9d22ffe4c386a7.tar.gz rails-da667908f6c84ecb5dbf7c3e2b9d22ffe4c386a7.tar.bz2 rails-da667908f6c84ecb5dbf7c3e2b9d22ffe4c386a7.zip |
updating functionality
-rw-r--r-- | spec/active_relation/unit/relations/update_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/active_relation/unit/relations/update_spec.rb b/spec/active_relation/unit/relations/update_spec.rb new file mode 100644 index 0000000000..c26e7fb525 --- /dev/null +++ b/spec/active_relation/unit/relations/update_spec.rb @@ -0,0 +1,27 @@ +require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper') + +module ActiveRelation + describe Update do + before do + @relation = Table.new(:users) + end + + describe '#to_sql' do + it 'manufactures sql updating attributes' do + Update.new(@relation, @relation[:name] => "nick").to_sql.should be_like(""" + UPDATE `users` + SET `users`.`name` = 'nick' + """) + end + + it 'manufactures sql updating a selection relation' do + Update.new(@relation.select(@relation[:id].equals(1)), @relation[:name] => "nick").to_sql.should be_like(""" + UPDATE `users` + SET `users`.`name` = 'nick' + WHERE `users`.`id` = 1 + """) + end + + end + end +end
\ No newline at end of file |