Commit f9c4fdeadd6503cc86d6de5cc1d4a80f31658e4e

Authored by AntonioTerceiro
1 parent a6c9836d

ActionItem21: writing integration test


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1008 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing 1 changed file with 36 additions and 4 deletions   Show diff stats
test/integration/manage_documents_test.rb
... ... @@ -28,13 +28,45 @@ class ManageDocumentsTest < ActionController::IntegrationTest
28 28 end
29 29  
30 30 def test_update_of_an_existing_article
31   - # FIXME
32   - fail 'need to be rewritten'
  31 + profile = create_user('myuser').person
  32 + article = profile.articles.build(:name => 'my-article')
  33 + article.save!
  34 +
  35 + login('myuser', 'myuser')
  36 +
  37 + assert_tag :tag => 'a', :attributes => { :href => '/myprofile/myuser' }
  38 + get '/myprofile/myuser'
  39 + assert_response :success
  40 +
  41 + assert_tag :tag => 'a', :attributes => { :href => '/myprofile/myuser/cms' }
  42 + get '/myprofile/myuser/cms'
  43 + assert_response :success
  44 +
  45 + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/myuser/cms/view/#{article.id}"}
  46 + get "/myprofile/myuser/cms/view/#{article.id}"
  47 + assert_response :success
  48 +
  49 + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/myuser/cms/edit/#{article.id}"}
  50 + get "/myprofile/myuser/cms/edit/#{article.id}"
  51 + assert_response :success
  52 +
  53 + assert_tag :tag => 'form', :attributes => { :action => "/myprofile/myuser/cms/edit/#{article.id}", :method => /post/i }
  54 +
  55 + assert_no_difference Article, :count do
  56 + post "/myprofile/myuser/cms/edit/#{article.id}", :article => { :name => 'my article', :body => 'this is the body of the article'}
  57 + end
  58 +
  59 + article.reload
  60 + assert_equal 'this is the body of the article', article.body
  61 +
  62 + assert_response :redirect
  63 + follow_redirect!
  64 + a = Article.find_by_path('my-article')
  65 + assert_equal "/myprofile/myuser/cms/view/#{a.id}", path
33 66 end
34 67  
35 68 def test_removing_an_article
36   - # FIXME
37   - fail 'need to be rewritten'
  69 + flunk 'pending'
38 70 end
39 71  
40 72 end
... ...