「名前」の通常の入力フィールドと「コンテンツ」のCKeditorテキストエリアを含むフォームがあります。ここで説明したように、フォームに入力できます。ここで停止すると、Test データベースで「name」列と「content」列が正しく更新されていることがわかります。罰金。
今、もしそうなら:
template = ContractTemplate.all.last
puts "#{template.name}" # => "template_name"
puts "#{template.content}" # => "<p>template_content</p>"
そして、問題が始まります.これら2つの属性を更新しようとすると(まだCapybaraを使用しています)、「作成」アクションで保存された値に常にフォールバックしますが、データベースに正しく更新されます. 値の更新がないのと同じです。ContractTemplate.reload を実行しようとしましたが、うまくいきません。
完全な仕様は次のとおりです。
it 'should edit a contract template', :js => true do
visit contract_templates_path
click_link "Add"
fill_in "contract_template_name", :with => "test_template_name"
fill_in_ckeditor "contract_template_content", :with => "test_template_content"
click_button "Save"
template = ContractTemplate.all.last
template.name.should eq("test_template_name") # pass, content created
template.content.should eq("<p>\r\n\ttest_template_content</p>\r\n") # pass
visit contract_template_path(template.id)
fill_in "contract_template_name", :with => "edited_test_template_name"
fill_in_ckeditor "contract_template_content", :with => "edited_test_template_content"
click_button "Save"
template.name.should eq("edited_test_template_name") # Fail, because == "test_template_name"
template.content.should eq("<p>\r\n\tedited_test_template_content</p>\r\n") # Fail, not updated too
end
私のアプローチは間違っているかもしれませんが、「コンテンツ」属性はwisiwigエディターを使用して入力されているため、保存アクションが実際に名前とコンテンツを更新するかどうかをテストする他の方法がわかりません...ところで、ビューはありませんテキストエリアの結果を表示できるアプリで、すべて PDF としてレンダリングされます。
誰かが私を助けることができますか?