Commit 9174ef492444dc066ef8e51ba3cdb0af9b3d4018

Authored by Heitor
Committed by Rafael Manzo
1 parent cbb5c943

WIP: Fixing compound metric configuration create acceptance test

Signed off by: Diego Araújo <diegoamc90@gmail.com>
app/controllers/compound_metric_configurations_controller.rb
@@ -3,7 +3,7 @@ class CompoundMetricConfigurationsController &lt; BaseMetricConfigurationsControlle @@ -3,7 +3,7 @@ class CompoundMetricConfigurationsController &lt; BaseMetricConfigurationsControlle
3 3
4 def create 4 def create
5 super 5 super
6 - metric_configuration.metric_snapshot.compound = true 6 + metric_configuration.metric.type = "CompoundMetricSnapshot"
7 respond_to do |format| 7 respond_to do |format|
8 create_and_redir(format) 8 create_and_redir(format)
9 end 9 end
@@ -40,6 +40,7 @@ class CompoundMetricConfigurationsController &lt; BaseMetricConfigurationsControlle @@ -40,6 +40,7 @@ class CompoundMetricConfigurationsController &lt; BaseMetricConfigurationsControlle
40 end 40 end
41 41
42 def update_metric_configuration (new_metric_configuration) 42 def update_metric_configuration (new_metric_configuration)
  43 + @kalibro_configuration_id = params[:kalibro_configuration_id]
43 @compound_metric_configuration = new_metric_configuration 44 @compound_metric_configuration = new_metric_configuration
44 end 45 end
45 46
@@ -56,7 +57,7 @@ class CompoundMetricConfigurationsController &lt; BaseMetricConfigurationsControlle @@ -56,7 +57,7 @@ class CompoundMetricConfigurationsController &lt; BaseMetricConfigurationsControlle
56 57
57 set_metric_configurations 58 set_metric_configurations
58 format.html { render action: destiny_action } 59 format.html { render action: destiny_action }
59 - format.json { render json: @compound_metric_configuration.errors, status: :unprocessable_entity } 60 + format.json { render json: @compound_metric_configuration.kalibro_errors, status: :unprocessable_entity }
60 end 61 end
61 62
62 #Code extracted from create action 63 #Code extracted from create action
app/views/compound_metric_configurations/_created_metric.html.erb
1 <tr> 1 <tr>
2 <td><%= metric_configuration.metric.name %></td> 2 <td><%= metric_configuration.metric.name %></td>
3 - <td><%= metric_configuration.code %></td>  
4 -</tr>  
5 \ No newline at end of file 3 \ No newline at end of file
  4 + <td><%= metric_configuration.metric.code %></td>
  5 +</tr>
app/views/compound_metric_configurations/_form.html.erb
@@ -8,22 +8,6 @@ @@ -8,22 +8,6 @@
8 8
9 <div class="form-row"> 9 <div class="form-row">
10 <div class="field-container"> 10 <div class="field-container">
11 - <%= f.label :code, class: 'control-label' %>  
12 - <%= f.text_field :code, :required => true, class: 'text-field form-control' %>  
13 - </div>  
14 - <div class="help-container">  
15 - <p>  
16 - A variable that holds the value of a metric calculation. It can be used in the script of another compound metric.  
17 - </p>  
18 - <p>  
19 - Example:  
20 - Code foo := 10  
21 - </p>  
22 - </div>  
23 - </div>  
24 -  
25 - <div class="form-row">  
26 - <div class="field-container">  
27 <%= f.label :weight, class: 'control-label' %> 11 <%= f.label :weight, class: 'control-label' %>
28 <%= f.text_field :weight, :required => true, class: 'text-field form-control' %> 12 <%= f.text_field :weight, :required => true, class: 'text-field form-control' %>
29 </div> 13 </div>
@@ -53,4 +37,4 @@ @@ -53,4 +37,4 @@
53 </div> 37 </div>
54 <br> 38 <br>
55 <%= f.submit 'Save', class: 'btn btn-primary' %> 39 <%= f.submit 'Save', class: 'btn btn-primary' %>
56 -<%= link_to 'Back', kalibro_configuration_path(@compound_metric_configuration.configuration_id), class: 'btn btn-default' %> 40 +<%= link_to 'Back', kalibro_configuration_path(@kalibro_configuration_id), class: 'btn btn-default' %>
app/views/compound_metric_configurations/_metric_options.html.erb
@@ -45,4 +45,20 @@ @@ -45,4 +45,20 @@
45 </p> 45 </p>
46 </div> 46 </div>
47 </div> 47 </div>
  48 +
  49 + <div class="form-row">
  50 + <div class="field-container">
  51 + <%= f.label :code, class: 'control-label' %>
  52 + <%= f.text_field :code, :required => true, class: 'text-field form-control' %>
  53 + </div>
  54 + <div class="help-container">
  55 + <p>
  56 + A variable that holds the value of a metric calculation. It can be used in the script of another compound metric.
  57 + </p>
  58 + <p>
  59 + Example:
  60 + Code foo := 10
  61 + </p>
  62 + </div>
  63 + </div>
48 <%= f.hidden_field(:compound, { value: "true"}) %> 64 <%= f.hidden_field(:compound, { value: "true"}) %>
app/views/compound_metric_configurations/new.html.erb
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 6
7 <br> 7 <br>
8 8
9 -<%= form_for(@compound_metric_configuration, :url => kalibro_configuration_compound_metric_configurations_path(@compound_metric_configuration.configuration_id)) do |f| %> 9 +<%= form_for(@compound_metric_configuration, :url => kalibro_configuration_compound_metric_configurations_path(@kalibro_configuration_id)) do |f| %>
10 <%= render partial: 'form', locals: {f: f} %> 10 <%= render partial: 'form', locals: {f: f} %>
11 <% end %> 11 <% end %>
12 12
features/compound_metric_configuration/create.feature
@@ -24,9 +24,10 @@ Feature: Compound Metric Configuration Creation @@ -24,9 +24,10 @@ Feature: Compound Metric Configuration Creation
24 And I set the select field "Scope" as "Class" 24 And I set the select field "Scope" as "Class"
25 And I set the select field "Reading Group" as "Scholar" 25 And I set the select field "Reading Group" as "Scholar"
26 And I press the Save button 26 And I press the Save button
  27 + And I take a picture of the page
27 When I click the show link of "My Compound Metric" 28 When I click the show link of "My Compound Metric"
28 Then I should see "My Compound Metric" 29 Then I should see "My Compound Metric"
29 And I should see "mcm" 30 And I should see "mcm"
30 And I should see "8" 31 And I should see "8"
31 And I should see "AVERAGE" 32 And I should see "AVERAGE"
32 -  
33 \ No newline at end of file 33 \ No newline at end of file
  34 +
features/step_definitions/compound_metric_configuration_steps.rb
@@ -3,7 +3,7 @@ Given(/^I see the sample metric configuration name$/) do @@ -3,7 +3,7 @@ Given(/^I see the sample metric configuration name$/) do
3 end 3 end
4 4
5 Given(/^I see the sample metric configuration code$/) do 5 Given(/^I see the sample metric configuration code$/) do
6 - expect(page).to have_content(@metric_configuration.code) 6 + expect(page).to have_content(@metric_configuration.metric.code)
7 end 7 end
8 8
9 Given(/^I have a sample compound metric configuration within the given mezuro configuration$/) do 9 Given(/^I have a sample compound metric configuration within the given mezuro configuration$/) do