Merge branch 'master' of github.com:couchrest/couchrest_model
Conflicts: lib/couchrest/model/base.rb
This commit is contained in:
commit
31b52ba012
|
@ -70,6 +70,10 @@ The example config above for example would use a database called "project_test".
|
||||||
|
|
||||||
## Generators
|
## Generators
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
$ rails generate couchrest_model:config
|
||||||
|
|
||||||
### Model
|
### Model
|
||||||
|
|
||||||
$ rails generate model person --orm=couchrest_model
|
$ rails generate model person --orm=couchrest_model
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Minor Fixes
|
* Minor Fixes
|
||||||
* Validation callbacks now support context (thanks kostia)
|
* Validation callbacks now support context (thanks kostia)
|
||||||
* Document comparisons now performed using database and document ID (pointer by neocsr)
|
* Document comparisons now performed using database and document ID (pointer by neocsr)
|
||||||
|
* Automatic config generation now supported (thanks lucasrenan)
|
||||||
|
|
||||||
## 1.1.0.rc1 - 2011-06-08
|
## 1.1.0.rc1 - 2011-06-08
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
require 'rails/generators/couchrest_model'
|
||||||
|
|
||||||
|
module CouchrestModel
|
||||||
|
module Generators
|
||||||
|
class ConfigGenerator < Rails::Generators::Base
|
||||||
|
source_root File.expand_path('../templates', __FILE__)
|
||||||
|
|
||||||
|
def app_name
|
||||||
|
Rails::Application.subclasses.first.parent.to_s.underscore
|
||||||
|
end
|
||||||
|
|
||||||
|
def copy_configuration_file
|
||||||
|
template 'couchdb.yml', File.join('config', "couchdb.yml")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,21 @@
|
||||||
|
development: &development
|
||||||
|
protocol: 'http'
|
||||||
|
host: localhost
|
||||||
|
port: 5984
|
||||||
|
prefix: <%= app_name %>
|
||||||
|
suffix: development
|
||||||
|
username:
|
||||||
|
password:
|
||||||
|
|
||||||
|
test:
|
||||||
|
<<: *development
|
||||||
|
suffix: test
|
||||||
|
|
||||||
|
production:
|
||||||
|
protocol: 'https'
|
||||||
|
host: localhost
|
||||||
|
port: 5984
|
||||||
|
prefix: <%= app_name %>
|
||||||
|
suffix: production
|
||||||
|
username: root
|
||||||
|
password: 123
|
|
@ -110,14 +110,22 @@ describe "Model Base" do
|
||||||
describe "#persisted?" do
|
describe "#persisted?" do
|
||||||
context "when the document is new" do
|
context "when the document is new" do
|
||||||
it "returns false" do
|
it "returns false" do
|
||||||
@obj.persisted?.should == false
|
@obj.persisted?.should be_false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the document is not new" do
|
context "when the document is not new" do
|
||||||
it "returns id" do
|
it "returns id" do
|
||||||
@obj.save
|
@obj.save
|
||||||
@obj.persisted?.should == true
|
@obj.persisted?.should be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when the document is destroyed" do
|
||||||
|
it "returns false" do
|
||||||
|
@obj.save
|
||||||
|
@obj.destroy
|
||||||
|
@obj.persisted?.should be_false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue