0
我在測試我的應用程序。我有一個功能,您可以通過名字,姓氏,城市,州等搜索註冊成員...我認爲集成測試會比控制器測試更好,但我很難找出在哪裏開始。這裏是我的控制器代碼:爲搜索控制器編寫Rails集成測試
class MsearchesController < ApplicationController
def new
@msearch = Msearch.new
@first_name = User.uniq.pluck(:first_name)
@last_name = User.uniq.pluck(:last_name)
@state = User.uniq.pluck(:state)
@cities = User.uniq.pluck(:city)
end
def create
@msearch = Msearch.create(msearch_params)
redirect_to @msearch
end
def show
@users = User.all
@msearch = Msearch.find(params[:id])
@first_name = User.uniq.pluck(:first_name)
@last_name = User.uniq.pluck(:last_name)
@states = User.uniq.pluck(:state)
@cities = User.uniq.pluck(:city)
end
def update
@msearch = Msearch.new
end
private
def msearch_params
params.require(:msearch).permit(:first_name, :last_name, :state, :city, :agency)
end
end
任何幫助讓我開始將非常感激!
感謝您的指導! –