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