stbaldricks 8.1.0 → 8.2.1.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/lib/stbaldricks/endpoints/lib/entity.rb +1 -1
  3. data/lib/stbaldricks/entities/contact_group.rb +0 -1
  4. data/lib/stbaldricks/entities/lib/base.rb +6 -0
  5. data/lib/stbaldricks/entities/response.rb +2 -2
  6. data/lib/stbaldricks/patches/boolean.rb +2 -0
  7. data/lib/stbaldricks/patches/float.rb +2 -0
  8. data/lib/stbaldricks/patches/integer.rb +2 -0
  9. data/lib/stbaldricks/patches/nil.rb +2 -0
  10. data/lib/stbaldricks/patches/string.rb +2 -0
  11. data/lib/stbaldricks/version.rb +1 -1
  12. data/lib/stbaldricks_factories.rb +5 -0
  13. data/spec/factories/address.rb +14 -0
  14. data/spec/factories/campaign/totals.rb +9 -0
  15. data/spec/factories/campaign.rb +9 -0
  16. data/spec/factories/challenge.rb +19 -0
  17. data/spec/factories/challenger.rb +27 -0
  18. data/spec/factories/collection.rb +17 -0
  19. data/spec/factories/contact.rb +18 -0
  20. data/spec/factories/contact_group.rb +18 -0
  21. data/spec/factories/diagnosis.rb +12 -0
  22. data/spec/factories/disease.rb +11 -0
  23. data/spec/factories/donation/participant.rb +27 -0
  24. data/spec/factories/donation.rb +68 -0
  25. data/spec/factories/donor.rb +13 -0
  26. data/spec/factories/email_address.rb +11 -0
  27. data/spec/factories/error.rb +9 -0
  28. data/spec/factories/event/coach_tracking/coaching_interactions.rb +12 -0
  29. data/spec/factories/event/coach_tracking/plaque.rb +12 -0
  30. data/spec/factories/event/coach_tracking/proceeds.rb +12 -0
  31. data/spec/factories/event/coach_tracking.rb +18 -0
  32. data/spec/factories/event/contacts/contact.rb +17 -0
  33. data/spec/factories/event/contacts/name_pieces.rb +12 -0
  34. data/spec/factories/event/contacts.rb +16 -0
  35. data/spec/factories/event/photos.rb +12 -0
  36. data/spec/factories/event/totals.rb +15 -0
  37. data/spec/factories/event/venue/location.rb +18 -0
  38. data/spec/factories/event/venue/social.rb +16 -0
  39. data/spec/factories/event/venue.rb +16 -0
  40. data/spec/factories/event.rb +43 -0
  41. data/spec/factories/event_application.rb +34 -0
  42. data/spec/factories/event_supporter.rb +19 -0
  43. data/spec/factories/fund.rb +18 -0
  44. data/spec/factories/fundraiser/photos.rb +12 -0
  45. data/spec/factories/fundraiser/policies.rb +11 -0
  46. data/spec/factories/fundraiser/totals.rb +11 -0
  47. data/spec/factories/fundraiser.rb +24 -0
  48. data/spec/factories/fundraising_page.rb +29 -0
  49. data/spec/factories/grant.rb +22 -0
  50. data/spec/factories/grant_institution.rb +17 -0
  51. data/spec/factories/institution.rb +18 -0
  52. data/spec/factories/kid/custom_institution.rb +12 -0
  53. data/spec/factories/kid.rb +70 -0
  54. data/spec/factories/kid_honor.rb +16 -0
  55. data/spec/factories/kid_institution.rb +17 -0
  56. data/spec/factories/lib/helpers.rb +7 -0
  57. data/spec/factories/location.rb +17 -0
  58. data/spec/factories/memorial/photos.rb +14 -0
  59. data/spec/factories/memorial/totals.rb +11 -0
  60. data/spec/factories/memorial/tribute.rb +19 -0
  61. data/spec/factories/memorial.rb +22 -0
  62. data/spec/factories/message.rb +31 -0
  63. data/spec/factories/name_pieces.rb +24 -0
  64. data/spec/factories/newsletter_recipient.rb +13 -0
  65. data/spec/factories/organization/addresses.rb +16 -0
  66. data/spec/factories/organization/email_addresses.rb +14 -0
  67. data/spec/factories/organization/phone_numbers.rb +14 -0
  68. data/spec/factories/organization.rb +34 -0
  69. data/spec/factories/page.rb +5 -0
  70. data/spec/factories/participant/photos.rb +14 -0
  71. data/spec/factories/participant/policies.rb +12 -0
  72. data/spec/factories/participant/rankings/ranking.rb +12 -0
  73. data/spec/factories/participant/rankings.rb +16 -0
  74. data/spec/factories/participant/roles/role.rb +150 -0
  75. data/spec/factories/participant/roles.rb +35 -0
  76. data/spec/factories/participant/totals.rb +11 -0
  77. data/spec/factories/participant.rb +89 -0
  78. data/spec/factories/payment.rb +13 -0
  79. data/spec/factories/permissions.rb +12 -0
  80. data/spec/factories/person/addresses.rb +16 -0
  81. data/spec/factories/person/email_addresses.rb +14 -0
  82. data/spec/factories/person/phone_numbers.rb +14 -0
  83. data/spec/factories/person/policies.rb +13 -0
  84. data/spec/factories/person.rb +22 -0
  85. data/spec/factories/phone.rb +11 -0
  86. data/spec/factories/photo.rb +11 -0
  87. data/spec/factories/photos.rb +9 -0
  88. data/spec/factories/recurring_gift.rb +22 -0
  89. data/spec/factories/researcher.rb +15 -0
  90. data/spec/factories/response.rb +38 -0
  91. data/spec/factories/search_event.rb +19 -0
  92. data/spec/factories/search_fundraiser.rb +15 -0
  93. data/spec/factories/search_kid.rb +13 -0
  94. data/spec/factories/search_participant.rb +15 -0
  95. data/spec/factories/search_team.rb +13 -0
  96. data/spec/factories/shave_schedule/time_selection_permissions.rb +12 -0
  97. data/spec/factories/shave_schedule.rb +33 -0
  98. data/spec/factories/team/photos.rb +12 -0
  99. data/spec/factories/team/rankings/ranking.rb +12 -0
  100. data/spec/factories/team/rankings.rb +15 -0
  101. data/spec/factories/team/totals.rb +14 -0
  102. data/spec/factories/team.rb +43 -0
  103. data/spec/factories/third_party_media.rb +12 -0
  104. data/spec/factories/treatment_status.rb +10 -0
  105. data/spec/factories/user.rb +14 -0
  106. data/spec/factories/venue.rb +15 -0
  107. metadata +405 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 919d8ea0fb81e66c6074e1be08d6469856579b532adc11e31c0ca621209c1e46
