Rails 'post' command in rspec controllers: Files aren't passing through. (Is there a multipart setting?) -


I am trying to run the following space

  describe "create post" Describe the "with valid parameters" post it redirects to the "created banner": create: banner = & gt; Valid_attributes response.should redirect_to (admin_banner_url (banner.lists)) End end end valid valid_attributes demo_image = File.open (File (Rails.root, "spec", "samples", "laptop1.jpg")) {: Name = & gt; 'Test Speak Banner' ,: bannerimage = & gt; Demo_image} end   

Validation failed on validates_presence_of: bannerimage - I have narrowed down to:

  • If I turn off validates_presence_of validation of Bannerimage It works, but the banner has been reported as 'absentee'
  • banner.credited! (Valid_addresses) works
  • I have shown only one speck, but there is a problem on any device, in which the post is included: Create: banner = & gt; Valid_attributes line
  • I have removed every reference for attr_accessible ... there is no difference
  • I have tried switching the validate_attributes to the factory. Databack (: banner), with information about the same file: bannerimage
  • Works fine with a Forof Browser, which includes image upload / processing
  • File. Exists? Confirms that the referenced file actually exists there.

    If someone has a suggestion why the post is unsuccessful, I would highly appreciate it. I'm guessing (and sorry - I have not seen in the inner workings of the 'post' command and can be closed here) to accept the files, some kind of 'multipart' parameters are missing on that call. .

    Any thoughts appreciated - I have been completely stumped.

    The controller is a completely unpredictable Rail 3.1 Scaffold resource. Model below.

      class banner & lt; ActiveRecord :: Base #Array_acable: Name ,: URL ,: BannerMail is_Tabbed_File: BannerMaze ,: styles = & gt; {: FULL = & gt; "960x",: thumb = & gt; "100x"} is valid_datetime_cent_type: banner image ,: content_type = & gt; ['Image / jpg', 'image / jpeg', 'image / gif', 'image / png'],: message = & gt; 'File should be a GIF, JPEG or PNG image' validates_attachment_size: bannerimage,: less_than = & gt; 3.Magabytes validates_presence_of: name validates_attachment_presence: bannerimage validates_uniqueness_of: name has_many: pages ,: depend => : Def to_s name expiration    

    Depending on your specific test setup, some combinations include the following file Instead of sending it can be a job. This function is defined by the rail, and it is defined by the rail. And I believe it is available with RSPC-Rail, although the rail is expecting you to use TestUnit

    I used it in cucumber step definitions, it works in rspec examples Can do.

      rack :: test :: uploaded file.New ('spec / samples / laptop1.jpg', 'image / jpg')    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -