2017-12-01 13 views
1

올바르게 이해했다면 아래 양식과 같이 사용자를 만들면 데이터베이스에 레코드가 생성되지 않습니다.가입 후 시스템 테스트를 통해 계정 페이지를 방문하십시오.

나는 다음 단계를 수행하기 위해 시스템 테스트를 만들려면 : 형태
1. 가입을
2. 방문 계정 페이지
3. 업데이트 계정 정보를 수행 할 수있는 것이 무엇 기술

위의 시나리오?

within 'form#t-signup-form' do 
    fill_in 'first_name', with: 'Eve' 
    fill_in 'last_name', with: 'Farmer' 
    fill_in 'email', with: '[email protected]' 
    fill_in 'password', with: 'Something' 
    find('button').click 
end 

답변

1

사용자 레코드가 실제로 데이터베이스에 커밋되는지 여부는 트랜잭션 테스트를 사용하는지 여부에 따라 다릅니다. 트랜잭션 테스트를 사용하는 경우 레코드가 실제로 커밋되지는 않지만 테스트 및 응용 프로그램의 모든 항목이 동일한 사전 커밋 트랜잭션에 액세스해야하므로 레코드를 확인해야하므로 중요하지 않아야합니다. 당신이하는 것을 당신이 원하는대로하기 위해서

visit signup_path #whatever is the correct route to the page with the signup form 
within '#t-signup-form' do 
    fill_in 'first_name', with: 'Eve' 
    fill_in 'last_name', with: 'Farmer' 
    fill_in 'email', with: '[email protected]' 
    fill_in 'password', with: 'Something' 
    find('button').click 
end 
assert_content('You are signed up!') # assert for visible change in page that indicates signup has succeeded 
visit account_path # route to whatever page you want to go to 
... # do whatever actions are required to update the account 
+0

고마워요! 이것은 눈을 뜨게했다. 그러나 내 뿌리 문제는 여전히 불행히도 여전히 있습니다. 나는 그것을 볼 시간이 있다면 나는 [그것에 대한 새로운 질문을 만들었다] (https://stackoverflow.com/questions/47604409/setting-current-user-in-system-tests). –