Commit 2443cd3a078cc72b199c33d712364a73efd2bd0f
Committed by
Rafael Manzo
1 parent
8109be9d
Exists in
colab
and in
4 other branches
Fixed metric configurations create acceptance tests
Signed off by: Diego Araújo <diegoamc90@gmail.com>
Showing
7 changed files
with
14 additions
and
11 deletions
Show diff stats
app/controllers/metric_configurations_controller.rb
... | ... | @@ -7,7 +7,7 @@ class MetricConfigurationsController < BaseMetricConfigurationsController |
7 | 7 | |
8 | 8 | def new |
9 | 9 | super |
10 | - metric_configuration.metric = KalibroClient::Entities::Processor::MetricCollectorDetails.find(params[:metric_collector_name]).metric params[:metric_code] | |
10 | + metric_configuration.metric = KalibroClient::Entities::Processor::MetricCollectorDetails.find_by_name(params[:metric_collector_name]).find_metric_by_code params[:metric_code] | |
11 | 11 | end |
12 | 12 | |
13 | 13 | def create |
... | ... | @@ -54,6 +54,7 @@ class MetricConfigurationsController < BaseMetricConfigurationsController |
54 | 54 | end |
55 | 55 | |
56 | 56 | def update_metric_configuration (new_metric_configuration) |
57 | + @kalibro_configuration_id = params[:kalibro_configuration_id] | |
57 | 58 | @metric_configuration = new_metric_configuration |
58 | 59 | end |
59 | 60 | ... | ... |
app/helpers/metric_configurations_helper.rb
... | ... | @@ -15,6 +15,6 @@ module MetricConfigurationsHelper |
15 | 15 | end |
16 | 16 | |
17 | 17 | def supported_metrics_of(metric_collector_name) |
18 | - KalibroClient::Processor::MetricCollectorDetails.find(metric_collector_name).supported_metrics | |
18 | + KalibroClient::Entities::Processor::MetricCollectorDetails.find_by_name(metric_collector_name).supported_metrics | |
19 | 19 | end |
20 | 20 | end | ... | ... |
app/models/metric_configuration.rb
app/views/metric_configurations/_form.html.erb
... | ... | @@ -47,4 +47,4 @@ |
47 | 47 | </div> |
48 | 48 | |
49 | 49 | <%= hidden_field_tag(:metric_name, @metric_configuration.metric.name) %> |
50 | -<%= hidden_field_tag(:metric_collector_name, @metric_configuration.metric_collector_name) %> | |
50 | +<%= hidden_field_tag(:metric_collector_name, @metric_configuration.metric.metric_collector_name) %> | ... | ... |
app/views/metric_configurations/choose_metric.html.erb
... | ... | @@ -11,8 +11,8 @@ |
11 | 11 | <% @metric_collectors_names.each do |metric_collector_name| %> |
12 | 12 | <h3 class="jquery-ui-accordion"><%= metric_collector_name %></h3> |
13 | 13 | <div> |
14 | - <% supported_metrics_of(metric_collector_name).each do |metric| %> | |
15 | - <%= link_to metric.name, '#', onclick: "MetricCollector.choose_metric(\"#{metric.code}\", \"#{metric_collector_name}\");", remote: true %><br> | |
14 | + <% supported_metrics_of(metric_collector_name).each do |code, metric| %> | |
15 | + <%= link_to metric.name, '#', onclick: "MetricCollector.choose_metric(\"#{code}\", \"#{metric_collector_name}\");", remote: true %><br> | |
16 | 16 | <% end %> |
17 | 17 | </div> |
18 | 18 | <% end %> | ... | ... |
app/views/metric_configurations/new.html.erb
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | </div> |
4 | 4 | |
5 | 5 | <p> |
6 | - <b>Base Tool:</b> <%= @metric_configuration.metric_collector_name %> | |
6 | + <b>Base Tool:</b> <%= @metric_configuration.metric.metric_collector_name %> | |
7 | 7 | </p> |
8 | 8 | |
9 | 9 | <p> |
... | ... | @@ -24,10 +24,10 @@ |
24 | 24 | |
25 | 25 | <br> |
26 | 26 | |
27 | -<%= form_for(@metric_configuration, :url => kalibro_configuration_metric_configurations_path(@metric_configuration.configuration_id)) do |f| %> | |
27 | +<%= form_for(@metric_configuration, :url => kalibro_configuration_metric_configurations_path(@kalibro_configuration_id)) do |f| %> | |
28 | 28 | <%= render partial: 'form', locals: {f: f} %> |
29 | 29 | <div class="row margin-left-none" style="margin-top: 20px"> |
30 | 30 | <%= f.submit 'Save', class: 'btn btn-primary' %> |
31 | - <%= link_to 'Back', kalibro_configuration_choose_metric_path(@metric_configuration.configuration_id), class: 'btn btn-default' %> | |
31 | + <%= link_to 'Back', kalibro_configuration_choose_metric_path(@kalibro_configuration_id), class: 'btn btn-default' %> | |
32 | 32 | </div> |
33 | 33 | <% end %> | ... | ... |
spec/controllers/metric_configurations_controller_spec.rb
... | ... | @@ -31,8 +31,8 @@ describe MetricConfigurationsController, :type => :controller do |
31 | 31 | context 'when the current user owns the kalibro configuration' do |
32 | 32 | before :each do |
33 | 33 | subject.expects(:kalibro_configuration_owner?).returns true |
34 | - KalibroClient::Entities::Processor::MetricCollectorDetails.expects(:find).with(metric_collector.name).returns(metric_collector) | |
35 | - metric_collector.expects(:metric).with(native_metric.code).returns(native_metric) | |
34 | + KalibroClient::Entities::Processor::MetricCollectorDetails.expects(:find_by_name).with(metric_collector.name).returns(metric_collector) | |
35 | + metric_collector.expects(:find_metric_by_code).with(native_metric.code).returns(native_metric) | |
36 | 36 | post :new, kalibro_configuration_id: kalibro_configuration.id, metric_code: native_metric.code, metric_collector_name: metric_collector.name |
37 | 37 | end |
38 | 38 | ... | ... |