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