Commit 6f3b41f9028303fa75d0f06ce87db7e93ab960db
1 parent
8770d20b
Exists in
master
and in
29 other branches
orders-plugin: feature tests of order checkout and repeat
Showing
2 changed files
with
50 additions
and
0 deletions
Show diff stats
plugins/orders/features/purchases.feature
| ... | ... | @@ -6,6 +6,7 @@ Feature: purchases |
| 6 | 6 | Background: |
| 7 | 7 | Given "ShoppingCart" plugin is enabled |
| 8 | 8 | And "Orders" plugin is enabled |
| 9 | + And "Delivery" plugin is enabled | |
| 9 | 10 | And the following users |
| 10 | 11 | | login | name | email | |
| 11 | 12 | | moe | Moe | moe@springfield.com | |
| ... | ... | @@ -111,3 +112,44 @@ Feature: purchases |
| 111 | 112 | When I press "Filter" |
| 112 | 113 | Then I should see "Moes Tavern" within any ".actor-name" |
| 113 | 114 | And I should not see "First Church of Springfield" within any ".actor-name" |
| 115 | + | |
| 116 | + @selenium | |
| 117 | + Scenario: products checkout | |
| 118 | + Given "moes-tavern" has the following delivery methods | |
| 119 | + | delivery_type | name | description | fixed_cost | free_over_price | | |
| 120 | + | deliver | Bike | My good old bike. | 8.00 | 10.00 | | |
| 121 | + | pickup | Bar | Come to my bar and drink it! | 0.00 | 0.00 | | |
| 122 | + And I am on moes-tavern's products page | |
| 123 | + And I follow "Add to basket" | |
| 124 | + And I follow "Add to basket" | |
| 125 | + And I follow "Add to basket" | |
| 126 | + And I follow "Show basket" | |
| 127 | + And I follow "Shopping checkout" | |
| 128 | + And I fill in "Contact phone" with "123456789" | |
| 129 | + And I select "Bike ($8.00)" from "Option" | |
| 130 | + And I press "Send buy request" | |
| 131 | + And I go to homer's control panel | |
| 132 | + When I follow "Purchases made" | |
| 133 | + Then I should see "Moes Tavern" within any ".actor-name" | |
| 134 | + | |
| 135 | + | |
| 136 | + @selenium | |
| 137 | + Scenario: repeat order | |
| 138 | + Given "moes-tavern" has the following delivery methods | |
| 139 | + | delivery_type | name | description | fixed_cost | free_over_price | | |
| 140 | + | deliver | Bike | My good old bike. | 8.00 | 10.00 | | |
| 141 | + | pickup | Bar | Come to my bar and drink it! | 0.00 | 0.00 | | |
| 142 | + And the following purchase from "homer" on "moes-tavern" that is "ordered" | |
| 143 | + | product | quantity | price | | |
| 144 | + | Duff | 3 | 3.50 | | |
| 145 | + | French fries | 1 | 7.00 | | |
| 146 | + And I am on moes-tavern's products page | |
| 147 | + And I follow "Add to basket" | |
| 148 | + And I follow "Add to basket" | |
| 149 | + And I follow "Show basket" | |
| 150 | + And I follow "Clean basket" | |
| 151 | + And I follow "Hide basket" | |
| 152 | + When I follow "checkout" | |
| 153 | + Then I should see "Shopping checkout" | |
| 154 | + And I should see "Duff" | |
| 155 | + And I should see "French fries" | ... | ... |
plugins/orders/features/step_definitions/orders_steps.rb
| ... | ... | @@ -5,6 +5,14 @@ Given /^the shopping basket is (enabled|disabled) on "([^""]*)"$/ do |status, na |
| 5 | 5 | settings.save! |
| 6 | 6 | end |
| 7 | 7 | |
| 8 | +Given /^"([^""]*)" has the following delivery methods$/ do |name, table| | |
| 9 | + enterprise = Enterprise.find_by_name(name) || Enterprise[name] | |
| 10 | + table.hashes.map{|item| item.dup}.each do |item| | |
| 11 | + delivery_method = enterprise.delivery_methods.build | |
| 12 | + delivery_method.update_attributes(item) | |
| 13 | + end | |
| 14 | +end | |
| 15 | + | |
| 8 | 16 | Given /^the following purchase from "([^""]*)" on "([^""]*)" that is "([^""]*)"$/ do |consumer_identifier, enterprise_identifier, status, table| |
| 9 | 17 | consumer = Person.find_by_name(consumer_identifier) || Person[consumer_identifier] |
| 10 | 18 | enterprise = Enterprise.find_by_name(enterprise_identifier) || Enterprise[enterprise_identifier] | ... | ... |