3 class UserDiariesTest < ActionDispatch::IntegrationTest
4 # Test the creation of a diary entry, making sure that you are redirected to
5 # login page when not logged in
6 def test_showing_create_diary_entry
12 # We should now be at the login page
13 assert_response :success
14 assert_template "users/login"
16 post "/login", :params => { "username" => user.email, "password" => "test", :referer => "/diary/new" }
17 assert_response :redirect
18 # print @response.body
19 # Check that there is some payload alerting the user to the redirect
20 # and allowing them to get to the page they are being directed to
21 assert_select "html:root" do
22 assert_select "body" do
23 assert_select "a[href='http://www.example.com/diary/new']"
26 # Required due to a bug in the rails testing framework
27 # http://markmail.org/message/wnslvi5xv5moqg7g
31 assert_response :success
32 assert_template "diary_entries/new"
33 # print @response.body
34 # print @html_document.to_yaml
36 # We will make sure that the form exists here, full
37 # assert testing of the full form should be done in the
38 # functional tests rather than this integration test
39 # There are some things that are specific to the integratio
40 # that need to be tested, which can't be tested in the functional tests
41 assert_select "div.content-heading", :count => 1 do
42 assert_select "h1", "New Diary Entry"
44 assert_select "div#content" do
45 assert_select "form[action='/diary']" do
46 assert_select "input[id=diary_entry_title]"