Commit 420ac5f6f7df584a8a653e6393a8a363598b8363
1 parent
6f3b41f9
Exists in
master
and in
29 other branches
remove orders and delivery plugin obsolete unit tests
Showing
6 changed files
with
0 additions
and
203 deletions
Show diff stats
plugins/delivery/test/test_helper.rb
| @@ -1 +0,0 @@ | @@ -1 +0,0 @@ | ||
| 1 | -require File.dirname(__FILE__) + '/../../../test/test_helper' |
plugins/delivery/test/unit/delivery_plugin/method_test.rb
| @@ -1,42 +0,0 @@ | @@ -1,42 +0,0 @@ | ||
| 1 | -require "#{File.dirname(__FILE__)}/../../test_helper" | ||
| 2 | - | ||
| 3 | -class DeliveryPlugin::MethodTest < ActiveSupport::TestCase | ||
| 4 | - | ||
| 5 | - def setup | ||
| 6 | - @profile = build(Profile) | ||
| 7 | - end | ||
| 8 | - | ||
| 9 | - attr_accessor :profile | ||
| 10 | - | ||
| 11 | - should 'have a name and a delivery type' do | ||
| 12 | - dm = DeliveryPlugin::Method.new :name => 'Delivery Deluxe', :delivery_type => 'deliver', :profile => profile | ||
| 13 | - assert dm.valid? | ||
| 14 | - dm = DeliveryPlugin::Method.new :profile => profile | ||
| 15 | - assert !dm.valid? | ||
| 16 | - end | ||
| 17 | - | ||
| 18 | - should 'accept only pickup and deliver as delivery types' do | ||
| 19 | - dm = build(DeliveryPlugin::Method, :name => 'Delivery Deluxe', :delivery_type => 'unkown', :profile => profile) | ||
| 20 | - assert !dm.valid? | ||
| 21 | - dm = build(DeliveryPlugin::Method, :name => 'Delivery Deluxe', :delivery_type => 'pickup', :profile => profile) | ||
| 22 | - assert dm.valid? | ||
| 23 | - dm = build(DeliveryPlugin::Method, :name => 'Delivery Deluxe', :delivery_type => 'deliver', :profile => profile) | ||
| 24 | - assert dm.valid? | ||
| 25 | - end | ||
| 26 | - | ||
| 27 | - should 'filter by delivery types' do | ||
| 28 | - dm_deliver = create(DeliveryPlugin::Method, :name => 'Delivery Deluxe', :delivery_type => 'deliver', :profile => profile) | ||
| 29 | - dm_pickup = create(DeliveryPlugin::Method, :name => 'Delivery Deluxe', :delivery_type => 'pickup', :profile => profile) | ||
| 30 | - assert_equal [dm_deliver], DeliveryPlugin::Method.delivery | ||
| 31 | - assert_equal [dm_pickup], DeliveryPlugin::Method.pickup | ||
| 32 | - end | ||
| 33 | - | ||
| 34 | - should 'have many delivery options' do | ||
| 35 | - dm = create(DeliveryPlugin::Method, :name => 'Delivery Deluxe', :delivery_type => 'deliver', :profile => profile) | ||
| 36 | - cycle = build(OrdersCyclePlugin::Cycle, :name => 'cycle name', :profile => profile) | ||
| 37 | - option = create(DeliveryPlugin::Option, :cycle => cycle, :delivery_method => dm) | ||
| 38 | - | ||
| 39 | - assert_equal [option], dm.reload.delivery_options | ||
| 40 | - end | ||
| 41 | - | ||
| 42 | -end |
plugins/delivery/test/unit/delivery_plugin/option_test.rb
| @@ -1,24 +0,0 @@ | @@ -1,24 +0,0 @@ | ||
| 1 | -require "#{File.dirname(__FILE__)}/../../test_helper" | ||
| 2 | - | ||
| 3 | -class DeliveryPlugin::OptionTest < ActiveSupport::TestCase | ||
| 4 | - | ||
| 5 | - def setup | ||
| 6 | - @profile = build(Profile) | ||
| 7 | - @cycle = build(OrdersCyclePluginCycle, :profile => @profile) | ||
| 8 | - @delivery_method = build(OrdersCyclePluginMethod, :profile => @profile) | ||
| 9 | - end | ||
| 10 | - | ||
| 11 | - attr_accessor :profile | ||
| 12 | - attr_accessor :cycle | ||
| 13 | - attr_accessor :delivery_method | ||
| 14 | - | ||
| 15 | - should 'be associated with a cycle and a delivery method' do | ||
| 16 | - option = OrdersCyclePluginOption.new :cycle => @cycle, :delivery_method => @delivery_method | ||
| 17 | - assert option.valid? | ||
| 18 | - option = OrdersCyclePluginOption.new | ||
| 19 | - :wa | ||
| 20 | - | ||
| 21 | - assert !option.valid? | ||
| 22 | - end | ||
| 23 | - | ||
| 24 | -end |
plugins/orders/test/test_helper.rb
| @@ -1 +0,0 @@ | @@ -1 +0,0 @@ | ||
| 1 | -require File.dirname(__FILE__) + '/../../../test/test_helper' |
plugins/orders/test/unit/orders_plugin/item_test.rb
| @@ -1,14 +0,0 @@ | @@ -1,14 +0,0 @@ | ||
| 1 | -require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
| 2 | - | ||
| 3 | -class OrdersPlugin::ItemTest < ActiveSupport::TestCase | ||
| 4 | - | ||
| 5 | - def setup | ||
| 6 | - @item = build(OrdersPlugin::Item, | ||
| 7 | - :quantity_shipped => 1.0, :quantity_consumer_ordered => 2.0, :quantity_accepted => 3.0, | ||
| 8 | - :price_shipped => 10.0, :price_consumer_ordered => 20.0, :price_accepted => 30.0) | ||
| 9 | - end | ||
| 10 | - | ||
| 11 | - should 'calculate prices' do | ||
| 12 | - end | ||
| 13 | - | ||
| 14 | -end |
plugins/orders/test/unit/orders_plugin/order_test.rb
| @@ -1,121 +0,0 @@ | @@ -1,121 +0,0 @@ | ||
| 1 | -require "test_helper" | ||
| 2 | - | ||
| 3 | -class OrdersPlugin::OrderTest < ActiveSupport::TestCase | ||
| 4 | - | ||
| 5 | - def setup | ||
| 6 | - @order = build(OrdersPlugin::Order, :profile => fast_create(Profile)) | ||
| 7 | - end | ||
| 8 | - | ||
| 9 | - should 'report supplier products when distributing aggregate products' do | ||
| 10 | - env = Environment.create! name: 'megacoop' | ||
| 11 | - supplier = Enterprise.create! identifier: 'supplier', name: 'supplier', environment: env | ||
| 12 | - p1 = supplier.products.create! product_category: ProductCategory.create!(name: 'banana', environment: env) | ||
| 13 | - p2 = supplier.products.create! product_category: ProductCategory.create!(name: 'aipim', environment: env) | ||
| 14 | - | ||
| 15 | - coop = Community.create! identifier: 'blah', name: 'blah', environment: env | ||
| 16 | - coop.suppliers.create! profile: supplier, consumer: coop | ||
| 17 | - aggregate_product = SuppliersPlugin::DistributedProduct.new profile: coop | ||
| 18 | - aggregate_product.sources_from_products.build quantity: 1, from_product: p1, to_product: aggregate_product | ||
| 19 | - aggregate_product.sources_from_products.build quantity: 5, from_product: p2, to_product: aggregate_product | ||
| 20 | - aggregate_product.save! | ||
| 21 | - | ||
| 22 | - # hack | ||
| 23 | - person = coop | ||
| 24 | - | ||
| 25 | - # this also create offered products | ||
| 26 | - cycle = OrdersCyclePlugin::Cycle.create! name: 'blah', profile: coop, start: Time.now, finish: Time.now+1.day, delivery_start: Time.now+2.days, delivery_finish: Time.now+3.days, status: 'orders' | ||
| 27 | - sale = cycle.sales.create! profile: person | ||
| 28 | - sale.items.create! quantity_consumer_ordered: 3, product: aggregate_product | ||
| 29 | - | ||
| 30 | - r = OrdersPlugin::Order.supplier_products_by_suppliers [sale] | ||
| 31 | - quantities = r.first.last.map(&:quantity_ordered).map(&:to_i) | ||
| 32 | - assert_equal [3*1,3*5], quantities | ||
| 33 | - end | ||
| 34 | - | ||
| 35 | - should 'format code with cycle code' do | ||
| 36 | - @order.save! | ||
| 37 | - assert_equal "#{@order.cycle.code}.#{@order.attributes['code']}", @order.code | ||
| 38 | - end | ||
| 39 | - | ||
| 40 | - should 'use as draft default status' do | ||
| 41 | - @order = create(OrdersPlugin::Order, :status => nil) | ||
| 42 | - assert_equal 'draft', @order.status | ||
| 43 | - end | ||
| 44 | - | ||
| 45 | - ### | ||
| 46 | - # Status | ||
| 47 | - ### | ||
| 48 | - | ||
| 49 | - should 'define and validate list of statuses' do | ||
| 50 | - @order.status = 'blah' | ||
| 51 | - @order.valid? | ||
| 52 | - assert @order.invalid?('status') | ||
| 53 | - | ||
| 54 | - ['draft', 'planned', 'ordered', 'cancelled'].each do |i| | ||
| 55 | - @order.status = i | ||
| 56 | - @order.valid? | ||
| 57 | - assert !@order.invalid?('status') | ||
| 58 | - end | ||
| 59 | - end | ||
| 60 | - | ||
| 61 | - should 'define status question methods' do | ||
| 62 | - ['draft', 'planned', 'ordered', 'cancelled'].each do |i| | ||
| 63 | - @order.status = i | ||
| 64 | - assert @order.send("#{@order.status}?") | ||
| 65 | - end | ||
| 66 | - end | ||
| 67 | - | ||
| 68 | - should 'define forgotten and open status' do | ||
| 69 | - @order.status = 'draft' | ||
| 70 | - assert @order.draft? | ||
| 71 | - assert @order.cycle.orders? | ||
| 72 | - assert @order.open? | ||
| 73 | - @order.cycle.status = 'closed' | ||
| 74 | - assert !@order.open? | ||
| 75 | - assert @order.forgotten? | ||
| 76 | - end | ||
| 77 | - | ||
| 78 | - should 'return current status using forgotten and open too' do | ||
| 79 | - @order.status = 'draft' | ||
| 80 | - assert @order.open? | ||
| 81 | - assert_equal 'open', @order.current_status | ||
| 82 | - @order.cycle.status = 'closed' | ||
| 83 | - assert @order.forgotten? | ||
| 84 | - assert_equal 'forgotten', @order.current_status | ||
| 85 | - end | ||
| 86 | - | ||
| 87 | - should 'define status_message method' do | ||
| 88 | - assert @order.respond_to?(:status_message) | ||
| 89 | - end | ||
| 90 | - | ||
| 91 | - ### | ||
| 92 | - # Delivery | ||
| 93 | - ### | ||
| 94 | - | ||
| 95 | - should 'give default value to supplier delivery if not present' do | ||
| 96 | - @order.save! | ||
| 97 | - @order.profile.save! | ||
| 98 | - | ||
| 99 | - @order.cycle.delivery_methods = [] | ||
| 100 | - @order.supplier_delivery = nil | ||
| 101 | - assert_nil @order.supplier_delivery | ||
| 102 | - | ||
| 103 | - default = @order.cycle.delivery_methods.create! :profile => @order.profile, :name => 'method', :delivery_type => 'deliver' | ||
| 104 | - assert_equal default, @order.supplier_delivery | ||
| 105 | - assert_equal default.id, @order.supplier_delivery_id | ||
| 106 | - end | ||
| 107 | - | ||
| 108 | - ### | ||
| 109 | - # Totals | ||
| 110 | - ### | ||
| 111 | - | ||
| 112 | - should 'give total price and quantity asked' do | ||
| 113 | - @order.cycle.profile.save! | ||
| 114 | - product = create(SuppliersPlugin::DistributedProduct, :price => 2.0, :profile => @order.cycle.profile, :supplier => @order.cycle.profile.self_supplier) | ||
| 115 | - @order.save! | ||
| 116 | - @order.item.create! :product => @order.cycle.products.first, :quantity_consumer_ordered => 2.0 | ||
| 117 | - assert_equal 2.0, @order.total_quantity_consumer_ordered | ||
| 118 | - assert_equal 4.0, @order.total_price_consumer_ordered | ||
| 119 | - end | ||
| 120 | - | ||
| 121 | -end |