stbaldricks 12.14.0.alpha.1 → 12.14.0.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/lib/stbaldricks/configuration.rb +2 -2
  3. data/lib/stbaldricks/default_logger.rb +2 -2
  4. data/lib/stbaldricks/endpoints/blog_post.rb +8 -8
  5. data/lib/stbaldricks/endpoints/communicate.rb +1 -1
  6. data/lib/stbaldricks/endpoints/config.rb +1 -1
  7. data/lib/stbaldricks/endpoints/deduplicator_match.rb +2 -2
  8. data/lib/stbaldricks/endpoints/kid.rb +1 -1
  9. data/lib/stbaldricks/endpoints/lib/entity.rb +11 -13
  10. data/lib/stbaldricks/endpoints/newsletter_recipient.rb +5 -11
  11. data/lib/stbaldricks/endpoints/participant.rb +3 -3
  12. data/lib/stbaldricks/endpoints/photo.rb +4 -5
  13. data/lib/stbaldricks/endpoints/search.rb +2 -2
  14. data/lib/stbaldricks/endpoints/user.rb +1 -1
  15. data/lib/stbaldricks/entities/batch.rb +5 -3
  16. data/lib/stbaldricks/entities/blog_post.rb +7 -1
  17. data/lib/stbaldricks/entities/campaign.rb +13 -6
  18. data/lib/stbaldricks/entities/challenge.rb +6 -4
  19. data/lib/stbaldricks/entities/challenger.rb +6 -4
  20. data/lib/stbaldricks/entities/concerns/entity_response_concern.rb +1 -1
  21. data/lib/stbaldricks/entities/config.rb +8 -3
  22. data/lib/stbaldricks/entities/contact.rb +7 -4
  23. data/lib/stbaldricks/entities/contact_group.rb +2 -2
  24. data/lib/stbaldricks/entities/deduplicator_history.rb +6 -1
  25. data/lib/stbaldricks/entities/deduplicator_match.rb +7 -4
  26. data/lib/stbaldricks/entities/disease.rb +5 -2
  27. data/lib/stbaldricks/entities/document_library.rb +8 -3
  28. data/lib/stbaldricks/entities/document_library_category.rb +4 -1
  29. data/lib/stbaldricks/entities/donation.rb +18 -12
  30. data/lib/stbaldricks/entities/donor.rb +5 -1
  31. data/lib/stbaldricks/entities/event.rb +44 -33
  32. data/lib/stbaldricks/entities/event_application.rb +10 -6
  33. data/lib/stbaldricks/entities/event_donation_summary.rb +5 -2
  34. data/lib/stbaldricks/entities/event_participant_summary.rb +3 -1
  35. data/lib/stbaldricks/entities/event_supporter.rb +3 -3
  36. data/lib/stbaldricks/entities/fund.rb +23 -6
  37. data/lib/stbaldricks/entities/fundraiser.rb +29 -16
  38. data/lib/stbaldricks/entities/grant.rb +25 -12
  39. data/lib/stbaldricks/entities/institution.rb +4 -3
  40. data/lib/stbaldricks/entities/international_partner.rb +16 -4
  41. data/lib/stbaldricks/entities/kid.rb +28 -11
  42. data/lib/stbaldricks/entities/kid_honor.rb +0 -1
  43. data/lib/stbaldricks/entities/kid_institution.rb +2 -2
  44. data/lib/stbaldricks/entities/lib/address.rb +6 -3
  45. data/lib/stbaldricks/entities/lib/alternate_shipping_address.rb +3 -1
  46. data/lib/stbaldricks/entities/lib/base.rb +39 -47
  47. data/lib/stbaldricks/entities/lib/collection.rb +2 -2
  48. data/lib/stbaldricks/entities/lib/email_address.rb +2 -1
  49. data/lib/stbaldricks/entities/lib/fundraising_page.rb +2 -1
  50. data/lib/stbaldricks/entities/lib/location.rb +0 -1
  51. data/lib/stbaldricks/entities/lib/milestone.rb +3 -1
  52. data/lib/stbaldricks/entities/lib/name.rb +2 -2
  53. data/lib/stbaldricks/entities/lib/not_implemented_object.rb +1 -1
  54. data/lib/stbaldricks/entities/lib/permissions.rb +4 -2
  55. data/lib/stbaldricks/entities/lib/phone.rb +3 -2
  56. data/lib/stbaldricks/entities/lib/third_party_media.rb +5 -1
  57. data/lib/stbaldricks/entities/lib/top_level.rb +1 -1
  58. data/lib/stbaldricks/entities/matching_gift_company.rb +39 -16
  59. data/lib/stbaldricks/entities/memorial.rb +14 -9
  60. data/lib/stbaldricks/entities/message.rb +15 -4
  61. data/lib/stbaldricks/entities/organization.rb +17 -11
  62. data/lib/stbaldricks/entities/page.rb +17 -9
  63. data/lib/stbaldricks/entities/participant.rb +28 -18
  64. data/lib/stbaldricks/entities/participant_donation_summary.rb +4 -2
  65. data/lib/stbaldricks/entities/person.rb +31 -22
  66. data/lib/stbaldricks/entities/person_donation_by_year_summary.rb +2 -1
  67. data/lib/stbaldricks/entities/photo.rb +11 -5
  68. data/lib/stbaldricks/entities/recurring_gift.rb +18 -10
  69. data/lib/stbaldricks/entities/response.rb +0 -1
  70. data/lib/stbaldricks/entities/search.rb +168 -30
  71. data/lib/stbaldricks/entities/section.rb +4 -1
  72. data/lib/stbaldricks/entities/shave_schedule.rb +13 -4
  73. data/lib/stbaldricks/entities/summary.rb +7 -1
  74. data/lib/stbaldricks/entities/team.rb +16 -12
  75. data/lib/stbaldricks/entities/team_donation_summary.rb +4 -2
  76. data/lib/stbaldricks/request.rb +2 -2
  77. data/lib/stbaldricks/version.rb +1 -1
  78. data/lib/stbaldricks_factories.rb +5 -0
  79. data/spec/factories/address.rb +14 -0
  80. data/spec/factories/campaign/totals.rb +9 -0
  81. data/spec/factories/campaign.rb +9 -0
  82. data/spec/factories/challenge.rb +19 -0
  83. data/spec/factories/challenger.rb +33 -0
  84. data/spec/factories/collection.rb +17 -0
  85. data/spec/factories/contact.rb +18 -0
  86. data/spec/factories/contact_group.rb +18 -0
  87. data/spec/factories/diagnosis.rb +12 -0
  88. data/spec/factories/disease.rb +11 -0
  89. data/spec/factories/donation/participant.rb +27 -0
  90. data/spec/factories/donation.rb +68 -0
  91. data/spec/factories/donor.rb +13 -0
  92. data/spec/factories/email_address.rb +11 -0
  93. data/spec/factories/error.rb +9 -0
  94. data/spec/factories/event/coach_tracking/coaching_interactions.rb +12 -0
  95. data/spec/factories/event/coach_tracking/plaque.rb +12 -0
  96. data/spec/factories/event/coach_tracking/proceeds.rb +12 -0
  97. data/spec/factories/event/coach_tracking.rb +18 -0
  98. data/spec/factories/event/contacts/contact.rb +17 -0
  99. data/spec/factories/event/contacts/name_pieces.rb +12 -0
  100. data/spec/factories/event/contacts.rb +16 -0
  101. data/spec/factories/event/photos.rb +12 -0
  102. data/spec/factories/event/totals.rb +15 -0
  103. data/spec/factories/event/venue/location.rb +18 -0
  104. data/spec/factories/event/venue/social.rb +16 -0
  105. data/spec/factories/event/venue.rb +16 -0
  106. data/spec/factories/event.rb +66 -0
  107. data/spec/factories/event_application.rb +34 -0
  108. data/spec/factories/event_supporter.rb +19 -0
  109. data/spec/factories/fund.rb +18 -0
  110. data/spec/factories/fundraiser/photos.rb +12 -0
  111. data/spec/factories/fundraiser/policies.rb +11 -0
  112. data/spec/factories/fundraiser/totals.rb +11 -0
  113. data/spec/factories/fundraiser.rb +24 -0
  114. data/spec/factories/fundraising_page.rb +29 -0
  115. data/spec/factories/grant.rb +22 -0
  116. data/spec/factories/grant_institution.rb +17 -0
  117. data/spec/factories/institution.rb +18 -0
  118. data/spec/factories/kid/custom_institution.rb +12 -0
  119. data/spec/factories/kid.rb +58 -0
  120. data/spec/factories/kid_honor.rb +16 -0
  121. data/spec/factories/kid_institution.rb +23 -0
  122. data/spec/factories/lib/faker_patch.rb +27 -0
  123. data/spec/factories/lib/helpers.rb +7 -0
  124. data/spec/factories/location.rb +17 -0
  125. data/spec/factories/memorial/photos.rb +14 -0
  126. data/spec/factories/memorial/totals.rb +11 -0
  127. data/spec/factories/memorial/tribute.rb +19 -0
  128. data/spec/factories/memorial.rb +22 -0
  129. data/spec/factories/message.rb +31 -0
  130. data/spec/factories/milestone.rb +15 -0
  131. data/spec/factories/name_pieces.rb +24 -0
  132. data/spec/factories/newsletter_recipient.rb +13 -0
  133. data/spec/factories/organization/addresses.rb +16 -0
  134. data/spec/factories/organization/email_addresses.rb +14 -0
  135. data/spec/factories/organization/phone_numbers.rb +14 -0
  136. data/spec/factories/organization.rb +34 -0
  137. data/spec/factories/page.rb +5 -0
  138. data/spec/factories/participant/photos.rb +14 -0
  139. data/spec/factories/participant/policies.rb +12 -0
  140. data/spec/factories/participant/rankings/ranking.rb +12 -0
  141. data/spec/factories/participant/rankings.rb +16 -0
  142. data/spec/factories/participant/roles/role.rb +154 -0
  143. data/spec/factories/participant/roles.rb +37 -0
  144. data/spec/factories/participant/totals.rb +11 -0
  145. data/spec/factories/participant.rb +95 -0
  146. data/spec/factories/payment.rb +13 -0
  147. data/spec/factories/permissions.rb +12 -0
  148. data/spec/factories/person/addresses.rb +16 -0
  149. data/spec/factories/person/email_addresses.rb +14 -0
  150. data/spec/factories/person/phone_numbers.rb +14 -0
  151. data/spec/factories/person/policies.rb +13 -0
  152. data/spec/factories/person.rb +22 -0
  153. data/spec/factories/phone.rb +11 -0
  154. data/spec/factories/photo.rb +11 -0
  155. data/spec/factories/photos.rb +9 -0
  156. data/spec/factories/recurring_gift.rb +22 -0
  157. data/spec/factories/researcher.rb +15 -0
  158. data/spec/factories/response.rb +38 -0
  159. data/spec/factories/search_event.rb +19 -0
  160. data/spec/factories/search_fundraiser.rb +15 -0
  161. data/spec/factories/search_kid.rb +13 -0
  162. data/spec/factories/search_participant.rb +15 -0
  163. data/spec/factories/search_team.rb +13 -0
  164. data/spec/factories/shave_schedule/time_selection_permissions.rb +12 -0
  165. data/spec/factories/shave_schedule.rb +33 -0
  166. data/spec/factories/team/photos.rb +12 -0
  167. data/spec/factories/team/rankings/ranking.rb +12 -0
  168. data/spec/factories/team/rankings.rb +15 -0
  169. data/spec/factories/team/totals.rb +14 -0
  170. data/spec/factories/team.rb +43 -0
  171. data/spec/factories/third_party_media.rb +12 -0
  172. data/spec/factories/treatment_status.rb +10 -0
  173. data/spec/factories/user.rb +14 -0
  174. data/spec/factories/venue.rb +15 -0
  175. metadata +275 -81
