blob: 6a177006d907b4c42c78e57ebfa547daae1db834 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
require "spec_helper"
describe 'v1/licenses/index' do
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(:licenses, [license])
assign(:well_types, WellType::ALL)
assign(:license_statuses, LicenseStatus::ALL)
render
end
let(:result) { JSON.parse(rendered) }
it "includes the license id" do
result["licenses"].first["id"].should == license.id
end
it "includes the license date range" do
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["licenses"].first["company"]["name"].should == license.company.name
end
it "includes information on the type of well" do
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["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
it "includes all the license statuses" do
LicenseStatus::ALL.each do |status|
row = result["license_statuses"].find { |x| x['name'] == status.to_s }
row.should_not be_nil
end
end
end
|