diff --git a/app/controllers/kalibro_ranges_controller.rb b/app/controllers/kalibro_ranges_controller.rb index 5cce883..deda43c 100644 --- a/app/controllers/kalibro_ranges_controller.rb +++ b/app/controllers/kalibro_ranges_controller.rb @@ -23,7 +23,7 @@ class KalibroRangesController < ApplicationController def destroy @kalibro_range.destroy respond_to do |format| - format_metric_configuration_path(format, "Range was successfully edited.") + format_metric_configuration_path(format, "Range was successfully destroyed.") format.json { head :no_content } end end diff --git a/features/kalibro_range/deletion.feature b/features/kalibro_range/deletion.feature index 98d7089..0db70a0 100644 --- a/features/kalibro_range/deletion.feature +++ b/features/kalibro_range/deletion.feature @@ -4,7 +4,7 @@ Feature: Kalibro Range Deletion The system should have an interface to it @kalibro_configuration_restart - Scenario: Should delete a kalibro range that I own + Scenario: Should delete a kalibro range I own which belongs to a metric configuration Given I am a regular user And I am signed in And I own a sample configuration @@ -18,6 +18,20 @@ Feature: Kalibro Range Deletion And I should see "There are no Ranges yet!" @kalibro_configuration_restart + Scenario: Should delete a kalibro range I own which belongs to a compound metric configuration + Given I am a regular user + And I am signed in + And I own a sample configuration + And I have a sample reading group + And I have a sample compound metric configuration within the given mezuro configuration + And I have a sample reading within the sample reading group labeled "My Reading" + And I have a sample range within the sample compound metric configuration + And I am at the sample compound metric configuration page + When I click the Destroy link + Then I should be at compound metric configuration sample page + And I should see "There are no Ranges yet!" + + @kalibro_configuration_restart Scenario: Should not see the destroy kalibro range link in the kalibro range that I do not own Given I am a regular user And I am signed in diff --git a/features/kalibro_range/edit.feature b/features/kalibro_range/edit.feature index c9a0cea..22b0e05 100644 --- a/features/kalibro_range/edit.feature +++ b/features/kalibro_range/edit.feature @@ -4,7 +4,7 @@ Feature: Kalibro Range Edit I should be able to edit my kalibro ranges @kalibro_configuration_restart - Scenario: editing a kalibro range successfully + Scenario: successfully editing a kalibro range which belongs to a metric configuration Given I am a regular user And I am signed in And I own a sample configuration @@ -22,6 +22,24 @@ Feature: Kalibro Range Edit Then I should see "2.2" @kalibro_configuration_restart + Scenario: successfully editing a kalibro range which belongs to a compound metric configuration + Given I am a regular user + And I am signed in + And I own a sample configuration + And I own a sample reading group + And I have a sample compound metric configuration within the given mezuro configuration + And I have a sample reading within the sample reading group labeled "My Reading" + And I have a sample range within the sample compound metric configuration with beginning "1.1" + And I am at the Edit Kalibro Range page for the compound metric configuration + And the select field "Reading" is set as "My Reading" + And the field "Beginning" should be filled with "1.1" + And the field "End" should be filled with "5.1" + And the field "Comments" should be filled with "Comment" + When I fill the Beginning field with "2.2" + And I press the Save button + Then I should see "2.2" + + @kalibro_configuration_restart Scenario: editing a kalibro range with blank fields Given I am a regular user And I am signed in diff --git a/features/step_definitions/compound_metric_configuration_steps.rb b/features/step_definitions/compound_metric_configuration_steps.rb index 832abc5..4012ffa 100644 --- a/features/step_definitions/compound_metric_configuration_steps.rb +++ b/features/step_definitions/compound_metric_configuration_steps.rb @@ -26,6 +26,12 @@ When(/^I click the show link of "(.*?)"$/) do |name| page.find('tr', :text => name).click_link('Show') end +When(/^I am at the sample compound metric configuration page$/) do + visit kalibro_configuration_compound_metric_configuration_path(@compound_metric_configuration.kalibro_configuration_id, @compound_metric_configuration.id) + expect(page).to have_content(@compound_metric_configuration.metric.name) + expect(page).to have_content("Ranges") +end + Then(/^I should be at compound metric configuration sample page$/) do expect(page).to have_content(@compound_metric_configuration.metric.name) expect(page).to have_content("Ranges") diff --git a/features/step_definitions/kalibro_range_steps.rb b/features/step_definitions/kalibro_range_steps.rb index cbb1c01..d359766 100644 --- a/features/step_definitions/kalibro_range_steps.rb +++ b/features/step_definitions/kalibro_range_steps.rb @@ -3,10 +3,19 @@ Given(/^I have a sample range within the sample metric configuration with beginn reading_id: @reading.id}) end +Given(/^I have a sample range within the sample compound metric configuration with beginning "(.*?)"$/) do |beginning| + @kalibro_range = FactoryGirl.create(:kalibro_range, {beginning: beginning, metric_configuration_id: @compound_metric_configuration.id, + reading_id: @reading.id}) +end + Given(/^I am at the Edit Kalibro Range page$/) do visit edit_kalibro_configuration_metric_configuration_kalibro_range_path(@metric_configuration.kalibro_configuration_id, @metric_configuration.id, @kalibro_range.id) end +Given(/^I am at the Edit Kalibro Range page for the compound metric configuration$/) do + visit edit_kalibro_configuration_metric_configuration_kalibro_range_path(@compound_metric_configuration.kalibro_configuration_id, @compound_metric_configuration.id, @kalibro_range.id) +end + Given(/^the select field "(.*?)" is set as "(.*?)"$/) do |field, text| select text, from: field end diff --git a/spec/controllers/kalibro_ranges_controller_spec.rb b/spec/controllers/kalibro_ranges_controller_spec.rb index bd5aec6..ea86a66 100644 --- a/spec/controllers/kalibro_ranges_controller_spec.rb +++ b/spec/controllers/kalibro_ranges_controller_spec.rb @@ -49,8 +49,9 @@ describe KalibroRangesController, :type => :controller do context 'with valid fields' do before :each do KalibroRange.any_instance.expects(:save).returns(true) + MetricConfiguration.expects(:find).with(kalibro_range.metric_configuration_id).returns(metric_configuration) - post :create, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: metric_configuration.id, kalibro_range: kalibro_range_params + post :create, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: kalibro_range.metric_configuration_id, kalibro_range: kalibro_range_params end it { is_expected.to respond_with(:redirect) } @@ -81,6 +82,7 @@ describe KalibroRangesController, :type => :controller do subject.expects(:metric_configuration_owner?).returns true kalibro_range.expects(:destroy) subject.expects(:find_resource).with(KalibroRange, kalibro_range.id).returns(kalibro_range) + MetricConfiguration.expects(:find).with(kalibro_range.metric_configuration_id).returns(metric_configuration) delete :destroy, id: kalibro_range.id.to_s, metric_configuration_id: metric_configuration.id.to_s, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s end @@ -172,6 +174,7 @@ describe KalibroRangesController, :type => :controller do before :each do subject.expects(:find_resource).with(KalibroRange, kalibro_range.id).returns(kalibro_range) KalibroRange.any_instance.expects(:update).with(kalibro_range_params).returns(true) + MetricConfiguration.expects(:find).with(kalibro_range.metric_configuration_id).returns(metric_configuration) post :update, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, id: kalibro_range.id, metric_configuration_id: metric_configuration.id, kalibro_range: kalibro_range_params end -- libgit2 0.21.2