summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-02-27 20:13:07 -0700
committermo khan <mo@mokhan.ca>2014-02-27 20:13:07 -0700
commitaabb666d1fbbaad401e163e89be9506c74df8ec3 (patch)
tree9e97bd34d994dbcf16e63d3e4830256b4ebfdadd
parentc142bb4e9fff7e0082ba6764cbe923fd3d5d60db (diff)
add integration test for v1/licenses/:id
-rw-r--r--spec/requests/v1/licenses_spec.rb64
1 files changed, 43 insertions, 21 deletions
diff --git a/spec/requests/v1/licenses_spec.rb b/spec/requests/v1/licenses_spec.rb
index b703490..295728b 100644
--- a/spec/requests/v1/licenses_spec.rb
+++ b/spec/requests/v1/licenses_spec.rb
@@ -7,28 +7,50 @@ describe 'v1/licenses' do
let!(:well_type) { WellType::DEV }
let!(:license) { License.create(id: SecureRandom.uuid, company: company, applicant: user, location: location, issued_at: 2.days.ago, expired_at: 1.day.from_now, well_type: well_type) }
- it "returns a list of licenses" do
- get 'v1/licenses'
- response.should be_success
- result = JSON.parse(response.body)
- result["licenses"].first["id"].should == license.id
- result["licenses"].first["issued_at"].should == license.issued_at.to_s
- result["licenses"].first["expired_at"].should == license.expired_at.to_s
- result["licenses"].first["company"]["name"].should == license.company.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
- result["licenses"].first["location"]["latitude"].should == location.latitude
- result["licenses"].first["location"]["longitude"].should == location.longitude
- result["licenses"].first["location"]["township"].should == location.township
- 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
+ describe "v1/licenses" do
+ it "returns a list of licenses" do
+ get 'v1/licenses'
+ response.should be_success
+ result = JSON.parse(response.body)
+ result["licenses"].first["id"].should == license.id
+ result["licenses"].first["issued_at"].should == license.issued_at.to_s
+ result["licenses"].first["expired_at"].should == license.expired_at.to_s
+ result["licenses"].first["company"]["name"].should == license.company.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
+ result["licenses"].first["location"]["latitude"].should == location.latitude
+ result["licenses"].first["location"]["longitude"].should == location.longitude
+ result["licenses"].first["location"]["township"].should == location.township
+ 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
+ LicenseStatus::ALL.each do |status|
+ row = result["license_statuses"].find { |x| x['name'] == status.to_s }
+ row.should_not be_nil
+ end
end
- LicenseStatus::ALL.each do |status|
- row = result["license_statuses"].find { |x| x['name'] == status.to_s }
- row.should_not be_nil
+ end
+
+ describe "v1/licenses/:id" do
+ it "returns details on a single license" do
+ get "v1/licenses/#{license.id}"
+ response.should be_success
+ result = JSON.parse(response.body)
+ result["id"].should == license.id
+ result["issued_at"].should == license.issued_at.to_s
+ result["expired_at"].should == license.expired_at.to_s
+ result["company"]["name"].should == license.company.name
+ result["company"]["applicant_name"].should == user.full_name
+ result["well_type"]["id"].should == well_type.id
+ result["well_type"]["acronym"].should == well_type.acronym
+ result["well_type"]["name"].should == well_type.name
+ result["location"]["latitude"].should == location.latitude
+ result["location"]["longitude"].should == location.longitude
+ result["location"]["township"].should == location.township
+ result['status'].should == 'active'
end
end
end