Class PortalControllerTest
In: test/functional/portal_controller_test.rb
Parent: Test::Unit::TestCase

Methods

Public Instance methods

[Source]

    # File test/functional/portal_controller_test.rb, line 24
24:   def setup
25:     logger.debug "Test Case: #{name}"  
26:     @controller = PortalController.new
27:     @request    = ActionController::TestRequest.new
28:     @response   = ActionController::TestResponse.new
29:     @andy = users(:andy) # admin
30:     @george = users(:george) #cadmin
31:     @tony = users(:tony) #user
32:     #create_templates
33:     #@emails = ActionMailer::Base::deliveries
34:     #@emails.clear
35:     #get :list     
36:   end

[Source]

    # File test/functional/portal_controller_test.rb, line 38
38:   def teardown
39:     [ENV['EPFWIKI_SITES_PATH'], ENV['EPFWIKI_WIKIS_PATH']].each do |p|
40:       FileUtils.rm_r(p) if File.exists?(p)
41:       File.makedirs(p)
42:     end
43:   end

Shows:

  1. We can access home, wikis, users … when there is no data
  2. We can access … with data

[Source]

    # File test/functional/portal_controller_test.rb, line 48
48:   def test_all
49:     # 1.
50:     @wiki = create_templates
51:     get :home
52:     assert_response :success
53:     get :wikis
54:     assert_response :success
55:     get :users
56:     assert_response :success
57:     get :about
58:     assert_response :success
59:     get :feedback
60:     assert_response :success
61:     get :privacypolicy
62:     assert_response :success
63:     get :termsofuse
64:     assert_response :success
65:     get :archives, :year => Time.now.year, :month => Time.now.month
66:     assert_response :success
67: 
68:     # 2. 
69:     create_some_data(WikiPage.find(:first))  
70:     get :home
71:     assert_response :success
72:     get :wikis
73:     assert_response :success
74:     get :users
75:     assert_response :success
76:     get :about
77:     assert_response :success
78:     get :feedback
79:     assert_response :success
80:     get :privacypolicy
81:     assert_response :success
82:     get :termsofuse
83:     assert_response :success
84:     get :archives, :year => Time.now.year, :month => Time.now.month
85:     assert_response :success
86:   end

Shows that if there no users, the user is redirected to create the first user

[Source]

    # File test/functional/portal_controller_test.rb, line 89
89:   def test_home
90:     User.destroy_all
91:     get :home
92:     assert_redirected_to :controller => 'login'
93:   end

Shows:

[Source]

     # File test/functional/portal_controller_test.rb, line 96
 96:   def test_with_different_status_wikis
 97:     create_templates
 98:     # 1.
 99:     get :home
100:     assert_response :success
101:     get :about
102:     assert_response :success
103:     get :wikis
104:     assert_response :success
105:     get :feedback
106:     assert_response :success    
107:     # 2.
108:     w1 = Wiki.create(:folder =>'test_with_different_status_wikis', :user => @andy, :title => 'test_with_different_status_wikis', :description => 'test_with_different_status_wikis' )
109:     assert_equal 'Pending', w1.status 
110:     w2 = Wiki.create(:folder =>'test_with_different_status_wikis2', :user => @andy, :title => 'test_with_different_status_wikis2', :description => 'test_with_different_status_wikis2' )    
111:     assert_equal 'Pending', w2.status
112:     bp = BaselineProcess.find(:first)
113:     update = Update.create(:baseline_process => bp, :wiki => w2, :user => @andy)
114:     assert_equal 'Scheduled', w2.status
115:     update.do_update
116:     w2.reload
117:     assert_equal 'Ready', w2.status
118:     w3 = Wiki.create(:folder =>'test_with_different_status_wikis3', :user => @andy, :title => 'test_with_different_status_wikis3', :description => 'test_with_different_status_wikis3' )    
119:     update = Update.create(:baseline_process => bp, :wiki => w3, :user => @andy)
120:     update.do_update
121:     update = Update.create(:baseline_process => bp, :wiki => w3, :user => @andy)
122:     w3.reload
123:     assert_equal 'Scheduled', w3.status 
124:     get :home
125:     assert_response :success
126:     get :about
127:     assert_response :success
128:     get :wikis
129:     assert_response :success
130:     get :feedback
131:     assert_response :success     
132:   end

[Validate]