From 2a55306a05284bfb13949dc0413064ec955ce0e6 Mon Sep 17 00:00:00 2001 From: Jan Tuitman Date: Wed, 24 Jul 2013 12:52:16 +0200 Subject: [PATCH] bugfix: when using ArrayModelAdapter, calling record.save! would raise an exception for existing records. the underlying reason is that the ArrayModelAdapter doesn't do anything with save, so it had no return value. But it still should return true to indicate that the record was saved successfully. --- motion/adapters/array_model_adapter.rb | 1 + spec/model_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/motion/adapters/array_model_adapter.rb b/motion/adapters/array_model_adapter.rb index baf0f8e..776db48 100644 --- a/motion/adapters/array_model_adapter.rb +++ b/motion/adapters/array_model_adapter.rb @@ -164,6 +164,7 @@ def do_insert(options = {}) end def do_update(options = {}) + true end def do_delete diff --git a/spec/model_spec.rb b/spec/model_spec.rb index 1bb8c8c..4169132 100644 --- a/spec/model_spec.rb +++ b/spec/model_spec.rb @@ -168,6 +168,12 @@ class TypeCast Task.where(:name).eq('updated').should == 0 lambda{task.save}.should.change{Task.where(:name).eq('updated')} end + + it 'should not raise MotionModel::RecordNotSaved when save! is called' do + task = Task.create(:name => 'updateable') + task.name = 'updated' + lambda{task.save!}.should.not.raise(MotionModel::RecordNotSaved) + end end describe 'deleting' do