Commit 54afda3843e03c32689c823449dcd74279852386

Authored by Rafael Manzo
2 parents 10fdcbdd e595da65

Merge branch 'refactoring_js' of gitorious.org:+mezuro/noosfero/mezuro into refactoring_js

plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
... ... @@ -21,7 +21,8 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
21 21 repository.save(project_content.project_id)
22 22  
23 23 if( repository.errors.empty? )
24   - redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}"
  24 + repository.process
  25 + redirect_to "/profile/#{profile.identifier}/plugin/mezuro/repository/show/#{project_content.id}?repository_id=#{repository.id}"
25 26 else
26 27 redirect_to_error_page repository.errors[0].message
27 28 end
... ... @@ -46,9 +47,9 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
46 47  
47 48 repository = Kalibro::Repository.new( params[:repository] )
48 49 repository.save(project_content.project_id)
49   -
  50 +
50 51 if( repository.errors.empty? )
51   - redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}"
  52 + redirect_to "/profile/#{profile.identifier}/plugin/mezuro/repository/show/#{project_content.id}?repository_id=#{repository.id}"
52 53 else
53 54 redirect_to_error_page repository.errors[0].message
54 55 end
... ...
plugins/mezuro/lib/kalibro/range_snapshot.rb
1 1 class Kalibro::RangeSnapshot < Kalibro::Model
2 2  
3   - attr_accessor :end, :label, :grade, :color, :comments
  3 + attr_accessor :beginning, :end, :label, :grade, :color, :comments
4 4  
5 5 end
... ...
plugins/mezuro/lib/kalibro/repository.rb
... ... @@ -17,7 +17,7 @@ class Kalibro::Repository &lt; 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 &lt; 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/lib/mezuro_plugin/project_content.rb
... ... @@ -83,7 +83,6 @@ class MezuroPlugin::ProjectContent &lt; Article
83 83  
84 84 def create_kalibro_project
85 85 Kalibro::Project.create(
86   - :id => project_id,
87 86 :name => name,
88 87 :description => description
89 88 )
... ...
plugins/mezuro/test/functional/profile/mezuro_plugin_processing_controller_test.rb
... ... @@ -19,8 +19,15 @@ class MezuroPluginProcessingControllerTest &lt; ActionController::TestCase
19 19 end
20 20  
21 21 should 'render last processing state' do
22   - Kalibro::Processing.expects(:request).with(:last_processing_state, :repository_id => @repository_id).returns({:process_state => @processing.state})
23   - get :render_last_state, :profile => @profile.identifier, :repository_id => @repository_id
  22 + Kalibro::Processing.expects(:processing_of).with(@repository_id).returns(@processing)
  23 + get :state, :profile => @profile.identifier, :repository_id => @repository_id
  24 + assert_response 200
  25 + assert_equal @processing.state, @response.body
  26 + end
  27 +
  28 + should 'render a processing state in a specific date' do
  29 + Kalibro::Processing.expects(:processing_with_date_of).with(@repository_id, @processing.date).returns(@processing)
  30 + get :state, :profile => @profile.identifier, :repository_id => @repository_id, :date => @processing.date
24 31 assert_response 200
25 32 assert_equal @processing.state, @response.body
26 33 end
... ...
plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb
... ... @@ -40,6 +40,7 @@ class MezuroPluginRepositoryControllerTest &lt; 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 &lt; 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 &lt; 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
... ...