summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-02-22 00:36:48 -0700
committermo khan <mo@mokhan.ca>2014-02-22 00:36:48 -0700
commit2dd2a09d8c9f939639e72c62ecd4367f7a3ec059 (patch)
tree7b071bbf672b7dc836c8c9aa1defe392f1b895f7
parentc76e1f97aec3c59cd5e3563e660bbb8905e64136 (diff)
define json for licenses#index endpoint.
-rw-r--r--app/views/v1/licenses/index.jbuilder18
-rw-r--r--spec/views/v1/licenses/index.json.jbuilder_spec.rb15
2 files changed, 26 insertions, 7 deletions
diff --git a/app/views/v1/licenses/index.jbuilder b/app/views/v1/licenses/index.jbuilder
index ff31792..5eaf41e 100644
--- a/app/views/v1/licenses/index.jbuilder
+++ b/app/views/v1/licenses/index.jbuilder
@@ -1,9 +1,17 @@
json.array! @licenses do |license|
- json.issued_at license.issued_at.to_s
- json.expired_at license.expired_at.to_s
json.well_type do
- json.id 1
- json.pneumonic "NFW"
- json.name "New Field Wildcat"
+ json.id license.well_type.id
+ json.acronym license.well_type.acronym
+ json.name license.well_type.name
+ end
+ json.location do
+ json.township license.location.township
+ json.latitude license.location.latitude
+ json.longitude license.location.longitude
end
+ json.company do
+ json.name license.company.name
+ end
+ json.issued_at license.issued_at.to_s
+ json.expired_at license.expired_at.to_s
end
diff --git a/spec/views/v1/licenses/index.json.jbuilder_spec.rb b/spec/views/v1/licenses/index.json.jbuilder_spec.rb
index d2583a3..38d9955 100644
--- a/spec/views/v1/licenses/index.json.jbuilder_spec.rb
+++ b/spec/views/v1/licenses/index.json.jbuilder_spec.rb
@@ -1,10 +1,14 @@
require "spec_helper"
describe 'v1/licenses/index' do
- let!(:license) { License.create(issued_at: 2.days.ago, expired_at: 1.day.from_now) }
+ let(:company) { Company.new(name: 'ABC Resources Ltd.') }
+ let(:user) { User.new(company: company) }
+ let(:location) { Location.new(latitude: 51.06, longitude: -114.09, township: '1') }
+ let(:well_type) { WellType::DEV }
+ let!(:license) { License.new(company: company, applicant: user, location: location, issued_at: 2.days.ago, expired_at: 1.day.from_now, well_type: well_type) }
before :each do
- assign(:licenses, License.all)
+ assign(:licenses, [license])
render
end
@@ -13,5 +17,12 @@ describe 'v1/licenses/index' do
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.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.first["location"]["latitude"].should == location.latitude
+ result.first["location"]["longitude"].should == location.longitude
+ result.first["location"]["township"].should == location.township
+ result.first["company"]["name"].should == license.company.name
end
end