diff --git a/plugins/delivery/features/delivery_admin.feature b/plugins/delivery/features/delivery_admin.feature new file mode 100644 index 0000000..9101a40 --- /dev/null +++ b/plugins/delivery/features/delivery_admin.feature @@ -0,0 +1,81 @@ +Feature: delivery administration + As an enterprise's administrator + I want to create delivery methods + In order to allow my customer to choose which delivery they want + + Background: + Given "ShoppingCart" plugin is enabled + And "Delivery" plugin is enabled + And the following users + | login | name | + | moe | Moe | + And the following enterprise + | identifier | name | owner | + | moes-tavern | Moes Tavern | moe | + And the shopping basket is enabled on "Moes Tavern" + And "Moe" is admin of "Moes Tavern" + And I am logged in as "moe" + And I go to moes-tavern's control panel + + @selenium + Scenario: enable delivery + Given I follow "Shopping basket" + When I check "Enable shopping basket" + Then I should see "Deliveries or pickups" + + @selenium + Scenario: disable delivery + Given I follow "Shopping basket" + When I uncheck "Enable shopping basket" + Then I should not see "Deliveries or pickups" + + @selenium + Scenario: create new deliver + Given I follow "Shopping basket" + And I check "Enable shopping basket" + And I follow "New delivery or pickup" + And I select "Deliver" from "Type" + And I fill in "Name" with "Bike" + And I fill in "Description" with "Beers delivered with my old bike." + And I fill in "Fixed cost" with "8.00" + And I fill in "Order's minimum price for free delivery" with "35.50" + When I press "Add" + Then I should see "Bike" within ".delivery-method" + + @selenium + Scenario: create new pickup + Given I follow "Shopping basket" + And I check "Enable shopping basket" + And I follow "New delivery or pickup" + And I select "Pickup" from "Type" + And I fill in "Name" with "Bar" + And I fill in "Description" with "Come to my bar and pick it yourself." + And I fill in "Fixed cost" with "0.00" + When I press "Add" + Then I should see "Bar" + + @selenium + Scenario: remove delivery + Given I follow "Shopping basket" + And I check "Enable shopping basket" + And I follow "New delivery or pickup" + And I fill in "Name" with "Bike" + When I press "Add" + Then I should see "Bike" + And I follow "Remove" within ".delivery-method" + When I confirm the browser dialog + Then I should see "Bike" + + @selenium + Scenario: edit delivery + Given I follow "Shopping basket" + And I check "Enable shopping basket" + And I follow "New delivery or pickup" + And I fill in "Name" with "Bike" + When I press "Add" + Then I should see "Bike" + And I follow "Edit" within ".delivery-method" + And I fill in "Name" with "Car" + When I press "Save" + Then I should not see "Bike" + Then I should see "Car" diff --git a/plugins/delivery/features/delivery_client.feature b/plugins/delivery/features/delivery_client.feature new file mode 100644 index 0000000..31fb8f0 --- /dev/null +++ b/plugins/delivery/features/delivery_client.feature @@ -0,0 +1,77 @@ +Feature: delivery client + As an enterprise's client + I want to choose the delivery method + In order to receive my procucts properly + + Background: + Given "ShoppingCart" plugin is enabled + And "Delivery" plugin is enabled + And the following users + | login | name | email | + | moe | Moe | moe@springfield.com | + | homer | Homer | homer@springfield.com | + And the following enterprise + | identifier | name | owner | + | moes-tavern | Moes Tavern | moe | + And the shopping basket is enabled on "Moes Tavern" + And the following product_categories + | name | + | Beer | + | Snacks | + And the following products + | owner | category | name | price | + | moes-tavern | beer | Duff | 3.00 | + | moes-tavern | snacks | French fries | 7.00 | + And "moes-tavern" has the following delivery methods + | delivery_type | name | description | fixed_cost | free_over_price | + | deliver | Bike | My good old bike. | 8.00 | 10.00 | + | pickup | Bar | Come to my bar and drink it! | 0.00 | 0.00 | + And feature "products_for_enterprises" is enabled on environment + And I am logged in as "homer" + And I go to moes-tavern's products page + + @selenium + Scenario: choose deliver method for purchase + Given I follow "Add to basket" + And I follow "Add to basket" + And I should see "Show basket" + And I follow "Show basket" + And I follow "Shopping checkout" + And I fill in "Contact phone" with "123456789" + When I select "Bike ($8.00)" from "Option" + Then I should see "My good old bike." within ".instructions" + And I should see "Address" + And I should see "Bike" within "#delivery-name" + And I should see "8.00" within "#delivery-price" + + @selenium + Scenario: choose pickup method for purchase + Given I follow "Add to basket" + And I follow "Add to basket" + And I should see "Show basket" + And I follow "Show basket" + And I follow "Shopping checkout" + And I fill in "Contact phone" with "123456789" + When I select "Bar" from "Option" + Then I should see "Come to my bar and drink it!" within ".instructions" + And I should not see "Address" + And I should see "Bar" within "#delivery-name" + And I should see "0.00" within "#delivery-price" + + @selenium + Scenario: gets free delivery due to free over price + Given I follow "Add to basket" + And I follow "Add to basket" + And I follow "Add to basket" + And I follow "Add to basket" + And I follow "Add to basket" + And I follow "Add to basket" + And I should see "Show basket" + And I follow "Show basket" + And I follow "Shopping checkout" + And I fill in "Contact phone" with "123456789" + When I select "Bike ($8.00)" from "Option" + Then I should see "My good old bike." within ".instructions" + And I should see "Address" + And I should see "Bike" within "#delivery-name" + And I should see "0.00" within "#delivery-price" diff --git a/plugins/delivery/features/step_definitions/delivery_steps.rb b/plugins/delivery/features/step_definitions/delivery_steps.rb new file mode 100644 index 0000000..93853ad --- /dev/null +++ b/plugins/delivery/features/step_definitions/delivery_steps.rb @@ -0,0 +1,14 @@ +Given /^the shopping basket is (enabled|disabled) on "([^""]*)"$/ do |status, name| + status = status == 'enabled' + enterprise = Enterprise.find_by_name(name) || Enterprise[name] + settings = enterprise.shopping_cart_settings({:enabled => status}) + settings.save! +end + +Given /^"([^""]*)" has the following delivery methods$/ do |name, table| + enterprise = Enterprise.find_by_name(name) || Enterprise[name] + table.hashes.map{|item| item.dup}.each do |item| + delivery_method = enterprise.delivery_methods.build + delivery_method.update_attributes(item) + end +end -- libgit2 0.21.2