Commit 0c7e0d3634ff2430ea0afe5099832f1674d70110
1 parent
b6f726f1
Exists in
master
and in
29 other branches
delivery-plugin: features tests
Showing
3 changed files
with
172 additions
and
0 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,81 @@ |
| 1 | +Feature: delivery administration | |
| 2 | + As an enterprise's administrator | |
| 3 | + I want to create delivery methods | |
| 4 | + In order to allow my customer to choose which delivery they want | |
| 5 | + | |
| 6 | + Background: | |
| 7 | + Given "ShoppingCart" plugin is enabled | |
| 8 | + And "Delivery" plugin is enabled | |
| 9 | + And the following users | |
| 10 | + | login | name | | |
| 11 | + | moe | Moe | | |
| 12 | + And the following enterprise | |
| 13 | + | identifier | name | owner | | |
| 14 | + | moes-tavern | Moes Tavern | moe | | |
| 15 | + And the shopping basket is enabled on "Moes Tavern" | |
| 16 | + And "Moe" is admin of "Moes Tavern" | |
| 17 | + And I am logged in as "moe" | |
| 18 | + And I go to moes-tavern's control panel | |
| 19 | + | |
| 20 | + @selenium | |
| 21 | + Scenario: enable delivery | |
| 22 | + Given I follow "Shopping basket" | |
| 23 | + When I check "Enable shopping basket" | |
| 24 | + Then I should see "Deliveries or pickups" | |
| 25 | + | |
| 26 | + @selenium | |
| 27 | + Scenario: disable delivery | |
| 28 | + Given I follow "Shopping basket" | |
| 29 | + When I uncheck "Enable shopping basket" | |
| 30 | + Then I should not see "Deliveries or pickups" | |
| 31 | + | |
| 32 | + @selenium | |
| 33 | + Scenario: create new deliver | |
| 34 | + Given I follow "Shopping basket" | |
| 35 | + And I check "Enable shopping basket" | |
| 36 | + And I follow "New delivery or pickup" | |
| 37 | + And I select "Deliver" from "Type" | |
| 38 | + And I fill in "Name" with "Bike" | |
| 39 | + And I fill in "Description" with "Beers delivered with my old bike." | |
| 40 | + And I fill in "Fixed cost" with "8.00" | |
| 41 | + And I fill in "Order's minimum price for free delivery" with "35.50" | |
| 42 | + When I press "Add" | |
| 43 | + Then I should see "Bike" within ".delivery-method" | |
| 44 | + | |
| 45 | + @selenium | |
| 46 | + Scenario: create new pickup | |
| 47 | + Given I follow "Shopping basket" | |
| 48 | + And I check "Enable shopping basket" | |
| 49 | + And I follow "New delivery or pickup" | |
| 50 | + And I select "Pickup" from "Type" | |
| 51 | + And I fill in "Name" with "Bar" | |
| 52 | + And I fill in "Description" with "Come to my bar and pick it yourself." | |
| 53 | + And I fill in "Fixed cost" with "0.00" | |
| 54 | + When I press "Add" | |
| 55 | + Then I should see "Bar" | |
| 56 | + | |
| 57 | + @selenium | |
| 58 | + Scenario: remove delivery | |
| 59 | + Given I follow "Shopping basket" | |
| 60 | + And I check "Enable shopping basket" | |
| 61 | + And I follow "New delivery or pickup" | |
| 62 | + And I fill in "Name" with "Bike" | |
| 63 | + When I press "Add" | |
| 64 | + Then I should see "Bike" | |
| 65 | + And I follow "Remove" within ".delivery-method" | |
| 66 | + When I confirm the browser dialog | |
| 67 | + Then I should see "Bike" | |
| 68 | + | |
| 69 | + @selenium | |
| 70 | + Scenario: edit delivery | |
| 71 | + Given I follow "Shopping basket" | |
| 72 | + And I check "Enable shopping basket" | |
| 73 | + And I follow "New delivery or pickup" | |
| 74 | + And I fill in "Name" with "Bike" | |
| 75 | + When I press "Add" | |
| 76 | + Then I should see "Bike" | |
| 77 | + And I follow "Edit" within ".delivery-method" | |
| 78 | + And I fill in "Name" with "Car" | |
| 79 | + When I press "Save" | |
| 80 | + Then I should not see "Bike" | |
| 81 | + Then I should see "Car" | ... | ... |
| ... | ... | @@ -0,0 +1,77 @@ |
| 1 | +Feature: delivery client | |
| 2 | + As an enterprise's client | |
| 3 | + I want to choose the delivery method | |
| 4 | + In order to receive my procucts properly | |
| 5 | + | |
| 6 | + Background: | |
| 7 | + Given "ShoppingCart" plugin is enabled | |
| 8 | + And "Delivery" plugin is enabled | |
| 9 | + And the following users | |
| 10 | + | login | name | email | | |
| 11 | + | moe | Moe | moe@springfield.com | | |
| 12 | + | homer | Homer | homer@springfield.com | | |
| 13 | + And the following enterprise | |
| 14 | + | identifier | name | owner | | |
| 15 | + | moes-tavern | Moes Tavern | moe | | |
| 16 | + And the shopping basket is enabled on "Moes Tavern" | |
| 17 | + And the following product_categories | |
| 18 | + | name | | |
| 19 | + | Beer | | |
| 20 | + | Snacks | | |
| 21 | + And the following products | |
| 22 | + | owner | category | name | price | | |
| 23 | + | moes-tavern | beer | Duff | 3.00 | | |
| 24 | + | moes-tavern | snacks | French fries | 7.00 | | |
| 25 | + And "moes-tavern" has the following delivery methods | |
| 26 | + | delivery_type | name | description | fixed_cost | free_over_price | | |
| 27 | + | deliver | Bike | My good old bike. | 8.00 | 10.00 | | |
| 28 | + | pickup | Bar | Come to my bar and drink it! | 0.00 | 0.00 | | |
| 29 | + And feature "products_for_enterprises" is enabled on environment | |
| 30 | + And I am logged in as "homer" | |
| 31 | + And I go to moes-tavern's products page | |
| 32 | + | |
| 33 | + @selenium | |
| 34 | + Scenario: choose deliver method for purchase | |
| 35 | + Given I follow "Add to basket" | |
| 36 | + And I follow "Add to basket" | |
| 37 | + And I should see "Show basket" | |
| 38 | + And I follow "Show basket" | |
| 39 | + And I follow "Shopping checkout" | |
| 40 | + And I fill in "Contact phone" with "123456789" | |
| 41 | + When I select "Bike ($8.00)" from "Option" | |
| 42 | + Then I should see "My good old bike." within ".instructions" | |
| 43 | + And I should see "Address" | |
| 44 | + And I should see "Bike" within "#delivery-name" | |
| 45 | + And I should see "8.00" within "#delivery-price" | |
| 46 | + | |
| 47 | + @selenium | |
| 48 | + Scenario: choose pickup method for purchase | |
| 49 | + Given I follow "Add to basket" | |
| 50 | + And I follow "Add to basket" | |
| 51 | + And I should see "Show basket" | |
| 52 | + And I follow "Show basket" | |
| 53 | + And I follow "Shopping checkout" | |
| 54 | + And I fill in "Contact phone" with "123456789" | |
| 55 | + When I select "Bar" from "Option" | |
| 56 | + Then I should see "Come to my bar and drink it!" within ".instructions" | |
| 57 | + And I should not see "Address" | |
| 58 | + And I should see "Bar" within "#delivery-name" | |
| 59 | + And I should see "0.00" within "#delivery-price" | |
| 60 | + | |
| 61 | + @selenium | |
| 62 | + Scenario: gets free delivery due to free over price | |
| 63 | + Given I follow "Add to basket" | |
| 64 | + And I follow "Add to basket" | |
| 65 | + And I follow "Add to basket" | |
| 66 | + And I follow "Add to basket" | |
| 67 | + And I follow "Add to basket" | |
| 68 | + And I follow "Add to basket" | |
| 69 | + And I should see "Show basket" | |
| 70 | + And I follow "Show basket" | |
| 71 | + And I follow "Shopping checkout" | |
| 72 | + And I fill in "Contact phone" with "123456789" | |
| 73 | + When I select "Bike ($8.00)" from "Option" | |
| 74 | + Then I should see "My good old bike." within ".instructions" | |
| 75 | + And I should see "Address" | |
| 76 | + And I should see "Bike" within "#delivery-name" | |
| 77 | + And I should see "0.00" within "#delivery-price" | ... | ... |
plugins/delivery/features/step_definitions/delivery_steps.rb
0 → 100644
| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | +Given /^the shopping basket is (enabled|disabled) on "([^""]*)"$/ do |status, name| | |
| 2 | + status = status == 'enabled' | |
| 3 | + enterprise = Enterprise.find_by_name(name) || Enterprise[name] | |
| 4 | + settings = enterprise.shopping_cart_settings({:enabled => status}) | |
| 5 | + settings.save! | |
| 6 | +end | |
| 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 | ... | ... |