speedmax-couch_potato 0.2.0
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/MIT-LICENSE.txt +19 -0
- data/README.md +260 -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 +15 -0
- data/lib/core_ext/time.rb +11 -0
- data/lib/couch_potato/database.rb +90 -0
- data/lib/couch_potato/persistence/belongs_to_property.rb +58 -0
- data/lib/couch_potato/persistence/callbacks.rb +108 -0
- data/lib/couch_potato/persistence/dirty_attributes.rb +26 -0
- data/lib/couch_potato/persistence/inline_collection.rb +14 -0
- data/lib/couch_potato/persistence/json.rb +41 -0
- data/lib/couch_potato/persistence/magic_timestamps.rb +13 -0
- data/lib/couch_potato/persistence/properties.rb +42 -0
- data/lib/couch_potato/persistence/simple_property.rb +64 -0
- data/lib/couch_potato/persistence.rb +57 -0
- data/lib/couch_potato/view/base_view_spec.rb +20 -0
- data/lib/couch_potato/view/custom_view_spec.rb +26 -0
- data/lib/couch_potato/view/custom_views.rb +30 -0
- data/lib/couch_potato/view/model_view_spec.rb +39 -0
- data/lib/couch_potato/view/properties_view_spec.rb +35 -0
- data/lib/couch_potato/view/raw_view_spec.rb +21 -0
- data/lib/couch_potato/view/view_query.rb +45 -0
- data/lib/couch_potato.rb +37 -0
- data/rails/init.rb +7 -0
- data/spec/callbacks_spec.rb +245 -0
- data/spec/create_spec.rb +22 -0
- data/spec/custom_view_spec.rb +118 -0
- data/spec/destroy_spec.rb +29 -0
- data/spec/property_spec.rb +64 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/unit/attributes_spec.rb +26 -0
- data/spec/unit/create_spec.rb +58 -0
- data/spec/unit/dirty_attributes_spec.rb +100 -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 +127 -0
@@ -0,0 +1,118 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
class Build
|
4
|
+
include CouchPotato::Persistence
|
5
|
+
|
6
|
+
property :state
|
7
|
+
property :time
|
8
|
+
|
9
|
+
view :timeline, :key => :time
|
10
|
+
view :minimal_timeline, :key => :time, :properties => [:state], :type => :properties
|
11
|
+
view :key_array_timeline, :key => [:time, :state]
|
12
|
+
view :custom_timeline, :map => "function(doc) { emit(doc._id, {state: 'custom_' + doc.state}); }", :type => :custom
|
13
|
+
view :custom_timeline_returns_docs, :map => "function(doc) { emit(doc._id, null); }", :include_docs => true, :type => :custom
|
14
|
+
view :raw, :type => :raw, :map => "function(doc) {emit(doc._id, doc.state)}"
|
15
|
+
view :filtered_raw, :type => :raw, :map => "function(doc) {emit(doc._id, doc.state)}", :results_filter => lambda{|res| res['rows'].map{|row| row['value']}}
|
16
|
+
view :with_view_options, :group => true, :key => :time
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'view' do
|
20
|
+
before(:each) do
|
21
|
+
recreate_db
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return instances of the class" do
|
25
|
+
CouchPotato.database.save_document Build.new(:state => 'success', :time => '2008-01-01')
|
26
|
+
CouchPotato.database.view(Build.timeline).map(&:class).should == [Build]
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should pass the view options to the viw query" do
|
30
|
+
query = mock 'query'
|
31
|
+
CouchPotato::View::ViewQuery.stub!(:new).and_return(query)
|
32
|
+
query.should_receive(:query_view!).with(hash_including(:key => 1)).and_return('rows' => [])
|
33
|
+
CouchPotato.database.view Build.timeline(:key => 1)
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "properties defined" do
|
37
|
+
it "should assign the configured properties" do
|
38
|
+
CouchPotato.couchrest_database.save_doc({:state => 'success', :time => '2008-01-01'})
|
39
|
+
CouchPotato.database.view(Build.minimal_timeline).first.state.should == 'success'
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should not assign the properties not configured" do
|
43
|
+
CouchPotato.couchrest_database.save_doc({:state => 'success', :time => '2008-01-01'})
|
44
|
+
CouchPotato.database.view(Build.minimal_timeline).first.time.should be_nil
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should assign the id even if it is not configured" do
|
48
|
+
id = CouchPotato.couchrest_database.save_doc({:state => 'success', :time => '2008-01-01'})['id']
|
49
|
+
CouchPotato.database.view(Build.minimal_timeline).first._id.should == id
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "no properties defined" do
|
54
|
+
it "should assign all properties to the objects by default" do
|
55
|
+
id = CouchPotato.couchrest_database.save_doc({:state => 'success', :time => '2008-01-01'})['id']
|
56
|
+
result = CouchPotato.database.view(Build.timeline).first
|
57
|
+
result.state.should == 'success'
|
58
|
+
result.time.should == '2008-01-01'
|
59
|
+
result._id.should == id
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "map function given" do
|
64
|
+
it "should still return instances of the class" do
|
65
|
+
CouchPotato.couchrest_database.save_doc({:state => 'success', :time => '2008-01-01'})
|
66
|
+
CouchPotato.database.view(Build.custom_timeline).map(&:class).should == [Build]
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should assign the properties from the value" do
|
70
|
+
CouchPotato.couchrest_database.save_doc({:state => 'success', :time => '2008-01-01'})
|
71
|
+
CouchPotato.database.view(Build.custom_timeline).map(&:state).should == ['custom_success']
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should leave the other properties blank" do
|
75
|
+
CouchPotato.couchrest_database.save_doc({:state => 'success', :time => '2008-01-01'})
|
76
|
+
CouchPotato.database.view(Build.custom_timeline).map(&:time).should == [nil]
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "that returns null documents" do
|
80
|
+
it "should return instances of the class" do
|
81
|
+
CouchPotato.couchrest_database.save_doc({:state => 'success', :time => '2008-01-01'})
|
82
|
+
CouchPotato.database.view(Build.custom_timeline_returns_docs).map(&:class).should == [Build]
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should assign the properties from the value" do
|
86
|
+
CouchPotato.couchrest_database.save_doc({:state => 'success', :time => '2008-01-01'})
|
87
|
+
CouchPotato.database.view(Build.custom_timeline_returns_docs).map(&:state).should == ['success']
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "with array as key" do
|
93
|
+
it "should create a map function with the composite key" do
|
94
|
+
CouchPotato::View::ViewQuery.should_receive(:new).with(anything, anything, anything, string_matching(/emit\(\[doc\['time'\], doc\['state'\]\]/), anything).and_return(stub('view query').as_null_object)
|
95
|
+
CouchPotato.database.view Build.key_array_timeline
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "raw view" do
|
100
|
+
it "should return the raw data" do
|
101
|
+
CouchPotato.database.save_document Build.new(:state => 'success', :time => '2008-01-01')
|
102
|
+
CouchPotato.database.view(Build.raw)['rows'][0]['value'].should == 'success'
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should return filtred raw data" do
|
106
|
+
CouchPotato.database.save_document Build.new(:state => 'success', :time => '2008-01-01')
|
107
|
+
CouchPotato.database.view(Build.filtered_raw).should == ['success']
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should pass view options declared in the view declaration to the query" do
|
111
|
+
view_query = mock 'view_query'
|
112
|
+
CouchPotato::View::ViewQuery.stub!(:new).and_return(view_query)
|
113
|
+
view_query.should_receive(:query_view!).with(hash_including(:group => true)).and_return({'rows' => []})
|
114
|
+
CouchPotato.database.view(Build.with_view_options)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe 'destroy' do
|
4
|
+
before(:all) do
|
5
|
+
recreate_db
|
6
|
+
end
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
@comment = Comment.new :title => 'title'
|
10
|
+
CouchPotato.database.save_document! @comment
|
11
|
+
@comment_id = @comment.id
|
12
|
+
CouchPotato.database.destroy_document @comment
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should unset the id" do
|
16
|
+
@comment._id.should be_nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should unset the revision" do
|
20
|
+
@comment._rev.should be_nil
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should remove the document from the database" do
|
24
|
+
lambda {
|
25
|
+
CouchPotato.couchrest_database.get(@comment_id).should
|
26
|
+
}.should raise_error(RestClient::ResourceNotFound)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
class Watch
|
4
|
+
include CouchPotato::Persistence
|
5
|
+
|
6
|
+
property :time, :type => Time
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
describe 'properties' do
|
11
|
+
before(:all) do
|
12
|
+
recreate_db
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return the property names" do
|
16
|
+
Comment.property_names.should == [:created_at, :updated_at, :title, :commenter]
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should persist a string" do
|
20
|
+
c = Comment.new :title => 'my title'
|
21
|
+
CouchPotato.database.save_document! c
|
22
|
+
c = CouchPotato.database.load_document c.id
|
23
|
+
c.title.should == 'my title'
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should persist a number" do
|
27
|
+
c = Comment.new :title => 3
|
28
|
+
CouchPotato.database.save_document! c
|
29
|
+
c = CouchPotato.database.load_document c.id
|
30
|
+
c.title.should == 3
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should persist a hash" do
|
34
|
+
c = Comment.new :title => {'key' => 'value'}
|
35
|
+
CouchPotato.database.save_document! c
|
36
|
+
c = CouchPotato.database.load_document c.id
|
37
|
+
c.title.should == {'key' => 'value'}
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should persist a Time object" do
|
41
|
+
w = Watch.new :time => Time.now
|
42
|
+
CouchPotato.database.save_document! w
|
43
|
+
w = CouchPotato.database.load_document w.id
|
44
|
+
w.time.year.should == Time.now.year
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "predicate" do
|
48
|
+
it "should return true if property set" do
|
49
|
+
Comment.new(:title => 'title').title?.should be_true
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should return false if property nil" do
|
53
|
+
Comment.new.title?.should be_false
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should return false if property false" do
|
57
|
+
Comment.new(:title => false).title?.should be_false
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should return false if property blank" do
|
61
|
+
Comment.new(:title => '').title?.should be_false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec'
|
3
|
+
|
4
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
5
|
+
|
6
|
+
require 'couch_potato'
|
7
|
+
|
8
|
+
CouchPotato::Config.database_name = 'couch_potato_test'
|
9
|
+
|
10
|
+
|
11
|
+
class Comment
|
12
|
+
include CouchPotato::Persistence
|
13
|
+
|
14
|
+
validates_presence_of :title
|
15
|
+
|
16
|
+
property :title
|
17
|
+
belongs_to :commenter
|
18
|
+
end
|
19
|
+
|
20
|
+
def recreate_db
|
21
|
+
CouchPotato.couchrest_database.delete! rescue nil
|
22
|
+
CouchPotato.couchrest_database.server.create_db CouchPotato::Config.database_name
|
23
|
+
end
|
24
|
+
recreate_db
|
25
|
+
|
26
|
+
Spec::Matchers.define :string_matching do |regex|
|
27
|
+
match do |string|
|
28
|
+
string =~ regex
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
class Plant
|
4
|
+
include CouchPotato::Persistence
|
5
|
+
property :leaf_count
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "attributes" do
|
9
|
+
|
10
|
+
describe 'attributes=' do
|
11
|
+
it "should assign the attributes" do
|
12
|
+
plant = Plant.new
|
13
|
+
plant.attributes = {:leaf_count => 1}
|
14
|
+
plant.leaf_count.should == 1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "attributes" do
|
19
|
+
it "should return the attributes" do
|
20
|
+
plant = Plant.new(:leaf_count => 1)
|
21
|
+
plant.attributes.should == {:leaf_count => 1, :created_at => nil, :updated_at => nil}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
@@ -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'})).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')).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,100 @@
|
|
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'})
|
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 save when there are dirty attributes" do
|
24
|
+
plate = Plate.new :food => 'sushi'
|
25
|
+
@db.save_document!(plate)
|
26
|
+
plate.food = 'burger'
|
27
|
+
@couchrest_db.should_receive(:save_doc)
|
28
|
+
@db.save_document(plate)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "newly created object" do
|
33
|
+
|
34
|
+
before(:each) do
|
35
|
+
@plate = Plate.new :food => 'sushi'
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "access old values" do
|
39
|
+
it "should return the old value" do
|
40
|
+
@plate.food = 'burger'
|
41
|
+
@plate.food_was.should == 'sushi'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "check for dirty" do
|
46
|
+
it "should return true if attribute changed" do
|
47
|
+
@plate.food = 'burger'
|
48
|
+
@plate.should be_food_changed
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return false if attribute not changed" do
|
52
|
+
@plate.should_not be_food_changed
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should return false if attribute forced not changed" do
|
56
|
+
@plate.food = 'burger'
|
57
|
+
@plate.food_not_changed
|
58
|
+
@plate.should_not be_food_changed
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "object loaded from database" do
|
64
|
+
before(:each) do
|
65
|
+
couchrest_db = stub('database', :get => {'_id' => '1', '_rev' => '2', 'food' => 'sushi', 'ruby_class' => 'Plate'})
|
66
|
+
@plate = CouchPotato::Database.new(couchrest_db).load_document '1'
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "access old values" do
|
70
|
+
it "should return the old value" do
|
71
|
+
@plate.food = 'burger'
|
72
|
+
@plate.food_was.should == 'sushi'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "check for dirty" do
|
77
|
+
it "should return true if attribute changed" do
|
78
|
+
@plate.food = 'burger'
|
79
|
+
@plate.should be_food_changed
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should return false if attribute not changed" do
|
83
|
+
@plate.should_not be_food_changed
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
describe "after save" do
|
90
|
+
it "should reset all attributes to not dirty" do
|
91
|
+
couchrest_db = stub('database', :get => {'_id' => '1', '_rev' => '2', 'food' => 'sushi', 'ruby_class' => 'Plate'}, :save_doc => {})
|
92
|
+
db = CouchPotato::Database.new(couchrest_db)
|
93
|
+
@plate = db.load_document '1'
|
94
|
+
@plate.food = 'burger'
|
95
|
+
db.save! @plate
|
96
|
+
@plate.should_not be_food_changed
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
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,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: speedmax-couch_potato
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Lang
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-04-28 00:00:00 -07: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: jchris-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.9.12
|
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
|
+
- MIT-LICENSE.txt
|
55
|
+
- README.md
|
56
|
+
- VERSION.yml
|
57
|
+
- lib/core_ext
|
58
|
+
- lib/core_ext/date.rb
|
59
|
+
- lib/core_ext/object.rb
|
60
|
+
- lib/core_ext/string.rb
|
61
|
+
- lib/core_ext/time.rb
|
62
|
+
- lib/couch_potato
|
63
|
+
- lib/couch_potato/database.rb
|
64
|
+
- lib/couch_potato/persistence
|
65
|
+
- lib/couch_potato/persistence/belongs_to_property.rb
|
66
|
+
- lib/couch_potato/persistence/callbacks.rb
|
67
|
+
- lib/couch_potato/persistence/dirty_attributes.rb
|
68
|
+
- lib/couch_potato/persistence/inline_collection.rb
|
69
|
+
- lib/couch_potato/persistence/json.rb
|
70
|
+
- lib/couch_potato/persistence/magic_timestamps.rb
|
71
|
+
- lib/couch_potato/persistence/properties.rb
|
72
|
+
- lib/couch_potato/persistence/simple_property.rb
|
73
|
+
- lib/couch_potato/persistence.rb
|
74
|
+
- lib/couch_potato/view
|
75
|
+
- lib/couch_potato/view/base_view_spec.rb
|
76
|
+
- lib/couch_potato/view/custom_view_spec.rb
|
77
|
+
- lib/couch_potato/view/custom_views.rb
|
78
|
+
- lib/couch_potato/view/model_view_spec.rb
|
79
|
+
- lib/couch_potato/view/properties_view_spec.rb
|
80
|
+
- lib/couch_potato/view/raw_view_spec.rb
|
81
|
+
- lib/couch_potato/view/view_query.rb
|
82
|
+
- lib/couch_potato.rb
|
83
|
+
- spec/callbacks_spec.rb
|
84
|
+
- spec/create_spec.rb
|
85
|
+
- spec/custom_view_spec.rb
|
86
|
+
- spec/destroy_spec.rb
|
87
|
+
- spec/property_spec.rb
|
88
|
+
- spec/spec.opts
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- spec/unit
|
91
|
+
- spec/unit/attributes_spec.rb
|
92
|
+
- spec/unit/create_spec.rb
|
93
|
+
- spec/unit/dirty_attributes_spec.rb
|
94
|
+
- spec/unit/string_spec.rb
|
95
|
+
- spec/unit/view_query_spec.rb
|
96
|
+
- spec/update_spec.rb
|
97
|
+
- rails/init.rb
|
98
|
+
- init.rb
|
99
|
+
has_rdoc: true
|
100
|
+
homepage: http://github.com/langalex/couch_potato
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options:
|
103
|
+
- --inline-source
|
104
|
+
- --charset=UTF-8
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: "0"
|
112
|
+
version:
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: "0"
|
118
|
+
version:
|
119
|
+
requirements: []
|
120
|
+
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 1.2.0
|
123
|
+
signing_key:
|
124
|
+
specification_version: 2
|
125
|
+
summary: Ruby persistence layer for CouchDB
|
126
|
+
test_files: []
|
127
|
+
|