Commit 505bff9f0b42b163114e9dff07a5ca9ebc112db7

Authored by Diego de Araújo Martinez Camarinha
2 parents c0263c49 bcd6ba18
Exists in colab and in 2 other branches master, stable

Merge pull request #329 from mezuro/compound_function_scope

Add FUNCTION scope to compound_metric_configuration form
app/helpers/compound_metric_configurations_helper.rb
1 module CompoundMetricConfigurationsHelper 1 module CompoundMetricConfigurationsHelper
2 def scope_options 2 def scope_options
3 - [[t("scopes.METHOD"),"METHOD"], [t("scopes.CLASS"), "CLASS"], [t("scopes.PACKAGE"), "PACKAGE"], [t("scopes.SOFTWARE"), "SOFTWARE"]] 3 + %w(FUNCTION METHOD CLASS PACKAGE SOFTWARE).map do |scope|
  4 + [t("scopes.#{scope}"), scope]
  5 + end
4 end 6 end
5 7
6 def compound_metric_human_name(count=1) 8 def compound_metric_human_name(count=1)
config/locales/views/metric_configurations/en.yml
@@ -40,6 +40,7 @@ en: @@ -40,6 +40,7 @@ en:
40 invalid_metric_or_collector: "Invalid combination of metric collector, name/code and type" 40 invalid_metric_or_collector: "Invalid combination of metric collector, name/code and type"
41 invalid_model: "Invalid %{model}" 41 invalid_model: "Invalid %{model}"
42 scopes: 42 scopes:
  43 + FUNCTION: "Function"
43 METHOD: "Method" 44 METHOD: "Method"
44 CLASS: "Class" 45 CLASS: "Class"
45 PACKAGE: "Package" 46 PACKAGE: "Package"
config/locales/views/metric_configurations/pt.yml
@@ -44,6 +44,7 @@ pt: @@ -44,6 +44,7 @@ pt:
44 invalid_metric_or_collector: "Combinação inválida de coletor de métricas, nome/código e tipo" 44 invalid_metric_or_collector: "Combinação inválida de coletor de métricas, nome/código e tipo"
45 invalid_model: "%{model} inválido" 45 invalid_model: "%{model} inválido"
46 scopes: 46 scopes:
  47 + FUNCTION: "Função"
47 METHOD: "Método" 48 METHOD: "Método"
48 CLASS: "Classe" 49 CLASS: "Classe"
49 PACKAGE: "Pacote" 50 PACKAGE: "Pacote"
spec/helpers/compound_metric_configurations_helper_spec.rb
@@ -3,7 +3,9 @@ require 'rails_helper' @@ -3,7 +3,9 @@ require 'rails_helper'
3 describe CompoundMetricConfigurationsHelper, :type => :helper do 3 describe CompoundMetricConfigurationsHelper, :type => :helper do
4 describe 'scope_options' do 4 describe 'scope_options' do
5 it 'should return an array with the supported scope options' do 5 it 'should return an array with the supported scope options' do
6 - expect(helper.scope_options).to eq [["Method","METHOD"], ["Class", "CLASS"], ["Package", "PACKAGE"], ["Software", "SOFTWARE"]] 6 + expect(helper.scope_options).to eq [
  7 + ["Function", "FUNCTION"], ["Method","METHOD"], ["Class", "CLASS"], ["Package", "PACKAGE"], ["Software", "SOFTWARE"]
  8 + ]
7 end 9 end
8 end 10 end
9 11