couch_potato 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES.md +15 -0
- data/MIT-LICENSE.txt +19 -0
- data/README.md +295 -0
- data/VERSION.yml +4 -0
- data/init.rb +3 -0
- data/lib/core_ext/date.rb +10 -0
- data/lib/core_ext/object.rb +5 -0
- data/lib/core_ext/string.rb +19 -0
- data/lib/core_ext/symbol.rb +15 -0
- data/lib/core_ext/time.rb +11 -0
- data/lib/couch_potato.rb +40 -0
- data/lib/couch_potato/database.rb +106 -0
- data/lib/couch_potato/persistence.rb +98 -0
- data/lib/couch_potato/persistence/attachments.rb +31 -0
- data/lib/couch_potato/persistence/callbacks.rb +60 -0
- data/lib/couch_potato/persistence/dirty_attributes.rb +49 -0
- data/lib/couch_potato/persistence/ghost_attributes.rb +22 -0
- data/lib/couch_potato/persistence/json.rb +46 -0
- data/lib/couch_potato/persistence/magic_timestamps.rb +13 -0
- data/lib/couch_potato/persistence/properties.rb +52 -0
- data/lib/couch_potato/persistence/simple_property.rb +83 -0
- data/lib/couch_potato/persistence/validation.rb +18 -0
- data/lib/couch_potato/view/base_view_spec.rb +24 -0
- data/lib/couch_potato/view/custom_view_spec.rb +27 -0
- data/lib/couch_potato/view/custom_views.rb +44 -0
- data/lib/couch_potato/view/model_view_spec.rb +63 -0
- data/lib/couch_potato/view/properties_view_spec.rb +39 -0
- data/lib/couch_potato/view/raw_view_spec.rb +25 -0
- data/lib/couch_potato/view/view_query.rb +44 -0
- data/rails/init.rb +7 -0
- data/spec/attachments_spec.rb +23 -0
- data/spec/callbacks_spec.rb +271 -0
- data/spec/create_spec.rb +22 -0
- data/spec/custom_view_spec.rb +149 -0
- data/spec/default_property_spec.rb +34 -0
- data/spec/destroy_spec.rb +29 -0
- data/spec/fixtures/address.rb +9 -0
- data/spec/fixtures/person.rb +6 -0
- data/spec/property_spec.rb +101 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/unit/attributes_spec.rb +48 -0
- data/spec/unit/callbacks_spec.rb +33 -0
- data/spec/unit/couch_potato_spec.rb +20 -0
- data/spec/unit/create_spec.rb +58 -0
- data/spec/unit/customs_views_spec.rb +15 -0
- data/spec/unit/database_spec.rb +50 -0
- data/spec/unit/dirty_attributes_spec.rb +131 -0
- data/spec/unit/string_spec.rb +13 -0
- data/spec/unit/view_query_spec.rb +9 -0
- data/spec/update_spec.rb +40 -0
- metadata +153 -0
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class Tree
         | 
| 4 | 
            +
              include CouchPotato::Persistence
         | 
| 5 | 
            +
              before_validation :water!
         | 
| 6 | 
            +
              before_validation lambda {|tree| tree.root_count += 1 }
         | 
| 7 | 
            +
              
         | 
| 8 | 
            +
              property :leaf_count
         | 
| 9 | 
            +
              property :root_count
         | 
| 10 | 
            +
              
         | 
| 11 | 
            +
              def water!
         | 
| 12 | 
            +
                self.leaf_count += 1
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
            end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
             | 
| 17 | 
            +
            describe 'before_validation callback' do
         | 
| 18 | 
            +
              before :each do
         | 
| 19 | 
            +
                @tree = Tree.new(:leaf_count => 1, :root_count => 1)
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
              
         | 
| 22 | 
            +
              it "should call water! when validated" do
         | 
| 23 | 
            +
                @tree.leaf_count.should == 1
         | 
| 24 | 
            +
                @tree.should be_valid
         | 
| 25 | 
            +
                @tree.leaf_count.should == 2
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
              
         | 
| 28 | 
            +
              it "should call lambda when validated" do
         | 
| 29 | 
            +
                @tree.root_count.should == 1
         | 
| 30 | 
            +
                @tree.should be_valid
         | 
