From 55a9a0db1ddd84432e00afedc9d509cc6ad801ae Mon Sep 17 00:00:00 2001 From: João M. M. da Silva + Alessandro Palmeira Date: Tue, 11 Dec 2012 10:50:25 -0200 Subject: [PATCH] [Mezuro] last state of a processing in controller --- plugins/mezuro/controllers/profile/mezuro_plugin_processing_controller.rb | 13 ++++--------- plugins/mezuro/test/functional/profile/mezuro_plugin_processing_controller_test.rb | 31 +++++++++++++++++-------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/plugins/mezuro/controllers/profile/mezuro_plugin_processing_controller.rb b/plugins/mezuro/controllers/profile/mezuro_plugin_processing_controller.rb index 409ec88..378e337 100644 --- a/plugins/mezuro/controllers/profile/mezuro_plugin_processing_controller.rb +++ b/plugins/mezuro/controllers/profile/mezuro_plugin_processing_controller.rb @@ -1,16 +1,11 @@ #TODO refatorar todo o controller e seus testes funcionais -class MezuroPluginProjectController < MezuroPluginProfileController +class MezuroPluginProcessingController < MezuroPluginProfileController append_view_path File.join(File.dirname(__FILE__) + '/../../views') - def processing_state - @content = profile.articles.find(params[:id]) - processing = @content.processing - if project_content_has_errors? - redirect_to_error_page(@content.errors[:base]) - else - render :text => processing.state - end + def render_last_state + last_state = Kalibro::Processing.last_processing_state_of(params[:repository_id].to_i) + render :text => last_state end def processing_error diff --git a/plugins/mezuro/test/functional/profile/mezuro_plugin_processing_controller_test.rb b/plugins/mezuro/test/functional/profile/mezuro_plugin_processing_controller_test.rb index 997e236..fef8c5e 100644 --- a/plugins/mezuro/test/functional/profile/mezuro_plugin_processing_controller_test.rb +++ b/plugins/mezuro/test/functional/profile/mezuro_plugin_processing_controller_test.rb @@ -5,32 +5,35 @@ require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/throwable_fixtures" require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures" -#TODO refatorar todos os testes -class MezuroPluginProjectControllerTest < ActionController::TestCase +class MezuroPluginProcessingControllerTest < ActionController::TestCase def setup - @controller = MezuroPluginProjectController.new + @controller = MezuroPluginProcessingController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @profile = fast_create(Community) - @project_result = ProcessingFixtures.project_result - @repository_url = RepositoryFixtures.repository.address - @project = @project_result.project - @date = "2012-04-13T20:39:41+04:00" - - Kalibro::Project.expects(:all_names).returns([]) + @repository = RepositoryFixtures.repository + @processing = ProcessingFixtures.processing + +=begin @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => @project.name, :repository_url => @repository_url) @content.expects(:send_project_to_service).returns(nil) @content.save + @project_result = ProcessingFixtures.project_result + + Kalibro::Project.expects(:all_names).returns([]) +=end end - should 'test project state without kalibro_error' do - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash}) - get :project_state, :profile => @profile.identifier, :id => @content.id + should 'render last processing state' do + Kalibro::Processing.expects(:request).with(:last_processing_state, :repository_id => @repository.id).returns({:process_state => @processing.state}) + get :render_last_state, :profile => @profile.identifier, :repository_id => @repository.id assert_response 200 - assert_equal @content, assigns(:content) + assert_equal @processing.state, @response.body end +#TODO refatorar todos os testes +=begin should 'test project state with kalibro_error' do Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ThrowableFixtures.throwable_hash})}) get :project_state, :profile => @profile.identifier, :id => @content.id @@ -90,5 +93,5 @@ class MezuroPluginProjectControllerTest < ActionController::TestCase assert_equal @project_result.source_tree.module.name, assigns(:source_tree).module.name assert_response 200 end - +=end end -- libgit2 0.21.2