diff options
| author | mo khan <mo@mokhan.ca> | 2014-02-22 07:31:20 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-02-22 07:31:20 -0700 |
| commit | 85009727fccd91a27c658993417ca2d3b50c2364 (patch) | |
| tree | a7d9b2d21d23d54770cd78c027699eea43af133d | |
| parent | 10d812064f745c4d11eeba91daf3376e608f0c6f (diff) | |
add json response for licenses#show.
| -rw-r--r-- | app/views/v1/licenses/show.jbuilder | 14 | ||||
| -rw-r--r-- | spec/views/v1/licenses/show.json.jbuilder_spec.rb | 26 |
2 files changed, 39 insertions, 1 deletions
diff --git a/app/views/v1/licenses/show.jbuilder b/app/views/v1/licenses/show.jbuilder index 98f59e8..6ada656 100644 --- a/app/views/v1/licenses/show.jbuilder +++ b/app/views/v1/licenses/show.jbuilder @@ -1,2 +1,16 @@ +json.id @license.id +json.well_type do + 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 diff --git a/spec/views/v1/licenses/show.json.jbuilder_spec.rb b/spec/views/v1/licenses/show.json.jbuilder_spec.rb index e4b337c..dff07fa 100644 --- a/spec/views/v1/licenses/show.json.jbuilder_spec.rb +++ b/spec/views/v1/licenses/show.json.jbuilder_spec.rb @@ -1,7 +1,11 @@ require "spec_helper" describe 'v1/licenses/show' 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(id: SecureRandom.uuid, 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(:license, license) @@ -14,4 +18,24 @@ describe 'v1/licenses/show' do result["issued_at"].should == license.issued_at.to_s result["expired_at"].should == license.expired_at.to_s end + + it "includes the license id" do + result["id"].should == license.id + end + + it "includes the company information" do + result["company"]["name"].should == license.company.name + end + + it "includes information on the type of well" do + result["well_type"]["id"].should == well_type.id + result["well_type"]["acronym"].should == well_type.acronym + result["well_type"]["name"].should == well_type.name + end + + it "includes location information" do + result["location"]["latitude"].should == location.latitude + result["location"]["longitude"].should == location.longitude + result["location"]["township"].should == location.township + end end |
