Commit 8bf5faf9c9fb161df68937d833f1f3067ab3745c

Authored by João M. M. da Silva + Caio Salgado
Committed by Caio
1 parent 39fe9156

[Mezuro] Writing and refactoring functionals profile tests

plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
... ... @@ -25,28 +25,31 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
25 25 @date = "2012-04-13T20:39:41+04:00"
26 26 end
27 27  
28   - should 'not find module result for inexistent project content' do
29   - get :module_result, :profile => '', :id => -1, :module_name => ''
  28 + should 'not find project state for inexistent project content' do
  29 + get :project_state, :profile => '', :id => -1
30 30 assert_response 404
31 31 end
32   -
  32 +
33 33 should 'get project state' do
34 34 create_project_content
35 35 Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project)
36 36 get :project_state, :profile => @profile.identifier, :id => @content.id
37 37 assert_response 200
38   - assert_equal @project.state, @response.body
39 38 end
40 39  
41 40 should 'get error state if project has error' do
42 41 create_project_content
43 42 Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project)
44   - @project.expects(:error).returns("")
  43 + @project.expects(:error).returns(ErrorFixtures.create)
45 44 get :project_state, :profile => @profile.identifier, :id => @content.id
46 45 assert_response 200
47   - assert_equal "ERROR", @response.body
48 46 end
49 47  
  48 + should 'not find content in project error for inexistent project content' do
  49 + get :project_error, :profile => '', :id => -1
  50 + assert_response 404
  51 + end
  52 +
50 53 should 'get project error' do
51 54 create_project_content
52 55 Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project)
... ... @@ -56,6 +59,11 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
56 59 assert_select('h3', 'ERROR')
57 60 end
58 61  
  62 + should 'not find project result for inexistent project content' do
  63 + get :project_result, :profile => '', :id => -1
  64 + assert_response 404
  65 + end
  66 +
59 67 should 'get project results without date' do
60 68 create_project_content
61 69 Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result)
... ... @@ -72,7 +80,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
72 80 get :project_result, :profile => @profile.identifier, :id => @content.id, :date => @project_result.date
73 81 assert_response 200
74 82 end
75   -
  83 +
  84 + should 'not find module result for inexistent project content' do
  85 + get :module_result, :profile => '', :id => -1, :module_name => ''
  86 + assert_response 404
  87 + end
  88 +
76 89 should 'get module result without date' do
77 90 create_project_content
78 91 mock_module_result
... ... @@ -91,6 +104,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
91 104 mock_project_result
92 105 get :module_result, :profile => @profile.identifier, :id => @content.id, :date => @project_result.date, :module_name => @name
93 106 assert_response 200
  107 + assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)')
  108 + end
  109 +
  110 + should 'not find project tree for inexistent project content' do
  111 + get :project_tree, :profile => '', :id => -1, :module_name => ''
  112 + assert_response 404
94 113 end
95 114  
96 115 should 'get project tree without date' do
... ... @@ -117,6 +136,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
117 136 get :module_grade_history, :profile => @profile.identifier, :id => @content.id, :module_name => @name
118 137 assert_response 200
119 138 end
  139 +
  140 + should 'not find project tree for inexistent project content' do
  141 + get :module_metrics_history, :profile => '', :id => -1, :module_name => ''
  142 + assert_response 404
  143 + end
  144 +
120 145  
121 146 private
122 147  
... ...