atdis 0.3.2 → 0.3.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 +4 -4
- data/lib/atdis/models/page.rb +1 -1
- data/lib/atdis/models/pagination.rb +1 -1
- data/lib/atdis/version.rb +1 -1
- data/spec/atdis/feed_spec.rb +2 -2
- data/spec/atdis/models/application_spec.rb +17 -17
- data/spec/atdis/models/land_title_ref_spec.rb +4 -4
- data/spec/atdis/models/page_spec.rb +8 -2
- data/spec/atdis/models/pagination_spec.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 582504f7e4d3344558df19bd967db447c881931a
|
4
|
+
data.tar.gz: b48255b2d8920eaf72ac22eff1981a14c0283727
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8432f063d638330887b15a2f9dbb4e15e867b529a9dc2bf13d2ed612485982e55f5d6b920c59a924fcf5bb31c4d6984a7acd0b32455306979beea0c9593ed57
|
7
|
+
data.tar.gz: 0bfb0c80d9f5d2c5b57afe5b9e6c47132b38226b84fbf466a03a1a3d69f20ddfd1480d45c26e7577796787076c492c15127ebf48cec73afd8340f1201cf2720e
|
data/lib/atdis/models/page.rb
CHANGED
@@ -28,7 +28,7 @@ module ATDIS
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def count_is_consistent
|
31
|
-
if count
|
31
|
+
if count && response.respond_to?(:count)
|
32
32
|
errors.add(:count, ErrorMessage["is not the same as the number of applications returned", "6.4"]) if count != response.count
|
33
33
|
errors.add(:count, ErrorMessage["should not be larger than the number of results per page", "6.4"]) if count > pagination.per_page
|
34
34
|
end
|
@@ -59,7 +59,7 @@ module ATDIS
|
|
59
59
|
if pages && per_page && count && count > pages * per_page
|
60
60
|
errors.add(:count, ErrorMessage["is larger than can be retrieved through paging", "6.4"])
|
61
61
|
end
|
62
|
-
if pages && per_page && count && count <= (pages - 1) * per_page
|
62
|
+
if pages && per_page && count && count > 0 && count <= (pages - 1) * per_page
|
63
63
|
errors.add(:count, ErrorMessage["could fit into a smaller number of pages", "6.4"])
|
64
64
|
end
|
65
65
|
end
|
data/lib/atdis/version.rb
CHANGED
data/spec/atdis/feed_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe ATDIS::Feed do
|
|
5
5
|
let(:page) { double }
|
6
6
|
|
7
7
|
it "should return all the applications" do
|
8
|
-
|
8
|
+
expect(ATDIS::Models::Page).to receive(:read_url).with("http://www.council.nsw.gov.au/atdis/1.0/applications.json").and_return(page)
|
9
9
|
feed.applications.should == page
|
10
10
|
end
|
11
11
|
|
@@ -89,7 +89,7 @@ describe ATDIS::Feed do
|
|
89
89
|
describe "#application" do
|
90
90
|
it {
|
91
91
|
application = double
|
92
|
-
ATDIS::Models::Application.
|
92
|
+
expect(ATDIS::Models::Application).to receive(:read_url).with("http://www.council.nsw.gov.au/atdis/1.0/27B%2F6.json").and_return(application)
|
93
93
|
feed.application("27B/6").should == application
|
94
94
|
}
|
95
95
|
end
|
@@ -3,9 +3,9 @@ require "spec_helper"
|
|
3
3
|
describe ATDIS::Models::Application do
|
4
4
|
context "extra parameter in json" do
|
5
5
|
it "should not be valid" do
|
6
|
-
ATDIS::Models::Location.
|
7
|
-
ATDIS::Models::Document.
|
8
|
-
ATDIS::Models::Event.
|
6
|
+
expect(ATDIS::Models::Location).to receive(:interpret).with("location").and_return(double(valid?: true))
|
7
|
+
expect(ATDIS::Models::Document).to receive(:interpret).with("document").and_return(double(valid?: true))
|
8
|
+
expect(ATDIS::Models::Event).to receive(:interpret).with("event").and_return(double(valid?: true))
|
9
9
|
|
10
10
|
a = ATDIS::Models::Application.interpret(
|
11
11
|
info: {
|
@@ -41,7 +41,7 @@ describe ATDIS::Models::Application do
|
|
41
41
|
it "should parse the json and create an application object" do
|
42
42
|
application = double
|
43
43
|
|
44
|
-
ATDIS::Models::Application.
|
44
|
+
expect(ATDIS::Models::Application).to receive(:new).with(
|
45
45
|
info: {
|
46
46
|
dat_id: "DA2013-0381",
|
47
47
|
development_type: "residential",
|
@@ -100,7 +100,7 @@ describe ATDIS::Models::Application do
|
|
100
100
|
|
101
101
|
it "should create a nil valued application when there is no information in the json" do
|
102
102
|
application = double
|
103
|
-
ATDIS::Models::Application.
|
103
|
+
expect(ATDIS::Models::Application).to receive(:new).with({json_left_overs:{}, info: {},
|
104
104
|
reference: {}}).and_return(application)
|
105
105
|
|
106
106
|
ATDIS::Models::Application.interpret(info: {}, reference: {}).should == application
|
@@ -118,7 +118,7 @@ describe ATDIS::Models::Application do
|
|
118
118
|
let(:a) { ATDIS::Models::Application.new }
|
119
119
|
it "should type cast to a location" do
|
120
120
|
location = double
|
121
|
-
ATDIS::Models::Location.
|
121
|
+
expect(ATDIS::Models::Location).to receive(:interpret).with(address: "123 Fourfivesix Street").and_return(location)
|
122
122
|
a.locations = [{ address: "123 Fourfivesix Street" }]
|
123
123
|
a.locations.should == [location]
|
124
124
|
end
|
@@ -134,8 +134,8 @@ describe ATDIS::Models::Application do
|
|
134
134
|
let(:a) { ATDIS::Models::Application.new }
|
135
135
|
it "should type cast to several events" do
|
136
136
|
event1, event2 = double, double
|
137
|
-
ATDIS::Models::Event.
|
138
|
-
ATDIS::Models::Event.
|
137
|
+
expect(ATDIS::Models::Event).to receive(:interpret).with(id: "event1").and_return(event1)
|
138
|
+
expect(ATDIS::Models::Event).to receive(:interpret).with(id: "event2").and_return(event2)
|
139
139
|
a.events = [ { id: "event1" }, { id: "event2" } ]
|
140
140
|
a.events.should == [event1, event2]
|
141
141
|
end
|
@@ -145,8 +145,8 @@ describe ATDIS::Models::Application do
|
|
145
145
|
let(:a) { ATDIS::Models::Application.new }
|
146
146
|
it "should type cast to several documents" do
|
147
147
|
document1, document2 = double, double
|
148
|
-
ATDIS::Models::Document.
|
149
|
-
ATDIS::Models::Document.
|
148
|
+
expect(ATDIS::Models::Document).to receive(:interpret).with(ref: "27B/6/a").and_return(document1)
|
149
|
+
expect(ATDIS::Models::Document).to receive(:interpret).with(ref: "27B/6/b").and_return(document2)
|
150
150
|
a.documents = [ { ref: "27B/6/a" }, { ref: "27B/6/b" } ]
|
151
151
|
a.documents.should == [document1, document2]
|
152
152
|
end
|
@@ -156,8 +156,8 @@ describe ATDIS::Models::Application do
|
|
156
156
|
let(:a) { ATDIS::Models::Application.new }
|
157
157
|
it "should type cast to several people" do
|
158
158
|
tuttle, buttle = double, double
|
159
|
-
ATDIS::Models::Person.
|
160
|
-
ATDIS::Models::Person.
|
159
|
+
expect(ATDIS::Models::Person).to receive(:interpret).with(name: "Tuttle").and_return(tuttle)
|
160
|
+
expect(ATDIS::Models::Person).to receive(:interpret).with(name: "Buttle").and_return(buttle)
|
161
161
|
a.people = [ { name: "Tuttle" }, { name: "Buttle" } ]
|
162
162
|
a.people.should == [tuttle, buttle]
|
163
163
|
end
|
@@ -181,9 +181,9 @@ describe ATDIS::Models::Application do
|
|
181
181
|
|
182
182
|
describe "validations" do
|
183
183
|
before :each do
|
184
|
-
ATDIS::Models::Location.
|
185
|
-
ATDIS::Models::Document.
|
186
|
-
ATDIS::Models::Event.
|
184
|
+
expect(ATDIS::Models::Location).to receive(:interpret).with("address").and_return(double(valid?: true))
|
185
|
+
expect(ATDIS::Models::Document).to receive(:interpret).with("document").and_return(double(valid?: true))
|
186
|
+
expect(ATDIS::Models::Event).to receive(:interpret).with("event").and_return(double(valid?: true))
|
187
187
|
end
|
188
188
|
|
189
189
|
let(:a) { ATDIS::Models::Application.new(
|
@@ -215,7 +215,7 @@ describe ATDIS::Models::Application do
|
|
215
215
|
describe ".location" do
|
216
216
|
it "should not be valid if the location is not valid" do
|
217
217
|
l = double(valid?: false)
|
218
|
-
ATDIS::Models::Location.
|
218
|
+
expect(ATDIS::Models::Location).to receive(:interpret).with(foo: "some location data").and_return(l)
|
219
219
|
a.locations = [{foo: "some location data"}]
|
220
220
|
a.should_not be_valid
|
221
221
|
end
|
@@ -223,7 +223,7 @@ describe ATDIS::Models::Application do
|
|
223
223
|
|
224
224
|
describe "events" do
|
225
225
|
it "has to be an array" do
|
226
|
-
ATDIS::Models::Event.
|
226
|
+
expect(ATDIS::Models::Event).to receive(:interpret).with(foo: "bar").and_return(double(valid?: true))
|
227
227
|
a.events = {foo: "bar"}
|
228
228
|
#a.events.should be_nil
|
229
229
|
a.should_not be_valid
|
@@ -4,8 +4,8 @@ describe ATDIS::Models::LandTitleRef do
|
|
4
4
|
context "torrens" do
|
5
5
|
before(:each) {
|
6
6
|
m = double
|
7
|
-
ATDIS::Models::TorrensTitle.
|
8
|
-
m.
|
7
|
+
expect(ATDIS::Models::TorrensTitle).to receive(:interpret).with({lot: "10"}).and_return(m)
|
8
|
+
expect(m).to receive(:valid?).and_return(true)
|
9
9
|
}
|
10
10
|
let(:l) { ATDIS::Models::LandTitleRef.new(torrens: {lot: "10"}) }
|
11
11
|
it { l.should be_valid }
|
@@ -27,8 +27,8 @@ describe ATDIS::Models::LandTitleRef do
|
|
27
27
|
context "both torrens and other" do
|
28
28
|
before(:each) {
|
29
29
|
m = double
|
30
|
-
ATDIS::Models::TorrensTitle.
|
31
|
-
m.
|
30
|
+
expect(ATDIS::Models::TorrensTitle).to receive(:interpret).with({lot: "10"}).and_return(m)
|
31
|
+
expect(m).to receive(:valid?).and_return(true)
|
32
32
|
}
|
33
33
|
let(:l) { ATDIS::Models::LandTitleRef.new(torrens: {lot: "10"}, other: {some: "foo", random: "stuff"})}
|
34
34
|
it {
|
@@ -5,6 +5,12 @@ describe ATDIS::Models::Page do
|
|
5
5
|
ATDIS::Models::Page.attribute_names.should == ["response", "count", "pagination"]
|
6
6
|
end
|
7
7
|
|
8
|
+
it "should error if response is null" do
|
9
|
+
page = ATDIS::Models::Page.new(response: nil, count: 0, pagination: {pages: 1, per_page: 20, count: 0, current: 1})
|
10
|
+
page.should_not be_valid
|
11
|
+
page.errors.messages.should == {:response => [ATDIS::ErrorMessage["can't be blank", "4.3"]]}
|
12
|
+
end
|
13
|
+
|
8
14
|
describe "validations" do
|
9
15
|
context "results block that is a hash" do
|
10
16
|
before :each do
|
@@ -131,14 +137,14 @@ describe ATDIS::Models::Page do
|
|
131
137
|
|
132
138
|
it do
|
133
139
|
page.should_not be_valid
|
134
|
-
page.errors.messages.has_key?(:json).should
|
140
|
+
page.errors.messages.has_key?(:json).should be_truthy
|
135
141
|
page.errors.messages.count.should == 1
|
136
142
|
# The error messages returned by the library are different for different Ruby versions
|
137
143
|
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
144
|
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
145
|
page.errors.messages[:json].count.should == 1
|
140
146
|
message = page.errors.messages[:json].first
|
141
|
-
(message == ruby19_message || message == ruby20_message).should
|
147
|
+
(message == ruby19_message || message == ruby20_message).should be_truthy
|
142
148
|
end
|
143
149
|
end
|
144
150
|
|
@@ -60,6 +60,13 @@ describe ATDIS::Models::Pagination do
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
context "zero results returned" do
|
64
|
+
let (:pagination) { ATDIS::Models::Pagination.new(previous: nil, current: 1, next: nil, per_page: 25, pages: 1, count: 0) }
|
65
|
+
it do
|
66
|
+
pagination.should be_valid
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
63
70
|
context "count is larger than would be expected" do
|
64
71
|
let(:pagination) { ATDIS::Models::Pagination.new(
|
65
72
|
previous: nil, current: 1, next: 2, per_page: 25, pages: 4, count: 101
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atdis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Landauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|