Commit afb225b94ab3c41e454440e58d3289c68f3728c6
Committed by
Rafael Manzo
1 parent
8b2e3e42
Exists in
colab
and in
4 other branches
WIP: Working on CompoundMetric's edit acceptance tests.
Signed off by: Daniel Alves <danpaulalves@gmail.com>
Showing
7 changed files
with
12 additions
and
15 deletions
Show diff stats
app/controllers/compound_metric_configurations_controller.rb
| ... | ... | @@ -17,7 +17,8 @@ class CompoundMetricConfigurationsController < BaseMetricConfigurationsControlle |
| 17 | 17 | |
| 18 | 18 | def edit |
| 19 | 19 | @compound_metric_configuration = @metric_configuration |
| 20 | - @compound_metric_configuration.kalibro_configuration_id = params[:kalibro_configuration_id].to_i | |
| 20 | + @kalibro_configuration_id = params[:kalibro_configuration_id].to_i | |
| 21 | + @compound_metric_configuration.kalibro_configuration_id = @kalibro_configuration_id | |
| 21 | 22 | end |
| 22 | 23 | |
| 23 | 24 | def update |
| ... | ... | @@ -46,11 +47,6 @@ class CompoundMetricConfigurationsController < BaseMetricConfigurationsControlle |
| 46 | 47 | |
| 47 | 48 | private |
| 48 | 49 | |
| 49 | - # Never trust parameters from the scary internet, only allow the white list through. | |
| 50 | - def metric_configuration_params | |
| 51 | - params[:metric_configuration] | |
| 52 | - end | |
| 53 | - | |
| 54 | 50 | # Duplicated code on create and update actions extracted here |
| 55 | 51 | def failed_action(format, destiny_action) |
| 56 | 52 | @kalibro_configuration_id = params[:kalibro_configuration_id] | ... | ... |
app/views/compound_metric_configurations/_form.html.erb
| ... | ... | @@ -19,8 +19,9 @@ |
| 19 | 19 | </div> |
| 20 | 20 | |
| 21 | 21 | <% if @compound_metric_configuration.persisted? %> |
| 22 | - <%= hidden_field_tag(:reading_group_id, @metric_configuration.reading_group_id) %> | |
| 23 | - <%= hidden_field_tag(:kalibro_configuration_id, @metric_configuration.kalibro_configuration_id) %> | |
| 22 | + <%= hidden_field_tag(:reading_group_id, @compound_metric_configuration.reading_group_id) %> | |
| 23 | + <%= hidden_field_tag(:kalibro_configuration_id, @compound_metric_configuration.kalibro_configuration_id) %> | |
| 24 | + <%= link_to 'Back', kalibro_configuration_path(@compound_metric_configuration.kalibro_configuration_id), class: 'btn btn-default' %> | |
| 24 | 25 | <% else %> |
| 25 | 26 | <div class="form-row"> |
| 26 | 27 | <div class="field-container"> |
| ... | ... | @@ -34,9 +35,9 @@ |
| 34 | 35 | </div> |
| 35 | 36 | </div> |
| 36 | 37 | <%= f.hidden_field(:kalibro_configuration_id, value: @kalibro_configuration_id) %> |
| 38 | + <%= link_to 'Back', kalibro_configuration_path(@kalibro_configuration_id), class: 'btn btn-default' %> | |
| 37 | 39 | <% end %> |
| 38 | 40 | </div> |
| 39 | 41 | </div> |
| 40 | 42 | <br> |
| 41 | 43 | <%= f.submit 'Save', class: 'btn btn-primary' %> |
| 42 | -<%= link_to 'Back', kalibro_configuration_path(@kalibro_configuration_id), class: 'btn btn-default' %> | ... | ... |
app/views/compound_metric_configurations/edit.html.erb
| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | |
| 7 | 7 | <br> |
| 8 | 8 | |
| 9 | -<%= form_for(@compound_metric_configuration, :url => kalibro_configuration_compound_metric_configuration_update_url(@compound_metric_configuration.configuration_id, @compound_metric_configuration.id), method: :put) do |f| %> | |
| 9 | +<%= form_for(@compound_metric_configuration, :url => kalibro_configuration_compound_metric_configuration_update_url(@compound_metric_configuration.kalibro_configuration_id, @compound_metric_configuration.id), method: :put) do |f| %> | |
| 10 | 10 | <%= render partial: 'form', locals: {f: f} %> |
| 11 | 11 | <% end %> |
| 12 | 12 | ... | ... |
features/compound_metric_configuration/edition.feature
| ... | ... | @@ -51,7 +51,7 @@ Feature: Compound Metric Configuration edition |
| 51 | 51 | And I should see "Weight can't be blank" |
| 52 | 52 | |
| 53 | 53 | |
| 54 | - @kalibro_configuration_restart | |
| 54 | + @kalibro_configuration_restart @javascript | |
| 55 | 55 | Scenario: trying to edit with an existing code |
| 56 | 56 | Given I am a regular user |
| 57 | 57 | And I am signed in |
| ... | ... | @@ -63,4 +63,5 @@ Feature: Compound Metric Configuration edition |
| 63 | 63 | When I visit the sample compound metric configuration edit page |
| 64 | 64 | And I fill the Code field with "Another_Code" |
| 65 | 65 | And I press the Save button |
| 66 | + And I take a picture of the page | |
| 66 | 67 | Then I should see "Code There is already a MetricConfiguration with code Another_Code! Please, choose another one." | ... | ... |
features/step_definitions/compound_metric_configuration_steps.rb
| ... | ... | @@ -11,11 +11,11 @@ Given(/^I have a sample compound metric configuration within the given mezuro co |
| 11 | 11 | end |
| 12 | 12 | |
| 13 | 13 | Given(/^I have another compound metric configuration with code "(.*?)" within the given mezuro configuration$/) do |code| |
| 14 | - @another_compound_metric_configuration = FactoryGirl.create(:compound_metric_configuration, {kalibro_configuration_id: @kalibro_configuration.id, code: code, reading_group_id: @reading_group.id}) | |
| 14 | + @another_compound_metric_configuration = FactoryGirl.create(:compound_metric_configuration, {kalibro_configuration_id: @kalibro_configuration.id, metric: FactoryGirl.build(:compound_metric, code: code), reading_group_id: @reading_group.id}) | |
| 15 | 15 | end |
| 16 | 16 | |
| 17 | 17 | When(/^I visit the sample compound metric configuration edit page$/) do |
| 18 | - visit edit_kalibro_configuration_compound_metric_configuration_path(@compound_metric_configuration.configuration_id, @compound_metric_configuration.id) | |
| 18 | + visit edit_kalibro_configuration_compound_metric_configuration_path(@compound_metric_configuration.kalibro_configuration_id, @compound_metric_configuration.id) | |
| 19 | 19 | end |
| 20 | 20 | |
| 21 | 21 | When(/^I click the edit link of the Coumpound Metric$/) do | ... | ... |
spec/factories/metric_configurations.rb
| ... | ... | @@ -16,7 +16,6 @@ FactoryGirl.define do |
| 16 | 16 | factory :compound_metric_configuration, class: MetricConfiguration do |
| 17 | 17 | metric { FactoryGirl.build(:compound_metric, script: 'native*2;', code: 'compound') } |
| 18 | 18 | weight 1 |
| 19 | - aggregation_form "AVERAGE" | |
| 20 | 19 | reading_group_id 1 |
| 21 | 20 | kalibro_configuration_id 1 |
| 22 | 21 | ... | ... |