forked from sharetribe/sharetribe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.rb
66 lines (57 loc) · 1.81 KB
/
data.rb
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
58
59
60
61
62
63
64
65
66
module FeatureTests
module Data
module_function
def create_marketplace(payment_gateway:)
marketplace = MarketplaceService.create(
marketplace_name: "Test marketplace",
marketplace_type: "product",
marketplace_country: "us",
marketplace_language: "en",
payment_process: :preauthorize,
disable_feature_flags: true
)
if payment_gateway
TransactionService::API::Api.settings.provision(
community_id: marketplace[:id],
payment_gateway: payment_gateway,
payment_process: :preauthorize,
active: true)
end
if payment_gateway == :stripe
FeatureFlagService::API::Api.features.enable(community_id: marketplace[:id], features: [:stripe])
end
{
id: marketplace[:id],
ident: marketplace[:ident]
}
end
def create_member(username:, marketplace_id:, admin:)
u = create_user(username: username, marketplace_id: marketplace_id)
m = create_membership(user_id: u[:id], marketplace_id: marketplace_id, admin: admin)
u
end
def create_user(username:, marketplace_id:)
password = "test"
u = FactoryGirl.create(:person,
username: username,
community_id: marketplace_id,
password: password,
emails: [
FactoryGirl.build(:email, address: "#{username}@example.com")
]
)
{
id: u.id,
username: u.username,
password: password
}
end
def create_membership(user_id:, marketplace_id:, admin: false)
FactoryGirl.create(:community_membership,
person_id: user_id,
community_id: marketplace_id,
consent: "SHARETRIBE1.0",
admin: admin)
end
end
end