Skip to content

Commit

Permalink
Merge pull request #22 from CruGlobal/fix_tests
Browse files Browse the repository at this point in the history
Fix a bunch of tests (part 1)
  • Loading branch information
jbirdjavi authored Feb 6, 2025
2 parents b7cd676 + e1e5a57 commit f525463
Show file tree
Hide file tree
Showing 51 changed files with 489 additions and 478 deletions.
42 changes: 19 additions & 23 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,31 @@ APP_PORT=3000
LOGIN_REDIRECT_URI="https://localhost:3000/authcallback"

# LIGHTSPEED CONFIGS
LIGHTSPEED_AUTH_REQUEST_URL=fake
LIGHTSPEED_API_ROOT=fake
LIGHTSPEED_API_AUTH_ROOT=fake
LIGHTSPEED_API_SCOPES=fake
LIGHTSPEED_CLIENT_ID=fake
LIGHTSPEED_CLIENT_SECRET=fake
LIGHTSPEED_INITIAL_TOKEN=fake
LIGHTSPEED_AUTH_REQUEST_URL=
LIGHTSPEED_API_ROOT=
LIGHTSPEED_API_AUTH_ROOT="https://api.lightspeedapp.com/auth/oauth/token"
LIGHTSPEED_API_SCOPES=
LIGHTSPEED_CLIENT_ID=
LIGHTSPEED_CLIENT_SECRET=
LIGHTSPEED_INITIAL_TOKEN=

# GOOGLE SERVICE ACCOUNT
GOOGLE_SERVICE_ACCOUNT_KEY=fake
GOOGLE_CLIENT_ID=fake
GOOGLE_CLIENT_SECRET=fake

# POSTGRES CONFIGS
PG_HOST=
PG_USER=
PG_PASS=
GOOGLE_SERVICE_ACCOUNT_KEY=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_SHEET_ID=

# WOOCOMMERCE CONFIGS
WOO_API_KEY=fake
WOO_API_SECRET=fake
WOO_API_KEY=
WOO_API_SECRET=

# SALESFORCE CONFIGS
SF_INSTANCE_URL=fake
SF_LOGIN_URL=fake
SF_PASSWORD=fake
SF_TOKEN=fake
SF_USERNAME=fake
SF_VERSION=58.0
SF_INSTANCE_URL=
SF_LOGIN_URL=
SF_PASSWORD=
SF_TOKEN=
SF_USERNAME=
SF_VERSION=

# RAILS CONFIGS
SECRET_KEY_BASE=fake-e44d2103b8a16cec8eefbb3945cc4371f2db4b0aba02ff40d8d89cef5e85fd0e2b1e6ddb5c53f921eb05d0e2c54779b9a0f1bb2fe2cc1ee2553181dc1b3b1b1e
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
env:
BUNDLE_GEMS__CONTRIBSYS__COM: ${{ secrets.BUNDLE_GEMS__CONTRIBSYS__COM }}


- name: Set up DB
run: |
Expand All @@ -59,6 +62,9 @@ jobs:
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
env:
BUNDLE_GEMS__CONTRIBSYS__COM: ${{ secrets.BUNDLE_GEMS__CONTRIBSYS__COM }}


- name: Bundle audit
run: bundle exec bundle audit check --update ${{ vars.CVE_IGNORES && format('--ignore {0}', vars.CVE_IGNORES) }}
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ group :development, :test do
gem "faker"
gem "pry-rails"
gem "rspec-rails"
gem "simplecov-cobertura", require: false
gem "standard"
gem "webmock"
end
16 changes: 16 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ GEM
reline (>= 0.3.8)
declarative (0.0.20)
diff-lcs (1.5.1)
docile (1.4.1)
dogstatsd-ruby (5.6.3)
dotenv (3.1.6)
dotenv-rails (3.1.6)
Expand Down Expand Up @@ -452,6 +453,15 @@ GEM
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-cobertura (2.1.0)
rexml
simplecov (~> 0.19)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
snaky_hash (2.0.1)
hashie
version_gem (~> 1.1, >= 1.1.1)
Expand Down Expand Up @@ -560,6 +570,7 @@ DEPENDENCIES
sidekiq-cron
sidekiq-pro!
sidekiq-unique-jobs
simplecov-cobertura
solid_cache
standard
thruster
Expand Down Expand Up @@ -609,6 +620,7 @@ CHECKSUMS
debug (1.9.2) sha256=48e026c0852c7a10c60263e2e527968308958e266231e36d64e3efcabec7e7fc
declarative (0.0.20) sha256=8021dd6cb17ab2b61233c56903d3f5a259c5cf43c80ff332d447d395b17d9ff9
diff-lcs (1.5.1) sha256=273223dfb40685548436d32b4733aa67351769c7dea621da7d9dd4813e63ddfe
docile (1.4.1) sha256=96159be799bfa73cdb721b840e9802126e4e03dfc26863db73647204c727f21e
dogstatsd-ruby (5.6.3) sha256=9702f3ddd4dbdbf0073edc4c70ed81dd00aa53677705eaebadcde6717c003b1c
dotenv (3.1.6) sha256=7d9b2d408d2cf5e309854d54743aa381143be3f4e0c8d02e9f984d0e0e56cec1
dotenv-rails (3.1.6) sha256=e731e9f9cc3087e3ebc9e1a54421618560015c1d20c148b61089eff4b0ed3a2a
Expand Down Expand Up @@ -741,6 +753,10 @@ CHECKSUMS
sidekiq-pro (7.3.3) sha256=84d3d624aade641243544244026f56ca9a0d48cdc22e2d58263d791a747f5c08
sidekiq-unique-jobs (8.0.10) sha256=d8abed98f863b2f830a75839e8325b892e72a2fda7cf335f10540382393c950c
signet (0.19.0) sha256=537f3939f57f141f691e6069a97ec40f34fadafc4c7e5ba94edb06cf4350dd31
simplecov (0.22.0) sha256=fe2622c7834ff23b98066bb0a854284b2729a569ac659f82621fc22ef36213a5
simplecov-cobertura (2.1.0) sha256=2c6532e34df2e38a379d72cef9a05c3b16c64ce90566beebc6887801c4ad3f02
simplecov-html (0.13.1) sha256=5dab0b7ee612e60e9887ad57693832fdf4695b4c0c859eaea5f95c18791ef10b
simplecov_json_formatter (0.1.4) sha256=529418fbe8de1713ac2b2d612aa3daa56d316975d307244399fa4838c601b428
snaky_hash (2.0.1) sha256=1ac87ec157fcfe7a460e821e0cd48ae1e6f5e3e082ab520f03f31a9259dbdc31
solid_cache (1.0.6) sha256=fe1acf73fbe4a6a53620425317949082d3b99e0cfd35416106b56220fa66c311
standard (1.43.0) sha256=b2da8ab706383a8162ae850bc349e40de5acd1f2b5dfebb36d6d8ac68ab91c97
Expand Down
3 changes: 0 additions & 3 deletions app/assets/javascripts/application.js

