diff --git a/config/locales/de.yml b/config/locales/de.yml index 7390e4832a..88c66fdafa 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -203,3 +203,6 @@ de: x_entries: one: "1 Eintrag" other: "%{count} Einträge" + + js: + text_are_you_sure: "Sind Sie sicher?" diff --git a/config/locales/en.yml b/config/locales/en.yml index 8bb43824f1..7ff28c9260 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -203,3 +203,6 @@ en: x_entries: one: "1 Entry" other: "%{count} Entries" + + js: + text_are_you_sure: "Are you sure?" diff --git a/features/cost_types/deletion.feature b/features/cost_types/deletion.feature index 2fc120db61..823d39bb49 100644 --- a/features/cost_types/deletion.feature +++ b/features/cost_types/deletion.feature @@ -36,3 +36,10 @@ Feature: Cost type deletion Then the cost type "cost_type1" should be listed as deleted on the index page + @javascript + Scenario: Click on the "delete" link for a cost type + When I go to the index page of cost types + + Then I expect to click "OK" on a confirmation box saying "Are you sure?" + And I click the delete link for the cost type "cost_type1" + And the confirmation box should have been displayed diff --git a/features/step_definitions/cost_type_steps.rb b/features/step_definitions/cost_type_steps.rb index 6c23d9b840..93f6aa0be2 100644 --- a/features/step_definitions/cost_type_steps.rb +++ b/features/step_definitions/cost_type_steps.rb @@ -47,6 +47,29 @@ When(/^I delete the cost type "(.*?)"$/) do |name| end end +When(/^I click the delete link for the cost type "(.*?)"$/) do |name| + ct = CostType.find_by_name name + + within ("#delete_cost_type_#{ct.id}") do + find('a.submit_cost_type').click + end +end + +When /^I expect to click "([^"]*)" on a confirmation box saying "([^"]*)"$/ do |option, message| + retval = (option == 'OK') ? 'true' : 'false' + page.evaluate_script("window.confirm = function (msg) { + document.cookie = msg + return #{retval} + }") + @expected_message = message.gsub("\\n", "\n") +end + +When /^the confirmation box should have been displayed$/ do + assert page.evaluate_script('document.cookie').include?(@expected_message), + "Expected confirm box with message: '#{@expected_message}'" + + " got: '#{page.evaluate_script('document.cookie')}'" +end + Then(/^the cost type "(.*?)" should not be listed on the index page$/) do |name| if has_css?(".cost_types")