summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-02-22 07:53:37 -0700
committermo khan <mo@mokhan.ca>2014-02-22 07:53:37 -0700
commitb675903ccb615c1f1868cd46095fec140a4198ae (patch)
tree477a03f76dab0f0631f0af1661402798fef3d4ce
parentd385a99f504dc183e92ffe87c18ac27bf0c88872 (diff)
do not disclose company or well type information for confidential licenses.
-rw-r--r--app/views/v1/licenses/_confidential_company.json.jbuilder3
-rw-r--r--app/views/v1/licenses/_confidential_well_type.json.jbuilder5
-rw-r--r--app/views/v1/licenses/_license.json.jbuilder9
-rw-r--r--spec/views/v1/licenses/show.json.jbuilder_spec.rb76
4 files changed, 67 insertions, 26 deletions
diff --git a/app/views/v1/licenses/_confidential_company.json.jbuilder b/app/views/v1/licenses/_confidential_company.json.jbuilder
new file mode 100644
index 0000000..676c5a1
--- /dev/null
+++ b/app/views/v1/licenses/_confidential_company.json.jbuilder
@@ -0,0 +1,3 @@
+json.company do
+ json.name "CONFIDENTIAL"
+end
diff --git a/app/views/v1/licenses/_confidential_well_type.json.jbuilder b/app/views/v1/licenses/_confidential_well_type.json.jbuilder
new file mode 100644
index 0000000..43d8f39
--- /dev/null
+++ b/app/views/v1/licenses/_confidential_well_type.json.jbuilder
@@ -0,0 +1,5 @@
+json.well_type do
+ json.id ""
+ json.acronym ""
+ json.name "CONFIDENTIAL"
+end
diff --git a/app/views/v1/licenses/_license.json.jbuilder b/app/views/v1/licenses/_license.json.jbuilder
index 3ef54ff..0035ea4 100644
--- a/app/views/v1/licenses/_license.json.jbuilder
+++ b/app/views/v1/licenses/_license.json.jbuilder
@@ -1,6 +1,11 @@
json.id license.id
-json.partial! 'v1/licenses/well_type', well_type: license.well_type
json.partial! 'v1/licenses/location', location: license.location
-json.partial! 'v1/licenses/company', company: license.company
+if license.confidential?
+ json.partial! 'v1/licenses/confidential_well_type', well_type: license.well_type
+ json.partial! 'v1/licenses/confidential_company'
+else
+ json.partial! 'v1/licenses/well_type', well_type: license.well_type
+ json.partial! 'v1/licenses/company', company: license.company
+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 dff07fa..576c1bb 100644
--- a/spec/views/v1/licenses/show.json.jbuilder_spec.rb
+++ b/spec/views/v1/licenses/show.json.jbuilder_spec.rb
@@ -5,37 +5,65 @@ describe 'v1/licenses/show' do
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)
- render
- end
+ 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) }
- let(:result) { JSON.parse(rendered) }
+ before :each do
+ assign(:license, public_license)
+ render
+ end
- it "includes the license date range" do
- result["issued_at"].should == license.issued_at.to_s
- result["expired_at"].should == license.expired_at.to_s
- end
+ let(:result) { JSON.parse(rendered) }
- it "includes the license id" do
- result["id"].should == license.id
- end
+ 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 company information" do
- result["company"]["name"].should == license.company.name
- 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
+ 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 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
+ 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
- it "includes location information" do
- result["location"]["latitude"].should == location.latitude
- result["location"]["longitude"].should == location.longitude
- result["location"]["township"].should == location.township
+ 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
+ assign(:license, confidential_license)
+ render
+ end
+
+ let(:result) { JSON.parse(rendered) }
+
+ it "should hide the name of the applicant" do
+
+ 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
end
end