0
我在控制這個動作:更新無效的屬性重新呈現新的模板,而不是編輯
def update
@board = Board.find(params[:board_id])
@category = Category.find(params[:id])
if @category.update_attributes(category_params)
flash[:notice] = "You sucessfully changed category name."
redirect_to settings_board_path(@board)
else
render :edit
end
end
和解決這個測試案例:
context "with invalid attributes" do
let(:updated_category) { FactoryGirl.attributes_for(:category, name: "") }
it "re-renders :edit template" do
patch :create, board_id: board, id: category, category: updated_category
expect(response).to render_template :edit
end
end
我得到這個錯誤:
expecting <"edit"> but rendering with <["categories/new", "layouts/application"]>
任何想法爲什麼?
Blah,謝謝:) –