Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMulhern committed Aug 13, 2024
1 parent 993c0b2 commit 25ba873
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 15 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ jobs:
services:
postgres:
image: postgres:15.7
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_DB: theodinproject_test
POSTGRES_PASSWORD: "password"
ports: ["5432:5432"]
POSTGRES_PASSWORD: postgres

redis:
image: redis
Expand Down Expand Up @@ -82,14 +82,18 @@ jobs:
bin/rails css:build
- name: Setup test database
run: |
bundle exec rake parallel:create
bundle exec rake parallel:load_schema
bundle exec rake parallel:migrate
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:password@localhost:5432/theodinproject_test
run: |
bin/rails db:schema:load
POSTGRES_USERNAME: postgres
POSTGRES_PASSWORD: postgres

- name: Run tests
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:password@localhost:5432/theodinproject_test
run: bin/rspec
POSTGRES_USERNAME: postgres
POSTGRES_PASSWORD: postgres
run: bundle exec rake parallel:spec
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ end

group :development, :test do
gem 'dotenv-rails', '~> 3.1'
gem 'parallel_tests', '~> 4.7'
gem 'rspec-rails', '~> 6.1'
end

Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ GEM
orm_adapter (0.5.0)
pagy (6.5.0)
parallel (1.26.1)
parallel_tests (4.7.1)
parallel
parser (3.3.4.2)
ast (~> 2.4.1)
racc
Expand Down Expand Up @@ -630,6 +632,7 @@ DEPENDENCIES
omniauth-google-oauth2 (~> 1.1.1)
omniauth-rails_csrf_protection (~> 1.0)
pagy (~> 6.2)
parallel_tests (~> 4.7)
pg (~> 1.5)
propshaft (~> 0.9)
public_activity (~> 3.0)
Expand Down
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ development: &development
# DO NOT PUT A REAL USERNAME AND PASSWORD IN THIS FILE
test: &test
<<: *default
database: <%= ENV['POSTGRES_TEST_DB'] || 'theodinproject_test' %>
database: theodinproject_test<%= ENV['TEST_ENV_NUMBER'] %>

production:
adapter: postgresql
Expand Down
5 changes: 3 additions & 2 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@

config.action_mailer.perform_caching = false

port = 3000 + ENV.fetch('TEST_ENV_NUMBER', 1).to_i + 1
config.action_mailer.default_url_options = {
host: ENV.fetch('HOST', 'localhost'),
port: ENV.fetch('HOST_PORT', 3001)
port: ENV.fetch('HOST_PORT', port)
}
routes.default_url_options = {
host: ENV.fetch('HOST', 'localhost'),
port: ENV.fetch('HOST_PORT', 3001)
port: ENV.fetch('HOST_PORT', port)
}

# Tell Action Mailer not to deliver emails to the real world.
Expand Down
2 changes: 1 addition & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spec/services/notifications/flag_submission_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
notification_message = "OdinUser has flagged a submission on #{flagged_submission.lesson.title}\n" \
"Reason: inappropriate\n" \
"Extra: I find it offensive\n" \
'Resolve the flag here: http://localhost:3001/admin/flags/120'
"Resolve the flag here: http://localhost:#{Rails.application.routes.default_url_options[:port]}/admin/flags/120"

expect(notification.message).to eq notification_message
end
Expand Down
4 changes: 2 additions & 2 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
Capybara.configure do |config|
config.test_id = 'data-test'
config.automatic_label_click = true
config.server_port = 3001
config.app_host = 'http://localhost:3001'
config.server_port = 3000 + ENV.fetch('TEST_ENV_NUMBER', 1).to_i + 1
config.app_host = "http://localhost:#{config.server_port}"
end

Capybara.singleton_class.prepend(Module.new do
Expand Down

0 comments on commit 25ba873

Please sign in to comment.