We have Griddler Model tests working fine. e.g. we can instantiate the lib/email_processor.rb and it processes. We want to create a controller test that does an end to end post to the standard /email_processor.
The problem is the params are not coming through the post. our basic code is:
@postattr= {to: "hello@hello.com", subject: "a subject", attachments: [
ActionDispatch::Http::UploadedFile.new({
filename: 'example_virgin_onetransaction.pdf',
type: 'application/pdf',
tempfile: File.new('testfiles/examplefile.pdf")})
]}
post :create, @postattr
expect(response).to be_success
it works as it posts to the correct route and gets processed except the email.attachments object is nil.
we've tried
- @postattr.to_json # gives invalid byte sequence in UTF-8
- @postattr.to_s.to_json # works, but no params passed through
- uri encoding the json string
nothing seems to get processed correctly. what have we missed?