Skip to content

Commit 67f873c

Browse files
committed
Filter opportunities by remote
1 parent fa4d66e commit 67f873c

File tree

6 files changed

+28
-4
lines changed

6 files changed

+28
-4
lines changed

app/controllers/opportunities_controller.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,15 @@ def geocode_location(location)
166166

167167
def get_jobs_for(chosen_location, tag, page)
168168
scope = Opportunity
169-
scope = scope.by_city(chosen_location) unless chosen_location.nil?
169+
170+
if chosen_location.present?
171+
if chosen_location == "Remote"
172+
scope = scope.where(remote: true)
173+
else
174+
scope = scope.by_city(chosen_location)
175+
end
176+
end
177+
170178
scope = scope.by_tag(tag) unless tag.nil?
171179
# TODO: Verify that there are no unmigrated teams
172180
scope = scope.where('team_id is not null')

app/helpers/opportunities_helper.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ def add_job_or_signin_path
99
end
1010

1111
def job_location_string(location)
12-
location == "Worldwide" ? location : "in #{location}"
12+
if location == "Worldwide"
13+
"Jobs Worldwide"
14+
elsif location == "Remote"
15+
"Remote Jobs"
16+
else
17+
"Jobs in #{location}"
18+
end
1319
end
1420

1521
def google_maps_image_url(location)

app/views/opportunities/_opportunity.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
.details
1111
%a.team-name.track{ href: friendly_team_path(opportunity.team), 'data-action' => 'view job', 'data-from' => 'jobs page', 'data-properties' => { team: opportunity.team.name, public_id: opportunity.public_id}.to_json }
1212
%h4= opportunity.team.name
13-
%p.location= (params[:location] != 'Worldwide' && params[:location]) || opportunity.locations.first
13+
%p.location= opportunity.locations.first || "Worldwide"
1414
%p.tag-line= opportunity.team.hiring_tagline || opportunity.team.about
1515
.team-avatar= link_to image_tag(opportunity.team.avatar_url), friendly_team_path(opportunity.team)

app/views/opportunities/index.html.haml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
%a.filter{ href: '/' }
1515
%h3= params[:skill].try(:titleize)
1616
%h1
17-
Jobs
1817
%span= job_location_string(params[:location].titleize)
1918
%ul.location-drop-down.hide
2019
%li

spec/controllers/opportunity_controlller_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,14 @@
1212
get :index
1313
expect(response).to render_template(['opportunities/index', 'layouts/jobs'])
1414
end
15+
16+
context "when it's filtered by remote opportunities" do
17+
before { @opportunity = Fabricate(:opportunity, remote: true, location: "Anywhere") }
18+
19+
it "should assign the remote opportunities to @jobs" do
20+
get :index, location: 'remote'
21+
expect(assigns(:jobs)).to be_include(@opportunity)
22+
end
23+
end
1524
end
1625
end

spec/fabricators/opportunity_fabricator.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
location 'San Francisco, CA'
77
cached_tags 'java, python'
88
team_id { Fabricate(:team, paid_job_posts: 1).id }
9+
remote false
10+
expires_at { Time.now + 1.year }
911
end
1012

1113
Fabricator(:job, from: :opportunity, class_name: :opportunity) do

0 commit comments

Comments
 (0)