Skip to content

Commit

Permalink
Fixes Jobs Index Spec
Browse files Browse the repository at this point in the history
  • Loading branch information
patanj101 committed May 26, 2024
1 parent 2994a01 commit 573a43d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 27 deletions.
5 changes: 3 additions & 2 deletions app/services/category_sidebar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ def initialize(filtered_jobs, params)
@params = params

# Leaving this here as presumably we need to pass the sorted jobs to the sidebar?
@filtered_jobs = filtered_jobs.eager_load(:roles, :locations)
# @filtered_jobs = filtered_jobs.eager_load(:roles, :locations)
@filtered_jobs = Job.where(id: filtered_jobs.pluck(:id)).eager_load(:roles, :locations)
end

def build
Expand Down Expand Up @@ -54,7 +55,7 @@ def build_seniority_array

def build_location_array
results = @filtered_jobs.group(:'locations.city').count.map do |location, count|
location_id = location ? city.downcase.gsub(' ', '_') : 'remote'
location_id = location ? location.downcase.gsub(' ', '_') : 'remote'
params = location ? @params[:location]&.include?(location_id) : @params[:location]&.include?('remote')
location ||= 'Remote'

Expand Down
57 changes: 34 additions & 23 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
# PostgreSQL. Versions 9.3 and up are supported.
# PostgreSQL. Versions 9.1 and up are supported.
#
# Install the pg driver:
# gem install pg
# On macOS with Homebrew:
# On OS X with Homebrew:
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On OS X with MacPorts:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem "pg"
# gem 'pg'
#
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

# If you'd like to use the docker development setup, uncomment the three
# following lines. They will also be used for the test database.
# username: postgres
# password: password
# host: localhost

development:
<<: *default
database: cheddar_development

# The specified database role being used to connect to PostgreSQL.
# To create additional roles in PostgreSQL see `$ createuser --help`.
# When left blank, PostgreSQL will use the default role. This is
# the same name as the operating system user running Rails.
#username: cheddar
# The specified database role being used to connect to postgres.
# To create additional roles in postgres see `$ createuser --help`.
# When left blank, postgres will use the default role. This is
# the same name as the operating system user that initialized the database.
username: cheddar_development_username

# The password associated with the PostgreSQL role (username).
#password:
# The password associated with the postgres role (username).
password: cheddar_development_password

# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
#host: localhost
host: localhost

# The TCP port the server listens on. Defaults to 5432.
# If your server runs on a different port number, change accordingly.
Expand All @@ -56,26 +64,29 @@ development:
test:
<<: *default
database: cheddar_test
username: cheddar_test_username
password: cheddar_test_password
host: localhost


# As with config/credentials.yml, you never want to store sensitive information,
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password or a full connection URL as an environment
# variable when you boot the app. For example:
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
#
# If the connection URL is provided in the special DATABASE_URL environment
# variable, Rails will automatically merge its configuration values on top of
# the values provided in this file. Alternatively, you can specify a connection
# URL environment variable explicitly:
# You can use this database configuration with:
#
# production:
# url: <%= ENV["MY_APP_DATABASE_URL"] %>
#
# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full overview on how database connection configuration can be specified.
# url: <%= ENV['DATABASE_URL'] %>
#
production:
<<: *default
Expand Down
4 changes: 2 additions & 2 deletions spec/features/jobs_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

scenario "User can filter jobs by seniority" do
check('entry-level')
check('mid-level')
# check('mid-level')

This comment has been minimized.

Copy link
@patanj101

patanj101 May 26, 2024

Author Collaborator

After my improvements, only checkboxes that are present in the set of jobs are shown ... Thus only senorities presents can be checked.


expect(page).to have_content("Graduate Software Developer")
expect(page).not_to have_content("Junior Test Developer")
Expand All @@ -58,7 +58,7 @@

scenario "User can filter jobs by role" do
check('front_end')
check('data_engineer')
# check('data_engineer')

This comment has been minimized.

Copy link
@patanj101

patanj101 May 26, 2024

Author Collaborator

After my improvements, only checkboxes that are present in the set of jobs are shown ... Thus only roles present can be checked.


expect(page).to have_content("Senior UI Engineer")
expect(page).not_to have_content("Junior Test Developer")
Expand Down

0 comments on commit 573a43d

Please sign in to comment.