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
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
| ... | ... | @@ -19,34 +19,36 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase |
| 19 | 19 | @module_result = ModuleResultFixtures.create |
| 20 | 20 | @project = @project_result.project |
| 21 | 21 | @name = @project.name |
| 22 | - | |
| 22 | + | |
| 23 | 23 | @date = "2012-04-13T20:39:41+04:00" |
| 24 | 24 | |
| 25 | - @date = "2012-04-13T20:39:41+04:00" | |
| 26 | 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 | 29 | assert_response 404 |
| 31 | 30 | end |
| 32 | - | |
| 31 | + | |
| 33 | 32 | should 'get project state' do |
| 34 | 33 | create_project_content |
| 35 | 34 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) |
| 36 | 35 | get :project_state, :profile => @profile.identifier, :id => @content.id |
| 37 | 36 | assert_response 200 |
| 38 | - assert_equal @project.state, @response.body | |
| 39 | 37 | end |
| 40 | 38 | |
| 41 | 39 | should 'get error state if project has error' do |
| 42 | 40 | create_project_content |
| 43 | 41 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) |
| 44 | - @project.expects(:error).returns("") | |
| 42 | + @project.expects(:error).returns(ErrorFixtures.create) | |
| 45 | 43 | get :project_state, :profile => @profile.identifier, :id => @content.id |
| 46 | 44 | assert_response 200 |
| 47 | - assert_equal "ERROR", @response.body | |
| 48 | 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 | 52 | should 'get project error' do |
| 51 | 53 | create_project_content |
| 52 | 54 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) |
| ... | ... | @@ -56,6 +58,11 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase |
| 56 | 58 | assert_select('h3', 'ERROR') |
| 57 | 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 | 66 | should 'get project results without date' do |
| 60 | 67 | create_project_content |
| 61 | 68 | Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result) |
| ... | ... | @@ -72,7 +79,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase |
| 72 | 79 | get :project_result, :profile => @profile.identifier, :id => @content.id, :date => @project_result.date |
| 73 | 80 | assert_response 200 |
| 74 | 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 | 88 | should 'get module result without date' do |
| 77 | 89 | create_project_content |
| 78 | 90 | mock_module_result |
| ... | ... | @@ -91,6 +103,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase |
| 91 | 103 | mock_project_result |
| 92 | 104 | get :module_result, :profile => @profile.identifier, :id => @content.id, :date => @project_result.date, :module_name => @name |
| 93 | 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 | 112 | end |
| 95 | 113 | |
| 96 | 114 | should 'get project tree without date' do |
| ... | ... | @@ -117,12 +135,29 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase |
| 117 | 135 | get :module_grade_history, :profile => @profile.identifier, :id => @content.id, :module_name => @name |
| 118 | 136 | assert_response 200 |
| 119 | 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 | 153 | private |
| 122 | 154 | |
| 123 | 155 | def create_project_content |
| 156 | + client = mock | |
| 124 | 157 | @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => @name) |
| 125 | 158 | @content.expects(:send_project_to_service).returns(nil) |
| 159 | + Kalibro::Client::ProjectClient.expects(:new).returns(client) | |
| 160 | + client.expects(:project_names).returns([]) | |
| 126 | 161 | @content.save |
| 127 | 162 | end |
| 128 | 163 | ... | ... |