diff --git a/.circleci/config.yml b/.circleci/config.yml index 650bb08..2e3a42f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,12 +1,5 @@ -# DO NOT MODIFY - this is managed by Git Reduce in goro and generated from build-matrix.json -# --- version: 2.1 - -############ -## Github Actions Pipeline Params -############ - parameters: GHA_Event: type: string @@ -20,298 +13,179 @@ parameters: GHA_Meta: type: string default: "" + old_ruby: + type: string + default: "3.2.4" + current_ruby: + type: string + default: "3.3.2" + old_rails: + type: string + default: "7.0.8.4" + current_rails: + type: string + default: "7.1.3.4" jobs: generate-and-push-docs: docker: - - image: cimg/ruby:3.3.2 - auth: - username: "$DOCKERHUB_USERNAME" - password: "$DOCKERHUB_PASSWORD" + - image: cimg/ruby:3.3.2 + auth: + username: "$DOCKERHUB_USERNAME" + password: "$DOCKERHUB_PASSWORD" steps: - - checkout - - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN - - run: bundle install - - run: - name: Generate documentation - command: ' if [[ $(bundle exec rake -T docs:generate:custom) ]]; then echo - "Generating docs using rake task docs:generate:custom" ; bundle exec rake - docs:generate:custom ; elif [[ $(bundle exec rake -T docs:generate) ]]; - then echo "Generating docs using rake task docs:generate" ; bundle exec - rake docs:generate ; else echo "Skipping doc generation" ; exit 0 ; fi ' - - run: - name: Push documentation to Unwritten - command: if [[ $(bundle exec rake -T docs:push) ]]; then bundle exec rake - docs:push; fi + - checkout + - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN + - run: bundle install + - run: + name: Generate documentation + command: + ' if [[ $(bundle exec rake -T docs:generate:custom) ]]; then echo + "Generating docs using rake task docs:generate:custom" ; bundle exec rake + docs:generate:custom ; elif [[ $(bundle exec rake -T docs:generate) ]]; + then echo "Generating docs using rake task docs:generate" ; bundle exec + rake docs:generate ; else echo "Skipping doc generation" ; exit 0 ; fi ' + - run: + name: Push documentation to Unwritten + command: + if [[ $(bundle exec rake -T docs:push) ]]; then bundle exec rake + docs:push; fi release: docker: - - image: cimg/ruby:3.3.2 - auth: - username: "$DOCKERHUB_USERNAME" - password: "$DOCKERHUB_PASSWORD" - steps: - - checkout - - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN - - run: bundle install - - run: - name: Artifactory login - command: mkdir -p ~/.gem && curl -u$ARTIFACTORY_USER:$ARTIFACTORY_TOKEN https://stitchfix01.jfrog.io/stitchfix01/api/gems/eng-gems/api/v1/api_key.yaml - > ~/.gem/credentials && chmod 0600 ~/.gem/credentials - - run: - name: Build/release gem to artifactory - command: bundle exec rake push_artifactory - ruby-3_3_2-rails-7_1: - docker: - - image: cimg/ruby:3.3.2 - auth: - username: "$DOCKERHUB_USERNAME" - password: "$DOCKERHUB_PASSWORD" - environment: - BUNDLE_GEMFILE: Gemfile.rails-7.1 - working_directory: "~/stitches" - steps: - - checkout - - run: - name: Check for Gemfile.lock presence - command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see - https://github.com/stitchfix/eng-wiki/blob/main/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)" - 1>&2 ; exit 1 ; else exit 0 ; fi ' - - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN - - run: bundle install - - run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml - --format=doc - - run: - name: Run Additional CI Steps - command: if [ -e bin/additional-ci-steps ]; then bin/additional-ci-steps; - fi - - run: - name: Notify Pager Duty - command: bundle exec y-notify "#app-platform-ops" - when: on_fail - - store_test_results: - path: "/tmp/test-results" - ruby-3_2_4-rails-7_1: - docker: - - image: cimg/ruby:3.2.4 - auth: - username: "$DOCKERHUB_USERNAME" - password: "$DOCKERHUB_PASSWORD" - environment: - BUNDLE_GEMFILE: Gemfile.rails-7.1 - working_directory: "~/stitches" - steps: - - checkout - - run: - name: Check for Gemfile.lock presence - command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see - https://github.com/stitchfix/eng-wiki/blob/main/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)" - 1>&2 ; exit 1 ; else exit 0 ; fi ' - - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN - - run: bundle install - - run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml - --format=doc - - run: - name: Run Additional CI Steps - command: if [ -e bin/additional-ci-steps ]; then bin/additional-ci-steps; - fi - - run: - name: Notify Pager Duty - command: bundle exec y-notify "#app-platform-ops" - when: on_fail - - store_test_results: - path: "/tmp/test-results" - ruby-3_3_2-rails-7_0: - docker: - - image: cimg/ruby:3.3.2 - auth: - username: "$DOCKERHUB_USERNAME" - password: "$DOCKERHUB_PASSWORD" - environment: - BUNDLE_GEMFILE: Gemfile.rails-7.0 - working_directory: "~/stitches" + - image: cimg/ruby:3.3.2 + auth: + username: "$DOCKERHUB_USERNAME" + password: "$DOCKERHUB_PASSWORD" steps: - - checkout - - run: - name: Check for Gemfile.lock presence - command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see - https://github.com/stitchfix/eng-wiki/blob/main/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)" - 1>&2 ; exit 1 ; else exit 0 ; fi ' - - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN - - run: bundle install - - run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml - --format=doc - - run: - name: Run Additional CI Steps - command: if [ -e bin/additional-ci-steps ]; then bin/additional-ci-steps; - fi - - run: - name: Notify Pager Duty - command: bundle exec y-notify "#app-platform-ops" - when: on_fail - - store_test_results: - path: "/tmp/test-results" - ruby-3_2_4-rails-7_0: + - checkout + - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN + - run: bundle install + - run: + name: Artifactory login + command: + mkdir -p ~/.gem && curl -u$ARTIFACTORY_USER:$ARTIFACTORY_TOKEN https://stitchfix01.jfrog.io/stitchfix01/api/gems/eng-gems/api/v1/api_key.yaml + > ~/.gem/credentials && chmod 0600 ~/.gem/credentials + - run: + name: Build/release gem to artifactory + command: bundle exec rake push_artifactory + test: + parameters: + ruby-version: + type: string + default: "" + rails-version: + type: string + default: "" docker: - - image: cimg/ruby:3.2.4 - auth: - username: "$DOCKERHUB_USERNAME" - password: "$DOCKERHUB_PASSWORD" - environment: - BUNDLE_GEMFILE: Gemfile.rails-7.0 + - image: cimg/ruby:<< parameters.ruby-version >> + auth: + username: "$DOCKERHUB_USERNAME" + password: "$DOCKERHUB_PASSWORD" + - image: cimg/postgres:13.3 + environment: + POSTGRES_HOST_AUTH_METHOD: trust + auth: + username: "$DOCKERHUB_USERNAME" + password: "$DOCKERHUB_PASSWORD" working_directory: "~/stitches" + environment: + DATABASE_URL: "postgres://postgres:@localhost:5432/stitches_fake_app_test" steps: - - checkout - - run: - name: Check for Gemfile.lock presence - command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see - https://github.com/stitchfix/eng-wiki/blob/main/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)" - 1>&2 ; exit 1 ; else exit 0 ; fi ' - - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN - - run: bundle install - - run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml - --format=doc - - run: - name: Run Additional CI Steps - command: if [ -e bin/additional-ci-steps ]; then bin/additional-ci-steps; - fi - - run: - name: Notify Pager Duty - command: bundle exec y-notify "#app-platform-ops" - when: on_fail - - store_test_results: - path: "/tmp/test-results" - ruby-3_3_2-rails-6_1: - docker: - - image: cimg/ruby:3.3.2 - auth: - username: "$DOCKERHUB_USERNAME" - password: "$DOCKERHUB_PASSWORD" - environment: - BUNDLE_GEMFILE: Gemfile.rails-6.1 - working_directory: "~/stitches" - steps: - - checkout - - run: - name: Check for Gemfile.lock presence - command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see - https://github.com/stitchfix/eng-wiki/blob/main/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)" - 1>&2 ; exit 1 ; else exit 0 ; fi ' - - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN - - run: bundle install - - run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml - --format=doc - - run: - name: Run Additional CI Steps - command: if [ -e bin/additional-ci-steps ]; then bin/additional-ci-steps; - fi - - run: - name: Notify Pager Duty - command: bundle exec y-notify "#app-platform-ops" - when: on_fail - - store_test_results: - path: "/tmp/test-results" - ruby-3_2_4-rails-6_1: - docker: - - image: cimg/ruby:3.2.4 - auth: - username: "$DOCKERHUB_USERNAME" - password: "$DOCKERHUB_PASSWORD" - environment: - BUNDLE_GEMFILE: Gemfile.rails-6.1 - working_directory: "~/stitches" - steps: - - checkout - - run: - name: Check for Gemfile.lock presence - command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see - https://github.com/stitchfix/eng-wiki/blob/main/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)" - 1>&2 ; exit 1 ; else exit 0 ; fi ' - - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN - - run: bundle install - - run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml - --format=doc - - run: - name: Run Additional CI Steps - command: if [ -e bin/additional-ci-steps ]; then bin/additional-ci-steps; - fi - - run: - name: Notify Pager Duty - command: bundle exec y-notify "#app-platform-ops" - when: on_fail - - store_test_results: - path: "/tmp/test-results" + - checkout + - run: + name: Check for Gemfile.lock presence + command: + ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see + https://github.com/stitchfix/eng-wiki/blob/main/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)" + 1>&2 ; exit 1 ; else exit 0 ; fi ' + - run: + command: echo "ruby-<< parameters.ruby-version >>" > .ruby-version + working_directory: spec/fake_app + - run: + command: sed -i "s/gem 'rails'.*/gem 'rails', '~> << parameters.rails-version >>'/" Gemfile + working_directory: spec/fake_app + - run: + command: sed -i "s/^ruby.*/ruby '<< parameters.ruby-version >>'/" Gemfile + working_directory: spec/fake_app + - run: + command: bundle install + working_directory: spec/fake_app + - run: + command: bundle exec rake db:create db:migrate --trace + working_directory: spec/fake_app + - run: echo "gem 'rails', '~> << parameters.rails-version >>'" >> Gemfile + - run: echo "ruby-<< parameters.ruby-version >>" > .ruby-version + - run: bundle install + - run: + bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml + --format=doc + - run: + name: Run Additional CI Steps + command: + if [ -e bin/additional-ci-steps ]; then bin/additional-ci-steps; + fi + - run: + name: Notify Pager Duty + command: bundle exec y-notify "#app-platform-ops" + when: on_fail + - store_test_results: + path: "/tmp/test-results" + workflows: - version: 2 on-commit: unless: - equal: [ "schedule", << pipeline.parameters.GHA_Event >> ] + equal: ["schedule", << pipeline.parameters.GHA_Event >>] jobs: - - release: - context: org-global - requires: - - ruby-3_3_2-rails-7_1 - - ruby-3_2_4-rails-7_1 - - ruby-3_3_2-rails-7_0 - - ruby-3_2_4-rails-7_0 - - ruby-3_3_2-rails-6_1 - - ruby-3_2_4-rails-6_1 - filters: - tags: - only: "/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:(-|\\.)(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$/" - branches: - ignore: /.*/ - - generate-and-push-docs: - context: org-global - requires: - - release - filters: - tags: - only: "/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:(-|\\.)(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$/" - branches: - ignore: /.*/ - - ruby-3_3_2-rails-7_1: - context: org-global - filters: - tags: - only: &1 /.*/ - - ruby-3_2_4-rails-7_1: - context: org-global - filters: - tags: - only: *1 - - ruby-3_3_2-rails-7_0: - context: org-global - filters: - tags: - only: *1 - - ruby-3_2_4-rails-7_0: - context: org-global - filters: - tags: - only: *1 - - ruby-3_3_2-rails-6_1: - context: org-global - filters: - tags: - only: *1 - - ruby-3_2_4-rails-6_1: - context: org-global - filters: - tags: - only: *1 + - release: + context: org-global + requires: + - test + filters: + tags: + only: "/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:(-|\\.)(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$/" + branches: + ignore: /.*/ + - generate-and-push-docs: + context: org-global + requires: + - release + filters: + tags: + only: "/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:(-|\\.)(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$/" + branches: + ignore: /.*/ + - test: + matrix: + parameters: + ruby-version: + [ + "<< pipeline.parameters.old_ruby >>", + "<< pipeline.parameters.current_ruby >>", + ] + rails-version: + [ + "<< pipeline.parameters.old_rails >>", + "<< pipeline.parameters.current_rails >>", + ] + context: org-global + filters: + tags: + only: /.*/ scheduled: when: - equal: [ "schedule", << pipeline.parameters.GHA_Event >> ] + equal: ["schedule", << pipeline.parameters.GHA_Event >>] jobs: - - ruby-3_3_2-rails-7_1: - context: org-global - - ruby-3_2_4-rails-7_1: - context: org-global - - ruby-3_3_2-rails-7_0: - context: org-global - - ruby-3_2_4-rails-7_0: - context: org-global - - ruby-3_3_2-rails-6_1: - context: org-global - - ruby-3_2_4-rails-6_1: - context: org-global + - test: + context: org-global + matrix: + parameters: + ruby-version: + [ + "<< pipeline.parameters.old_ruby >>", + "<< pipeline.parameters.current_ruby >>", + ] + rails-version: + [ + "<< pipeline.parameters.old_rails >>", + "<< pipeline.parameters.current_rails >>", + ] diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..c3bf0da --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +DATABASE_URL="postgres://postgres:@localhost:5432/stitches_fake_app_development" diff --git a/.gitignore b/.gitignore index 5d807b4..e5526d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ pkg spec/reports spec/fake_app/log/ +spec/fake_app/tmp/ +spec/fake_app/db/schema.rb .vimrc *.sw? .idea/ @@ -12,3 +14,4 @@ config/database.yml Gemfile.lock Gemfile.*.lock .projections.json +*.local diff --git a/Gemfile.rails-6.1 b/Gemfile.rails-6.1 deleted file mode 100644 index 568df9a..0000000 --- a/Gemfile.rails-6.1 +++ /dev/null @@ -1,7 +0,0 @@ -# DO NOT MODIFY - this is managed by Git Reduce in goro -# -source 'https://stitchfix01.jfrog.io/stitchfix01/api/gems/eng-gems/' - -gemspec - -gem 'rails', '~> 6.1.0' diff --git a/Gemfile.rails-7.0 b/Gemfile.rails-7.0 deleted file mode 100644 index 47f3922..0000000 --- a/Gemfile.rails-7.0 +++ /dev/null @@ -1,7 +0,0 @@ -# DO NOT MODIFY - this is managed by Git Reduce in goro -# -source 'https://stitchfix01.jfrog.io/stitchfix01/api/gems/eng-gems/' - -gemspec - -gem 'rails', '~> 7.0.0' diff --git a/Gemfile.rails-7.1 b/Gemfile.rails-7.1 deleted file mode 100644 index e063ff6..0000000 --- a/Gemfile.rails-7.1 +++ /dev/null @@ -1,7 +0,0 @@ -# DO NOT MODIFY - this is managed by Git Reduce in goro -# -source 'https://stitchfix01.jfrog.io/stitchfix01/api/gems/eng-gems/' - -gemspec - -gem 'rails', '~> 7.1.0' diff --git a/README.md b/README.md index 785745a..fdeebf8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ Create Microservices in Rails by pretty much just writing regular Rails code. -![build status](https://travis-ci.org/stitchfix/stitches.svg?branch=master) - This gem provides: - transparent API key authentication. @@ -54,16 +52,16 @@ how long ago the API key was disabled. ```ruby Stitches.configure do |config| - config.disabled_key_leniency_in_seconds = 3 * 24 * 60 * 60 # Time in seconds, defaults to three days - config.disabled_key_leniency_error_log_threshold_in_seconds = 2 * 24 * 60 * 60 # Time in seconds, defaults to two days + config.disabled_key_leniency_in_seconds = 3 * 24 * 60 * 60 # Time in seconds, defaults to three days + config.disabled_key_leniency_error_log_threshold_in_seconds = 2 * 24 * 60 * 60 # Time in seconds, defaults to two days end ``` -If a disabled key is used within the `disabled_key_leniency_in_seconds`, it will be allowed. +If a disabled key is used within the `disabled_key_leniency_in_seconds`, it will be allowed. -Anytime a disabled key is used a log will be generated. If it is before the +Anytime a disabled key is used a log will be generated. If it is before the `disabled_key_leniency_error_log_threshold_in_seconds` it will be a warning log message, if it is after that, it will be -an error message. `disabled_key_leniency_error_log_threshold_in_seconds` should never be a greater number than +an error message. `disabled_key_leniency_error_log_threshold_in_seconds` should never be a greater number than `disabled_key_leniency_in_seconds`, as this provides an escallating series of warnings before finally disabling access. - If you are upgrading from a version older than 3.3.0 you need to run three generators, two of which create database diff --git a/build-matrix.json b/build-matrix.json deleted file mode 100644 index 53b6658..0000000 --- a/build-matrix.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "build_matrix": { - "dependencies": [ - "libsqlite3-dev" - ] - } -} diff --git a/lib/stitches/api_generator.rb b/lib/stitches/api_generator.rb index 149d8ad..d3f7733 100644 --- a/lib/stitches/api_generator.rb +++ b/lib/stitches/api_generator.rb @@ -18,7 +18,7 @@ def bootstrap_api gem "rspec_api_documentation" end - Bundler.with_clean_env do + Bundler.with_unbundled_env do run "bundle install" end generate "rspec:install" diff --git a/lib/stitches/railtie.rb b/lib/stitches/railtie.rb index 897c02b..85ec2cd 100644 --- a/lib/stitches/railtie.rb +++ b/lib/stitches/railtie.rb @@ -6,6 +6,5 @@ module Stitches class Railtie < Rails::Railtie config.app_middleware.use Stitches::ApiKey config.app_middleware.use Stitches::ValidMimeType - end end diff --git a/spec/fake_app/.ruby-version b/spec/fake_app/.ruby-version index c0013a8..ab96aa9 100644 --- a/spec/fake_app/.ruby-version +++ b/spec/fake_app/.ruby-version @@ -1 +1 @@ -ruby-2.7.3 +ruby-3.2.3 diff --git a/spec/fake_app/Gemfile b/spec/fake_app/Gemfile index a240ff0..d453f40 100644 --- a/spec/fake_app/Gemfile +++ b/spec/fake_app/Gemfile @@ -1,14 +1,14 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby '2.7.3' +ruby '3.2.3' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' -gem 'rails', '~> 6.1.4' -# Use sqlite3 as the database for Active Record -gem 'sqlite3', '~> 1.4' +gem 'rails', '~> 7.1.3' +# Use postgres as the database for Active Record +gem 'pg' # Use Puma as the app server -gem 'puma', '~> 5.0' +gem 'puma' # Use SCSS for stylesheets gem 'sass-rails', '>= 6' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder diff --git a/spec/fake_app/config/application.rb b/spec/fake_app/config/application.rb index 488885c..fce9952 100644 --- a/spec/fake_app/config/application.rb +++ b/spec/fake_app/config/application.rb @@ -20,7 +20,7 @@ module FakeApp class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 6.0 + config.load_defaults 7.0 # Configuration for the application, engines, and railties goes here. # diff --git a/spec/fake_app/config/database.yml b/spec/fake_app/config/database.yml index 4a8a1b2..d021412 100644 --- a/spec/fake_app/config/database.yml +++ b/spec/fake_app/config/database.yml @@ -1,25 +1,24 @@ -# SQLite. Versions 3.8.0 and up are supported. -# gem install sqlite3 -# -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem 'sqlite3' -# default: &default - adapter: sqlite3 + adapter: postgresql + encoding: unicode pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> timeout: 5000 + username: stitchfix_owner + password: + host: localhost + port: 5432 development: <<: *default - database: db/development.sqlite3 + database: stitches_fake_app_dev # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default - database: db/test.sqlite3 + database: stitches_fake_app_test production: <<: *default - database: db/production.sqlite3 + database: stitches_fake_app_production diff --git a/spec/fake_app/db/development.sqlite3 b/spec/fake_app/db/development.sqlite3 deleted file mode 100644 index 89201f2..0000000 Binary files a/spec/fake_app/db/development.sqlite3 and /dev/null differ diff --git a/spec/fake_app/db/test.sqlite3 b/spec/fake_app/db/test.sqlite3 deleted file mode 100644 index e69de29..0000000 diff --git a/spec/integration/add_to_rails_app_spec.rb b/spec/integration/add_to_rails_app_spec.rb index 5dd1a53..8f13e93 100644 --- a/spec/integration/add_to_rails_app_spec.rb +++ b/spec/integration/add_to_rails_app_spec.rb @@ -43,7 +43,7 @@ def run(command) gem_path = File.expand_path("../..", File.dirname(__FILE__)) use_local_stitches = %{echo "gem 'stitches', path: '#{gem_path}'" >> Gemfile} - Bundler.with_clean_env do + Bundler.with_unbundled_env do FileUtils.chdir work_dir do run rails_new diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index af8c57a..e700708 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,5 +1,8 @@ # frozen_string_literal: true +require 'dotenv' +Dotenv.load('.env.test.local') + # This file is copied to spec/ when you run 'rails generate rspec:install' require "rails_helper" ENV["RAILS_ENV"] ||= "test" @@ -10,8 +13,7 @@ abort("The Rails environment is running in production mode!") if Rails.env.production? require "rspec/rails" # Add additional requires below this line. Rails is not loaded until this point! - -ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:" +ActiveRecord::Base.establish_connection adapter: "postgresql", url: ENV["DATABASE_URL"] load 'fake_app/db/schema_modern.rb' diff --git a/stitches.gemspec b/stitches.gemspec index 5332d95..8dc321a 100644 --- a/stitches.gemspec +++ b/stitches.gemspec @@ -22,9 +22,10 @@ Gem::Specification.new do |s| s.add_runtime_dependency("pg") s.add_runtime_dependency("lru_redux") + s.add_development_dependency("dotenv") s.add_development_dependency("rspec", ">= 3") s.add_development_dependency("rspec-rails") - s.add_development_dependency("sqlite3") + s.add_development_dependency("pg") s.add_development_dependency("rake") s.add_development_dependency("rspec_junit_formatter") end