couchdb_acts_as_list 0.0.1.1 → 0.0.1.2
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/README.md +3 -1
- data/couchdb_acts_as_list.gemspec +4 -0
- data/lib/couchdb_acts_as_list/version.rb +1 -1
- data/spec/position_spec.rb +76 -0
- data/spec/spec_helper.rb +27 -0
- metadata +55 -3
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CouchdbActsAsList
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Implementation of the acts as list gem for CouchDB
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -19,7 +19,9 @@ Or install it yourself as:
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
21
|
class Locale < CouchRest::Model::Base
|
|
22
|
+
|
|
22
23
|
include CouchdbActsAsList
|
|
24
|
+
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
## Instance methods
|
|
@@ -16,4 +16,8 @@ Gem::Specification.new do |gem|
|
|
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
18
|
gem.require_paths = ["lib"]
|
|
19
|
+
|
|
20
|
+
gem.add_development_dependency "rspec", ">= 2.0.0"
|
|
21
|
+
gem.add_development_dependency 'couchrest_model'
|
|
22
|
+
gem.add_development_dependency 'couchrest'
|
|
19
23
|
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe CouchdbActsAsList do
|
|
4
|
+
class Locale < CouchRest::Model::Base
|
|
5
|
+
use_database COUCH
|
|
6
|
+
include CouchdbActsAsList
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe "position" do
|
|
10
|
+
it "should create with right value" do
|
|
11
|
+
ru = Locale.create
|
|
12
|
+
en = Locale.create
|
|
13
|
+
ru.position.should == 1
|
|
14
|
+
en.position.should == 2
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should reorder after destroy" do
|
|
18
|
+
ru = Locale.create
|
|
19
|
+
en = Locale.create
|
|
20
|
+
su = Locale.create
|
|
21
|
+
en.destroy
|
|
22
|
+
ru.reload.position.should == 1
|
|
23
|
+
su.reload.position.should == 2
|
|
24
|
+
|
|
25
|
+
ru.destroy
|
|
26
|
+
su.reload.position.should == 1
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "#insert_at" do
|
|
31
|
+
it "should insert to correct position" do
|
|
32
|
+
ru = Locale.create
|
|
33
|
+
en = Locale.create
|
|
34
|
+
su = Locale.create
|
|
35
|
+
fu = Locale.create
|
|
36
|
+
|
|
37
|
+
fu.insert_at 2
|
|
38
|
+
Locale.by_position.all.map(&:position).should == [1,2,3,4]
|
|
39
|
+
Locale.by_position.all.map(&:id).should == [ru, fu, en, su].map(&:id)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should insert to correct position" do
|
|
43
|
+
ru = Locale.create
|
|
44
|
+
en = Locale.create
|
|
45
|
+
su = Locale.create
|
|
46
|
+
fu = Locale.create
|
|
47
|
+
|
|
48
|
+
fu.insert_at 2
|
|
49
|
+
Locale.by_position.all.map(&:position).should == [1,2,3,4]
|
|
50
|
+
Locale.by_position.all.map(&:id).should == [ru, fu, en, su].map(&:id)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should insert to correct position if position is less than 1" do
|
|
54
|
+
ru = Locale.create
|
|
55
|
+
en = Locale.create
|
|
56
|
+
su = Locale.create
|
|
57
|
+
fu = Locale.create
|
|
58
|
+
|
|
59
|
+
su.insert_at 0
|
|
60
|
+
Locale.by_position.all.map(&:position).should == [1,2,3,4]
|
|
61
|
+
Locale.by_position.all.map(&:id).should == [su, ru, en, fu].map(&:id)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "should insert to correct position if position is more than count of elements" do
|
|
65
|
+
ru = Locale.create
|
|
66
|
+
en = Locale.create
|
|
67
|
+
su = Locale.create
|
|
68
|
+
fu = Locale.create
|
|
69
|
+
|
|
70
|
+
ru.insert_at 10
|
|
71
|
+
Locale.by_position.all.map(&:position).should == [1,2,3,4]
|
|
72
|
+
Locale.by_position.all.map(&:id).should == [en, su, fu, ru].map(&:id)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
|
|
4
|
+
require 'couchdb_acts_as_list'
|
|
5
|
+
require 'couchrest_model'
|
|
6
|
+
|
|
7
|
+
unless defined?(COUCH)
|
|
8
|
+
COUCH_URL = "http://127.0.0.1:5984"
|
|
9
|
+
COUCH_NAME = 'couchrest-test'
|
|
10
|
+
|
|
11
|
+
COUCH = CouchRest.database!("#{COUCH_URL}/#{COUCH_NAME}")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def reset_test_db!
|
|
15
|
+
COUCH.recreate! rescue nil
|
|
16
|
+
COUCH
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
RSpec.configure do |config|
|
|
20
|
+
config.before(:each) {
|
|
21
|
+
reset_test_db!
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
config.after(:all) do
|
|
25
|
+
COUCH.delete!
|
|
26
|
+
end
|
|
27
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: couchdb_acts_as_list
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.1.
|
|
4
|
+
version: 0.0.1.2
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -10,7 +10,55 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
date: 2012-12-25 00:00:00.000000000 Z
|
|
13
|
-
dependencies:
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: rspec
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: 2.0.0
|
|
22
|
+
type: :development
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ! '>='
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: 2.0.0
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: couchrest_model
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ! '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
type: :development
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: couchrest
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
50
|
+
requirements:
|
|
51
|
+
- - ! '>='
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ! '>='
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
14
62
|
description: ''
|
|
15
63
|
email:
|
|
16
64
|
- ivan.rostovsky@gmail.com
|
|
@@ -28,6 +76,8 @@ files:
|
|
|
28
76
|
- couchdb_acts_as_list.gemspec
|
|
29
77
|
- lib/couchdb_acts_as_list.rb
|
|
30
78
|
- lib/couchdb_acts_as_list/version.rb
|
|
79
|
+
- spec/position_spec.rb
|
|
80
|
+
- spec/spec_helper.rb
|
|
31
81
|
homepage: ''
|
|
32
82
|
licenses: []
|
|
33
83
|
post_install_message:
|
|
@@ -52,4 +102,6 @@ rubygems_version: 1.8.24
|
|
|
52
102
|
signing_key:
|
|
53
103
|
specification_version: 3
|
|
54
104
|
summary: Implementation of the acts as list gem for CouchDB
|
|
55
|
-
test_files:
|
|
105
|
+
test_files:
|
|
106
|
+
- spec/position_spec.rb
|
|
107
|
+
- spec/spec_helper.rb
|