Skip to content

Commit

Permalink
Merged changes from branch 0.8.3 as they should be here anyway
Browse files Browse the repository at this point in the history
  • Loading branch information
Yomi Colledge committed Jul 14, 2010
2 parents b6f6752 + 8601137 commit c85a7d0
Show file tree
Hide file tree
Showing 11 changed files with 223 additions and 8 deletions.
164 changes: 164 additions & 0 deletions features/enhanced/form_submission_via_ajax.feature
@@ -0,0 +1,164 @@
Feature: Form submission via AJAX
In order to keep the AJAX based form submission consistent
As an user
I want to experience the same kind of user journey regardless of using AJAX or not

Scenario Outline: A feature we should still see the source feature file contents via a dialog box
Given there is a <item>
When I am on "<page>" page
And "<form action>" the "<item>" form
Then I submit the form
Then there should be an AJAX request
When I use the features path link
Then there should be an AJAX request
And a dialog box should appear

Examples:
| page | item | form action |
| edit feature | feature | update |

Scenario Outline: After editing a item the hover dialog should still function
Given there is a <item>
When I am on "<page>" page
And "<form action>" the "<item>" form
Then I submit the form
When I click "button.display_form"
Then there should be an AJAX request

Examples:
| page | item | form action |
| new project | project | fill in |
| edit project | project | update |
| new feature | feature | fill in |
| edit feature | feature | update |
| new story | story | fill in |
| edit story | story | update |
| new step | step | fill in |
| edit step | step | update |

Scenario Outline: The items panel should be visible
Given there is a <item>
When I am on the <page> page
And the <item> is filled in
Then there should be an AJAX call
And the icons panel should be visible

Examples:
| page | item | form action |
| new project | project | fill in |
| edit project | project | update |
| new feature | feature | fill in |
| edit feature | feature | update |
| new story | story | fill in |
| edit story | story | update |
| new step | step | fill in |
| edit step | step | update |

Scenario Outline: The order button should still function
Given there is a <item>
When I am on the <page> page
And the <item> is filled in
Then there should be an AJAX call
And the order button should be visible
When I click the "Order" button
Then I should see the handlers

Examples:
| page | item | form action |
| new project | project | fill in |
| edit project | project | update |
| new feature | feature | fill in |
| edit feature | feature | update |
| new story | story | fill in |
| edit story | story | update |

# @TODO Add more pagination related scenarios later
Scenario Outline: We should still be able to use the pagination
Given there is a <item>
When I am on the <page> page
And the <item> is filled in
Then there should be an AJAX call
And pagination should be visible

Examples:
| page | item | form action |
| new project | project | fill in |
| edit project | project | update |
| new feature | feature | fill in |
| edit feature | feature | update |
| new story | story | fill in |
| edit story | story | update |
| new step | step | fill in |
| edit step | step | update |

Scenario Outline: Animated icon panels should still work
Given there is a <item>
When I am on the <page> page
And the <item> is filled in
Then there should be an AJAX call
And I click panel for the first item in the sortable list
Then the panels icons should be visible

Examples:
| page | item | form action |
| new project | project | fill in |
| edit project | project | update |
| new feature | feature | fill in |
| edit feature | feature | update |
| new story | story | fill in |
| edit story | story | update |
| new step | step | fill in |
| edit step | step | update |

Scenario Outline: The submitted form should be hidden
Given there is a <item>
When I am on the <page> page
And the <item> is filled in
Then there should be an AJAX call
And the for should be hidden

Examples:
| page | item | form action |
| new project | project | fill in |
| edit project | project | update |
| new feature | feature | fill in |
| edit feature | feature | update |
| new story | story | fill in |
| edit story | story | update |
| new step | step | fill in |
| edit step | step | update |

Scenario Outline: The submitted form can be revealed via a button
Given there is a <item>
When I am on the <page> page
And the <item> is filled in
Then there should be an AJAX call
And the for should be hidden
And there should be a "view form" button

Examples:
| page | item | form action |
| new project | project | fill in |
| edit project | project | update |
| new feature | feature | fill in |
| edit feature | feature | update |
| new story | story | fill in |
| edit story | story | update |
| new step | step | fill in |
| edit step | step | update |

Scenario Outline: Should be able to sort the responding
Given there is a <item>
When I am on the <page> page
And the <item> is filled in
Then there should be an AJAX call
And the order button should be visible
When I click the "Order" button
Then I should see the handlers

Examples:
| page | item | form action |
| edit project | project | update |
| edit feature | feature | update |
| edit story | story | update |
| edit step | step | update |
6 changes: 6 additions & 0 deletions features/enhanced/import_feature_ajax_functionality.feature
Expand Up @@ -50,3 +50,9 @@ Feature: Import feature ajax functionality
And I click "button.button"
Then the flash message "was created" should be displayed

Scenario: Importing a feature should disable the submit button on sumbission
Given there is a project
And the project has a project path
When I am on the "import project" page
When I import "button.button"
Then the submit button should be disabled
7 changes: 4 additions & 3 deletions features/enhanced/sidebar_functionality.feature
@@ -1,18 +1,19 @@
Feature: AJAX based Sidebar functionality
Feature: AJAX based sidebar functionality
In order to keep the functionality consistent
As a user
I want to be able to submit a form and have the side bar along with its hover items available to the user

