Skip to content

Commit 1c68acd

Browse files
committed
Merged Phase 1 and Phase 2
2 parents 87d7b10 + 0f3ba8e commit 1c68acd

File tree

125 files changed

+1025
-910
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1025
-910
lines changed

Gemfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ gem 'tire'
146146

147147
group :development do
148148
gem 'better_errors'
149+
gem 'binding_of_caller'
149150
gem 'flog'
150151
gem 'fukuzatsu'
151152
gem 'guard-rspec'
@@ -157,16 +158,17 @@ group :development do
157158
end
158159

159160
group :development, :test do
161+
gem 'annotate'
160162
gem 'fabrication-rails'
161163
gem 'ffaker'
162164
gem 'jazz_hands', github: 'nixme/jazz_hands', branch: 'bring-your-own-debugger'
163165
gem 'launchy'
164166
gem 'pry-byebug'
165-
gem 'pry-rescue'
167+
#gem 'pry-rescue'
168+
#gem 'pry-stack_explorer'
166169
gem 'quiet_assets'
167-
gem 'syntax'
168-
gem 'annotate'
169170
gem 'rspec-rails'
171+
gem 'syntax'
170172
end
171173

172174
group :test do

Gemfile.lock

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,6 @@ GIT
3838
mime-types (>= 1.25, < 3.0)
3939
rest-client (~> 1.4)
4040

41-
GIT
42-
remote: https://github.com/rebelidealist/stripe-ruby-mock
43-
revision: f694a2792bf817932b3e9c4fe7ec51d00da03b4b
44-
branch: live-tests
45-
specs:
46-
stripe-ruby-mock (2.0.0)
47-
dante (>= 0.2.0)
48-
jimson-temp
49-
stripe (>= 1.15.0)
50-
5141
GEM
5242
remote: https://rubygems.org/
5343
remote: https://rails-assets.org/
@@ -350,7 +340,6 @@ GEM
350340
httpauth (0.2.1)
351341
i18n (0.6.11)
352342
inflecto (0.0.2)
353-
interception (0.5)
354343
ipaddress (0.8.0)
355344
jbuilder (2.1.3)
356345
activesupport (>= 3.0.0, < 5)
@@ -503,9 +492,6 @@ GEM
503492
pry-remote (0.1.8)
504493
pry (~> 0.9)
505494
slop (~> 3.0)
506-
pry-rescue (1.4.1)
507-
interception (>= 0.5)
508-
pry
509495
pry-stack_explorer (0.4.9.1)
510496
binding_of_caller (>= 0.7)
511497
pry (>= 0.9.11)
@@ -773,6 +759,7 @@ DEPENDENCIES
773759
awesome_print
774760
backbone-on-rails
775761
better_errors
762+
binding_of_caller
776763
bson_ext
777764
capybara
778765
capybara-screenshot
@@ -840,7 +827,6 @@ DEPENDENCIES
840827
poltergeist
841828
postgres_ext
842829
pry-byebug
843-
pry-rescue
844830
pubnub (= 0.1.9)
845831
puma
846832
querystring

Vagrantfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ $provision = 'vagrant/bootstrap.sh'
2828

2929
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
3030

31-
config.vm.box = $box
32-
config.vm.box_url = $box_url
31+
config.vm.box = box
32+
#config.vm.box_url = box_url
3333
config.vm.provision :shell do |s|
34-
s.path = $provision
34+
s.path = provision
3535
end
3636

3737
config.ssh.keep_alive = true

app/controllers/accounts_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def create
2222

2323
if @account.save_with_payment(@plan)
2424
unless @team.is_member?(current_user)
25-
@team.add_user(current_user)
25+
@team.add_member(current_user)
2626
@team.save
2727
end
2828
record_event('upgraded team')
@@ -85,7 +85,7 @@ def ensure_account_admin
8585
end
8686

8787
def determine_plan
88-
chosen_plan = params[:account].delete(:chosen_plan)
88+
chosen_plan = params[:teams_account].delete(:chosen_plan)
8989
@plan = Plan.find_by_public_id(chosen_plan)
9090
end
9191

