diff options
| author | mo khan <mo@mokhan.ca> | 2014-02-22 08:52:13 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-02-22 08:52:13 -0700 |
| commit | 7947414c935aa6a20a2de068b343df2a0f141384 (patch) | |
| tree | 46fc01930169f48a5debf42092baebb141bd18ba /spec/views | |
| parent | 1388b346450b975703b7890eb87505e975713c22 (diff) | |
add status to license and fix broken jbuilder spec.
Diffstat (limited to 'spec/views')
| -rw-r--r-- | spec/views/v1/company_licenses/index.json.jbuilder_spec.rb | 37 | ||||
| -rw-r--r-- | spec/views/v1/licenses/show.json.jbuilder_spec.rb | 4 |
2 files changed, 29 insertions, 12 deletions
diff --git a/spec/views/v1/company_licenses/index.json.jbuilder_spec.rb b/spec/views/v1/company_licenses/index.json.jbuilder_spec.rb index 6d85141..90eefb9 100644 --- a/spec/views/v1/company_licenses/index.json.jbuilder_spec.rb +++ b/spec/views/v1/company_licenses/index.json.jbuilder_spec.rb @@ -9,33 +9,50 @@ describe 'v1/company_licenses/index' do 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.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 + + 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 diff --git a/spec/views/v1/licenses/show.json.jbuilder_spec.rb b/spec/views/v1/licenses/show.json.jbuilder_spec.rb index 404a514..f000674 100644 --- a/spec/views/v1/licenses/show.json.jbuilder_spec.rb +++ b/spec/views/v1/licenses/show.json.jbuilder_spec.rb @@ -10,7 +10,7 @@ describe 'v1/licenses/show' 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('active') + public_license.stub(:status).and_return(LicenseStatus::ACTIVE) assign(:license, public_license) render end @@ -52,7 +52,7 @@ describe 'v1/licenses/show' 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('confidential') + confidential_license.stub(:status).and_return(LicenseStatus::CONFIDENTIAL) assign(:license, confidential_license) render end |
