Вот создание в контроллере rfq:
def create
if has_create_right?
@rfq = Rfq.new(params[:rfq], :as => :roles_new )
#save into join table rfqs_standards
params[:rfq][:standard_ids].each do |sid|
@rfq.standards << Standard.find(sid.to_i) if !sid.nil?
end
if @rfq.save
redirect_to URI.escape("/view_handler?index=0&msg=RFQ saved!")
else
flash.now[:error] = "RFQ not saved!"
render 'new'
end
end
end
Вот код rspec
describe "'create'" do
it "should be successful for corp head" do
session[:corp_head] = true
session[:user_id] = 1
s = Factory(:standard)
rfq = Factory.attributes_for(:rfq)
rfq.standards << s
get 'create', :rfq => rfq
response.should redirect_to URI.escape("/view_handler?index=0&msg=RFQ saved!")
end
end
Ошибка:
1) RfqsController 'create' should be successful for corp head
Failure/Error: rfq.standards << s
NoMethodError:
undefined method `standards' for #<Hash:0x6741570>
# ./spec/controllers/rfqs_controller_spec.rb:65:in `block (3 levels) in <top (requi
Что правильноспособ проверить запись присоединения?Благодаря.