Commit 4e5d6969b31759a36b9125509119d46a96bc367d
Committed by
Rafael Manzo
1 parent
6ed35a1d
Exists in
colab
and in
4 other branches
Started implementation of metric configurations
Signed off by: Diego Araújo <diegoamc90@gmail.com>
Showing
7 changed files
with
70 additions
and
8 deletions
Show diff stats
... | ... | @@ -0,0 +1,13 @@ |
1 | +class MetricConfiguration < KalibroGem::Entities::MetricConfiguration | |
2 | + include KalibroRecord | |
3 | + | |
4 | + attr_accessor :code, :weight, :aggregation_form, :metric_name, :metric_scope, :metric_origin | |
5 | + | |
6 | + validates :code, presence: true, kalibro_uniqueness: true | |
7 | + validates :weight, presence: true | |
8 | + validates :aggregation_form, presence: true | |
9 | + validates :metric_name, presence: true | |
10 | + validates :metric_scope, presence: true | |
11 | + validates :metric_origin, presence: true | |
12 | + | |
13 | +end | ... | ... |
app/models/mezuro_configuration.rb
... | ... | @@ -7,6 +7,6 @@ class MezuroConfiguration < KalibroGem::Entities::Configuration |
7 | 7 | validates :name, presence: true, kalibro_uniqueness: true |
8 | 8 | |
9 | 9 | def metric_configurations |
10 | - KalibroGem::Entities::MetricConfiguration.metric_configurations_of(self.id) | |
10 | + MetricConfiguration.metric_configurations_of(self.id) | |
11 | 11 | end |
12 | 12 | end | ... | ... |
app/views/mezuro_configurations/show.html.erb
... | ... | @@ -7,11 +7,29 @@ |
7 | 7 | <%= @configuration.description %> |
8 | 8 | </p> |
9 | 9 | |
10 | -<hr /> | |
10 | +<hr> | |
11 | + | |
12 | +<h2> Metrics </h2> | |
13 | + | |
14 | +<% if configuration_owner? @configuration.id %> | |
15 | + <%= link_to 'Add Metric', new_mezuro_configuration_metric_configuration_path(@configuration), class: 'btn btn-info' %> | |
16 | +<% end %> | |
17 | + | |
18 | +<table class="table table-hover"> | |
19 | + <thead> | |
20 | + <tr> | |
21 | + <th>Metric Name</th> | |
22 | + <th>Code</th> | |
23 | + <th>Weight</th> | |
24 | + </tr> | |
25 | + </thead> | |
26 | +</table> | |
27 | + | |
28 | +<hr> | |
11 | 29 | |
12 | 30 | <p> |
13 | - <%= link_to 'Back', mezuro_configurations_path, class: 'btn btn-default' %> | |
14 | - <% if configuration_owner? @configuration.id %> | |
15 | - <%= link_to 'Destroy configuration', mezuro_configuration_path(@configuration.id), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %> | |
16 | - <% end %> | |
31 | + <%= link_to 'Back', mezuro_configurations_path, class: 'btn btn-default' %> | |
32 | + <% if configuration_owner? @configuration.id %> | |
33 | + <%= link_to 'Destroy Configuration', mezuro_configuration_path(@configuration.id), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %> | |
34 | + <% end %> | |
17 | 35 | </p> | ... | ... |
config/routes.rb
... | ... | @@ -10,7 +10,11 @@ Mezuro::Application.routes.draw do |
10 | 10 | get '/repositories/:id/process' => 'repositories#process_repository', as: :repository_process |
11 | 11 | end |
12 | 12 | |
13 | - resources :mezuro_configurations | |
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 | |
16 | + put '/metric_configurations/:id' => 'metric_configurations#update', as: :metric_configuration_update | |
17 | + end | |
14 | 18 | |
15 | 19 | resources :reading_groups do |
16 | 20 | resources :readings, except: [:index, :update, :show] | ... | ... |
spec/models/mezuro_configuration_spec.rb
... | ... | @@ -44,7 +44,7 @@ describe MezuroConfiguration do |
44 | 44 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration) } |
45 | 45 | |
46 | 46 | it 'should call metric_configurations_of on the Metric Configuration model' do |
47 | - KalibroGem::Entities::MetricConfiguration.expects(:metric_configurations_of).with(subject.id).returns([metric_configuration]) | |
47 | + MetricConfiguration.expects(:metric_configurations_of).with(subject.id).returns([metric_configuration]) | |
48 | 48 | |
49 | 49 | subject.metric_configurations.should include(metric_configuration) |
50 | 50 | end | ... | ... |
... | ... | @@ -0,0 +1,22 @@ |
1 | +require "spec_helper" | |
2 | + | |
3 | +describe MetricConfigurationsController do | |
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") } | |
9 | + it { should route(:get, '/mezuro_configurations/1/metric_configurations'). | |
10 | + to(controller: :metric_configurations, action: :index, mezuro_configuration_id: "1") } | |
11 | + it { should route(:post, '/mezuro_configurations/1/metric_configurations'). | |
12 | + to(controller: :metric_configurations, action: :create, mezuro_configuration_id: "1") } | |
13 | + it { should route(:get, '/mezuro_configurations/1/metric_configurations/1'). | |
14 | + to(controller: :metric_configurations, action: :show, mezuro_configuration_id: "1", id: "1") } | |
15 | + it { should route(:get, '/mezuro_configurations/1/metric_configurations/1/edit'). | |
16 | + to(controller: :metric_configurations, action: :edit, mezuro_configuration_id: "1", id: "1") } | |
17 | + it { should route(:put, '/mezuro_configurations/1/metric_configurations/1'). | |
18 | + to(controller: :metric_configurations, action: :update, mezuro_configuration_id: "1", id: "1") } | |
19 | + it { should route(:delete, '/mezuro_configurations/1/metric_configurations/1'). | |
20 | + to(controller: :metric_configurations, action: :destroy, mezuro_configuration_id: "1", id: "1") } | |
21 | + end | |
22 | +end | |
0 | 23 | \ No newline at end of file | ... | ... |