From b994b87194ece5325abc38c260003e20a3d18700 Mon Sep 17 00:00:00 2001 From: Didier Lafforgue Date: Wed, 29 Feb 2012 02:11:56 +0100 Subject: [PATCH] fixing cucumber tests (still wip) --- features/backoffice/contents.feature | 22 +++++++++---------- features/backoffice/snippets.feature | 9 ++++---- .../step_definitions/content_types_steps.rb | 2 +- features/step_definitions/snippet_steps.rb | 8 +++++++ .../step_definitions/theme_asset_steps.rb | 1 - features/support/paths.rb | 6 ++--- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/features/backoffice/contents.feature b/features/backoffice/contents.feature index 2f6960d4..ef3ccf6f 100644 --- a/features/backoffice/contents.feature +++ b/features/backoffice/contents.feature @@ -23,27 +23,27 @@ Scenario: Then I should see "My sexy project" Scenario: Add a new entry - When I go to the "Projects" model edition page - And I follow "new item" - Then I should see "Projects — new item" + When I go to the "Projects" model list page + And I follow "new entry" + Then I should see "Projects — new entry" When I fill in "Name" with "My other sexy project" And I fill in "Description" with "Lorem ipsum...." And I press "Create" - Then I should see "Content was successfully created." + Then I should see "Entry was successfully created." Scenario: Add an invalid entry - When I go to the "Projects" model edition page - And I follow "new item" + When I go to the "Projects" model list page + And I follow "new entry" And I fill in "Description" with "Lorem ipsum...." And I press "Create" - Then I should not see "Content was successfully created." + Then I should not see "Entry was successfully created." Scenario: Update an existing entry When I go to the "Projects" model list page And I follow "My sexy project" When I fill in "Name" with "My other sexy project (UPDATED)" And I press "Save" - Then I should see "Content was successfully updated." + Then I should see "Entry was successfully updated." When I go to the "Projects" model list page Then I should see "My other sexy project (UPDATED)" @@ -52,12 +52,12 @@ Scenario: Update an invalid entry And I follow "My sexy project" When I fill in "Name" with "" And I press "Save" - Then I should not see "Content was successfully updated." + Then I should not see "Entry was successfully updated." Scenario: Destroy an entry When I go to the "Projects" model list page - And I follow image link "Delete" - Then I should see "Content was successfully deleted." + And I follow "x" + Then I should see "Entry was successfully deleted." And I should not see "My sexy project" Scenario: Group entries by category diff --git a/features/backoffice/snippets.feature b/features/backoffice/snippets.feature index 5b99d185..5afcc360 100644 --- a/features/backoffice/snippets.feature +++ b/features/backoffice/snippets.feature @@ -15,7 +15,7 @@ Background: "yield" """ -Scenario: Creating a Snippet +Scenario: Creating a snippet When I go to theme assets And I follow "new snippet" And I fill in "Name" with "Banner" @@ -25,14 +25,15 @@ Scenario: Creating a Snippet Then I should see "Snippet was successfully created." And I should have "banner" in the banner snippet -Scenario: Updating a Snippet that includes another snippet +@javascript +Scenario: Updating a snippet that includes another snippet Given a snippet named "other" with the template: """ "other" """ When I go to theme assets And I follow "yield" - And I fill in "snippet_template" with "{% include 'other' %}" + And I change the snippet template to "{% include other %}" And I press "Save" Then I should see "Snippet was successfully updated." - And I should have "{% include 'other' %}" in the yield snippet + And I should have "{% include other %}" in the yield snippet diff --git a/features/step_definitions/content_types_steps.rb b/features/step_definitions/content_types_steps.rb index 6390ed9c..8451a3d8 100644 --- a/features/step_definitions/content_types_steps.rb +++ b/features/step_definitions/content_types_steps.rb @@ -55,7 +55,7 @@ end When %r{^I change the presentation of the "([^"]*)" model by grouping items by "([^"]*)"$} do |name, field| content_type = Locomotive::ContentType.where(:name => name).first field = content_type.entries_custom_fields.detect { |f| f.label == field } - content_type.group_by_field_name = field._name + content_type.group_by_field_id = field._id content_type.save.should be_true end diff --git a/features/step_definitions/snippet_steps.rb b/features/step_definitions/snippet_steps.rb index 830d9e40..c2522a27 100644 --- a/features/step_definitions/snippet_steps.rb +++ b/features/step_definitions/snippet_steps.rb @@ -13,6 +13,14 @@ Given /^a snippet named "([^"]*)" with the template:$/ do |name, template| @snippet = create_snippet(name, template) end +When /^I change the snippet template to "([^"]*)"$/ do |code| + page.evaluate_script "window.application_view.view.editor.setValue('#{code}')" +end + +# Then /^I should see "([^"]*)" as the snippet template$/ do |code| +# find(:css, "#theme_asset_plain_text").value.should == code +# end + # checks to see if a string is in the slug Then /^I should have "(.*)" in the (.*) snippet/ do |content, snippet_slug| snippet = @site.snippets.where(:slug => snippet_slug).first diff --git a/features/step_definitions/theme_asset_steps.rb b/features/step_definitions/theme_asset_steps.rb index d23614e1..8caeafcc 100644 --- a/features/step_definitions/theme_asset_steps.rb +++ b/features/step_definitions/theme_asset_steps.rb @@ -30,7 +30,6 @@ Given /^I have an image theme asset named "([^"]*)"$/ do |name| @asset.save! end - # other stuff # change the template diff --git a/features/support/paths.rb b/features/support/paths.rb index 71315e77..e71b3239 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -35,9 +35,9 @@ module NavigationHelpers when /the "(.*)" model creation page/ content_type = Locomotive::Site.first.content_types.where(:name => $1).first new_content_entry_path(content_type.slug) - when /the "(.*)" model edition page/ - content_type = Locomotive::Site.first.content_types.where(:name => $1).first - edit_content_entries_path(content_type) + # when /the "(.*)" model edition page/ + # content_type = Locomotive::Site.first.content_types.where(:name => $1).first + # edit_content_entry_path(content_type) # Add more mappings here. # Here is an example that pulls values out of the Regexp: