2017-12-01 10 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)。 –

関連する問題