app/controllers/team_members_controller.rb renamed to app/controllers/members_controller.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
class TeamMembersController < ApplicationController
1+
class MembersController < ApplicationController
22

33
def destroy
44
@user = User.find(params[:id])
55
return head(:forbidden) unless signed_in? && (team.admin?(current_user) || current_user == @user)
6-
team.remove_user(@user)
6+
team.remove_member(@user)
77
record_event("removed team") if !Team.where(id: team.id.to_s).exists?
88

99
if @user == current_user
@@ -20,6 +20,7 @@ def destroy
2020
end
2121

2222
private
23+
2324
def team
2425
@team ||= Team.find(params[:team_id])
2526
end
@@ -30,4 +31,4 @@ def is_email_address?(value)
3031
t = m.__send__(:tree)
3132
r &&= (t.domain.dot_atom_text.elements.size > 1)
3233
end
33-
end
34+
end

app/controllers/opportunities_controller.rb

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@ def apply
2121
end
2222

2323
def new
24-
team_id = params.permit(:team_id)[:team_id]
25-
@job = Opportunity.new(team_document_id: team_id)
24+
team_id = params[:team_id]
25+
@job = Opportunity.new(team_id: team_id)
2626
end
2727

2828
def edit
29-
3029
end
3130

3231
def create
33-
opportunity_create_params = params.require(:opportunity).permit(:name, :team_document_id, :opportunity_type, :description, :tags, :location, :link, :salary, :apply)
32+
opportunity_create_params = params.require(:opportunity).permit(:name, :team_id, :opportunity_type, :description, :tags, :location, :link, :salary, :apply)
3433
@job = Opportunity.new(opportunity_create_params)
3534
respond_to do |format|
3635
if @job.save
@@ -43,7 +42,7 @@ def create
4342
end
4443

4544
def update
46-
opportunity_update_params = params.require(:opportunity).permit(:id, :name, :team_document_id, :opportunity_type, :description, :tags, :location, :link, :salary, :apply)
45+
opportunity_update_params = params.require(:opportunity).permit(:id, :name, :team_id, :opportunity_type, :description, :tags, :location, :link, :salary, :apply)
4746
respond_to do |format|
4847
if @job.update_attributes(opportunity_update_params)
4948
format.html { redirect_to teamname_path(@team.slug), notice: "#{@job.name} updated" }
@@ -73,22 +72,30 @@ def visit
7372

7473
def index
7574
current_user.seen(:jobs) if signed_in?
76-
store_location! if !signed_in?
75+
store_location! unless signed_in?
7776
chosen_location = (params[:location] || closest_to_user(current_user)).try(:titleize)
78-
chosen_location = nil if chosen_location == "Worldwide"
79-
@page = params[:page].try(:to_i) || 1
80-
tag = params[:skill].gsub(/\-/, ' ').downcase unless params[:skill].nil?
81-
@jobs = get_jobs_for(chosen_location, tag, @page)
82-
@jobs_left = @jobs.count
83-
@jobs = @jobs.limit(20)
84-
chosen_location = "Worldwide" if chosen_location.nil?
85-
@locations = Rails.cache.fetch("job_locations_#{params[:location]}_#{params[:skill]}", expires_in: 1.hour) { Opportunity.by_tag(tag).map(&:locations).flatten.reject { |loc| loc == "Worldwide" }.push("Worldwide").uniq.compact }
77+
chosen_location = nil if chosen_location == 'Worldwide'
78+
79+
@page = params[:page].try(:to_i) || 1
80+
tag = params[:skill].gsub(/\-/, ' ').downcase unless params[:skill].nil?
81+
82+
83+
@jobs = get_jobs_for(chosen_location, tag, @page)
84+
@jobs_left = @jobs.count
85+
@jobs = @jobs.limit(20)
86+
87+
88+
89+
chosen_location = 'Worldwide' if chosen_location.nil?
90+
@locations = Rails.cache.fetch("job_locations_#{params[:location]}_#{params[:skill]}", expires_in: 1.hour) do
91+
Opportunity.by_tag(tag).map(&:locations).flatten.reject { |loc| loc == "Worldwide" }.push("Worldwide").uniq.compact
92+
end
8693
@locations.delete(chosen_location) unless @locations.frozen?
8794
params[:location] = chosen_location
88-
@lat, @lng = geocode_location(chosen_location)
95+
@lat, @lng = geocode_location(chosen_location)
8996

