manage_documents_test.rb
2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
require "#{File.dirname(__FILE__)}/../test_helper"
class ManageDocumentsTest < ActionController::IntegrationTest
fixtures :users, :profiles, :comatose_pages, :domains, :environments
def test_creation_of_a_new_article
count = Article.count
login('ze', 'test')
assert_tag :tag => 'a', :attributes => { :href => '/account' }
get '/account'
assert_response :success
assert_tag :tag => 'a', :attributes => { :href => '/myprofile/ze/cms' }
get '/myprofile/ze/cms'
assert_response :success
assert_tag :tag => 'a', :attributes => { :href => '/myprofile/ze/cms/new' }
get '/myprofile/ze/cms/new'
assert_response :success
assert_tag :tag => 'form', :attributes => { :action => '/myprofile/ze/cms/new' }
post '/myprofile/ze/cms/new', :page => { :title => 'my new article', :body => 'this is the text of my new article' , :parent_id => Article.find_by_path('ze').id }
assert_response :redirect
follow_redirect!
assert_response :success
assert_equal '/myprofile/ze/cms', path
assert_equal count + 1, Article.count
end
def test_update_of_an_existing_article
login('ze', 'test')
get '/myprofile/ze/cms'
assert_response :success
id = Comatose::Page.find_by_path('ze').id
get "myprofile/ze/cms/edit/#{id}"
assert_response :success
assert_tag :tag => 'form', :attributes => { :action => "/myprofile/ze/cms/edit/#{id}" }
post "myprofile/ze/cms/edit/#{id}", :page => { :body => 'changed_body' }
assert_response :redirect
follow_redirect!
assert_equal '/myprofile/ze/cms', path
end
def test_removing_an_article
article = Article.create!(:title => 'to be removed', :body => 'go to hell', :parent_id => Article.find_by_path('ze').id)
count = Article.count
get '/myprofile/ze/cms'
assert_response :success
assert_tag :tag => 'a', :attributes => { :href => "/myprofile/ze/cms/delete/#{article.id}" }
post "/myprofile/ze/cms/delete/#{article.id}"
assert_response :redirect
follow_redirect!
assert_equal '/myprofile/ze/cms', path
assert_raise ActiveRecord::RecordNotFound do
Article.find(article.id)
end
end
# FIXME: add tests for page reordering
end