move to class_inheritable_accessor
This commit is contained in:
parent
c170008deb
commit
355d408730
2 changed files with 96 additions and 39 deletions
|
@ -29,6 +29,7 @@ class Course < CouchRest::Model
|
|||
key_accessor :title
|
||||
cast :questions, :as => [Question]
|
||||
cast :professor, :as => Person
|
||||
view_by :title
|
||||
end
|
||||
|
||||
class Article < CouchRest::Model
|
||||
|
@ -177,6 +178,25 @@ describe CouchRest::Model do
|
|||
end
|
||||
end
|
||||
|
||||
describe "finding all instances of a model" do
|
||||
before(:all) do
|
||||
WithTemplate.new('important-field' => '1').save
|
||||
WithTemplate.new('important-field' => '2').save
|
||||
WithTemplate.new('important-field' => '3').save
|
||||
WithTemplate.new('important-field' => '4').save
|
||||
end
|
||||
it "should make the design doc" do
|
||||
WithTemplate.all
|
||||
puts d = WithTemplate.design_doc.to_json
|
||||
d.should == 'xs'
|
||||
end
|
||||
it "should find all" do
|
||||
rs = WithTemplate.all :raw => true
|
||||
rs.should == 'x'
|
||||
rs.length.should == 4
|
||||
end
|
||||
end
|
||||
|
||||
describe "getting a model with a subobject field" do
|
||||
before(:all) do
|
||||
course_doc = {
|
||||
|
@ -356,6 +376,23 @@ describe CouchRest::Model do
|
|||
end
|
||||
end
|
||||
|
||||
describe "another model with a simple view" do
|
||||
before(:all) do
|
||||
Course.database.delete! rescue nil
|
||||
@db = @cr.create_db(TESTDB) rescue nil
|
||||
Course.new(:title => 'aaa').save
|
||||
Course.new(:title => 'bbb').save
|
||||
end
|
||||
it "should make the design doc" do
|
||||
doc = Course.design_doc
|
||||
doc['views']['all']['map'].should include('Course')
|
||||
end
|
||||
it "should get them" do
|
||||
rs = Course.by_title
|
||||
rs.length.should == 2
|
||||
end
|
||||
end
|
||||
|
||||
describe "a model with a compound key view" do
|
||||
before(:all) do
|
||||
written_at = Time.now - 24 * 3600 * 7
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue