Вот ошибка rspec для обновления в контроллере клиента:
5) CustomersController GET customer page 'update' should be successful
Failure/Error: put 'update', id => 1, :customer => {:name => 'name changed'}
<Customer(id: integer, name: string, short_name: string, contact: string, address: string, country: string, phone: string, fax: string, email: string, cell:
string, sales_id: integer, test_eng_id: integer, safety_eng_id: integer, web: string, category1_id: integer, category2_id: integer, active: boolean, biz_status: str
ing, input_by_id: integer, quality_system: string, employee_num: string, revenue: string, note: text, user_id: integer, created_at: datetime, updated_at: datetime)
(class)> received :find with unexpected arguments
expected: (1)
got: ("1")
# ./app/controllers/customers_controller.rb:44:in `update'
# ./spec/controllers/customers_controller_spec.rb:41:in `block (3 levels) in <top (required)>'
Вот код rspec:
it "'update' should be successful" do
customer = mock_model(Customer)
Customer.should_receive(:find).with(1).and_return(customer)
customer.stub(:update_attributes).and_return(true)
put 'update', :id => 1, :customer => {:name => 'name changed'}
response.status.should == 302 #redirect()
end
Вот обновление в контроллере:
def update
@customer = Customer.find(params[:id])
if @customer.update_attributes(params[:customer], :as => :roles_new_update)
if @customer.changed
@message = 'The following info have been changed\n' + @customer.changes.to_s
@subject ='Customer info was changed BY' + session[:user_name]
notify_all_in_sales_eng(@message,@subject)
end
redirect_to session[('page'+session[:page_step].to_s).to_sym], :notice => 'Customer was updated successfaully!'
else
render 'edit', :notice => 'Customer was not updated!'
end
end
Есть мысли?Благодаря.