| 31 | 
            +
                @tree.root_count.should == 2
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe CouchPotato, 'full_url_to_database' do
         | 
| 4 | 
            +
              before(:each) do
         | 
| 5 | 
            +
                @original_database_name = CouchPotato::Config.database_name
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
              after(:each) do
         | 
| 8 | 
            +
                CouchPotato::Config.database_name = @original_database_name
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
              
         | 
| 11 | 
            +
              it "should add the default localhost and port if only a name is set" do
         | 
| 12 | 
            +
                CouchPotato::Config.database_name = 'test'
         | 
| 13 | 
            +
                CouchPotato.full_url_to_database.should == 'http://127.0.0.1:5984/test'
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
              it "should return the set url" do
         | 
| 17 | 
            +
                CouchPotato::Config.database_name = 'http://db.local/test'
         | 
| 18 | 
            +
                CouchPotato.full_url_to_database.should == 'http://db.local/test'
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| @@ -0,0 +1,58 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe "create" do
         | 
| 4 | 
            +
              
         | 
| 5 | 
            +
              describe "succeeds" do
         | 
| 6 | 
            +
                before(:each) do
         | 
| 7 | 
            +
                  @comment = Comment.new :title => 'my_title'
         | 
| 8 | 
            +
                  CouchPotato::Database.new(stub('database', :save_doc => {'rev' => '123', 'id' => '456'}, :info => nil)).save_document!(@comment)
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                it "should assign the id" do
         | 
| 12 | 
            +
                  @comment._id.should == '456'
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                it "should assign the revision" do
         | 
| 16 | 
            +
                  @comment._rev.should == '123'
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                it "should set created at" do
         | 
| 20 | 
            +
                  @comment.created_at.should >= Time.now - 10
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                it "should set updated at" do
         | 
| 24 | 
            +
                  @comment.updated_at.should >= Time.now - 10
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
              
         | 
| 28 | 
            +
              describe "fails" do
         | 
| 29 | 
            +
                before(:each) do
         | 
| 30 | 
            +
                  @comment = Comment.new
         | 
| 31 | 
            +
                  CouchPotato::Database.new(stub('database', :info => nil)).save_document(@comment)
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                it "should not assign an id" do
         | 
| 35 | 
            +
                  @comment._id.should be_nil
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                it "should not assign a revision" do
         | 
| 39 | 
            +
                  @comment._rev.should be_nil
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                it "should not set created at" do
         | 
| 43 | 
            +
                  @comment.created_at.should be_nil
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                it "should set updated at" do
         | 
| 47 | 
            +
                  @comment.updated_at.should be_nil
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
                
         | 
| 50 | 
            +
                describe "with bank" do
         | 
| 51 | 
            +
                  it "should raise an exception" do
         | 
| 52 | 
            +
                    lambda {
         | 
| 53 | 
            +
                      @comment.save!
         | 
| 54 | 
            +
                    }.should raise_error
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
            end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe CouchPotato::View::CustomViews do
         | 
| 4 | 
            +
              
         | 
| 5 | 
            +
              class MyViewSpec; end
         | 
| 6 | 
            +
              class ModelWithView
         | 
| 7 | 
            +
                include CouchPotato::Persistence
         | 
| 8 | 
            +
                view :all, :type => MyViewSpec
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
              
         | 
| 11 | 
            +
              it "should use a custom viewspec class" do
         | 
| 12 | 
            +
                MyViewSpec.should_receive(:new)
         | 
| 13 | 
            +
                ModelWithView.all
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,50 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class DbTestUser
         | 
| 4 | 
            +
            end
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # namespaced model
         | 
| 7 | 
            +
            module Parent
         | 
| 8 | 
            +
              class Child
         | 
| 9 | 
            +
                include CouchPotato::Persistence
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
            end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            describe CouchPotato::Database, 'new' do
         | 
| 14 | 
            +
              it "should raise an exception if the database doesn't exist" do
         | 
| 15 | 
            +
                lambda {
         | 
| 16 | 
            +
                  CouchPotato::Database.new CouchRest.database('couch_potato_invalid')
         | 
| 17 | 
            +
                }.should raise_error('Database \'couch_potato_invalid\' does not exist.')
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            describe CouchPotato::Database, 'load' do
         | 
