Commit 3d56744a525c13b3b28030d89ffdfe8ea986416b
Committed by
Daniel
1 parent
25cbbb33
Exists in
colab
and in
4 other branches
Add action_path parameter to choose_metric
This will enable different actions for TreeMetricConfigurations and Hotspot ones. Signed off by: Diego Araújo <diegoamc90@gmail.com>
Showing
2 changed files
with
6 additions
and
2 deletions
Show diff stats
app/assets/javascripts/metric_collector.js.coffee
| 1 | 1 | class @MetricCollector |
| 2 | 2 | |
| 3 | 3 | # Static Method |
| 4 | - @choose_metric: (metric_code, metric_collector_name) -> | |
| 4 | + @choose_metric: (metric_code, metric_collector_name, action_path) -> | |
| 5 | 5 | $("#metric_code").val(metric_code) |
| 6 | 6 | $("#metric_collector_name").val(metric_collector_name) |
| 7 | + $("form").attr('action', action_path) | |
| 7 | 8 | $("form").submit() | ... | ... |
spec/javascripts/metric_collector_spec.js.coffee
| ... | ... | @@ -16,15 +16,18 @@ describe "MetricCollector", -> |
| 16 | 16 | |
| 17 | 17 | @form = sinon.stub() |
| 18 | 18 | @form.submit = sinon.stub() |
| 19 | + @action_path = '/en/kalibro_configurations/1/metric_configurations/new' | |
| 20 | + @form.attr = sinon.stub().withArgs('action', @action_path) | |
| 19 | 21 | |
| 20 | 22 | $.withArgs("#metric_code").returns(@metric_code_field) |
| 21 | 23 | $.withArgs("#metric_collector_name").returns(@metric_collector_name_field) |
| 22 | 24 | $.withArgs("form").returns(@form) |
| 23 | 25 | |
| 24 | 26 | it 'is expected to fill in the form and submit', -> |
| 25 | - MetricCollector.choose_metric(@metric_code, @metric_collector_name) | |
| 27 | + MetricCollector.choose_metric(@metric_code, @metric_collector_name, @action_path) | |
| 26 | 28 | |
| 27 | 29 | sinon.assert.calledOnce(@metric_code_field.val, @metric_code) |
| 28 | 30 | sinon.assert.calledOnce(@metric_collector_name_field.val, @metric_collector_name) |
| 29 | 31 | sinon.assert.calledOnce(@form.submit) |
| 32 | + sinon.assert.calledOnce(@form.attr, 'action', @action_path) | |
| 30 | 33 | ... | ... |