Commit 9b94cafdeab2fd94642ba2d31b5f258ea294183c
Committed by
Rafael Manzo
1 parent
16c53cf6
Exists in
colab
and in
4 other branches
New metric configuration feature
Routes for choose_metric & new metric configuration Missing acceptance tests Signed off by: Renan Fichberg <rfichberg@gmail.com>
Showing
8 changed files
with
69 additions
and
16 deletions
Show diff stats
app/views/metric_configurations/_form.html.erb
1 | 1 | <%= render :partial => 'shared/form_errors', :locals => {:object => @metric_configuration} %> |
2 | 2 | |
3 | 3 | <div class="form-group"> |
4 | - <%= f.label :code, class: 'control-label' %><br> | |
4 | + <%= f.label :code, class: 'control-label' %> | |
5 | 5 | <%= f.text_field :code, class: 'form-control' %> |
6 | 6 | </div> |
7 | 7 | |
8 | 8 | <div class="form-group"> |
9 | - <%= f.label :weight, class: 'control-label' %><br> | |
9 | + <%= f.label :weight, class: 'control-label' %> | |
10 | 10 | <%= f.text_field :weight, class: 'form-control' %> |
11 | 11 | </div> |
12 | 12 | |
13 | +<div class="form-group"> | |
14 | + <%= f.label :aggregation_form, 'Aggregation Form', class: 'control-label' %> | |
15 | + <%= f.select( :aggregation_form, aggregation_options, {class: 'form-control'} ) %> | |
16 | +</div> | |
17 | + | |
18 | +<br> | |
13 | 19 | <%= f.submit 'Save', class: 'btn btn-primary' %> |
14 | 20 | <%= link_to 'Back', mezuro_configuration_path(@mezuro_configuration_id), class: 'btn btn-default' %> | ... | ... |
app/views/metric_configurations/new.html.erb
... | ... | @@ -2,6 +2,25 @@ |
2 | 2 | <h1>New Metric Configuration</h1> |
3 | 3 | </div> |
4 | 4 | |
5 | +<p> | |
6 | + <b>Base Tool:</b> <%= @base_tool_name %> | |
7 | +</p> | |
8 | +<p> | |
9 | + <b>Metric Name:</b> <%= @metric.name %> | |
10 | +</p> | |
11 | +<p> | |
12 | + <b>Metric Description:</b> <%= @metric.description.nil? ? "No description available." : @metric.description %> | |
13 | +</p> | |
14 | +<p> | |
15 | + <b>Language:</b> <%= @metric.languages.to_s %> | |
16 | +</p> | |
17 | + | |
18 | +<p> | |
19 | + <b>Scope:</b> <%= @metric.scope %> | |
20 | +</p> | |
21 | + | |
22 | +<br> | |
23 | + | |
5 | 24 | <%= form_for(@metric_configuration, :url => mezuro_configuration_metric_configurations_path(@mezuro_configuration_id)) do |f| %> |
6 | 25 | <%= render partial: 'form', locals: {f: f} %> |
7 | 26 | <% end %> | ... | ... |
config/routes.rb
... | ... | @@ -11,8 +11,9 @@ Mezuro::Application.routes.draw do |
11 | 11 | end |
12 | 12 | |
13 | 13 | resources :mezuro_configurations do |
14 | - resources :metric_configurations, except: [:update] | |
15 | - get '/metric_configurations/:id/choose_metric' => 'metric_configurations#choose_metric', as: :choose_metric | |
14 | + get '/metric_configurations/choose_metric' => 'metric_configurations#choose_metric', as: :choose_metric | |
15 | + resources :metric_configurations, except: [:update, :new] | |
16 | + get '/metric_configurations/:metric_name/:base_tool_name/new' => 'metric_configurations#new', as: :new_metric_configuration | |
16 | 17 | put '/metric_configurations/:id' => 'metric_configurations#update', as: :metric_configuration_update |
17 | 18 | end |
18 | 19 | ... | ... |
spec/controllers/concerns/ownership_authentication_spec.rb
... | ... | @@ -63,4 +63,20 @@ describe OwnershipAuthentication, type: :controller do |
63 | 63 | end |
64 | 64 | end |
65 | 65 | end |
66 | -end | |
67 | 66 | \ No newline at end of file |
67 | + | |
68 | + describe 'mezuro_configuration_owner?' do | |
69 | + let(:mezuro_configuration) { FactoryGirl.build(:mezuro_configuration) } | |
70 | + | |
71 | + context 'Not MezuroConfigurationsController nor MetricConfigurationsController' do | |
72 | + let!(:projects_controller) { ProjectsController.new } | |
73 | + | |
74 | + before do | |
75 | + projects_controller.extend(OwnershipAuthentication) | |
76 | + end | |
77 | + | |
78 | + it 'should raise an exception' do | |
79 | + expect { projects_controller.mezuro_configuration_owner? }.to raise_error("Not supported") | |
80 | + end | |
81 | + end | |
82 | + end | |
83 | +end | ... | ... |
... | ... | @@ -0,0 +1,10 @@ |
1 | +require 'spec_helper' | |
2 | + | |
3 | +describe MetricConfigurationsHelper do | |
4 | + describe 'aggregation_form_options' do | |
5 | + it 'should return an array with the supported aggregation forms' do | |
6 | + helper.aggregation_options.should eq [["Average","AVERAGE"], ["Median", "MEDIAN"], ["Maximum", "MAXIMUM"], ["Minimum", "MINIMUM"], | |
7 | + ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]] | |
8 | + end | |
9 | + end | |
10 | +end | ... | ... |
spec/routing/metric_configurations_routing_spec.rb
... | ... | @@ -2,10 +2,8 @@ require "spec_helper" |
2 | 2 | |
3 | 3 | describe MetricConfigurationsController do |
4 | 4 | describe "routing" do |
5 | - it { should route(:get, '/mezuro_configurations/1/metric_configurations/1/choose_metric'). | |
6 | - to(controller: :metric_configurations, action: :choose_metric, mezuro_configuration_id: "1", id: "1") } | |
7 | - it { should route(:get, '/mezuro_configurations/1/metric_configurations/new'). | |
8 | - to(controller: :metric_configurations, action: :new, mezuro_configuration_id: "1") } | |
5 | + it { should route(:get, '/mezuro_configurations/1/metric_configurations/LOC/Analizo/new'). | |
6 | + to(controller: :metric_configurations, action: :new, mezuro_configuration_id: "1", metric_name: "LOC", base_tool_name: "Analizo") } | |
9 | 7 | it { should route(:get, '/mezuro_configurations/1/metric_configurations'). |
10 | 8 | to(controller: :metric_configurations, action: :index, mezuro_configuration_id: "1") } |
11 | 9 | it { should route(:post, '/mezuro_configurations/1/metric_configurations'). |
... | ... | @@ -19,4 +17,4 @@ describe MetricConfigurationsController do |
19 | 17 | it { should route(:delete, '/mezuro_configurations/1/metric_configurations/1'). |
20 | 18 | to(controller: :metric_configurations, action: :destroy, mezuro_configuration_id: "1", id: "1") } |
21 | 19 | end |
22 | -end | |
23 | 20 | \ No newline at end of file |
21 | +end | ... | ... |
spec/routing/mezuro_configuration_routing_spec.rb
... | ... | @@ -4,23 +4,19 @@ describe MezuroConfigurationsController do |
4 | 4 | describe "routing" do |
5 | 5 | it { should route(:get, '/mezuro_configurations/new'). |
6 | 6 | to(controller: :mezuro_configurations, action: :new) } |
7 | - | |
8 | 7 | it { should route(:get, '/mezuro_configurations'). |
9 | 8 | to(controller: :mezuro_configurations, action: :index) } |
10 | - | |
11 | 9 | it { should route(:post, '/mezuro_configurations'). |
12 | 10 | to(controller: :mezuro_configurations, action: :create) } |
13 | - | |
14 | 11 | it { should route(:get, '/mezuro_configurations/1'). |
15 | 12 | to(controller: :mezuro_configurations, action: :show, id: "1") } |
16 | - | |
17 | 13 | it { should route(:get, '/mezuro_configurations/1/edit'). |
18 | 14 | to(controller: :mezuro_configurations, action: :edit, id: "1") } |
19 | - | |
20 | 15 | it { should route(:put, '/mezuro_configurations/1'). |
21 | 16 | to(controller: :mezuro_configurations, action: :update, id: "1") } |
22 | - | |
23 | 17 | it { should route(:delete, '/mezuro_configurations/1'). |
24 | 18 | to(controller: :mezuro_configurations, action: :destroy, id: "1") } |
19 | + it { should route(:get, '/mezuro_configurations/1/metric_configurations/choose_metric'). | |
20 | + to(controller: :metric_configurations, action: :choose_metric, mezuro_configuration_id: "1") } | |
25 | 21 | end |
26 | 22 | end | ... | ... |