| 22 | 
            +
              it "should raise an exception if nil given" do
         | 
| 23 | 
            +
                db = CouchPotato::Database.new(stub('couchrest db', :info => nil))
         | 
| 24 | 
            +
                lambda {
         | 
| 25 | 
            +
                  db.load nil
         | 
| 26 | 
            +
                }.should raise_error("Can't load a document without an id (got nil)")
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              it "should set itself on the model" do
         | 
| 30 | 
            +
                user = mock 'user'
         | 
| 31 | 
            +
                DbTestUser.stub!(:new).and_return(user)
         | 
| 32 | 
            +
                db = CouchPotato::Database.new(stub('couchrest db', :info => nil, :get => {'ruby_class' => 'DbTestUser'}))
         | 
| 33 | 
            +
                user.should_receive(:database=).with(db)
         | 
| 34 | 
            +
                db.load '1'
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              it "should load namespaced models" do
         | 
| 38 | 
            +
                db = CouchPotato::Database.new(stub('couchrest db', :info => nil, :get => {'ruby_class' => 'Parent::Child'}))
         | 
| 39 | 
            +
                db.load('1').class.should == Parent::Child
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
            end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            describe CouchPotato::Database, 'save_document' do
         | 
| 44 | 
            +
              it "should set itself on the model for a new object before doing anything else" do
         | 
| 45 | 
            +
                db = CouchPotato::Database.new(stub('couchrest db', :info => nil))
         | 
| 46 | 
            +
                user = stub('user', :new? => true, :valid? => false).as_null_object
         | 
| 47 | 
            +
                user.should_receive(:database=).with(db)
         | 
| 48 | 
            +
                db.save_document user
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
            end
         | 
| @@ -0,0 +1,131 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class Plate
         | 
| 4 | 
            +
              include CouchPotato::Persistence
         | 
| 5 | 
            +
              
         | 
| 6 | 
            +
              property :food
         | 
| 7 | 
            +
            end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            describe 'dirty attribute tracking' do
         | 
| 10 | 
            +
              before(:each) do
         | 
| 11 | 
            +
                @couchrest_db = stub('database', :save_doc => {'id' => '1', 'rev' => '2'}, :info => nil)
         | 
| 12 | 
            +
                @db = CouchPotato::Database.new(@couchrest_db)
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
              
         | 
| 15 | 
            +
              describe "save" do
         | 
| 16 | 
            +
                it "should not save when nothing dirty" do
         | 
| 17 | 
            +
                  plate = Plate.new :food => 'sushi'
         | 
| 18 | 
            +
                  @db.save_document!(plate)
         | 
| 19 | 
            +
                  @couchrest_db.should_not_receive(:save_doc)
         | 
| 20 | 
            +
                  @db.save_document(plate)
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
                
         | 
| 23 | 
            +
                it "should return true when not dirty" do
         | 
| 24 | 
            +
                  plate = Plate.new :food => 'sushi'
         | 
| 25 | 
            +
                  @db.save_document!(plate)
         | 
| 26 | 
            +
                  @db.save_document(plate).should be_true
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
                
         | 
| 29 | 
            +
                it "should save when there are dirty attributes" do
         | 
| 30 | 
            +
                  plate = Plate.new :food => 'sushi'
         | 
| 31 | 
            +
                  @db.save_document!(plate)
         | 
| 32 | 
            +
                  plate.food = 'burger'
         | 
| 33 | 
            +
                  @couchrest_db.should_receive(:save_doc)
         | 
| 34 | 
            +
                  @db.save_document(plate)
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                it "should correctly track dirty hashes (deep clone)" do
         | 
| 38 | 
            +
                  plate = Plate.new :food => {:veggies => ['carrots', 'peas']}
         | 
| 39 | 
            +
                  @db.save_document(plate)
         | 
| 40 | 
            +
                  plate.food[:veggies] << 'beans'
         | 
| 41 | 
            +
                  @couchrest_db.should_receive(:save_doc)
         | 
| 42 | 
            +
                  @db.save_document(plate)
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                it "should correctly track dirty hashes (deep clone) after a save" do
         | 
