Commit 55a9a0db1ddd84432e00afedc9d509cc6ad801ae

Authored by João M. M. da Silva + Alessandro Palmeira
Committed by João M. M. da Silva
1 parent 1cdaecd5

[Mezuro] last state of a processing in controller

plugins/mezuro/controllers/profile/mezuro_plugin_processing_controller.rb
1 #TODO refatorar todo o controller e seus testes funcionais 1 #TODO refatorar todo o controller e seus testes funcionais
2 -class MezuroPluginProjectController < MezuroPluginProfileController 2 +class MezuroPluginProcessingController < MezuroPluginProfileController
3 3
4 append_view_path File.join(File.dirname(__FILE__) + '/../../views') 4 append_view_path File.join(File.dirname(__FILE__) + '/../../views')
5 5
6 - def processing_state  
7 - @content = profile.articles.find(params[:id])  
8 - processing = @content.processing  
9 - if project_content_has_errors?  
10 - redirect_to_error_page(@content.errors[:base])  
11 - else  
12 - render :text => processing.state  
13 - end 6 + def render_last_state
  7 + last_state = Kalibro::Processing.last_processing_state_of(params[:repository_id].to_i)
  8 + render :text => last_state
14 end 9 end
15 10
16 def processing_error 11 def processing_error
plugins/mezuro/test/functional/profile/mezuro_plugin_processing_controller_test.rb
@@ -5,32 +5,35 @@ require &quot;#{RAILS_ROOT}/plugins/mezuro/test/fixtures/throwable_fixtures&quot; @@ -5,32 +5,35 @@ require &quot;#{RAILS_ROOT}/plugins/mezuro/test/fixtures/throwable_fixtures&quot;
5 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures" 5 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures"
6 6
7 7
8 -#TODO refatorar todos os testes  
9 -class MezuroPluginProjectControllerTest < ActionController::TestCase 8 +class MezuroPluginProcessingControllerTest < ActionController::TestCase
10 def setup 9 def setup
11 - @controller = MezuroPluginProjectController.new 10 + @controller = MezuroPluginProcessingController.new
12 @request = ActionController::TestRequest.new 11 @request = ActionController::TestRequest.new
13 @response = ActionController::TestResponse.new 12 @response = ActionController::TestResponse.new
14 @profile = fast_create(Community) 13 @profile = fast_create(Community)
15 14
16 - @project_result = ProcessingFixtures.project_result  
17 - @repository_url = RepositoryFixtures.repository.address  
18 - @project = @project_result.project  
19 - @date = "2012-04-13T20:39:41+04:00"  
20 -  
21 - Kalibro::Project.expects(:all_names).returns([]) 15 + @repository = RepositoryFixtures.repository
  16 + @processing = ProcessingFixtures.processing
  17 +
  18 +=begin
22 @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => @project.name, :repository_url => @repository_url) 19 @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => @project.name, :repository_url => @repository_url)
23 @content.expects(:send_project_to_service).returns(nil) 20 @content.expects(:send_project_to_service).returns(nil)
24 @content.save 21 @content.save
  22 + @project_result = ProcessingFixtures.project_result
  23 +
  24 + Kalibro::Project.expects(:all_names).returns([])
  25 +=end
25 end 26 end
26 27
27 - should 'test project state without kalibro_error' do  
28 - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash})  
29 - get :project_state, :profile => @profile.identifier, :id => @content.id 28 + should 'render last processing state' do
  29 + Kalibro::Processing.expects(:request).with(:last_processing_state, :repository_id => @repository.id).returns({:process_state => @processing.state})
  30 + get :render_last_state, :profile => @profile.identifier, :repository_id => @repository.id
30 assert_response 200 31 assert_response 200
31 - assert_equal @content, assigns(:content) 32 + assert_equal @processing.state, @response.body
32 end 33 end
33 34
  35 +#TODO refatorar todos os testes
  36 +=begin
34 should 'test project state with kalibro_error' do 37 should 'test project state with kalibro_error' do
35 Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ThrowableFixtures.throwable_hash})}) 38 Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ThrowableFixtures.throwable_hash})})
36 get :project_state, :profile => @profile.identifier, :id => @content.id 39 get :project_state, :profile => @profile.identifier, :id => @content.id
@@ -90,5 +93,5 @@ class MezuroPluginProjectControllerTest &lt; ActionController::TestCase @@ -90,5 +93,5 @@ class MezuroPluginProjectControllerTest &lt; ActionController::TestCase
90 assert_equal @project_result.source_tree.module.name, assigns(:source_tree).module.name 93 assert_equal @project_result.source_tree.module.name, assigns(:source_tree).module.name
91 assert_response 200 94 assert_response 200
92 end 95 end
93 - 96 +=end
94 end 97 end