Skip to content

Instantly share code, notes, and snippets.

@jeremiahlukus
Last active December 29, 2017 14:25
Show Gist options
  • Save jeremiahlukus/d6e67f58dde84f15ec9de053c15841f3 to your computer and use it in GitHub Desktop.
Save jeremiahlukus/d6e67f58dde84f15ec9de053c15841f3 to your computer and use it in GitHub Desktop.
5 describe "POST #create" do
4 describe "with valid params" do
3 it "creates a new inbound order" do
0 inbound_params = FactoryGirl.attributes_for(:inbound_order, documents: [Document.create(name: Faker::App.name, doc: File.new("#{Rails.root}/spec/fixtures/test_file.pdf"))])
1 expect { post :create, :inbound_order => inbound_params }.to change(InboundOrder, :count).by(1)
2 end
3
==============================================================================================
BINDING PRY
==============================================================================================
[1] pry(#<RSpec::ExampleGroups::ShipperInboundOrdersController::WithLoggedInAsShipper::POSTCreate::WithValidParams>)> inbound_params
=> {:facility_id=>2,
:company_id=>1,
:project_id=>1,
:user_id=>1,
:order_state_id=>1,
:documents=>
[#<Document:0x007f9296286c18
id: 3,
name: "Konklux",
created_at: Fri, 29 Dec 2017 14:04:51 UTC +00:00,
updated_at: Fri, 29 Dec 2017 14:04:51 UTC +00:00,
doc_file_name: "test_file.pdf",
doc_content_type: "application/pdf",
doc_file_size: 1304010,
doc_updated_at: Fri, 29 Dec 2017 14:04:51 UTC +00:00,
outbound_order_id: nil,
inbound_order_id: nil,
slug: "447016314",
reference_number: nil>]}
==============================================================================================
==============================================================================================
I get this error even though the document is in the inbound_params
Failure/Error: elsif @inbound_order.documents.last.name == ""
NoMethodError:
undefined method `name' for nil:NilClass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment