]> git.openstreetmap.org Git - rails.git/blob - test/integration/user_diaries_test.rb
more diary entry tests, and a minor fix to the relation member that makes the code...
[rails.git] / test / integration / user_diaries_test.rb
1 require File.dirname(__FILE__) + '/../test_helper'
2
3 class UserDiariesTest < ActionController::IntegrationTest
4   fixtures :users, :diary_entries
5
6   def test_showing_create_diary_entry
7     get_via_redirect '/user/test/diary/new'
8     # We should now be at the login page
9     assert_response :success
10     assert_template 'user/login'
11     # We can now login
12     post  '/login', {'user[email]' => "test@openstreetmap.org", 'user[password]' => "test", :referer => '/user/test/diary/new'}
13     assert_response :redirect
14     #print @response.body
15     # Check that there is some payload alerting the user to the redirect
16     # and allowing them to get to the page they are being directed to
17     assert_select "html:root" do
18       assert_select "body" do
19         assert_select "a[href='http://www.example.com/user/test/diary/new']"
20       end
21     end
22     # Required due to a bug in the rails testing framework
23     # http://markmail.org/message/wnslvi5xv5moqg7g
24     @html_document = nil
25     follow_redirect!
26     
27     assert_response :success
28     assert_template 'diary_entry/edit'
29     #print @response.body
30     #print @html_document.to_yaml
31
32     assert_select "html:root" do
33       assert_select "body" do
34         assert_select "div#content" do
35           assert_select "h1", "New diary entry" 
36           assert_select "form" do
37             assert_select "input[id=diary_entry_title]"
38           end
39         end
40       end
41     end
42   end
43 end