I am trying to run the following specification
describe "POST create" do describe "with valid params" do it "redirects to the created banner" do post :create, :banner => valid_attributes response.should redirect_to(admin_banner_url(Banner.last)) end end end def valid_attributes demo_image = File.open(File.join(Rails.root, "spec", "samples", "laptop1.jpg")) { :name => 'Test Spec Banner', :bannerimage => demo_image } end
A validation error is generated for validates_presence_of: bannerimage - I narrowed it down as follows:
- If I take validates_presence_of checks from bannerimage, it works, but the banner is reported as "missing.png"
- Banner.create! (valid_attributes) works
- I showed only one spec above, but the problem arises in any specification that includes this entry: create ,: banner => valid_attributes line
- I selected all the links to attr_accessible ... no difference
- I tried switching validate_attributes to Factory.attributes_for (: banner), with the same file information in: bannerimage
- The form works fine through the browser, including uploading / processing images
- File.Exists? confirms that the link file is indeed there.
If anyone has any ideas on why the message fails, I would really appreciate it. I guess (and I apologize - I did not look into the internal work of the "post" command and maybe here) that it skips some kind of "multipart" parameter in this call to receive files (?) ... I could not find anything through Google
Any ideas appreciated - I'm completely at a standstill.
The controller is a fully unmodified Rails 3.1 forest resource. The model is below.
class Banner < ActiveRecord::Base
source share