| 46 | 
            +
                  plate = Plate.new :food => {:veggies => ['carrots', 'peas']}
         | 
| 47 | 
            +
                  @db.save_document(plate)
         | 
| 48 | 
            +
                  plate.food[:veggies] << 'beans'
         | 
| 49 | 
            +
                  @db.save_document(plate)
         | 
| 50 | 
            +
                  plate.food[:veggies] << 'cauliflower'
         | 
| 51 | 
            +
                  @couchrest_db.should_receive(:save_doc)
         | 
| 52 | 
            +
                  @db.save_document(plate)
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
              
         | 
| 56 | 
            +
              describe "newly created object" do
         | 
| 57 | 
            +
                
         | 
| 58 | 
            +
                before(:each) do
         | 
| 59 | 
            +
                  @plate = Plate.new :food => 'sushi'
         | 
| 60 | 
            +
                end
         | 
| 61 | 
            +
                
         | 
| 62 | 
            +
                describe "access old values" do
         | 
| 63 | 
            +
                  it "should return the old value" do
         | 
| 64 | 
            +
                    @plate.food = 'burger'
         | 
| 65 | 
            +
                    @plate.food_was.should == 'sushi'
         | 
| 66 | 
            +
                  end
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                describe "check for dirty" do
         | 
| 70 | 
            +
                  it "should return true if attribute changed" do
         | 
| 71 | 
            +
                    @plate.food = 'burger'
         | 
| 72 | 
            +
                    @plate.should be_food_changed
         | 
| 73 | 
            +
                  end
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                  it "should return false if attribute not changed" do
         | 
| 76 | 
            +
                    @plate.should_not be_food_changed
         | 
| 77 | 
            +
                  end
         | 
| 78 | 
            +
                  
         | 
| 79 | 
            +
                  it "should return false if attribute forced not changed" do
         | 
| 80 | 
            +
                    @plate.food = 'burger'
         | 
| 81 | 
            +
                    @plate.food_not_changed
         | 
| 82 | 
            +
                    @plate.should_not be_food_changed
         | 
| 83 | 
            +
                  end
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
              end
         | 
| 86 | 
            +
              
         | 
| 87 | 
            +
              describe "object loaded from database" do
         | 
| 88 | 
            +
                before(:each) do
         | 
| 89 | 
            +
                  couchrest_db = stub('database', :get => {'_id' => '1', '_rev' => '2', 'food' => 'sushi', 'ruby_class' => 'Plate'}, :info => nil)
         | 
| 90 | 
            +
                  @plate = CouchPotato::Database.new(couchrest_db).load_document '1'
         | 
| 91 | 
            +
                end
         | 
| 92 | 
            +
                
         | 
| 93 | 
            +
                describe "access old values" do
         | 
| 94 | 
            +
                  it "should return the old value" do
         | 
| 95 | 
            +
                    @plate.food = 'burger'
         | 
| 96 | 
            +
                    @plate.food_was.should == 'sushi'
         | 
| 97 | 
            +
                  end
         | 
| 98 | 
            +
                end
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                describe "check for dirty" do
         | 
| 101 | 
            +
                  it "should return true if attribute changed" do
         | 
| 102 | 
            +
                    @plate.food = 'burger'
         | 
| 103 | 
            +
                    @plate.should be_food_changed
         | 
| 104 | 
            +
                  end
         | 
| 105 | 
            +
                  
         | 
| 106 | 
            +
                  it "should return true if array attribute changed" do
         | 
| 107 | 
            +
                    couchrest_db = stub('database', :get => {'_id' => '1', '_rev' => '2', 'food' => ['sushi'], 'ruby_class' => 'Plate'}, :info => nil)
         | 
| 108 | 
            +
                    plate = CouchPotato::Database.new(couchrest_db).load_document '1'
         | 
| 109 | 
            +
                    plate.food << 'burger'
         | 
| 110 | 
            +
                    plate.should be_food_changed
         | 
| 111 | 
            +
                  end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                  it "should return false if attribute not changed" do
         | 
| 114 | 
            +
                    @plate.should_not be_food_changed
         | 
| 115 | 
            +
                  end
         | 
| 116 | 
            +
                end
         | 
| 117 | 
            +
              end
         | 
| 118 | 
            +
              
         | 
