1
0
mirror of https://github.com/fspc/bike-database.git synced 2025-02-23 01:23:24 -05:00

lk | doesn't display clients without agencies on the print select page

This commit is contained in:
Louis Knapp 2016-07-30 20:35:22 -05:00
parent b7090dba0d
commit ba23905e20
5 changed files with 20 additions and 2 deletions

View File

@ -32,7 +32,10 @@ class ClientsController < ApplicationController
end end
def print_select def print_select
@clients = Client.includes(:bike).where.not(bike_id: nil).order(application_date: :desc).paginate(:page => params[:page], :per_page => 30) @clients = Client.includes(:bike, :agency)
.where.not(bike_id: nil, agency_id: nil)
.order(application_date: :desc)
.paginate(:page => params[:page], :per_page => 30)
end end
def print_receipts def print_receipts

View File

@ -1,5 +1,6 @@
.container .container
%h1 Select the clients whose receipts you would like to print %h1 Select the clients whose receipts you would like to print
%p Only clients with a bike and an agency assigned are shown on this page.
=form_tag("/clients/print_receipts", method: "get") do =form_tag("/clients/print_receipts", method: "get") do
%table.table.table-striped.table-bordered.table-hover %table.table.table-striped.table-bordered.table-hover

View File

@ -8,6 +8,16 @@ describe ClientsController do
sign_in user sign_in user
end end
describe "#print_select" do
it "only assigns clients with a bike and an agency" do
client_with_bike_and_agency = create :client, bike: create(:bike), agency: create(:agency)
create :client, bike: create(:bike)
create :client, agency: create(:agency)
get :print_select
expect(assigns(:clients)).to eq [client_with_bike_and_agency]
end
end
describe "PUT #update" do describe "PUT #update" do
xit "updates a client with an application date" do xit "updates a client with an application date" do
put :update, id: client.id, client: {application_date: "12/21/2015"} put :update, id: client.id, client: {application_date: "12/21/2015"}

View File

@ -0,0 +1,5 @@
FactoryGirl.define do
factory :agency do
sequence(:name) { |n| "Agency #{n}" }
end
end

View File

@ -4,6 +4,5 @@ FactoryGirl.define do
last_name "Doe" last_name "Doe"
application_date Date.new(2010, 03, 02) application_date Date.new(2010, 03, 02)
gender "Male" gender "Male"
end end
end end