ActionController :: TestCase (아래 코드)를 사용하여 BranchController의 create 메소드를 테스트하고 있습니다. find_by_name 메서드를 호출하여 개체가 만들어 졌는지 확인합니다 (여기서는 이름이 고유하다고 가정). 테스트가 성공적으로 실행되었지만 mysql db에서 동일한 레코드를 확인할 때 해당 레코드가 존재하지 않습니다.레일 컨트롤러 테스트 : 테스트 성공 후 데이터베이스 상태가 변경되지 않습니까?
class Security::BranchControllerTest < ActionController::TestCase
test "the create" do
post(:create, :branch => {:name => "test branch", :details=> "test branch details"})
#replace find with where searching with all of fields
assert_not_nil Company::Branch.find_by_name("test branch")
end
end