| 119 | 
            +
              
         | 
| 120 | 
            +
              describe "after save" do
         | 
| 121 | 
            +
                it "should reset all attributes to not dirty" do
         | 
| 122 | 
            +
                  couchrest_db = stub('database', :get => {'_id' => '1', '_rev' => '2', 'food' => 'sushi', 'ruby_class' => 'Plate'}, :info => nil, :save_doc => {})
         | 
| 123 | 
            +
                  db = CouchPotato::Database.new(couchrest_db)
         | 
| 124 | 
            +
                  @plate = db.load_document '1'
         | 
| 125 | 
            +
                  @plate.food = 'burger'
         | 
| 126 | 
            +
                  db.save! @plate
         | 
| 127 | 
            +
                  @plate.should_not be_food_changed
         | 
| 128 | 
            +
                end
         | 
| 129 | 
            +
              end
         | 
| 130 | 
            +
              
         | 
| 131 | 
            +
            end
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe String, 'camelize' do
         | 
| 4 | 
            +
              it "should camelize a string" do
         | 
| 5 | 
            +
                'my_string'.camelize.should == 'MyString'
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
            end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            describe String, 'underscore' do
         | 
| 10 | 
            +
              it "should underscore a string" do
         | 
| 11 | 
            +
                'MyString'.underscore.should == 'my_string'
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe CouchPotato::View::ViewQuery, 'query_view' do
         | 
| 4 | 
            +
              it "should not pass a key if conditions are empty" do
         | 
| 5 | 
            +
                db = mock 'db'
         | 
| 6 | 
            +
                db.should_receive(:view).with(anything, {})
         | 
| 7 | 
            +
                CouchPotato::View::ViewQuery.new(db, '', '', '', '').query_view!
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
            end
         | 
    
        data/spec/update_spec.rb
    ADDED
    
    | @@ -0,0 +1,40 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe "create" do
         | 
| 4 | 
            +
              before(:all) do
         | 
| 5 | 
            +
                recreate_db
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
              
         | 
| 8 | 
            +
              before(:each) do
         | 
| 9 | 
            +
                @comment = Comment.new :title => 'my_title'
         | 
| 10 | 
            +
                CouchPotato.database.save_document! @comment
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
              
         | 
| 13 | 
            +
              it "should update the revision" do
         | 
| 14 | 
            +
                old_rev = @comment._rev
         | 
| 15 | 
            +
                @comment.title = 'xyz'
         | 
| 16 | 
            +
                CouchPotato.database.save_document! @comment
         | 
| 17 | 
            +
                @comment._rev.should_not == old_rev
         | 
| 18 | 
            +
                @comment._rev.should_not be_nil
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
              
         | 
| 21 | 
            +
              it "should not update created at" do
         | 
| 22 | 
            +
                old_created_at = @comment.created_at
         | 
| 23 | 
            +
                @comment.title = 'xyz'
         | 
| 24 | 
            +
                CouchPotato.database.save_document! @comment
         | 
| 25 | 
            +
                @comment.created_at.should == old_created_at
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
              
         | 
| 28 | 
            +
              it "should update updated at" do
         | 
| 29 | 
            +
                old_updated_at = @comment.updated_at
         | 
| 30 | 
            +
                @comment.title = 'xyz'
         | 
| 31 | 
            +
                CouchPotato.database.save_document! @comment
         | 
| 32 | 
            +
                @comment.updated_at.should > old_updated_at
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
              
         | 
| 35 | 
            +
              it "should update the attributes" do
         | 
| 36 | 
            +
                @comment.title = 'new title'
         | 
| 37 | 
            +
                CouchPotato.database.save_document! @comment
         | 
| 38 | 
            +
                CouchPotato.couchrest_database.get("#{@comment.id}")['title'].should == 'new title'
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,153 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            name: couch_potato
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              version: 0.2.12
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors: 
         | 
| 7 | 
            +
            - Alexander Lang
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            date: 2009-09-20 00:00:00 +02:00
         | 
| 13 | 
            +
            default_executable: 
         | 
| 14 | 
            +
            dependencies: 
         | 
| 15 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 16 | 
            +
              name: json
         | 
| 17 | 
            +
              type: :runtime
         | 
