factories.rb
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
module OrdersCyclePlugin::Factory
def defaults_for_suppliers_plugin_supplier
{:profile => build(Profile),
:consumer => build(Profile)}
end
def defaults_for_suppliers_plugin_distributed_product attrs = {}
profile = attrs[:profile] || build(Profile)
{:profile => profile, :name => "product-#{factory_num_seq}", :price => 2.0,
:product => build(Product, :enterprise => profile.profile, :price => 2.0),
:supplier => build(SuppliersPlugin::Supplier, :profile => profile, :consumer => profile)}
end
def defaults_for_orders_cycle_plugin_offered_product attrs = {}
hash = defaults_for_orders_cycle_plugin_product(attrs)
profile = hash[:profile]
hash.merge({
:from_products => [build(SuppliersPlugin::DistributedProduct, :profile => profile)]})
end
def defaults_for_delivery_plugin_method
{:profile => build(OrdersCyclePlugin::Profile),
:name => "My delivery #{factory_num_seq.to_s}",
:delivery_type => 'deliver'}
end
def defaults_for_delivery_plugin_option
{:cycle => build(OrdersCyclePlugin::Cycle),
:delivery_method => build(DeliveryPlugin::Method)}
end
def defaults_for_orders_plugin_order attrs = {}
profile = attrs[:profile] || build(OrdersCyclePlugin::Profile)
{:status => 'ordered',
:cycle => build(OrdersCyclePlugin::Cycle, :profile => profile),
:consumer => build(OrdersCyclePlugin::Profile),
:supplier_delivery => build(DeliveryPlugin::Method, :profile => profile),
:consumer_delivery => build(DeliveryPlugin::Method, :profile => profile)}
end
def defaults_for_orders_plugin_items
{:order => build(OrdersPlugin::Order),
:product => build(OrdersCyclePlugin::OfferedProduct),
:quantity_shipped => 1.0, :quantity_ordered => 2.0, :quantity_accepted => 3.0,
:price_shipped => 10.0, :price_ordered => 20.0, :price_accepted => 30.0}
end
def defaults_for_orders_cycle_plugin_cycle
{:profile => build(OrdersCyclePlugin::Profile), :status => 'orders',
:name => 'weekly', :start => Time.now, :finish => Time.now+1.days}
end
end
Noosfero::Factory.register_extension OrdersCyclePlugin::Factory