This file was deleted.

34 changes: 15 additions & 19 deletions app/controllers/jobs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ def index
end_date = params[:end_date]

q = Job.order(updated_at: :desc).includes(:logs)
if (job_id != '')
if job_id != ""
q = q.where(id: job_id)
end
if (type != '')
q = q.where(type: type)
q = if type != ""
q.where(type: type)
else
q = q.where.not(type: ['POLL_SHEET', 'WOO_REFRESH'])
q.where.not(type: ["POLL_SHEET", "WOO_REFRESH"])
end
if (status != '')
if status != ""
q = q.where(status: status)
end
if (start_date != '')
if start_date != ""
q = q.where("start_date >= ?", start_date)
end
if (end_date != '')
if end_date != ""
q = q.where("end_date <= ?", end_date)
end
@jobs = q.paginate(page: params[:page], per_page: 10)
Expand All @@ -35,8 +35,8 @@ def index
def new
@job = Job.new
@event_options = get_event_options
@job_status = 'created'
@job_type = 'LS_EXTRACT'
@job_status = "created"
@job_type = "LS_EXTRACT"
@start_date_default = Date.today.last_week(:thursday)
@end_date_default = @start_date_default + 4.days
end
Expand All @@ -52,12 +52,8 @@ def edit

# POST /jobs
def create
# format HTML date field to postgres friendly format
start_date = "#{job_params["start_date"]}"
end_date = "#{job_params["end_date"]}"

sf_job = SFImport.new.create_job(job_params[:shop_id], start_date, end_date)
ls_job = LSExtract.new.create_job(job_params[:shop_id], start_date, end_date)
sf_job = SFImport.new.create_job(job_params[:shop_id], job_params[:start_date], job_params[:end_date])
ls_job = LSExtract.new.create_job(job_params[:shop_id], job_params[:start_date], job_params[:end_date])

SalesforceImportJob.perform_later
LightspeedExtractJob.perform_later
Expand Down Expand Up @@ -92,14 +88,14 @@ def job_params
end

def set_form_defaults
if(params[:id])
@job = Job.find(params[:id])
@job = if params[:id]
Job.find(params[:id])
else
@job = Job.new
Job.new
end
@job.start_date = @job.start_date || params[:start_date] || Date.today.last_week(:thursday)
@job.end_date = @job.end_date || params[:start_date] || @job.start_date + 4.days
@job_status = @job.status || 'created'
@job_status = @job.status || "created"
@event_options = get_event_options
@start_date_default = @job.start_date
@end_date_default = @job.end_date
Expand Down
2 changes: 0 additions & 2 deletions app/helpers/jobs_helper.rb

This file was deleted.

2 changes: 0 additions & 2 deletions app/helpers/lightspeedauth_helper.rb

This file was deleted.

2 changes: 0 additions & 2 deletions app/helpers/lightspeedinit_helper.rb

This file was deleted.

4 changes: 2 additions & 2 deletions app/models/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ class Job < ApplicationRecord
self.inheritance_column = nil
has_many :logs, foreign_key: "jobs_id", class_name: "AppLog", dependent: :destroy
enum :status, [:created, :processing, :error, :complete, :paused], prefix: true, default: :created
TYPE = ['WOO_IMPORT', 'LS_EXTRACT', 'LS_IMPORT', 'SF_IMPORT', 'WOO_REFRESH', 'POLL_SHEET']
STATUS = ['created', 'processing', 'error', 'complete', 'paused']
TYPE = ["WOO_IMPORT", "LS_EXTRACT", "LS_IMPORT", "SF_IMPORT", "WOO_REFRESH", "POLL_SHEET"]
STATUS = ["created", "processing", "error", "complete", "paused"]
end
5 changes: 1 addition & 4 deletions app/services/clean_jobs.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
class CleanJobs

def create_job()
shop = @lsh.find_shop(shop_id)
def create_job
job = Job.create(
type: "CLEAN_JOBS",
status: :created
Expand Down Expand Up @@ -54,5 +52,4 @@ def handle_job(job)
job.status_complete!
job.save!
end

end
Loading

0 comments on commit f525463

Please sign in to comment.