| 18 | 
            +
              version_requirement: 
         | 
| 19 | 
            +
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 20 | 
            +
                requirements: 
         | 
| 21 | 
            +
                - - ">="
         | 
| 22 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 23 | 
            +
                    version: "0"
         | 
| 24 | 
            +
                version: 
         | 
| 25 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 26 | 
            +
              name: validatable
         | 
| 27 | 
            +
              type: :runtime
         | 
| 28 | 
            +
              version_requirement: 
         | 
| 29 | 
            +
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 30 | 
            +
                requirements: 
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 33 | 
            +
                    version: "0"
         | 
| 34 | 
            +
                version: 
         | 
| 35 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 36 | 
            +
              name: couchrest
         | 
| 37 | 
            +
              type: :runtime
         | 
| 38 | 
            +
              version_requirement: 
         | 
| 39 | 
            +
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 40 | 
            +
                requirements: 
         | 
| 41 | 
            +
                - - ">="
         | 
| 42 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 43 | 
            +
                    version: "0.24"
         | 
| 44 | 
            +
                version: 
         | 
| 45 | 
            +
            description: Ruby persistence layer for CouchDB
         | 
| 46 | 
            +
            email: alex@upstream-berlin.com
         | 
| 47 | 
            +
            executables: []
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            extensions: []
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            extra_rdoc_files: 
         | 
| 52 | 
            +
            - README.md
         | 
| 53 | 
            +
            files: 
         | 
| 54 | 
            +
            - CHANGES.md
         | 
| 55 | 
            +
            - MIT-LICENSE.txt
         | 
| 56 | 
            +
            - README.md
         | 
| 57 | 
            +
            - VERSION.yml
         | 
| 58 | 
            +
            - init.rb
         | 
| 59 | 
            +
            - lib/core_ext/date.rb
         | 
| 60 | 
            +
            - lib/core_ext/object.rb
         | 
| 61 | 
            +
            - lib/core_ext/string.rb
         | 
| 62 | 
            +
            - lib/core_ext/symbol.rb
         | 
| 63 | 
            +
            - lib/core_ext/time.rb
         | 
| 64 | 
            +
            - lib/couch_potato.rb
         | 
| 65 | 
            +
            - lib/couch_potato/database.rb
         | 
| 66 | 
            +
            - lib/couch_potato/persistence.rb
         | 
| 67 | 
            +
            - lib/couch_potato/persistence/attachments.rb
         | 
| 68 | 
            +
            - lib/couch_potato/persistence/callbacks.rb
         | 
| 69 | 
            +
            - lib/couch_potato/persistence/dirty_attributes.rb
         | 
| 70 | 
            +
            - lib/couch_potato/persistence/ghost_attributes.rb
         | 
| 71 | 
            +
            - lib/couch_potato/persistence/json.rb
         | 
| 72 | 
            +
            - lib/couch_potato/persistence/magic_timestamps.rb
         | 
| 73 | 
            +
            - lib/couch_potato/persistence/properties.rb
         | 
| 74 | 
            +
            - lib/couch_potato/persistence/simple_property.rb
         | 
| 75 | 
            +
            - lib/couch_potato/persistence/validation.rb
         | 
| 76 | 
            +
            - lib/couch_potato/view/base_view_spec.rb
         | 
| 77 | 
            +
            - lib/couch_potato/view/custom_view_spec.rb
         | 
| 78 | 
            +
            - lib/couch_potato/view/custom_views.rb
         | 
| 79 | 
            +
            - lib/couch_potato/view/model_view_spec.rb
         | 
| 80 | 
            +
            - lib/couch_potato/view/properties_view_spec.rb
         | 
| 81 | 
            +
            - lib/couch_potato/view/raw_view_spec.rb
         | 
| 82 | 
            +
            - lib/couch_potato/view/view_query.rb
         | 
| 83 | 
            +
            - rails/init.rb
         | 
| 84 | 
            +
            - spec/attachments_spec.rb
         | 
| 85 | 
            +
            - spec/callbacks_spec.rb
         | 
| 86 | 
            +
            - spec/create_spec.rb
         | 
| 87 | 
            +
            - spec/custom_view_spec.rb
         | 
| 88 | 
            +
            - spec/default_property_spec.rb
         | 