# @TODO move this to the form submission feature file
Scenario Outline: Displaying the side bar after form submission
Given there is a <model>
Given there is a <item>
When I view the "<page name>" path
Then the side bar should not be rendered
And submit the form
And there should be an AJAX request
And the sidebar will be rendered via AJAX

Examples: All pages that should have render the sidebar after an AJAX based form submission
| model | page name |
| item | page name |
| project | edit project |
| feature | edit feature |
| story | edit story |
Expand Down
7 changes: 7 additions & 0 deletions features/step_definitions/features_steps.rb
Expand Up @@ -67,6 +67,13 @@
click_link 'Stories'
end

When /^I fill in the feature form"$/ do
When %{we fill in the feature title with 'Logging in'}
When %{we fill in the feature in_order with 'to create the best app'}
When %{we fill in the feature as_a with 'user'}
When %{we fill in the feature i_want with 'the best project ever'}
end

Then /^I should see a list of features$/ do
response.should have_selector :ul do |list|
list.should have_selector :li
Expand Down
15 changes: 14 additions & 1 deletion features/step_definitions/general_steps.rb
Expand Up @@ -12,4 +12,17 @@

When /^we submit the new feature$/ do
click_button 'save'
end
end

# @TODO Refactor to work with other form actions
When /^"([^\"]*)" the "([^\"]*)" form$/ do |form_action, item|
case form_action
when /update/
# Do nothing
when /fill in/
When %{I fill in the #{item} form"}
else
raise "Can't find form action\"#{form_action}\".\n" +
"Now, go and add a mapping in #{__FILE__}"
end
end
6 changes: 6 additions & 0 deletions features/step_definitions/projects_steps.rb
Expand Up @@ -141,6 +141,12 @@
end
end

When /^I fill in the project form"$/ do
When %{we fill in the project title with 'A project'}
When %{we fill in the project aim with 'An aim'}
When %{we fill in the project description with 'A description'}
end

Then /^submit the form$/ do
click_button 'save'
end
Expand Down
10 changes: 9 additions & 1 deletion features/step_definitions/selenium_steps.rb
Expand Up @@ -60,6 +60,10 @@
selenium.click "css=button.button"
end

When /^I use the features path link$/ do
click_link "#{@feature.path}"
end

Then /^the project's information will be display in the sidebar$/ do
selenium.wait_for_visible("project_1")
end
Expand Down Expand Up @@ -135,7 +139,7 @@
end

Then /^I should see a hover dialog box$/ do
selenium.wait_for_visible("css=div.hover")
selenium.wait_for_visible("css=div.hover", :timeout_in_seconds => 10)
end

Then /^I should not see a hover dialog box$/ do
Expand Down Expand Up @@ -218,4 +222,8 @@

Then /^a dialog box should appear$/ do
selenium.wait_for_visible("css=div.dialog", :timeout_in_seconds => 10)
end

Then /^the submit button should be disabled$/ do
selenium.wait_for_element("css=button.ui-button-disabled", :timeout_in_seconds => 10)
end
3 changes: 3 additions & 0 deletions features/step_definitions/steps_steps.rb
Expand Up @@ -17,6 +17,9 @@
When /^the step is viewed$/ do
visit step_path @step
end
When /^I fill in the step form"$/ do
When %{we fill in the step title with 'Given we have a new step'}
end

Then /^the new step form should be displayed$/ do
response.should have_selector :form
Expand Down
4 changes: 4 additions & 0 deletions features/step_definitions/stories_steps.rb
Expand Up @@ -53,6 +53,10 @@
visit story_path @story
end

When /^I fill in the story form"$/ do
When %{we fill in the story scenario with 'this is our stories scenario'}
end

Then /^there should be a list of stories$/ do
response.should have_selector(:div) do |content|
content.should have_selector(:ul) do |list|
Expand Down
2 changes: 2 additions & 0 deletions features/support/paths.rb
Expand Up @@ -12,6 +12,8 @@ def path_to(page_name)
'/'
when /project show/
project_path(@project)
when /new feature/
new_feature_path
when /export feature/
export_feature_path @feature
when /import project/
Expand Down
7 changes: 4 additions & 3 deletions public/javascripts/form.js
Expand Up @@ -31,8 +31,9 @@ $(document).ready(function() {
if ($form.hasClass('hidden') == false) {
// here is where we make our necessary form response for all our AJAX based responses
$('#wrapper').append($form.hide());
$('<a class="display_form" href="javascript://">view form</a>').insertBefore('#wrapper form')
.addClass('ui-widget ui-widget-content ui-corner-all');
$('<button class="display_form button" href="javascript://">view form</a>')
.insertBefore('#wrapper form')
.button({ option: 'text' });
}
// setup our generic list events
$('ul.icons li .handler').button('option', 'icon');
Expand All @@ -51,7 +52,7 @@ $(document).ready(function() {
return false;
});

$("a.display_form").live("click",function(event) {
$("button.display_form").live("click",function(event) {
var link = $(this),
id_attribute_name = link.attr('id').split('_'),
title_array = link.text().split(' '),
Expand Down

0 comments on commit c85a7d0

Please sign in to comment.