Commit 5c39634f33bea7a7ebf64b511505951bedb8eced

Authored by Diego Camarinha
2 parents 29bc9792 55a9a0db

Merge branch 'refactoring_processing' into refactoring_repository

plugins/mezuro/controllers/profile/mezuro_plugin_processing_controller.rb
1 1 #TODO refatorar todo o controller e seus testes funcionais
2   -class MezuroPluginProjectController < MezuroPluginProfileController
  2 +class MezuroPluginProcessingController < MezuroPluginProfileController
3 3  
4 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 9 end
15 10  
16 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 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 9 def setup
11   - @controller = MezuroPluginProjectController.new
  10 + @controller = MezuroPluginProcessingController.new
12 11 @request = ActionController::TestRequest.new
13 12 @response = ActionController::TestResponse.new
14 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 19 @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => @project.name, :repository_url => @repository_url)
23 20 @content.expects(:send_project_to_service).returns(nil)
24 21 @content.save
  22 + @project_result = ProcessingFixtures.project_result
  23 +
  24 + Kalibro::Project.expects(:all_names).returns([])
  25 +=end
25 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 31 assert_response 200
31   - assert_equal @content, assigns(:content)
  32 + assert_equal @processing.state, @response.body
32 33 end
33 34  
  35 +#TODO refatorar todos os testes
  36 +=begin
34 37 should 'test project state with kalibro_error' do
35 38 Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash.merge({:error => ThrowableFixtures.throwable_hash})})
36 39 get :project_state, :profile => @profile.identifier, :id => @content.id
... ... @@ -90,5 +93,5 @@ class MezuroPluginProjectControllerTest &lt; ActionController::TestCase
90 93 assert_equal @project_result.source_tree.module.name, assigns(:source_tree).module.name
91 94 assert_response 200
92 95 end
93   -
  96 +=end
94 97 end
... ...