Commit 06744385478af0b24b46eacfa05c45cbbf206ec0
Committed by
Alessandro Palmeira
1 parent
e67c922d
Exists in
staging
and in
42 other branches
[Mezuro] Refactored the processing of a repository
Showing
4 changed files
with
4 additions
and
4 deletions
Show diff stats
plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
| ... | ... | @@ -21,6 +21,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController |
| 21 | 21 | repository.save(project_content.project_id) |
| 22 | 22 | |
| 23 | 23 | if( repository.errors.empty? ) |
| 24 | + repository.process | |
| 24 | 25 | redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}" |
| 25 | 26 | else |
| 26 | 27 | redirect_to_error_page repository.errors[0].message | ... | ... |
plugins/mezuro/lib/kalibro/repository.rb
| ... | ... | @@ -17,7 +17,7 @@ class Kalibro::Repository < Kalibro::Model |
| 17 | 17 | response.map {|repository| new repository} |
| 18 | 18 | end |
| 19 | 19 | |
| 20 | - def process_repository | |
| 20 | + def process | |
| 21 | 21 | self.class.request(:process_repository, {:repository_id => self.id}) |
| 22 | 22 | end |
| 23 | 23 | |
| ... | ... | @@ -28,7 +28,6 @@ class Kalibro::Repository < Kalibro::Model |
| 28 | 28 | def save(project_id) |
| 29 | 29 | begin |
| 30 | 30 | self.id = self.class.request(:save_repository, {:repository => self.to_hash, :project_id => project_id})[:repository_id] |
| 31 | - process_repository | |
| 32 | 31 | true |
| 33 | 32 | rescue Exception => exception |
| 34 | 33 | add_error exception | ... | ... |
plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb
| ... | ... | @@ -40,6 +40,7 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase |
| 40 | 40 | should 'create a repository' do |
| 41 | 41 | Kalibro::Repository.expects(:new).returns(@repository) |
| 42 | 42 | @repository.expects(:save).with(@content.project_id).returns(true) |
| 43 | + @repository.expects(:process) | |
| 43 | 44 | get :create, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash |
| 44 | 45 | assert @repository.errors.empty? |
| 45 | 46 | assert_response :redirect | ... | ... |
plugins/mezuro/test/unit/kalibro/repository_test.rb
| ... | ... | @@ -40,7 +40,6 @@ class RepositoryTest < ActiveSupport::TestCase |
| 40 | 40 | id_from_kalibro = 1 |
| 41 | 41 | project_id = 56 |
| 42 | 42 | Kalibro::Repository.expects(:request).with(:save_repository, {:repository => @created_repository.to_hash, :project_id => project_id}).returns(:repository_id => id_from_kalibro) |
| 43 | - Kalibro::Repository.expects(:request).with(:process_repository, :repository_id => id_from_kalibro).returns(:repository_id => id_from_kalibro) | |
| 44 | 43 | assert @created_repository.save(project_id) |
| 45 | 44 | assert_equal id_from_kalibro, @created_repository.id |
| 46 | 45 | end |
| ... | ... | @@ -59,7 +58,7 @@ class RepositoryTest < ActiveSupport::TestCase |
| 59 | 58 | |
| 60 | 59 | should 'process repository' do |
| 61 | 60 | Kalibro::Repository.expects(:request).with(:process_repository, {:repository_id => @repository.id}); |
| 62 | - @repository.process_repository | |
| 61 | + @repository.process | |
| 63 | 62 | end |
| 64 | 63 | |
| 65 | 64 | should 'cancel processing of a repository' do | ... | ... |