Commit 18bac9aa23ae320bf4e2237b81d24a55b39daac0
1 parent
cf8fd6ef
Exists in
master
and in
23 other branches
[Mezuro] Changing controller actions order
Showing
2 changed files
with
32 additions
and
32 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
| @@ -2,16 +2,11 @@ class MezuroPluginProfileController < ProfileController | @@ -2,16 +2,11 @@ class MezuroPluginProfileController < ProfileController | ||
| 2 | 2 | ||
| 3 | append_view_path File.join(File.dirname(__FILE__) + '/../views') | 3 | append_view_path File.join(File.dirname(__FILE__) + '/../views') |
| 4 | 4 | ||
| 5 | - def module_result | ||
| 6 | - content = profile.articles.find(params[:id]) | ||
| 7 | - module_result = content.module_result(params[:module_name]) | ||
| 8 | - render :partial => 'content_viewer/module_result', :locals => { :module_result => module_result} | ||
| 9 | - end | ||
| 10 | - | ||
| 11 | - def project_result | 5 | + def project_state |
| 12 | content = profile.articles.find(params[:id]) | 6 | content = profile.articles.find(params[:id]) |
| 13 | - project_result = content.project_result | ||
| 14 | - render :partial => 'content_viewer/project_result', :locals => { :project_result => project_result } | 7 | + project = content.project |
| 8 | + state = project.error.nil? ? project.state : "ERROR" | ||
| 9 | + render :text => state | ||
| 15 | end | 10 | end |
| 16 | 11 | ||
| 17 | def project_error | 12 | def project_error |
| @@ -20,11 +15,16 @@ class MezuroPluginProfileController < ProfileController | @@ -20,11 +15,16 @@ class MezuroPluginProfileController < ProfileController | ||
| 20 | render :partial => 'content_viewer/project_error', :locals => { :project => project } | 15 | render :partial => 'content_viewer/project_error', :locals => { :project => project } |
| 21 | end | 16 | end |
| 22 | 17 | ||
| 23 | - def project_state | 18 | + def project_result |
| 24 | content = profile.articles.find(params[:id]) | 19 | content = profile.articles.find(params[:id]) |
| 25 | - project = content.project | ||
| 26 | - state = project.error.nil? ? project.state : "ERROR" | ||
| 27 | - render :text => state | 20 | + project_result = content.project_result |
| 21 | + render :partial => 'content_viewer/project_result', :locals => { :project_result => project_result } | ||
| 22 | + end | ||
| 23 | + | ||
| 24 | + def module_result | ||
| 25 | + content = profile.articles.find(params[:id]) | ||
| 26 | + module_result = content.module_result(params[:module_name]) | ||
| 27 | + render :partial => 'content_viewer/module_result', :locals => { :module_result => module_result} | ||
| 28 | end | 28 | end |
| 29 | 29 | ||
| 30 | end | 30 | end |
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
| @@ -23,28 +23,21 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -23,28 +23,21 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
| 23 | assert_response 404 | 23 | assert_response 404 |
| 24 | end | 24 | end |
| 25 | 25 | ||
| 26 | - should 'get metric results for a module' do | ||
| 27 | - create_project_content | ||
| 28 | - Kalibro::Client::ModuleResultClient.expects(:module_result).with(@content, @name).returns(@module_result) | ||
| 29 | - get :module_result, :profile => @profile.identifier, :id => @content.id, :module_name => @name | ||
| 30 | - assert_response 200 | ||
| 31 | - assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') | ||
| 32 | - end | ||
| 33 | - | ||
| 34 | - should 'get project results' do | 26 | + should 'get project state' do |
| 35 | create_project_content | 27 | create_project_content |
| 36 | - Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result) | ||
| 37 | - get :project_result, :profile => @profile.identifier, :id => @content.id | 28 | + Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) |
| 29 | + get :project_state, :profile => @profile.identifier, :id => @content.id | ||
| 38 | assert_response 200 | 30 | assert_response 200 |
| 39 | - assert_select('h3', 'LAST RESULT') | 31 | + assert_equal @project.state, @response.body |
| 40 | end | 32 | end |
| 41 | 33 | ||
| 42 | - should 'get project state' do | 34 | + should 'get error state if project has error' do |
| 43 | create_project_content | 35 | create_project_content |
| 44 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) | 36 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) |
| 37 | + @project.expects(:error).returns("") | ||
| 45 | get :project_state, :profile => @profile.identifier, :id => @content.id | 38 | get :project_state, :profile => @profile.identifier, :id => @content.id |
| 46 | assert_response 200 | 39 | assert_response 200 |
| 47 | - assert_equal @project.state, @response.body | 40 | + assert_equal "ERROR", @response.body |
| 48 | end | 41 | end |
| 49 | 42 | ||
| 50 | should 'get project error' do | 43 | should 'get project error' do |
| @@ -56,13 +49,20 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -56,13 +49,20 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
| 56 | assert_select('h3', 'ERROR') | 49 | assert_select('h3', 'ERROR') |
| 57 | end | 50 | end |
| 58 | 51 | ||
| 59 | - should 'get error state if project has error' do | 52 | + should 'get project results' do |
| 60 | create_project_content | 53 | create_project_content |
| 61 | - Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) | ||
| 62 | - @project.expects(:error).returns("") | ||
| 63 | - get :project_state, :profile => @profile.identifier, :id => @content.id | 54 | + Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result) |
| 55 | + get :project_result, :profile => @profile.identifier, :id => @content.id | ||
| 64 | assert_response 200 | 56 | assert_response 200 |
| 65 | - assert_equal "ERROR", @response.body | 57 | + assert_select('h3', 'LAST RESULT') |
| 58 | + end | ||
| 59 | + | ||
| 60 | + should 'get metric results for a module' do | ||
| 61 | + create_project_content | ||
| 62 | + Kalibro::Client::ModuleResultClient.expects(:module_result).with(@content, @name).returns(@module_result) | ||
| 63 | + get :module_result, :profile => @profile.identifier, :id => @content.id, :module_name => @name | ||
| 64 | + assert_response 200 | ||
| 65 | + assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') | ||
| 66 | end | 66 | end |
| 67 | 67 | ||
| 68 | private | 68 | private |