Commit 11179af96df01578cd227c54e496d112f06dc947
Committed by
Rafael Manzo
1 parent
108b8cec
Exists in
colab
and in
4 other branches
Helper to get the native metrics
signed-off-by: Diego Araújo <diegoamc90@gmail.com>
Showing
2 changed files
with
18 additions
and
0 deletions
Show diff stats
app/helpers/metric_configurations_helper.rb
... | ... | @@ -7,5 +7,11 @@ module MetricConfigurationsHelper |
7 | 7 | def reading_group_options |
8 | 8 | ReadingGroup.all.map { |reading_group| [reading_group.name, reading_group.id] } |
9 | 9 | end |
10 | + | |
11 | + def native_metrics_of(mezuro_configuration_id) | |
12 | + MetricConfiguration.metric_configurations_of(mezuro_configuration_id).map do |metric_configuration| | |
13 | + [ metric_configuration.code, metric_configuration.metric.name ] | |
14 | + end | |
15 | + end | |
10 | 16 | end |
11 | 17 | ... | ... |
spec/helpers/metric_configurations_helper_spec.rb
... | ... | @@ -19,4 +19,16 @@ describe MetricConfigurationsHelper do |
19 | 19 | helper.reading_group_options.should eq [[reading_group.name, reading_group.id]] |
20 | 20 | end |
21 | 21 | end |
22 | + | |
23 | + describe 'native_metrics_of' do | |
24 | + let! (:metric_configuration) { FactoryGirl.build(:metric_configuration) } | |
25 | + | |
26 | + before :each do | |
27 | + MetricConfiguration.expects(:metric_configurations_of).with(metric_configuration.configuration_id).returns([metric_configuration]) | |
28 | + end | |
29 | + | |
30 | + it 'should return a pair with the metric configuration code and metric name' do | |
31 | + helper.native_metrics_of(metric_configuration.configuration_id).should eq [[metric_configuration.code, metric_configuration.metric.name]] | |
32 | + end | |
33 | + end | |
22 | 34 | end | ... | ... |