18
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
##############################################################################
28
##############################################################################
29
Then /^I should get account_payable and pricelist proprety$/ do
30
part = ResPartner.find(@part.id, :fields => ["property_account_payable","property_account_receivable"])
31
part.property_account_payable.should be_true
32
part.property_account_receivable.should be_true
36
##############################################################################
37
Given /^I want to create a partner named (\w+)$/ do |name|
38
@part = ResPartner.new(:name => "#{name}, #{rand.to_s[0..10]}")
39
@part.create.should be_true
42
##############################################################################
43
Then /^I copy the partner$/ do
46
##############################################################################
47
Then /^I should get a copied partner id$/ do
49
res = @part.copy() #copy function ot found
53
##############################################################################
54
Given /^I want to create a prodcut named (.*)$/ do |name|
55
@prod = ProductProduct.new(:name => "#{name}, #{rand.to_s[0..10]}")
59
##############################################################################
60
Then /^I get a product category$/ do
61
res = ProductCategory.find(:first)
63
@prod.categ_id = res.id
66
##############################################################################
67
Then /^I should get a product id$/ do
68
@prod.create.should be_true
71
##############################################################################
72
Then /^I should get property_expense_account and property_income_account proprety$/ do
73
prod = ProductProduct.find(@prod.id, :fields => ["property_account_income","property_account_expense"])
74
prod.property_account_income.should be_true
75
prod.property_account_expense.should be_true
78
##############################################################################
79
Given /^I want to create a prodcut to copy named automatedtestprodcutcopy$/ do
83
##############################################################################
84
Then /^I copy the product$/ do
22
# ##############################################################################
23
# Scenario: Sample Create a partner and test some basic stuffs
24
# ##############################################################################
25
Given /^I want to show you how to use OERPScenario$/ do
26
# Empty to pass (no need for an action)
29
# ##############################################################################
30
When /^I create a partner named (\w+)$/ do |name|
31
# Create a new partner using Ooor, and store it in a
32
# global var for the current feature
33
@partner = ResPartner.new(:name => name)
35
# Controle it has been a success
36
@partner.should be_true
39
# ##############################################################################
40
Then /^I should be able to find it by his id$/ do
41
# Find the partner by id
42
result=ResPartner.find(@partner.id)
43
# Test we get something
45
# Store it into @partner to have it for the next step
49
# ##############################################################################
50
Then /^the name should be (\w+)$/ do |name|
51
# Test the name is correct
52
@partner.name.should == name
56
# ##############################################################################
57
# Scenario: Sample using the memorizer
58
# ##############################################################################
59
Given /^I am still in the same features and not the same scenario$/ do
60
# Empty to pass (no need for an action)
63
# ##############################################################################
64
When /^I call the @partner variable I should not retrieve the partner$/ do
65
# Check it contain nothing
66
@partner.should be_false
69
# ##############################################################################
70
Given /^I take the first found partner to set @partner variable$/ do
71
@partner=ResPartner.find(:first)
72
@partner.should be_true
75
# ##############################################################################
76
Given /^I store it into the memorizer as (\w+) in order to retrieve it in another scenario$/ do |var_name|
77
# Memorize the partner in order
78
# to retrieve it again when needed in another
80
$utils.set_var(var_name,@partner)
83
# ##############################################################################
84
Given /^I call back the memorizer to retieve the (\w+) variable$/ do |var_name|
85
@Memorized_partner=$utils.get_var(var_name.strip).should be_true
88
# ##############################################################################
89
Then /^I should have the same partner as contained into @partner variable$/ do
90
@Memorized_partner.id.should == @partner.id
93
# ##############################################################################
94
# Scenario: Sample using ResPartner Helper
95
# ##############################################################################
96
Given /^I want to show you how to use the Helpers$/ do
100
# ##############################################################################
101
When /^you need to look for a supplier partner with at least one contact$/ do
105
# ##############################################################################
106
Then /^you can use one of the ResPartner helper called get_valid_partner$/ do
107
# Use the ResPartner Helper to get a partner of a certain type
108
# and with at least one address
109
@partner=ResPartner.get_valid_partner({:type=>'supplier'})
110
@partner.should be_true
113
# ##############################################################################
114
Then /^get the corresponding partner very easily$/ do
115
# Check it's a supplier
116
@partner.supplier.should be_true
117
# Check it has a contact
118
@partner.address.count.should > 0
124
# ##############################################################################
125
# Scenario: Sample using object method like validate an invoice
126
# ##############################################################################
127
Given /^I have recorded a supplier invoice of (.*) (\w+) called (\w+) using Helpers$/ do |amount, currency, name|
128
# Take first supplier partner with at least one address
129
@partner=ResPartner.get_valid_partner({:type=>'supplier'})
130
@partner.should be_true
131
# Create an invoice with a line = amount
132
@invoice=AccountInvoice.create_invoice_with_currency(name, @partner,
133
{:currency_code=>currency, :amount=>amount.to_f, :type=>'in_invoice'})
134
@invoice.should be_true
137
# ##############################################################################
138
When /^I validate the invoice using the validate button$/ do
139
# Call the 'invoice_open' method from account.invoice openobject
140
@invoice.wkf_action('invoice_open')
143
# ##############################################################################
144
Then /^I should get the invoice (\w+)$/ do |state|
145
# Take the invoice and check the state
146
@invoice.should be_true
147
@invoice.state.should == state
151
# ##############################################################################
152
# Scenario: Sample to create and rename a partner
153
# ##############################################################################
154
Given /^I have created a partner named "([^\"]*)" with the following addresses:$/ do |name, table|
155
# table is a Cucumber::Ast::Table
156
@partner = ResPartner.new(:name => name)
158
@partner.should be_true
159
table.hashes.each do |adress|
160
add = ResPartnerAddress.new(:name => adress[:name],:partner_id => @partner.id)
163
@partner = ResPartner.find(@partner.id)
164
@partner.address.count.should == table.hashes.count
167
# ##############################################################################
168
Then /^.*expect.* partner (\w+) to be "?([^"]+)"?$/ do |field,value|
169
@partner.send(field).to_s.should == value
172
# ##############################################################################
173
When /^I change the partner name to "([^\"]*)"$/ do |name|
178
# ##############################################################################
179
Then /^the partner name to be "([^\"]*)"$/ do |name|
181
@partner.name.should == name