Commit e64fac10c440d842b9ead6832d0cd2a2dd7595e6
Committed by
João M. M. da Silva
1 parent
a964974a
Exists in
master
and in
29 other branches
[Mezuro] Finished refactoring of project content.
Showing
3 changed files
with
10 additions
and
36 deletions
Show diff stats
plugins/mezuro/lib/kalibro/repository.rb
... | ... | @@ -15,11 +15,11 @@ class Kalibro::Repository < Kalibro::Model |
15 | 15 | end |
16 | 16 | |
17 | 17 | def process_repository |
18 | - self.class.request(:process_repository, {:repository_id => self.id}); | |
18 | + self.class.request(:process_repository, {:repository_id => self.id}) | |
19 | 19 | end |
20 | 20 | |
21 | 21 | def cancel_processing_of_repository |
22 | - self.class.request(:cancel_processing_of_repository, {:repository_id => self.id}); | |
22 | + self.class.request(:cancel_processing_of_repository, {:repository_id => self.id}) | |
23 | 23 | end |
24 | 24 | |
25 | 25 | end | ... | ... |
plugins/mezuro/lib/mezuro_plugin/project_content.rb
... | ... | @@ -4,7 +4,7 @@ class MezuroPlugin::ProjectContent < Article |
4 | 4 | settings_items :project_id |
5 | 5 | |
6 | 6 | validate_on_create :validate_kalibro_project_name |
7 | - validate_on_create :validate_repository_url | |
7 | + validate_on_create :validate_repository_address | |
8 | 8 | |
9 | 9 | def self.short_description |
10 | 10 | 'Mezuro project' |
... | ... | @@ -104,27 +104,23 @@ class MezuroPlugin::ProjectContent < Article |
104 | 104 | value.kind_of?(Hash) ? Kalibro::Repository.new(value) : value |
105 | 105 | end |
106 | 106 | |
107 | - def validate_repository_url | |
108 | - if(@repositories.nil? || repository_url == "") | |
109 | - errors.add_to_base("Repository URL is mandatory") | |
107 | + def validate_repository_address | |
108 | + if(address.nil? || address == "") | |
109 | + errors.add_to_base("Repository Address is mandatory") | |
110 | 110 | end |
111 | 111 | end |
112 | 112 | |
113 | 113 | def send_project_to_service |
114 | 114 | created_project = create_kalibro_project |
115 | - created_project.process_project(periodicity_in_days) | |
115 | + repositories = Kalibro::Repository.repositories_of(project_id) | |
116 | + repositories.each {|repository| repository.process_repository } | |
116 | 117 | end |
117 | 118 | |
118 | 119 | def create_kalibro_project |
119 | 120 | Kalibro::Project.create( |
121 | + :id => project_id, | |
120 | 122 | :name => name, |
121 | - :license => project_license, | |
122 | - :description => description, | |
123 | - :repository => { | |
124 | - :type => repository_type, | |
125 | - :address => repository_url | |
126 | - }, | |
127 | - :configuration_name => configuration_name | |
123 | + :description => description | |
128 | 124 | ) |
129 | 125 | end |
130 | 126 | ... | ... |
plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb
... | ... | @@ -106,26 +106,4 @@ class ProjectContentTest < ActiveSupport::TestCase |
106 | 106 | assert_not_nil @project_content.errors[:base] |
107 | 107 | end |
108 | 108 | |
109 | -=begin | |
110 | - should 'send project to service after saving' do | |
111 | - @project_content.expects :send_project_to_service | |
112 | - @project_content.run_callbacks :after_save | |
113 | - end | |
114 | - | |
115 | - should 'destroy project from service' do | |
116 | - Kalibro::Project.expects(:request).with("Project", :get_project, :project_name => @project.name).returns({:project => @project.to_hash}) | |
117 | - Kalibro::Project.expects(:request).with("Project", :remove_project, {:project_name => @project.name}) | |
118 | - @project_content.send :destroy_project_from_service | |
119 | - end | |
120 | - | |
121 | - should 'send correct project to service' do | |
122 | - hash = ProjectFixtures.project_hash | |
123 | - hash.delete(:attributes!) | |
124 | - hash.delete(:state) | |
125 | - Kalibro::Project.expects(:create).with(hash).returns(@project) | |
126 | - @project.expects(:process_project).with(@project_content.periodicity_in_days) | |
127 | - @project_content.send :send_project_to_service | |
128 | - end | |
129 | - | |
130 | -=end | |
131 | 109 | end | ... | ... |