Commit cd5beb43788021007c90fa4ee88fae4a57cb99f7

Authored by Fellipe Souto Sampaio
Committed by Rafael Manzo
1 parent 4e5ee1c7

Show feature

Pending acceptance test for listing all the ranges
Pending show template

signed-off-by: Renan Fichberg <rfichberg@gmail.com>
app/controllers/metric_configurations_controller.rb
... ... @@ -2,8 +2,8 @@ include OwnershipAuthentication
2 2 include MetricConfigurationsConcern
3 3  
4 4 class MetricConfigurationsController < ApplicationController
5   - before_action :authenticate_user!, except: [:index]
6   - before_action :set_metric_configuration, only: [:edit, :update, :destroy]
  5 + before_action :authenticate_user!, except: [:show, :index]
  6 + before_action :set_metric_configuration, only: [:show, :edit, :update, :destroy]
7 7 before_action :metric_configuration_owner?, only: [:edit, :update, :destroy]
8 8 before_action :mezuro_configuration_owner?, only: [:new, :create, :choose_metric]
9 9  
... ... @@ -29,6 +29,10 @@ class MetricConfigurationsController &lt; ApplicationController
29 29 end
30 30 end
31 31  
  32 + def show
  33 + @reading_group = ReadingGroup.find(@metric_configuration.reading_group_id)
  34 + end
  35 +
32 36 def edit
33 37 #FIXME: set the configuration id just once!
34 38 @mezuro_configuration_id = params[:mezuro_configuration_id]
... ...
app/views/metric_configurations/show.html.erb 0 → 100644
... ... @@ -0,0 +1,55 @@
  1 +<div class="page-header">
  2 + <h1><%=@metric_configuration.metric.name %></h1>
  3 +</div>
  4 +
  5 +<p>
  6 + <strong>Base Tool Name:</strong>
  7 + <%= @metric_configuration.base_tool_name %>
  8 +</p>
  9 +
  10 +<p>
  11 + <strong>Code:</strong>
  12 + <%= @metric_configuration.code %>
  13 +</p>
  14 +
  15 +<p>
  16 + <strong>Weight:</strong>
  17 + <%= @metric_configuration.weight %>
  18 +</p>
  19 +
  20 +<p>
  21 + <strong>Language:</strong>
  22 + <%= @metric_configuration.metric.language %>
  23 +</p>
  24 +
  25 +<p>
  26 + <strong>Scope:</strong>
  27 + <%= @metric_configuration.metric.scope %>
  28 +</p>
  29 +
  30 +<p>
  31 + <strong>Aggregation Form:</strong>
  32 + <%= @metric_configuration.aggregation_form %>
  33 +</p>
  34 +
  35 +<p>
  36 + <strong>Reading Group Name:</strong>
  37 + <%= @reading_group.name %>
  38 +</p>
  39 +
  40 +<p>
  41 + <strong>Description:</strong>
  42 + <% if @metric_configuration.metric.description.nil? %>
  43 + <%= "There is no description available." %>
  44 + <% else %>
  45 + <%= @metric_configuration.metric.description %>
  46 + <% end %>
  47 +
  48 +</p>
  49 +<hr>
  50 +
  51 +<h2> Ranges </h2>
  52 +
  53 +
  54 +
  55 +
... ...
app/views/mezuro_configurations/_metric_configurations.html.erb
... ... @@ -2,6 +2,10 @@
2 2 <td><%= metric_configuration.metric.name %></td>
3 3 <td><%= metric_configuration.code %></td>
4 4 <td><%= metric_configuration.weight %></td>
  5 + <td>
  6 + <%= link_to 'Show', mezuro_configuration_metric_configuration_path(@mezuro_configuration.id, metric_configuration.id),
  7 + class: 'btn btn-info' %>
  8 + </td>
5 9 <% if mezuro_configuration_owner? @mezuro_configuration.id %>
6 10 <td>
7 11 <%= link_to_edit_form(metric_configuration, @mezuro_configuration.id) %>
... ...
features/metric_configuration/show.feature 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +Feature: Show Metric Configuration
  2 + In order to know all the metric configurations of the given configuration and its 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 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 metric configuration sample page
0 14 \ No newline at end of file
... ...
features/mezuro_configuration/show.feature
1 1 Feature: Show Configuration
2   - In order to know all the repositories of the given configuration and its contents
  2 + In order to know all the contents of a given configuration
3 3 As a regular user
4 4 I should be able to see each of them
5 5  
... ...
features/step_definitions/metric_configuration_steps.rb
... ... @@ -16,4 +16,14 @@ Then(/^I should see the sample metric configuration content$/) do
16 16 page.should have_content(@metric_configuration.metric.name)
17 17 page.should have_content(@metric_configuration.code)
18 18 page.should have_content(@metric_configuration.weight)
  19 +end
  20 +
  21 +When(/^I visit the sample metric configuration page$/) do
  22 + visit edit_mezuro_configuration_path(@mezuro_configuration.id)
  23 +end
  24 +
  25 +
  26 +Then(/^I should be at metric configuration sample page$/) do
  27 + page.should have_content(@metric_configuration.metric.name)
  28 + page.should have_content("Ranges")
19 29 end
20 30 \ No newline at end of file
... ...
spec/controllers/metric_configurations_controller_spec.rb
... ... @@ -84,6 +84,17 @@ describe MetricConfigurationsController do
84 84 end
85 85 end
86 86 end
  87 +
  88 + describe 'show' do
  89 + let(:metric_configuration) { FactoryGirl.build(:metric_configuration) }
  90 + let(:reading_group) { FactoryGirl.build(:reading_group) }
  91 + before :each do
  92 + ReadingGroup.expects(:find).with(metric_configuration.reading_group_id).returns(reading_group)
  93 + get :show, mezuro_configuration_id: metric_configuration.configuration_id.to_s, id: metric_configuration.id
  94 + end
  95 +
  96 + it { should render_template(:show) }
  97 + end
87 98  
88 99 describe 'edit' do
89 100 let(:metric_configuration) { FactoryGirl.build(:metric_configuration) }
... ...