Browse Source

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

master
Louis Knapp 8 years ago
parent
commit
ba23905e20
  1. 5
      app/controllers/clients_controller.rb
  2. 1
      app/views/clients/print_select.html.haml
  3. 10
      spec/controllers/clients_controller_spec.rb
  4. 5
      spec/factories/agencies.rb
  5. 1
      spec/factories/clients.rb

5
app/controllers/clients_controller.rb

@ -32,7 +32,10 @@ class ClientsController < ApplicationController
end
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
def print_receipts

1
app/views/clients/print_select.html.haml

@ -1,5 +1,6 @@
.container
%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
%table.table.table-striped.table-bordered.table-hover

10
spec/controllers/clients_controller_spec.rb

@ -8,6 +8,16 @@ describe ClientsController do
sign_in user
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
xit "updates a client with an application date" do
put :update, id: client.id, client: {application_date: "12/21/2015"}

5
spec/factories/agencies.rb

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

1
spec/factories/clients.rb

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

Loading…
Cancel
Save