diff --git a/plugins/orders/features/purchases.feature b/plugins/orders/features/purchases.feature deleted file mode 100644 index cb8b414..0000000 --- a/plugins/orders/features/purchases.feature +++ /dev/null @@ -1,155 +0,0 @@ -Feature: purchases - As an enterprise's client - I want to view my purchases - In order to manage the products I bought - - Background: - Given "ShoppingCart" plugin is enabled - And "Orders" 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 feature "products_for_enterprises" is enabled on environment - And I am logged in as "homer" - And I am on homer's control panel - - @selenium - Scenario: view orders - Given the following purchase from "homer" on "moes-tavern" that is "ordered" - | product | quantity | price | - | Duff | 3 | 3.50 | - | French fries | 1 | 7.00 | - When I follow "Purchases made" - Then I should see "Moes Tavern" within any ".actor-name" - And I should see "17.50" within any ".total" - And I should see "Ordered" within any ".situation" - - @selenium - Scenario: view orders with different status - Given the following purchase from "homer" on "moes-tavern" that is "accepted" - | product | quantity | price | - | Duff | 2 | 3.50 | - And the following purchase from "homer" on "moes-tavern" that is "delivered" - | product | quantity | price | - | French fries | 1 | 7.00 | - When I follow "Purchases made" - Then I should see "Accepted" within any ".situation" - And I should see "Delivered" within any ".situation" - - @selenium - Scenario: filter orders by situation - Given the following purchase from "homer" on "moes-tavern" that is "accepted" - | product | quantity | price | - | Duff | 2 | 3.50 | - And the following purchase from "homer" on "moes-tavern" that is "delivered" - | product | quantity | price | - | French fries | 1 | 7.00 | - And I follow "Purchases made" - And I should see "Accepted" within any ".situation" - And I should see "Delivered" within any ".situation" - And I select "Delivered" from "Status" - When I press "Filter" - Then I should not see "Accepted" within any ".situation" - And I should see "Delivered" within any ".situation" - - - @selenium - Scenario: filter orders by code - Given the following purchase from "homer" on "moes-tavern" that is "ordered" - | product | quantity | price | - | Duff | 2 | 3.50 | - And the following purchase from "homer" on "moes-tavern" that is "ordered" - | product | quantity | price | - | French fries | 1 | 7.00 | - And I follow "Purchases made" - And I should see "1" within any ".code" - And I should see "2" within any ".code" - And I fill in "Code" with "2" - When I press "Filter" - Then I should not see "1" within any ".code" - Then I should see "2" within any ".code" - - - @selenium - Scenario: filter orders by supplier - Given the following users - | login | name | email | - | lovejoy | Reverend Lovejoy | lovejoy@springfield.com | - And the following enterprise - | identifier | name | owner | - | first-church-of-springfield | First Church of Springfield | lovejoy | - And the shopping basket is enabled on "First Church of Springfield" - And the following product_categories - | name | - | Holy | - And the following products - | owner | category | name | price | - | first-church-of-springfield | holy | Wine | 5.00 | - And the following purchase from "homer" on "moes-tavern" that is "ordered" - | product | quantity | price | - | French fries | 1 | 7.00 | - And the following purchase from "homer" on "first-church-of-springfield" that is "ordered" - | product | quantity | price | - | Wine | 5 | 10.50 | - And I follow "Purchases made" - And I should see "Moes Tavern" within any ".actor-name" - And I should see "First Church of Springfield" within any ".actor-name" - And I select "Moes Tavern" from "Supplier" - When I press "Filter" - Then I should see "Moes Tavern" within any ".actor-name" - And I should not see "First Church of Springfield" within any ".actor-name" - - @selenium - Scenario: products checkout - Given "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 I am on moes-tavern's products page - And I follow "Add to basket" - And I follow "Add to basket" - And I follow "Add to basket" - And I follow "Show basket" - And I follow "Shopping checkout" - And I fill in "Contact phone" with "123456789" - And I select "Bike ($8.00)" from "Option" - And I press "Send buy request" - And I go to homer's control panel - When I follow "Purchases made" - Then I should see "Moes Tavern" within any ".actor-name" - - - @selenium - Scenario: repeat order - Given "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 the following purchase from "homer" on "moes-tavern" that is "ordered" - | product | quantity | price | - | Duff | 3 | 3.50 | - | French fries | 1 | 7.00 | - And I am on moes-tavern's products page - And I follow "Add to basket" - And I follow "Add to basket" - And I follow "Show basket" - And I follow "Clean basket" - And I follow "Hide basket" - When I follow "checkout" - Then I should see "Shopping checkout" - And I should see "Duff" - And I should see "French fries" diff --git a/plugins/orders/features/sales.feature b/plugins/orders/features/sales.feature deleted file mode 100644 index e5803fd..0000000 --- a/plugins/orders/features/sales.feature +++ /dev/null @@ -1,104 +0,0 @@ -Feature: sales - As an enterprise's administrator - I want to view my sales - In order to manage the products I sold - - Background: - Given "ShoppingCart" plugin is enabled - And "Orders" 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 "Moe" is admin of "Moes Tavern" - 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 feature "products_for_enterprises" is enabled on environment - And I am logged in as "moe" - And I am on moes-tavern's control panel - - @selenium - Scenario: view orders - Given the following purchase from "homer" on "moes-tavern" that is "ordered" - | product | quantity | price | - | Duff | 3 | 3.50 | - | French fries | 1 | 7.00 | - When I follow "Purchases and Sales" - Then I should see "Homer" within any ".actor-name" - And I should see "17.50" within any ".total" - And I should see "Ordered" within any ".situation" - - @selenium - Scenario: view orders with different status - Given the following purchase from "homer" on "moes-tavern" that is "accepted" - | product | quantity | price | - | Duff | 2 | 3.50 | - And the following purchase from "homer" on "moes-tavern" that is "delivered" - | product | quantity | price | - | French fries | 1 | 7.00 | - When I follow "Purchases and Sales" - Then I should see "Accepted" within any ".situation" - And I should see "Delivered" within any ".situation" - - @selenium - Scenario: filter orders by situation - Given the following purchase from "homer" on "moes-tavern" that is "accepted" - | product | quantity | price | - | Duff | 2 | 3.50 | - And the following purchase from "homer" on "moes-tavern" that is "delivered" - | product | quantity | price | - | French fries | 1 | 7.00 | - And I follow "Purchases and Sales" - And I should see "Accepted" within any ".situation" - And I should see "Delivered" within any ".situation" - And I select "Delivered" from "Status" - When I press "Filter" - Then I should not see "Accepted" within any ".situation" - And I should see "Delivered" within any ".situation" - - - @selenium - Scenario: filter orders by code - Given the following purchase from "homer" on "moes-tavern" that is "ordered" - | product | quantity | price | - | Duff | 2 | 3.50 | - And the following purchase from "homer" on "moes-tavern" that is "ordered" - | product | quantity | price | - | French fries | 1 | 7.00 | - And I follow "Purchases and Sales" - And I should see "1" within any ".code" - And I should see "2" within any ".code" - And I fill in "Code" with "2" - When I press "Filter" - Then I should not see "1" within any ".code" - Then I should see "2" within any ".code" - - - @selenium - Scenario: filter orders by consumer - Given the following users - | login | name | email | - | lovejoy | Reverend Lovejoy | lovejoy@springfield.com | - And the following purchase from "homer" on "moes-tavern" that is "ordered" - | product | quantity | price | - | Duff | 5 | 10.50 | - And the following purchase from "lovejoy" on "moes-tavern" that is "ordered" - | product | quantity | price | - | French fries | 1 | 7.00 | - And I follow "Purchases and Sales" - And I should see "Homer" within any ".actor-name" - And I should see "Reverend Lovejoy" within any ".actor-name" - And I select "Homer" from "Consumer" - When I press "Filter" - Then I should see "Homer" within any ".actor-name" - And I should not see "Reverend Lovejoy" within any ".actor-name" diff --git a/plugins/orders/features/step_definitions/orders_steps.rb b/plugins/orders/features/step_definitions/orders_steps.rb deleted file mode 100644 index 92c1c89..0000000 --- a/plugins/orders/features/step_definitions/orders_steps.rb +++ /dev/null @@ -1,28 +0,0 @@ -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 - -Given /^the following purchase from "([^""]*)" on "([^""]*)" that is "([^""]*)"$/ do |consumer_identifier, enterprise_identifier, status, table| - consumer = Person.find_by_name(consumer_identifier) || Person[consumer_identifier] - enterprise = Enterprise.find_by_name(enterprise_identifier) || Enterprise[enterprise_identifier] - order = OrdersPlugin::Purchase.new(:profile => enterprise, :consumer => consumer, :status => status) - - table.hashes.map{|item| item.dup}.each do |item| - product = enterprise.products.find_by_name item[:product] - item = order.items.build({:product => product, :name => item[:product], :quantity_consumer_ordered => item[:quantity], :price => item[:price]}) - item.order = order - end - - order.save! -end diff --git a/plugins/shopping_cart/features/purchases.feature b/plugins/shopping_cart/features/purchases.feature new file mode 100644 index 0000000..cb8b414 --- /dev/null +++ b/plugins/shopping_cart/features/purchases.feature @@ -0,0 +1,155 @@ +Feature: purchases + As an enterprise's client + I want to view my purchases + In order to manage the products I bought + + Background: + Given "ShoppingCart" plugin is enabled + And "Orders" 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 feature "products_for_enterprises" is enabled on environment + And I am logged in as "homer" + And I am on homer's control panel + + @selenium + Scenario: view orders + Given the following purchase from "homer" on "moes-tavern" that is "ordered" + | product | quantity | price | + | Duff | 3 | 3.50 | + | French fries | 1 | 7.00 | + When I follow "Purchases made" + Then I should see "Moes Tavern" within any ".actor-name" + And I should see "17.50" within any ".total" + And I should see "Ordered" within any ".situation" + + @selenium + Scenario: view orders with different status + Given the following purchase from "homer" on "moes-tavern" that is "accepted" + | product | quantity | price | + | Duff | 2 | 3.50 | + And the following purchase from "homer" on "moes-tavern" that is "delivered" + | product | quantity | price | + | French fries | 1 | 7.00 | + When I follow "Purchases made" + Then I should see "Accepted" within any ".situation" + And I should see "Delivered" within any ".situation" + + @selenium + Scenario: filter orders by situation + Given the following purchase from "homer" on "moes-tavern" that is "accepted" + | product | quantity | price | + | Duff | 2 | 3.50 | + And the following purchase from "homer" on "moes-tavern" that is "delivered" + | product | quantity | price | + | French fries | 1 | 7.00 | + And I follow "Purchases made" + And I should see "Accepted" within any ".situation" + And I should see "Delivered" within any ".situation" + And I select "Delivered" from "Status" + When I press "Filter" + Then I should not see "Accepted" within any ".situation" + And I should see "Delivered" within any ".situation" + + + @selenium + Scenario: filter orders by code + Given the following purchase from "homer" on "moes-tavern" that is "ordered" + | product | quantity | price | + | Duff | 2 | 3.50 | + And the following purchase from "homer" on "moes-tavern" that is "ordered" + | product | quantity | price | + | French fries | 1 | 7.00 | + And I follow "Purchases made" + And I should see "1" within any ".code" + And I should see "2" within any ".code" + And I fill in "Code" with "2" + When I press "Filter" + Then I should not see "1" within any ".code" + Then I should see "2" within any ".code" + + + @selenium + Scenario: filter orders by supplier + Given the following users + | login | name | email | + | lovejoy | Reverend Lovejoy | lovejoy@springfield.com | + And the following enterprise + | identifier | name | owner | + | first-church-of-springfield | First Church of Springfield | lovejoy | + And the shopping basket is enabled on "First Church of Springfield" + And the following product_categories + | name | + | Holy | + And the following products + | owner | category | name | price | + | first-church-of-springfield | holy | Wine | 5.00 | + And the following purchase from "homer" on "moes-tavern" that is "ordered" + | product | quantity | price | + | French fries | 1 | 7.00 | + And the following purchase from "homer" on "first-church-of-springfield" that is "ordered" + | product | quantity | price | + | Wine | 5 | 10.50 | + And I follow "Purchases made" + And I should see "Moes Tavern" within any ".actor-name" + And I should see "First Church of Springfield" within any ".actor-name" + And I select "Moes Tavern" from "Supplier" + When I press "Filter" + Then I should see "Moes Tavern" within any ".actor-name" + And I should not see "First Church of Springfield" within any ".actor-name" + + @selenium + Scenario: products checkout + Given "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 I am on moes-tavern's products page + And I follow "Add to basket" + And I follow "Add to basket" + And I follow "Add to basket" + And I follow "Show basket" + And I follow "Shopping checkout" + And I fill in "Contact phone" with "123456789" + And I select "Bike ($8.00)" from "Option" + And I press "Send buy request" + And I go to homer's control panel + When I follow "Purchases made" + Then I should see "Moes Tavern" within any ".actor-name" + + + @selenium + Scenario: repeat order + Given "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 the following purchase from "homer" on "moes-tavern" that is "ordered" + | product | quantity | price | + | Duff | 3 | 3.50 | + | French fries | 1 | 7.00 | + And I am on moes-tavern's products page + And I follow "Add to basket" + And I follow "Add to basket" + And I follow "Show basket" + And I follow "Clean basket" + And I follow "Hide basket" + When I follow "checkout" + Then I should see "Shopping checkout" + And I should see "Duff" + And I should see "French fries" diff --git a/plugins/shopping_cart/features/sales.feature b/plugins/shopping_cart/features/sales.feature new file mode 100644 index 0000000..e5803fd --- /dev/null +++ b/plugins/shopping_cart/features/sales.feature @@ -0,0 +1,104 @@ +Feature: sales + As an enterprise's administrator + I want to view my sales + In order to manage the products I sold + + Background: + Given "ShoppingCart" plugin is enabled + And "Orders" 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 "Moe" is admin of "Moes Tavern" + 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 feature "products_for_enterprises" is enabled on environment + And I am logged in as "moe" + And I am on moes-tavern's control panel + + @selenium + Scenario: view orders + Given the following purchase from "homer" on "moes-tavern" that is "ordered" + | product | quantity | price | + | Duff | 3 | 3.50 | + | French fries | 1 | 7.00 | + When I follow "Purchases and Sales" + Then I should see "Homer" within any ".actor-name" + And I should see "17.50" within any ".total" + And I should see "Ordered" within any ".situation" + + @selenium + Scenario: view orders with different status + Given the following purchase from "homer" on "moes-tavern" that is "accepted" + | product | quantity | price | + | Duff | 2 | 3.50 | + And the following purchase from "homer" on "moes-tavern" that is "delivered" + | product | quantity | price | + | French fries | 1 | 7.00 | + When I follow "Purchases and Sales" + Then I should see "Accepted" within any ".situation" + And I should see "Delivered" within any ".situation" + + @selenium + Scenario: filter orders by situation + Given the following purchase from "homer" on "moes-tavern" that is "accepted" + | product | quantity | price | + | Duff | 2 | 3.50 | + And the following purchase from "homer" on "moes-tavern" that is "delivered" + | product | quantity | price | + | French fries | 1 | 7.00 | + And I follow "Purchases and Sales" + And I should see "Accepted" within any ".situation" + And I should see "Delivered" within any ".situation" + And I select "Delivered" from "Status" + When I press "Filter" + Then I should not see "Accepted" within any ".situation" + And I should see "Delivered" within any ".situation" + + + @selenium + Scenario: filter orders by code + Given the following purchase from "homer" on "moes-tavern" that is "ordered" + | product | quantity | price | + | Duff | 2 | 3.50 | + And the following purchase from "homer" on "moes-tavern" that is "ordered" + | product | quantity | price | + | French fries | 1 | 7.00 | + And I follow "Purchases and Sales" + And I should see "1" within any ".code" + And I should see "2" within any ".code" + And I fill in "Code" with "2" + When I press "Filter" + Then I should not see "1" within any ".code" + Then I should see "2" within any ".code" + + + @selenium + Scenario: filter orders by consumer + Given the following users + | login | name | email | + | lovejoy | Reverend Lovejoy | lovejoy@springfield.com | + And the following purchase from "homer" on "moes-tavern" that is "ordered" + | product | quantity | price | + | Duff | 5 | 10.50 | + And the following purchase from "lovejoy" on "moes-tavern" that is "ordered" + | product | quantity | price | + | French fries | 1 | 7.00 | + And I follow "Purchases and Sales" + And I should see "Homer" within any ".actor-name" + And I should see "Reverend Lovejoy" within any ".actor-name" + And I select "Homer" from "Consumer" + When I press "Filter" + Then I should see "Homer" within any ".actor-name" + And I should not see "Reverend Lovejoy" within any ".actor-name" diff --git a/plugins/shopping_cart/features/step_definitions/delivery_steps.rb b/plugins/shopping_cart/features/step_definitions/delivery_steps.rb new file mode 100644 index 0000000..452242c --- /dev/null +++ b/plugins/shopping_cart/features/step_definitions/delivery_steps.rb @@ -0,0 +1,7 @@ +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 diff --git a/plugins/shopping_cart/features/step_definitions/orders_steps.rb b/plugins/shopping_cart/features/step_definitions/orders_steps.rb new file mode 100644 index 0000000..dcfda78 --- /dev/null +++ b/plugins/shopping_cart/features/step_definitions/orders_steps.rb @@ -0,0 +1,21 @@ +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 + +Given /^the following purchase from "([^""]*)" on "([^""]*)" that is "([^""]*)"$/ do |consumer_identifier, enterprise_identifier, status, table| + consumer = Person.find_by_name(consumer_identifier) || Person[consumer_identifier] + enterprise = Enterprise.find_by_name(enterprise_identifier) || Enterprise[enterprise_identifier] + order = OrdersPlugin::Purchase.new(:profile => enterprise, :consumer => consumer, :status => status) + + table.hashes.map{|item| item.dup}.each do |item| + product = enterprise.products.find_by_name item[:product] + item = order.items.build({:product => product, :name => item[:product], :quantity_consumer_ordered => item[:quantity], :price => item[:price]}) + item.order = order + end + + order.save! +end diff --git a/plugins/shopping_cart/features/step_definitions/shopping_cart_steps.rb b/plugins/shopping_cart/features/step_definitions/shopping_cart_steps.rb new file mode 100644 index 0000000..a25321c --- /dev/null +++ b/plugins/shopping_cart/features/step_definitions/shopping_cart_steps.rb @@ -0,0 +1,7 @@ +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 + diff --git a/plugins/shopping_cart/step_definitions/delivery_steps.rb b/plugins/shopping_cart/step_definitions/delivery_steps.rb deleted file mode 100644 index 93853ad..0000000 --- a/plugins/shopping_cart/step_definitions/delivery_steps.rb +++ /dev/null @@ -1,14 +0,0 @@ -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