Commit eed7bbd0c774bd17e0544a6e2881d80b798f5ce2
Committed by
Rafael Manzo
1 parent
7febfea6
Exists in
colab
and in
4 other branches
Helper for show page link of metric configurations.
Showing
3 changed files
with
25 additions
and
2 deletions
Show diff stats
app/helpers/mezuro_configurations_helper.rb
... | ... | @@ -10,4 +10,12 @@ module MezuroConfigurationsHelper |
10 | 10 | link_to('Edit', edit_mezuro_configuration_metric_configuration_path(mezuro_configuration_id, metric_configuration.id), class: 'btn btn-info') |
11 | 11 | end |
12 | 12 | end |
13 | + | |
14 | + def link_to_show_page(metric_configuration, mezuro_configuration_id) | |
15 | + if (metric_configuration.metric.compound) | |
16 | + link_to('Show', mezuro_configuration_compound_metric_configuration_path(mezuro_configuration_id, metric_configuration.id), class: 'btn btn-info') | |
17 | + else | |
18 | + link_to('Show', mezuro_configuration_metric_configuration_path(mezuro_configuration_id, metric_configuration.id), class: 'btn btn-info') | |
19 | + end | |
20 | + end | |
13 | 21 | end | ... | ... |
app/views/mezuro_configurations/_metric_configurations.html.erb
... | ... | @@ -3,8 +3,7 @@ |
3 | 3 | <td><%= metric_configuration.code %></td> |
4 | 4 | <td><%= metric_configuration.weight %></td> |
5 | 5 | <td> |
6 | - <%= link_to 'Show', mezuro_configuration_metric_configuration_path(@mezuro_configuration.id, metric_configuration.id), | |
7 | - class: 'btn btn-info' %> | |
6 | + <%= link_to_show_page(metric_configuration, @mezuro_configuration.id) %> | |
8 | 7 | </td> |
9 | 8 | <% if mezuro_configuration_owner? @mezuro_configuration.id %> |
10 | 9 | <td> | ... | ... |
spec/helpers/mezuro_configurations_helper_spec.rb
... | ... | @@ -57,4 +57,20 @@ describe MezuroConfigurationsHelper do |
57 | 57 | it { helper.link_to_edit_form(compound_metric_configuration, compound_metric_configuration.configuration_id).should eq(response_link) } |
58 | 58 | end |
59 | 59 | end |
60 | + | |
61 | + describe 'link to show page' do | |
62 | + context 'when the metric is native' do | |
63 | + let(:metric_configuration) { FactoryGirl.build(:metric_configuration) } | |
64 | + let(:response_link) {"<a class=\"btn btn-info\" href=\"/mezuro_configurations/#{metric_configuration.configuration_id}/metric_configurations/#{metric_configuration.id}\">Show</a>"} | |
65 | + | |
66 | + it { helper.link_to_show_page(metric_configuration, metric_configuration.configuration_id).should eq(response_link) } | |
67 | + end | |
68 | + | |
69 | + context 'when the metric is compound' do | |
70 | + let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration) } | |
71 | + let(:response_link) {"<a class=\"btn btn-info\" href=\"/mezuro_configurations/#{compound_metric_configuration.configuration_id}/compound_metric_configurations/#{compound_metric_configuration.id}\">Show</a>"} | |
72 | + | |
73 | + it { helper.link_to_show_page(compound_metric_configuration, compound_metric_configuration.configuration_id).should eq(response_link) } | |
74 | + end | |
75 | + end | |
60 | 76 | end | ... | ... |