Commit cb5511ae524a0190a604400741946d82a0861222
Exists in
master
and in
29 other branches
Merge branch 'refactoring_js' into refactoring
Showing
56 changed files
with
435 additions
and
258 deletions
Show diff stats
plugins/mezuro/controllers/profile/mezuro_plugin_module_result_controller.rb
@@ -7,7 +7,7 @@ class MezuroPluginModuleResultController < MezuroPluginProfileController | @@ -7,7 +7,7 @@ class MezuroPluginModuleResultController < MezuroPluginProfileController | ||
7 | @metric_results = Kalibro::MetricResult.metric_results_of(@module_result.id) | 7 | @metric_results = Kalibro::MetricResult.metric_results_of(@module_result.id) |
8 | render :partial => 'module_result' | 8 | render :partial => 'module_result' |
9 | end | 9 | end |
10 | - | 10 | + |
11 | def metric_result_history | 11 | def metric_result_history |
12 | @history = Kalibro::MetricResult.history_of(params[:metric_name], params[:module_result_id].to_i) | 12 | @history = Kalibro::MetricResult.history_of(params[:metric_name], params[:module_result_id].to_i) |
13 | render :partial => 'score_history' | 13 | render :partial => 'score_history' |
plugins/mezuro/controllers/profile/mezuro_plugin_processing_controller.rb
@@ -2,20 +2,32 @@ class MezuroPluginProcessingController < MezuroPluginProfileController | @@ -2,20 +2,32 @@ class MezuroPluginProcessingController < MezuroPluginProfileController | ||
2 | 2 | ||
3 | append_view_path File.join(File.dirname(__FILE__) + '/../../views') | 3 | append_view_path File.join(File.dirname(__FILE__) + '/../../views') |
4 | 4 | ||
5 | - def render_last_state | ||
6 | - last_state = Kalibro::Processing.last_processing_state_of(params[:repository_id].to_i) | ||
7 | - render :text => last_state | 5 | + def state |
6 | + processing = processing_for_date(params[:repository_id].to_i, params[:date]) | ||
7 | + if processing.error.nil? | ||
8 | + render :text => processing.state | ||
9 | + else | ||
10 | + render :text => 'ERROR' | ||
11 | + end | ||
8 | end | 12 | end |
9 | 13 | ||
10 | def processing | 14 | def processing |
11 | - date = params[:date] | ||
12 | - repository_id = params[:repository_id].to_i | ||
13 | - processing_class = Kalibro::Processing | ||
14 | - @processing = date.nil? ? processing_class.processing_of(repository_id) : processing_class.processing_with_date_of(repository_id, date) | ||
15 | - if @processing.state == 'ERROR' | 15 | + @processing = processing_for_date(params[:repository_id].to_i, params[:date]) |
16 | + if @processing.error.nil? | ||
17 | + render :partial => 'processing' | ||
18 | + else | ||
16 | render :partial => 'processing_error' | 19 | render :partial => 'processing_error' |
20 | + end | ||
21 | + end | ||
22 | + | ||
23 | + private | ||
24 | + | ||
25 | + def processing_for_date(repository_id, date = nil) | ||
26 | + processing_class = Kalibro::Processing | ||
27 | + if date.nil? | ||
28 | + processing_class.processing_of(repository_id) | ||
17 | else | 29 | else |
18 | - render :partial => 'processing' | 30 | + processing_class.processing_with_date_of(repository_id, date) |
19 | end | 31 | end |
20 | end | 32 | end |
21 | 33 |
plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
@@ -3,8 +3,11 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | @@ -3,8 +3,11 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | ||
3 | append_view_path File.join(File.dirname(__FILE__) + '/../../views') | 3 | append_view_path File.join(File.dirname(__FILE__) + '/../../views') |
4 | 4 | ||
5 | def new | 5 | def new |
6 | - @project_content = profile.articles.find(params[:id]) | ||
7 | - | 6 | + project_content = profile.articles.find(params[:id]) |
7 | + @project_name = project_content.name | ||
8 | + @data_profile = project_content.profile.identifier | ||
9 | + @project_content_id = project_content.id | ||
10 | + | ||
8 | @repository_types = Kalibro::Repository.repository_types | 11 | @repository_types = Kalibro::Repository.repository_types |
9 | 12 | ||
10 | configurations = Kalibro::Configuration.all | 13 | configurations = Kalibro::Configuration.all |
@@ -16,20 +19,24 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | @@ -16,20 +19,24 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | ||
16 | 19 | ||
17 | def create | 20 | def create |
18 | project_content = profile.articles.find(params[:id]) | 21 | project_content = profile.articles.find(params[:id]) |
19 | - | 22 | + |
20 | repository = Kalibro::Repository.new( params[:repository] ) | 23 | repository = Kalibro::Repository.new( params[:repository] ) |
21 | repository.save(project_content.project_id) | 24 | repository.save(project_content.project_id) |
22 | 25 | ||
23 | if( repository.errors.empty? ) | 26 | if( repository.errors.empty? ) |
24 | - redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}" | 27 | + repository.process |
28 | + redirect_to "/profile/#{profile.identifier}/plugin/mezuro/repository/show/#{project_content.id}?repository_id=#{repository.id}" | ||
25 | else | 29 | else |
26 | redirect_to_error_page repository.errors[0].message | 30 | redirect_to_error_page repository.errors[0].message |
27 | end | 31 | end |
28 | end | 32 | end |
29 | 33 | ||
30 | def edit | 34 | def edit |
31 | - @project_content = profile.articles.find(params[:id]) | ||
32 | - | 35 | + project_content = profile.articles.find(params[:id]) |
36 | + @project_name = project_content.name | ||
37 | + @data_profile = project_content.profile.identifier | ||
38 | + @project_content_id = project_content.id | ||
39 | + | ||
33 | @repository_types = Kalibro::Repository.repository_types | 40 | @repository_types = Kalibro::Repository.repository_types |
34 | 41 | ||
35 | configurations = Kalibro::Configuration.all | 42 | configurations = Kalibro::Configuration.all |
@@ -38,7 +45,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | @@ -38,7 +45,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | ||
38 | [configuration.name,configuration.id] | 45 | [configuration.name,configuration.id] |
39 | end | 46 | end |
40 | 47 | ||
41 | - @repository = @project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first | 48 | + @repository = project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first |
42 | end | 49 | end |
43 | 50 | ||
44 | def update | 51 | def update |
@@ -46,9 +53,10 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | @@ -46,9 +53,10 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | ||
46 | 53 | ||
47 | repository = Kalibro::Repository.new( params[:repository] ) | 54 | repository = Kalibro::Repository.new( params[:repository] ) |
48 | repository.save(project_content.project_id) | 55 | repository.save(project_content.project_id) |
49 | - | 56 | + |
50 | if( repository.errors.empty? ) | 57 | if( repository.errors.empty? ) |
51 | - redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}" | 58 | + repository.process |
59 | + redirect_to "/profile/#{profile.identifier}/plugin/mezuro/repository/show/#{project_content.id}?repository_id=#{repository.id}" | ||
52 | else | 60 | else |
53 | redirect_to_error_page repository.errors[0].message | 61 | redirect_to_error_page repository.errors[0].message |
54 | end | 62 | end |
plugins/mezuro/lib/kalibro/metric_configuration_snapshot.rb
@@ -2,6 +2,10 @@ class Kalibro::MetricConfigurationSnapshot < Kalibro::Model | @@ -2,6 +2,10 @@ class Kalibro::MetricConfigurationSnapshot < Kalibro::Model | ||
2 | 2 | ||
3 | attr_accessor :code, :weight, :aggregation_form, :metric, :base_tool_name, :range | 3 | attr_accessor :code, :weight, :aggregation_form, :metric, :base_tool_name, :range |
4 | 4 | ||
5 | + def weight=(value) | ||
6 | + @weight = value.to_f | ||
7 | + end | ||
8 | + | ||
5 | def metric=(value) | 9 | def metric=(value) |
6 | if value.kind_of?(Hash) | 10 | if value.kind_of?(Hash) |
7 | @metric = Kalibro::Metric.to_object(value) | 11 | @metric = Kalibro::Metric.to_object(value) |
@@ -11,11 +15,24 @@ class Kalibro::MetricConfigurationSnapshot < Kalibro::Model | @@ -11,11 +15,24 @@ class Kalibro::MetricConfigurationSnapshot < Kalibro::Model | ||
11 | end | 15 | end |
12 | 16 | ||
13 | def range=(value) | 17 | def range=(value) |
14 | - @range = Kalibro::RangeSnapshot.to_object value | 18 | + value.to_a |
19 | + @range = [] | ||
20 | + | ||
21 | + value.each do |range_snapshot| | ||
22 | + @range << Kalibro::RangeSnapshot.to_object(range_snapshot) | ||
23 | + end | ||
24 | + | ||
15 | end | 25 | end |
16 | 26 | ||
17 | def range_snapshot | 27 | def range_snapshot |
18 | range | 28 | range |
19 | end | 29 | end |
20 | 30 | ||
31 | + def to_hash | ||
32 | + hash = super | ||
33 | + hash[:attributes!][:range] = {'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | ||
34 | + 'xsi:type' => 'kalibro:rangeSnapshotXml' } | ||
35 | + hash | ||
36 | + end | ||
37 | + | ||
21 | end | 38 | end |
plugins/mezuro/lib/kalibro/metric_result.rb
@@ -2,8 +2,19 @@ class Kalibro::MetricResult < Kalibro::Model | @@ -2,8 +2,19 @@ class Kalibro::MetricResult < Kalibro::Model | ||
2 | 2 | ||
3 | attr_accessor :id, :configuration, :value, :error | 3 | attr_accessor :id, :configuration, :value, :error |
4 | 4 | ||
5 | - def value=(value) | ||
6 | - @value = value.to_f | 5 | + def initialize(attributes={}) |
6 | + value = attributes[:value] | ||
7 | + @value = (value == "NaN") ? attributes[:aggregated_value].to_f : value.to_f | ||
8 | + attributes.each do |field, value| | ||
9 | + if field!= :value and field!= :aggregated_value and self.class.is_valid?(field) | ||
10 | + send("#{field}=", value) | ||
11 | + end | ||
12 | + end | ||
13 | + @errors = [] | ||
14 | + end | ||
15 | + | ||
16 | + def id=(value) | ||
17 | + @id = value.to_i | ||
7 | end | 18 | end |
8 | 19 | ||
9 | def configuration=(value) | 20 | def configuration=(value) |
@@ -30,7 +41,7 @@ class Kalibro::MetricResult < Kalibro::Model | @@ -30,7 +41,7 @@ class Kalibro::MetricResult < Kalibro::Model | ||
30 | end | 41 | end |
31 | 42 | ||
32 | def self.history_of(metric_name, module_result_id) | 43 | def self.history_of(metric_name, module_result_id) |
33 | - response = self.request(:history_of, {:metric_name => metric_name, :module_result_id => module_result_id})[:date_metric_result] | 44 | + response = self.request(:history_of_metric, {:metric_name => metric_name, :module_result_id => module_result_id})[:date_metric_result] |
34 | response = [] if response.nil? | 45 | response = [] if response.nil? |
35 | response = [response] if response.is_a?(Hash) | 46 | response = [response] if response.is_a?(Hash) |
36 | response.map {|date_metric_result| Kalibro::DateMetricResult.new date_metric_result} | 47 | response.map {|date_metric_result| Kalibro::DateMetricResult.new date_metric_result} |
plugins/mezuro/lib/kalibro/model.rb
@@ -7,6 +7,7 @@ class Kalibro::Model | @@ -7,6 +7,7 @@ class Kalibro::Model | ||
7 | @errors = [] | 7 | @errors = [] |
8 | end | 8 | end |
9 | 9 | ||
10 | + | ||
10 | def to_hash(options={}) | 11 | def to_hash(options={}) |
11 | hash = Hash.new | 12 | hash = Hash.new |
12 | excepts = options[:except].nil? ? [] : options[:except] | 13 | excepts = options[:except].nil? ? [] : options[:except] |
@@ -15,7 +16,7 @@ class Kalibro::Model | @@ -15,7 +16,7 @@ class Kalibro::Model | ||
15 | if(!excepts.include?(field)) | 16 | if(!excepts.include?(field)) |
16 | field_value = send(field) | 17 | field_value = send(field) |
17 | if !field_value.nil? | 18 | if !field_value.nil? |
18 | - hash[field] = convert_to_hash(field_value) | 19 | + hash[field] = convert_to_hash(field_value) |
19 | if field_value.is_a?(Kalibro::Model) | 20 | if field_value.is_a?(Kalibro::Model) |
20 | hash = {:attributes! => {}}.merge(hash) | 21 | hash = {:attributes! => {}}.merge(hash) |
21 | hash[:attributes!][field.to_sym] = { | 22 | hash[:attributes!][field.to_sym] = { |
@@ -91,7 +92,7 @@ class Kalibro::Model | @@ -91,7 +92,7 @@ class Kalibro::Model | ||
91 | return self.class.date_with_milliseconds(value) if value.is_a?(DateTime) | 92 | return self.class.date_with_milliseconds(value) if value.is_a?(DateTime) |
92 | return 'INF' if value.is_a?(Float) and value.infinite? == 1 | 93 | return 'INF' if value.is_a?(Float) and value.infinite? == 1 |
93 | return '-INF' if value.is_a?(Float) and value.infinite? == -1 | 94 | return '-INF' if value.is_a?(Float) and value.infinite? == -1 |
94 | - value | 95 | + value.to_s |
95 | end | 96 | end |
96 | 97 | ||
97 | def xml_instance_class_name(object) | 98 | def xml_instance_class_name(object) |
plugins/mezuro/lib/kalibro/module_result.rb
@@ -22,6 +22,10 @@ class Kalibro::ModuleResult < Kalibro::Model | @@ -22,6 +22,10 @@ class Kalibro::ModuleResult < Kalibro::Model | ||
22 | end | 22 | end |
23 | end | 23 | end |
24 | 24 | ||
25 | + def id=(value) | ||
26 | + @id = value.to_i | ||
27 | + end | ||
28 | + | ||
25 | def module=(value) | 29 | def module=(value) |
26 | @module = Kalibro::Module.to_object value | 30 | @module = Kalibro::Module.to_object value |
27 | end | 31 | end |
@@ -30,6 +34,10 @@ class Kalibro::ModuleResult < Kalibro::Model | @@ -30,6 +34,10 @@ class Kalibro::ModuleResult < Kalibro::Model | ||
30 | @grade = value.to_f | 34 | @grade = value.to_f |
31 | end | 35 | end |
32 | 36 | ||
37 | + def parent_id=(value) | ||
38 | + @parent_id = value.to_i | ||
39 | + end | ||
40 | + | ||
33 | def self.history_of(module_result_id) | 41 | def self.history_of(module_result_id) |
34 | response = self.request(:history_of_module, {:module_result_id => module_result_id})[:date_module_result] | 42 | response = self.request(:history_of_module, {:module_result_id => module_result_id})[:date_module_result] |
35 | response = [] if response.nil? | 43 | response = [] if response.nil? |
plugins/mezuro/lib/kalibro/process_time.rb
plugins/mezuro/lib/kalibro/processing.rb
1 | -#TODO arrumar esse modelo e seus testes de unidade | ||
2 | class Kalibro::Processing < Kalibro::Model | 1 | class Kalibro::Processing < Kalibro::Model |
3 | 2 | ||
4 | attr_accessor :id, :date, :state, :error, :process_time, :results_root_id | 3 | attr_accessor :id, :date, :state, :error, :process_time, :results_root_id |
@@ -12,6 +11,7 @@ class Kalibro::Processing < Kalibro::Model | @@ -12,6 +11,7 @@ class Kalibro::Processing < Kalibro::Model | ||
12 | end | 11 | end |
13 | 12 | ||
14 | def self.processing_with_date_of(repository_id, date) | 13 | def self.processing_with_date_of(repository_id, date) |
14 | + date = date.is_a?(String) ? DateTime.parse(date) : date | ||
15 | if has_processing_after(repository_id, date) | 15 | if has_processing_after(repository_id, date) |
16 | first_processing_after(repository_id, date) | 16 | first_processing_after(repository_id, date) |
17 | elsif has_processing_before(repository_id, date) | 17 | elsif has_processing_before(repository_id, date) |
@@ -21,6 +21,10 @@ class Kalibro::Processing < Kalibro::Model | @@ -21,6 +21,10 @@ class Kalibro::Processing < Kalibro::Model | ||
21 | end | 21 | end |
22 | end | 22 | end |
23 | 23 | ||
24 | + def id=(value) | ||
25 | + @id = value.to_i | ||
26 | + end | ||
27 | + | ||
24 | def date=(value) | 28 | def date=(value) |
25 | @date = value.is_a?(String) ? DateTime.parse(value) : value | 29 | @date = value.is_a?(String) ? DateTime.parse(value) : value |
26 | end | 30 | end |
@@ -41,6 +45,10 @@ class Kalibro::Processing < Kalibro::Model | @@ -41,6 +45,10 @@ class Kalibro::Processing < Kalibro::Model | ||
41 | @error = Kalibro::Throwable.to_object value | 45 | @error = Kalibro::Throwable.to_object value |
42 | end | 46 | end |
43 | 47 | ||
48 | + def results_root_id=(value) | ||
49 | + @results_root_id = value.to_i | ||
50 | + end | ||
51 | + | ||
44 | private | 52 | private |
45 | 53 | ||
46 | def self.has_processing(repository_id) | 54 | def self.has_processing(repository_id) |
plugins/mezuro/lib/kalibro/project.rb
@@ -2,6 +2,10 @@ class Kalibro::Project < Kalibro::Model | @@ -2,6 +2,10 @@ class Kalibro::Project < Kalibro::Model | ||
2 | 2 | ||
3 | attr_accessor :id, :name, :description | 3 | attr_accessor :id, :name, :description |
4 | 4 | ||
5 | + def id=(value) | ||
6 | + @id = value.to_i | ||
7 | + end | ||
8 | + | ||
5 | def self.all | 9 | def self.all |
6 | response = request(:all_projects)[:project] | 10 | response = request(:all_projects)[:project] |
7 | response = [] if response.nil? | 11 | response = [] if response.nil? |
plugins/mezuro/lib/kalibro/range_snapshot.rb
1 | class Kalibro::RangeSnapshot < Kalibro::Model | 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 | + | ||
5 | + def beginning=(value) | ||
6 | + @beginning = ((value == "-INF") ? -1.0/0 : value.to_f) | ||
7 | + end | ||
8 | + | ||
9 | + def end=(value) | ||
10 | + @end = ((value == "INF") ? 1.0/0 : value.to_f) | ||
11 | + end | ||
12 | + | ||
13 | + def grade=(value) | ||
14 | + @grade = value.to_f | ||
15 | + end | ||
4 | 16 | ||
5 | end | 17 | end |
plugins/mezuro/lib/kalibro/repository.rb
@@ -17,7 +17,19 @@ class Kalibro::Repository < Kalibro::Model | @@ -17,7 +17,19 @@ 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 id=(value) |
21 | + @id = value.to_i | ||
22 | + end | ||
23 | + | ||
24 | + def process_period=(value) | ||
25 | + @process_period = value.to_i | ||
26 | + end | ||
27 | + | ||
28 | + def configuration_id=(value) | ||
29 | + @configuration_id = value.to_i | ||
30 | + end | ||
31 | + | ||
32 | + def process | ||
21 | self.class.request(:process_repository, {:repository_id => self.id}) | 33 | self.class.request(:process_repository, {:repository_id => self.id}) |
22 | end | 34 | end |
23 | 35 | ||
@@ -28,7 +40,6 @@ class Kalibro::Repository < Kalibro::Model | @@ -28,7 +40,6 @@ class Kalibro::Repository < Kalibro::Model | ||
28 | def save(project_id) | 40 | def save(project_id) |
29 | begin | 41 | begin |
30 | self.id = self.class.request(:save_repository, {:repository => self.to_hash, :project_id => project_id})[:repository_id] | 42 | self.id = self.class.request(:save_repository, {:repository => self.to_hash, :project_id => project_id})[:repository_id] |
31 | - process_repository | ||
32 | true | 43 | true |
33 | rescue Exception => exception | 44 | rescue Exception => exception |
34 | add_error exception | 45 | add_error exception |
plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb
@@ -7,7 +7,7 @@ class MezuroPlugin::Helpers::ContentViewerHelper | @@ -7,7 +7,7 @@ class MezuroPlugin::Helpers::ContentViewerHelper | ||
7 | end | 7 | end |
8 | 8 | ||
9 | def self.periodicity_options | 9 | def self.periodicity_options |
10 | - [["Not Periodically", 0], ["1 day", 1], ["2 days", 2], ["Weekly", 7], ["Biweeky", 15], ["Monthly", 30]] | 10 | + [["Not Periodically", 0], ["1 day", 1], ["2 days", 2], ["Weekly", 7], ["Biweekly", 15], ["Monthly", 30]] |
11 | end | 11 | end |
12 | 12 | ||
13 | def self.periodicity_option(periodicity) | 13 | def self.periodicity_option(periodicity) |
@@ -43,10 +43,14 @@ class MezuroPlugin::Helpers::ContentViewerHelper | @@ -43,10 +43,14 @@ class MezuroPlugin::Helpers::ContentViewerHelper | ||
43 | ) | 43 | ) |
44 | end | 44 | end |
45 | 45 | ||
46 | - | ||
47 | def self.format_name(metric_configuration_snapshot) | 46 | def self.format_name(metric_configuration_snapshot) |
48 | metric_configuration_snapshot.metric.name.delete("() ") | 47 | metric_configuration_snapshot.metric.name.delete("() ") |
49 | end | 48 | end |
49 | + | ||
50 | + def self.format_time(miliseconds) | ||
51 | + seconds = miliseconds/1000 | ||
52 | + MezuroPluginModuleResultController.helpers.distance_of_time_in_words(0, seconds, include_seconds = true) | ||
53 | + end | ||
50 | 54 | ||
51 | private | 55 | private |
52 | 56 |
plugins/mezuro/lib/mezuro_plugin/helpers/module_result_helper.rb
0 → 100644
plugins/mezuro/lib/mezuro_plugin/project_content.rb
@@ -83,7 +83,6 @@ class MezuroPlugin::ProjectContent < Article | @@ -83,7 +83,6 @@ class MezuroPlugin::ProjectContent < Article | ||
83 | 83 | ||
84 | def create_kalibro_project | 84 | def create_kalibro_project |
85 | Kalibro::Project.create( | 85 | Kalibro::Project.create( |
86 | - :id => project_id, | ||
87 | :name => name, | 86 | :name => name, |
88 | :description => description | 87 | :description => description |
89 | ) | 88 | ) |
plugins/mezuro/public/javascripts/processing.js
@@ -2,41 +2,39 @@ var processingTree = false; | @@ -2,41 +2,39 @@ var processingTree = false; | ||
2 | var metricName; | 2 | var metricName; |
3 | jQuery(function (){ | 3 | jQuery(function (){ |
4 | jQuery('.source-tree-link').live("click", reloadModule); | 4 | jQuery('.source-tree-link').live("click", reloadModule); |
5 | - jQuery('[show-metric-history]').live("click", display_metric_history); //TODO review for project history | ||
6 | - jQuery('[show-grade-history]').live("click", display_grade_history); //TODO review for project history | ||
7 | - jQuery('#project_date_submit').live("click", reloadProjectWithDate); //TODO review for project history | 5 | + jQuery('[show-metric-history]').live("click", display_metric_history); |
6 | + jQuery('[show-grade-history]').live("click", display_grade_history); | ||
7 | + jQuery('#project_date_submit').live("click", reloadProcessingWithDate); | ||
8 | showLoadingProcess(true); | 8 | showLoadingProcess(true); |
9 | showProcessing(); | 9 | showProcessing(); |
10 | }); | 10 | }); |
11 | 11 | ||
12 | function showProcessing() { | 12 | function showProcessing() { |
13 | - callAction('processing', 'processing', {}, showProcessingFor); | 13 | + repository_id = processingData('repository-id'); |
14 | + callAction('processing', 'state', {repository_id: repository_id}, showProcessingFor); | ||
14 | } | 15 | } |
15 | 16 | ||
16 | -//TODO review for project history | ||
17 | function display_metric_history() { | 17 | function display_metric_history() { |
18 | - var module_name = jQuery(this).attr('data-module-name'); | ||
19 | - var metric_name = jQuery(this).attr('show-metric-history'); | ||
20 | - toggle_mezuro("." + metric_name); | ||
21 | - metricName = metric_name; | 18 | + var module_result_id = jQuery(this).attr('data-module-id'); |
19 | + var formatted_name = jQuery(this).attr('show-metric-history'); | ||
20 | + var metric_name = jQuery(this).attr('data-metric-name'); | ||
21 | + toggle_mezuro("." + formatted_name); | ||
22 | + metricName = formatted_name; | ||
22 | callAction('module_result', 'metric_result_history', {metric_name: metric_name, module_result_id: module_result_id}, show_metrics); | 23 | callAction('module_result', 'metric_result_history', {metric_name: metric_name, module_result_id: module_result_id}, show_metrics); |
23 | return false; | 24 | return false; |
24 | } | 25 | } |
25 | 26 | ||
26 | -//TODO review for project history | ||
27 | function display_grade_history() { | 27 | function display_grade_history() { |
28 | - var module_name = jQuery(this).attr('data-module-name'); | 28 | + var module_result_id = jQuery(this).attr('data-module-id'); |
29 | toggle_mezuro("#historical-grade"); | 29 | toggle_mezuro("#historical-grade"); |
30 | callAction('module_result', 'module_result_history', {module_result_id: module_result_id}, show_grades); | 30 | callAction('module_result', 'module_result_history', {module_result_id: module_result_id}, show_grades); |
31 | return false; | 31 | return false; |
32 | } | 32 | } |
33 | 33 | ||
34 | -//TODO review for project history | ||
35 | function show_metrics(content) { | 34 | function show_metrics(content) { |
36 | jQuery('#historical-' + metricName).html(content); | 35 | jQuery('#historical-' + metricName).html(content); |
37 | } | 36 | } |
38 | 37 | ||
39 | -//TODO review for project history | ||
40 | function show_grades(content) { | 38 | function show_grades(content) { |
41 | jQuery('#historical-grade').html(content); | 39 | jQuery('#historical-grade').html(content); |
42 | } | 40 | } |
@@ -46,93 +44,85 @@ function toggle_mezuro(element){ | @@ -46,93 +44,85 @@ function toggle_mezuro(element){ | ||
46 | return false; | 44 | return false; |
47 | } | 45 | } |
48 | 46 | ||
49 | -//TODO Waiting for ModuleResultController refactoring | ||
50 | function reloadModule(){ | 47 | function reloadModule(){ |
51 | - var results_root_id = jQuery(this).attr('results_root_id'); | 48 | + var module_result_id = jQuery(this).attr('data-module-id'); |
52 | showLoadingProcess(false); | 49 | showLoadingProcess(false); |
53 | processingTree = true; | 50 | processingTree = true; |
54 | -// callAction('module_result', 'project_tree', {results_root_id: results_root_id }, showProjectTree); | ||
55 | - callAction('module_result', 'module_result', {results_root_id: results_root_id}, showModuleResult); | 51 | + callAction('module_result', 'module_result', {module_result_id: module_result_id}, showModuleResult); |
56 | return false; | 52 | return false; |
57 | } | 53 | } |
58 | 54 | ||
59 | -//TODO review for project history | ||
60 | -function reloadProjectWithDate(date){ | ||
61 | - reloadProject(date + "T00:00:00+00:00"); | 55 | +function reloadProcessingWithDate(date){ |
56 | + reloadProcessing(date + "T00:00:00+00:00"); | ||
62 | return false; | 57 | return false; |
63 | } | 58 | } |
64 | 59 | ||
65 | -//TODO review for project history | ||
66 | -function reloadProject(date){ | 60 | +function reloadProcessing(date){ |
61 | + repository_id = processingData('repository-id'); | ||
67 | showLoadingProcess(true); | 62 | showLoadingProcess(true); |
68 | - | ||
69 | - callAction('processing', 'processing', {date: date}, showProjectResult); | ||
70 | -// callAction('module_result', 'project_tree', {date: date}, showProjectTree); | ||
71 | - callAction('module_result', 'module_result', {date: date}, showModuleResult); | 63 | + |
64 | + callAction('processing', 'processing', {date: date, repository_id: repository_id}, function(content){ | ||
65 | + showReadyProcessing(content); | ||
66 | + var module_result_id = jQuery("#module_result_root_id").attr('module_result_root_id'); | ||
67 | + callAction('module_result', 'module_result', {module_result_id: module_result_id}, showModuleResult); | ||
68 | + } | ||
69 | + ); | ||
72 | } | 70 | } |
73 | 71 | ||
74 | function showProcessingFor(state){ | 72 | function showProcessingFor(state){ |
73 | + repository_id = processingData('repository-id'); | ||
75 | if (state == 'ERROR') { | 74 | if (state == 'ERROR') { |
76 | - jQuery('#project-state').html('<div style="color:Red">ERROR</div>'); | ||
77 | - callAction('processing', 'processing_error', {}, showProcessing); | 75 | + jQuery('#processing-state').html('<div style="color:Red">ERROR</div>'); |
76 | + callAction('processing', 'processing', {repository_id: repository_id}, showReadyProcessing); | ||
77 | + showModuleResult(''); | ||
78 | } | 78 | } |
79 | else if (state == 'READY') { | 79 | else if (state == 'READY') { |
80 | jQuery('#msg-time').html(''); | 80 | jQuery('#msg-time').html(''); |
81 | jQuery('#processing-state').html('<div style="color:Green">READY</div>'); | 81 | jQuery('#processing-state').html('<div style="color:Green">READY</div>'); |
82 | - callAction('processing', 'processing', {}, showProcessing); | ||
83 | -// callAction('processing','project_tree', {}, showProjectTree); | ||
84 | - //var module_result_id = jQuery("#processing").attr('results_root_id'); //TODO Waiting for ModuleResultController refactoring | ||
85 | - callAction('module_result', 'module_result', {module_result_id: module_result_id}, showModuleResult); //TODO Waiting for ModuleResultController refactoring | ||
86 | - } | 82 | + callAction('processing', 'processing', {repository_id: repository_id}, function(content){ |
83 | + showReadyProcessing(content); | ||
84 | + var module_result_id = jQuery("#module_result_root_id").attr('module_result_root_id'); | ||
85 | + callAction('module_result', 'module_result', {module_result_id: module_result_id}, showModuleResult); | ||
86 | + } | ||
87 | + ); | ||
88 | + } | ||
87 | else if (state.endsWith("ING")) { | 89 | else if (state.endsWith("ING")) { |
88 | jQuery('#processing-state').html('<div style="color:DarkGoldenRod">'+ state +'</div>'); | 90 | jQuery('#processing-state').html('<div style="color:DarkGoldenRod">'+ state +'</div>'); |
89 | jQuery('#msg-time').html("The project analysis may take long. <br/> You'll receive an e-mail when it's ready!"); | 91 | jQuery('#msg-time').html("The project analysis may take long. <br/> You'll receive an e-mail when it's ready!"); |
90 | - showProjectContentAfter(20); | ||
91 | - } | 92 | + showProcessingAfter(20); |
93 | + } | ||
92 | } | 94 | } |
93 | 95 | ||
94 | -function showProjectContentAfter(seconds){ | 96 | +function showProcessingAfter(seconds){ |
95 | if (seconds > 0){ | 97 | if (seconds > 0){ |
96 | - setTimeout(function() { showProjectContentAfter(seconds - 10);}, 10000); | 98 | + setTimeout(function() { showProcessingAfter(seconds - 10);}, 10000); |
97 | } else { | 99 | } else { |
98 | - showProjectContent(); | 100 | + showProcessing(); |
99 | } | 101 | } |
100 | } | 102 | } |
101 | 103 | ||
102 | -function showProjectResult(content) { | 104 | +function showReadyProcessing(content) { |
103 | jQuery('#processing').html(content); | 105 | jQuery('#processing').html(content); |
104 | } | 106 | } |
105 | 107 | ||
106 | -//function showProjectTree(content){ | ||
107 | -// processingTree = false; | ||
108 | -// jQuery('#project-tree').html(content); | ||
109 | -// return false; | ||
110 | -//} | ||
111 | - | ||
112 | -//TODO Waiting for ModuleResultController refactoring | ||
113 | function showModuleResult(content){ | 108 | function showModuleResult(content){ |
114 | -// if (processingTree != true){ | ||
115 | jQuery('#module-result').html(content); | 109 | jQuery('#module-result').html(content); |
116 | -// } | ||
117 | -// return false; | ||
118 | } | 110 | } |
119 | 111 | ||
120 | function callAction(controller, action, params, callback){ | 112 | function callAction(controller, action, params, callback){ |
121 | - var profile = projectContentData('profile'); | ||
122 | - var content = projectContentData('content'); | 113 | + var profile = processingData('profile'); |
114 | + var content = processingData('content'); | ||
123 | var endpoint = '/profile/' + profile + '/plugin/mezuro/' + controller + '/' + action + '/' + content; | 115 | var endpoint = '/profile/' + profile + '/plugin/mezuro/' + controller + '/' + action + '/' + content; |
124 | jQuery.get(endpoint, params, callback); | 116 | jQuery.get(endpoint, params, callback); |
125 | } | 117 | } |
126 | 118 | ||
127 | -function projectContentData(data){ | 119 | +function processingData(data){ |
128 | return jQuery('#processing').attr('data-' + data); | 120 | return jQuery('#processing').attr('data-' + data); |
129 | } | 121 | } |
130 | 122 | ||
131 | function showLoadingProcess(firstLoad){ | 123 | function showLoadingProcess(firstLoad){ |
132 | - if(firstLoad) | ||
133 | - showProjectResult("<img src='/images/loading-small.gif'/>"); | ||
134 | - | ||
135 | - showProjectTree("<img src='/images/loading-small.gif'/>"); | 124 | + if(firstLoad) |
125 | + showReadyProcessing("<img src='/images/loading-small.gif'/>"); | ||
136 | showModuleResult("<img src='/images/loading-small.gif'/>"); | 126 | showModuleResult("<img src='/images/loading-small.gif'/>"); |
137 | } | 127 | } |
138 | 128 |
plugins/mezuro/test/fixtures/configuration_fixtures.rb
@@ -15,7 +15,7 @@ class ConfigurationFixtures | @@ -15,7 +15,7 @@ class ConfigurationFixtures | ||
15 | 15 | ||
16 | def self.configuration_hash | 16 | def self.configuration_hash |
17 | { | 17 | { |
18 | - :id => 42, | 18 | + :id => "42", |
19 | :name => 'Sample Configuration', | 19 | :name => 'Sample Configuration', |
20 | :description => 'Kalibro configuration for Java projects.' | 20 | :description => 'Kalibro configuration for Java projects.' |
21 | } | 21 | } |
plugins/mezuro/test/fixtures/date_metric_result_fixtures.rb
@@ -21,4 +21,13 @@ class DateMetricResultFixtures | @@ -21,4 +21,13 @@ class DateMetricResultFixtures | ||
21 | } | 21 | } |
22 | end | 22 | end |
23 | 23 | ||
24 | + def self.score_history | ||
25 | + result = [] | ||
26 | + result << date_metric_result | ||
27 | + newer_date_metric_result = date_metric_result | ||
28 | + newer_date_metric_result.date = '2011-10-25T18:26:43.151+00:00' | ||
29 | + newer_date_metric_result.metric_result.value = 5.0 | ||
30 | + result << newer_date_metric_result | ||
31 | + end | ||
32 | + | ||
24 | end | 33 | end |
plugins/mezuro/test/fixtures/metric_configuration_fixtures.rb
@@ -4,13 +4,13 @@ class MetricConfigurationFixtures | @@ -4,13 +4,13 @@ class MetricConfigurationFixtures | ||
4 | 4 | ||
5 | def self.amloc_metric_configuration | 5 | def self.amloc_metric_configuration |
6 | amloc = Kalibro::MetricConfiguration.new amloc_metric_configuration_hash | 6 | amloc = Kalibro::MetricConfiguration.new amloc_metric_configuration_hash |
7 | - amloc.configuration_id = 13 | 7 | + amloc.configuration_id = "13" |
8 | amloc | 8 | amloc |
9 | end | 9 | end |
10 | 10 | ||
11 | def self.sc_metric_configuration | 11 | def self.sc_metric_configuration |
12 | sc = Kalibro::MetricConfiguration.new sc_metric_configuration_hash | 12 | sc = Kalibro::MetricConfiguration.new sc_metric_configuration_hash |
13 | - sc.configuration_id = 13 | 13 | + sc.configuration_id = "13" |
14 | sc | 14 | sc |
15 | end | 15 | end |
16 | 16 | ||
@@ -19,22 +19,22 @@ class MetricConfigurationFixtures | @@ -19,22 +19,22 @@ class MetricConfigurationFixtures | ||
19 | :code => 'amloc', | 19 | :code => 'amloc', |
20 | :metric => MetricFixtures.amloc_hash, | 20 | :metric => MetricFixtures.amloc_hash, |
21 | :base_tool_name => MetricFixtures.amloc_hash[:origin], | 21 | :base_tool_name => MetricFixtures.amloc_hash[:origin], |
22 | - :weight => 1.0, | 22 | + :weight => "1.0", |
23 | :aggregation_form => 'AVERAGE', | 23 | :aggregation_form => 'AVERAGE', |
24 | - :reading_group_id => 31, | ||
25 | - :configuration_id => 13 | 24 | + :reading_group_id => "31", |
25 | + :configuration_id => "13" | ||
26 | }) | 26 | }) |
27 | end | 27 | end |
28 | 28 | ||
29 | def self.amloc_metric_configuration_hash | 29 | def self.amloc_metric_configuration_hash |
30 | { | 30 | { |
31 | - :id => 42, | 31 | + :id => "42", |
32 | :code => 'amloc', | 32 | :code => 'amloc', |
33 | :metric => MetricFixtures.amloc_hash, | 33 | :metric => MetricFixtures.amloc_hash, |
34 | :base_tool_name => MetricFixtures.amloc_hash[:origin], | 34 | :base_tool_name => MetricFixtures.amloc_hash[:origin], |
35 | - :weight => 1.0, | 35 | + :weight => "1.0", |
36 | :aggregation_form => 'AVERAGE', | 36 | :aggregation_form => 'AVERAGE', |
37 | - :reading_group_id => 31, | 37 | + :reading_group_id => "31", |
38 | :attributes! => {:metric => { | 38 | :attributes! => {:metric => { |
39 | 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | 39 | 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', |
40 | 'xsi:type' => 'kalibro:metricXml' }} | 40 | 'xsi:type' => 'kalibro:metricXml' }} |
@@ -43,12 +43,12 @@ class MetricConfigurationFixtures | @@ -43,12 +43,12 @@ class MetricConfigurationFixtures | ||
43 | 43 | ||
44 | def self.sc_metric_configuration_hash | 44 | def self.sc_metric_configuration_hash |
45 | { | 45 | { |
46 | - :id => 42, | 46 | + :id => "42", |
47 | :code => 'sc', | 47 | :code => 'sc', |
48 | :metric => MetricFixtures.compound_metric_hash, | 48 | :metric => MetricFixtures.compound_metric_hash, |
49 | - :weight => 1.0, | 49 | + :weight => "1.0", |
50 | :aggregation_form => 'AVERAGE', | 50 | :aggregation_form => 'AVERAGE', |
51 | - :reading_group_id => 31, | 51 | + :reading_group_id => "31", |
52 | :attributes! => {:metric => { | 52 | :attributes! => {:metric => { |
53 | 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | 53 | 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', |
54 | 'xsi:type' => 'kalibro:metricXml' }} | 54 | 'xsi:type' => 'kalibro:metricXml' }} |
plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures.rb
@@ -10,11 +10,11 @@ class MetricConfigurationSnapshotFixtures | @@ -10,11 +10,11 @@ class MetricConfigurationSnapshotFixtures | ||
10 | def self.metric_configuration_snapshot_hash | 10 | def self.metric_configuration_snapshot_hash |
11 | { | 11 | { |
12 | :code => "code", | 12 | :code => "code", |
13 | - :weight => 1, | 13 | + :weight => "1.0", |
14 | :aggregation_form => 'AVERAGE', | 14 | :aggregation_form => 'AVERAGE', |
15 | :metric => MetricFixtures.amloc_hash, | 15 | :metric => MetricFixtures.amloc_hash, |
16 | :base_tool_name => "Analizo", | 16 | :base_tool_name => "Analizo", |
17 | - :range => RangeSnapshotFixtures.range_snapshot_hash, | 17 | + :range => [RangeSnapshotFixtures.range_snapshot_hash], |
18 | :attributes! => { | 18 | :attributes! => { |
19 | :metric => { | 19 | :metric => { |
20 | 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | 20 | 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', |
@@ -26,6 +26,16 @@ class MetricConfigurationSnapshotFixtures | @@ -26,6 +26,16 @@ class MetricConfigurationSnapshotFixtures | ||
26 | } | 26 | } |
27 | end | 27 | end |
28 | 28 | ||
29 | + def self.metric_configuration_snapshot_with_2_elements | ||
30 | + Kalibro::MetricConfigurationSnapshot.new metric_configuration_snapshot_hash_with_2_elements | ||
31 | + end | ||
32 | + | ||
33 | + def self.metric_configuration_snapshot_hash_with_2_elements | ||
34 | + hash = self.metric_configuration_snapshot_hash | ||
35 | + hash[:range] << RangeSnapshotFixtures.range_snapshot_hash | ||
36 | + hash | ||
37 | + end | ||
38 | + | ||
29 | def self.compound_metric_configuration_snapshot | 39 | def self.compound_metric_configuration_snapshot |
30 | Kalibro::MetricConfigurationSnapshot.new compound_metric_configuration_snapshot_hash | 40 | Kalibro::MetricConfigurationSnapshot.new compound_metric_configuration_snapshot_hash |
31 | end | 41 | end |
@@ -33,11 +43,11 @@ class MetricConfigurationSnapshotFixtures | @@ -33,11 +43,11 @@ class MetricConfigurationSnapshotFixtures | ||
33 | def self.compound_metric_configuration_snapshot_hash | 43 | def self.compound_metric_configuration_snapshot_hash |
34 | { | 44 | { |
35 | :code => "code", | 45 | :code => "code", |
36 | - :weight => 1, | 46 | + :weight => "1.0", |
37 | :aggregation_form => 'AVERAGE', | 47 | :aggregation_form => 'AVERAGE', |
38 | :metric => MetricFixtures.compound_metric, | 48 | :metric => MetricFixtures.compound_metric, |
39 | :base_tool_name => "Analizo", | 49 | :base_tool_name => "Analizo", |
40 | - :range => RangeSnapshotFixtures.range_snapshot_hash, | 50 | + :range => [RangeSnapshotFixtures.range_snapshot_hash], |
41 | :attributes! => { | 51 | :attributes! => { |
42 | :metric => { | 52 | :metric => { |
43 | 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | 53 | 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', |
plugins/mezuro/test/fixtures/metric_fixtures.rb
@@ -5,7 +5,7 @@ class MetricFixtures | @@ -5,7 +5,7 @@ class MetricFixtures | ||
5 | end | 5 | end |
6 | 6 | ||
7 | def self.compound_metric_hash | 7 | def self.compound_metric_hash |
8 | - {:name => 'Structural Complexity', :compound => true, :scope => 'CLASS', :script => 'return 42;', :description => 'Calculate the Structural Complexity of the Code'} | 8 | + {:name => 'Structural Complexity', :compound => "true", :scope => 'CLASS', :script => 'return 42;', :description => 'Calculate the Structural Complexity of the Code'} |
9 | end | 9 | end |
10 | 10 | ||
11 | def self.total_cof | 11 | def self.total_cof |
@@ -13,7 +13,7 @@ class MetricFixtures | @@ -13,7 +13,7 @@ class MetricFixtures | ||
13 | end | 13 | end |
14 | 14 | ||
15 | def self.total_cof_hash | 15 | def self.total_cof_hash |
16 | - {:name => 'Total Coupling Factor', :compound => false, :scope => 'APPLICATION', :origin => 'Analizo', :language => ['JAVA']} | 16 | + {:name => 'Total Coupling Factor', :compound => "false", :scope => 'APPLICATION', :origin => 'Analizo', :language => ['JAVA']} |
17 | end | 17 | end |
18 | 18 | ||
19 | def self.amloc | 19 | def self.amloc |
@@ -21,7 +21,7 @@ class MetricFixtures | @@ -21,7 +21,7 @@ class MetricFixtures | ||
21 | end | 21 | end |
22 | 22 | ||
23 | def self.amloc_hash | 23 | def self.amloc_hash |
24 | - {:name => 'Average Method LOC', :compound => false, :scope => 'CLASS', :origin => 'Analizo', :language => ['JAVA']} | 24 | + {:name => 'Average Method LOC', :compound => "false", :scope => 'CLASS', :origin => 'Analizo', :language => ['JAVA']} |
25 | end | 25 | end |
26 | 26 | ||
27 | end | 27 | end |
plugins/mezuro/test/fixtures/metric_result_fixtures.rb
@@ -13,7 +13,7 @@ class MetricResultFixtures | @@ -13,7 +13,7 @@ class MetricResultFixtures | ||
13 | 13 | ||
14 | def self.metric_result_with_error_hash | 14 | def self.metric_result_with_error_hash |
15 | { | 15 | { |
16 | - :id => 41, | 16 | + :id => "41", |
17 | :configuration => MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_hash, | 17 | :configuration => MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_hash, |
18 | :error => ThrowableFixtures.throwable_hash | 18 | :error => ThrowableFixtures.throwable_hash |
19 | } | 19 | } |
@@ -21,9 +21,9 @@ class MetricResultFixtures | @@ -21,9 +21,9 @@ class MetricResultFixtures | ||
21 | 21 | ||
22 | def self.native_metric_result_hash | 22 | def self.native_metric_result_hash |
23 | { | 23 | { |
24 | - :id => 42, | 24 | + :id => "42", |
25 | :configuration => MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_hash, | 25 | :configuration => MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_hash, |
26 | - :value => 0.0, | 26 | + :value => "0.0", |
27 | :attributes! => | 27 | :attributes! => |
28 | { | 28 | { |
29 | :configuration => | 29 | :configuration => |
@@ -37,9 +37,9 @@ class MetricResultFixtures | @@ -37,9 +37,9 @@ class MetricResultFixtures | ||
37 | 37 | ||
38 | def self.compound_metric_result_hash | 38 | def self.compound_metric_result_hash |
39 | { | 39 | { |
40 | - :id => 43, | 40 | + :id => "43", |
41 | :configuration => MetricConfigurationSnapshotFixtures.compound_metric_configuration_snapshot_hash, | 41 | :configuration => MetricConfigurationSnapshotFixtures.compound_metric_configuration_snapshot_hash, |
42 | - :value => 1.0, | 42 | + :value => "1.0", |
43 | :attributes! => | 43 | :attributes! => |
44 | { | 44 | { |
45 | :configuration => | 45 | :configuration => |
plugins/mezuro/test/fixtures/module_result_fixtures.rb
@@ -8,10 +8,10 @@ class ModuleResultFixtures | @@ -8,10 +8,10 @@ class ModuleResultFixtures | ||
8 | 8 | ||
9 | def self.module_result_hash | 9 | def self.module_result_hash |
10 | { | 10 | { |
11 | - :id => 42, | 11 | + :id => "42", |
12 | :module => ModuleFixtures.module_hash, | 12 | :module => ModuleFixtures.module_hash, |
13 | - :grade => 10.0, | ||
14 | - :parent_id => 31, | 13 | + :grade => "10.0", |
14 | + :parent_id => "31", | ||
15 | :attributes! => | 15 | :attributes! => |
16 | { | 16 | { |
17 | :module => | 17 | :module => |
@@ -25,12 +25,12 @@ class ModuleResultFixtures | @@ -25,12 +25,12 @@ class ModuleResultFixtures | ||
25 | 25 | ||
26 | def self.parent_module_result_hash | 26 | def self.parent_module_result_hash |
27 | { | 27 | { |
28 | - :id => 31, | 28 | + :id => "31", |
29 | :module => { | 29 | :module => { |
30 | :name => 'Qt-Calculator Parent', | 30 | :name => 'Qt-Calculator Parent', |
31 | :granularity => 'APPLICATION' | 31 | :granularity => 'APPLICATION' |
32 | }, | 32 | }, |
33 | - :grade => 10.0, | 33 | + :grade => "10.0", |
34 | :attributes! => | 34 | :attributes! => |
35 | { | 35 | { |
36 | :module => | 36 | :module => |
plugins/mezuro/test/fixtures/process_time_fixtures.rb
plugins/mezuro/test/fixtures/processing_fixtures.rb
@@ -9,17 +9,17 @@ class ProcessingFixtures | @@ -9,17 +9,17 @@ class ProcessingFixtures | ||
9 | 9 | ||
10 | def self.processing_hash | 10 | def self.processing_hash |
11 | { | 11 | { |
12 | - :id => 31, | 12 | + :id => "31", |
13 | :date => '2011-10-20T18:26:43.151+00:00', | 13 | :date => '2011-10-20T18:26:43.151+00:00', |
14 | :state => 'READY', | 14 | :state => 'READY', |
15 | :process_time => [ProcessTimeFixtures.process_time_hash], | 15 | :process_time => [ProcessTimeFixtures.process_time_hash], |
16 | - :results_root_id => 13 | 16 | + :results_root_id => "13" |
17 | } | 17 | } |
18 | end | 18 | end |
19 | 19 | ||
20 | def self.processing_with_error_hash | 20 | def self.processing_with_error_hash |
21 | { | 21 | { |
22 | - :id => 31, | 22 | + :id => "31", |
23 | :date => '2011-10-20T18:26:43.151+00:00', | 23 | :date => '2011-10-20T18:26:43.151+00:00', |
24 | :state => 'ERROR', | 24 | :state => 'ERROR', |
25 | :process_time => [ProcessTimeFixtures.process_time_hash], | 25 | :process_time => [ProcessTimeFixtures.process_time_hash], |
plugins/mezuro/test/fixtures/project_content_fixtures.rb
@@ -3,14 +3,7 @@ class ProjectContentFixtures | @@ -3,14 +3,7 @@ class ProjectContentFixtures | ||
3 | def self.project_content | 3 | def self.project_content |
4 | content = MezuroPlugin::ProjectContent.new | 4 | content = MezuroPlugin::ProjectContent.new |
5 | content.project_id = 42 | 5 | content.project_id = 42 |
6 | - #content.name = 'Qt-Calculator' | ||
7 | - #content.project_license = 'GPL' | ||
8 | - #content.description = 'Calculator for Qt' | ||
9 | - #content.repository_type = [RepositoryFixtures.repository_hash[:type]] | ||
10 | - #content.repository_url = [RepositoryFixtures.repository_hash[:address]] | ||
11 | - #content.configuration_name = 'Kalibro for Java' | ||
12 | - #content.periodicity_in_days = 1 | ||
13 | content | 6 | content |
14 | end | 7 | end |
15 | 8 | ||
16 | -end | ||
17 | \ No newline at end of file | 9 | \ No newline at end of file |
10 | +end |
plugins/mezuro/test/fixtures/project_fixtures.rb
@@ -12,7 +12,7 @@ class ProjectFixtures | @@ -12,7 +12,7 @@ class ProjectFixtures | ||
12 | 12 | ||
13 | def self.project_hash | 13 | def self.project_hash |
14 | { | 14 | { |
15 | - :id => 42, | 15 | + :id => "42", |
16 | :name => 'Qt-Calculator', | 16 | :name => 'Qt-Calculator', |
17 | :description => 'Calculator for Qt' | 17 | :description => 'Calculator for Qt' |
18 | } | 18 | } |
plugins/mezuro/test/fixtures/range_fixtures.rb
@@ -5,11 +5,11 @@ class RangeFixtures | @@ -5,11 +5,11 @@ class RangeFixtures | ||
5 | end | 5 | end |
6 | 6 | ||
7 | def self.created_range | 7 | def self.created_range |
8 | - Kalibro::Range.new :beginning => 19.5, :end => "INF", :reading_id => 1, :comments => "Test range 1" | 8 | + Kalibro::Range.new :beginning => "19.5", :end => "INF", :reading_id => "1", :comments => "Test range 1" |
9 | end | 9 | end |
10 | 10 | ||
11 | def self.range_hash | 11 | def self.range_hash |
12 | - {:id => 1, :beginning => 19.5, :end => "INF", :reading_id => 1, :comments => "Test range 1"} | 12 | + {:id => "1", :beginning => "19.5", :end => "INF", :reading_id => "1", :comments => "Test range 1"} |
13 | end | 13 | end |
14 | 14 | ||
15 | end | 15 | end |
plugins/mezuro/test/fixtures/range_snapshot_fixtures.rb
@@ -4,8 +4,16 @@ class RangeSnapshotFixtures | @@ -4,8 +4,16 @@ class RangeSnapshotFixtures | ||
4 | Kalibro::RangeSnapshot.new range_snapshot_hash | 4 | Kalibro::RangeSnapshot.new range_snapshot_hash |
5 | end | 5 | end |
6 | 6 | ||
7 | + def self.range_snapshot_with_infinite_range | ||
8 | + Kalibro::RangeSnapshot.new range_snapshot_with_infinite_range_hash | ||
9 | + end | ||
10 | + | ||
7 | def self.range_snapshot_hash | 11 | def self.range_snapshot_hash |
8 | - { :end => 5, :label => "snapshot", :grade => 10, :color => "FF2284", :comments => "comment" } | 12 | + { :beginning => "1.1", :end => "5.1", :label => "snapshot", :grade => "10.1", :color => "FF2284", :comments => "comment" } |
9 | end | 13 | end |
10 | 14 | ||
15 | + def self.range_snapshot_with_infinite_range_hash | ||
16 | + { :beginning => "-INF", :end => "INF", :label => "snapshot", :grade => "10.1", :color => "FF2284", :comments => "comment" } | ||
17 | + end | ||
18 | + | ||
11 | end | 19 | end |
plugins/mezuro/test/fixtures/reading_fixtures.rb
@@ -5,11 +5,11 @@ class ReadingFixtures | @@ -5,11 +5,11 @@ class ReadingFixtures | ||
5 | end | 5 | end |
6 | 6 | ||
7 | def self.created_reading # A created object has no id before being sent to kalibro | 7 | def self.created_reading # A created object has no id before being sent to kalibro |
8 | - Kalibro::Reading.new :label => "Reading Test Label", :grade => 10.5, :color => "AABBCC" | 8 | + Kalibro::Reading.new :label => "Reading Test Label", :grade => "10.5", :color => "AABBCC" |
9 | end | 9 | end |
10 | 10 | ||
11 | def self.reading_hash | 11 | def self.reading_hash |
12 | - {:id => 42, :label => "Reading Test Label", :grade => 10.5, :color => "AABBCC" } | 12 | + {:id => "42", :label => "Reading Test Label", :grade => "10.5", :color => "AABBCC" } |
13 | end | 13 | end |
14 | 14 | ||
15 | end | 15 | end |
plugins/mezuro/test/fixtures/reading_group_fixtures.rb
@@ -9,7 +9,7 @@ class ReadingGroupFixtures | @@ -9,7 +9,7 @@ class ReadingGroupFixtures | ||
9 | end | 9 | end |
10 | 10 | ||
11 | def self.reading_group_hash | 11 | def self.reading_group_hash |
12 | - {:id => 42, :name => "Reading Group Test", :description => "Reading group in the fixtures"} | 12 | + {:id => "42", :name => "Reading Group Test", :description => "Reading group in the fixtures"} |
13 | end | 13 | end |
14 | 14 | ||
15 | end | 15 | end |
plugins/mezuro/test/fixtures/repository_fixtures.rb
@@ -12,12 +12,12 @@ class RepositoryFixtures | @@ -12,12 +12,12 @@ class RepositoryFixtures | ||
12 | :process_period => "1", | 12 | :process_period => "1", |
13 | :type => 'SUBVERSION', | 13 | :type => 'SUBVERSION', |
14 | :address => 'https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator', | 14 | :address => 'https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator', |
15 | - :configuration_id => 31 | 15 | + :configuration_id => "31" |
16 | }) | 16 | }) |
17 | end | 17 | end |
18 | 18 | ||
19 | def self.repository_hash | 19 | def self.repository_hash |
20 | - {:id => 42, :name => "test repository", :description => "test description", :license => "GPL", :process_period => "1", :type => 'SUBVERSION', :address => 'https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator', :configuration_id => 31} | 20 | + {:id => "42", :name => "test repository", :description => "test description", :license => "GPL", :process_period => "1", :type => 'SUBVERSION', :address => "https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator", :configuration_id => "31"} |
21 | end | 21 | end |
22 | 22 | ||
23 | def self.types | 23 | def self.types |
plugins/mezuro/test/fixtures/stack_trace_element_fixtures.rb
1 | class StackTraceElementFixtures | 1 | class StackTraceElementFixtures |
2 | 2 | ||
3 | - def self.stack_trace_element(method_name = 'my method name', line_number = 42) | ||
4 | - Kalibro::StackTraceElement.new stack_trace_element_hash(method_name, line_number) | 3 | + def self.stack_trace_element |
4 | + Kalibro::StackTraceElement.new stack_trace_element_hash | ||
5 | end | 5 | end |
6 | 6 | ||
7 | - def self.stack_trace_element_hash(method_name = 'my method name', line_number = 42) | 7 | + def self.stack_trace_element_hash |
8 | { | 8 | { |
9 | :declaring_class => 'my.declaring.Class', | 9 | :declaring_class => 'my.declaring.Class', |
10 | - :method_name => method_name, | 10 | + :method_name => 'my method name', |
11 | :file_name => 'MyFile.java', | 11 | :file_name => 'MyFile.java', |
12 | - :line_number => line_number | 12 | + :line_number => '42' |
13 | } | 13 | } |
14 | end | 14 | end |
15 | 15 |
plugins/mezuro/test/fixtures/throwable_fixtures.rb
@@ -11,8 +11,7 @@ class ThrowableFixtures | @@ -11,8 +11,7 @@ class ThrowableFixtures | ||
11 | :target_string => 'Target String', | 11 | :target_string => 'Target String', |
12 | :message => 'Throwable message from ThrowableTest', | 12 | :message => 'Throwable message from ThrowableTest', |
13 | :stack_trace_element => [ | 13 | :stack_trace_element => [ |
14 | - StackTraceElementFixtures.stack_trace_element_hash('my method 1', 42), | ||
15 | - StackTraceElementFixtures.stack_trace_element_hash('my method 2', 84) | 14 | + StackTraceElementFixtures.stack_trace_element_hash, StackTraceElementFixtures.stack_trace_element_hash |
16 | ] | 15 | ] |
17 | } | 16 | } |
18 | end | 17 | end |
plugins/mezuro/test/functional/profile/mezuro_plugin_module_result_controller_test.rb
@@ -21,24 +21,24 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase | @@ -21,24 +21,24 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase | ||
21 | 21 | ||
22 | should 'find module result on kalibro' do | 22 | should 'find module result on kalibro' do |
23 | parent_module_result = ModuleResultFixtures.parent_module_result_hash | 23 | parent_module_result = ModuleResultFixtures.parent_module_result_hash |
24 | - Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:id] }). | 24 | + Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:id].to_i }). |
25 | returns({:module_result => @module_result_hash}) | 25 | returns({:module_result => @module_result_hash}) |
26 | - Kalibro::MetricResult.expects(:request).with(:metric_results_of, { :module_result_id => @module_result_hash[:id] }). | 26 | + Kalibro::MetricResult.expects(:request).with(:metric_results_of, { :module_result_id => @module_result_hash[:id].to_i }). |
27 | returns({:metric_result => @metric_result_hash}) | 27 | returns({:metric_result => @metric_result_hash}) |
28 | - Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:parent_id] }). | 28 | + Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:parent_id].to_i }). |
29 | returns({:module_result => parent_module_result}) | 29 | returns({:module_result => parent_module_result}) |
30 | - Kalibro::ModuleResult.expects(:request).with(:children_of, {:module_result_id => @module_result_hash[:id]}). | 30 | + Kalibro::ModuleResult.expects(:request).with(:children_of, {:module_result_id => @module_result_hash[:id].to_i}). |
31 | returns({:module_result => nil}) | 31 | returns({:module_result => nil}) |
32 | get :module_result, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] | 32 | get :module_result, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] |
33 | - assert_equal @module_result_hash[:grade], assigns(:module_result).grade | ||
34 | - assert_equal @metric_result_hash[:value], assigns(:metric_results).first.value | 33 | + assert_equal @module_result_hash[:grade].to_f, assigns(:module_result).grade |
34 | + assert_equal @metric_result_hash[:value].to_f, assigns(:metric_results).first.value | ||
35 | assert_response 200 | 35 | assert_response 200 |
36 | #TODO assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') | 36 | #TODO assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') |
37 | end | 37 | end |
38 | 38 | ||
39 | should 'get metric result history' do | 39 | should 'get metric result history' do |
40 | metric_name = @metric_result_hash[:configuration][:metric][:name] | 40 | metric_name = @metric_result_hash[:configuration][:metric][:name] |
41 | - Kalibro::MetricResult.expects(:request).with(:history_of, { :metric_name => metric_name, :module_result_id => @module_result_hash[:id] }). | 41 | + Kalibro::MetricResult.expects(:request).with(:history_of_metric, { :metric_name => metric_name, :module_result_id => @module_result_hash[:id].to_i }). |
42 | returns({:date_metric_result => @date_metric_result_hash}) | 42 | returns({:date_metric_result => @date_metric_result_hash}) |
43 | get :metric_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id], :metric_name => metric_name | 43 | get :metric_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id], :metric_name => metric_name |
44 | assert_equal DateTime.parse(@date_metric_result_hash[:date]), assigns(:history).first.date | 44 | assert_equal DateTime.parse(@date_metric_result_hash[:date]), assigns(:history).first.date |
@@ -47,7 +47,7 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase | @@ -47,7 +47,7 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase | ||
47 | end | 47 | end |
48 | 48 | ||
49 | should 'get module result history' do | 49 | should 'get module result history' do |
50 | - Kalibro::ModuleResult.expects(:request).with(:history_of_module, { :module_result_id => @module_result_hash[:id] }). | 50 | + Kalibro::ModuleResult.expects(:request).with(:history_of_module, { :module_result_id => @module_result_hash[:id].to_i }). |
51 | returns({:date_module_result => @date_module_result_hash}) | 51 | returns({:date_module_result => @date_module_result_hash}) |
52 | get :module_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] | 52 | get :module_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] |
53 | assert_equal DateTime.parse(@date_module_result_hash[:date]), assigns(:history).first.date | 53 | assert_equal DateTime.parse(@date_module_result_hash[:date]), assigns(:history).first.date |
plugins/mezuro/test/functional/profile/mezuro_plugin_processing_controller_test.rb
@@ -19,8 +19,15 @@ class MezuroPluginProcessingControllerTest < ActionController::TestCase | @@ -19,8 +19,15 @@ class MezuroPluginProcessingControllerTest < ActionController::TestCase | ||
19 | end | 19 | end |
20 | 20 | ||
21 | should 'render last processing state' do | 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 | assert_response 200 | 31 | assert_response 200 |
25 | assert_equal @processing.state, @response.body | 32 | assert_equal @processing.state, @response.body |
26 | end | 33 | end |
plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb
@@ -31,8 +31,10 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | @@ -31,8 +31,10 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | ||
31 | 31 | ||
32 | get :new, :profile => @profile.identifier, :id => @content.id | 32 | get :new, :profile => @profile.identifier, :id => @content.id |
33 | 33 | ||
34 | - assert_equal @content, assigns(:project_content) | 34 | + assert_equal @content.id, assigns(:project_content_id) |
35 | + assert_equal @content.name, assigns(:project_name) | ||
35 | assert_equal @repository_types, assigns(:repository_types) | 36 | assert_equal @repository_types, assigns(:repository_types) |
37 | + assert_equal @content.profile.identifier, assigns(:data_profile) | ||
36 | assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first | 38 | assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first |
37 | assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last | 39 | assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last |
38 | end | 40 | end |
@@ -40,6 +42,7 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | @@ -40,6 +42,7 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | ||
40 | should 'create a repository' do | 42 | should 'create a repository' do |
41 | Kalibro::Repository.expects(:new).returns(@repository) | 43 | Kalibro::Repository.expects(:new).returns(@repository) |
42 | @repository.expects(:save).with(@content.project_id).returns(true) | 44 | @repository.expects(:save).with(@content.project_id).returns(true) |
45 | + @repository.expects(:process) | ||
43 | get :create, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash | 46 | get :create, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash |
44 | assert @repository.errors.empty? | 47 | assert @repository.errors.empty? |
45 | assert_response :redirect | 48 | assert_response :redirect |
@@ -62,8 +65,10 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | @@ -62,8 +65,10 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | ||
62 | 65 | ||
63 | get :edit, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id | 66 | get :edit, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id |
64 | 67 | ||
65 | - assert_equal @content, assigns(:project_content) | 68 | + assert_equal @content.id, assigns(:project_content_id) |
69 | + assert_equal @content.name, assigns(:project_name) | ||
66 | assert_equal @repository_types, assigns(:repository_types) | 70 | assert_equal @repository_types, assigns(:repository_types) |
71 | + assert_equal @content.profile.identifier, assigns(:data_profile) | ||
67 | assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first | 72 | assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first |
68 | assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last | 73 | assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last |
69 | assert_equal @repository, assigns(:repository) | 74 | assert_equal @repository, assigns(:repository) |
@@ -72,6 +77,7 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | @@ -72,6 +77,7 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | ||
72 | should 'update a repository' do | 77 | should 'update a repository' do |
73 | Kalibro::Repository.expects(:new).returns(@repository) | 78 | Kalibro::Repository.expects(:new).returns(@repository) |
74 | @repository.expects(:save).with(@content.project_id).returns(true) | 79 | @repository.expects(:save).with(@content.project_id).returns(true) |
80 | + Kalibro::Repository.expects(:request).with(:process_repository, {:repository_id => @repository.id}) | ||
75 | get :update, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash | 81 | get :update, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash |
76 | assert @repository.errors.empty? | 82 | assert @repository.errors.empty? |
77 | assert_response :redirect | 83 | assert_response :redirect |
@@ -91,6 +97,7 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | @@ -91,6 +97,7 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | ||
91 | Kalibro::Configuration.expects(:configuration_of).with(@repository.id).returns(@configuration) | 97 | Kalibro::Configuration.expects(:configuration_of).with(@repository.id).returns(@configuration) |
92 | 98 | ||
93 | get :show, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id | 99 | get :show, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id |
100 | + | ||
94 | assert_equal @content.name, assigns(:project_name) | 101 | assert_equal @content.name, assigns(:project_name) |
95 | assert_equal @repository, assigns(:repository) | 102 | assert_equal @repository, assigns(:repository) |
96 | assert_equal @configuration.name, assigns(:configuration_name) | 103 | assert_equal @configuration.name, assigns(:configuration_name) |
plugins/mezuro/test/unit/kalibro/date_metric_result_test.rb
@@ -10,7 +10,7 @@ class DateMetricResultTest < ActiveSupport::TestCase | @@ -10,7 +10,7 @@ class DateMetricResultTest < ActiveSupport::TestCase | ||
10 | end | 10 | end |
11 | 11 | ||
12 | should 'create date_metric_result from hash' do | 12 | should 'create date_metric_result from hash' do |
13 | - assert_equal @hash[:metric_result][:id], Kalibro::DateMetricResult.new(@hash).metric_result.id | 13 | + assert_equal @hash[:metric_result][:id].to_i, Kalibro::DateMetricResult.new(@hash).metric_result.id |
14 | end | 14 | end |
15 | 15 | ||
16 | should 'convert date_metric_result to hash' do | 16 | should 'convert date_metric_result to hash' do |
plugins/mezuro/test/unit/kalibro/date_module_result_test.rb
@@ -10,7 +10,7 @@ class DateModuleResultTest < ActiveSupport::TestCase | @@ -10,7 +10,7 @@ class DateModuleResultTest < ActiveSupport::TestCase | ||
10 | end | 10 | end |
11 | 11 | ||
12 | should 'create date_module_result from hash' do | 12 | should 'create date_module_result from hash' do |
13 | - assert_equal @hash[:module_result][:id], Kalibro::DateModuleResult.new(@hash).module_result.id | 13 | + assert_equal @hash[:module_result][:id].to_i, Kalibro::DateModuleResult.new(@hash).module_result.id |
14 | end | 14 | end |
15 | 15 | ||
16 | should 'convert date_module_result to hash' do | 16 | should 'convert date_module_result to hash' do |
plugins/mezuro/test/unit/kalibro/metric_configuration_snapshot_test.rb
@@ -6,15 +6,19 @@ class MetricConfigurationSnapshotTest < ActiveSupport::TestCase | @@ -6,15 +6,19 @@ class MetricConfigurationSnapshotTest < ActiveSupport::TestCase | ||
6 | 6 | ||
7 | def setup | 7 | def setup |
8 | @hash = MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_hash | 8 | @hash = MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_hash |
9 | + @hash2 = MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_hash_with_2_elements | ||
9 | @metric_configuration_snapshot = MetricConfigurationSnapshotFixtures.metric_configuration_snapshot | 10 | @metric_configuration_snapshot = MetricConfigurationSnapshotFixtures.metric_configuration_snapshot |
11 | + @metric_configuration_snapshot2 = MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_with_2_elements | ||
10 | end | 12 | end |
11 | 13 | ||
12 | - should 'create metric configuration snapshot from hash' do | 14 | + should 'create and convert metric configuration snapshot from hash' do |
13 | assert_equal @hash[:code], Kalibro::MetricConfigurationSnapshot.new(@hash).code | 15 | assert_equal @hash[:code], Kalibro::MetricConfigurationSnapshot.new(@hash).code |
16 | + assert_equal @hash[:weight].to_f, @metric_configuration_snapshot.weight | ||
14 | end | 17 | end |
15 | 18 | ||
16 | - should 'convert metric configuration snapshot to hash' do | ||
17 | - assert_equal @hash, @metric_configuration_snapshot.to_hash | 19 | + should 'create and convert metric configuration snapshot from hash with 2 elements' do |
20 | + assert_equal @hash2[:code], Kalibro::MetricConfigurationSnapshot.new(@hash2).code | ||
21 | + assert_equal @hash2, @metric_configuration_snapshot2.to_hash | ||
18 | end | 22 | end |
19 | 23 | ||
20 | end | 24 | end |
plugins/mezuro/test/unit/kalibro/metric_result_test.rb
@@ -12,7 +12,18 @@ class MetricResultTest < ActiveSupport::TestCase | @@ -12,7 +12,18 @@ class MetricResultTest < ActiveSupport::TestCase | ||
12 | end | 12 | end |
13 | 13 | ||
14 | should 'create metric result from hash' do | 14 | should 'create metric result from hash' do |
15 | - assert_equal @native_hash[:configuration][:code], Kalibro::MetricResult.new(@native_hash).configuration.code | 15 | + metric_result = Kalibro::MetricResult.new(@native_hash) |
16 | + assert_equal @native_hash[:configuration][:code], metric_result.configuration.code | ||
17 | + assert_equal @native_hash[:id].to_i, metric_result.id | ||
18 | + assert_equal @native_hash[:value].to_f, metric_result.value | ||
19 | + end | ||
20 | + | ||
21 | + should 'create metric result with aggregated value from hash' do | ||
22 | + hash = @native_hash | ||
23 | + hash[:aggregated_value] = "2.0" | ||
24 | + hash[:value] = "NaN" | ||
25 | + metric_result = Kalibro::MetricResult.new(hash) | ||
26 | + assert_equal @native_hash[:aggregated_value].to_f, metric_result.value | ||
16 | end | 27 | end |
17 | 28 | ||
18 | should 'convert metric result to hash' do | 29 | should 'convert metric result to hash' do |
@@ -28,13 +39,13 @@ class MetricResultTest < ActiveSupport::TestCase | @@ -28,13 +39,13 @@ class MetricResultTest < ActiveSupport::TestCase | ||
28 | should 'return metric results of a module result' do | 39 | should 'return metric results of a module result' do |
29 | id = 31 | 40 | id = 31 |
30 | Kalibro::MetricResult.expects(:request).with(:metric_results_of, {:module_result_id => id}).returns(:metric_result => [@native_hash, @compound_hash]) | 41 | Kalibro::MetricResult.expects(:request).with(:metric_results_of, {:module_result_id => id}).returns(:metric_result => [@native_hash, @compound_hash]) |
31 | - assert_equal @native_hash[:id], Kalibro::MetricResult.metric_results_of(id).first.id | 42 | + assert_equal @native_hash[:id].to_i, Kalibro::MetricResult.metric_results_of(id).first.id |
32 | end | 43 | end |
33 | 44 | ||
34 | should 'return history of a metric with a module result id' do | 45 | should 'return history of a metric with a module result id' do |
35 | module_result_id = 31 | 46 | module_result_id = 31 |
36 | - Kalibro::MetricResult.expects(:request).with(:history_of, {:metric_name => @result.configuration.metric.name, :module_result_id => module_result_id}).returns({:date_metric_result => DateMetricResultFixtures.date_metric_result_hash}) | ||
37 | - assert_equal DateMetricResultFixtures.date_metric_result_hash[:metric_result][:id], Kalibro::MetricResult.history_of(@result.configuration.metric.name, module_result_id).first.metric_result.id | 47 | + Kalibro::MetricResult.expects(:request).with(:history_of_metric, {:metric_name => @result.configuration.metric.name, :module_result_id => module_result_id}).returns({:date_metric_result => DateMetricResultFixtures.date_metric_result_hash}) |
48 | + assert_equal DateMetricResultFixtures.date_metric_result_hash[:metric_result][:id].to_i, Kalibro::MetricResult.history_of(@result.configuration.metric.name, module_result_id).first.metric_result.id | ||
38 | end | 49 | end |
39 | 50 | ||
40 | end | 51 | end |
plugins/mezuro/test/unit/kalibro/module_result_test.rb
@@ -11,7 +11,10 @@ class ModuleResultTest < ActiveSupport::TestCase | @@ -11,7 +11,10 @@ class ModuleResultTest < ActiveSupport::TestCase | ||
11 | end | 11 | end |
12 | 12 | ||
13 | should 'create module result' do | 13 | should 'create module result' do |
14 | - assert_equal @hash[:id] , Kalibro::ModuleResult.new(@hash).id | 14 | + module_result = Kalibro::ModuleResult.new(@hash) |
15 | + assert_equal @hash[:id].to_i , module_result.id | ||
16 | + assert_equal @hash[:grade].to_f , module_result.grade | ||
17 | + assert_equal @hash[:parent_id].to_i , module_result.parent_id | ||
15 | end | 18 | end |
16 | 19 | ||
17 | should 'convert module result to hash' do | 20 | should 'convert module result to hash' do |
@@ -41,7 +44,7 @@ class ModuleResultTest < ActiveSupport::TestCase | @@ -41,7 +44,7 @@ class ModuleResultTest < ActiveSupport::TestCase | ||
41 | 44 | ||
42 | should 'return history of a module result' do | 45 | should 'return history of a module result' do |
43 | Kalibro::ModuleResult.expects(:request).with(:history_of_module, {:module_result_id => @module_result.id}).returns({:date_module_result => [DateModuleResultFixtures.date_module_result_hash]}) | 46 | Kalibro::ModuleResult.expects(:request).with(:history_of_module, {:module_result_id => @module_result.id}).returns({:date_module_result => [DateModuleResultFixtures.date_module_result_hash]}) |
44 | - assert_equal DateModuleResultFixtures.date_module_result_hash[:module_result][:id], Kalibro::ModuleResult.history_of(@module_result.id).first.module_result.id | 47 | + assert_equal DateModuleResultFixtures.date_module_result_hash[:module_result][:id].to_i, Kalibro::ModuleResult.history_of(@module_result.id).first.module_result.id |
45 | end | 48 | end |
46 | 49 | ||
47 | end | 50 | end |
plugins/mezuro/test/unit/kalibro/process_time_test.rb
@@ -11,10 +11,15 @@ class ProcessTimeTest < ActiveSupport::TestCase | @@ -11,10 +11,15 @@ class ProcessTimeTest < ActiveSupport::TestCase | ||
11 | 11 | ||
12 | should 'create process time from hash' do | 12 | should 'create process time from hash' do |
13 | assert_equal @hash[:state], Kalibro::ProcessTime.new(@hash).state | 13 | assert_equal @hash[:state], Kalibro::ProcessTime.new(@hash).state |
14 | + assert_equal @hash[:time].to_i, Kalibro::ProcessTime.new(@hash).time | ||
14 | end | 15 | end |
15 | 16 | ||
16 | should 'convert process time to hash' do | 17 | should 'convert process time to hash' do |
17 | assert_equal @hash, @process_time.to_hash | 18 | assert_equal @hash, @process_time.to_hash |
18 | end | 19 | end |
19 | 20 | ||
21 | + should 'get time as an integer' do | ||
22 | + assert_equal 1.class, @process_time.time.class | ||
23 | + end | ||
24 | + | ||
20 | end | 25 | end |
plugins/mezuro/test/unit/kalibro/processing_test.rb
1 | require "test_helper" | 1 | require "test_helper" |
2 | 2 | ||
3 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/processing_fixtures" | 3 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/processing_fixtures" |
4 | -#TODO arrumar os testes de unidade | ||
5 | class ProcessingTest < ActiveSupport::TestCase | 4 | class ProcessingTest < ActiveSupport::TestCase |
6 | 5 | ||
7 | def setup | 6 | def setup |
@@ -11,12 +10,14 @@ class ProcessingTest < ActiveSupport::TestCase | @@ -11,12 +10,14 @@ class ProcessingTest < ActiveSupport::TestCase | ||
11 | @repository_id = 31 | 10 | @repository_id = 31 |
12 | end | 11 | end |
13 | 12 | ||
14 | - should 'create project result from hash' do | ||
15 | - assert_equal @hash[:results_root_id], Kalibro::Processing.new(@hash).results_root_id | ||
16 | - assert_equal @hash[:process_time].first[:state], Kalibro::Processing.new(@hash).process_times.first.state | 13 | + should 'create processing from hash' do |
14 | + processing = Kalibro::Processing.new(@hash) | ||
15 | + assert_equal @hash[:results_root_id].to_i, processing.results_root_id | ||
16 | + assert_equal @hash[:process_time].first[:state], processing.process_times.first.state | ||
17 | + assert_equal @hash[:id].to_i, processing.id | ||
17 | end | 18 | end |
18 | 19 | ||
19 | - should 'convert project result to hash' do | 20 | + should 'convert processing to hash' do |
20 | assert_equal @hash, @processing.to_hash | 21 | assert_equal @hash, @processing.to_hash |
21 | end | 22 | end |
22 | 23 | ||
@@ -94,56 +95,4 @@ class ProcessingTest < ActiveSupport::TestCase | @@ -94,56 +95,4 @@ class ProcessingTest < ActiveSupport::TestCase | ||
94 | assert_equal @processing.id, Kalibro::Processing.last_processing_before(@repository_id, @processing.date).id | 95 | assert_equal @processing.id, Kalibro::Processing.last_processing_before(@repository_id, @processing.date).id |
95 | end | 96 | end |
96 | 97 | ||
97 | -=begin | ||
98 | - should 'get processing of a repository' do | ||
99 | - Kalibro::Processing.expects(:has_ready_processing).with(@repository.id).returns(true) | ||
100 | - Kalibro::Processing.expects(:last_ready_processing_of).with(@repository.id).returns(@processing) | ||
101 | - assert_equal @processing, @project_content.processing(@repository.id) | ||
102 | - end | ||
103 | - | ||
104 | - should 'get not ready processing of a repository' do | ||
105 | - Kalibro::Processing.expects(:has_ready_processing).with(@repository.id).returns(false) | ||
106 | - Kalibro::Processing.expects(:last_processing_of).with(@repository.id).returns(@processing) | ||
107 | - assert_equal @processing, @project_content.processing(@repository.id) | ||
108 | - end | ||
109 | - | ||
110 | - should 'get processing of a repository after date' do | ||
111 | - Kalibro::Processing.expects(:has_processing_after).with(@repository.id, @date).returns(true) | ||
112 | - Kalibro::Processing.expects(:first_processing_after).with(@repository.id, @date).returns(@processing) | ||
113 | - assert_equal @processing, @project_content.processing_with_date(@repository.id, @date) | ||
114 | - end | ||
115 | - | ||
116 | - should 'get processing of a repository before date' do | ||
117 | - Kalibro::Processing.expects(:has_processing_after).with(@repository.id, @date).returns(false) | ||
118 | - Kalibro::Processing.expects(:has_processing_before).with(@repository.id, @date).returns(true) | ||
119 | - Kalibro::Processing.expects(:last_processing_before).with(@repository.id, @date).returns(@processing) | ||
120 | - assert_equal @processing, @project_content.processing_with_date(@repository.id, @date) | ||
121 | - end | ||
122 | - | ||
123 | - should 'get module result' do | ||
124 | - @project_content.expects(:processing).with(@repository.id).returns(@processing) | ||
125 | - Kalibro::ModuleResult.expects(:find).with(@processing.results_root_id).returns(@module_result) | ||
126 | - assert_equal @module_result, @project_content.module_result(@repository.id) | ||
127 | - | ||
128 | - end | ||
129 | - | ||
130 | - should 'get module result with date' do | ||
131 | - @project_content.expects(:processing_with_date).with(@repository.id,@date.to_s).returns(@processing) | ||
132 | - Kalibro::ModuleResult.expects(:find).with(@processing.results_root_id).returns(@module_result) | ||
133 | - assert_equal @module_result, @project_content.module_result(@repository.id, @date.to_s) | ||
134 | - end | ||
135 | - | ||
136 | - should 'get result history' do | ||
137 | - Kalibro::MetricResult.expects(:history_of).with(@module_result.id).returns([@date_metric_result]) | ||
138 | - assert_equal [@date_metric_result], @project_content.result_history(@module_result.id) | ||
139 | - end | ||
140 | - | ||
141 | - should 'add error to base when the module_result does not exist' do | ||
142 | - Kalibro::MetricResult.expects(:history_of).with(@module_result.id).raises(Kalibro::Errors::RecordNotFound) | ||
143 | - assert_nil @project_content.errors[:base] | ||
144 | - @project_content.result_history(@module_result.id) | ||
145 | - assert_not_nil @project_content.errors[:base] | ||
146 | - end | ||
147 | -=end | ||
148 | - | ||
149 | end | 98 | end |
plugins/mezuro/test/unit/kalibro/project_test.rb
@@ -13,6 +13,7 @@ class ProjectTest < ActiveSupport::TestCase | @@ -13,6 +13,7 @@ class ProjectTest < ActiveSupport::TestCase | ||
13 | should 'initialize new project from hash' do | 13 | should 'initialize new project from hash' do |
14 | project = Kalibro::Project.new @hash | 14 | project = Kalibro::Project.new @hash |
15 | assert_equal @hash[:name], project.name | 15 | assert_equal @hash[:name], project.name |
16 | + assert_equal @hash[:id].to_i, project.id | ||
16 | end | 17 | end |
17 | 18 | ||
18 | should 'convert project to hash' do | 19 | should 'convert project to hash' do |
plugins/mezuro/test/unit/kalibro/range_snapshot_test.rb
@@ -6,11 +6,23 @@ class RangeSnapshotTest < ActiveSupport::TestCase | @@ -6,11 +6,23 @@ class RangeSnapshotTest < ActiveSupport::TestCase | ||
6 | 6 | ||
7 | def setup | 7 | def setup |
8 | @hash = RangeSnapshotFixtures.range_snapshot_hash | 8 | @hash = RangeSnapshotFixtures.range_snapshot_hash |
9 | + @range_snapshot_with_infinite_range_hash = RangeSnapshotFixtures.range_snapshot_with_infinite_range_hash | ||
9 | @range_snapshot = RangeSnapshotFixtures.range_snapshot | 10 | @range_snapshot = RangeSnapshotFixtures.range_snapshot |
11 | + @range_snapshot_with_infinite_range = RangeSnapshotFixtures.range_snapshot_with_infinite_range | ||
10 | end | 12 | end |
11 | 13 | ||
12 | should 'create range_snapshot from hash' do | 14 | should 'create range_snapshot from hash' do |
13 | - assert_equal @hash[:comments], Kalibro::RangeSnapshot.new(@hash).comments | 15 | + range_snapshot = Kalibro::RangeSnapshot.new(@hash) |
16 | + assert_equal @hash[:comments], range_snapshot.comments | ||
17 | + assert_equal @hash[:beginning].to_f, range_snapshot.beginning | ||
18 | + assert_equal @hash[:end].to_f, range_snapshot.end | ||
19 | + assert_equal @hash[:grade].to_f, range_snapshot.grade | ||
20 | + end | ||
21 | + | ||
22 | + should 'create range_snapshot from hash with infinity values' do | ||
23 | + range_snapshot = Kalibro::RangeSnapshot.new(@range_snapshot_with_infinite_range_hash) | ||
24 | + assert_equal -1.0/0, range_snapshot.beginning | ||
25 | + assert_equal 1.0/0, range_snapshot.end | ||
14 | end | 26 | end |
15 | 27 | ||
16 | should 'convert range_snapshot to hash' do | 28 | should 'convert range_snapshot to hash' do |
plugins/mezuro/test/unit/kalibro/repository_test.rb
@@ -11,7 +11,11 @@ class RepositoryTest < ActiveSupport::TestCase | @@ -11,7 +11,11 @@ class RepositoryTest < ActiveSupport::TestCase | ||
11 | end | 11 | end |
12 | 12 | ||
13 | should 'new repository from hash' do | 13 | should 'new repository from hash' do |
14 | - assert_equal @repository.type, Kalibro::Repository.new(@hash).type | 14 | + repository = Kalibro::Repository.new(@hash) |
15 | + assert_equal @hash[:type], repository.type | ||
16 | + assert_equal @hash[:id].to_i, repository.id | ||
17 | + assert_equal @hash[:process_period].to_i, repository.process_period | ||
18 | + assert_equal @hash[:configuration_id].to_i, repository.configuration_id | ||
15 | end | 19 | end |
16 | 20 | ||
17 | should 'convert repository to hash' do | 21 | should 'convert repository to hash' do |
@@ -40,7 +44,6 @@ class RepositoryTest < ActiveSupport::TestCase | @@ -40,7 +44,6 @@ class RepositoryTest < ActiveSupport::TestCase | ||
40 | id_from_kalibro = 1 | 44 | id_from_kalibro = 1 |
41 | project_id = 56 | 45 | 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) | 46 | 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) | 47 | assert @created_repository.save(project_id) |
45 | assert_equal id_from_kalibro, @created_repository.id | 48 | assert_equal id_from_kalibro, @created_repository.id |
46 | end | 49 | end |
@@ -59,7 +62,7 @@ class RepositoryTest < ActiveSupport::TestCase | @@ -59,7 +62,7 @@ class RepositoryTest < ActiveSupport::TestCase | ||
59 | 62 | ||
60 | should 'process repository' do | 63 | should 'process repository' do |
61 | Kalibro::Repository.expects(:request).with(:process_repository, {:repository_id => @repository.id}); | 64 | Kalibro::Repository.expects(:request).with(:process_repository, {:repository_id => @repository.id}); |
62 | - @repository.process_repository | 65 | + @repository.process |
63 | end | 66 | end |
64 | 67 | ||
65 | should 'cancel processing of a repository' do | 68 | should 'cancel processing of a repository' do |
plugins/mezuro/test/unit/mezuro_plugin/helpers/content_viewer_helper_test.rb
1 | require "test_helper" | 1 | require "test_helper" |
2 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures" | 2 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures" |
3 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/date_metric_result_fixtures" | ||
3 | 4 | ||
4 | class ContentViewerHelperTest < ActiveSupport::TestCase | 5 | class ContentViewerHelperTest < ActiveSupport::TestCase |
5 | 6 | ||
7 | + def setup | ||
8 | + @helper = MezuroPlugin::Helpers::ContentViewerHelper | ||
9 | + end | ||
10 | + | ||
6 | should 'get the number rounded by two decimal points' do | 11 | should 'get the number rounded by two decimal points' do |
7 | - assert_equal '4.22', MezuroPlugin::Helpers::ContentViewerHelper.format_grade('4.22344') | ||
8 | - assert_equal '4.10', MezuroPlugin::Helpers::ContentViewerHelper.format_grade('4.1') | ||
9 | - assert_equal '4.00', MezuroPlugin::Helpers::ContentViewerHelper.format_grade('4') | 12 | + assert_equal '4.22', @helper.format_grade('4.22344') |
13 | + assert_equal '4.10', @helper.format_grade('4.1') | ||
14 | + assert_equal '4.00', @helper.format_grade('4') | ||
10 | end | 15 | end |
11 | 16 | ||
12 | should 'create the periodicity options array' do | 17 | should 'create the periodicity options array' do |
13 | - assert_equal [["Not Periodically", 0], ["1 day", 1], ["2 days", 2], ["Weekly", 7], ["Biweeky", 15], ["Monthly", 30]], MezuroPlugin::Helpers::ContentViewerHelper.periodicity_options | 18 | + assert_equal [["Not Periodically", 0], ["1 day", 1], ["2 days", 2], ["Weekly", 7], ["Biweekly", 15], ["Monthly", 30]], @helper.periodicity_options |
19 | + end | ||
20 | + | ||
21 | + should 'return the correct string for a given periodicity' do | ||
22 | + assert_equal "Not Periodically", @helper.periodicity_option(0) | ||
23 | + assert_equal "1 day", @helper.periodicity_option(1) | ||
24 | + assert_equal "2 days", @helper.periodicity_option(2) | ||
25 | + assert_equal "Weekly", @helper.periodicity_option(7) | ||
26 | + assert_equal "Biweekly", @helper.periodicity_option(15) | ||
27 | + assert_equal "Monthly", @helper.periodicity_option(30) | ||
28 | + end | ||
29 | + | ||
30 | + should 'create the license options array' do | ||
31 | + options = YAML.load_file("#{RAILS_ROOT}/plugins/mezuro/licenses.yml") | ||
32 | + options = options.split(";") | ||
33 | + formated_options = [] | ||
34 | + options.each { |option| formated_options << [option, option] } | ||
35 | + assert_equal formated_options, @helper.license_options | ||
14 | end | 36 | end |
15 | 37 | ||
38 | + should 'generate chart from metric result history' do | ||
39 | + chart = "http://chart.apis.google.com/chart?chxt=y,x&chco=c4a000&chf=bg,ls,90,efefef,0.2,ffffff,0.2&chd=s:A9&chl=2011-10-20T18%3A26%3A43%2B00%3A00|2011-10-25T18%3A26%3A43%2B00%3A00&cht=lc&chs=600x180&chxr=0,0.0,5.0" | ||
40 | + metric_history = DateMetricResultFixtures.score_history | ||
41 | + | ||
42 | + assert_equal chart, @helper.generate_chart(metric_history) | ||
43 | + end | ||
44 | + | ||
45 | + should 'format time to show a sentence' do | ||
46 | + assert_equal 'less than 5 seconds', @helper.format_time(0) | ||
47 | + assert_equal 'less than 5 seconds', @helper.format_time(4999) | ||
48 | + assert_equal 'less than 10 seconds', @helper.format_time(5000) | ||
49 | + assert_equal '1 minute', @helper.format_time(70000) | ||
50 | + assert_equal 'about 2 hours', @helper.format_time(7000000) | ||
51 | + end | ||
52 | + | ||
16 | should 'format metric name for metric configuration snapshot' do | 53 | should 'format metric name for metric configuration snapshot' do |
17 | metric_configuration_snapshot = MetricConfigurationSnapshotFixtures.metric_configuration_snapshot | 54 | metric_configuration_snapshot = MetricConfigurationSnapshotFixtures.metric_configuration_snapshot |
18 | - assert_equal 'AverageMethodLOC', MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_configuration_snapshot) | 55 | + assert_equal 'AverageMethodLOC', @helper.format_name(metric_configuration_snapshot) |
19 | end | 56 | end |
20 | 57 | ||
21 | end | 58 | end |
plugins/mezuro/test/unit/mezuro_plugin/helpers/module_result_helper_test.rb
0 → 100644
@@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
1 | +require "test_helper" | ||
2 | + | ||
3 | +class ModuleResultHelperTest < ActiveSupport::TestCase | ||
4 | + | ||
5 | + should 'return last module name when receive a string' do | ||
6 | + name = 'Class' | ||
7 | + assert_equal name, MezuroPlugin::Helpers::ModuleResultHelper.module_name(name) | ||
8 | + end | ||
9 | + | ||
10 | + should 'return last module name when receive an array of strings' do | ||
11 | + name = ['Class', 'Module'] | ||
12 | + assert_equal name.last, MezuroPlugin::Helpers::ModuleResultHelper.module_name(name) | ||
13 | + end | ||
14 | + | ||
15 | +end |
plugins/mezuro/views/mezuro_plugin_module_result/_metric_results.rhtml
@@ -9,19 +9,22 @@ | @@ -9,19 +9,22 @@ | ||
9 | <tbody> | 9 | <tbody> |
10 | <% @metric_results.each do |metric_result| %> | 10 | <% @metric_results.each do |metric_result| %> |
11 | <% metric_configuration_snapshot = metric_result.metric_configuration_snapshot%> | 11 | <% metric_configuration_snapshot = metric_result.metric_configuration_snapshot%> |
12 | - <% range_snapshot = metric_configuration_snapshot.range_snapshot %> | ||
13 | - <% formatted_name = MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_configuration_snapshot) %> | ||
14 | - <% if !range_snapshot.nil? %> | 12 | + <% range_snapshots = metric_configuration_snapshot.range_snapshot %> |
13 | + <% metric_name = metric_configuration_snapshot.metric.name %> | ||
14 | + <% formatted_name = metric_name.delete("() ") %> | ||
15 | + <% if !range_snapshots.nil? %> | ||
15 | <tr> | 16 | <tr> |
16 | - <td style="width: 74%"><a href="#" show-metric-history="<%= formatted_name %>" data-module-id="<%= @module_result_id %>"><%= metric_configuration_snapshot.metric.name %></a></td> | 17 | + <td style="width: 74%"><a href="#" show-metric-history="<%= formatted_name %>" data-metric-name="<%= metric_name %>" data-module-id="<%= @module_result.id %>"><%= metric_name %></a></td> |
17 | <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %></td> | 18 | <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %></td> |
18 | <td><%= metric_configuration_snapshot.weight %></td> | 19 | <td><%= metric_configuration_snapshot.weight %></td> |
20 | + <% range_snapshots.each do |range_snapshot| %> | ||
21 | + <% if range_snapshot.beginning <= metric_result.value and range_snapshot.end > metric_result.value %> | ||
19 | <td style="background-color: #<%= range_snapshot.color %>"> | 22 | <td style="background-color: #<%= range_snapshot.color %>"> |
20 | <span title="<%= range_snapshot.comments %>" > | 23 | <span title="<%= range_snapshot.comments %>" > |
21 | <%= range_snapshot.label %> | 24 | <%= range_snapshot.label %> |
22 | </span> | 25 | </span> |
23 | </td> | 26 | </td> |
24 | - </tr> | 27 | + </tr> |
25 | <tr class="<%= formatted_name %>" style="display: none;"> | 28 | <tr class="<%= formatted_name %>" style="display: none;"> |
26 | <td colspan="3"> | 29 | <td colspan="3"> |
27 | <div id='historical-<%= formatted_name %>'> | 30 | <div id='historical-<%= formatted_name %>'> |
@@ -29,8 +32,10 @@ | @@ -29,8 +32,10 @@ | ||
29 | </td> | 32 | </td> |
30 | <td align="right"> | 33 | <td align="right"> |
31 | <%= range_snapshot.comments.nil? ? '' : range_snapshot.comments %> | 34 | <%= range_snapshot.comments.nil? ? '' : range_snapshot.comments %> |
32 | - </td> | 35 | + </td> |
33 | </tr> | 36 | </tr> |
37 | + <% end %> | ||
38 | + <% end %> | ||
34 | <% end %> | 39 | <% end %> |
35 | <% end %> | 40 | <% end %> |
36 | </tbody> | 41 | </tbody> |
plugins/mezuro/views/mezuro_plugin_module_result/_module_result.rhtml
1 | -<% render :partial => "source_tree", :locals => {:module_result => @module_result} %> | ||
2 | -<h5><%= _('Metric results for: #{@module_result.module.name} (#{@module_result.module.granularity}) ') %> </h5> | 1 | +<%= render :partial => "source_tree", :locals => {:module_result => @module_result} %> |
2 | +<h5><%= _"Metric results for: #{@module_result.module.name} (#{@module_result.module.granularity})" %> </h5> | ||
3 | 3 | ||
4 | <hr/> | 4 | <hr/> |
5 | <div class="zoomable-image"> | 5 | <div class="zoomable-image"> |
plugins/mezuro/views/mezuro_plugin_module_result/_source_tree.rhtml
1 | <h4><%= _('Source tree') %></h4> | 1 | <h4><%= _('Source tree') %></h4> |
2 | -<% module_name = module_result.module.name %> | 2 | +<% helper = MezuroPlugin::Helpers::ModuleResultHelper %> |
3 | +<% module_name = helper.module_name(module_result.module.name) %> | ||
3 | <% module_label = "#{module_name} (#{module_result.module.granularity})" %> | 4 | <% module_label = "#{module_name} (#{module_result.module.granularity})" %> |
4 | 5 | ||
5 | <p> | 6 | <p> |
6 | <h2 class="path"> | 7 | <h2 class="path"> |
7 | <% module_result.parents.each do |parent| %> | 8 | <% module_result.parents.each do |parent| %> |
8 | /<a href="#" class="source-tree-link" data-module-id="<%= parent.id %>"> | 9 | /<a href="#" class="source-tree-link" data-module-id="<%= parent.id %>"> |
9 | - <%= parent.module.name %> | 10 | + <%= helper.module_name parent.module.name %> |
10 | </a> | 11 | </a> |
11 | - <% end %> | 12 | + <% end %>/ <%= helper.module_name module_name %> |
12 | </h2> | 13 | </h2> |
13 | </p> | 14 | </p> |
14 | 15 | ||
@@ -17,14 +18,14 @@ | @@ -17,14 +18,14 @@ | ||
17 | <% if child.module.granularity=='PACKAGE' %> | 18 | <% if child.module.granularity=='PACKAGE' %> |
18 | <tr> | 19 | <tr> |
19 | <td class="icon"><%= image_tag('/plugins/mezuro/images/folder.png')%></td> | 20 | <td class="icon"><%= image_tag('/plugins/mezuro/images/folder.png')%></td> |
20 | - <td class="source-tree-text"><a href='#' class="source-tree-link" data-module-id="<%= child.id %>"><%= child.module.name %></a></td> | 21 | + <td class="source-tree-text"><a href='#' class="source-tree-link" data-module-id="<%= child.id %>"><%= helper.module_name child.module.name %></a></td> |
21 | </tr> | 22 | </tr> |
22 | <% else %> | 23 | <% else %> |
23 | <tr> | 24 | <tr> |
24 | <td class="icon"><%= image_tag('/plugins/mezuro/images/file.png') %></td> | 25 | <td class="icon"><%= image_tag('/plugins/mezuro/images/file.png') %></td> |
25 | <td class="source-tree-text"> | 26 | <td class="source-tree-text"> |
26 | <a href='#' class="source-tree-link" data-module-id="<%= child.id %>"> | 27 | <a href='#' class="source-tree-link" data-module-id="<%= child.id %>"> |
27 | - <%= child.module.name %> | 28 | + <%= helper.module_name child.module.name %> |
28 | </a> | 29 | </a> |
29 | </td> | 30 | </td> |
30 | </tr> | 31 | </tr> |
plugins/mezuro/views/mezuro_plugin_processing/_processing.rhtml
@@ -5,12 +5,12 @@ | @@ -5,12 +5,12 @@ | ||
5 | <table> | 5 | <table> |
6 | <tr> | 6 | <tr> |
7 | <td><%= _('Date') %></td> | 7 | <td><%= _('Date') %></td> |
8 | - <td><%= @processing.date %></td> | 8 | + <td><%= @processing.date.inspect %></td> |
9 | </tr> | 9 | </tr> |
10 | <% @processing.process_time.each do |process_time| %> | 10 | <% @processing.process_time.each do |process_time| %> |
11 | <tr> | 11 | <tr> |
12 | <td><%= _(process_time.state + ' time') %></td> | 12 | <td><%= _(process_time.state + ' time') %></td> |
13 | - <td><%= process_time.time %></td> | 13 | + <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_time(process_time.time) %></td> |
14 | </tr> | 14 | </tr> |
15 | <% end %> | 15 | <% end %> |
16 | <tr> | 16 | <tr> |
@@ -25,10 +25,12 @@ | @@ -25,10 +25,12 @@ | ||
25 | jQuery(document).ready(function($) { | 25 | jQuery(document).ready(function($) { |
26 | $("#datepicker").datepicker({ | 26 | $("#datepicker").datepicker({ |
27 | onSelect: function(dateText, inst) { | 27 | onSelect: function(dateText, inst) { |
28 | - reloadProjectWithDate(dateText) } }); | 28 | + reloadProcessingWithDate(dateText) } }); |
29 | $("#datepicker").toggle(); | 29 | $("#datepicker").toggle(); |
30 | var date = jQuery("#current_processing_date").attr('data-date').substr(0,10); | 30 | var date = jQuery("#current_processing_date").attr('data-date').substr(0,10); |
31 | - $("#datepicker").datepicker( "setDate" , date ); | 31 | + $("#datepicker").datepicker( "setDate" , date.substr(5,2)+"/"+date.substr(8,2)+"/"+date.substr(0,4)); |
32 | 32 | ||
33 | }); | 33 | }); |
34 | </script> | 34 | </script> |
35 | + | ||
36 | +<span id="module_result_root_id" module_result_root_id="<%= @processing.results_root_id %>"> |
plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb
1 | -<h2><%= @project_content.name %> Project</h2> | 1 | +<h3> <%= link_to( @project_name, homepage_url(@data_profile, @project_name.downcase.gsub(/[^0-9A-Za-z]/, '')) ) %></h3> |
2 | 2 | ||
3 | <% form_for :repository, :url => {:action =>"update", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %> | 3 | <% form_for :repository, :url => {:action =>"update", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %> |
4 | - <%= hidden_field_tag :id, @project_content.id %> | 4 | + <%= hidden_field_tag :id, @project_content_id %> |
5 | 5 | ||
6 | <%= f.hidden_field :id%> | 6 | <%= f.hidden_field :id%> |
7 | <%= required labelled_form_field _('Name:'), f.text_field(:name) %> | 7 | <%= required labelled_form_field _('Name:'), f.text_field(:name) %> |
plugins/mezuro/views/mezuro_plugin_repository/new.html.erb
1 | -<h2><%= @project_content.name %> Project</h2> | 1 | +<h3> <%= link_to( @project_name, homepage_url(@data_profile, @project_name.downcase.gsub(/[^0-9A-Za-z]/, '')) ) %></h3> |
2 | 2 | ||
3 | <% form_for :repository, :url => {:action =>"create", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %> | 3 | <% form_for :repository, :url => {:action =>"create", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %> |
4 | - <%= hidden_field_tag :id, @project_content.id %> | 4 | + <%= hidden_field_tag :id, @project_content_id %> |
5 | 5 | ||
6 | <%= required labelled_form_field _('Name:'), f.text_field(:name) %> | 6 | <%= required labelled_form_field _('Name:'), f.text_field(:name) %> |
7 | 7 |
plugins/mezuro/views/mezuro_plugin_repository/show.html.erb
1 | <script src="/plugins/mezuro/javascripts/processing.js" type="text/javascript"></script> | 1 | <script src="/plugins/mezuro/javascripts/processing.js" type="text/javascript"></script> |
2 | -<h3><%= @project_name %></h3> | 2 | +<h3> <%= link_to( @project_name, homepage_url(@data_profile, @project_name.downcase.gsub(/[^0-9A-Za-z]/, '')) ) %></h3> |
3 | 3 | ||
4 | <table> | 4 | <table> |
5 | <tr> | 5 | <tr> |
@@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
14 | <td><%= _('License') %></td> | 14 | <td><%= _('License') %></td> |
15 | <td><%= @repository.license %></td> | 15 | <td><%= @repository.license %></td> |
16 | </tr> | 16 | </tr> |
17 | - <tr> | 17 | + <tr> |
18 | <td><%= _('Process Period') %></td> | 18 | <td><%= _('Process Period') %></td> |
19 | <td><%= MezuroPlugin::Helpers::ContentViewerHelper.periodicity_option(@repository.process_period.to_i) %></td> | 19 | <td><%= MezuroPlugin::Helpers::ContentViewerHelper.periodicity_option(@repository.process_period.to_i) %></td> |
20 | </tr> | 20 | </tr> |
@@ -34,7 +34,7 @@ | @@ -34,7 +34,7 @@ | ||
34 | <td><%= _('Status')%></td> | 34 | <td><%= _('Status')%></td> |
35 | <td> | 35 | <td> |
36 | <div id="processing-state" style="color:DarkGoldenRod">Retrieving</div> | 36 | <div id="processing-state" style="color:DarkGoldenRod">Retrieving</div> |
37 | - <div id="msg-time"></div> | 37 | + <div id="msg-time"></div> |
38 | </td> | 38 | </td> |
39 | </tr> | 39 | </tr> |
40 | </table> | 40 | </table> |