blob: 636537ca22b297cd18d4a6a70c6ddd4ab174fb1e (
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
|
require "spec_helper"
describe V1::CompanyLicensesController do
describe :index do
let(:company) { Company.new }
let(:company_id) { SecureRandom.uuid }
let(:active_licenses) { ["active"] }
let(:active_licenses_in_township) { ["active township"] }
before { Company.stub(:find).with(company_id).and_return(company) }
it "returns the active licenses" do
company.stub(:filter_licenses_using).with(status: LicenseStatus::ACTIVE, township: nil).and_return(active_licenses)
get :index, company_id: company_id
assigns(:licenses).should == active_licenses
end
it "returns the active licenses for a given township" do
company.stub(:filter_licenses_using).with(status: LicenseStatus::ACTIVE, township: "123").and_return(active_licenses_in_township)
get :index, company_id: company_id, township: "123"
assigns(:licenses).should == active_licenses_in_township
end
end
describe :integration do
describe :index do
let(:company) { Company.create(name: 'ABC Resources Ltd.') }
let(:location) { Location.new(latitude: 51.06, longitude: -114.09, township: '1') }
let!(:license) { company.licenses.create(well_type: WellType::DEV, location: location, issued_at: 2.days.ago, expired_at: 1.day.ago) }
it "finds expired licenses from a specific township" do
get :index, company_id: company.id, status: "expired", township: "1"
assigns(:licenses).should include(license)
end
end
end
end
|