@@ -0,0 +1,12 @@
1
+ FactoryBot.define do
2
+ factory :participant_policies, class: SBF::Client::Participant::Policies do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ is_waiver_policy_accepted { true }
10
+ is_razor_policy_accepted { true }
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ FactoryBot.define do
2
+ factory :participant_rankings_ranking, class: SBF::Client::Participant::Rankings::Ranking do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ rank { 5 }
10
+ total { 10 }
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :participant_rankings, class: SBF::Client::Participant::Rankings do
5
+ skip_create
6
+
7
+ initialize_with do
8
+ new(attributes)
9
+ end
10
+
11
+ after :build do |rankings, evaluator|
12
+ rankings.send(:team=, build(:participant_rankings_ranking)) if unpopulated?(evaluator, :team)
13
+ rankings.send(:event=, build(:participant_rankings_ranking)) if unpopulated?(evaluator, :event)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,154 @@
1
+ require_relative '../../lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :participant_roles_shavee, class: SBF::Client::Participant::Roles::Shavee do
5
+ skip_create
6
+
7
+ initialize_with do
8
+ new(attributes)
9
+ end
10
+
11
+ after :build do |role, evaluator|
12
+ role.status = SBF::Client::Participant::Roles::Status::ACTIVE if unpopulated?(evaluator, :status)
13
+ role.requested_shavee_packet = false if unpopulated?(evaluator, :requested_shavee_packet)
14
+ end
15
+ end
16
+
17
+ factory :participant_roles_event_support_volunteer, class: SBF::Client::Participant::Roles::EventSupportVolunteer do
18
+ skip_create
19
+
20
+ initialize_with do
21
+ new(attributes)
22
+ end
23
+
24
+ after :build do |role, evaluator|
25
+ role.status = SBF::Client::Participant::Roles::Status::ACTIVE if unpopulated?(evaluator, :status)
26
+ end
27
+ end
28
+
29
+ factory :participant_roles_individual_fundraiser, class: SBF::Client::Participant::Roles::IndividualFundraiser do
30
+ skip_create
31
+
32
+ initialize_with do
33
+ new(attributes)
34
+ end
35
+
36
+ after :build do |role, evaluator|
37
+ role.status = SBF::Client::Participant::Roles::Status::ACTIVE if unpopulated?(evaluator, :status)
38
+ end
39
+ end
40
+
41
+ factory :participant_roles_barber_coordinator, class: SBF::Client::Participant::Roles::BarberCoordinator do
42
+ skip_create
43
+
44
+ initialize_with do
45
+ new(attributes)
46
+ end
47
+
48
+ after :build do |role, evaluator|
49
+ role.status = SBF::Client::Participant::Roles::Status::ACTIVE if unpopulated?(evaluator, :status)
50
+ end
51
+ end
52
+
53
+ factory :participant_roles_shavee_recruiter, class: SBF::Client::Participant::Roles::ShaveeRecruiter do
54
+ skip_create
55
+
56
+ initialize_with do
57
+ new(attributes)
58
+ end
59
+
60
+ after :build do |role, evaluator|
61
+ role.status = SBF::Client::Participant::Roles::Status::ACTIVE if unpopulated?(evaluator, :status)
62
+ end
63
+ end
64
+
65
+ factory :participant_roles_team_captain, class: SBF::Client::Participant::Roles::TeamCaptain do
66
+ skip_create
67
+
68
+ initialize_with do
69
+ new(attributes)
70
+ end
71
+
72
+ after :build do |role, evaluator|
73
+ role.status = SBF::Client::Participant::Roles::Status::ACTIVE if unpopulated?(evaluator, :status)
74
+ end
75
+ end
76
+
77
+ factory :participant_roles_organizer, class: SBF::Client::Participant::Roles::Organizer do
78
+ skip_create
79
+
80
+ initialize_with do
81
+ new(attributes)
82
+ end
83
+
84
+ after :build do |role, evaluator|
85
+ role.status = SBF::Client::Participant::Roles::Status::ACTIVE if unpopulated?(evaluator, :status)
86
+ role.policies = build(:participant_roles_organizer_role_policies) if unpopulated?(evaluator, :policies)
87
+ end
88
+ end
89
+
90
+ factory :participant_roles_treasurer, class: SBF::Client::Participant::Roles::Treasurer do
91
+ skip_create
92
+
93
+ initialize_with do
94
+ new(attributes)
95
+ end
96
+
97
+ after :build do |role, evaluator|
98
+ role.status = SBF::Client::Participant::Roles::Status::ACTIVE if unpopulated?(evaluator, :status)
99
+ end
100
+ end
101
+
102
+ factory :participant_roles_barber, class: SBF::Client::Participant::Roles::Barber do
103
+ skip_create
104
+
105
+ initialize_with do
106
+ new(attributes)
107
+ end
108
+
109
+ after :build do |role, evaluator|
110
+ role.status = SBF::Client::Participant::Roles::Status::ACTIVE if unpopulated?(evaluator, :status)
111
+ role.license = {number: 'License Number', organization: 'License Organization'}
112
+ role.salon = {name: 'Salon Name', phone: {number: '444-333-8888'}}
113
+ end
114
+ end
115
+
116
+ factory :participant_roles_lead_treasurer, class: SBF::Client::Participant::Roles::Treasurer do
117
+ skip_create
118
+
119
+ initialize_with do
120
+ new(attributes)
121
+ end
122
+
123
+ status { SBF::Client::Participant::Roles::Status::ACTIVE }
124
+ is_lead { true }
125
+ end
126
+
127
+ factory :participant_roles_lead_organizer, class: SBF::Client::Participant::Roles::Organizer do
128
+ skip_create
129
+
130
+ initialize_with do
131
+ new(attributes)
132
+ end
133
+
134
+ status { SBF::Client::Participant::Roles::Status::ACTIVE }
135
+ is_lead { true }
136
+
137
+ after :build do |organizer, evaluator|
138
+ organizer.policies = build(:participant_roles_organizer_role_policies) if unpopulated?(evaluator, :policies)
139
+ end
140
+ end
141
+
142
+ factory :participant_roles_organizer_role_policies, class: SBF::Client::Participant::Roles::Organizer::Policies do
143
+ skip_create
144
+
145
+ initialize_with do
146
+ new(attributes)
147
+ end
148
+
149
+ agreement_received_date { Time.now.to_s }
150
+ coaches_questionnaire_received_date { Time.now.to_s }
151
+ is_revenue_waiver_accepted { true }
152
+ is_host_agreement_waiver_accepted { true }
153
+ end
154
+ end
@@ -0,0 +1,37 @@
1
+ FactoryBot.define do
2
+ factory :participant_roles, class: SBF::Client::Participant::Roles do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ transient do
10
+ shavee { true }
11
+ event_support_volunteer { nil }
12
+ individual_fundraiser { nil }
13
+ shavee_recruiter { nil }
14
+ team_captain { nil }
15
+ barber_coordinator { nil }
16
+ organizer { nil }
17
+ lead_organizer { nil }
18
+ treasurer { nil }
19
+ lead_treasurer { nil }
20
+ barber { nil }
21
+ end
22
+
23
+ after :build do |roles, evaluator|
24
+ roles.shavee = build(:participant_roles_shavee) if evaluator.shavee
25
+ roles.event_support_volunteer = build(:participant_roles_event_support_volunteer) if evaluator.event_support_volunteer
26
+ roles.individual_fundraiser = build(:participant_roles_individual_fundraiser) if evaluator.individual_fundraiser
27
+ roles.shavee_recruiter = build(:participant_roles_shavee_recruiter) if evaluator.shavee_recruiter
28
+ roles.team_captain = build(:participant_roles_team_captain) if evaluator.team_captain
29
+ roles.barber_coordinator = build(:participant_roles_barber_coordinator) if evaluator.barber_coordinator
30
+ roles.organizer = build(:participant_roles_lead_organizer) if evaluator.lead_organizer
31
+ roles.organizer = build(:participant_roles_organizer) if evaluator.organizer
32
+ roles.treasurer = build(:participant_roles_treasurer) if evaluator.treasurer
33
+ roles.treasurer = build(:participant_roles_lead_treasurer) if evaluator.lead_treasurer
34
+ roles.barber = build(:participant_roles_barber) if evaluator.barber
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,11 @@
1
+ FactoryBot.define do
2
+ factory :participant_totals, class: SBF::Client::Participant::Totals do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ amount_raised { 0 }
10
+ end
11
+ end
@@ -0,0 +1,95 @@
1
+ require_relative 'lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :participant, class: SBF::Client::FullParticipant do
5
+ to_create { |it| raise "Failed to create #{it.class}: #{it.errors.details}" unless it.save }
6
+
7
+ initialize_with do
8
+ new(attributes)
9
+ end
10
+
11
+ fundraising_goal { 100 }
12
+ shave_time { Time.now.to_s }
13
+ model_type { 'person' }
14
+ fundraising_message { 'I am raising money for SBF' }
15
+ how_created { 'admin_control_panel' }
16
+
17
+ after :build do |participant, evaluator|
18
+ participant.person = build(:person) if unpopulated?(evaluator, :person)
19
+ if !unpopulated?(evaluator, :event) && evaluator.event.virtual?
20
+ participant.is_virtual = true
21
+ participant.shave_schedule = {date: Date.today + 30, time: '12:00:00'} if unpopulated?(evaluator, :shave_schedule)
22
+ end
23
+ end
24
+ end
25
+
26
+ factory :lead_organizer, class: SBF::Client::FullParticipant, parent: :participant do
27
+ after :build do |participant, evaluator|
28
+ participant.roles = build(:participant_roles, lead_organizer: true, shavee: false) if unpopulated?(evaluator, :roles)
29
+ end
30
+ end
31
+
32
+ factory :organizer, class: SBF::Client::FullParticipant, parent: :participant do
33
+ after :build do |participant, evaluator|
34
+ participant.roles = build(:participant_roles, organizer: true, shavee: false) if unpopulated?(evaluator, :roles)
35
+ end
36
+ end
37
+
38
+ factory :shavee, class: SBF::Client::FullParticipant, parent: :participant do
39
+ after :build do |participant, evaluator|
40
+ participant.roles = build(:participant_roles, shavee: true) if unpopulated?(evaluator, :roles)
41
+ end
42
+ end
43
+
44
+ factory :team_captain, class: SBF::Client::FullParticipant, parent: :participant do
45
+ after :build do |participant, evaluator|
46
+ # NOTE: The roles are being ignored on purpose. Do not change this until team create through the api works - and when
47
+ # that happens we will need to re-write the team factory. Instead we are using the move_participant_to_team route
48
+ # which will create the roles for us.
49
+ # participant.roles = build(:participant_roles, team_captain: true, shavee: true) if unpopulated?(evaluator, :roles)
50
+ participant.roles = build(:participant_roles, team_captain: false, shavee: true) if unpopulated?(evaluator, :roles)
51
+ end
52
+ end
53
+
54
+ factory :shavee_recruiter, class: SBF::Client::FullParticipant, parent: :participant do
55
+ after :build do |participant, evaluator|
56
+ participant.roles = build(:participant_roles, shavee_recruiter: true, shavee: false) if unpopulated?(evaluator, :roles)
57
+ end
58
+ end
59
+
60
+ factory :treasurer, class: SBF::Client::FullParticipant, parent: :participant do
61
+ after :build do |participant, evaluator|
62
+ participant.roles = build(:participant_roles, treasurer: true, shavee: false) if unpopulated?(evaluator, :roles)
63
+ end
64
+ end
65
+
66
+ factory :lead_treasurer, class: SBF::Client::FullParticipant, parent: :participant do
67
+ after :build do |participant, evaluator|
68
+ participant.roles = build(:participant_roles, lead_treasurer: true, shavee: false) if unpopulated?(evaluator, :roles)
69
+ end
70
+ end
71
+
72
+ factory :barber_coordinator, class: SBF::Client::FullParticipant, parent: :participant do
73
+ after :build do |participant, evaluator|
74
+ participant.roles = build(:participant_roles, barber_coordinator: true, shavee: false) if unpopulated?(evaluator, :roles)
75
+ end
76
+ end
77
+
78
+ factory :barber, class: SBF::Client::FullParticipant, parent: :participant do
79
+ after :build do |participant, evaluator|
80
+ participant.roles = build(:participant_roles, barber: true, shavee: false) if unpopulated?(evaluator, :roles)
81
+ end
82
+ end
83
+
84
+ factory :event_support_volunteer, class: SBF::Client::FullParticipant, parent: :participant do
85
+ after :build do |participant, evaluator|
86
+ participant.roles = build(:participant_roles, event_support_volunteer: true, shavee: false) if unpopulated?(evaluator, :roles)
87
+ end
88
+ end
89
+
90
+ factory :individual_fundraiser, class: SBF::Client::FullParticipant, parent: :participant do
91
+ after :build do |participant, evaluator|
92
+ participant.roles = build(:participant_roles, individual_fundraiser: true, shavee: false) if unpopulated?(evaluator, :roles)
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,13 @@
1
+ FactoryBot.define do
2
+ factory :payment, class: SBF::Client::Payment do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+ end
9
+
10
+ factory :subscription_credit_card_payment, class: SBF::Client::Payment::SubscriptionCreditCardDetails, parent: :payment do
11
+ type { SBF::Client::Payment::Type::CREDIT_CARD }
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ FactoryBot.define do
2
+ factory :permissions, class: SBF::Client::Permissions do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ is_owner { false }
10
+ permission_ids { [] }
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :person_addresses, class: SBF::Client::Person::Addresses do
5
+ skip_create
6
+
7
+ initialize_with do
8
+ new(attributes)
9
+ end
10
+
11
+ after :build do |addresses, evaluator|
12
+ addresses.primary = build(:address) if unpopulated?(evaluator, :primary)
13
+ addresses.secondary = build(:address) if unpopulated?(evaluator, :secondary)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ FactoryBot.define do
2
+ factory :person_email_addresses, class: SBF::Client::Person::EmailAddresses do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ after :build do |email_addresses|
10
+ email_addresses.primary = build(:email_address)
11
+ email_addresses.secondary = build(:email_address)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ FactoryBot.define do
2
+ factory :person_phone_numbers, class: SBF::Client::Person::PhoneNumbers do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ after :build do |phone_numbers|
10
+ phone_numbers.primary = build(:phone)
11
+ phone_numbers.secondary = build(:phone)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ FactoryBot.define do
2
+ factory :policies, class: SBF::Client::Person::Policies do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ is_photo_policy_accepted { Time.now.to_s }
10
+ background_check_date { Time.now.to_s }
11
+ background_check_url { 'http://example.com' }
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ require_relative 'lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :person, class: SBF::Client::FullPerson do
5
+ to_create { |it| raise "Failed to create #{it.class}: #{it.errors.details}" unless it.save }
6
+
7
+ initialize_with do
8
+ new(attributes)
9
+ end
10
+
11
+ after :build do |person, evaluator|
12
+ person.email_addresses = build(:person_email_addresses) if unpopulated?(evaluator, :email_addresses)
13
+ person.phone_numbers = build(:person_phone_numbers) if unpopulated?(evaluator, :phone_numbers)
14
+ person.name_pieces = build(:name_pieces) if unpopulated?(evaluator, :name_pieces)
15
+ person.policies = build(:policies) if unpopulated?(evaluator, :policies)
16
+ person.addresses = build(:person_addresses) if unpopulated?(evaluator, :addresses)
17
+ person.status = 'active' if unpopulated?(evaluator, :status)
18
+ person.type = SBF::Client::Person::Type::INDIVIDUAL if unpopulated?(evaluator, :type)
19
+ person.birthday = Faker::Date.birthday(min_age: 19, max_age: 65).to_s if unpopulated?(evaluator, :birthday)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ FactoryBot.define do
2
+ factory :phone, class: SBF::Client::Phone do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ number { "#{Faker::Number.between(from: 200, to: 999)}-#{Faker::Number.number(digits: 3)}-#{Faker::Number.number(digits: 4)}" }
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ FactoryBot.define do
2
+ factory :photo, class: SBF::Client::Photo do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ sequence(:id) { |n| n + 100 }
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ FactoryBot.define do
2
+ factory :photos, class: SBF::Client::Photos do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ require_relative 'lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :recurring_gift, class: SBF::Client::FullRecurringGift do
5
+ to_create { |it| raise "Failed to create #{it.class}: #{it.errors.details}" unless it.save }
6
+
7
+ initialize_with do
8
+ new(attributes)
9
+ end
10
+
11
+ amount { rand(10..100) }
12
+ status { SBF::Client::RecurringGift::Status::PENDING }
13
+ created_at { Date.today }
14
+ last_collected_at { Date.today }
15
+ is_unrecognized { false }
16
+
17
+ after :build do |recurring_gift, evaluator|
18
+ recurring_gift.donor = build(:person, status: SBF::Client::Person::Status::ACTIVE) if unpopulated?(evaluator, :donor)
19
+ recurring_gift.payment_details = build(:nonce_payment) if unpopulated?(evaluator, :payment_details)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ require_relative 'lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :researcher, class: SBF::Client::Grant::FullResearcher do
5
+ to_create { |it| raise "Failed to create #{it.class}: #{it.errors.details}" unless it.save }
6
+
7
+ initialize_with do
8
+ new(attributes)
9
+ end
10
+
11
+ after :build do |researcher, evaluator|
12
+ researcher.name_pieces = build(:name_pieces) if unpopulated?(evaluator, :name_pieces)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,38 @@
1
+ FactoryBot.define do
2
+ factory :response, class: SBF::Client::Api::Response do
3
+ skip_create
4
+
5
+ transient do
6
+ # allow passing in results as an argument
7
+ results { nil }
8
+ total_count { nil }
9
+ end
10
+
11
+ after :build do |response, evaluator|
12
+ # Either set data to data passed in as an arg or an empty hash if no data arg
13
+ response.data = evaluator.data || {}
14
+
15
+ # Set data[:results] to the arg results
16
+ response.data[:results] = evaluator.results if evaluator.results
17
+
18
+ # Set data[:total_count] to the arg total_count
19
+ response.data[:total_count] = evaluator.total_count if evaluator.total_count
20
+ end
21
+
22
+ http_code { 200 }
23
+ end
24
+
25
+ factory :not_found, class: SBF::Client::Api::Response do
26
+ skip_create
27
+
28
+ data { nil }
29
+ http_code { 404 }
30
+ end
31
+
32
+ factory :unavailable, class: SBF::Client::Api::Response do
33
+ skip_create
34
+
35
+ data { nil }
36
+ http_code { 503 }
37
+ end
38
+ end
@@ -0,0 +1,19 @@
1
+ FactoryBot.define do
2
+ factory :search_event, class: SBF::Client::Search::Event do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ sequence(:event_id) { |n| n + 10_000 }
10
+ event_year { 2015 }
11
+ event_title { 'My Event Title' }
12
+ event_date { '2015-05-05' }
13
+ total_donations { 12_345 }
14
+ total_participants { 5 }
15
+ total_shavees { rand(10) }
16
+ address1 { '123 Main Street' }
17
+ closed_roles { [] }
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ FactoryBot.define do
2
+ factory :search_fundraiser, class: SBF::Client::Search::Fundraiser do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ sequence(:fundraiser_id) { |n| n }
10
+ sequence(:profile_id) { |n| n + 100 }
11
+ sequence(:team_id) { |n| n + 1000 }
12
+ sequence(:event_id) { |n| n + 10_000 }
13
+ event_year { 2014 }
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ FactoryBot.define do
2
+ factory :search_kid, class: SBF::Client::Search::Kid do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ sequence(:kid_id) { |n| n }
10
+ sequence(:treatment_status_slug) { |n| "Treatment status slug #{n}" }
11
+ sequence(:treatment_status_other) { |n| "Treatment status other #{n}" }
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ FactoryBot.define do
2
+ factory :search_participant, class: SBF::Client::Search::Participant do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ sequence(:participant_id) { |n| n }
10
+ sequence(:profile_id) { |n| n + 100 }
11
+ sequence(:team_id) { |n| n + 1000 }
12
+ sequence(:event_id) { |n| n + 10_000 }
13
+ event_year { 2014 }
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ FactoryBot.define do
2
+ factory :search_team, class: SBF::Client::Search::Team do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ sequence(:team_id) { |n| n + 10_000 }
10
+ sequence(:event_id) { |n| n + 10_000 }
11
+ event_year { 2014 }
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ FactoryBot.define do
2
+ factory :shave_schedule_time_selection_permissions, class: SBF::Client::ShaveSchedule::TimeSelectionPermissions do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ shavees { [] }
10
+ team_captains { [] }
11
+ end
12
+ end