Skip to content

Instantly share code, notes, and snippets.

class Team < ApplicationRecord
has_many :users
has_many :business_industries, through: :users
belongs_to :coach, class_name: 'User'
belongs_to :leader, class_name: 'User', optional: true
belongs_to :captain, class_name: 'User', optional: true
belongs_to :social_director, class_name: 'User', optional: true
belongs_to :trainer, class_name: 'User', optional: true
belongs_to :sponsor, class_name: 'User', optional: true
Hey there,
I'm very excited to share this news: the course is finally launching!
It's been four months of work, but I'm really happy with the final product. I think I managed to distill all my best advice for creating, maintaining, and refactoring a top-notch Rails app.
As for the launch, here's everything you need to know:
Launch date
4 Get 4 - Platinum Growth Model
(This is simply a model illustrating what would happen in a perfect word when a team is started, sponsors 4, who sponsors 4, etc.. and all teams have at least 25 teammates.   This will NOT be what happens for you.  Your success or lack of depends on your personal results and your results WILL differ from this model.)
* Elite Coach:  25 members X $49 per month X 15%1st tier = $184 per month (covers dues and lunches)

* Bronze:  4 teams X 25 members X $49 per month X 20%2nd Tier = additional $980 per month (total $1,164mo or $13,968yr)

* Silver:  16 team X 25 members X $49 per month X 15%3rd Tier = additional $2,940 per month (total $4,104mo or $49,248yr)

* Gold:  64 teams X 25 members X $49 per month X 10%4th Tier = $7,840 per month (total $11,944mo or $143,328yr)

Platinum:  256 teams X 25 members. X $49 per month X 5%5th Tier = $15,680 per month (total $27,624 or $331,488yr)
5 Tier Affiliate Commissions on Team Dues - Total Payout including bonuses = 65%
RSpec.describe UsersController do
before(:each) do
sponsor = create(:user, role: 'sponsor')
@team_leader = create(:user, role: 'team leader')
@ref = create(:user, role: 'admin')
@team = create(:team, coach_id: @ref.id, leader_id: @team_leader.id, sponsor: sponsor )
end
describe '#create' do
RSpec.describe Team, :type => :model do
let(:admin) { create(:user, role: Role::ADMIN, first_name: 'Administrator') }
let(:man) { create(:user, role: Role::COACH, first_name: 'Coach') }
it "doesn't allow for more than 4 teams for a sponsor" do
create_list(:team, 4, sponsor: admin)
admin.reload
admin.sponsored_teams.build(sponsor: admin)
# So this is what I want to have happen
# first it checks if the current sponsor has 4 or more sponsored teams
# if he does it goes down to the his first sponsored coaches,
# if THAT coach has 4 or more sponsored teams it goes to the 2nd sponsored coach
def check_to_if_sponsor_count(new_team)
if new_team.sponsor.sponsored_teams.count >= 4
add_team_to_new_sponsor(new_team)
raise "full"
end
1) Team adds team to downline coach which doesnt have 4 sponsord teams
Failure/Error: expect(@coach.sponsored_teams.count).to eq(1)
expected: 1
got: 0
(compared using ==)
# ./spec/models/team_spec.rb:40:in `block (2 levels) in <top (required)>'
# -e:1:in `<main>'
class User < ApplicationRecord
has_many :sponsored_teams, class_name: 'Team', foreign_key: "sponsor_id",
inverse_of: :sponsor, before_add: :check_to_if_sponsor_count
def check_to_if_sponsor_count(new_team)
if new_team.sponsor.sponsored_teams.count >= 4
add_team_to_new_sponsor(new_team)
end
UserMailer
send email to administrators
sends welcome email to new user (FAILED - 1)
[{"created":1472916748000,"duration":3600000,"id":"fzqpxlywpbjb","name":"Midtown Tulsa OK: Connect & Learn","rsvp_limit":20,"status":"upcoming","time":1509989400000,"local_date":"2017-11-06","local_time":"11:30","updated":1488070729000,"utc_offset":-21600000,"waitlist_count":0,"yes_rsvp_count":1,"venue":{"id":24030410,"name":"Red Lobster","lat":36.09050750732422,"lon":-95.92521667480469,"repinned":false,"address_1":"4525 E 51st St","city":"Tulsa","country":"us","localized_country_name":"USA","zip":"","state":"OK"},"group":{"created":1461536091000,"name":"Midtown Tulsa, OK - Bold Networking","id":19878659,"join_mode":"approval","lat":36.04999923706055,"lon":-95.87999725341797,"urlname":"Bold-Networking-Midtown-Tulsa-OK","who":"Bold Networking Teammates","localized_location":"Tulsa, OK","region":"en_US"},"link":"https://www.meetup.com/Bold-Networking-Midtown-Tulsa-OK/events/244283509/","description":"<p>Bold Networking teams meet for professional networking and sales growth training. </p> <p><br/>Our teammates