- <%= f.label :scope, t('scope'), class: 'control-label' %>
+ <%= f.label :scope, compound_metric_human_attribute_name('scope'), class: 'control-label' %>
<%= f.select( :scope, scope_options, {class: 'form-control', selected: (metric.scope unless metric.nil?)} ) %>
@@ -48,16 +48,16 @@
diff --git a/app/views/compound_metric_configurations/edit.html.erb b/app/views/compound_metric_configurations/edit.html.erb
index 382954a..c760768 100644
--- a/app/views/compound_metric_configurations/edit.html.erb
+++ b/app/views/compound_metric_configurations/edit.html.erb
@@ -1,5 +1,5 @@
diff --git a/app/views/compound_metric_configurations/new.html.erb b/app/views/compound_metric_configurations/new.html.erb
index d296321..4887a93 100644
--- a/app/views/compound_metric_configurations/new.html.erb
+++ b/app/views/compound_metric_configurations/new.html.erb
@@ -1,5 +1,5 @@
<%= render partial: 'created_metrics', locals: {metric_configurations: @metric_configurations} %>
diff --git a/config/locales/views/compound_metric_configuration/en.yml b/config/locales/views/compound_metric_configuration/en.yml
index 9cbe916..e01566c 100644
--- a/config/locales/views/compound_metric_configuration/en.yml
+++ b/config/locales/views/compound_metric_configuration/en.yml
@@ -1,11 +1,23 @@
en:
- body1_compound_form: "A variable that holds the value of a metric calculation. It can be used in the script of another compound metric."
- body2_compound_form: " It is used to calculate the weighted average of a"
- body1_compound_form_example: "Example: Code foo := 10"
- body1_compound_metric_options: "A custom name for your compound metric."
- body2_compound_metric_options: "A short description of your compound metric."
- body3_compound_metric_options: "A mathematical expression (in javascript) to calculate your compound metric. It needs a return statement. The codes of already created metrics can be used inside the script."
- title_compound_edit: "Edit Compound Metric Configuration"
- title_compound_new: "New Compound Metric Configuration"
- compound_metric: "Compound Metric"
-
+ activemodel:
+ models:
+ compound_metric_configuration:
+ one: "Compound Metric Configuration"
+ other: "Compound Metric Configurations"
+ attributes:
+ compound_metric_configuration:
+ name: "Name"
+ description: "Description"
+ script: "Script"
+ scope: "Scope"
+ code: "Code"
+ weight: "Weight"
+ hints:
+ compound_metric_configuration:
+ name: "A custom name for your compound metric."
+ description: "A short description of your compound metric."
+ script: "A mathematical expression (in javascript) to calculate your compound metric. It needs a return statement. The codes of already created metrics can be used inside the script."
+ code:
+ description: "A variable that holds the value of a metric calculation. It can be used in the script of another compound metric."
+ example: "Example: Code foo := 10"
+ weight: "It is used to calculate the weighted average of a"
diff --git a/config/locales/views/compound_metric_configuration/pt.yml b/config/locales/views/compound_metric_configuration/pt.yml
index dc6925a..c53a579 100644
--- a/config/locales/views/compound_metric_configuration/pt.yml
+++ b/config/locales/views/compound_metric_configuration/pt.yml
@@ -1,9 +1,23 @@
pt:
- body1_compound_form: "Uma variável que contém o valor de um cálculo de métrica. Ele pode ser utilizado no script de outra métrica composta."
- body1_compound_form_example: "Exemplo: Código foo := 10"
- body1_compound_metric_options: "Um nome personalizado para a sua métrica composta."
- body2_compound_metric_options: "Uma breve descrição de sua métrica composta."
- body3_compound_metric_options: "A expressão matemática (em javascript) para calcular a sua métrica composta. Ela precisa de uma instrução de retorno (por exemplo, 'return resultado;'). Os códigos de métricas já criadas podem ser usados dentro do script."
- title_compound_edit: "Editar Configuração de Métrica Composta"
- title_compound_new: "Nova Configuração de Métrica Composta"
- compound_metric: "Métrica Composta"
+ activemodel:
+ models:
+ compound_metric_configuration:
+ one: "Configuração de Métrica Composta"
+ other: "Configurações de Métricas Compostas"
+ attributes:
+ compound_metric_configuration:
+ name: "Nome"
+ description: "Descrição"
+ script: "Script"
+ scope: "Escopo"
+ code: "Código"
+ weight: "Peso"
+ hints:
+ compound_metric_configuration:
+ name: "Um nome personalizado para sua métrica composta."
+ description: "Uma descrição curta de sua métrica composta."
+ script: "Uma expressão matemática (em JavaScript) para calcular sua métrica composta. Ela precisa de uma cláusula de retorno. O código de suas demais métricas pode ser utilizado dentro deste script."
+ code:
+ description: "Uma variável que contém o valor do cálculo da métrica. Ela pode ser usada no script de outra métrica composa."
+ example: "Examplo: Código foo := 10"
+ weight: "ele é usado para o cálculo de uma média ponderada de um"
diff --git a/features/compound_metric_configuration/create.feature b/features/compound_metric_configuration/create.feature
index fa3fdc8..0cfa918 100644
--- a/features/compound_metric_configuration/create.feature
+++ b/features/compound_metric_configuration/create.feature
@@ -13,18 +13,18 @@ Feature: Compound Metric Configuration Creation
And I am at the Sample Configuration page
And I click the Add Metric link
And I click the Compound Metric link
- When I click the "Created Metrics" h3
Then I see the sample metric configuration name
And I see the sample metric configuration code
When I fill the Name field with "My Compound Metric"
And I fill the Description field with "Some description"
And I fill the Code field with "mcm"
- And I fill the Script field with "8*8;"
+ And I fill the Script field with "return 8*8;"
And I fill the Weight field with "8"
And I set the select field "Scope" as "Class"
And I set the select field "Reading Group" as "Scholar"
And I press the Save button
- When I click the show link of "My Compound Metric"
+ Then I should see "Compound Metric Configuration was successfully created."
+ And I click the show link of "My Compound Metric"
Then I should see "My Compound Metric"
And I should see "mcm"
And I should see "8"
diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb
index 35fa2c4..7a2ae88 100644
--- a/features/step_definitions/user_steps.rb
+++ b/features/step_definitions/user_steps.rb
@@ -7,11 +7,11 @@ When(/^I press the (.+) button$/) do |text|
end
When(/^I fill the (.+) field with "(.+)"$/) do |field, text|
- fill_in I18n.t(field.gsub(" ", "_").downcase), :with => text
+ fill_in field, :with => text
end
Then(/^the field "(.*?)" should be filled with "(.*?)"$/) do |field, value|
- expect(page.find_field(I18n.t(field.gsub(" ", "_").downcase)).value).to eq(value)
+ expect(page.find_field(field).value).to eq(value)
end
Then(/^my name should have changed to (.+)$/) do |text|
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
new file mode 100644
index 0000000..f4d4288
--- /dev/null
+++ b/spec/helpers/application_helper_spec.rb
@@ -0,0 +1,26 @@
+require 'rails_helper'
+
+describe ApplicationHelper, :type => :helper do
+ describe 't_hint' do
+ let(:class_key) { :compound_metric_configuration }
+ let(:attribute_key) { :script }
+
+ context 'without class_key' do
+ let!(:translation) { "translated test" }
+
+ before :each do
+ helper.expects(:t).with("activemodel.hints.#{helper.controller_name}.#{attribute_key}").returns(translation)
+ end
+
+ it 'is expected to return the hint for the given attribute' do
+ expect(helper.t_hint(attribute_key)).to eq(translation)
+ end
+ end
+
+ context 'with class_key' do
+ it 'is expected to return the hint for the given attribute' do
+ expect(helper.t_hint(attribute_key, class_key)).to eq(I18n.t("activemodel.hints.#{class_key}.#{attribute_key}"))
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/spec/helpers/compound_metric_configurations_helper_spec.rb b/spec/helpers/compound_metric_configurations_helper_spec.rb
index 045732d..2763a3a 100644
--- a/spec/helpers/compound_metric_configurations_helper_spec.rb
+++ b/spec/helpers/compound_metric_configurations_helper_spec.rb
@@ -6,4 +6,27 @@ describe CompoundMetricConfigurationsHelper, :type => :helper do
expect(helper.scope_options).to eq [["Method","METHOD"], ["Class", "CLASS"], ["Package", "PACKAGE"], ["Software", "SOFTWARE"]]
end
end
+
+ describe 'compound_metric_human_name' do
+ context 'with one' do
+ it 'is expected to return the class name internationalized' do
+ expect(helper.compound_metric_human_name).to eq(I18n.t('activemodel.models.compound_metric_configuration.one'))
+ end
+ end
+
+ context 'with more than one' do
+ it 'is expected to return the class name internationalized and pluralized' do
+ expect(helper.compound_metric_human_name(2)).to eq(I18n.t('activemodel.models.compound_metric_configuration.other'))
+ expect(helper.compound_metric_human_name(50)).to eq(I18n.t('activemodel.models.compound_metric_configuration.other'))
+ end
+ end
+ end
+
+ describe 'compound_metric_human_attribute_name' do
+ let(:attribute) { :name }
+
+ it 'is expected to return the attribute name internationalized' do
+ expect(helper.compound_metric_human_attribute_name(attribute)).to eq(I18n.t("activemodel.attributes.compound_metric_configuration.#{attribute}"))
+ end
+ end
end
--
libgit2 0.21.2