-
Notifications
You must be signed in to change notification settings - Fork 108
Issue365 add jobs #366
base: master
Are you sure you want to change the base?
Issue365 add jobs #366
Changes from 15 commits
ada2703
a1ffefe
777af57
8543559
6f022f0
e2c5b19
a1bcd87
b9e40d6
263375b
75eed14
2c0596f
7656a81
8960e38
c85f56d
f6de002
ef27d87
d8c8336
9ea4d55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
RAILS_CONTAINER:= web | ||
DOCKER_COMPOSE:= docker-compose | ||
DOCKER:= docker | ||
RED=\033[0;31m | ||
GREEN=\032[0;32m | ||
NC=\033[0m | ||
|
||
|
||
.DELETE_ON_ERROR: | ||
.SILENT: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
ActiveAdmin.register Job do | ||
permit_params :title, :source_url, :source, :city, :state, :country, :description, :is_open, :remote | ||
|
||
index do | ||
selectable_column | ||
id_column | ||
|
||
column :title | ||
column :source_url | ||
column :source | ||
column :city | ||
column :state | ||
column :country | ||
column :description | ||
column :is_open | ||
column :remote | ||
|
||
actions | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you pls add a form for creating/updating. Here is an example: https://github.com/OperationCode/operationcode_backend/blob/master/app/admin/code_school.rb#L28-L45 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I add the form and try to add a job I get the following error: "
Should I install that gem, or are we already using something else? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hpjaj I don't see where you responded here. If @leenyburger issue has been addressed, disregard just getting visibility. |
||
|
||
form do |f| | ||
f.inputs do | ||
f.input :title | ||
f.input :source_url | ||
f.input :source | ||
f.input :city | ||
f.input :state | ||
f.input :country | ||
f.input :description | ||
f.input :is_open | ||
f.input :remote | ||
end | ||
|
||
f.actions | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Api | ||
module V1 | ||
class JobsController < ApiController | ||
def index | ||
render json: Job.is_open, status: :ok | ||
rescue StandardError => e | ||
render json: { errors: e.message }, status: :unprocessable_entity | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Job < ApplicationRecord | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does having this in the models section of the code base make it clear enough that this is separate from Sidekiq Jobs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so, yes. Though, it might be helpful to rename the background jobs from Job(s) to Worker(s). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure you don't want JobJobs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that you mention it, maybe |
||
acts_as_taggable | ||
|
||
scope :is_open, -> { where(closed_at: nil) } | ||
scope :is_closed, -> { where.not(closed_at: nil) } | ||
|
||
def self.with_tags(*args) | ||
tagged_with(args, any: true) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class CreateJobs < ActiveRecord::Migration[5.0] | ||
def change | ||
create_table :jobs do |t| | ||
t.string :title | ||
t.string :source_url | ||
t.string :source | ||
t.string :city | ||
t.string :state | ||
t.string :country | ||
t.text :description | ||
t.datetime :closed_at, default: nil | ||
t.boolean :remote, default: false | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
TeamMember.destroy_all | ||
AdminUser.destroy_all | ||
Role.destroy_all | ||
Job.destroy_all | ||
|
||
FactoryGirl.create(:user) | ||
FactoryGirl.create(:user) | ||
|
@@ -31,6 +32,9 @@ | |
Service.create!(:name => service) | ||
end | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you pls add a |
||
# Create jobs | ||
Job.create!(title: "A great job", source_url: "www.applyhere.com", source: "Company A", city: "Virginia Beach", state: "VA", country: "USA", description: "Our job is fun!", is_open: true, remote: false) | ||
|
||
# Create team members | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As well as a reporting call, i.e. https://github.com/OperationCode/operationcode_backend/blob/master/db/seeds.rb#L57-L64 |
||
SeedTeamMembers.seed_all | ||
|
||
|
@@ -53,6 +57,7 @@ | |
admin_users = AdminUser.count | ||
scholarship_count = Scholarship.count | ||
scholarship_app = ScholarshipApplication.count | ||
jobs = Job.count | ||
|
||
puts 'Seeding complete. Created:' | ||
p "#{users} users" | ||
|
@@ -62,3 +67,4 @@ | |
p "#{admin_users} admin users" | ||
p "#{scholarship_count} scholarships" | ||
p "#{scholarship_app} scholarship applications" | ||
p "#{jobs} jobs" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require 'test_helper' | ||
|
||
class Api::V1::JobsControllerTest < ActionDispatch::IntegrationTest | ||
test 'index endpoint should return job parameters in JSON format' do | ||
jobs = [] | ||
5.times do | ||
jobs << create(:job) | ||
end | ||
get api_v1_jobs_url, as: :json | ||
i = 0 | ||
response.parsed_body.each do |response| | ||
assert_equal true, response['title'] == jobs[i].title | ||
i += 1 | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FactoryGirl.define do | ||
factory :job do | ||
title Faker::Lorem.characters(7) | ||
source_url Faker::Internet.url | ||
source Faker::Lorem.characters(7) | ||
city Faker::Address.city | ||
state Faker::Address.state | ||
country Faker::Address.country | ||
description Faker::Lorem.paragraph | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the attributes being set above this comment should get assigned with block to evaluate the Faker data lazily each time the factory is used instead of at test load time. Otherwise all jobs created with this factory will have the same values. e.g. |
||
closed_at nil | ||
remote false | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'test_helper' | ||
|
||
class JobTest < ActiveSupport::TestCase | ||
setup do | ||
@job = create :job | ||
end | ||
|
||
test 'should be valid' do | ||
assert @job.valid? | ||
end | ||
|
||
test '.with_tags returns job with tag' do | ||
@job.tag_list.add('front-end') | ||
@job.save! | ||
assert_equal Job.with_tags('front-end'), [@job] | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm starting to feel odd about this.
As this gets bigger it should really be things in their own target, or in a bash script. Large makefiles with lots of distractions are hard to understand. Plus hiding tests behind a very long bash script means I can't pass in parameters to run test groups.