Displaying 2 results from an estimated 2 matches for "attributes_for".
2014 Feb 18
0
How to Test Multimodel Paperclip attachments?
...s. From searching other questions, it seems like a single
image attachment is more common.
Car.rb
class Car < ActiveRecord::Base
has_many :uploads, dependent: :destroy
validates :uploads, presence: { message: 'You must upload at least
one image' }
accepts_nested_attributes_for :uploads, allow_destroy: true
end
Upload.rb
class Upload < ActiveRecord::Base
belongs_to :car
has_attached_file :upload, styles: { medium: '300x300>', thumb:
'100x100>' }
validates_attachment_content_type :upload, content_type:
/\Aimage\/.*\Z/...
2012 Nov 12
7
RSpec: controller POST create
Rails 3.1.3
rspec-rails (2.11.4)
rspec 2.11.1
I am new to rspec. I don''t quite understand tests for POST create part.
I have generated scaffold, and simultaneously it generated
controller_spec.rb as well.
it "assigns a newly created plan as @plan" do
post :create, {:plan => valid_attributes}, valid_session
assigns(:plan).should be_a(Plan)