]> git.openstreetmap.org Git - rails.git/blob - test/integration/user_diaries_test.rb
Merge branch 'p' of https://github.com/jfirebaugh/openstreetmap-website into jfirebaugh-p
[rails.git] / test / integration / user_diaries_test.rb
1 require "test_helper"
2
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
7     user = create(:user)
8
9     get "/diary/new"
10     follow_redirect!
11     follow_redirect!
12     # We should now be at the login page
13     assert_response :success
14     assert_template "user/login"
15     # We can now 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']"
24       end
25     end
26     # Required due to a bug in the rails testing framework
27     # http://markmail.org/message/wnslvi5xv5moqg7g
28     @html_document = nil
29     follow_redirect!
30
31     assert_response :success
32     assert_template "diary_entry/edit"
33     # print @response.body
34     # print @html_document.to_yaml
35
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"
43     end
44     assert_select "div#content" do
45       assert_select "form[action='/diary/new']" do
46         assert_select "input[id=diary_entry_title]"
47       end
48     end
49   end
50 end