4
- data.tar.gz: a73be6ad68968e80572caaab2f873d434e31c976eff84b6f037ac77fbf21fbd5
3
+ metadata.gz: d116a3534065666c7e6802ef0df0cb5bdf04571b280bde3b607d77f1cb39eb81
4
+ data.tar.gz: ebbc18fb80398caf1613856dd402e943bf3e0cd8f67121c23e5d1be2ba7f184a
5
5
  SHA512:
6
- metadata.gz: 0d6f6311b44a0f9906e7ce81d16f23204e2c40d2bc4534d79e40cb74a2195f2c4ac95079f6286621773efe721907e76d87a68b7f9e89dea947c125fa347e6b99
7
- data.tar.gz: 4adeb44b88ab74b43516e6473083716b55fe602830ddde8348446d6544c405074952372fd27c840e0a272187882d9278a2cc419c12b41058cc4fb40591999c7e
6
+ metadata.gz: 49b494684cc47383febbee7a8641d01f0546e74de599c125365d275c8a547cd0e3ee36b10ae043e3b366b7d5e34f684c6c604e00bdb079e6401eed3db7dbce80
7
+ data.tar.gz: ea1ccfede3938b10bdc31097f454344d99259f1b8073629de4aae6feaf13ed982c8a9df19189ea76485bda8bb9cf8ba765abb0810731c1ec4dd7a25e68045981
@@ -20,7 +20,7 @@ module SBF
20
20
  # Calls create if the id field is empty. Otherwise it calls update.
21
21
  def save(entity_or_hash, with = {})
22
22
  if entity_or_hash.is_a?(SBF::Client::BaseEntity)
