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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
require "spec_helper"
describe 'v1/licenses/show' do
let(:company) { Company.new(name: 'ABC Resources Ltd.') }
let(:user) { User.new(first_name: 'john', last_name: 'dielwart', company: company) }
let(:location) { Location.new(latitude: 51.06, longitude: -114.09, township: '1') }
let(:well_type) { WellType::DEV }
context "for public licenses" do
let(:public_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
public_license.stub(:status).and_return(LicenseStatus::ACTIVE)
assign(:license, public_license)
render
end
let(:result) { JSON.parse(rendered) }
it "includes the license date range" do
result["issued_at"].should == public_license.issued_at.to_s
result["expired_at"].should == public_license.expired_at.to_s
end
it "includes the license id" do
result["id"].should == public_license.id
end
it "includes the company information" do
result["company"]["name"].should == public_license.company.name
result["company"]["applicant_name"].should == user.full_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
it "includes the license status" do
result['status'].should == 'active'
end
end
context "for confidential licenses" do
let(:confidential_license) { License.new(confidential: true, company: company, applicant: user, location: location, well_type: well_type) }
before :each do
confidential_license.stub(:status).and_return(LicenseStatus::CONFIDENTIAL)
assign(:license, confidential_license)
render
end
let(:result) { JSON.parse(rendered) }
it "should hide the name of the applicant" do
result["company"]["applicant_name"].should == "CONFIDENTIAL"
end
it "should hide the type of well" do
result['well_type']['id'].should == ''
result['well_type']['acronym'].should == ''
result['well_type']['name'].should == 'CONFIDENTIAL'
end
it "should hide the company name" do
result["company"]["name"].should == "CONFIDENTIAL"
end
it "includes the license status" do
result['status'].should == 'confidential'
end
end
end
|