blob: 2784a1dd3df1e004f1ea6f949312a8f5a66ae3b0 (
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
|
require "spec_helper"
describe V1::CompanyLicensesController do
describe :index do
let(:company) { Object.new }
let(:company_id) { SecureRandom.uuid }
let(:active_licenses) { ["active"] }
let(:active_licenses_in_township) { ["active township"] }
before :each do
Company.stub(:find).with(company_id).and_return(company)
company.stub(:status).with(LicenseStatus::ACTIVE).and_return(active_licenses)
active_licenses.stub(:township).with("123").and_return(active_licenses_in_township)
end
it "returns the active licenses" do
xhr :get, :index, company_id: company_id
assigns(:active_licenses).should == active_licenses
end
it "returns a json response" do
xhr :get, :index, company_id: company_id
expect(-> { JSON.parse(response.body) }).not_to raise_error
end
it "returns the active licenses for a given township" do
xhr :get, :index, company_id: company_id, township: "123"
assigns(:active_licenses).should == active_licenses_in_township
end
end
end
|