From ecf6998a6849885278e1b34e71bf2babb11c025a Mon Sep 17 00:00:00 2001 From: Didier Lafforgue Date: Fri, 17 Feb 2012 09:56:11 +0100 Subject: [PATCH] fix the cucumber tests for pages --- features/backoffice/pages.feature | 5 ++--- features/step_definitions/page_steps.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/features/backoffice/pages.feature b/features/backoffice/pages.feature index ad5ae4ca..7c9f5254 100644 --- a/features/backoffice/pages.feature +++ b/features/backoffice/pages.feature @@ -23,13 +23,12 @@ Scenario: Creating a valid page Then I should see "Page was successfully created." And I should have "{% extends 'parent' %}" in the test page -@wip @javascript Scenario: Updating a valid page When I go to pages And I follow "Home page" - And I fill in "page_title" with "Home page !" - And I fill in "Raw template" with "My new content is here" + And I change the page title with "Home page !" + And I change the page template with "My new content is here" And I press "Save" Then I should see "Page was successfully updated." And I should have "My new content is here" in the index page diff --git a/features/step_definitions/page_steps.rb b/features/step_definitions/page_steps.rb index 8cb6bff1..d8c5c5f7 100644 --- a/features/step_definitions/page_steps.rb +++ b/features/step_definitions/page_steps.rb @@ -17,6 +17,17 @@ Given /^a page named "([^"]*)" with the template:$/ do |page_slug, template| @page = create_content_page(page_slug, '', template) end +# change the title +When /^I change the page title with "([^"]*)"$/ do |page_title| + page.evaluate_script "window.prompt = function() { return '#{page_title}'; }" + page.find('h2 a.editable').click +end + +# change the template +When /^I change the page template with "([^"]*)"$/ do |page_template| + page.evaluate_script "window.application_view.view.model.set({ 'raw_template': '#{page_template}' })" +end + # update a page When /^I update the "([^"]*)" page with the template:$/ do |page_slug, template| page = @site.pages.where(:slug => page_slug).first