Permalink
Browse files

Heavy bugfix

  • Loading branch information...
1 parent f846538 commit a93000b06c9576636a561d0dfd7da28067b8ae53 @pyromaniac pyromaniac committed Nov 6, 2012
Showing with 16 additions and 8 deletions.
  1. +1 −1 lib/activeuuid/uuid.rb
  2. +15 −7 spec/lib/activerecord_spec.rb
View
@@ -106,7 +106,7 @@ def uuids(*attributes)
def instantiate_with_uuid(record)
uuid_columns.each do |uuid_column|
- record[uuid_column] = UUIDTools::UUID.serialize(record[uuid_column]).to_s
+ record[uuid_column] = UUIDTools::UUID.serialize(record[uuid_column]).to_s if record[uuid_column]
end
instantiate_without_uuid(record)
end
@@ -21,15 +21,16 @@
specify { model.where(id: id).first.should == article }
end
- context '.destroy' do
- specify { article.delete.should be_true }
- specify { article.destroy.should be_true }
+ context '#destroy' do
+ subject { article }
+ its(:delete) { should be_true }
+ its(:destroy) { should be_true }
end
end
describe UuidArticle do
let!(:article) { Fabricate :uuid_article }
- let(:id) { article.id }
+ let!(:id) { article.id }
let(:model) { UuidArticle }
specify { model.primary_key.should == 'id' }
@@ -56,9 +57,16 @@
specify { model.where(id: id.raw).first.should == article }
end
- context '.destroy' do
- specify { article.delete.should be_true }
- specify { article.destroy.should be_true }
+ context '#destroy' do
+ subject { article }
+ its(:delete) { should be_true }
+ its(:destroy) { should be_true }
+ end
+
+ context '#reload' do
+ subject { article }
+ its(:'reload.id') { should == id }
+ specify { subject.reload(:select => :another_uuid).id.should == id }
end
context 'typecasting' do

0 comments on commit a93000b

Please sign in to comment.