Commit 4b33b10ab20a7f1794218ae4e26617a9ab11b4b0
Exists in
master
and in
28 other branches
Merge branch 'functional_tests' into merging
Showing
2 changed files
with
45 additions
and
10 deletions
Show diff stats
plugins/mezuro/test/fixtures/native_metric_fixtures.rb
@@ -26,4 +26,4 @@ class NativeMetricFixtures | @@ -26,4 +26,4 @@ class NativeMetricFixtures | ||
26 | {:name => 'Average Method LOC', :scope => 'CLASS', :origin => 'Analizo', :language => ['JAVA']} | 26 | {:name => 'Average Method LOC', :scope => 'CLASS', :origin => 'Analizo', :language => ['JAVA']} |
27 | end | 27 | end |
28 | 28 | ||
29 | -end | ||
30 | \ No newline at end of file | 29 | \ No newline at end of file |
30 | +end |
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
@@ -19,34 +19,36 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -19,34 +19,36 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
19 | @module_result = ModuleResultFixtures.create | 19 | @module_result = ModuleResultFixtures.create |
20 | @project = @project_result.project | 20 | @project = @project_result.project |
21 | @name = @project.name | 21 | @name = @project.name |
22 | - | 22 | + |
23 | @date = "2012-04-13T20:39:41+04:00" | 23 | @date = "2012-04-13T20:39:41+04:00" |
24 | 24 | ||
25 | - @date = "2012-04-13T20:39:41+04:00" | ||
26 | end | 25 | end |
27 | 26 | ||
28 | - should 'not find module result for inexistent project content' do | ||
29 | - get :module_result, :profile => '', :id => -1, :module_name => '' | 27 | + should 'not find project state for inexistent project content' do |
28 | + get :project_state, :profile => '', :id => -1 | ||
30 | assert_response 404 | 29 | assert_response 404 |
31 | end | 30 | end |
32 | - | 31 | + |
33 | should 'get project state' do | 32 | should 'get project state' do |
34 | create_project_content | 33 | create_project_content |
35 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) | 34 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) |
36 | get :project_state, :profile => @profile.identifier, :id => @content.id | 35 | get :project_state, :profile => @profile.identifier, :id => @content.id |
37 | assert_response 200 | 36 | assert_response 200 |
38 | - assert_equal @project.state, @response.body | ||
39 | end | 37 | end |
40 | 38 | ||
41 | should 'get error state if project has error' do | 39 | should 'get error state if project has error' do |
42 | create_project_content | 40 | create_project_content |
43 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) | 41 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) |
44 | - @project.expects(:error).returns("") | 42 | + @project.expects(:error).returns(ErrorFixtures.create) |
45 | get :project_state, :profile => @profile.identifier, :id => @content.id | 43 | get :project_state, :profile => @profile.identifier, :id => @content.id |
46 | assert_response 200 | 44 | assert_response 200 |
47 | - assert_equal "ERROR", @response.body | ||
48 | end | 45 | end |
49 | 46 | ||
47 | + should 'not find content in project error for inexistent project content' do | ||
48 | + get :project_error, :profile => '', :id => -1 | ||
49 | + assert_response 404 | ||
50 | + end | ||
51 | + | ||
50 | should 'get project error' do | 52 | should 'get project error' do |
51 | create_project_content | 53 | create_project_content |
52 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) | 54 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) |
@@ -56,6 +58,11 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -56,6 +58,11 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
56 | assert_select('h3', 'ERROR') | 58 | assert_select('h3', 'ERROR') |
57 | end | 59 | end |
58 | 60 | ||
61 | + should 'not find project result for inexistent project content' do | ||
62 | + get :project_result, :profile => '', :id => -1 | ||
63 | + assert_response 404 | ||
64 | + end | ||
65 | + | ||
59 | should 'get project results without date' do | 66 | should 'get project results without date' do |
60 | create_project_content | 67 | create_project_content |
61 | Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result) | 68 | Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result) |
@@ -72,7 +79,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -72,7 +79,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
72 | get :project_result, :profile => @profile.identifier, :id => @content.id, :date => @project_result.date | 79 | get :project_result, :profile => @profile.identifier, :id => @content.id, :date => @project_result.date |
73 | assert_response 200 | 80 | assert_response 200 |
74 | end | 81 | end |
75 | - | 82 | + |
83 | + should 'not find module result for inexistent project content' do | ||
84 | + get :module_result, :profile => '', :id => -1, :module_name => '' | ||
85 | + assert_response 404 | ||
86 | + end | ||
87 | + | ||
76 | should 'get module result without date' do | 88 | should 'get module result without date' do |
77 | create_project_content | 89 | create_project_content |
78 | mock_module_result | 90 | mock_module_result |
@@ -91,6 +103,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -91,6 +103,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
91 | mock_project_result | 103 | mock_project_result |
92 | get :module_result, :profile => @profile.identifier, :id => @content.id, :date => @project_result.date, :module_name => @name | 104 | get :module_result, :profile => @profile.identifier, :id => @content.id, :date => @project_result.date, :module_name => @name |
93 | assert_response 200 | 105 | assert_response 200 |
106 | + assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') | ||
107 | + end | ||
108 | + | ||
109 | + should 'not find project tree for inexistent project content' do | ||
110 | + get :project_tree, :profile => '', :id => -1, :module_name => '' | ||
111 | + assert_response 404 | ||
94 | end | 112 | end |
95 | 113 | ||
96 | should 'get project tree without date' do | 114 | should 'get project tree without date' do |
@@ -117,12 +135,29 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -117,12 +135,29 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
117 | get :module_grade_history, :profile => @profile.identifier, :id => @content.id, :module_name => @name | 135 | get :module_grade_history, :profile => @profile.identifier, :id => @content.id, :module_name => @name |
118 | assert_response 200 | 136 | assert_response 200 |
119 | end | 137 | end |
138 | + | ||
139 | + should 'not find metrics history for inexistent project content' do | ||
140 | + get :module_metrics_history, :profile => '', :id => -1, :module_name => '' | ||
141 | + assert_response 404 | ||
142 | + end | ||
143 | + #copied from 'get grade history' test | ||
144 | + should 'get metrics history' do | ||
145 | + create_project_content | ||
146 | + mock_module_result_history | ||
147 | + Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) | ||
148 | + get :module_metrics_history, :profile => @profile.identifier, :id => @content.id, :module_name => @name, | ||
149 | + :metric_name => @module_result.metric_result.first.metric.name.delete("() ") | ||
150 | + assert_response 200 | ||
151 | + end | ||
120 | 152 | ||
121 | private | 153 | private |
122 | 154 | ||
123 | def create_project_content | 155 | def create_project_content |
156 | + client = mock | ||
124 | @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => @name) | 157 | @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => @name) |
125 | @content.expects(:send_project_to_service).returns(nil) | 158 | @content.expects(:send_project_to_service).returns(nil) |
159 | + Kalibro::Client::ProjectClient.expects(:new).returns(client) | ||
160 | + client.expects(:project_names).returns([]) | ||
126 | @content.save | 161 | @content.save |
127 | end | 162 | end |
128 | 163 |