summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/v1/licenses/index.json.jbuilder_spec.rb29
1 files changed, 19 insertions, 10 deletions
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