Commit 1d36a3dedea5a0901b94854b25d0815888d97a34
1 parent
92674958
Exists in
colab
and in
4 other branches
Changing the redirection path after create, edit or delete on a range
Acceptance tests for edit and delete pending Signed off by: Diego Araújo <diegoamc90@gmail.com>
Showing
3 changed files
with
39 additions
and
6 deletions
Show diff stats
app/controllers/kalibro_ranges_controller.rb
... | ... | @@ -23,8 +23,7 @@ class KalibroRangesController < ApplicationController |
23 | 23 | def destroy |
24 | 24 | @kalibro_range.destroy |
25 | 25 | respond_to do |format| |
26 | - format.html { redirect_to kalibro_configuration_metric_configuration_path( | |
27 | - @kalibro_configuration_id, @metric_configuration_id) } | |
26 | + format_metric_configuration_path(format, "Range was successfully edited.") | |
28 | 27 | format.json { head :no_content } |
29 | 28 | end |
30 | 29 | end |
... | ... | @@ -37,8 +36,7 @@ class KalibroRangesController < ApplicationController |
37 | 36 | respond_to do |format| |
38 | 37 | @kalibro_range.metric_configuration_id = @metric_configuration_id |
39 | 38 | if @kalibro_range.update(kalibro_range_params) |
40 | - format.html { redirect_to kalibro_configuration_metric_configuration_path( | |
41 | - @kalibro_configuration_id, @metric_configuration_id), notice: 'Range was successfully edited.' } | |
39 | + format_metric_configuration_path(format, 'Range was successfully edited.') | |
42 | 40 | format.json { head :no_content } |
43 | 41 | else |
44 | 42 | failed_action(format, 'edit') |
... | ... | @@ -55,13 +53,23 @@ class KalibroRangesController < ApplicationController |
55 | 53 | |
56 | 54 | def create_and_redir(format) |
57 | 55 | if @kalibro_range.save |
58 | - format.html { redirect_to kalibro_configuration_metric_configuration_path( | |
59 | - @kalibro_configuration_id, @metric_configuration_id), notice: 'Range was successfully created.' } | |
56 | + format_metric_configuration_path(format, 'Range was successfully created.') | |
60 | 57 | else |
61 | 58 | failed_action(format, 'new') |
62 | 59 | end |
63 | 60 | end |
64 | 61 | |
62 | + def format_metric_configuration_path(format, notice) | |
63 | + @metric_configuration = MetricConfiguration.find @kalibro_range.metric_configuration_id | |
64 | + if(@metric_configuration.metric.is_a? KalibroClient::Entities::Miscellaneous::CompoundMetric) | |
65 | + format.html { redirect_to kalibro_configuration_compound_metric_configuration_path( | |
66 | + @kalibro_configuration_id, @metric_configuration_id), notice: notice } | |
67 | + else | |
68 | + format.html { redirect_to kalibro_configuration_metric_configuration_path( | |
69 | + @kalibro_configuration_id, @metric_configuration_id), notice: notice } | |
70 | + end | |
71 | + end | |
72 | + | |
65 | 73 | def failed_action(format, destiny_action) |
66 | 74 | before_form |
67 | 75 | format.html { render action: destiny_action } | ... | ... |
features/kalibro_range/create.feature
... | ... | @@ -186,3 +186,23 @@ Feature: Create Kalibro Range |
186 | 186 | Then I should be at metric configuration sample page |
187 | 187 | And I should see "666" |
188 | 188 | And I should see "INF" |
189 | + | |
190 | + @kalibro_configuration_restart @javascript | |
191 | + Scenario: Should create a kalibro range and redirect to the compound metric configuration page | |
192 | + Given I am a regular user | |
193 | + And I am signed in | |
194 | + And I own a sample configuration | |
195 | + And I own a sample reading group | |
196 | + And I have a sample metric configuration within the given mezuro configuration | |
197 | + And I have a sample compound metric configuration within the given mezuro configuration | |
198 | + And I have a sample reading within the sample reading group labeled "My Reading" | |
199 | + And I am at the New Range page for the compound metric configuration | |
200 | + And I click the -∞ link | |
201 | + And I click the ∞ link | |
202 | + And I fill the Comments field with "My Comment" | |
203 | + And I set the select field "Reading" as "My Reading" | |
204 | + When I press the Save button | |
205 | + Then I should be at compound metric configuration sample page | |
206 | + And I should see "-INF" | |
207 | + And I should see "INF" | |
208 | + | ... | ... |
features/step_definitions/kalibro_range_steps.rb
... | ... | @@ -25,6 +25,11 @@ When(/^I am at the New Range page$/) do |
25 | 25 | visit kalibro_configuration_metric_configuration_new_kalibro_range_path(@metric_configuration.kalibro_configuration_id, @metric_configuration.id) |
26 | 26 | end |
27 | 27 | |
28 | +Given(/^I am at the New Range page for the compound metric configuration$/) do | |
29 | + visit kalibro_configuration_metric_configuration_new_kalibro_range_path(@compound_metric_configuration.kalibro_configuration_id, @compound_metric_configuration.id) | |
30 | +end | |
31 | + | |
32 | + | |
28 | 33 | Then(/^I should be at the New Range page$/) do |
29 | 34 | expect(page).to have_content("New Range") |
30 | 35 | expect(page).to have_content("Beginning") | ... | ... |