atdis 0.2 → 0.3
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.
- checksums.yaml +7 -0
- data/.ruby-version +1 -1
- data/.travis.yml +0 -1
- data/Gemfile +1 -1
- data/README.md +25 -2
- data/Rakefile +1 -1
- data/docs/ATDIS-1.0.2 Application Tracking Data Interchange Specification (v1.0.2).doc +0 -0
- data/docs/ATDIS-1.0.2 Application Tracking Data Interchange Specification (v1.0.2).pdf +0 -0
- data/lib/atdis.rb +2 -7
- data/lib/atdis/feed.rb +80 -8
- data/lib/atdis/model.rb +74 -128
- data/lib/atdis/models/address.rb +17 -0
- data/lib/atdis/models/application.rb +31 -0
- data/lib/atdis/models/authority.rb +19 -0
- data/lib/atdis/models/document.rb +16 -0
- data/lib/atdis/models/event.rb +16 -0
- data/lib/atdis/models/info.rb +81 -0
- data/lib/atdis/models/land_title_ref.rb +26 -0
- data/lib/atdis/models/location.rb +23 -0
- data/lib/atdis/models/page.rb +56 -0
- data/lib/atdis/models/pagination.rb +68 -0
- data/lib/atdis/models/person.rb +14 -0
- data/lib/atdis/models/reference.rb +13 -0
- data/lib/atdis/models/response.rb +16 -0
- data/lib/atdis/models/torrens_title.rb +24 -0
- data/lib/atdis/validators.rb +26 -10
- data/lib/atdis/version.rb +1 -1
- data/spec/atdis/feed_spec.rb +78 -22
- data/spec/atdis/model_spec.rb +80 -131
- data/spec/atdis/models/address_spec.rb +22 -0
- data/spec/atdis/models/application_spec.rb +246 -0
- data/spec/atdis/models/authority_spec.rb +34 -0
- data/spec/atdis/models/document_spec.rb +19 -0
- data/spec/atdis/models/event_spec.rb +29 -0
- data/spec/atdis/models/info_spec.rb +303 -0
- data/spec/atdis/models/land_title_ref_spec.rb +39 -0
- data/spec/atdis/models/location_spec.rb +95 -0
- data/spec/atdis/models/page_spec.rb +296 -0
- data/spec/atdis/models/pagination_spec.rb +153 -0
- data/spec/atdis/models/person_spec.rb +19 -0
- data/spec/atdis/models/reference_spec.rb +55 -0
- data/spec/atdis/models/response_spec.rb +5 -0
- data/spec/atdis/models/torrens_title_spec.rb +52 -0
- data/spec/atdis/separated_url_spec.rb +4 -4
- metadata +141 -135
- data/docs/ATDIS-1.0.7 Application Tracking Data Interchange Specification (v1.0).doc +0 -0
- data/docs/ATDIS-1.0.7 Application Tracking Data Interchange Specification (v1.0).pdf +0 -0
- data/lib/atdis/application.rb +0 -78
- data/lib/atdis/document.rb +0 -14
- data/lib/atdis/event.rb +0 -17
- data/lib/atdis/location.rb +0 -21
- data/lib/atdis/page.rb +0 -130
- data/lib/atdis/person.rb +0 -12
- data/spec/atdis/application_spec.rb +0 -539
- data/spec/atdis/document_spec.rb +0 -19
- data/spec/atdis/event_spec.rb +0 -29
- data/spec/atdis/location_spec.rb +0 -148
- data/spec/atdis/page_spec.rb +0 -492
- data/spec/atdis/person_spec.rb +0 -19
@@ -0,0 +1,296 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ATDIS::Models::Page do
|
4
|
+
it ".attribute_names" do
|
5
|
+
ATDIS::Models::Page.attribute_names.should == ["response", "count", "pagination"]
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "validations" do
|
9
|
+
context "results block that is a hash" do
|
10
|
+
before :each do
|
11
|
+
ATDIS::Models::Response.should_receive(:interpret).with(description: "application1").and_return(double(valid?: true))
|
12
|
+
end
|
13
|
+
let(:page) { ATDIS::Models::Page.new(response: {description: "application1"}) }
|
14
|
+
|
15
|
+
it do
|
16
|
+
page.should_not be_valid
|
17
|
+
page.errors.messages.should == {response: [ATDIS::ErrorMessage["should be an array", "6.4"]]}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "two valid applications no paging" do
|
22
|
+
before :each do
|
23
|
+
ATDIS::Models::Response.should_receive(:interpret).with(description: "application1").and_return(double(valid?: true))
|
24
|
+
ATDIS::Models::Response.should_receive(:interpret).with(description: "application2").and_return(double(valid?: true))
|
25
|
+
end
|
26
|
+
let(:page) { ATDIS::Models::Page.new(response: [{description: "application1"}, {description: "application2"}]) }
|
27
|
+
|
28
|
+
it {page.should be_valid}
|
29
|
+
|
30
|
+
context "with pagination" do
|
31
|
+
before :each do
|
32
|
+
page.count = 2
|
33
|
+
page.pagination = ATDIS::Models::Pagination.new(per_page: 25, current: 1, count: 2, pages: 1)
|
34
|
+
end
|
35
|
+
it { page.should be_valid }
|
36
|
+
|
37
|
+
context "count is not consistent" do
|
38
|
+
before :each do
|
39
|
+
page.count = 1
|
40
|
+
end
|
41
|
+
it do
|
42
|
+
page.should_not be_valid
|
43
|
+
page.errors.messages.should == {count: [ATDIS::ErrorMessage["is not the same as the number of applications returned", "6.4"]]}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "count is larger than number of results per page" do
|
48
|
+
before :each do
|
49
|
+
page.pagination.per_page = 1
|
50
|
+
page.pagination.count = 1
|
51
|
+
end
|
52
|
+
it do
|
53
|
+
page.should_not be_valid
|
54
|
+
page.errors.messages.should == {count: [ATDIS::ErrorMessage["should not be larger than the number of results per page", "6.4"]]}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "count is absent" do
|
59
|
+
before :each do
|
60
|
+
page.count = nil
|
61
|
+
end
|
62
|
+
|
63
|
+
it do
|
64
|
+
page.should_not be_valid
|
65
|
+
page.errors.messages.should == {count: [ATDIS::ErrorMessage["should be present if pagination is being used", "6.4"]]}
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "pagination not valid" do
|
70
|
+
before :each do
|
71
|
+
page.pagination.should_receive(:valid?).and_return(false)
|
72
|
+
end
|
73
|
+
|
74
|
+
it do
|
75
|
+
page.should_not be_valid
|
76
|
+
page.errors.messages.should == {pagination: [ATDIS::ErrorMessage["is not valid (see further errors for details)", nil]]}
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "one valid application out of two no paging" do
|
83
|
+
before :each do
|
84
|
+
ATDIS::Models::Response.should_receive(:interpret).with(description: "application1").and_return(double(valid?: true))
|
85
|
+
ATDIS::Models::Response.should_receive(:interpret).with(description: "application2").and_return(double(valid?: false))
|
86
|
+
end
|
87
|
+
let(:page) { ATDIS::Models::Page.new(response: [{description: "application1"}, {description: "application2"}]) }
|
88
|
+
|
89
|
+
it do
|
90
|
+
page.should_not be_valid
|
91
|
+
page.errors.messages.should == {response: [ATDIS::ErrorMessage["is not valid (see further errors for details)", nil]]}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "two invalid applications no paging" do
|
96
|
+
let(:a1) { double(valid?: false, json_errors: [[{dat_id: "null"}, ["can not be empty"]]]) }
|
97
|
+
let(:a2) { double(valid?: false) }
|
98
|
+
before :each do
|
99
|
+
ATDIS::Models::Response.should_receive(:interpret).with(description: "application1").and_return(a1)
|
100
|
+
ATDIS::Models::Response.should_receive(:interpret).with(description: "application2").and_return(a2)
|
101
|
+
end
|
102
|
+
let(:page) { ATDIS::Models::Page.new(response: [{description: "application1"}, {description: "application2"}]) }
|
103
|
+
|
104
|
+
it do
|
105
|
+
page.should_not be_valid
|
106
|
+
page.errors.messages.should == {response: [ATDIS::ErrorMessage["is not valid (see further errors for details)", nil]]}
|
107
|
+
end
|
108
|
+
|
109
|
+
it "the errors from the first errored application should be here" do
|
110
|
+
page.should_not be_valid
|
111
|
+
page.json_errors.should == [[{response: [{description: "application1"}, {description: "application2"}]}, [ATDIS::ErrorMessage["response is not valid (see further errors for details)"]]], [{response: [{dat_id: "null"}]} , ["can not be empty"]]]
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context "paging supported by vendor" do
|
118
|
+
context "read a from an invalid json string" do
|
119
|
+
let(:page) { ATDIS::Models::Page.read_json(<<-EOF
|
120
|
+
{
|
121
|
+
"response": [
|
122
|
+
{
|
123
|
+
"application": {
|
124
|
+
"description": "application2"
|
125
|
+
}
|
126
|
+
}
|
127
|
+
],
|
128
|
+
}
|
129
|
+
EOF
|
130
|
+
)}
|
131
|
+
|
132
|
+
it do
|
133
|
+
page.should_not be_valid
|
134
|
+
page.errors.messages.has_key?(:json).should be_true
|
135
|
+
page.errors.messages.count.should == 1
|
136
|
+
# The error messages returned by the library are different for different Ruby versions
|
137
|
+
ruby19_message = ATDIS::ErrorMessage["Invalid JSON: 784: unexpected token at '{\n \"response\": [\n {\n \"application\": {\n \"description\": \"application2\"\n }\n }\n ],\n}\n'", nil]
|
138
|
+
ruby20_message = ATDIS::ErrorMessage["Invalid JSON: 795: unexpected token at '{\n \"response\": [\n {\n \"application\": {\n \"description\": \"application2\"\n }\n }\n ],\n}\n'", nil]
|
139
|
+
page.errors.messages[:json].count.should == 1
|
140
|
+
message = page.errors.messages[:json].first
|
141
|
+
(message == ruby19_message || message == ruby20_message).should be_true
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context "read from a json string" do
|
146
|
+
let(:page) { ATDIS::Models::Page.read_json(<<-EOF
|
147
|
+
{
|
148
|
+
"response": [
|
149
|
+
{
|
150
|
+
"application": {
|
151
|
+
"description": "application1"
|
152
|
+
}
|
153
|
+
},
|
154
|
+
{
|
155
|
+
"application": {
|
156
|
+
"description": "application2"
|
157
|
+
}
|
158
|
+
}
|
159
|
+
],
|
160
|
+
"count": 2,
|
161
|
+
"pagination": {
|
162
|
+
"previous": 1,
|
163
|
+
"next": 3,
|
164
|
+
"current": 2,
|
165
|
+
"per_page": 2,
|
166
|
+
"count": 50,
|
167
|
+
"pages": 25
|
168
|
+
}
|
169
|
+
}
|
170
|
+
EOF
|
171
|
+
)}
|
172
|
+
it ".results" do
|
173
|
+
application1 = double("Application")
|
174
|
+
application2 = double("Application")
|
175
|
+
ATDIS::Models::Response.should_receive(:interpret).with(application: {description: "application1"}).and_return(application1)
|
176
|
+
ATDIS::Models::Response.should_receive(:interpret).with(application: {description: "application2"}).and_return(application2)
|
177
|
+
|
178
|
+
page.response.should == [application1, application2]
|
179
|
+
end
|
180
|
+
|
181
|
+
it ".next_page" do
|
182
|
+
expect { page.next_page }.to raise_error "Can't use next_url when loaded with read_json"
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
context "read from a url" do
|
187
|
+
before :each do
|
188
|
+
# Mock network response
|
189
|
+
RestClient.should_receive(:get).with("http://www.council.nsw.gov.au/atdis/1.0/applications.json").and_return(double(to_str: <<-EOF
|
190
|
+
{
|
191
|
+
"response": [
|
192
|
+
{
|
193
|
+
"application": {
|
194
|
+
"description": "application1"
|
195
|
+
}
|
196
|
+
},
|
197
|
+
{
|
198
|
+
"application": {
|
199
|
+
"description": "application2"
|
200
|
+
}
|
201
|
+
}
|
202
|
+
]
|
203
|
+
}
|
204
|
+
EOF
|
205
|
+
))
|
206
|
+
end
|
207
|
+
|
208
|
+
let(:applications_results) { ATDIS::Models::Page.read_url("http://www.council.nsw.gov.au/atdis/1.0/applications.json") }
|
209
|
+
|
210
|
+
it ".response" do
|
211
|
+
application1 = double("Application")
|
212
|
+
application2 = double("Application")
|
213
|
+
ATDIS::Models::Response.should_receive(:interpret).with(application: {description: "application1"}).and_return(application1)
|
214
|
+
ATDIS::Models::Response.should_receive(:interpret).with(application: {description: "application2"}).and_return(application2)
|
215
|
+
|
216
|
+
applications_results.response.should == [application1, application2]
|
217
|
+
end
|
218
|
+
|
219
|
+
it ".next_page" do
|
220
|
+
applications_results.next_page.should be_nil
|
221
|
+
end
|
222
|
+
|
223
|
+
it ".pagination" do
|
224
|
+
applications_results.pagination.should be_nil
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
context "paging supported by vendor" do
|
230
|
+
before :each do
|
231
|
+
RestClient.should_receive(:get).with("http://www.council.nsw.gov.au/atdis/1.0/applications.json?page=2").and_return(double(to_str: <<-EOF
|
232
|
+
{
|
233
|
+
"response": [
|
234
|
+
{
|
235
|
+
"application": {
|
236
|
+
"description": "application1"
|
237
|
+
}
|
238
|
+
},
|
239
|
+
{
|
240
|
+
"application": {
|
241
|
+
"description": "application2"
|
242
|
+
}
|
243
|
+
}
|
244
|
+
],
|
245
|
+
"count": 2,
|
246
|
+
"pagination": {
|
247
|
+
"previous": 1,
|
248
|
+
"next": 3,
|
249
|
+
"current": 2,
|
250
|
+
"per_page": 2,
|
251
|
+
"count": 50,
|
252
|
+
"pages": 25
|
253
|
+
}
|
254
|
+
}
|
255
|
+
EOF
|
256
|
+
))
|
257
|
+
end
|
258
|
+
|
259
|
+
let(:applications_results) { ATDIS::Models::Page.read_url("http://www.council.nsw.gov.au/atdis/1.0/applications.json?page=2") }
|
260
|
+
|
261
|
+
it ".previous" do
|
262
|
+
applications_results.pagination.previous.should == 1
|
263
|
+
end
|
264
|
+
|
265
|
+
it ".next" do
|
266
|
+
applications_results.pagination.next.should == 3
|
267
|
+
end
|
268
|
+
|
269
|
+
it ".current" do
|
270
|
+
applications_results.pagination.current.should == 2
|
271
|
+
end
|
272
|
+
|
273
|
+
it ".per_page" do
|
274
|
+
applications_results.pagination.per_page.should == 2
|
275
|
+
end
|
276
|
+
|
277
|
+
it ".count" do
|
278
|
+
applications_results.pagination.count.should == 50
|
279
|
+
end
|
280
|
+
|
281
|
+
it ".pages" do
|
282
|
+
applications_results.pagination.pages.should == 25
|
283
|
+
end
|
284
|
+
|
285
|
+
it ".next_url" do
|
286
|
+
applications_results.next_url.should == "http://www.council.nsw.gov.au/atdis/1.0/applications.json?page=3"
|
287
|
+
end
|
288
|
+
|
289
|
+
it ".next_page" do
|
290
|
+
n = double("Page")
|
291
|
+
applications_results
|
292
|
+
ATDIS::Models::Page.should_receive(:read_url).with("http://www.council.nsw.gov.au/atdis/1.0/applications.json?page=3").and_return(n)
|
293
|
+
applications_results.next_page.should == n
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ATDIS::Models::Pagination do
|
4
|
+
context "valid pagination" do
|
5
|
+
let (:pagination) { ATDIS::Models::Pagination.new(
|
6
|
+
previous: nil, current: 1, next: 2, per_page: 25, pages: 4, count: 90
|
7
|
+
)}
|
8
|
+
it do
|
9
|
+
pagination.should be_valid
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context "current is not set" do
|
14
|
+
let (:pagination) { ATDIS::Models::Pagination.new(
|
15
|
+
previous: nil, current: nil, next: 2, per_page: 25, pages: 4, count: 90
|
16
|
+
)}
|
17
|
+
it do
|
18
|
+
pagination.should_not be_valid
|
19
|
+
pagination.errors.messages.should == {current: [ATDIS::ErrorMessage["should be present if pagination is being used", "6.4"]]}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "per_page is not set" do
|
24
|
+
let (:pagination) { ATDIS::Models::Pagination.new(
|
25
|
+
previous: nil, current: 1, next: 2, per_page: nil, pages: 4, count: 90
|
26
|
+
)}
|
27
|
+
it do
|
28
|
+
pagination.should_not be_valid
|
29
|
+
pagination.errors.messages.should == {per_page: [ATDIS::ErrorMessage["should be present if pagination is being used", "6.4"]]}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "total_not_results is not set" do
|
34
|
+
let (:pagination) { ATDIS::Models::Pagination.new(
|
35
|
+
previous: nil, current: 1, next: 2, per_page: 25, pages: 4, count: nil
|
36
|
+
)}
|
37
|
+
it do
|
38
|
+
pagination.should_not be_valid
|
39
|
+
pagination.errors.messages.should == {count: [ATDIS::ErrorMessage["should be present if pagination is being used", "6.4"]]}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "pages is not set" do
|
44
|
+
let (:pagination) { ATDIS::Models::Pagination.new(
|
45
|
+
previous: nil, current: 1, next: 2, per_page: 25, pages: nil, count: 90
|
46
|
+
)}
|
47
|
+
it do
|
48
|
+
pagination.should_not be_valid
|
49
|
+
pagination.errors.messages.should == {pages: [ATDIS::ErrorMessage["should be present if pagination is being used", "6.4"]]}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "total no_results is less than would be expected" do
|
54
|
+
let (:pagination) { ATDIS::Models::Pagination.new(
|
55
|
+
previous: nil, current: 1, next: 2, per_page: 25, pages: 4, count: 75
|
56
|
+
)}
|
57
|
+
it do
|
58
|
+
pagination.should_not be_valid
|
59
|
+
pagination.errors.messages.should == {count: [ATDIS::ErrorMessage["could fit into a smaller number of pages", "6.4"]]}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "count is larger than would be expected" do
|
64
|
+
let(:pagination) { ATDIS::Models::Pagination.new(
|
65
|
+
previous: nil, current: 1, next: 2, per_page: 25, pages: 4, count: 101
|
66
|
+
)}
|
67
|
+
it do
|
68
|
+
pagination.should_not be_valid
|
69
|
+
pagination.errors.messages.should == {count: [ATDIS::ErrorMessage["is larger than can be retrieved through paging", "6.4"]]}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "current page is zero" do
|
74
|
+
let(:pagination) { ATDIS::Models::Pagination.new(
|
75
|
+
previous: nil, current: 0, next: 1, pages: 1, per_page: 25, count: 2
|
76
|
+
) }
|
77
|
+
it do
|
78
|
+
pagination.should_not be_valid
|
79
|
+
pagination.errors.messages.should == {current: [ATDIS::ErrorMessage["can not be less than 1", "6.4"]]}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "current page is larger than the number of pages" do
|
84
|
+
let(:pagination) { ATDIS::Models::Pagination.new(
|
85
|
+
previous: nil, previous: 1, current: 2, next: 3, pages: 1, per_page: 25, count: 2
|
86
|
+
) }
|
87
|
+
it do
|
88
|
+
pagination.should_not be_valid
|
89
|
+
pagination.errors.messages.should == {current: [ATDIS::ErrorMessage["is larger than the number of pages", "6.4"]]}
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "next page number is not nil but on last page" do
|
94
|
+
let(:pagination) { ATDIS::Models::Pagination.new(
|
95
|
+
previous: 3, current: 4, next: 5, pages: 4, per_page: 25, count: 100
|
96
|
+
) }
|
97
|
+
it do
|
98
|
+
pagination.should_not be_valid
|
99
|
+
pagination.errors.messages.should == {next: [ATDIS::ErrorMessage["should be null if on the last page", "6.4"]]}
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context "next page number is nil but not on last page" do
|
104
|
+
let(:pagination) { ATDIS::Models::Pagination.new(
|
105
|
+
previous: 3, current: 4, next: nil, pages: 6, per_page: 25, count: 140
|
106
|
+
) }
|
107
|
+
it do
|
108
|
+
pagination.should_not be_valid
|
109
|
+
pagination.errors.messages.should == {next: [ATDIS::ErrorMessage["can't be null if not on the last page", "6.4"]]}
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context "next page number is pointing to a weird page number" do
|
114
|
+
let(:pagination) { ATDIS::Models::Pagination.new(
|
115
|
+
previous: nil, current: 1, next: 5, pages: 2, per_page: 25, count: 50
|
116
|
+
) }
|
117
|
+
it do
|
118
|
+
pagination.should_not be_valid
|
119
|
+
pagination.errors.messages.should == {next: [ATDIS::ErrorMessage["should be one greater than current page number or null if last page", "6.4"]]}
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "previous page number not nil but on first page" do
|
124
|
+
let(:pagination) { ATDIS::Models::Pagination.new(
|
125
|
+
previous: 0, current: 1, next: 2, pages: 10, per_page: 25, count: 240
|
126
|
+
) }
|
127
|
+
it do
|
128
|
+
pagination.should_not be_valid
|
129
|
+
pagination.errors.messages.should == {previous: [ATDIS::ErrorMessage["should be null if on the first page", "6.4"]]}
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context "previous page number if nil but not on first page" do
|
134
|
+
let(:pagination) { ATDIS::Models::Pagination.new(
|
135
|
+
previous: nil, current: 4, next: 5, pages: 10, per_page: 25, count: 240
|
136
|
+
) }
|
137
|
+
it do
|
138
|
+
pagination.should_not be_valid
|
139
|
+
pagination.errors.messages.should == {previous: [ATDIS::ErrorMessage["can't be null if not on the first page", "6.4"]]}
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context "previous page number is pointing to a weird page number" do
|
144
|
+
let(:pagination) { ATDIS::Models::Pagination.new(
|
145
|
+
previous: 5, current: 2, next: nil, pages: 2, per_page: 25, count: 50
|
146
|
+
) }
|
147
|
+
it do
|
148
|
+
pagination.should_not be_valid
|
149
|
+
pagination.errors.messages.should == {previous: [ATDIS::ErrorMessage["should be one less than current page number or null if first page", "6.4"]]}
|
150
|
+
pagination.json_errors.should == [[{previous: 5}, [ATDIS::ErrorMessage["previous should be one less than current page number or null if first page", "6.4"]]]]
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ATDIS::Models::Person do
|
4
|
+
it ".attribute_names" do
|
5
|
+
ATDIS::Models::Person.attribute_names.should == ["name", "role", "contact"]
|
6
|
+
end
|
7
|
+
|
8
|
+
it ".name" do
|
9
|
+
ATDIS::Models::Person.interpret(name: "Tuttle").name.should == "Tuttle"
|
10
|
+
end
|
11
|
+
|
12
|
+
it ".role" do
|
13
|
+
ATDIS::Models::Person.interpret(role: "Heating Engineer").role.should == "Heating Engineer"
|
14
|
+
end
|
15
|
+
|
16
|
+
it ".contact" do
|
17
|
+
ATDIS::Models::Person.interpret(contact: "94-FLUSH").contact.should == "94-FLUSH"
|
18
|
+
end
|
19
|
+
end
|