23
- return create(entity_or_hash, with) if entity_or_hash.id.nil?
23
+ return create(entity_or_hash, with) if !entity_or_hash.respond_to?(:id) || entity_or_hash.id.nil?
24
24
 
25
25
  update(entity_or_hash.id, entity_or_hash, with)
26
26
  else
@@ -11,7 +11,6 @@ module SBF
11
11
  attr_accessor :id
12
12
  attr_accessor :display_name
13
13
  entity_attr_accessor :owner, 'SBF::Client::FullPerson'
14
- attr_accessor :contacts
15
14
  multitype_collection_attr_accessor(
16
15
  :contacts,
17
16
  [
@@ -71,6 +71,12 @@ module SBF
71
71
  @destroyed
72
72
  end
73
73
 
74
+ def to_partial
75
+ base_class = self.class.name.gsub(/(.*::)(Full|Partial)(.*)/, '\1')
76
+ base_name = self.class.name.gsub(/(.*::)(Full|Partial)(.*)/, '\3')
77
+ "#{base_class}Partial#{base_name}".to_class.new(to_hash)
78
+ end
79
+
74
80
  ## Returns a hash of changed data for the entity and its sub-entities
75
81
  # @param with_keys [Boolean] when true, include the keys of the current entity. (sub-entity keys will always be included if they are present)
76
82
  # @return [Hash] the changed data
@@ -19,8 +19,8 @@ module SBF
19
19
  http_code.to_s.start_with?('2')
20
20
  end
21
21
 
22
- def to_json
23
- to_hash.to_json
22
+ def to_json(opts = nil)
23
+ to_hash.to_json(opts)
24
24
  end
25
25
 
26
26
  def to_hash
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/object/blank'
2
+
1
3
  module Boolean
2
4
  def empty?
3
5
  false
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/object/blank'
2
+
1
3
  class Float
2
4
  def blank?
3
5
  false
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/object/blank'
2
+
1
3
  class Integer
2
4
  def blank?
3
5
  false
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/object/blank'
2
+
1
3
  class NilClass
2
4
  def [](_)
3
5
  nil
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/object/blank'
2
+
1
3
  class String
2
4
  SNAKE_CASE_REGEX = Regexp.new('(?<!^)([[:upper:]])|([[:upper:]])')
3
5
  ID_REGEX = Regexp.new('(^|_)i_d')
@@ -1,5 +1,5 @@
1
1
  module SBF
2
2
  module Client
3
- VERSION = '8.1.0'
3
+ VERSION = '8.2.1.alpha.1'
4
4
  end
5
5
  end
@@ -0,0 +1,5 @@
1
+ require 'stbaldricks'
2
+
3
+ project_root = File.realpath("#{File.dirname(__FILE__)}/../")
4
+ $LOAD_PATH.unshift(project_root)
5
+ Dir["#{project_root}/spec/factories/**/*.rb"].each { |file| require file }
@@ -0,0 +1,14 @@
1
+ FactoryBot.define do
2
+ factory :address, class: SBF::Client::Address do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ type { SBF::Client::Address::Type::HOME }
10
+ city { Faker::Address.city }
11
+ state { 'NE' }
12
+ country { 'US' }
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ FactoryBot.define do
2
+ factory :totals, class: SBF::Client::Campaign::Totals do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ FactoryBot.define do
2
+ factory :campaign, class: SBF::Client::FullCampaign do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ require_relative 'lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :challenge, class: SBF::Client::Challenge 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
+ status { SBF::Client::Challenge::Status::PENDING }
12
+ end_date { Date.today + 30 }
13
+
14
+ after :build do |challenge, evaluator|
15
+ challenge.challenger = build(:challenger) if unpopulated?(evaluator, :challenger)
16
+ challenge.challengee = build(:challengee) if unpopulated?(evaluator, :challengee)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ require_relative 'lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :_base_challenger, class: SBF::Client::Challenger 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 |challenger, evaluator|
12
+ if unpopulated?(evaluator, :entity)
13
+ event = create(:event)
14
+ participant = create(:shavee, event: event.to_partial)
15
+ challenger.entity = participant.to_partial
16
+ end
17
+ end
18
+ end
19
+
20
+ factory :challenger, class: SBF::Client::Challenger, parent: :_base_challenger do
21
+ is_accepted { true }
22
+ end
23
+
24
+ factory :challengee, class: SBF::Client::Challenger, parent: :_base_challenger do
25
+ is_accepted { false }
26
+ end
27
+ end
@@ -0,0 +1,17 @@
1
+ FactoryBot.define do
2
+ factory :collection, class: SBF::Client::EntityCollection do
3
+ skip_create
4
+ end
5
+
6
+ factory :collection_with_error, parent: :collection do
7
+ after :build do |collection, evaluator|
8
+ if evaluator.error
9
+ collection.add_errors(evaluator.error)
10
+ else
11
+ error = SBF::Client::ErrorEntity.new(code: 5007, type: 'BadRequest', details: 'Invalid Request')
12
+ collection.add_errors(error)
13
+ end
14
+ collection.errors_http_code = evaluator.http_code || 400
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ require_relative 'lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :contact, class: SBF::Client::CustomContact 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
+ email { Faker::Internet.email }
12
+ contact_groups { [] }
13
+
14
+ after :build do |contact_group, evaluator|
15
+ contact_group.owner = create(:person) if unpopulated?(evaluator, :owner)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require_relative 'lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :contact_group, class: SBF::Client::ContactGroup 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
+ display_name { random }
12
+ contacts { [] }
13
+
14
+ after :build do |contact_group, evaluator|
15
+ contact_group.owner = create(:person) if unpopulated?(evaluator, :owner)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ FactoryBot.define do
2
+ factory :diagnosis, class: SBF::Client::Diagnosis do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ cancer_type { SBF::Client::Diagnosis::CancerType::EWING_SARCOMA }
10
+ date { '2015-05-05' }
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ FactoryBot.define do
2
+ factory :disease, class: SBF::Client::Grant::Disease do
3
+ to_create { |it| raise "Failed to create #{it.class}: #{it.errors.details}" unless it.save }
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ name { SecureRandom.hex }
10
+ end
11
+ end
@@ -0,0 +1,27 @@
1
+ require_relative '../lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :full_donation_participant, class: SBF::Client::Donation::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
+ sequence(:display_name) { |n| "Display Name #{n}" }
14
+ model_type { 'person' }
15
+
16
+ after :build do |participant, evaluator|
17
+ participant.person = build(:person) if unpopulated?(evaluator, :person)
18
+ participant.send(:totals=, build(:participant_totals)) if unpopulated?(evaluator, :totals)
19
+ participant.send(:rankings=, build(:participant_rankings)) if unpopulated?(evaluator, :rankings)
20
+ participant.roles = build(:participant_roles) if unpopulated?(evaluator, :roles)
21
+ participant.send(:photos=, build(:participant_photos)) if unpopulated?(evaluator, :photos)
22
+ participant.event = build(:event) if unpopulated?(evaluator, :event)
23
+ participant.team = build(:team, event: participant.event) if unpopulated?(evaluator, :team)
24
+ participant.fundraising_page = build(:fundraising_page) if unpopulated?(evaluator, :fundraising_page)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,68 @@
1
+ require_relative 'lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :_donation, class: SBF::Client::FullDonation 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
+ status { SBF::Client::Donation::Status::ACTIVE }
12
+ amount { rand(10..100) }
13
+ display_name { Faker::Name.name }
14
+ year { DateTime.now.year }
15
+ fund { nil }
16
+ memorial { nil }
17
+ end
18
+
19
+ factory :donation, class: SBF::Client::FullDonation, parent: :_donation do
20
+ after :build do |donation, evaluator|
21
+ donation.payment_details = build(:cc_payment) if unpopulated?(evaluator, :payment_details)
22
+ donation.donor = build(:person) if unpopulated?(evaluator, :donor)
23
+ end
24
+ end
25
+
26
+ factory :cc_payment, class: SBF::Client::Payment::CreditCardDetails do
27
+ end
28
+
29
+ factory :cash_donation, class: SBF::Client::FullDonation, parent: :_donation do
30
+ status { SBF::Client::Donation::Status::PENDING }
31
+ how_created { SBF::Client::Donation::HowCreated::SUBMIT_CASH }
32
+
33
+ after :build do |donation, evaluator|
34
+ donation.payment_details = build(:cash_payment) if unpopulated?(evaluator, :payment_details)
35
+ donation.donor = build(:person, status: SBF::Client::Person::Status::PENDING) if unpopulated?(evaluator, :donor)
36
+ donation.submitter = build(:person) if unpopulated?(evaluator, :submitter)
37
+ end
38
+ end
39
+
40
+ factory :cash_payment, class: SBF::Client::Payment::CashDetails do
41
+ end
42
+
43
+ factory :nonce_payment, class: SBF::Client::Payment::NonceDetails do
44
+ gateway { SBF::Client::Payment::Gateway::PAYMENTSPRING }
45
+ nonce { fake_valid_nonce }
46
+ device_data { random }
47
+ end
48
+ end
49
+
50
+ require 'httparty'
51
+ require 'uri'
52
+ def fake_valid_nonce
53
+ url = "#{ENV['PAYMENTSPRING_BASE_URL']}/tokens/jsonp"
54
+ pub_key = ENV['PAYMENTSPRING_PUBLIC_KEY']
55
+ data = {
56
+ public_api_key: pub_key,
57
+ card_number: '4111111111111111',
58
+ card_exp_month: '1',
59
+ card_exp_year: Date.today.year + 1,
60
+ card_owner_name: 'John%20Doe'
61
+ }
62
+
63
+ uri = URI.parse("#{url}?#{data.to_query}")
64
+ response = HTTParty.get(uri, headers: {'Accept' => 'application/json'})
65
+ raise 'Error retrieving valid nonce' unless response.ok?
66
+
67
+ response.parsed_response['id']
68
+ end
@@ -0,0 +1,13 @@
1
+ FactoryBot.define do
2
+ factory :donor, class: SBF::Client::Donor do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ sequence(:donor_name) { |n| "donor name #{n}" }
10
+ amount { 100 }
11
+ donation_created_at { DateTime.now.to_s }
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ FactoryBot.define do
2
+ factory :email_address, class: SBF::Client::EmailAddress do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ email_address { Faker::Internet.safe_email("test.#{random}") }
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ FactoryBot.define do
2
+ factory :error, class: SBF::Client::ErrorEntity do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ FactoryBot.define do
2
+ factory :event_coach_tracking_coaching_interactions, class: SBF::Client::Event::CoachTracking::CoachingInteractions do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ introductory_conversation_date { Time.now.to_s }
10
+ post_event_conversation_date { Time.now.to_s }
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ FactoryBot.define do
2
+ factory :event_coach_tracking_plaque, class: SBF::Client::Event::CoachTracking::Plaque do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ sequence(:issued_to) { |n| "Issued To: #{n}" }
10
+ sent_date { Time.now.to_s }
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ FactoryBot.define do
2
+ factory :event_coach_tracking_proceeds, class: SBF::Client::Event::CoachTracking::Proceeds do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ received_date { Time.now.to_s }
10
+ notification_email_sent_date { Time.now.to_s }
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ FactoryBot.define do
2
+ factory :event_coach_tracking, class: SBF::Client::Event::CoachTracking do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ host_agreement_date { Time.now.to_s }
10
+ activated_date { Time.now.to_s }
11
+
12
+ after :build do |coach_tracking, _evaluator|
13
+ coach_tracking.proceeds = build(:event_coach_tracking_proceeds)
14
+ coach_tracking.coaching_interactions = build(:event_coach_tracking_coaching_interactions)
15
+ coach_tracking.plaque = build(:event_coach_tracking_plaque)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ require_relative '../../lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :event_contact, class: SBF::Client::Event::Contacts::Contact do
5
+ skip_create
6
+
7
+ initialize_with do
8
+ new(attributes)
9
+ end
10
+
11
+ after :build do |contact, evaluator|
12
+ contact.name_pieces = build(:event_contact_name_pieces) if unpopulated?(evaluator, :name_pieces)
13
+ contact.phone = build(:phone) if unpopulated?(evaluator, :phone)
14
+ contact.email_address = build(:email_address) if unpopulated?(evaluator, :email_address)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ FactoryBot.define do
2
+ factory :event_name_pieces, class: SBF::Client::Event::Contacts::NamePieces do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ first_name { 'John' }
10
+ last_name { 'Smith' }
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :event_contacts, class: SBF::Client::Event::Contacts do
5
+ skip_create
6
+
7
+ initialize_with do
8
+ new(attributes)
9
+ end
10
+
11
+ after :build do |contacts, evaluator|
12
+ contacts.primary = build(:event_contact) if unpopulated?(evaluator, :primary)
13
+ contacts.secondary = build(:event_contact) if unpopulated?(evaluator, :secondary)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ FactoryBot.define do
2
+ factory :event_photos, class: SBF::Client::Event::Photos do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ avatar { 'avatar.jpg' }
10
+ default { 'default.jpg' }
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ FactoryBot.define do
2
+ factory :event_totals, class: SBF::Client::Event::Totals do
3
+ skip_create
4
+
5
+ initialize_with do
6
+ new(attributes)
7
+ end
8
+
9
+ fundraisers { 1 }
10
+ participants { 8 }
11
+ shavees { 5 }
12
+ teams { 2 }
13
+ amount_raised { 100 }
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ require_relative '../../lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :event_venue_location, class: SBF::Client::Event::Venue::Location do
5
+ skip_create
6
+
7
+ initialize_with do
8
+ new(attributes)
9
+ end
10
+
11
+ type { SBF::Client::Event::Venue::Location::Type::OTHER }
12
+ name { Faker::University.name }
13
+
14
+ after :build do |location, evaluator|
15
+ location.address = build(:address) if unpopulated?(evaluator, :address)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../../lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :event_venue_social, class: SBF::Client::Event::Venue::Social do
5
+ skip_create
6
+
7
+ initialize_with do
8
+ new(attributes)
9
+ end
10
+
11
+ after :build do |social, evaluator|
12
+ social.facebook_url = "https://www.facebook.com/#{Faker::Internet.slug}" if unpopulated?(evaluator, :facebook_url)
13
+ social.twitter_name = "@#{Faker::Twitter.screen_name.slice(0, 14)}" if unpopulated?(evaluator, :twitter_name)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :event_venue, class: SBF::Client::Event::Venue do
5
+ skip_create
6
+
7
+ initialize_with do
8
+ new(attributes)
9
+ end
10
+
11
+ after :build do |venue, evaluator|
12
+ venue.location = build(:event_venue_location) if unpopulated?(evaluator, :location)
13
+ venue.social = build(:event_venue_social) if unpopulated?(evaluator, :social)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,43 @@
1
+ require_relative 'lib/helpers'
2
+
3
+ FactoryBot.define do
4
+ factory :event, class: SBF::Client::FullEvent do
5
+ # TODO: Hack - including organizers in the save's with should not be necessary. We should always include any dirty data
6
+ # we send to the api in the with so that we know we have the latest data. Fix and remove the with
7
+ to_create { |it| raise "Failed to create #{it.class}: #{it.errors.details}" unless it.save(organizers: nil) }
8
+
9
+ initialize_with do
10
+ new(attributes)
11
+ end
12
+
13
+ event_title { "#{Faker::Team.name} #{random}" }
14
+ year { Time.now.year }
15
+ date { Time.now.to_s }
16
+ fund_relationship_type { 'no_association' }
17
+ status { 'active' }
18
+ type { 'head_shaving' }
19
+ sub_type { 'community' }
20
+ how_created { 'admin_control_panel' }
21
+ fundraising_goal { rand(20) * 5000 }
22
+ is_private { false }
23
+
24
+ after :build do |event, evaluator|
25
+ event.venue = build(:event_venue) if unpopulated?(evaluator, :venue)
26
+ event.contacts = build(:event_contacts) if unpopulated?(evaluator, :contacts)
27
+ event.organizers = [build(:lead_organizer, person: create(:person))] if unpopulated?(evaluator, :organizers)
28
+ end
29
+ end
30
+
31
+ factory :event_activity, class: SBF::Client::Event::Activity do
32
+ skip_create
33
+
34
+ initialize_with do
35
+ new(attributes)
36
+ end
37
+
38
+ start_time { '12:00:00' }
39
+ end_time { '14:00:00' }
40
+ activity { random }
41
+ sort_order { 1 }
42
+ end
43
+ end