9097
respond_to do |format|
91-
format.html { render layout: "jobs" }
98+
format.html { render layout: 'jobs' }
9299
format.json { render json: @jobs.map(&:to_public_hash).to_json }
93100
format.js
94101
end
@@ -97,10 +104,11 @@ def index
97104

98105
def map
99106
@job_locations = all_job_locations
100-
@job_skills = all_job_skills
107+
@job_skills = all_job_skills
101108
end
102109

103110
private
111+
104112
def validate_permissions
105113
redirect_to :back unless team_admin?
106114
end
@@ -160,6 +168,8 @@ def get_jobs_for(chosen_location, tag, page)
160168
scope = Opportunity
161169
scope = scope.by_city(chosen_location) unless chosen_location.nil?
162170
scope = scope.by_tag(tag) unless tag.nil?
171+
# TODO: Verify that there are no unmigrated teams
172+
scope = scope.where('team_id is not null')
163173
scope.offset((page-1) * 20)
164174
end
165175
end

app/controllers/teams_controller.rb

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,26 @@ def followed
3939
end
4040

4141
def show
42+
4243
show_params = params.permit(:job_id, :refresh, :callback, :id, :slug)
4344

4445
respond_to do |format|
4546
format.html do
4647
@team = team_from_params(slug: show_params[:slug], id: show_params[:id])
48+
4749
return render_404 if @team.nil?
50+
4851
@team_protips = @team.trending_protips(4)
4952
@query = "team:#{@team.slug}"
5053
viewing_user.track_team_view!(@team) if viewing_user
5154
@team.viewed_by(viewing_user || session_id) unless is_admin?
5255
@job = show_params[:job_id].nil? ? @team.jobs.sample : Opportunity.with_public_id(show_params[:job_id])
56+
5357
@other_jobs = @team.jobs.reject { |job| job.id == @job.id } unless @job.nil?
5458
@job_page = show_params[:job_id].present?
5559
return render(:premium) if show_premium_page?
5660
end
61+
5762
format.json do
5863
options = { :expires_in => 5.minutes }
5964
options[:force] = true if !show_params[:refresh].blank?
@@ -104,6 +109,10 @@ def create
104109
end
105110
end
106111

112+
#def team_to_regex(team)
113+
#team.name.gsub(/ \-\./, '.*')
114+
#end
115+
107116
def edit
108117
edit_params = params.permit(:slug, :id)
109118

@@ -145,12 +154,17 @@ def update
145154
end
146155

147156
def follow
157+
158+
require 'pry'; binding.pry
159+
160+
148161
# TODO move to concern
149-
if params[:id] =~ /^[0-9A-F]{24}$/i
150-
@team = Team.find(params[:id])
151-
else
152-
@team = Team.where(slug: params[:id]).first
153-
end
162+
@team = if params[:id].present? && (params[:id].to_i rescue nil)
163+
Team.find(params[:id].to_i)
164+
else
165+
Team.where(slug: params[:id]).first
166+
end
167+
154168
if current_user.following_team?(@team)
155169
current_user.unfollow_team!(@team)
156170
else
@@ -191,7 +205,7 @@ def accept
191205

192206
@team = Team.find(accept_params[:id])
193207
if accept_params[:r] && @team.has_user_with_referral_token?(accept_params[:r])
194-
@team.add_user(current_user)
208+
@team.add_member(current_user)
195209
current_user.update_attribute(:referred_by, accept_params[:r]) if current_user.referred_by.nil?
196210
flash[:notice] = "Welcome to team #{@team.name}"
197211
record_event("accepted team invite")
@@ -268,11 +282,12 @@ def deny_join
268282

