Commit d79ced99b18316465d17a90789819c4a772e3ae8
Committed by
Rafael Manzo
1 parent
eed7bbd0
Exists in
colab
and in
4 other branches
Show feature for compound metric configuration.
Showing
5 changed files
with
116 additions
and
2 deletions
Show diff stats
app/controllers/compound_metric_configurations_controller.rb
| ... | ... | @@ -2,10 +2,10 @@ include OwnershipAuthentication |
| 2 | 2 | include MetricConfigurationsConcern |
| 3 | 3 | |
| 4 | 4 | class CompoundMetricConfigurationsController < ApplicationController |
| 5 | - before_action :authenticate_user!, except: [:index] | |
| 5 | + before_action :authenticate_user!, except: [:show, :index] | |
| 6 | 6 | before_action :mezuro_configuration_owner?, only: [:new, :create] |
| 7 | 7 | before_action :metric_configuration_owner?, only: [:edit, :update] |
| 8 | - before_action :set_metric_configuration, only: [:edit, :update] | |
| 8 | + before_action :set_metric_configuration, only: [:show, :edit, :update] | |
| 9 | 9 | before_action :set_metric_configurations, only: [:new, :edit] |
| 10 | 10 | |
| 11 | 11 | # GET mezuro_configurations/1/compound_metric_configurations/new |
| ... | ... | @@ -23,6 +23,12 @@ class CompoundMetricConfigurationsController < ApplicationController |
| 23 | 23 | end |
| 24 | 24 | end |
| 25 | 25 | |
| 26 | + def show | |
| 27 | + @compound_metric_configuration = @metric_configuration | |
| 28 | + @reading_group = ReadingGroup.find(@compound_metric_configuration.reading_group_id) | |
| 29 | + @compound_metric_configuration.configuration_id = params[:mezuro_configuration_id].to_i | |
| 30 | + end | |
| 31 | + | |
| 26 | 32 | def edit |
| 27 | 33 | @compound_metric_configuration = @metric_configuration |
| 28 | 34 | @compound_metric_configuration.configuration_id = params[:mezuro_configuration_id].to_i | ... | ... |
| ... | ... | @@ -0,0 +1,76 @@ |
| 1 | +<div class="page-header"> | |
| 2 | + <h1><%=@compound_metric_configuration.metric.name %></h1> | |
| 3 | +</div> | |
| 4 | + | |
| 5 | +<p> | |
| 6 | + <strong>Description:</strong> | |
| 7 | + <% if @compound_metric_configuration.metric.description.nil? %> | |
| 8 | + <%= "There is no description available." %> | |
| 9 | + <% else %> | |
| 10 | + <%= @compound_metric_configuration.metric.description %> | |
| 11 | + <% end %> | |
| 12 | +</p> | |
| 13 | + | |
| 14 | +<p> | |
| 15 | + <strong>Script:</strong> | |
| 16 | + <%= @compound_metric_configuration.metric.script %> | |
| 17 | +</p> | |
| 18 | + | |
| 19 | +<p> | |
| 20 | + <strong>Scope:</strong> | |
| 21 | + <%= @compound_metric_configuration.metric.scope %> | |
| 22 | +</p> | |
| 23 | + | |
| 24 | +<p> | |
| 25 | + <strong>Code:</strong> | |
| 26 | + <%= @compound_metric_configuration.code %> | |
| 27 | +</p> | |
| 28 | + | |
| 29 | +<p> | |
| 30 | + <strong>Weight:</strong> | |
| 31 | + <%= @compound_metric_configuration.weight %> | |
| 32 | +</p> | |
| 33 | + | |
| 34 | +<p> | |
| 35 | + <strong>Aggregation Form:</strong> | |
| 36 | + <%= @compound_metric_configuration.aggregation_form %> | |
| 37 | +</p> | |
| 38 | + | |
| 39 | +<p> | |
| 40 | + <strong>Reading Group Name:</strong> | |
| 41 | + <%= @reading_group.name %> | |
| 42 | +</p> | |
| 43 | + | |
| 44 | +<hr> | |
| 45 | + | |
| 46 | +<h2> Ranges </h2> | |
| 47 | +<% if mezuro_configuration_owner? @compound_metric_configuration.configuration_id %> | |
| 48 | + <%= link_to 'Add Range', mezuro_configuration_metric_configuration_new_mezuro_range_path(@compound_metric_configuration.configuration_id, | |
| 49 | + @compound_metric_configuration.id), class: 'btn btn-info' %> | |
| 50 | +<% end %> | |
| 51 | + | |
| 52 | +<table class="table table-hover"> | |
| 53 | + <thead> | |
| 54 | + <tr> | |
| 55 | + <th>Label</th> | |
| 56 | + <th>Beginning</th> | |
| 57 | + <th>End</th> | |
| 58 | + </tr> | |
| 59 | + </thead> | |
| 60 | + <tbody> | |
| 61 | + | |
| 62 | + </tbody> | |
| 63 | +</table> | |
| 64 | + | |
| 65 | +<hr> | |
| 66 | + | |
| 67 | +<p> | |
| 68 | + <%= link_to 'Back', mezuro_configuration_path(@compound_metric_configuration.configuration_id), class: 'btn btn-default' %> | |
| 69 | +<% if mezuro_configuration_owner? @compound_metric_configuration.configuration_id %> | |
| 70 | + <%= link_to 'Destroy Metric Configuration', mezuro_configuration_metric_configuration_path(@compound_metric_configuration.configuration_id, | |
| 71 | + @compound_metric_configuration.id), method: :delete, data: { confirm: 'Are you sure that you want to destroy this metric configuration?' }, | |
| 72 | + class: 'btn btn-danger' %> | |
| 73 | + <% end %> | |
| 74 | +</p> | |
| 75 | + | |
| 76 | + | ... | ... |
| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | +Feature: Show Compound Metric Configuration | |
| 2 | + In order to know all the compound metric configurations contents | |
| 3 | + As a regular user | |
| 4 | + I should be able to see each of them | |
| 5 | + | |
| 6 | + @kalibro_restart | |
| 7 | + Scenario: Checking metric configuration show link | |
| 8 | + Given I have a sample configuration | |
| 9 | + And I have a sample reading group | |
| 10 | + And I have a sample compound metric configuration within the given mezuro configuration | |
| 11 | + When I am at the Sample Configuration page | |
| 12 | + And I click the Show link | |
| 13 | + Then I should be at compound metric configuration sample page | ... | ... |
features/step_definitions/compound_metric_configuration_steps.rb
| ... | ... | @@ -21,3 +21,8 @@ end |
| 21 | 21 | When(/^I click the edit link of the Coumpound Metric$/) do |
| 22 | 22 | page.find('tr', :text => @compound_metric_configuration.metric.name).click_link('Edit') |
| 23 | 23 | end |
| 24 | + | |
| 25 | +Then(/^I should be at compound metric configuration sample page$/) do | |
| 26 | + page.should have_content(@compound_metric_configuration.metric.name) | |
| 27 | + page.should have_content("Ranges") | |
| 28 | +end | ... | ... |
spec/controllers/compound_metric_configurations_controller_spec.rb
| ... | ... | @@ -68,6 +68,20 @@ describe CompoundMetricConfigurationsController do |
| 68 | 68 | end |
| 69 | 69 | end |
| 70 | 70 | |
| 71 | + describe 'show' do | |
| 72 | + let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration) } | |
| 73 | + let(:reading_group) { FactoryGirl.build(:reading_group) } | |
| 74 | + | |
| 75 | + before :each do | |
| 76 | + ReadingGroup.expects(:find).with(compound_metric_configuration.reading_group_id).returns(reading_group) | |
| 77 | + MetricConfiguration.expects(:find).with(compound_metric_configuration.id).returns(compound_metric_configuration) | |
| 78 | + | |
| 79 | + get :show, mezuro_configuration_id: compound_metric_configuration.configuration_id.to_s, id: compound_metric_configuration.id | |
| 80 | + end | |
| 81 | + | |
| 82 | + it { should render_template(:show) } | |
| 83 | + end | |
| 84 | + | |
| 71 | 85 | describe 'edit' do |
| 72 | 86 | let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration) } |
| 73 | 87 | ... | ... |