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,28 +25,31 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
25 @date = "2012-04-13T20:39:41+04:00" 25 @date = "2012-04-13T20:39:41+04:00"
26 end 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 assert_response 404 30 assert_response 404
31 end 31 end
32 - 32 +
33 should 'get project state' do 33 should 'get project state' do
34 create_project_content 34 create_project_content
35 Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) 35 Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project)
36 get :project_state, :profile => @profile.identifier, :id => @content.id 36 get :project_state, :profile => @profile.identifier, :id => @content.id
37 assert_response 200 37 assert_response 200
38 - assert_equal @project.state, @response.body  
39 end 38 end
40 39
41 should 'get error state if project has error' do 40 should 'get error state if project has error' do
42 create_project_content 41 create_project_content
43 Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) 42 Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project)
44 - @project.expects(:error).returns("") 43 + @project.expects(:error).returns(ErrorFixtures.create)
45 get :project_state, :profile => @profile.identifier, :id => @content.id 44 get :project_state, :profile => @profile.identifier, :id => @content.id
46 assert_response 200 45 assert_response 200
47 - assert_equal "ERROR", @response.body  
48 end 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 should 'get project error' do 53 should 'get project error' do
51 create_project_content 54 create_project_content
52 Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) 55 Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project)
@@ -56,6 +59,11 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase @@ -56,6 +59,11 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
56 assert_select('h3', 'ERROR') 59 assert_select('h3', 'ERROR')
57 end 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 should 'get project results without date' do 67 should 'get project results without date' do
60 create_project_content 68 create_project_content
61 Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result) 69 Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result)
@@ -72,7 +80,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase @@ -72,7 +80,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
72 get :project_result, :profile => @profile.identifier, :id => @content.id, :date => @project_result.date 80 get :project_result, :profile => @profile.identifier, :id => @content.id, :date => @project_result.date
73 assert_response 200 81 assert_response 200
74 end 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 should 'get module result without date' do 89 should 'get module result without date' do
77 create_project_content 90 create_project_content
78 mock_module_result 91 mock_module_result
@@ -91,6 +104,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase @@ -91,6 +104,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
91 mock_project_result 104 mock_project_result
92 get :module_result, :profile => @profile.identifier, :id => @content.id, :date => @project_result.date, :module_name => @name 105 get :module_result, :profile => @profile.identifier, :id => @content.id, :date => @project_result.date, :module_name => @name
93 assert_response 200 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 end 113 end
95 114
96 should 'get project tree without date' do 115 should 'get project tree without date' do
@@ -117,6 +136,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase @@ -117,6 +136,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
117 get :module_grade_history, :profile => @profile.identifier, :id => @content.id, :module_name => @name 136 get :module_grade_history, :profile => @profile.identifier, :id => @content.id, :module_name => @name
118 assert_response 200 137 assert_response 200
119 end 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 private 146 private
122 147