269283
protected
270284

271-
272285
def team_from_params(opts)
273-
return Team.where(slug: opts[:slug].downcase).first if opts[:slug].present?
274-
275-
Team.find(opts[:id])
286+
if opts[:slug].present?
287+
Team.where(slug: opts[:slug].downcase).first
288+
else
289+
Team.find(opts[:id])
290+
end
276291
end
277292

278293
def replace_section(section_name)
@@ -298,7 +313,7 @@ def page_based_on_rank(rank)
298313
end
299314

300315
def job_public_ids
301-
Rails.cache.fetch('all-jobs-public-ids', :expires_in => 1.hour) { Opportunity.select(:public_id).group('team_document_id, created_at, public_id').map(&:public_id) }
316+
Rails.cache.fetch('all-jobs-public-ids', :expires_in => 1.hour) { Opportunity.select(:public_id).group('team_id, created_at, public_id').map(&:public_id) }
302317
end
303318

304319
def next_job(job)

app/controllers/usernames_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ def index
55
# returns nothing if validation is run agains empty params[:id]
66
render nothing: true
77
end
8+
# TODO: Clean up the config/routes for /usernames
9+
# There is no UsernamesController#index for example. Why is there a route?
810

911
def show
1012
# allow validation to pass if it's the user's username that they're trying to validate (for edit username)

app/helpers/premium_helper.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def default_job
185185
cached_tags: 'Skilled, Awesome',
186186
tags: 'Java, TDD, Heroku',
187187
location_city: 'San Francisco, CA',
188-
team_document_id: @team.id || Team.featured.first.id
188+
team_id: @team.id || Team.featured.first.id
189189
)
190190
end
191191

@@ -220,12 +220,12 @@ def reason_description_1_or_default(team)
220220
end
221221

222222
def job_visited(job)
223-
visit_team_opportunity_path(job.team_document_id, job.id) unless job.new_record?
223+
visit_team_opportunity_path(job.team_id, job.id) unless job.new_record?
224224
end
225225

226-
def link_to_add_fields(name, f, association)
227-
new_object = f.object.class.reflect_on_association(association).klass.new
228-
fields = f.fields_for(association, new_object, child_index: "new_#{association}") do |builder|
226+
def link_to_add_fields(name, form, association)
227+
new_object = form.object.class.reflect_on_association(association).klass.new
228+
fields = form.fields_for(association, new_object, child_index: "new_#{association}") do |builder|
229229
render(association.to_s.singularize + "_fields", f: builder)
230230
end
231231
link_to_function(name, "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")")

app/helpers/teams_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def team_job_path(team)
154154
teamname_path(slug: team.slug) + "#open-positions"
155155
end
156156

157-
def edit_team_locations_path(team)
157+
def edit_s_path(team)
158158
teamname_path(slug: team.slug) + "/edit/#locations"
159159
end
160160

app/mailers/protip_mailer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def self.get_team_and_job_for(user)
9393
else
9494
teams = teams_for_user(user)
9595
teams.each do |team|
96-
best_job = team.best_positions_for(user).detect{|job| (job.team_document_id == user.team_document_id) or !already_sent?(job, user)}
96+
best_job = team.best_positions_for(user).detect{|job| (job.team_id == user.team_id) or !already_sent?(job, user)}
9797
return [team, best_job] unless best_job.nil?
9898
end
9999
end

app/mailers/weekly_digest_mailer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def get_team_and_job_for(user)
136136
else
137137
teams = teams_for_user(user)
138138
teams.each do |team|
139-
best_job = team.best_positions_for(user).detect { |job| (job.team_document_id == user.team_document_id) or !already_sent?(job, user) }
139+
best_job = team.best_positions_for(user).detect { |job| (job.team_id == user.team_id) or !already_sent?(job, user) }
140140
return [team, best_job] unless best_job.nil?
141141
end
142142
end

0 commit comments

Comments
 (0)