summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/views/v1/licenses/index.jbuilder13
-rw-r--r--spec/views/v1/licenses/index.json.jbuilder_spec.rb29
2 files changed, 30 insertions, 12 deletions
diff --git a/app/views/v1/licenses/index.jbuilder b/app/views/v1/licenses/index.jbuilder
index 1cc2069..2f31916 100644
--- a/app/views/v1/licenses/index.jbuilder
+++ b/app/views/v1/licenses/index.jbuilder
@@ -1,3 +1,12 @@
-json.array! @licenses do |license|
- json.partial! 'v1/licenses/license', license: license
+json.licenses do
+ json.array! @licenses do |license|
+ json.partial! 'v1/licenses/license', license: license
+ end
+end
+json.well_types do
+ json.array! @well_types do |well_type|
+ json.id well_type.id
+ json.acronym well_type.acronym
+ json.name well_type.name
+ end
end
diff --git a/spec/views/v1/licenses/index.json.jbuilder_spec.rb b/spec/views/v1/licenses/index.json.jbuilder_spec.rb
index c3743a5..f88ecc5 100644
--- a/spec/views/v1/licenses/index.json.jbuilder_spec.rb
+++ b/spec/views/v1/licenses/index.json.jbuilder_spec.rb
@@ -9,33 +9,42 @@ describe 'v1/licenses/index' do
before :each do
assign(:licenses, [license])
+ assign(:well_types, WellType::ALL)
render
end
let(:result) { JSON.parse(rendered) }
it "includes the license id" do
- result.first["id"].should == license.id
+ result["licenses"].first["id"].should == license.id
end
it "includes the license date range" do
- result.first["issued_at"].should == license.issued_at.to_s
- result.first["expired_at"].should == license.expired_at.to_s
+ result["licenses"].first["issued_at"].should == license.issued_at.to_s
+ result["licenses"].first["expired_at"].should == license.expired_at.to_s
end
it "includes the company information" do
- result.first["company"]["name"].should == license.company.name
+ result["licenses"].first["company"]["name"].should == license.company.name
end
it "includes information on the type of well" do
- result.first["well_type"]["id"].should == well_type.id
- result.first["well_type"]["acronym"].should == well_type.acronym
- result.first["well_type"]["name"].should == well_type.name
+ result["licenses"].first["well_type"]["id"].should == well_type.id
+ result["licenses"].first["well_type"]["acronym"].should == well_type.acronym
+ result["licenses"].first["well_type"]["name"].should == well_type.name
end
it "includes location information" do
- result.first["location"]["latitude"].should == location.latitude
- result.first["location"]["longitude"].should == location.longitude
- result.first["location"]["township"].should == location.township
+ result["licenses"].first["location"]["latitude"].should == location.latitude
+ result["licenses"].first["location"]["longitude"].should == location.longitude
+ result["licenses"].first["location"]["township"].should == location.township
+ end
+
+ it "includes all the well types" do
+ WellType::ALL.each do |well_type|
+ row = result["well_types"].find { |x| x['id'] == well_type.id }
+ row['acronym'].should == well_type.acronym
+ row['name'].should == well_type.name
+ end
end
end