summaryrefslogtreecommitdiff
path: root/spec/views/v1
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 /spec/views/v1
parentd385a99f504dc183e92ffe87c18ac27bf0c88872 (diff)
do not disclose company or well type information for confidential licenses.
Diffstat (limited to 'spec/views/v1')
-rw-r--r--spec/views/v1/licenses/show.json.jbuilder_spec.rb76
1 files changed, 52 insertions, 24 deletions
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