| 89 | 
            +
            - spec/destroy_spec.rb
         | 
| 90 | 
            +
            - spec/fixtures/address.rb
         | 
| 91 | 
            +
            - spec/fixtures/person.rb
         | 
| 92 | 
            +
            - spec/property_spec.rb
         | 
| 93 | 
            +
            - spec/spec.opts
         | 
| 94 | 
            +
            - spec/spec_helper.rb
         | 
| 95 | 
            +
            - spec/unit/attributes_spec.rb
         | 
| 96 | 
            +
            - spec/unit/callbacks_spec.rb
         | 
| 97 | 
            +
            - spec/unit/couch_potato_spec.rb
         | 
| 98 | 
            +
            - spec/unit/create_spec.rb
         | 
| 99 | 
            +
            - spec/unit/customs_views_spec.rb
         | 
| 100 | 
            +
            - spec/unit/database_spec.rb
         | 
| 101 | 
            +
            - spec/unit/dirty_attributes_spec.rb
         | 
| 102 | 
            +
            - spec/unit/string_spec.rb
         | 
| 103 | 
            +
            - spec/unit/view_query_spec.rb
         | 
| 104 | 
            +
            - spec/update_spec.rb
         | 
| 105 | 
            +
            has_rdoc: true
         | 
| 106 | 
            +
            homepage: http://github.com/langalex/couch_potato
         | 
| 107 | 
            +
            licenses: []
         | 
| 108 | 
            +
             | 
| 109 | 
            +
            post_install_message: 
         | 
| 110 | 
            +
            rdoc_options: 
         | 
| 111 | 
            +
            - --charset=UTF-8
         | 
| 112 | 
            +
            require_paths: 
         | 
| 113 | 
            +
            - lib
         | 
| 114 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 115 | 
            +
              requirements: 
         | 
| 116 | 
            +
              - - ">="
         | 
| 117 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 118 | 
            +
                  version: "0"
         | 
| 119 | 
            +
              version: 
         | 
| 120 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 121 | 
            +
              requirements: 
         | 
| 122 | 
            +
              - - ">="
         | 
| 123 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 124 | 
            +
                  version: "0"
         | 
| 125 | 
            +
              version: 
         | 
| 126 | 
            +
            requirements: []
         | 
| 127 | 
            +
             | 
| 128 | 
            +
            rubyforge_project: 
         | 
| 129 | 
            +
            rubygems_version: 1.3.5
         | 
| 130 | 
            +
            signing_key: 
         | 
| 131 | 
            +
            specification_version: 3
         | 
| 132 | 
            +
            summary: Ruby persistence layer for CouchDB
         | 
| 133 | 
            +
            test_files: 
         | 
| 134 | 
            +
            - spec/attachments_spec.rb
         | 
| 135 | 
            +
            - spec/callbacks_spec.rb
         | 
| 136 | 
            +
            - spec/create_spec.rb
         | 
| 137 | 
            +
            - spec/custom_view_spec.rb
         | 
| 138 | 
            +
            - spec/default_property_spec.rb
         | 
| 139 | 
            +
            - spec/destroy_spec.rb
         | 
| 140 | 
            +
            - spec/fixtures/address.rb
         | 
| 141 | 
            +
            - spec/fixtures/person.rb
         | 
| 142 | 
            +
            - spec/property_spec.rb
         | 
| 143 | 
            +
            - spec/spec_helper.rb
         | 
| 144 | 
            +
            - spec/unit/attributes_spec.rb
         | 
| 145 | 
            +
            - spec/unit/callbacks_spec.rb
         | 
| 146 | 
            +
            - spec/unit/couch_potato_spec.rb
         | 
| 147 | 
            +
            - spec/unit/create_spec.rb
         | 
| 148 | 
            +
            - spec/unit/customs_views_spec.rb
         | 
| 149 | 
            +
            - spec/unit/database_spec.rb
         | 
| 150 | 
            +
            - spec/unit/dirty_attributes_spec.rb
         | 
| 151 | 
            +
            - spec/unit/string_spec.rb
         | 
| 152 | 
            +
            - spec/unit/view_query_spec.rb
         | 
| 153 | 
            +
            - spec/update_spec.rb
         |