From 39fc3e184c1c185ffc9fc1f17bd19c5a8d9d0106 Mon Sep 17 00:00:00 2001 From: mo khan Date: Fri, 21 Feb 2014 23:43:42 -0700 Subject: move search filter method from controller down to model. --- spec/controllers/v1/company_licenses_controller_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'spec/controllers') diff --git a/spec/controllers/v1/company_licenses_controller_spec.rb b/spec/controllers/v1/company_licenses_controller_spec.rb index 198b4f3..e811179 100644 --- a/spec/controllers/v1/company_licenses_controller_spec.rb +++ b/spec/controllers/v1/company_licenses_controller_spec.rb @@ -2,18 +2,18 @@ require "spec_helper" describe V1::CompanyLicensesController do describe :index do - let(:company) { Object.new } + let(:company) { Company.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 + company.stub(:filter_licenses_using).with({status: LicenseStatus::ACTIVE, township: nil}).and_return(active_licenses) xhr :get, :index, company_id: company_id assigns(:active_licenses).should == active_licenses end @@ -24,6 +24,7 @@ describe V1::CompanyLicensesController do 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) xhr :get, :index, company_id: company_id, township: "123" assigns(:active_licenses).should == active_licenses_in_township end -- cgit v1.2.3