paginative 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paginative/models/model_extension.rb +8 -6
- data/lib/paginative/version.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +5735 -0
- data/spec/models/paginative/test_model_spec.rb +28 -4
- metadata +3 -3
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
2
|
|
3
3
|
describe TestModel do
|
4
4
|
|
@@ -20,7 +20,7 @@ describe TestModel do
|
|
20
20
|
10.times do |count|
|
21
21
|
FactoryGirl.create(:test_model, created_at: Time.now.ago(count.days))
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
TestModel.with_field_from("created_at", (Time.now.ago(5.days))).count.should eq 5
|
25
25
|
end
|
26
26
|
|
@@ -32,8 +32,8 @@ describe TestModel do
|
|
32
32
|
|
33
33
|
it "works on INT values" do
|
34
34
|
create_models
|
35
|
-
|
36
|
-
TestModel.with_field_from("id", @model3.id).should
|
35
|
+
|
36
|
+
TestModel.with_field_from("id", @model3.id).should match_array [@model4, @model5]
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -94,4 +94,28 @@ describe TestModel do
|
|
94
94
|
|
95
95
|
end
|
96
96
|
end
|
97
|
+
|
98
|
+
context "Sorting" do
|
99
|
+
before :each do
|
100
|
+
@first = FactoryGirl.create(:test_model, name: "ab", latitude: -37.5, longitude: 144)
|
101
|
+
@second = FactoryGirl.create(:test_model, name: "ba", latitude: -38, longitude: 144.5)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "defaults to ascending by name" do
|
105
|
+
|
106
|
+
expect(TestModel.with_name_from("a")).to eq [@first, @second]
|
107
|
+
end
|
108
|
+
|
109
|
+
it "can be set to descending on name" do
|
110
|
+
expect(TestModel.with_name_from("z", 25, "desc")).to eq [@second, @first]
|
111
|
+
end
|
112
|
+
|
113
|
+
it "can be set to descending on custom field" do
|
114
|
+
expect(TestModel.with_field_from("id", @second.id+1, 25, "desc")).to eq [@second, @first]
|
115
|
+
end
|
116
|
+
|
117
|
+
it "always sorts distance by ascending" do
|
118
|
+
expect(TestModel.by_distance_from(-37,144,0,2)).to eq [@first, @second]
|
119
|
+
end
|
120
|
+
end
|
97
121
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paginative
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaac Norman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
212
|
version: '0'
|
213
213
|
requirements: []
|
214
214
|
rubyforge_project:
|
215
|
-
rubygems_version: 2.2.
|
215
|
+
rubygems_version: 2.2.2
|
216
216
|
signing_key:
|
217
217
|
specification_version: 4
|
218
218
|
summary: A new way to paginate your Rails API
|